Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <hintids.hxx>
31 : : #include <svx/svdview.hxx>
32 : : #include <svx/svdobj.hxx>
33 : : #include <svl/ptitem.hxx>
34 : : #include <editeng/sizeitem.hxx>
35 : : #include <sfx2/request.hxx>
36 : : #include <sfx2/bindings.hxx>
37 : : #include <fmtclds.hxx>
38 : : #include <frmfmt.hxx>
39 : : #include "cmdid.h"
40 : : #include "basesh.hxx"
41 : : #include "view.hxx"
42 : : #include "wrtsh.hxx"
43 : : #include "drawbase.hxx"
44 : : #include "edtwin.hxx"
45 : : #include "caption.hxx"
46 : : #include "swundo.hxx"
47 : : #include <SwRewriter.hxx>
48 : : #include "comcore.hrc"
49 : :
50 : : using namespace ::com::sun::star;
51 : :
52 : : extern sal_Bool bNoInterrupt; // in mainwn.cxx
53 : :
54 : : #define MINMOVE ((sal_uInt16)m_pSh->GetOut()->PixelToLogic(Size(m_pSh->GetDrawView()->GetMarkHdlSizePixel()/2,0)).Width())
55 : :
56 : :
57 : : /*************************************************************************
58 : : |*
59 : : |* Konstruktor
60 : : |*
61 : : \************************************************************************/
62 : :
63 : :
64 : 0 : SwDrawBase::SwDrawBase(SwWrtShell* pSwWrtShell, SwEditWin* pWindow, SwView* pSwView) :
65 : : m_pView(pSwView),
66 : : m_pSh(pSwWrtShell),
67 : : m_pWin(pWindow),
68 : : m_nSlotId(USHRT_MAX),
69 : : m_bCreateObj(sal_True),
70 : 0 : m_bInsForm(sal_False)
71 : : {
72 [ # # ]: 0 : if ( !m_pSh->HasDrawView() )
73 : 0 : m_pSh->MakeDrawView();
74 : 0 : }
75 : :
76 : : /*************************************************************************
77 : : |*
78 : : |* Destruktor
79 : : |*
80 : : \************************************************************************/
81 : :
82 : 0 : SwDrawBase::~SwDrawBase()
83 : : {
84 [ # # ]: 0 : if (m_pView->GetWrtShellPtr()) // Im view-Dtor koennte die wrtsh bereits geloescht worden sein...
85 : 0 : m_pSh->GetDrawView()->SetEditMode(sal_True);
86 [ # # ]: 0 : }
87 : :
88 : : /*************************************************************************
89 : : |*
90 : : |* MouseButtonDown-event
91 : : |*
92 : : \************************************************************************/
93 : :
94 : :
95 : 0 : sal_Bool SwDrawBase::MouseButtonDown(const MouseEvent& rMEvt)
96 : : {
97 : 0 : sal_Bool bReturn = sal_False;
98 : :
99 [ # # ]: 0 : SdrView *pSdrView = m_pSh->GetDrawView();
100 : :
101 : : // #i33136#
102 [ # # ][ # # ]: 0 : pSdrView->SetOrtho(doConstructOrthogonal() ? !rMEvt.IsShift() : rMEvt.IsShift());
103 : 0 : pSdrView->SetAngleSnapEnabled(rMEvt.IsShift());
104 : :
105 [ # # ]: 0 : if (rMEvt.IsMod2())
106 : : {
107 : 0 : pSdrView->SetCreate1stPointAsCenter(sal_True);
108 : 0 : pSdrView->SetResizeAtCenter(sal_True);
109 : : }
110 : : else
111 : : {
112 : 0 : pSdrView->SetCreate1stPointAsCenter(sal_False);
113 : 0 : pSdrView->SetResizeAtCenter(sal_False);
114 : : }
115 : :
116 [ # # ]: 0 : SdrViewEvent aVEvt;
117 [ # # ]: 0 : SdrHitKind eHit = pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
118 : :
119 : : // Nur neues Objekt, wenn nicht im Basismode (bzw reinem Selektionsmode)
120 [ # # ][ # # ]: 0 : if (rMEvt.IsLeft() && !m_pWin->IsDrawAction())
[ # # ]
121 : : {
122 [ # # ][ # # ]: 0 : if (IsCreateObj() && (eHit == SDRHIT_UNMARKEDOBJECT || eHit == SDRHIT_NONE || m_pSh->IsDrawCreate()))
[ # # ][ # # ]
[ # # ][ # # ]
123 : : {
124 : 0 : bNoInterrupt = sal_True;
125 [ # # ]: 0 : m_pWin->CaptureMouse();
126 : :
127 [ # # ]: 0 : m_aStartPos = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
128 : :
129 [ # # ]: 0 : bReturn = m_pSh->BeginCreate( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), m_aStartPos);
130 : :
131 [ # # ]: 0 : SetDrawPointer();
132 : :
133 [ # # ]: 0 : if ( bReturn )
134 : 0 : m_pWin->SetDrawAction(sal_True);
135 : : }
136 [ # # ][ # # ]: 0 : else if (!pSdrView->IsAction())
137 : : {
138 : : /**********************************************************************
139 : : * BEZIER-EDITOR
140 : : **********************************************************************/
141 [ # # ]: 0 : m_pWin->CaptureMouse();
142 [ # # ]: 0 : m_aStartPos = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
143 : 0 : sal_uInt16 nEditMode = m_pWin->GetBezierMode();
144 : :
145 [ # # ][ # # ]: 0 : if (eHit == SDRHIT_HANDLE && aVEvt.pHdl->GetKind() == HDL_BWGT)
[ # # ]
146 : : {
147 : : /******************************************************************
148 : : * Handle draggen
149 : : ******************************************************************/
150 : 0 : bNoInterrupt = sal_True;
151 [ # # ]: 0 : bReturn = pSdrView->BegDragObj(m_aStartPos, (OutputDevice*) NULL, aVEvt.pHdl);
152 : 0 : m_pWin->SetDrawAction(sal_True);
153 : : }
154 [ # # ][ # # ]: 0 : else if (eHit == SDRHIT_MARKEDOBJECT && nEditMode == SID_BEZIER_INSERT)
155 : : {
156 : : /******************************************************************
157 : : * Klebepunkt einfuegen
158 : : ******************************************************************/
159 : 0 : bNoInterrupt = sal_True;
160 [ # # ]: 0 : bReturn = pSdrView->BegInsObjPoint(m_aStartPos, rMEvt.IsMod1());
161 : 0 : m_pWin->SetDrawAction(sal_True);
162 : : }
163 [ # # ][ # # ]: 0 : else if (eHit == SDRHIT_MARKEDOBJECT && rMEvt.IsMod1())
[ # # ]
164 : : {
165 : : /******************************************************************
166 : : * Klebepunkt selektieren
167 : : ******************************************************************/
168 [ # # ]: 0 : if (!rMEvt.IsShift())
169 [ # # ]: 0 : pSdrView->UnmarkAllPoints();
170 : :
171 [ # # ]: 0 : bReturn = pSdrView->BegMarkPoints(m_aStartPos);
172 : 0 : m_pWin->SetDrawAction(sal_True);
173 : : }
174 [ # # ][ # # ]: 0 : else if (eHit == SDRHIT_MARKEDOBJECT && !rMEvt.IsShift() && !rMEvt.IsMod2())
[ # # ][ # # ]
175 : : {
176 : : /******************************************************************
177 : : * Objekt verschieben
178 : : ******************************************************************/
179 : 0 : return sal_False;
180 : : }
181 [ # # ]: 0 : else if (eHit == SDRHIT_HANDLE)
182 : : {
183 : : /******************************************************************
184 : : * Klebepunkt selektieren
185 : : ******************************************************************/
186 [ # # ][ # # ]: 0 : if (pSdrView->HasMarkablePoints() && (!pSdrView->IsPointMarked(*aVEvt.pHdl) || rMEvt.IsShift()))
[ # # ][ # # ]
[ # # ][ # # ]
187 : : {
188 : 0 : SdrHdl* pHdl = NULL;
189 : :
190 [ # # ]: 0 : if (!rMEvt.IsShift())
191 : : {
192 [ # # ]: 0 : pSdrView->UnmarkAllPoints();
193 [ # # ]: 0 : pHdl = pSdrView->PickHandle(m_aStartPos);
194 : : }
195 : : else
196 : : {
197 [ # # ][ # # ]: 0 : if (pSdrView->IsPointMarked(*aVEvt.pHdl))
198 : : {
199 [ # # ]: 0 : bReturn = pSdrView->UnmarkPoint(*aVEvt.pHdl);
200 : 0 : pHdl = NULL;
201 : : }
202 : : else
203 : : {
204 [ # # ]: 0 : pHdl = pSdrView->PickHandle(m_aStartPos);
205 : : }
206 : : }
207 : :
208 [ # # ]: 0 : if (pHdl)
209 : : {
210 : 0 : bNoInterrupt = sal_True;
211 [ # # ]: 0 : pSdrView->MarkPoint(*pHdl);
212 : : }
213 : : }
214 : : }
215 : : else
216 : : {
217 : : /******************************************************************
218 : : * Objekt selektieren oder draggen
219 : : ******************************************************************/
220 [ # # ][ # # ]: 0 : if (m_pSh->IsObjSelectable(m_aStartPos) && eHit == SDRHIT_UNMARKEDOBJECT)
[ # # ][ # # ]
221 : : {
222 [ # # ][ # # ]: 0 : if (pSdrView->HasMarkablePoints())
223 [ # # ]: 0 : pSdrView->UnmarkAllPoints();
224 : :
225 : 0 : bNoInterrupt = sal_False;
226 : : // Drag im edtwin verwenden
227 : 0 : return sal_False;
228 : : }
229 : :
230 : 0 : bNoInterrupt = sal_True;
231 : :
232 [ # # ][ # # ]: 0 : if (m_pSh->IsObjSelected())
233 : : {
234 [ # # ]: 0 : if (!rMEvt.IsShift())
235 : : {
236 [ # # ][ # # ]: 0 : if (!pSdrView->HasMarkablePoints())
237 : : {
238 : 0 : sal_Bool bUnlockView = !m_pSh->IsViewLocked();
239 : 0 : m_pSh->LockView( sal_True ); //lock visible section
240 [ # # ]: 0 : m_pSh->SelectObj(Point(LONG_MAX, LONG_MAX)); // deselect all
241 [ # # ]: 0 : if( bUnlockView )
242 : 0 : m_pSh->LockView( sal_False );
243 : : }
244 : : else
245 [ # # ]: 0 : pSdrView->UnmarkAllPoints();
246 : : }
247 : : }
248 [ # # ]: 0 : if (!m_pSh->IsSelFrmMode())
249 [ # # ]: 0 : m_pSh->EnterSelFrmMode(NULL);
250 : :
251 [ # # ][ # # ]: 0 : if( 0 != (bReturn = m_pSh->BeginMark(m_aStartPos)) )
252 : 0 : m_pWin->SetDrawAction(sal_True);
253 : :
254 [ # # ]: 0 : SetDrawPointer();
255 : : }
256 : : }
257 : : }
258 [ # # ]: 0 : return bReturn;
259 : : }
260 : :
261 : : /*************************************************************************
262 : : |*
263 : : |* MouseMove-event
264 : : |*
265 : : \************************************************************************/
266 : :
267 : :
268 : 0 : sal_Bool SwDrawBase::MouseMove(const MouseEvent& rMEvt)
269 : : {
270 [ # # ]: 0 : SdrView *pSdrView = m_pSh->GetDrawView();
271 [ # # ]: 0 : Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
272 : 0 : sal_Bool bRet = sal_False;
273 : :
274 [ # # ][ # # ]: 0 : if (IsCreateObj() && !m_pWin->IsDrawSelMode() && pSdrView->IsCreateObj())
[ # # ][ # # ]
[ # # ]
275 : : {
276 : : // #i33136#
277 [ # # ][ # # ]: 0 : pSdrView->SetOrtho(doConstructOrthogonal() ? !rMEvt.IsShift() : rMEvt.IsShift());
278 : 0 : pSdrView->SetAngleSnapEnabled(rMEvt.IsShift());
279 : :
280 [ # # ]: 0 : m_pSh->MoveCreate(aPnt);
281 : 0 : bRet = sal_True;
282 : : }
283 [ # # ][ # # ]: 0 : else if (pSdrView->IsAction() || pSdrView->IsInsObjPoint() || pSdrView->IsMarkPoints())
[ # # ][ # # ]
[ # # ]
284 : : {
285 [ # # ]: 0 : m_pSh->MoveMark(aPnt);
286 : 0 : bRet = sal_True;
287 : : }
288 : :
289 : 0 : return (bRet);
290 : : }
291 : :
292 : : /*************************************************************************
293 : : |*
294 : : |* MouseButtonUp-event
295 : : |*
296 : : \************************************************************************/
297 : :
298 : :
299 : 0 : sal_Bool SwDrawBase::MouseButtonUp(const MouseEvent& rMEvt)
300 : : {
301 : 0 : sal_Bool bReturn = sal_False;
302 : 0 : sal_Bool bCheckShell = sal_False;
303 : 0 : sal_Bool bAutoCap = sal_False;
304 : :
305 [ # # ]: 0 : Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
306 : :
307 [ # # ][ # # ]: 0 : if (IsCreateObj() && m_pSh->IsDrawCreate() && !m_pWin->IsDrawSelMode())
[ # # ][ # # ]
[ # # ][ # # ]
308 : : {
309 : 0 : const SdrObjKind nDrawMode = m_pWin->GetSdrDrawMode();
310 : : //objects with multiple point may end at the start position
311 : : sal_Bool bMultiPoint = OBJ_PLIN == nDrawMode ||
312 : : OBJ_PATHLINE == nDrawMode ||
313 [ # # ][ # # ]: 0 : OBJ_FREELINE == nDrawMode;
[ # # ]
314 [ # # ][ # # ]: 0 : if(rMEvt.IsRight() || (aPnt == m_aStartPos && !bMultiPoint))
[ # # ][ # # ]
315 : : {
316 [ # # ]: 0 : m_pSh->BreakCreate();
317 [ # # ]: 0 : m_pView->LeaveDrawCreate();
318 : : }
319 : : else
320 : : {
321 [ # # ]: 0 : if (OBJ_NONE == nDrawMode)
322 : : {
323 [ # # ]: 0 : SwRewriter aRewriter;
324 : :
325 [ # # ][ # # ]: 0 : aRewriter.AddRule(UndoArg1, SW_RES(STR_FRAME));
[ # # ]
326 [ # # ][ # # ]: 0 : m_pSh->StartUndo(UNDO_INSERT, &aRewriter);
327 : : }
328 : :
329 [ # # ]: 0 : m_pSh->EndCreate(SDRCREATE_FORCEEND);
330 [ # # ]: 0 : if (OBJ_NONE == nDrawMode) // Textrahmen eingefuegt
331 : : {
332 : : uno::Reference< frame::XDispatchRecorder > xRecorder =
333 [ # # ]: 0 : m_pSh->GetView().GetViewFrame()->GetBindings().GetRecorder();
334 [ # # ]: 0 : if ( xRecorder.is() )
335 : : {
336 [ # # ]: 0 : SfxRequest aReq(m_pSh->GetView().GetViewFrame(),FN_INSERT_FRAME);
337 : : aReq.AppendItem(SfxUInt16Item( FN_INSERT_FRAME,
338 [ # # ][ # # ]: 0 : static_cast<sal_uInt16>(FLY_AT_PARA) ));
[ # # ]
339 [ # # ][ # # ]: 0 : aReq.AppendItem(SfxPointItem( FN_PARAM_1, m_pSh->GetAnchorObjDiff()));
[ # # ][ # # ]
340 [ # # ][ # # ]: 0 : aReq.AppendItem(SvxSizeItem( FN_PARAM_2, m_pSh->GetObjSize()));
[ # # ][ # # ]
341 [ # # ][ # # ]: 0 : aReq.Done();
342 : : }
343 : 0 : bAutoCap = sal_True;
344 [ # # ]: 0 : if(m_pWin->GetFrmColCount() > 1)
345 : : {
346 [ # # ]: 0 : SfxItemSet aSet(m_pView->GetPool(),RES_COL,RES_COL);
347 [ # # ][ # # ]: 0 : SwFmtCol aCol((const SwFmtCol&)aSet.Get(RES_COL));
348 [ # # ][ # # ]: 0 : aCol.Init(m_pWin->GetFrmColCount(), aCol.GetGutterWidth(), aCol.GetWishWidth());
349 [ # # ]: 0 : aSet.Put(aCol);
350 : : // Vorlagen-AutoUpdate
351 [ # # ]: 0 : SwFrmFmt* pFmt = m_pSh->GetCurFrmFmt();
352 [ # # ][ # # ]: 0 : if(pFmt && pFmt->IsAutoUpdateFmt())
[ # # ]
353 [ # # ]: 0 : m_pSh->AutoUpdateFrame(pFmt, aSet);
354 : : else
355 [ # # ][ # # ]: 0 : m_pSh->SetFlyFrmAttr( aSet );
[ # # ]
356 : 0 : }
357 : : }
358 [ # # ]: 0 : if (m_pWin->GetSdrDrawMode() == OBJ_NONE)
359 : : {
360 [ # # ]: 0 : m_pSh->EndUndo();
361 : : }
362 : : }
363 : :
364 : 0 : bReturn = sal_True;
365 : :
366 [ # # ]: 0 : EnterSelectMode(rMEvt);
367 : : }
368 : : else
369 : : {
370 [ # # ]: 0 : SdrView *pSdrView = m_pSh->GetDrawView();
371 : :
372 [ # # ][ # # ]: 0 : if (!pSdrView->HasMarkablePoints())
373 : : {
374 : : /**********************************************************************
375 : : * KEIN BEZIER_EDITOR
376 : : **********************************************************************/
377 [ # # ][ # # ]: 0 : if ((m_pSh->GetDrawView()->IsMarkObj() || m_pSh->GetDrawView()->IsMarkPoints())
[ # # ]
[ # # # # ]
[ # # ]
378 : 0 : && rMEvt.IsLeft())
379 : : {
380 [ # # ]: 0 : bReturn = m_pSh->EndMark();
381 : :
382 : 0 : m_pWin->SetDrawAction(sal_False);
383 : :
384 [ # # ][ # # ]: 0 : if (aPnt == m_aStartPos && m_pSh->IsObjSelectable(aPnt))
[ # # ][ # # ]
385 : : {
386 : 0 : m_pSh->SelectObj(aPnt, ( rMEvt.IsShift() &&
387 [ # # ][ # # ]: 0 : m_pSh->IsSelFrmMode()) ? SW_ADD_SELECT : 0);
[ # # ]
388 : :
389 [ # # ][ # # ]: 0 : if (!m_pSh->IsObjSelected())
390 : : {
391 [ # # ]: 0 : m_pView->LeaveDrawCreate(); // In Selektionsmode wechseln
392 : :
393 [ # # ]: 0 : m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
394 : :
395 [ # # ]: 0 : if (m_pSh->IsSelFrmMode())
396 [ # # ]: 0 : m_pSh->LeaveSelFrmMode();
397 : : }
398 [ # # ]: 0 : m_pView->NoRotate();
399 : :
400 : 0 : bCheckShell = sal_True; // ggf BezierShell anwerfen
401 : : }
402 [ # # ][ # # ]: 0 : else if (!m_pSh->IsObjSelected() && !m_pWin->IsDrawAction())
[ # # ][ # # ]
403 : : {
404 [ # # ][ # # ]: 0 : if (m_pSh->IsObjSelectable(aPnt))
405 : 0 : m_pSh->SelectObj(aPnt, ( rMEvt.IsShift() &&
406 [ # # ][ # # ]: 0 : m_pSh->IsSelFrmMode() ) ? SW_ADD_SELECT : 0 );
[ # # ]
407 : : else
408 : : {
409 [ # # ]: 0 : m_pView->LeaveDrawCreate();
410 [ # # ]: 0 : if (m_pSh->IsSelFrmMode())
411 [ # # ]: 0 : m_pSh->LeaveSelFrmMode();
412 : : }
413 [ # # ]: 0 : m_pView->NoRotate();
414 : :
415 : 0 : bReturn = sal_True;
416 : : }
417 : : }
418 : : }
419 : : else
420 : : {
421 : : /**********************************************************************
422 : : * BEZIER_EDITOR
423 : : **********************************************************************/
424 [ # # ][ # # ]: 0 : if ( pSdrView->IsAction() )
425 : : {
426 [ # # ]: 0 : if ( pSdrView->IsInsObjPoint() )
427 [ # # ]: 0 : bReturn = pSdrView->EndInsObjPoint(SDRCREATE_FORCEEND);
428 [ # # ]: 0 : else if (pSdrView->IsMarkPoints() )
429 [ # # ]: 0 : bReturn = pSdrView->EndMarkPoints();
430 : : else
431 : : {
432 [ # # ]: 0 : pSdrView->EndAction();
433 : 0 : bReturn = sal_True;
434 : : }
435 : 0 : m_pWin->SetDrawAction(sal_False);
436 : :
437 [ # # ]: 0 : if (aPnt == m_aStartPos)
438 : : {
439 [ # # ][ # # ]: 0 : if (!m_pSh->IsObjSelectable(aPnt))
440 [ # # ]: 0 : m_pSh->SelectObj(Point(LONG_MAX, LONG_MAX));
441 [ # # ]: 0 : else if (!bReturn)
442 : : {
443 [ # # ]: 0 : if (!rMEvt.IsShift())
444 [ # # ]: 0 : pSdrView->UnmarkAllPoints();
445 : 0 : m_pSh->SelectObj(aPnt, (rMEvt.IsShift() &&
446 [ # # ][ # # ]: 0 : m_pSh->IsSelFrmMode()) ? SW_ADD_SELECT :0);
[ # # ]
447 : : }
448 : :
449 [ # # ][ # # ]: 0 : if (!m_pSh->IsObjSelected())
450 : : {
451 [ # # ]: 0 : m_pView->LeaveDrawCreate(); // In Selektionsmode wechseln
452 : :
453 [ # # ]: 0 : m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
454 : :
455 [ # # ]: 0 : if (m_pSh->IsSelFrmMode())
456 [ # # ]: 0 : m_pSh->LeaveSelFrmMode();
457 : : }
458 [ # # ]: 0 : m_pView->NoRotate();
459 : :
460 : 0 : bCheckShell = sal_True; // ggf BezierShell anwerfen
461 : : }
462 : : }
463 : :
464 [ # # ]: 0 : SetDrawPointer();
465 : :
466 [ # # ][ # # ]: 0 : if (!m_pSh->IsObjSelected() && !m_pWin->IsDrawAction())
[ # # ][ # # ]
467 : : {
468 [ # # ]: 0 : m_pView->LeaveDrawCreate();
469 [ # # ]: 0 : if (m_pSh->IsSelFrmMode())
470 [ # # ]: 0 : m_pSh->LeaveSelFrmMode();
471 : :
472 [ # # ]: 0 : m_pView->NoRotate();
473 : 0 : bReturn = sal_True;
474 : : }
475 : : }
476 : : }
477 : :
478 [ # # ]: 0 : if (bCheckShell)
479 [ # # ]: 0 : m_pView->AttrChangedNotify( m_pSh ); // ggf BezierShell anwerfen
480 : :
481 : : //!!!!!!!!!! Achtung Suizid !!!!!!!!!!! Sollte alles mal erneuert werden
482 [ # # ]: 0 : if ( bAutoCap )
483 [ # # ]: 0 : m_pView->AutoCaption(FRAME_CAP); //Kann derzeit nur FRAME sein, sonst auf
484 : : //enums umstellen
485 : 0 : return (bReturn);
486 : : }
487 : :
488 : : /*************************************************************************
489 : : |*
490 : : |* Function aktivieren
491 : : |*
492 : : \************************************************************************/
493 : :
494 : :
495 : 0 : void SwDrawBase::Activate(const sal_uInt16 nSlot)
496 : : {
497 : 0 : SetSlotId(nSlot);
498 : 0 : SdrView *pSdrView = m_pSh->GetDrawView();
499 : :
500 : 0 : pSdrView->SetCurrentObj( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()) );
501 : 0 : pSdrView->SetEditMode(sal_False);
502 : :
503 : 0 : SetDrawPointer();
504 : 0 : m_pSh->NoEdit();
505 : 0 : }
506 : :
507 : : /*************************************************************************
508 : : |*
509 : : |* Function deaktivieren
510 : : |*
511 : : \************************************************************************/
512 : :
513 : :
514 : 0 : void SwDrawBase::Deactivate()
515 : : {
516 : 0 : SdrView *pSdrView = m_pSh->GetDrawView();
517 : 0 : pSdrView->SetOrtho(sal_False);
518 : 0 : pSdrView->SetAngleSnapEnabled(sal_False);
519 : :
520 [ # # ][ # # ]: 0 : if (m_pWin->IsDrawAction() && m_pSh->IsDrawCreate())
[ # # ]
521 : 0 : m_pSh->BreakCreate();
522 : :
523 : 0 : m_pWin->SetDrawAction(sal_False);
524 : :
525 : 0 : m_pWin->ReleaseMouse();
526 : 0 : bNoInterrupt = sal_False;
527 : :
528 [ # # ]: 0 : if(m_pWin->GetApplyTemplate())
529 [ # # ]: 0 : m_pWin->SetApplyTemplate(SwApplyTemplate());
530 : 0 : m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
531 : 0 : }
532 : :
533 : : /*************************************************************************
534 : : |*
535 : : |* Tastaturereignisse bearbeiten
536 : : |*
537 : : |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
538 : : |* sal_False.
539 : : |*
540 : : \************************************************************************/
541 : :
542 : :
543 : 0 : sal_Bool SwDrawBase::KeyInput(const KeyEvent& rKEvt)
544 : : {
545 : 0 : sal_Bool bReturn = sal_False;
546 : 0 : sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
547 : :
548 [ # # # # ]: 0 : switch (nCode)
549 : : {
550 : : case KEY_ESCAPE:
551 : : {
552 [ # # ]: 0 : if (m_pWin->IsDrawAction())
553 : : {
554 : 0 : BreakCreate();
555 : 0 : m_pView->LeaveDrawCreate();
556 : : }
557 : :
558 : 0 : bReturn = sal_True;
559 : : }
560 : 0 : break;
561 : :
562 : : case KEY_DELETE:
563 : : {
564 : 0 : m_pSh->DelSelectedObj();
565 : 0 : bReturn = sal_True;
566 : : }
567 : 0 : break;
568 : :
569 : : case KEY_UP:
570 : : case KEY_DOWN:
571 : : case KEY_LEFT:
572 : : case KEY_RIGHT:
573 : : {
574 : 0 : SdrView *pSdrView = m_pSh->GetDrawView();
575 : :
576 [ # # ]: 0 : if (!pSdrView->IsTextEdit())
577 : : {
578 : 0 : long nX = 0;
579 : 0 : long nY = 0;
580 : :
581 [ # # ]: 0 : if (nCode == KEY_UP)
582 : : {
583 : : // Scroll nach oben
584 : 0 : nX = 0;
585 : 0 : nY =-1;
586 : : }
587 [ # # ]: 0 : else if (nCode == KEY_DOWN)
588 : : {
589 : : // Scroll nach unten
590 : 0 : nX = 0;
591 : 0 : nY = 1;
592 : : }
593 [ # # ]: 0 : else if (nCode == KEY_LEFT)
594 : : {
595 : : // Scroll nach links
596 : 0 : nX =-1;
597 : 0 : nY = 0;
598 : : }
599 [ # # ]: 0 : else if (nCode == KEY_RIGHT)
600 : : {
601 : : // Scroll nach rechts
602 : 0 : nX = 1;
603 : 0 : nY = 0;
604 : : }
605 : :
606 [ # # ][ # # ]: 0 : if (pSdrView->AreObjectsMarked() && rKEvt.GetKeyCode().IsMod2())
[ # # ]
607 : : {
608 : : // Objekte verschieben
609 : 0 : nX *= 100;
610 : 0 : nY *= 100;
611 [ # # ]: 0 : pSdrView->MoveAllMarked(Size(nX, nY));
612 : : }
613 : :
614 : 0 : bReturn = sal_True;
615 : : }
616 : : }
617 : 0 : break;
618 : : }
619 : :
620 : 0 : return (bReturn);
621 : : }
622 : :
623 : :
624 : : /*************************************************************************
625 : : |*
626 : : |* Tastaturereignisse bearbeiten
627 : : |*
628 : : |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
629 : : |* sal_False.
630 : : |*
631 : : \************************************************************************/
632 : :
633 : :
634 : 0 : void SwDrawBase::BreakCreate()
635 : : {
636 : 0 : m_pSh->BreakCreate();
637 : 0 : m_pWin->SetDrawAction(sal_False);
638 : 0 : m_pWin->ReleaseMouse();
639 : :
640 : 0 : Deactivate();
641 : 0 : }
642 : :
643 : : /*************************************************************************
644 : : |*
645 : : |* Mauspointer umschalten
646 : : |*
647 : : \************************************************************************/
648 : :
649 : :
650 : 0 : void SwDrawBase::SetDrawPointer()
651 : : {
652 [ # # ]: 0 : SdrView *pSdrView = m_pSh->GetDrawView();
653 [ # # ][ # # ]: 0 : Point aPnt(m_pWin->OutputToScreenPixel(m_pWin->GetPointerPosPixel()));
654 [ # # ][ # # ]: 0 : aPnt = m_pWin->PixelToLogic(m_pWin->ScreenToOutputPixel(aPnt));
655 [ # # ]: 0 : const Pointer aPointTyp = pSdrView->GetPreferedPointer(aPnt, m_pSh->GetOut());
656 : 0 : const Pointer aDrawPt(aPointTyp);
657 [ # # ]: 0 : m_pWin->SetPointer(aDrawPt);
658 : 0 : }
659 : :
660 : : /*************************************************************************
661 : : |*
662 : : |* Ggf in Selektionsmode wechseln
663 : : |*
664 : : \************************************************************************/
665 : :
666 : 0 : void SwDrawBase::EnterSelectMode(const MouseEvent& rMEvt)
667 : : {
668 : 0 : m_pWin->SetDrawAction(sal_False);
669 : :
670 [ # # ][ # # ]: 0 : if (!m_pSh->IsObjSelected() && !m_pWin->IsDrawAction())
[ # # ]
671 : : {
672 [ # # ]: 0 : Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
673 : :
674 [ # # ][ # # ]: 0 : if (m_pSh->IsObjSelectable(aPnt))
675 : : {
676 [ # # ]: 0 : m_pSh->SelectObj(aPnt);
677 [ # # ][ # # ]: 0 : if (rMEvt.GetModifier() == KEY_SHIFT || !m_pSh->IsObjSelected())
[ # # ][ # # ]
678 : : {
679 [ # # ]: 0 : m_pView->LeaveDrawCreate(); // In Selektionsmode wechseln
680 : :
681 [ # # ]: 0 : m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
682 : : }
683 : : }
684 : : else
685 : : {
686 [ # # ]: 0 : m_pView->LeaveDrawCreate();
687 [ # # ]: 0 : if (m_pSh->IsSelFrmMode())
688 [ # # ]: 0 : m_pSh->LeaveSelFrmMode();
689 : : }
690 [ # # ]: 0 : m_pView->NoRotate();
691 : : }
692 : 0 : }
693 : :
694 : 0 : void SwDrawBase::CreateDefaultObject()
695 : : {
696 [ # # ]: 0 : Point aStartPos = GetDefaultCenterPos();
697 : 0 : Point aEndPos(aStartPos);
698 : 0 : aStartPos.X() -= 8 * MM50;
699 : 0 : aStartPos.Y() -= 4 * MM50;
700 : 0 : aEndPos.X() += 8 * MM50;
701 : 0 : aEndPos.Y() += 4 * MM50;
702 [ # # ]: 0 : Rectangle aRect(aStartPos, aEndPos);
703 [ # # ]: 0 : m_pSh->CreateDefaultShape( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), aRect, m_nSlotId);
704 : 0 : }
705 : :
706 : 0 : Point SwDrawBase::GetDefaultCenterPos()
707 : : {
708 [ # # ]: 0 : Size aDocSz(m_pSh->GetDocSize());
709 : 0 : const SwRect& rVisArea = m_pSh->VisArea();
710 [ # # ]: 0 : Point aStartPos = rVisArea.Center();
711 [ # # ]: 0 : if(rVisArea.Width() > aDocSz.Width())
712 : 0 : aStartPos.X() = aDocSz.Width() / 2 + rVisArea.Left();
713 [ # # ]: 0 : if(rVisArea.Height() > aDocSz.Height())
714 : 0 : aStartPos.Y() = aDocSz.Height() / 2 + rVisArea.Top();
715 : 0 : return aStartPos;
716 : : }
717 : :
718 : : // #i33136#
719 : 0 : bool SwDrawBase::doConstructOrthogonal() const
720 : : {
721 : 0 : return false;
722 : : }
723 : :
724 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|