merge the formfield patch from ooo-build
[ooovba.git] / svx / source / svdraw / svdview.cxx
blob0005489d10cd0012a199646fdc832f54c58e2527
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdview.cxx,v $
10 * $Revision: 1.29.18.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <svx/eeitem.hxx>
35 #include "svdstr.hrc" // Namen aus der Resource
36 #include "svdglob.hxx" // StringCache
37 #include <svx/svdpagv.hxx>
38 #include <svx/svdmrkv.hxx>
39 #include <svx/svdedxv.hxx>
40 #include <svx/svdobj.hxx>
41 #include <svx/svdopath.hxx> // fuer GetContext
42 #include <svx/svdograf.hxx> // fuer GetContext
43 #include <svx/svdomedia.hxx> // fuer GetContext
44 #include <svx/svdetc.hxx> // Fuer SdrEngineDefaults
46 #ifdef DBG_UTIL
47 #include <svdibrow.hxx>
48 #endif
50 #include "svx/svdoutl.hxx"
51 #include "svx/svdview.hxx"
52 #include "svx/editview.hxx" // fuer GetField
53 #include "svx/flditem.hxx" // fuer URLField
54 #include "svx/obj3d.hxx"
55 #include "svx/svddrgmt.hxx"
56 #include "svx/svdoutl.hxx"
57 #include "svx/svdotable.hxx"
58 #include <tools/tenccvt.hxx>
59 #include <svx/sdr/overlay/overlaypolypolygon.hxx>
60 #include <svx/sdr/overlay/overlaymanager.hxx>
61 #include <sdrpaintwindow.hxx>
62 #include <svx/sdrpagewindow.hxx>
63 #include <svx/sdrhittesthelper.hxx>
65 ////////////////////////////////////////////////////////////////////////////////////////////////////
67 SdrViewEvent::SdrViewEvent()
68 : pHdl(NULL),
69 pObj(NULL),
70 pRootObj(NULL),
71 pPV(NULL),
72 pURLField(NULL),
73 eHit(SDRHIT_NONE),
74 eEvent(SDREVENT_NONE),
75 eHdlKind(HDL_MOVE),
76 eEndCreateCmd(SDRCREATE_NEXTPOINT),
77 nMouseClicks(0),
78 nMouseMode(0),
79 nMouseCode(0),
80 nHlplIdx(0),
81 nGlueId(0),
82 bMouseDown(FALSE),
83 bMouseUp(FALSE),
84 bDoubleHdlSize(FALSE),
85 bIsAction(FALSE),
86 bIsTextEdit(FALSE),
87 bTextEditHit(FALSE),
88 bAddMark(FALSE),
89 bUnmark(FALSE),
90 bPrevNextMark(FALSE),
91 bMarkPrev(FALSE),
92 bInsPointNewObj(FALSE),
93 bDragWithCopy(FALSE),
94 bCaptureMouse(FALSE),
95 bReleaseMouse(FALSE)
99 SdrViewEvent::~SdrViewEvent()
103 ////////////////////////////////////////////////////////////////////////////////////////////////////
104 // helper class for all D&D overlays
106 void SdrDropMarkerOverlay::ImplCreateOverlays(const SdrView& rView, const basegfx::B2DPolyPolygon& rPolyPolygon)
108 for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
110 SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
111 ::sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager();
113 if(pTargetOverlay)
115 ::sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(
116 rPolyPolygon);
117 pTargetOverlay->add(*pNew);
118 maObjects.append(*pNew);
123 SdrDropMarkerOverlay::SdrDropMarkerOverlay(const SdrView& rView, const SdrObject& rObject)
125 ImplCreateOverlays(rView, rObject.TakeXorPoly());
128 SdrDropMarkerOverlay::SdrDropMarkerOverlay(const SdrView& rView, const Rectangle& rRectangle)
130 basegfx::B2DPolygon aB2DPolygon;
131 aB2DPolygon.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Top()));
132 aB2DPolygon.append(basegfx::B2DPoint(rRectangle.Right(), rRectangle.Top()));
133 aB2DPolygon.append(basegfx::B2DPoint(rRectangle.Right(), rRectangle.Bottom()));
134 aB2DPolygon.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom()));
135 aB2DPolygon.setClosed(true);
137 basegfx::B2DPolyPolygon aB2DPolyPolygon;
138 aB2DPolyPolygon.append(aB2DPolygon);
140 ImplCreateOverlays(rView, aB2DPolyPolygon);
143 SdrDropMarkerOverlay::SdrDropMarkerOverlay(const SdrView& rView, const Point& rStart, const Point& rEnd)
145 basegfx::B2DPolygon aB2DPolygon;
146 aB2DPolygon.append(basegfx::B2DPoint(rStart.X(), rStart.Y()));
147 aB2DPolygon.append(basegfx::B2DPoint(rEnd.X(), rEnd.Y()));
148 aB2DPolygon.setClosed(true);
150 basegfx::B2DPolyPolygon aB2DPolyPolygon;
151 aB2DPolyPolygon.append(aB2DPolygon);
153 ImplCreateOverlays(rView, aB2DPolyPolygon);
156 SdrDropMarkerOverlay::~SdrDropMarkerOverlay()
158 // The OverlayObjects are cleared using the destructor of OverlayObjectList.
159 // That destructor calls clear() at the list which removes all objects from the
160 // OverlayManager and deletes them.
163 ////////////////////////////////////////////////////////////////////////////////////////////////////
164 ////////////////////////////////////////////////////////////////////////////////////////////////////
166 // @@ @@ @@ @@@@@ @@ @@
167 // @@ @@ @@ @@ @@ @@
168 // @@ @@ @@ @@ @@ @ @@
169 // @@@@@ @@ @@@@ @@@@@@@
170 // @@@ @@ @@ @@@@@@@
171 // @@@ @@ @@ @@@ @@@
172 // @ @@ @@@@@ @@ @@
174 ////////////////////////////////////////////////////////////////////////////////////////////////////
175 ////////////////////////////////////////////////////////////////////////////////////////////////////
177 TYPEINIT1(SdrView,SdrCreateView);
179 SdrView::SdrView(SdrModel* pModel1, OutputDevice* pOut)
180 : SdrCreateView(pModel1,pOut),
181 bNoExtendedMouseDispatcher(FALSE),
182 bNoExtendedKeyDispatcher(FALSE),
183 bNoExtendedCommandDispatcher(FALSE),
184 mbMasterPagePaintCaching(sal_False)
186 bTextEditOnObjectsWithoutTextIfTextTool=FALSE;
188 StartListening( maAccessibilityOptions );
190 onAccessibilityOptionsChanged();
193 SdrView::~SdrView()
195 EndListening( maAccessibilityOptions );
198 BOOL SdrView::KeyInput(const KeyEvent& rKEvt, Window* pWin)
200 SetActualWin(pWin);
201 BOOL bRet=SdrCreateView::KeyInput(rKEvt,pWin);
202 if (!bRet && !IsExtendedKeyInputDispatcherEnabled()) {
203 bRet=TRUE;
204 switch (rKEvt.GetKeyCode().GetFullFunction()) {
205 case KEYFUNC_CUT : Cut(); break;
206 case KEYFUNC_COPY : Yank(); break;
207 case KEYFUNC_PASTE : Paste(pWin); break;
208 case KEYFUNC_DELETE: DeleteMarked(); break;
209 case KEYFUNC_UNDO: pMod->Undo(); break;
210 case KEYFUNC_REDO: pMod->Redo(); break;
211 case KEYFUNC_REPEAT: pMod->Repeat(*this); break;
212 default: {
213 switch (rKEvt.GetKeyCode().GetFullCode()) {
214 case KEY_ESCAPE: {
215 if (IsTextEdit()) SdrEndTextEdit();
216 if (IsAction()) BrkAction();
217 if (pWin!=NULL) pWin->ReleaseMouse();
218 } break;
219 case KEY_DELETE: DeleteMarked(); break;
220 case KEY_CUT: case KEY_DELETE+KEY_SHIFT: Cut(); break;
221 case KEY_COPY: case KEY_INSERT+KEY_MOD1: Yank(); break;
222 case KEY_PASTE: case KEY_INSERT+KEY_SHIFT: Paste(pWin); break;
223 case KEY_UNDO: case KEY_BACKSPACE+KEY_MOD2: pMod->Undo(); break;
224 case KEY_BACKSPACE+KEY_MOD2+KEY_SHIFT: pMod->Redo(); break;
225 case KEY_REPEAT: case KEY_BACKSPACE+KEY_MOD2+KEY_MOD1: pMod->Repeat(*this); break;
226 case KEY_MOD1+KEY_A: MarkAll(); break;
227 default: bRet=FALSE;
228 } // switch
230 } // switch
231 if (bRet && pWin!=NULL) {
232 pWin->SetPointer(GetPreferedPointer(
233 pWin->PixelToLogic(pWin->ScreenToOutputPixel( pWin->GetPointerPosPixel() ) ),
234 pWin,
235 rKEvt.GetKeyCode().GetModifier()));
238 return bRet;
241 BOOL SdrView::MouseButtonDown(const MouseEvent& rMEvt, Window* pWin)
243 SetActualWin(pWin);
244 if (rMEvt.IsLeft()) aDragStat.SetMouseDown(TRUE);
245 BOOL bRet=SdrCreateView::MouseButtonDown(rMEvt,pWin);
246 if (!bRet && !IsExtendedMouseEventDispatcherEnabled()) {
247 SdrViewEvent aVEvt;
248 PickAnything(rMEvt,SDRMOUSEBUTTONDOWN,aVEvt);
249 bRet=DoMouseEvent(aVEvt);
251 return bRet;
254 BOOL SdrView::MouseButtonUp(const MouseEvent& rMEvt, Window* pWin)
256 SetActualWin(pWin);
257 if (rMEvt.IsLeft()) aDragStat.SetMouseDown(FALSE);
258 BOOL bAction=IsAction();
259 BOOL bRet=!bAction && SdrCreateView::MouseButtonUp(rMEvt,pWin);
260 if (!bRet && !IsExtendedMouseEventDispatcherEnabled()) {
261 SdrViewEvent aVEvt;
262 PickAnything(rMEvt,SDRMOUSEBUTTONUP,aVEvt);
263 bRet=DoMouseEvent(aVEvt);
265 return bRet;
268 BOOL SdrView::MouseMove(const MouseEvent& rMEvt, Window* pWin)
270 SetActualWin(pWin);
271 aDragStat.SetMouseDown(rMEvt.IsLeft());
272 BOOL bRet=SdrCreateView::MouseMove(rMEvt,pWin);
273 if (!IsExtendedMouseEventDispatcherEnabled() && !IsTextEditInSelectionMode()) {
274 SdrViewEvent aVEvt;
275 PickAnything(rMEvt,SDRMOUSEMOVE,aVEvt);
276 if (DoMouseEvent(aVEvt)) bRet=TRUE;
279 // #87792# Removed code which did let the mouse snap on object
280 // points
282 return bRet;
285 BOOL SdrView::Command(const CommandEvent& rCEvt, Window* pWin)
287 SetActualWin(pWin);
288 BOOL bRet=SdrCreateView::Command(rCEvt,pWin);
289 return bRet;
292 /* new interface src537 */
293 BOOL SdrView::GetAttributes(SfxItemSet& rTargetSet, BOOL bOnlyHardAttr) const
295 return SdrCreateView::GetAttributes(rTargetSet, bOnlyHardAttr);
298 SfxStyleSheet* SdrView::GetStyleSheet() const
300 //BOOL bOk=FALSE;
301 return SdrCreateView::GetStyleSheet(); //bOk);
304 SdrHitKind SdrView::PickAnything(const MouseEvent& rMEvt, USHORT nEventKind, SdrViewEvent& rVEvt) const
306 rVEvt.bMouseDown=nEventKind==SDRMOUSEBUTTONDOWN;
307 rVEvt.bMouseUp=nEventKind==SDRMOUSEBUTTONUP;
308 rVEvt.nMouseClicks=rMEvt.GetClicks();
309 rVEvt.nMouseMode=rMEvt.GetMode();
310 rVEvt.nMouseCode=rMEvt.GetButtons() | rMEvt.GetModifier();
311 const OutputDevice* pOut=pActualOutDev;
312 if (pOut==NULL)
314 pOut = GetFirstOutputDevice();
315 //pOut=GetWin(0);
317 Point aPnt(rMEvt.GetPosPixel());
318 if (pOut!=NULL) aPnt=pOut->PixelToLogic(aPnt);
319 rVEvt.aLogicPos=aPnt;
320 return PickAnything(aPnt,rVEvt);
323 // Mit der Maus draggen (Move)
324 // Beispiel beim erzeugen eines Rechtecks. MouseDown muss ohne
325 // ModKey erfolgen, weil sonst i.d.R. Markieren forciert wird (s.u.)
326 // Drueckt man dann beim MouseMove gleichzeitig Shift, Ctrl, und Alt,
327 // so erzeugt man ein zentrisches Quadrat ohne Fang.
328 // Die Doppelbelegung von Ortho und Shift stellt i.d.R. kein Problem dar,
329 // da sich beides meisst gegenseitig ausschliesst. Einzig Shear (das beim
330 // Verzerren, nicht dass beim Drehen) beruecksichtigt beides gleichzeitig.
331 // Dass muss der Anwender erstmal noch umschiffen (z.B. mit einer Hilfslinie).
332 #define MODKEY_NoSnap bCtrl /* Fang temporaer aus */
333 #define MODKEY_Ortho bShift /* na eben ortho */
334 #define MODKEY_Center bAlt /* Zentrisch erzeugen/resizen */
335 #define MODKEY_AngleSnap bShift
336 #define MODKEY_CopyDrag bCtrl /* Draggen mit kopieren */
338 // irgendwo hinklicken (MouseDown)
339 #define MODKEY_PolyPoly bAlt /* Neues Poly bei InsPt und bei Create */
340 #define MODKEY_MultiMark bShift /* MarkObj ohne vorher UnmarkAll */
341 #define MODKEY_Unmark bAlt /* Unmark durch Rahmenaufziehen */
342 #define MODKEY_ForceMark bCtrl /* Rahmenaufziehen erzwingen, auch wenn Obj an MausPos */
343 #define MODKEY_DeepMark bAlt /* MarkNextObj */
344 #define MODKEY_DeepBackw bShift /* MarkNextObj rueckwaerts */
346 SdrHitKind SdrView::PickAnything(const Point& rLogicPos, SdrViewEvent& rVEvt) const
348 const OutputDevice* pOut=pActualOutDev;
349 if (pOut==NULL)
351 pOut = GetFirstOutputDevice();
352 //pOut=GetWin(0);
355 // #i73628# Use a non-changeable copy of he logic pos
356 const Point aLocalLogicPosition(rLogicPos);
358 BOOL bEditMode=IsEditMode();
359 BOOL bPointMode=bEditMode && HasMarkablePoints();
360 BOOL bGluePointMode=IsGluePointEditMode();
361 BOOL bInsPolyPt=bPointMode && IsInsObjPointMode() && IsInsObjPointPossible();
362 BOOL bInsGluePt=bGluePointMode && IsInsGluePointMode() && IsInsGluePointPossible();
363 BOOL bIsTextEdit=IsTextEdit();
364 BOOL bTextEditHit=IsTextEditHit(aLocalLogicPosition,0/*nHitTolLog*/);
365 BOOL bTextEditSel=IsTextEditInSelectionMode();
366 BOOL bShift=(rVEvt.nMouseCode & KEY_SHIFT) !=0;
367 BOOL bCtrl=(rVEvt.nMouseCode & KEY_MOD1) !=0;
368 BOOL bAlt=(rVEvt.nMouseCode & KEY_MOD2) !=0;
369 SdrHitKind eHit=SDRHIT_NONE;
370 SdrHdl* pHdl=pOut!=NULL && !bTextEditSel ? PickHandle(aLocalLogicPosition) : NULL;
371 SdrPageView* pPV=NULL;
372 SdrObject* pObj=NULL;
373 SdrObject* pHitObj=NULL;
374 USHORT nHitPassNum=0;
375 USHORT nHlplIdx=0;
376 USHORT nGlueId=0;
377 BOOL bUnmarkedObjHit=FALSE;
378 if (bTextEditHit || bTextEditSel)
380 eHit=SDRHIT_TEXTEDIT;
381 bTextEditHit=TRUE;
383 else if (pHdl!=NULL)
385 eHit=SDRHIT_HANDLE; // Handle getroffen hat hoechste Prioritaet
387 else if (bEditMode && IsHlplVisible() && IsHlplFront() && pOut!=NULL && PickHelpLine(aLocalLogicPosition,nHitTolLog,*pOut,nHlplIdx,pPV))
389 eHit=SDRHIT_HELPLINE; // Hilfslinie im Vordergrund getroffen zum verschieben
391 else if (bGluePointMode && PickGluePoint(aLocalLogicPosition,pObj,nGlueId,pPV))
393 eHit=SDRHIT_GLUEPOINT; // nichtmarkierter Klebepunkt getroffen
395 else if (PickObj(aLocalLogicPosition,nHitTolLog,pHitObj,pPV,SDRSEARCH_DEEP|SDRSEARCH_MARKED,&pObj,NULL,&nHitPassNum))
397 eHit=SDRHIT_MARKEDOBJECT;
398 ::sdr::table::SdrTableObj* pTableObj = dynamic_cast< ::sdr::table::SdrTableObj* >( pObj );
399 if( pTableObj )
401 sal_Int32 nX = 0, nY = 0;
402 switch( pTableObj->CheckTableHit( aLocalLogicPosition, nX, nY, 0 ) )
404 case sdr::table::SDRTABLEHIT_CELL:
405 eHit = SDRHIT_CELL;
406 break;
407 case sdr::table::SDRTABLEHIT_CELLTEXTAREA:
408 eHit = SDRHIT_TEXTEDITOBJ;
409 break;
410 default:
411 break;
415 else if (PickObj(aLocalLogicPosition,nHitTolLog,pHitObj,pPV,SDRSEARCH_DEEP|/*SDRSEARCH_TESTMARKABLE|*/SDRSEARCH_ALSOONMASTER|SDRSEARCH_WHOLEPAGE,&pObj,NULL,&nHitPassNum))
417 // MasterPages und WholePage fuer Macro und URL
418 eHit=SDRHIT_UNMARKEDOBJECT;
419 ::sdr::table::SdrTableObj* pTableObj = dynamic_cast< ::sdr::table::SdrTableObj* >( pObj );
420 if( pTableObj )
422 sal_Int32 nX = 0, nY = 0;
423 switch( pTableObj->CheckTableHit( aLocalLogicPosition, nX, nY, 0 ) )
425 case sdr::table::SDRTABLEHIT_CELL:
426 eHit = SDRHIT_CELL;
427 break;
428 case sdr::table::SDRTABLEHIT_CELLTEXTAREA:
429 eHit = SDRHIT_TEXTEDITOBJ;
430 break;
431 default:
432 break;
435 bUnmarkedObjHit=TRUE;
437 else if (bEditMode && IsHlplVisible() && !IsHlplFront() && pOut!=NULL && PickHelpLine(aLocalLogicPosition,nHitTolLog,*pOut,nHlplIdx,pPV))
439 eHit=SDRHIT_HELPLINE; // Hilfslinie im Vordergrund getroffen zum verschieben
441 if (IsMacroMode() && eHit==SDRHIT_UNMARKEDOBJECT)
443 bool bRoot=pObj->HasMacro();
444 BOOL bDeep=pObj!=pHitObj && pHitObj->HasMacro();
445 BOOL bMid=FALSE; // Gruppierte Gruppe mit Macro getroffen?
446 SdrObject* pMidObj=NULL;
447 if (pObj!=pHitObj)
449 SdrObject* pObjTmp=NULL;
450 pObjTmp=pHitObj->GetUpGroup();
451 if (pObjTmp==pObj) pObjTmp=NULL;
452 while (pObjTmp!=NULL)
454 if (pObjTmp->HasMacro())
456 bMid=TRUE;
457 pMidObj=pObjTmp;
459 pObjTmp=pObjTmp->GetUpGroup();
460 if (pObjTmp==pObj) pObjTmp=NULL;
464 if (bDeep || bMid || bRoot)
466 SdrObjMacroHitRec aHitRec;
467 aHitRec.aPos=aLocalLogicPosition;
468 aHitRec.aDownPos=aLocalLogicPosition;
469 aHitRec.nTol=nHitTolLog;
470 aHitRec.pVisiLayer=&pPV->GetVisibleLayers();
471 aHitRec.pPageView=pPV;
472 if (bDeep) bDeep=pHitObj->IsMacroHit(aHitRec);
473 if (bMid ) bMid =pMidObj->IsMacroHit(aHitRec);
474 if (bRoot) bRoot=pObj->IsMacroHit(aHitRec);
475 if (bRoot || bMid || bDeep)
477 // Prio: 1.Root, 2.Mid, 3.Deep
478 rVEvt.pRootObj=pObj;
479 if (!bRoot) pObj=pMidObj;
480 if (!bRoot && !bMid) pObj=pHitObj;
481 eHit=SDRHIT_MACRO;
485 // auf URL-Field checken
486 if (IsMacroMode() && eHit==SDRHIT_UNMARKEDOBJECT)
488 SdrTextObj* pTextObj=PTR_CAST(SdrTextObj,pHitObj);
489 if (pTextObj!=NULL && pTextObj->HasText())
491 bool bTEHit(pPV &&
492 SdrObjectPrimitiveHit(*pTextObj, aLocalLogicPosition, 0, *pPV, &pPV->GetVisibleLayers(), true));
494 if (bTEHit)
496 Rectangle aTextRect;
497 Rectangle aAnchor;
498 SdrOutliner* pOutliner = &pTextObj->ImpGetDrawOutliner();
499 if( pTextObj->GetModel() )
500 pOutliner = &pTextObj->GetModel()->GetHitTestOutliner();
502 pTextObj->TakeTextRect( *pOutliner, aTextRect, FALSE, &aAnchor, FALSE );
504 // #i73628# Use a text-relative position for hit test in hit test outliner
505 Point aTemporaryTextRelativePosition(aLocalLogicPosition - aTextRect.TopLeft());
507 // FitToSize berueksichtigen
508 BOOL bFitToSize(pTextObj->IsFitToSize());
509 if (bFitToSize) {
510 Fraction aX(aTextRect.GetWidth()-1,aAnchor.GetWidth()-1);
511 Fraction aY(aTextRect.GetHeight()-1,aAnchor.GetHeight()-1);
512 ResizePoint(aTemporaryTextRelativePosition,Point(),aX,aY);
514 // Drehung berueksichtigen
515 const GeoStat& rGeo=pTextObj->GetGeoStat();
516 if (rGeo.nDrehWink!=0) RotatePoint(aTemporaryTextRelativePosition,Point(),-rGeo.nSin,rGeo.nCos); // -sin fuer Unrotate
517 // Laufschrift berueksichtigen fehlt noch ...
518 if(pActualOutDev && pActualOutDev->GetOutDevType() == OUTDEV_WINDOW)
520 OutlinerView aOLV(pOutliner, (Window*)pActualOutDev);
521 const EditView& aEV=aOLV.GetEditView();
522 const SvxFieldItem* pItem=aEV.GetField(aTemporaryTextRelativePosition);
523 if (pItem!=NULL) {
524 const SvxFieldData* pFld=pItem->GetField();
525 const SvxURLField* pURL=PTR_CAST(SvxURLField,pFld);
526 if (pURL!=NULL) {
527 eHit=SDRHIT_URLFIELD;
528 rVEvt.pURLField=pURL;
536 if (nHitPassNum==SDRSEARCHPASS_DIRECT &&
537 (eHit==SDRHIT_MARKEDOBJECT || eHit==SDRHIT_UNMARKEDOBJECT) &&
538 (IsTextTool() || (IsEditMode() && IsQuickTextEditMode())) && pHitObj->HasTextEdit())
540 // Ringsum die TextEditArea ein Rand zum Selektieren ohne Textedit
541 Rectangle aBoundRect(pHitObj->GetCurrentBoundRect());
543 // #105130# Force to SnapRect when Fontwork
544 if(pHitObj->ISA(SdrTextObj) && ((SdrTextObj*)pHitObj)->IsFontwork())
546 aBoundRect = pHitObj->GetSnapRect();
549 // #105130# Old test for hit on BoundRect is completely wrong
550 // and never worked, doing it new here.
551 sal_Int32 nTolerance(nHitTolLog);
552 sal_Bool bBoundRectHit(sal_False);
554 if(pOut)
556 nTolerance = pOut->PixelToLogic(Size(2, 0)).Width();
559 if( (aLocalLogicPosition.X() >= aBoundRect.Left() - nTolerance && aLocalLogicPosition.X() <= aBoundRect.Left() + nTolerance)
560 || (aLocalLogicPosition.X() >= aBoundRect.Right() - nTolerance && aLocalLogicPosition.X() <= aBoundRect.Right() + nTolerance)
561 || (aLocalLogicPosition.Y() >= aBoundRect.Top() - nTolerance && aLocalLogicPosition.Y() <= aBoundRect.Top() + nTolerance)
562 || (aLocalLogicPosition.Y() >= aBoundRect.Bottom() - nTolerance && aLocalLogicPosition.Y() <= aBoundRect.Bottom() + nTolerance))
564 bBoundRectHit = sal_True;
567 if(!bBoundRectHit)
569 bool bTEHit(pPV &&
570 SdrObjectPrimitiveHit(*pHitObj, aLocalLogicPosition, 0, *pPV, &pPV->GetVisibleLayers(), true));
572 // TextEdit an Objekten im gesperrten Layer
573 if (pPV->GetLockedLayers().IsSet(pHitObj->GetLayer()))
575 bTEHit=FALSE;
578 if (bTEHit)
580 rVEvt.pRootObj=pObj;
581 pObj=pHitObj;
582 eHit=SDRHIT_TEXTEDITOBJ;
586 if (nHitPassNum!=SDRSEARCHPASS_DIRECT && eHit==SDRHIT_UNMARKEDOBJECT) {
587 eHit=SDRHIT_NONE;
588 pObj=NULL;
589 pPV=NULL;
591 BOOL bMouseLeft=(rVEvt.nMouseCode&MOUSE_LEFT)!=0;
592 BOOL bMouseRight=(rVEvt.nMouseCode&MOUSE_RIGHT)!=0;
593 BOOL bMouseDown=rVEvt.bMouseDown;
594 BOOL bMouseUp=rVEvt.bMouseUp;
595 SdrEventKind eEvent=SDREVENT_NONE;
596 BOOL bIsAction=IsAction();
598 if (bIsAction)
600 if (bMouseDown)
602 if (bMouseRight) eEvent=SDREVENT_BCKACTION;
604 else if (bMouseUp)
606 if (bMouseLeft)
608 eEvent=SDREVENT_ENDACTION;
609 if (IsDragObj())
611 eEvent=SDREVENT_ENDDRAG;
612 rVEvt.bDragWithCopy=MODKEY_CopyDrag;
614 else if (IsCreateObj() || IsInsObjPoint())
616 eEvent=IsCreateObj() ? SDREVENT_ENDCREATE : SDREVENT_ENDINSOBJPOINT;
617 rVEvt.eEndCreateCmd=SDRCREATE_NEXTPOINT;
618 if (MODKEY_PolyPoly) rVEvt.eEndCreateCmd=SDRCREATE_NEXTOBJECT;
619 if (rVEvt.nMouseClicks>1) rVEvt.eEndCreateCmd=SDRCREATE_FORCEEND;
621 else if (IsMarking())
623 eEvent=SDREVENT_ENDMARK;
624 if (!aDragStat.IsMinMoved())
626 eEvent=SDREVENT_BRKMARK;
627 rVEvt.bAddMark=MODKEY_MultiMark;
632 else
634 eEvent=SDREVENT_MOVACTION;
637 else if (eHit==SDRHIT_TEXTEDIT)
639 eEvent=SDREVENT_TEXTEDIT;
641 else if (bMouseDown && bMouseLeft)
643 if (rVEvt.nMouseClicks==2 && rVEvt.nMouseCode==MOUSE_LEFT && pObj!=NULL && pHitObj!=NULL && pHitObj->HasTextEdit() && eHit==SDRHIT_MARKEDOBJECT)
645 rVEvt.pRootObj=pObj;
646 pObj=pHitObj;
647 eEvent=SDREVENT_BEGTEXTEDIT;
649 else if (MODKEY_ForceMark && eHit!=SDRHIT_URLFIELD)
651 eEvent=SDREVENT_BEGMARK; // AddMark,Unmark */
653 else if (eHit==SDRHIT_HELPLINE)
655 eEvent=SDREVENT_BEGDRAGHELPLINE; // nix weiter
657 else if (eHit==SDRHIT_GLUEPOINT)
659 eEvent=SDREVENT_MARKGLUEPOINT; // AddMark+Drag
660 rVEvt.bAddMark=MODKEY_MultiMark || MODKEY_DeepMark; // falls bei Deep nicht getroffen
662 else if (eHit==SDRHIT_HANDLE)
664 eEvent=SDREVENT_BEGDRAGOBJ; // Mark+Drag,AddMark+Drag,DeepMark+Drag,Unmark
665 BOOL bGlue=pHdl->GetKind()==HDL_GLUE;
666 BOOL bPoly=!bGlue && IsPointMarkable(*pHdl);
667 BOOL bMarked=bGlue || bPoly && pHdl->IsSelected();
668 if (bGlue || bPoly)
670 eEvent=bGlue ? SDREVENT_MARKGLUEPOINT : SDREVENT_MARKPOINT;
671 if (MODKEY_DeepMark)
673 rVEvt.bAddMark=TRUE;
674 rVEvt.bPrevNextMark=TRUE;
675 rVEvt.bMarkPrev=MODKEY_DeepBackw;
677 else if (MODKEY_MultiMark)
679 rVEvt.bAddMark=TRUE;
680 rVEvt.bUnmark=bMarked; // Toggle
681 if (bGlue)
683 pObj=pHdl->GetObj();
684 nGlueId=(sal_uInt16)pHdl->GetObjHdlNum();
687 else if (bMarked)
689 eEvent=SDREVENT_BEGDRAGOBJ; // MarkState nicht aendern, nur Drag
693 else if (bInsPolyPt && (MODKEY_PolyPoly || (!MODKEY_MultiMark && !MODKEY_DeepMark)))
695 eEvent=SDREVENT_BEGINSOBJPOINT;
696 rVEvt.bInsPointNewObj=MODKEY_PolyPoly;
698 else if (bInsGluePt && !MODKEY_MultiMark && !MODKEY_DeepMark)
700 eEvent=SDREVENT_BEGINSGLUEPOINT;
702 else if (eHit==SDRHIT_TEXTEDITOBJ)
704 eEvent=SDREVENT_BEGTEXTEDIT; // AddMark+Drag,DeepMark+Drag,Unmark
705 if (MODKEY_MultiMark || MODKEY_DeepMark)
706 { // falls bei Deep nicht getroffen
707 eEvent=SDREVENT_MARKOBJ;
710 else if (eHit==SDRHIT_MACRO)
712 eEvent=SDREVENT_BEGMACROOBJ; // AddMark+Drag
713 if (MODKEY_MultiMark || MODKEY_DeepMark)
714 { // falls bei Deep nicht getroffen
715 eEvent=SDREVENT_MARKOBJ;
718 else if (eHit==SDRHIT_URLFIELD)
720 eEvent=SDREVENT_EXECUTEURL; // AddMark+Drag
721 if (MODKEY_MultiMark || MODKEY_DeepMark)
722 { // falls bei Deep nicht getroffen
723 eEvent=SDREVENT_MARKOBJ;
726 else if (eHit==SDRHIT_MARKEDOBJECT)
728 eEvent=SDREVENT_BEGDRAGOBJ; // DeepMark+Drag,Unmark
730 if (MODKEY_MultiMark || MODKEY_DeepMark)
731 { // falls bei Deep nicht getroffen
732 eEvent=SDREVENT_MARKOBJ;
735 else if (IsCreateMode())
737 eEvent=SDREVENT_BEGCREATEOBJ; // Nix weiter
739 else if (eHit==SDRHIT_UNMARKEDOBJECT)
741 eEvent=SDREVENT_MARKOBJ; // AddMark+Drag
743 else
745 eEvent=SDREVENT_BEGMARK;
748 if (eEvent==SDREVENT_MARKOBJ)
750 rVEvt.bAddMark=MODKEY_MultiMark || MODKEY_DeepMark; // falls bei Deep nicht getroffen
751 rVEvt.bPrevNextMark=MODKEY_DeepMark;
752 rVEvt.bMarkPrev=MODKEY_DeepMark && MODKEY_DeepBackw;
754 if (eEvent==SDREVENT_BEGMARK)
756 rVEvt.bAddMark=MODKEY_MultiMark;
757 rVEvt.bUnmark=MODKEY_Unmark;
760 rVEvt.bIsAction=bIsAction;
761 rVEvt.bIsTextEdit=bIsTextEdit;
762 rVEvt.bTextEditHit=bTextEditHit;
763 rVEvt.aLogicPos=aLocalLogicPosition;
764 rVEvt.pHdl=pHdl;
765 rVEvt.pObj=pObj;
766 if(rVEvt.pRootObj==NULL)
767 rVEvt.pRootObj=pObj;
768 rVEvt.pPV=pPV;
769 rVEvt.nHlplIdx=nHlplIdx;
770 rVEvt.nGlueId=nGlueId;
771 rVEvt.eHit=eHit;
772 rVEvt.eEvent=eEvent;
773 rVEvt.bCaptureMouse=bMouseLeft && bMouseDown && eEvent!=SDREVENT_NONE;
774 rVEvt.bReleaseMouse=bMouseLeft && bMouseUp;
775 #ifdef DGB_UTIL
776 if (rVEvt.pRootObj!=NULL) {
777 if (rVEvt.pRootObj->GetObjList()!=rVEvt.pPV->GetObjList()) {
778 DBG_ERROR("SdrView::PickAnything(): pRootObj->GetObjList()!=pPV->GetObjList() !");
781 #endif
782 return eHit;
785 BOOL SdrView::DoMouseEvent(const SdrViewEvent& rVEvt)
787 BOOL bRet=FALSE;
788 SdrHitKind eHit=rVEvt.eHit;
789 Point aLogicPos(rVEvt.aLogicPos);
791 BOOL bShift=(rVEvt.nMouseCode & KEY_SHIFT) !=0;
792 BOOL bCtrl=(rVEvt.nMouseCode & KEY_MOD1) !=0;
793 BOOL bAlt=(rVEvt.nMouseCode & KEY_MOD2) !=0;
794 BOOL bMouseLeft=(rVEvt.nMouseCode&MOUSE_LEFT)!=0;
795 //BOOL bMouseRight=(rVEvt.nMouseCode&MOUSE_RIGHT)!=0;
796 BOOL bMouseDown=rVEvt.bMouseDown;
797 BOOL bMouseUp=rVEvt.bMouseUp;
798 if (bMouseDown) {
799 if (bMouseLeft) aDragStat.SetMouseDown(TRUE);
800 } else if (bMouseUp) {
801 if (bMouseLeft) aDragStat.SetMouseDown(FALSE);
802 } else { // ansonsten MoueMove
803 aDragStat.SetMouseDown(bMouseLeft);
806 #ifdef MODKEY_NoSnap
807 SetSnapEnabled(!MODKEY_NoSnap);
808 #endif
809 #ifdef MODKEY_Ortho
810 SetOrtho(MODKEY_Ortho!=IsOrthoDesired());
811 #endif
812 #ifdef MODKEY_BigOrtho
813 SetBigOrtho(MODKEY_BigOrtho);
814 #endif
815 #ifdef MODKEY_AngleSnap
816 SetAngleSnapEnabled(MODKEY_AngleSnap);
817 #endif
818 #ifdef MODKEY_CopyDrag
819 SetDragWithCopy(MODKEY_CopyDrag);
820 #endif
821 #ifdef MODKEY_Center
822 SetCreate1stPointAsCenter(MODKEY_Center);
823 SetResizeAtCenter(MODKEY_Center);
824 SetCrookAtCenter(MODKEY_Center);
825 #endif
826 if (bMouseLeft && bMouseDown && rVEvt.bIsTextEdit && (eHit==SDRHIT_UNMARKEDOBJECT || eHit==SDRHIT_NONE)) {
827 SdrEndTextEdit(); // Danebengeklickt, Ende mit Edit
828 // pHdl ist dann ungueltig. Sollte aber egal sein, wein pHdl==NULL
829 // sein muesste (wg. eHit).
831 switch (rVEvt.eEvent) {
832 case SDREVENT_NONE: bRet=FALSE; break;
833 case SDREVENT_TEXTEDIT: bRet=FALSE; break; // Events an die OutlinerView werden hier nicht beruecksichtigt
834 case SDREVENT_MOVACTION: MovAction(aLogicPos); bRet=TRUE; break;
835 case SDREVENT_ENDACTION: EndAction(); bRet=TRUE; break;
836 case SDREVENT_BCKACTION: BckAction(); bRet=TRUE; break;
837 case SDREVENT_BRKACTION: BrkAction(); bRet=TRUE; break;
838 case SDREVENT_ENDMARK : EndAction(); bRet=TRUE; break;
839 case SDREVENT_BRKMARK : {
840 BrkAction();
841 if (!MarkObj(aLogicPos,nHitTolLog,rVEvt.bAddMark)) {
842 // Kein Obj getroffen. Dann werden zuerst
843 // - Markierte Klebepunkte deselektiert
844 // - dann ggf. selektierte Polygonpunkte
845 // - und ansonsten Objekte
846 if (!rVEvt.bAddMark) UnmarkAll();
848 bRet=TRUE;
849 } break;
850 case SDREVENT_ENDCREATE: { // ggf. MarkObj
851 SdrCreateCmd eCmd=SDRCREATE_NEXTPOINT;
852 if (MODKEY_PolyPoly) eCmd=SDRCREATE_NEXTOBJECT;
853 if (rVEvt.nMouseClicks>1) eCmd=SDRCREATE_FORCEEND;
854 if (!EndCreateObj(eCmd)) { // Event fuer Create nicht ausgewerten? -> Markieren
855 if (eHit==SDRHIT_UNMARKEDOBJECT || eHit==SDRHIT_TEXTEDIT) {
856 MarkObj(rVEvt.pRootObj,rVEvt.pPV);
857 if (eHit==SDRHIT_TEXTEDIT)
859 BOOL bRet2(pActualOutDev && OUTDEV_WINDOW == pActualOutDev->GetOutDevType() &&
860 SdrBeginTextEdit(rVEvt.pObj, rVEvt.pPV, (Window*)pActualOutDev, sal_False, (SdrOutliner*)0L));
862 if(bRet2)
864 MouseEvent aMEvt(pActualOutDev->LogicToPixel(aLogicPos),
865 1,rVEvt.nMouseMode,rVEvt.nMouseCode,rVEvt.nMouseCode);
867 OutlinerView* pOLV=GetTextEditOutlinerView();
868 if (pOLV!=NULL) {
869 pOLV->MouseButtonDown(aMEvt); // Event an den Outliner, aber ohne Doppelklick
870 pOLV->MouseButtonUp(aMEvt); // Event an den Outliner, aber ohne Doppelklick
874 bRet=TRUE; // Obj markiert und ggf. TextEdit gestartet
875 } else bRet=FALSE; // Create abgebrochen, sonst nix weiter.
876 } else bRet=TRUE; // EndCreate mit TRUE returniert
877 } break;
878 case SDREVENT_ENDDRAG: {
879 bRet=EndDragObj(IsDragWithCopy());
880 ForceMarkedObjToAnotherPage(); // Undo+Klammerung fehlt noch !!!
881 } break;
882 case SDREVENT_MARKOBJ: { // + ggf. BegDrag
883 if (!rVEvt.bAddMark) UnmarkAllObj();
884 BOOL bUnmark=rVEvt.bUnmark;
885 if (rVEvt.bPrevNextMark) {
886 bRet=MarkNextObj(aLogicPos,nHitTolLog,rVEvt.bMarkPrev);
887 } else {
888 SortMarkedObjects();
889 ULONG nAnz0=GetMarkedObjectCount();
890 bRet=MarkObj(aLogicPos,nHitTolLog,rVEvt.bAddMark);
891 SortMarkedObjects();
892 ULONG nAnz1=GetMarkedObjectCount();
893 bUnmark=nAnz1<nAnz0;
895 if (!bUnmark) {
896 BegDragObj(aLogicPos,NULL,(SdrHdl*)NULL,nMinMovLog);
897 bRet=TRUE;
899 } break;
900 case SDREVENT_MARKPOINT: { // + ggf. BegDrag
901 if (!rVEvt.bAddMark) UnmarkAllPoints();
902 if (rVEvt.bPrevNextMark) {
903 bRet=MarkNextPoint(aLogicPos,rVEvt.bMarkPrev);
904 } else {
905 bRet=MarkPoint(*rVEvt.pHdl,rVEvt.bUnmark);
907 if (!rVEvt.bUnmark && !rVEvt.bPrevNextMark) {
908 BegDragObj(aLogicPos,NULL,rVEvt.pHdl,nMinMovLog);
909 bRet=TRUE;
911 } break;
912 case SDREVENT_MARKGLUEPOINT: { // + ggf. BegDrag
913 if (!rVEvt.bAddMark) UnmarkAllGluePoints();
914 if (rVEvt.bPrevNextMark) {
915 bRet=MarkNextGluePoint(aLogicPos,rVEvt.bMarkPrev);
916 } else {
917 bRet=MarkGluePoint(rVEvt.pObj,rVEvt.nGlueId,rVEvt.pPV,rVEvt.bUnmark);
919 if (!rVEvt.bUnmark && !rVEvt.bPrevNextMark) {
920 SdrHdl* pHdl=GetGluePointHdl(rVEvt.pObj,rVEvt.nGlueId);
921 BegDragObj(aLogicPos,NULL,pHdl,nMinMovLog);
922 bRet=TRUE;
924 } break;
925 case SDREVENT_BEGMARK: bRet=BegMark(aLogicPos,rVEvt.bAddMark,rVEvt.bUnmark); break;
926 case SDREVENT_BEGINSOBJPOINT: bRet = BegInsObjPoint(aLogicPos, MODKEY_PolyPoly); break;
927 case SDREVENT_ENDINSOBJPOINT: {
928 SdrCreateCmd eCmd=SDRCREATE_NEXTPOINT;
929 if (MODKEY_PolyPoly) eCmd=SDRCREATE_NEXTOBJECT;
930 if (rVEvt.nMouseClicks>1) eCmd=SDRCREATE_FORCEEND;
931 EndInsObjPoint(eCmd);
932 bRet=TRUE;
933 } break;
934 case SDREVENT_BEGINSGLUEPOINT: bRet=BegInsGluePoint(aLogicPos); break;
935 case SDREVENT_BEGDRAGHELPLINE: bRet=BegDragHelpLine(rVEvt.nHlplIdx,rVEvt.pPV); break;
936 case SDREVENT_BEGDRAGOBJ: bRet=BegDragObj(aLogicPos,NULL,rVEvt.pHdl,nMinMovLog); break;
937 case SDREVENT_BEGCREATEOBJ: {
938 if (nAktInvent==SdrInventor && nAktIdent==OBJ_CAPTION) {
939 long nHgt=SdrEngineDefaults::GetFontHeight();
940 bRet=BegCreateCaptionObj(aLogicPos,Size(5*nHgt,2*nHgt));
941 } else bRet=BegCreateObj(aLogicPos);
942 } break;
943 case SDREVENT_BEGMACROOBJ: bRet=BegMacroObj(aLogicPos,nHitTolLog,rVEvt.pObj,rVEvt.pPV,(Window*)pActualOutDev); break;
944 case SDREVENT_BEGTEXTEDIT: {
945 if (!IsObjMarked(rVEvt.pObj)) {
946 UnmarkAllObj();
947 MarkObj(rVEvt.pRootObj,rVEvt.pPV);
950 bRet = pActualOutDev && OUTDEV_WINDOW == pActualOutDev->GetOutDevType()&&
951 SdrBeginTextEdit(rVEvt.pObj, rVEvt.pPV, (Window*)pActualOutDev, sal_False, (SdrOutliner*)0L);
953 if(bRet)
955 MouseEvent aMEvt(pActualOutDev->LogicToPixel(aLogicPos),
956 1,rVEvt.nMouseMode,rVEvt.nMouseCode,rVEvt.nMouseCode);
957 OutlinerView* pOLV=GetTextEditOutlinerView();
958 if (pOLV!=NULL) pOLV->MouseButtonDown(aMEvt); // Event an den Outliner, aber ohne Doppelklick
960 } break;
961 default: break;
962 } // switch
963 if (bRet && pActualOutDev!=NULL && pActualOutDev->GetOutDevType()==OUTDEV_WINDOW) {
964 Window* pWin=(Window*)pActualOutDev;
965 // Maus links gedrueckt?
966 BOOL bLeftDown=(rVEvt.nMouseCode&MOUSE_LEFT)!=0 && rVEvt.bMouseDown;
967 // Maus links losgelassen?
968 BOOL bLeftUp=(rVEvt.nMouseCode&MOUSE_LEFT)!=0 && rVEvt.bMouseUp;
969 // Maus links gedrueckt oder gehalten?
970 BOOL bLeftDown1=(rVEvt.nMouseCode&MOUSE_LEFT)!=0 && !rVEvt.bMouseUp;
971 pWin->SetPointer(GetPreferedPointer(rVEvt.aLogicPos,pWin,
972 rVEvt.nMouseCode & (KEY_SHIFT|KEY_MOD1|KEY_MOD2),bLeftDown1));
973 BOOL bAction=IsAction();
974 if (bLeftDown && bAction) pWin->CaptureMouse();
975 else if (bLeftUp || (rVEvt.bIsAction && !bAction)) pWin->ReleaseMouse();
977 return bRet;
979 #include <svx/outlobj.hxx>
981 Pointer SdrView::GetPreferedPointer(const Point& rMousePos, const OutputDevice* pOut, USHORT nModifier, BOOL bLeftDown) const
983 // Actions
984 if (IsCreateObj())
986 return pAktCreate->GetCreatePointer();
988 if (mpCurrentSdrDragMethod)
990 if ((IsDraggingPoints() || IsDraggingGluePoints()) && IsMouseHideWhileDraggingPoints())
991 return Pointer(POINTER_NULL);
993 OSL_TRACE("SdrView::GetPreferedPointer(%lx) %lx\n", this, mpCurrentSdrDragMethod);
995 return mpCurrentSdrDragMethod->GetSdrDragPointer();
997 if (IsMarkObj() || IsMarkPoints() || IsMarkGluePoints() || IsEncirclement() || IsSetPageOrg()) return Pointer(POINTER_ARROW);
998 if (IsDragHelpLine()) return GetDraggedHelpLinePointer();
999 if (IsMacroObj()) {
1000 SdrObjMacroHitRec aHitRec;
1001 aHitRec.aPos=pOut->LogicToPixel(rMousePos);
1002 aHitRec.aDownPos=aMacroDownPos;
1003 aHitRec.nTol=nMacroTol;
1004 aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers();
1005 aHitRec.pPageView=pMacroPV;
1006 aHitRec.pOut=pMacroWin;
1007 aHitRec.bDown=bMacroDown;
1008 return pMacroObj->GetMacroPointer(aHitRec);
1010 //USHORT nTol=nHitTolLog;
1011 // TextEdit, ObjEdit, Macro
1012 if (IsTextEdit() && (IsTextEditInSelectionMode() || IsTextEditHit(rMousePos,0/*nTol*/)))
1014 if(!pOut || IsTextEditInSelectionMode())
1016 if(pTextEditOutliner->IsVertical())
1017 return Pointer(POINTER_TEXT_VERTICAL);
1018 else
1019 return Pointer(POINTER_TEXT);
1021 // hier muss besser der Outliner was liefern:
1022 Point aPos(pOut->LogicToPixel(rMousePos));
1023 Pointer aPointer(pTextEditOutlinerView->GetPointer(aPos));
1024 if (aPointer==POINTER_ARROW)
1026 if(pTextEditOutliner->IsVertical())
1027 aPointer = POINTER_TEXT_VERTICAL;
1028 else
1029 aPointer = POINTER_TEXT;
1031 return aPointer;
1034 SdrViewEvent aVEvt;
1035 aVEvt.nMouseCode=(nModifier&(KEY_SHIFT|KEY_MOD1|KEY_MOD2))|MOUSE_LEFT; // um zu sehen, was bei MouseLeftDown passieren wuerde
1036 aVEvt.bMouseDown=!bLeftDown; // Was waere wenn ...
1037 aVEvt.bMouseUp=bLeftDown; // Was waere wenn ...
1038 if (pOut!=NULL)
1039 ((SdrView*)this)->SetActualWin(pOut);
1040 SdrHitKind eHit=PickAnything(rMousePos,aVEvt);
1041 SdrEventKind eEvent=aVEvt.eEvent;
1042 switch (eEvent)
1044 case SDREVENT_BEGCREATEOBJ:
1045 return aAktCreatePointer;
1046 case SDREVENT_MARKOBJ:
1047 case SDREVENT_BEGMARK:
1048 return Pointer(POINTER_ARROW);
1049 case SDREVENT_MARKPOINT:
1050 case SDREVENT_MARKGLUEPOINT:
1051 return Pointer(POINTER_MOVEPOINT);
1052 case SDREVENT_BEGINSOBJPOINT:
1053 case SDREVENT_BEGINSGLUEPOINT:
1054 return Pointer(POINTER_CROSS);
1055 case SDREVENT_EXECUTEURL:
1056 return Pointer(POINTER_REFHAND);
1057 case SDREVENT_BEGMACROOBJ:
1059 SdrObjMacroHitRec aHitRec;
1060 aHitRec.aPos=aVEvt.aLogicPos;
1061 aHitRec.aDownPos=aHitRec.aPos;
1062 aHitRec.nTol=nHitTolLog;
1063 aHitRec.pVisiLayer=&aVEvt.pPV->GetVisibleLayers();
1064 aHitRec.pPageView=aVEvt.pPV;
1065 aHitRec.pOut=(OutputDevice*)pOut;
1066 return aVEvt.pObj->GetMacroPointer(aHitRec);
1068 default: break;
1069 } // switch
1071 switch(eHit)
1073 case SDRHIT_CELL:
1074 return Pointer(POINTER_ARROW);
1075 case SDRHIT_HELPLINE :
1076 return aVEvt.pPV->GetHelpLines()[aVEvt.nHlplIdx].GetPointer();
1077 case SDRHIT_GLUEPOINT:
1078 return Pointer(POINTER_MOVEPOINT);
1079 case SDRHIT_TEXTEDIT :
1080 case SDRHIT_TEXTEDITOBJ:
1082 SdrTextObj* pText = dynamic_cast< SdrTextObj* >( aVEvt.pObj );
1083 if(pText && pText->HasText())
1085 OutlinerParaObject* pParaObj = pText->GetOutlinerParaObject();
1086 if(pParaObj && pParaObj->IsVertical())
1087 return Pointer(POINTER_TEXT_VERTICAL);
1089 return Pointer(POINTER_TEXT);
1091 default: break;
1094 BOOL bMarkHit=eHit==SDRHIT_MARKEDOBJECT;
1095 SdrHdl* pHdl=aVEvt.pHdl;
1096 // Nun die Pointer fuer Dragging checken
1097 if (pHdl!=NULL || bMarkHit) {
1098 SdrHdlKind eHdl= pHdl!=NULL ? pHdl->GetKind() : HDL_MOVE;
1099 BOOL bCorner=pHdl!=NULL && pHdl->IsCornerHdl();
1100 BOOL bVertex=pHdl!=NULL && pHdl->IsVertexHdl();
1101 BOOL bMov=eHdl==HDL_MOVE;
1102 if (bMov && (eDragMode==SDRDRAG_MOVE || eDragMode==SDRDRAG_RESIZE || bMarkedHitMovesAlways)) {
1103 if (!IsMoveAllowed()) return Pointer(POINTER_ARROW); // weil Doppelklick oder Drag&Drop moeglich
1104 return Pointer(POINTER_MOVE);
1106 switch (eDragMode) {
1107 case SDRDRAG_ROTATE: {
1108 if ((bCorner || bMov) && !IsRotateAllowed(TRUE))
1109 return Pointer(POINTER_NOTALLOWED);
1111 // Sind 3D-Objekte selektiert?
1112 BOOL b3DObjSelected = FALSE;
1113 #ifndef SVX_LIGHT
1114 for (UINT32 a=0; !b3DObjSelected && a<GetMarkedObjectCount(); a++) {
1115 SdrObject* pObj = GetMarkedObjectByIndex(a);
1116 if(pObj && pObj->ISA(E3dObject))
1117 b3DObjSelected = TRUE;
1119 #endif
1120 // Falls es um ein 3D-Objekt geht, muss trotz !IsShearAllowed
1121 // weitergemacht werden, da es sich um eine Rotation statt um
1122 // einen Shear handelt
1123 if (bVertex && !IsShearAllowed() && !b3DObjSelected)
1124 return Pointer(POINTER_NOTALLOWED);
1125 if (bMov)
1126 return Pointer(POINTER_ROTATE);
1127 } break;
1128 case SDRDRAG_SHEAR: case SDRDRAG_DISTORT: {
1129 if (bCorner) {
1130 if (!IsDistortAllowed(TRUE) && !IsDistortAllowed(FALSE)) return Pointer(POINTER_NOTALLOWED);
1131 else return Pointer(POINTER_REFHAND);
1133 if (bVertex && !IsShearAllowed()) return Pointer(POINTER_NOTALLOWED);
1134 if (bMov) {
1135 if (!IsMoveAllowed()) return Pointer(POINTER_ARROW); // weil Doppelklick oder Drag&Drop moeglich
1136 return Pointer(POINTER_MOVE);
1138 } break;
1139 case SDRDRAG_MIRROR: {
1140 if (bCorner || bVertex || bMov) {
1141 SdrHdl* pH1=aHdl.GetHdl(HDL_REF1);
1142 SdrHdl* pH2=aHdl.GetHdl(HDL_REF2);
1143 BOOL b90=FALSE;
1144 BOOL b45=FALSE;
1145 Point aDif;
1146 if (pH1!=NULL && pH2!=NULL) {
1147 aDif=pH2->GetPos()-pH1->GetPos();
1148 b90=(aDif.X()==0) || aDif.Y()==0;
1149 b45=b90 || (Abs(aDif.X())==Abs(aDif.Y()));
1151 BOOL bNo=FALSE;
1152 if (!IsMirrorAllowed(TRUE,TRUE)) bNo=TRUE; // Spiegeln ueberhaupt nicht erlaubt
1153 if (!IsMirrorAllowed(FALSE,FALSE) && !b45) bNo=TRUE; // freies Spiegeln nicht erlaubt
1154 if (!IsMirrorAllowed(TRUE,FALSE) && !b90) bNo=TRUE; // Spiegeln hor/ver erlaubt
1155 if (bNo) return Pointer(POINTER_NOTALLOWED);
1156 if (b90) {
1157 return Pointer(POINTER_MIRROR);
1159 return Pointer(POINTER_MIRROR);
1161 } break;
1163 case SDRDRAG_TRANSPARENCE:
1165 if(!IsTransparenceAllowed())
1166 return Pointer(POINTER_NOTALLOWED);
1168 return Pointer(POINTER_REFHAND);
1171 case SDRDRAG_GRADIENT:
1173 if(!IsGradientAllowed())
1174 return Pointer(POINTER_NOTALLOWED);
1176 return Pointer(POINTER_REFHAND);
1179 case SDRDRAG_CROOK: {
1180 if (bCorner || bVertex || bMov) {
1181 if (!IsCrookAllowed(TRUE) && !IsCrookAllowed(FALSE)) return Pointer(POINTER_NOTALLOWED);
1182 return Pointer(POINTER_CROOK);
1186 case SDRDRAG_CROP:
1188 return Pointer(POINTER_CROP);
1191 default: {
1192 if ((bCorner || bVertex) && !IsResizeAllowed(TRUE)) return Pointer(POINTER_NOTALLOWED);
1195 if (pHdl!=NULL) return pHdl->GetPointer();
1196 if (bMov) {
1197 if (!IsMoveAllowed()) return Pointer(POINTER_ARROW); // weil Doppelklick oder Drag&Drop moeglich
1198 return Pointer(POINTER_MOVE);
1201 if (eEditMode==SDREDITMODE_CREATE) return aAktCreatePointer;
1202 return Pointer(POINTER_ARROW);
1205 XubString SdrView::GetStatusText()
1207 XubString aStr;
1208 XubString aName;
1210 aStr.AppendAscii("nix");
1212 if (pAktCreate!=NULL)
1214 aStr=pAktCreate->getSpecialDragComment(aDragStat);
1216 if(!aStr.Len())
1218 pAktCreate->TakeObjNameSingul(aName);
1219 aStr = ImpGetResStr(STR_ViewCreateObj);
1222 else if (mpCurrentSdrDragMethod)
1224 if (bInsPolyPoint || IsInsertGluePoint())
1226 aStr=aInsPointUndoStr;
1228 else
1230 if (aDragStat.IsMinMoved())
1232 OSL_TRACE("SdrView::GetStatusText(%lx) %lx\n", this, mpCurrentSdrDragMethod);
1233 mpCurrentSdrDragMethod->TakeSdrDragComment(aStr);
1237 else if(IsMarkObj())
1239 if(AreObjectsMarked())
1241 aStr = ImpGetResStr(STR_ViewMarkMoreObjs);
1243 else
1245 aStr = ImpGetResStr(STR_ViewMarkObjs);
1248 else if(IsMarkPoints())
1250 if(HasMarkedPoints())
1252 aStr = ImpGetResStr(STR_ViewMarkMorePoints);
1254 else
1256 aStr = ImpGetResStr(STR_ViewMarkPoints);
1258 } else if (IsMarkGluePoints())
1260 if(HasMarkedGluePoints())
1262 aStr = ImpGetResStr(STR_ViewMarkMoreGluePoints);
1264 else
1266 aStr = ImpGetResStr(STR_ViewMarkGluePoints);
1269 else if (IsTextEdit() && pTextEditOutlinerView!=NULL) {
1270 aStr=ImpGetResStr(STR_ViewTextEdit); // "TextEdit - Zeile y Spalte x";
1271 ESelection aSel(pTextEditOutlinerView->GetSelection());
1272 long nPar=aSel.nEndPara,nLin=0,nCol=aSel.nEndPos;
1273 if (aSel.nEndPara>0) {
1274 for (USHORT nParaNum=0; nParaNum<aSel.nEndPara; nParaNum++) {
1275 nLin+=pTextEditOutliner->GetLineCount(nParaNum);
1278 // Noch 'ne kleine Unschoenheit:
1279 // Am Ende einer Zeile eines mehrzeiligen Absatzes wird die Position
1280 // der naechsten Zeile des selben Absatzes angezeigt, so es eine solche
1281 // gibt.
1282 USHORT nParaLine=0;
1283 ULONG nParaLineAnz=pTextEditOutliner->GetLineCount(aSel.nEndPara);
1284 BOOL bBrk=FALSE;
1285 while (!bBrk) {
1286 USHORT nLen=pTextEditOutliner->GetLineLen(aSel.nEndPara,nParaLine);
1287 BOOL bLastLine=(nParaLine==nParaLineAnz-1);
1288 if (nCol>nLen || (!bLastLine && nCol==nLen)) {
1289 nCol-=nLen;
1290 nLin++;
1291 nParaLine++;
1292 } else bBrk=TRUE;
1293 if (nLen==0) bBrk=TRUE; // Sicherheitshalber
1296 aStr.SearchAndReplaceAscii("%1", UniString::CreateFromInt32(nPar + 1));
1297 aStr.SearchAndReplaceAscii("%2", UniString::CreateFromInt32(nLin + 1));
1298 aStr.SearchAndReplaceAscii("%3", UniString::CreateFromInt32(nCol + 1));
1300 #ifndef PRODUCT
1301 aStr += UniString( RTL_CONSTASCII_USTRINGPARAM( ", Level " ) );
1302 aStr += UniString::CreateFromInt32( pTextEditOutliner->GetDepth( aSel.nEndPara ) );
1303 #endif
1306 if(aStr.EqualsAscii("nix"))
1308 if (AreObjectsMarked()) {
1309 ImpTakeDescriptionStr(STR_ViewMarked,aStr);
1310 if (IsGluePointEditMode()) {
1311 if (HasMarkedGluePoints()) {
1312 ImpTakeDescriptionStr(STR_ViewMarked,aStr,0,IMPSDR_GLUEPOINTSDESCRIPTION);
1314 } else {
1315 if (HasMarkedPoints()) {
1316 ImpTakeDescriptionStr(STR_ViewMarked,aStr,0,IMPSDR_POINTSDESCRIPTION);
1319 } else {
1320 aStr.Erase();
1323 else if(aName.Len())
1325 aStr.SearchAndReplaceAscii("%1", aName);
1328 if(aStr.Len())
1330 // ersten Buchstaben gross schreiben
1331 String aTmpStr(aStr.Copy(0, 1));
1332 aTmpStr.ToUpperAscii();
1333 aStr.Replace(0, 1, aTmpStr);
1335 return aStr;
1338 SdrViewContext SdrView::GetContext() const
1340 if( IsGluePointEditMode() )
1341 return SDRCONTEXT_GLUEPOINTEDIT;
1343 const ULONG nMarkAnz = GetMarkedObjectCount();
1345 if( HasMarkablePoints() && !IsFrameHandles() )
1347 BOOL bPath=TRUE;
1348 for( ULONG nMarkNum = 0; nMarkNum < nMarkAnz && bPath; nMarkNum++ )
1349 if (!GetMarkedObjectByIndex(nMarkNum)->ISA(SdrPathObj))
1350 bPath=FALSE;
1352 if( bPath )
1353 return SDRCONTEXT_POINTEDIT;
1356 if( GetMarkedObjectCount() )
1358 BOOL bGraf = TRUE, bMedia = TRUE, bTable = TRUE;
1360 for( ULONG nMarkNum = 0; nMarkNum < nMarkAnz && ( bGraf || bMedia ); nMarkNum++ )
1362 const SdrObject* pMarkObj = GetMarkedObjectByIndex( nMarkNum );
1364 if( !pMarkObj->ISA( SdrGrafObj ) )
1365 bGraf = FALSE;
1367 if( !pMarkObj->ISA( SdrMediaObj ) )
1368 bMedia = FALSE;
1370 if( !pMarkObj->ISA( ::sdr::table::SdrTableObj ) )
1371 bTable = FALSE;
1374 if( bGraf )
1375 return SDRCONTEXT_GRAPHIC;
1376 else if( bMedia )
1377 return SDRCONTEXT_MEDIA;
1378 else if( bTable )
1379 return SDRCONTEXT_TABLE;
1382 return SDRCONTEXT_STANDARD;
1385 void SdrView::MarkAll()
1387 if (IsTextEdit()) {
1388 GetTextEditOutlinerView()->SetSelection(ESelection(0,0,0xFFFF,0xFFFF));
1389 #ifdef DBG_UTIL
1390 if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
1391 #endif
1392 } else if (IsGluePointEditMode()) MarkAllGluePoints();
1393 else if (HasMarkablePoints()) MarkAllPoints();
1394 else MarkAllObj();
1397 void SdrView::UnmarkAll()
1399 if (IsTextEdit()) {
1400 ESelection eSel=GetTextEditOutlinerView()->GetSelection();
1401 eSel.nStartPara=eSel.nEndPara;
1402 eSel.nStartPos=eSel.nEndPos;
1403 GetTextEditOutlinerView()->SetSelection(eSel);
1404 #ifdef DBG_UTIL
1405 if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
1406 #endif
1407 } else if (HasMarkedGluePoints()) UnmarkAllGluePoints();
1408 else if (HasMarkedPoints()) UnmarkAllPoints(); // ! Marked statt Markable !
1409 else UnmarkAllObj();
1412 BOOL SdrView::IsAllMarked() const
1414 if (IsTextEdit()) {
1415 return ImpIsTextEditAllSelected();
1417 if (IsGluePointEditMode()) {
1418 ULONG nAnz=GetMarkableGluePointCount();
1419 return nAnz!=0 && nAnz==GetMarkedGluePointCount();
1421 if (HasMarkedPoints()) {
1422 ULONG nAnz=GetMarkablePointCount();
1423 return nAnz!=0 && nAnz==GetMarkedPointCount();
1425 ULONG nAnz=GetMarkableObjCount();
1426 return nAnz!=0 && nAnz == GetMarkedObjectCount();
1429 BOOL SdrView::IsMarkPossible() const
1431 if(IsTextEdit())
1433 return SdrTextObj::HasTextImpl( pTextEditOutliner );
1436 if(IsGluePointEditMode())
1438 return HasMarkableGluePoints();
1441 if(HasMarkedPoints())
1443 return HasMarkablePoints();
1446 return HasMarkableObj();
1449 BOOL SdrView::IsAllMarkPrevNextPossible() const
1451 if (IsTextEdit()) {
1452 return FALSE;
1454 if (IsGluePointEditMode()) {
1455 return HasMarkableGluePoints();
1457 if (HasMarkedPoints()) {
1458 return HasMarkablePoints();
1460 return HasMarkableObj();
1463 BOOL SdrView::MarkNext(BOOL bPrev)
1465 if (IsTextEdit()) {
1466 return FALSE;
1468 if (IsGluePointEditMode() && HasMarkedGluePoints()) {
1469 return MarkNextGluePoint(bPrev);
1471 if (HasMarkedPoints()) {
1472 return MarkNextPoint(bPrev);
1474 return MarkNextObj(bPrev);
1477 BOOL SdrView::MarkNext(const Point& rPnt, BOOL bPrev)
1479 if (IsTextEdit()) {
1480 return FALSE;
1482 if (IsGluePointEditMode() && HasMarkedGluePoints()) {
1483 //return MarkNextGluePoint(rPnt,bPrev); fehlende Implementation !!!
1485 if (HasMarkedPoints()) {
1486 //return MarkNextPoint(rPnt,bPrev); fehlende Implementation !!!
1488 return MarkNextObj(rPnt,-2,bPrev);
1491 const Rectangle& SdrView::GetMarkedRect() const
1493 if (IsGluePointEditMode() && HasMarkedGluePoints()) {
1494 return GetMarkedGluePointsRect();
1496 if (HasMarkedPoints()) {
1497 return GetMarkedPointsRect();
1499 return GetMarkedObjRect();
1502 void SdrView::SetMarkedRect(const Rectangle& rRect)
1504 if (IsGluePointEditMode() && HasMarkedGluePoints()) {
1505 //SetMarkedGluePointsRect(rRect); fehlende Implementation !!!
1506 } else if (HasMarkedPoints()) {
1507 //SetMarkedPointsRect(rRect); fehlende Implementation !!!
1508 } else SetMarkedObjRect(rRect);
1511 void SdrView::DeleteMarked()
1513 if (IsTextEdit())
1515 SdrObjEditView::KeyInput(KeyEvent(0,KeyCode(KEYFUNC_DELETE)),pTextEditWin);
1517 else
1519 if( mxSelectionController.is() && mxSelectionController->DeleteMarked() )
1521 // action already performed by current selection controller, do nothing
1523 else if (IsGluePointEditMode() && HasMarkedGluePoints())
1525 DeleteMarkedGluePoints();
1527 else if (GetContext()==SDRCONTEXT_POINTEDIT && HasMarkedPoints())
1529 DeleteMarkedPoints();
1531 else
1533 DeleteMarkedObj();
1538 BOOL SdrView::BegMark(const Point& rPnt, BOOL bAddMark, BOOL bUnmark)
1540 if (bUnmark) bAddMark=TRUE;
1541 if (IsGluePointEditMode()) {
1542 if (!bAddMark) UnmarkAllGluePoints();
1543 return BegMarkGluePoints(rPnt,bUnmark);
1544 } else if (HasMarkablePoints()) {
1545 if (!bAddMark) UnmarkAllPoints();
1546 return BegMarkPoints(rPnt,bUnmark);
1547 } else {
1548 if (!bAddMark) UnmarkAllObj();
1549 return BegMarkObj(rPnt,bUnmark);
1553 BOOL SdrView::IsDeleteMarkedPossible() const
1555 if (IsReadOnly()) return FALSE;
1556 if (IsTextEdit()) return TRUE;
1557 if (IsGluePointEditMode() && HasMarkedGluePoints()) return TRUE;
1558 if (HasMarkedPoints()) return TRUE;
1559 return IsDeleteMarkedObjPossible();
1562 void SdrView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
1564 if( rHint.ISA( SfxSimpleHint ) && ( (SfxSimpleHint&) rHint ).GetId() == SFX_HINT_ACCESSIBILITY_CHANGED )
1566 onAccessibilityOptionsChanged();
1569 SdrCreateView::Notify(rBC, rHint);
1572 SvtAccessibilityOptions& SdrView::getAccessibilityOptions()
1574 return maAccessibilityOptions;
1577 /** method is called whenever the global SvtAccessibilityOptions is changed */
1578 void SdrView::onAccessibilityOptionsChanged()
1582 void SdrView::SetMasterPagePaintCaching(sal_Bool bOn)
1584 if(mbMasterPagePaintCaching != bOn)
1586 mbMasterPagePaintCaching = bOn;
1588 // reset at all SdrPageWindow's
1589 SdrPageView* pPageView = GetSdrPageView();
1591 if(pPageView)
1593 for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
1595 SdrPageWindow* pPageWindow = pPageView->GetPageWindow(b);
1596 DBG_ASSERT(pPageWindow, "SdrView::SetMasterPagePaintCaching: Corrupt SdrPageWindow list (!)");
1598 // force deletion of ObjectContact, so at re-display all VOCs
1599 // will be re-created with updated flag setting
1600 pPageWindow->ResetObjectContact();
1603 // force redraw of this view
1604 pPageView->InvalidateAllWin();
1608 // eof