merge the formfield patch from ooo-build
[ooovba.git] / svx / source / svdraw / svdmrkv.cxx
blob9e78481c08770a3e62ecac3d327e6b143285b823
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: svdmrkv.cxx,v $
10 * $Revision: 1.39.74.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"
34 #include <svx/svdmrkv.hxx>
35 #include <svx/svdetc.hxx>
36 #include <svx/svdoedge.hxx>
37 #include "svdglob.hxx"
38 #include "svditext.hxx"
39 #include <svx/svdview.hxx>
40 #include <svx/svdpagv.hxx>
41 #include <svx/svdpage.hxx>
42 #include "svddrgm1.hxx"
44 #ifdef DBG_UTIL
45 #include <svdibrow.hxx>
46 #endif
48 #include <svx/svdoole2.hxx>
49 #include <svx/xgrad.hxx>
50 #include <svx/xflgrit.hxx>
51 #include "gradtrns.hxx"
52 #include <svx/xflftrit.hxx>
53 #include <svx/dialmgr.hxx>
54 #include "svdstr.hrc"
55 #include <svx/svdundo.hxx>
56 #include <svx/svdopath.hxx>
57 #include <svx/scene3d.hxx>
58 #include <svx/svdovirt.hxx>
59 #include <svx/sdr/overlay/overlayrollingrectangle.hxx>
60 #include <svx/sdr/overlay/overlaymanager.hxx>
61 #include <sdrpaintwindow.hxx>
62 #include <svx/sdrpagewindow.hxx>
63 #include <svx/sdrhittesthelper.hxx>
65 ////////////////////////////////////////////////////////////////////////////////////////////////////
66 // predefines
68 class SdrUnoControlList;
70 ////////////////////////////////////////////////////////////////////////////////////////////////////
71 // #114409#-3 Migrate Marking of Objects, Points and GluePoints
73 class ImplMarkingOverlay
75 // The OverlayObjects
76 ::sdr::overlay::OverlayObjectList maObjects;
78 // The remembered second position in logical coodinates
79 basegfx::B2DPoint maSecondPosition;
81 // bitfield
82 // A flag to remember if the action is for unmarking.
83 unsigned mbUnmarking : 1;
85 public:
86 ImplMarkingOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos, sal_Bool bUnmarking = sal_False);
87 ~ImplMarkingOverlay();
89 void SetSecondPosition(const basegfx::B2DPoint& rNewPosition);
90 sal_Bool IsUnmarking() const { return mbUnmarking; }
93 ImplMarkingOverlay::ImplMarkingOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos, sal_Bool bUnmarking)
94 : maSecondPosition(rStartPos),
95 mbUnmarking(bUnmarking)
97 for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
99 SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
100 ::sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager();
102 if(pTargetOverlay)
104 ::sdr::overlay::OverlayRollingRectangleStriped* pNew = new ::sdr::overlay::OverlayRollingRectangleStriped(
105 rStartPos, rStartPos, false);
106 pTargetOverlay->add(*pNew);
107 maObjects.append(*pNew);
112 ImplMarkingOverlay::~ImplMarkingOverlay()
114 // The OverlayObjects are cleared using the destructor of OverlayObjectList.
115 // That destructor calls clear() at the list which removes all objects from the
116 // OverlayManager and deletes them.
119 void ImplMarkingOverlay::SetSecondPosition(const basegfx::B2DPoint& rNewPosition)
121 if(rNewPosition != maSecondPosition)
123 // apply to OverlayObjects
124 for(sal_uInt32 a(0L); a < maObjects.count(); a++)
126 ::sdr::overlay::OverlayRollingRectangleStriped& rCandidate = (::sdr::overlay::OverlayRollingRectangleStriped&)maObjects.getOverlayObject(a);
127 rCandidate.setSecondPosition(rNewPosition);
130 // remember new position
131 maSecondPosition = rNewPosition;
135 ////////////////////////////////////////////////////////////////////////////////////////////////////
136 ////////////////////////////////////////////////////////////////////////////////////////////////////
138 // @@ @@ @@@@ @@@@@ @@ @@ @@ @@ @@ @@@@@ @@ @@
139 // @@@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
140 // @@@@@@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@
141 // @@@@@@@ @@@@@@ @@@@@ @@@@ @@@@@ @@ @@@@ @@@@@@@
142 // @@ @ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@@@@@@
143 // @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@@ @@@
144 // @@ @@ @@ @@ @@ @@ @@ @@ @ @@ @@@@@ @@ @@
146 ////////////////////////////////////////////////////////////////////////////////////////////////////
147 ////////////////////////////////////////////////////////////////////////////////////////////////////
149 void SdrMarkView::ImpClearVars()
151 eDragMode=SDRDRAG_MOVE;
152 //HMHbHdlShown=FALSE;
153 bRefHdlShownOnly=FALSE;
154 eEditMode=SDREDITMODE_EDIT;
155 eEditMode0=SDREDITMODE_EDIT;
156 bDesignMode=FALSE;
157 pMarkedObj=NULL;
158 pMarkedPV=NULL;
159 bForceFrameHandles=FALSE;
160 bPlusHdlAlways=FALSE;
161 nFrameHandlesLimit=50;
162 bInsPolyPoint=FALSE;
163 mnInsPointNum = 0L;
164 bMarkedObjRectDirty=FALSE;
165 bMarkedPointsRectsDirty=FALSE;
166 mbMarkHandlesHidden = false;
167 bMrkPntDirty=FALSE;
168 bMarkHdlWhenTextEdit=FALSE;
169 bMarkableObjCountDirty=FALSE; // noch nicht implementiert
170 nMarkableObjCount=0; // noch nicht implementiert
172 // #114409#-3 Migrate selections
173 BrkMarkObj();
174 BrkMarkPoints();
175 BrkMarkGluePoints();
178 SdrMarkView::SdrMarkView(SdrModel* pModel1, OutputDevice* pOut)
179 : SdrSnapView(pModel1,pOut),
180 mpMarkObjOverlay(0L),
181 mpMarkPointsOverlay(0L),
182 mpMarkGluePointsOverlay(0L),
183 aHdl(this),
184 mpSdrViewSelection(new sdr::ViewSelection())
186 ImpClearVars();
187 StartListening(*pModel1);
190 SdrMarkView::~SdrMarkView()
192 // #114409#-3 Migrate selections
193 BrkMarkObj();
194 BrkMarkPoints();
195 BrkMarkGluePoints();
196 delete mpSdrViewSelection;
199 void __EXPORT SdrMarkView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
201 SdrHint* pSdrHint=PTR_CAST(SdrHint,&rHint);
202 if (pSdrHint!=NULL)
204 SdrHintKind eKind=pSdrHint->GetKind();
206 if (eKind==HINT_OBJCHG || eKind==HINT_OBJINSERTED || eKind==HINT_OBJREMOVED)
208 bMarkedObjRectDirty=TRUE;
209 bMarkedPointsRectsDirty=TRUE;
211 /* removed for now since this breaks existing code who iterates over the mark list and sequentially replaces objects
212 if( eKind==HINT_OBJREMOVED && IsObjMarked( const_cast<SdrObject*>(pSdrHint->GetObject()) ) )
214 MarkObj( const_cast<SdrObject*>(pSdrHint->GetObject()), GetSdrPageView(), TRUE );
218 SdrSnapView::Notify(rBC,rHint);
221 void SdrMarkView::ModelHasChanged()
223 SdrPaintView::ModelHasChanged();
224 GetMarkedObjectListWriteAccess().SetNameDirty();
225 bMarkedObjRectDirty=TRUE;
226 bMarkedPointsRectsDirty=TRUE;
227 // Es sind beispielsweise Obj markiert und maMarkedObjectListist Sorted.
228 // In einer anderen View 2 wird die ObjOrder veraendert
229 // (z.B. MovToTop()). Dann ist Neusortieren der MarkList erforderlich.
230 GetMarkedObjectListWriteAccess().SetUnsorted();
231 SortMarkedObjects();
232 bMrkPntDirty=TRUE;
233 //remove empty maked SdrObject
234 ULONG nMarkAnz=GetMarkedObjectCount();
235 for (ULONG nMarkNum=nMarkAnz; nMarkNum>0;)
237 nMarkNum--;
238 SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
239 const SdrObject* pObj=pM->GetMarkedSdrObj();
240 if( pObj == NULL )
242 GetMarkedObjectListWriteAccess().DeleteMark(nMarkNum);
246 UndirtyMrkPnt();
247 SdrView* pV=(SdrView*)this;
248 if (pV!=NULL && !pV->IsDragObj() && !pV->IsInsObjPoint()) { // an dieser Stelle habe ich ein ziemliches Problem !!!
249 AdjustMarkHdl();
253 ////////////////////////////////////////////////////////////////////////////////////////////////////
255 BOOL SdrMarkView::IsAction() const
257 return SdrSnapView::IsAction() || IsMarkObj() || IsMarkPoints() || IsMarkGluePoints();
260 void SdrMarkView::MovAction(const Point& rPnt)
262 SdrSnapView::MovAction(rPnt);
264 if(IsMarkObj())
266 MovMarkObj(rPnt);
268 else if(IsMarkPoints())
270 MovMarkPoints(rPnt);
272 else if(IsMarkGluePoints())
274 MovMarkGluePoints(rPnt);
278 void SdrMarkView::EndAction()
280 if(IsMarkObj())
282 EndMarkObj();
284 else if(IsMarkPoints())
286 EndMarkPoints();
288 else if(IsMarkGluePoints())
290 EndMarkGluePoints();
293 SdrSnapView::EndAction();
296 void SdrMarkView::BckAction()
298 SdrSnapView::BckAction();
299 BrkMarkObj();
300 BrkMarkPoints();
301 BrkMarkGluePoints();
304 void SdrMarkView::BrkAction()
306 SdrSnapView::BrkAction();
307 BrkMarkObj();
308 BrkMarkPoints();
309 BrkMarkGluePoints();
312 void SdrMarkView::TakeActionRect(Rectangle& rRect) const
314 if(IsMarkObj() || IsMarkPoints() || IsMarkGluePoints())
316 rRect = Rectangle(aDragStat.GetStart(), aDragStat.GetNow());
318 else
320 SdrSnapView::TakeActionRect(rRect);
324 ////////////////////////////////////////////////////////////////////////////////////////////////////
326 void SdrMarkView::ClearPageView()
328 UnmarkAllObj();
329 SdrSnapView::ClearPageView();
332 void SdrMarkView::HideSdrPage()
334 bool bMrkChg(false);
335 //HMHbool bVis(false);
337 if(mpPageView)
339 // break all creation actions when hiding page (#75081#)
340 BrkAction();
341 //HMHbVis = IsMarkHdlShown();
343 //HMHif(bVis)
344 //HMH{
345 //HMH HideMarkHdl();
346 //HMH}
348 // Alle Markierungen dieser Seite verwerfen
349 bMrkChg = GetMarkedObjectListWriteAccess().DeletePageView(*mpPageView);
352 SdrSnapView::HideSdrPage();
354 if(bMrkChg)
356 MarkListHasChanged();
357 AdjustMarkHdl();
360 //HMHif(bVis)
361 //HMH{
362 //HMH ShowMarkHdl();
363 //HMH}
366 ////////////////////////////////////////////////////////////////////////////////////////////////////
368 sal_Bool SdrMarkView::BegMarkObj(const Point& rPnt, sal_Bool bUnmark)
370 BrkAction();
372 DBG_ASSERT(0L == mpMarkObjOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkObjOverlay (!)");
373 basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
374 mpMarkObjOverlay = new ImplMarkingOverlay(*this, aStartPos, bUnmark);
376 aDragStat.Reset(rPnt);
377 aDragStat.NextPoint();
378 aDragStat.SetMinMove(nMinMovLog);
380 return sal_True;
383 void SdrMarkView::MovMarkObj(const Point& rPnt)
385 if(IsMarkObj() && aDragStat.CheckMinMoved(rPnt))
387 aDragStat.NextMove(rPnt);
388 DBG_ASSERT(mpMarkObjOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
389 basegfx::B2DPoint aNewPos(rPnt.X(), rPnt.Y());
390 mpMarkObjOverlay->SetSecondPosition(aNewPos);
394 sal_Bool SdrMarkView::EndMarkObj()
396 sal_Bool bRetval(sal_False);
398 if(IsMarkObj())
400 if(aDragStat.IsMinMoved())
402 Rectangle aRect(aDragStat.GetStart(), aDragStat.GetNow());
403 aRect.Justify();
404 MarkObj(aRect, mpMarkObjOverlay->IsUnmarking());
405 bRetval = sal_True;
408 // cleanup
409 BrkMarkObj();
412 return bRetval;
415 void SdrMarkView::BrkMarkObj()
417 if(IsMarkObj())
419 DBG_ASSERT(mpMarkObjOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
420 delete mpMarkObjOverlay;
421 mpMarkObjOverlay = 0L;
425 ////////////////////////////////////////////////////////////////////////////////////////////////////
427 sal_Bool SdrMarkView::BegMarkPoints(const Point& rPnt, sal_Bool bUnmark)
429 if(HasMarkablePoints())
431 BrkAction();
433 DBG_ASSERT(0L == mpMarkPointsOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkPointsOverlay (!)");
434 basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
435 mpMarkPointsOverlay = new ImplMarkingOverlay(*this, aStartPos, bUnmark);
437 aDragStat.Reset(rPnt);
438 aDragStat.NextPoint();
439 aDragStat.SetMinMove(nMinMovLog);
441 return sal_True;
444 return sal_False;
447 void SdrMarkView::MovMarkPoints(const Point& rPnt)
449 if(IsMarkPoints() && aDragStat.CheckMinMoved(rPnt))
451 aDragStat.NextMove(rPnt);
453 DBG_ASSERT(mpMarkPointsOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
454 basegfx::B2DPoint aNewPos(rPnt.X(), rPnt.Y());
455 mpMarkPointsOverlay->SetSecondPosition(aNewPos);
459 sal_Bool SdrMarkView::EndMarkPoints()
461 sal_Bool bRetval(sal_False);
463 if(IsMarkPoints())
465 if(aDragStat.IsMinMoved())
467 Rectangle aRect(aDragStat.GetStart(), aDragStat.GetNow());
468 aRect.Justify();
469 MarkPoints(aRect, mpMarkPointsOverlay->IsUnmarking());
471 bRetval = sal_True;
474 // cleanup
475 BrkMarkPoints();
478 return bRetval;
481 void SdrMarkView::BrkMarkPoints()
483 if(IsMarkPoints())
485 DBG_ASSERT(mpMarkPointsOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
486 delete mpMarkPointsOverlay;
487 mpMarkPointsOverlay = 0L;
491 ////////////////////////////////////////////////////////////////////////////////////////////////////
493 sal_Bool SdrMarkView::BegMarkGluePoints(const Point& rPnt, sal_Bool bUnmark)
495 if(HasMarkableGluePoints())
497 BrkAction();
499 DBG_ASSERT(0L == mpMarkGluePointsOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkGluePointsOverlay (!)");
500 basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
501 mpMarkGluePointsOverlay = new ImplMarkingOverlay(*this, aStartPos, bUnmark);
503 aDragStat.Reset(rPnt);
504 aDragStat.NextPoint();
505 aDragStat.SetMinMove(nMinMovLog);
507 return sal_True;
510 return sal_False;
513 void SdrMarkView::MovMarkGluePoints(const Point& rPnt)
515 if(IsMarkGluePoints() && aDragStat.CheckMinMoved(rPnt))
517 aDragStat.NextMove(rPnt);
519 DBG_ASSERT(mpMarkGluePointsOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
520 basegfx::B2DPoint aNewPos(rPnt.X(), rPnt.Y());
521 mpMarkGluePointsOverlay->SetSecondPosition(aNewPos);
525 sal_Bool SdrMarkView::EndMarkGluePoints()
527 sal_Bool bRetval(sal_False);
529 if(IsMarkGluePoints())
531 if(aDragStat.IsMinMoved())
533 Rectangle aRect(aDragStat.GetStart(),aDragStat.GetNow());
534 aRect.Justify();
535 MarkGluePoints(&aRect, mpMarkGluePointsOverlay->IsUnmarking());
537 bRetval = sal_True;
540 // cleanup
541 BrkMarkGluePoints();
544 return bRetval;
547 void SdrMarkView::BrkMarkGluePoints()
549 if(IsMarkGluePoints())
551 DBG_ASSERT(mpMarkGluePointsOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
552 delete mpMarkGluePointsOverlay;
553 mpMarkGluePointsOverlay = 0L;
557 BOOL SdrMarkView::HasMarkableObj() const
559 ULONG nCount=0;
561 SdrPageView* pPV = GetSdrPageView();
562 if(pPV)
564 SdrObjList* pOL=pPV->GetObjList();
565 ULONG nObjAnz=pOL->GetObjCount();
566 for (ULONG nObjNum=0; nObjNum<nObjAnz && nCount==0; nObjNum++) {
567 SdrObject* pObj=pOL->GetObj(nObjNum);
568 if (IsObjMarkable(pObj,pPV)) {
569 nCount++;
573 return nCount!=0;
576 ULONG SdrMarkView::GetMarkableObjCount() const
578 ULONG nCount=0;
579 SdrPageView* pPV = GetSdrPageView();
581 if(pPV)
583 SdrObjList* pOL=pPV->GetObjList();
584 ULONG nObjAnz=pOL->GetObjCount();
585 for (ULONG nObjNum=0; nObjNum<nObjAnz; nObjNum++) {
586 SdrObject* pObj=pOL->GetObj(nObjNum);
587 if (IsObjMarkable(pObj,pPV)) {
588 nCount++;
592 return nCount;
595 //HMHvoid SdrMarkView::ImpShowMarkHdl(bool /*bNoRefHdl*/)
596 //HMH{
597 //HMH bNoRefHdl=FALSE; // geht leider erstmal nicht anders
598 //HMH if (!bHdlShown) {
599 //HMH bRefHdlShownOnly=FALSE;
600 //HMH bHdlShown=TRUE;
601 //HMH }
602 //HMH}
604 //HMHvoid SdrMarkView::ShowMarkHdl(bool /*bNoRefHdl*/)
605 //HMH{
606 //HMH bNoRefHdl=FALSE; // geht leider erstmal nicht anders
607 //HMH ImpShowMarkHdl(bNoRefHdl);
608 //HMH}
611 //HMHvoid SdrMarkView::HideMarkHdl(bool /*bNoRefHdl*/)
612 //HMH{
613 //HMH bNoRefHdl=FALSE; // geht leider erstmal nicht anders
614 //HMH if (bHdlShown) {
615 //HMH bRefHdlShownOnly=bNoRefHdl;
616 //HMH bHdlShown=FALSE;
617 //HMH }
618 //HMH}
620 void SdrMarkView::hideMarkHandles()
622 if(!mbMarkHandlesHidden)
624 mbMarkHandlesHidden = true;
625 AdjustMarkHdl();
629 void SdrMarkView::showMarkHandles()
631 if(mbMarkHandlesHidden)
633 mbMarkHandlesHidden = false;
634 AdjustMarkHdl();
638 BOOL SdrMarkView::ImpIsFrameHandles() const
640 ULONG nMarkAnz=GetMarkedObjectCount();
641 BOOL bFrmHdl=nMarkAnz>nFrameHandlesLimit || bForceFrameHandles;
642 BOOL bStdDrag=eDragMode==SDRDRAG_MOVE;
643 if (nMarkAnz==1 && bStdDrag && bFrmHdl)
645 const SdrObject* pObj=GetMarkedObjectByIndex(0);
646 if (pObj->GetObjInventor()==SdrInventor)
648 UINT16 nIdent=pObj->GetObjIdentifier();
649 if (nIdent==OBJ_LINE || nIdent==OBJ_EDGE || nIdent==OBJ_CAPTION || nIdent==OBJ_MEASURE || nIdent==OBJ_CUSTOMSHAPE || nIdent==OBJ_TABLE )
651 bFrmHdl=FALSE;
655 if (!bStdDrag && !bFrmHdl) {
656 // Grundsaetzlich erstmal alle anderen Dragmodi nur mit FrameHandles
657 bFrmHdl=TRUE;
658 if (eDragMode==SDRDRAG_ROTATE) {
659 // bei Rotate ObjOwn-Drag, wenn mind. 1 PolyObj
660 for (ULONG nMarkNum=0; nMarkNum<nMarkAnz && bFrmHdl; nMarkNum++) {
661 const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
662 const SdrObject* pObj=pM->GetMarkedSdrObj();
663 bFrmHdl=!pObj->IsPolyObj();
667 if (!bFrmHdl) {
668 // FrameHandles, wenn wenigstens 1 Obj kein SpecialDrag kann
669 for (ULONG nMarkNum=0; nMarkNum<nMarkAnz && !bFrmHdl; nMarkNum++) {
670 const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
671 const SdrObject* pObj=pM->GetMarkedSdrObj();
672 bFrmHdl=!pObj->hasSpecialDrag();
675 return bFrmHdl;
678 void SdrMarkView::SetMarkHandles()
680 // #105722# remember old focus handle values to search for it again
681 const SdrHdl* pSaveOldFocusHdl = aHdl.GetFocusHdl();
682 sal_Bool bSaveOldFocus(sal_False);
683 sal_uInt32 nSavePolyNum(0L), nSavePointNum(0L);
684 SdrHdlKind eSaveKind(HDL_MOVE);
685 SdrObject* pSaveObj = NULL;
687 if(pSaveOldFocusHdl
688 && pSaveOldFocusHdl->GetObj()
689 && pSaveOldFocusHdl->GetObj()->ISA(SdrPathObj)
690 && (pSaveOldFocusHdl->GetKind() == HDL_POLY || pSaveOldFocusHdl->GetKind() == HDL_BWGT))
692 bSaveOldFocus = sal_True;
693 nSavePolyNum = pSaveOldFocusHdl->GetPolyNum();
694 nSavePointNum = pSaveOldFocusHdl->GetPointNum();
695 pSaveObj = pSaveOldFocusHdl->GetObj();
696 eSaveKind = pSaveOldFocusHdl->GetKind();
699 // delete/clear all handles. This will always be done, even with areMarkHandlesHidden()
700 aHdl.Clear();
701 aHdl.SetRotateShear(eDragMode==SDRDRAG_ROTATE);
702 aHdl.SetDistortShear(eDragMode==SDRDRAG_SHEAR);
703 pMarkedObj=NULL;
704 pMarkedPV=NULL;
706 // are handles enabled at all? Create only then
707 if(!areMarkHandlesHidden())
709 ULONG nMarkAnz=GetMarkedObjectCount();
710 BOOL bStdDrag=eDragMode==SDRDRAG_MOVE;
711 BOOL bSingleTextObjMark=FALSE;
713 if (nMarkAnz==1)
715 pMarkedObj=GetMarkedObjectByIndex(0);
716 bSingleTextObjMark =
717 pMarkedObj &&
718 pMarkedObj->ISA(SdrTextObj) &&
719 static_cast<SdrTextObj*>(pMarkedObj)->IsTextFrame();
722 BOOL bFrmHdl=ImpIsFrameHandles();
724 if (nMarkAnz>0)
726 pMarkedPV=GetSdrPageViewOfMarkedByIndex(0);
728 for (ULONG nMarkNum=0; nMarkNum<nMarkAnz && (pMarkedPV!=NULL || !bFrmHdl); nMarkNum++)
730 const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
732 if (pMarkedPV!=pM->GetPageView())
734 pMarkedPV=NULL;
739 if (bFrmHdl)
741 Rectangle aRect(GetMarkedObjRect());
743 // #i33755#
744 const sal_Bool bHideHandlesWhenInTextEdit(
745 ((SdrView*)this)->IsTextEdit()
746 && pMarkedObj
747 && pMarkedObj->ISA(SdrTextObj)
748 && ((SdrTextObj*)pMarkedObj)->IsInEditMode());
750 if(!aRect.IsEmpty() && !bHideHandlesWhenInTextEdit)
751 { // sonst nix gefunden
752 if( bSingleTextObjMark )
754 const ULONG nSiz0=aHdl.GetHdlCount();
755 pMarkedObj->AddToHdlList(aHdl);
756 const ULONG nSiz1=aHdl.GetHdlCount();
757 for (ULONG i=nSiz0; i<nSiz1; i++)
759 SdrHdl* pHdl=aHdl.GetHdl(i);
760 pHdl->SetObj(pMarkedObj);
761 pHdl->SetPageView(pMarkedPV);
762 pHdl->SetObjHdlNum(USHORT(i-nSiz0));
765 else if( eDragMode==SDRDRAG_CROP )
767 aHdl.AddHdl(new SdrCropHdl(aRect.TopLeft() ,HDL_UPLFT));
768 aHdl.AddHdl(new SdrCropHdl(aRect.TopCenter() ,HDL_UPPER));
769 aHdl.AddHdl(new SdrCropHdl(aRect.TopRight() ,HDL_UPRGT));
770 aHdl.AddHdl(new SdrCropHdl(aRect.LeftCenter() ,HDL_LEFT ));
771 aHdl.AddHdl(new SdrCropHdl(aRect.RightCenter() ,HDL_RIGHT));
772 aHdl.AddHdl(new SdrCropHdl(aRect.BottomLeft() ,HDL_LWLFT));
773 aHdl.AddHdl(new SdrCropHdl(aRect.BottomCenter(),HDL_LOWER));
774 aHdl.AddHdl(new SdrCropHdl(aRect.BottomRight() ,HDL_LWRGT));
776 else
778 BOOL bWdt0=aRect.Left()==aRect.Right();
779 BOOL bHgt0=aRect.Top()==aRect.Bottom();
780 if (bWdt0 && bHgt0)
782 aHdl.AddHdl(new SdrHdl(aRect.TopLeft(),HDL_UPLFT));
784 else if (!bStdDrag && (bWdt0 || bHgt0))
786 aHdl.AddHdl(new SdrHdl(aRect.TopLeft() ,HDL_UPLFT));
787 aHdl.AddHdl(new SdrHdl(aRect.BottomRight(),HDL_LWRGT));
789 else
791 if (!bWdt0 && !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.TopLeft() ,HDL_UPLFT));
792 if ( !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.TopCenter() ,HDL_UPPER));
793 if (!bWdt0 && !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.TopRight() ,HDL_UPRGT));
794 if (!bWdt0 ) aHdl.AddHdl(new SdrHdl(aRect.LeftCenter() ,HDL_LEFT ));
795 if (!bWdt0 ) aHdl.AddHdl(new SdrHdl(aRect.RightCenter() ,HDL_RIGHT));
796 if (!bWdt0 && !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.BottomLeft() ,HDL_LWLFT));
797 if ( !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.BottomCenter(),HDL_LOWER));
798 if (!bWdt0 && !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.BottomRight() ,HDL_LWRGT));
803 else
805 for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++)
807 const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
808 SdrObject* pObj=pM->GetMarkedSdrObj();
809 SdrPageView* pPV=pM->GetPageView();
810 const ULONG nSiz0=aHdl.GetHdlCount();
811 pObj->AddToHdlList(aHdl);
812 const ULONG nSiz1=aHdl.GetHdlCount();
813 bool bPoly=pObj->IsPolyObj();
814 const SdrUShortCont* pMrkPnts=pM->GetMarkedPoints();
815 for (ULONG i=nSiz0; i<nSiz1; i++)
817 SdrHdl* pHdl=aHdl.GetHdl(i);
818 pHdl->SetObj(pObj);
819 pHdl->SetPageView(pPV);
820 pHdl->SetObjHdlNum(USHORT(i-nSiz0));
821 if (bPoly)
823 BOOL bSelected=pMrkPnts!=NULL && pMrkPnts->Exist(USHORT(i-nSiz0));
824 pHdl->SetSelected(bSelected);
825 //BOOL bPlus=bPlusHdlAlways;
826 if (bPlusHdlAlways || bSelected)
828 sal_uInt32 nPlusAnz=pObj->GetPlusHdlCount(*pHdl);
829 for (sal_uInt32 nPlusNum=0; nPlusNum<nPlusAnz; nPlusNum++)
831 SdrHdl* pPlusHdl=pObj->GetPlusHdl(*pHdl,nPlusNum);
832 if (pPlusHdl!=NULL)
834 pPlusHdl->SetObj(pObj);
835 pPlusHdl->SetPageView(pPV);
836 pPlusHdl->SetPlusHdl(TRUE);
837 aHdl.AddHdl(pPlusHdl);
843 } // for nMarkNum
844 } // if bFrmHdl else
846 // GluePoint-Handles
847 for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++)
849 const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
850 SdrObject* pObj=pM->GetMarkedSdrObj();
851 SdrPageView* pPV=pM->GetPageView();
852 const SdrUShortCont* pMrkGlue=pM->GetMarkedGluePoints();
853 if (pMrkGlue!=NULL)
855 const SdrGluePointList* pGPL=pObj->GetGluePointList();
856 if (pGPL!=NULL)
858 //USHORT nGlueAnz=pGPL->GetCount();
859 USHORT nAnz=(USHORT)pMrkGlue->GetCount();
860 for (USHORT nNum=0; nNum<nAnz; nNum++)
862 USHORT nId=pMrkGlue->GetObject(nNum);
863 //nNum changed to nNumGP because already used in for loop
864 USHORT nNumGP=pGPL->FindGluePoint(nId);
865 if (nNumGP!=SDRGLUEPOINT_NOTFOUND)
867 const SdrGluePoint& rGP=(*pGPL)[nNumGP];
868 Point aPos(rGP.GetAbsolutePos(*pObj));
869 SdrHdl* pGlueHdl=new SdrHdl(aPos,HDL_GLUE);
870 pGlueHdl->SetObj(pObj);
871 pGlueHdl->SetPageView(pPV);
872 pGlueHdl->SetObjHdlNum(nId);
873 aHdl.AddHdl(pGlueHdl);
880 // Drehpunkt/Spiegelachse
881 AddDragModeHdl(eDragMode);
883 // add custom handles (used by other apps, e.g. AnchorPos)
884 AddCustomHdl();
886 // sort handles
887 aHdl.Sort();
889 // #105722# try to restore focus handle index from remembered values
890 if(bSaveOldFocus)
892 for(sal_uInt32 a(0); a < aHdl.GetHdlCount(); a++)
894 SdrHdl* pCandidate = aHdl.GetHdl(a);
896 if(pCandidate->GetObj()
897 && pCandidate->GetObj() == pSaveObj
898 && pCandidate->GetKind() == eSaveKind
899 && pCandidate->GetPolyNum() == nSavePolyNum
900 && pCandidate->GetPointNum() == nSavePointNum)
902 aHdl.SetFocusHdl(pCandidate);
903 break;
910 void SdrMarkView::AddCustomHdl()
912 // add custom handles (used by other apps, e.g. AnchorPos)
915 void SdrMarkView::SetDragMode(SdrDragMode eMode)
917 SdrDragMode eMode0=eDragMode;
918 eDragMode=eMode;
919 if (eDragMode==SDRDRAG_RESIZE) eDragMode=SDRDRAG_MOVE;
920 if (eDragMode!=eMode0) {
921 //HMHBOOL bVis=IsMarkHdlShown();
922 //HMHif (bVis) HideMarkHdl();
923 ForceRefToMarked();
924 SetMarkHandles();
925 //HMHif (bVis) ShowMarkHdl();
927 if (AreObjectsMarked()) MarkListHasChanged();
932 void SdrMarkView::AddDragModeHdl(SdrDragMode eMode)
934 switch(eMode)
936 case SDRDRAG_ROTATE:
938 // add rotation center
939 SdrHdl* pHdl = new SdrHdl(aRef1, HDL_REF1);
941 aHdl.AddHdl(pHdl);
943 break;
945 case SDRDRAG_MIRROR:
947 // add mirror axis
948 SdrHdl* pHdl3 = new SdrHdl(aRef2, HDL_REF2);
949 SdrHdl* pHdl2 = new SdrHdl(aRef1, HDL_REF1);
950 SdrHdl* pHdl1 = new SdrHdlLine(*pHdl2, *pHdl3, HDL_MIRX);
952 pHdl1->SetObjHdlNum(1); // fuer Sortierung
953 pHdl2->SetObjHdlNum(2); // fuer Sortierung
954 pHdl3->SetObjHdlNum(3); // fuer Sortierung
956 aHdl.AddHdl(pHdl1); // Linie als erstes, damit als letztes im HitTest
957 aHdl.AddHdl(pHdl2);
958 aHdl.AddHdl(pHdl3);
960 break;
962 case SDRDRAG_TRANSPARENCE:
964 // add interactive transparence handle
965 ULONG nMarkAnz = GetMarkedObjectCount();
966 if(nMarkAnz == 1)
968 SdrObject* pObj = GetMarkedObjectByIndex(0);
969 SdrModel* pModel = GetModel();
970 const SfxItemSet& rSet = pObj->GetMergedItemSet();
972 if(SFX_ITEM_SET != rSet.GetItemState(XATTR_FILLFLOATTRANSPARENCE, FALSE))
974 // add this item, it's not yet there
975 XFillFloatTransparenceItem aNewItem(
976 (const XFillFloatTransparenceItem&)rSet.Get(XATTR_FILLFLOATTRANSPARENCE));
977 XGradient aGrad = aNewItem.GetGradientValue();
979 aNewItem.SetEnabled(TRUE);
980 aGrad.SetStartIntens(100);
981 aGrad.SetEndIntens(100);
982 aNewItem.SetGradientValue(aGrad);
984 // add undo to allow user to take back this step
985 if( pModel->IsUndoEnabled() )
987 pModel->BegUndo(SVX_RESSTR(SIP_XA_FILLTRANSPARENCE));
988 pModel->AddUndo(pModel->GetSdrUndoFactory().CreateUndoAttrObject(*pObj));
989 pModel->EndUndo();
992 //pObj->SetItemAndBroadcast(aNewItem);
993 SfxItemSet aNewSet(pModel->GetItemPool());
994 aNewSet.Put(aNewItem);
995 pObj->SetMergedItemSetAndBroadcast(aNewSet);
998 // set values and transform to vector set
999 GradTransformer aGradTransformer;
1000 GradTransVector aGradTransVector;
1001 GradTransGradient aGradTransGradient;
1003 aGradTransGradient.aGradient = ((XFillFloatTransparenceItem&)rSet.Get(XATTR_FILLFLOATTRANSPARENCE)).GetGradientValue();
1004 aGradTransformer.GradToVec(aGradTransGradient, aGradTransVector, pObj);
1006 // build handles
1007 const Point aTmpPos1(basegfx::fround(aGradTransVector.maPositionA.getX()), basegfx::fround(aGradTransVector.maPositionA.getY()));
1008 const Point aTmpPos2(basegfx::fround(aGradTransVector.maPositionB.getX()), basegfx::fround(aGradTransVector.maPositionB.getY()));
1009 SdrHdlColor* pColHdl1 = new SdrHdlColor(aTmpPos1, aGradTransVector.aCol1, SDR_HANDLE_COLOR_SIZE_NORMAL, TRUE);
1010 SdrHdlColor* pColHdl2 = new SdrHdlColor(aTmpPos2, aGradTransVector.aCol2, SDR_HANDLE_COLOR_SIZE_NORMAL, TRUE);
1011 SdrHdlGradient* pGradHdl = new SdrHdlGradient(aTmpPos1, aTmpPos2, FALSE);
1012 DBG_ASSERT(pColHdl1 && pColHdl2 && pGradHdl, "Got not all necessary handles!!");
1014 // link them
1015 pGradHdl->SetColorHandles(pColHdl1, pColHdl2);
1016 pGradHdl->SetObj(pObj);
1017 pColHdl1->SetColorChangeHdl(LINK(pGradHdl, SdrHdlGradient, ColorChangeHdl));
1018 pColHdl2->SetColorChangeHdl(LINK(pGradHdl, SdrHdlGradient, ColorChangeHdl));
1020 // insert them
1021 aHdl.AddHdl(pColHdl1);
1022 aHdl.AddHdl(pColHdl2);
1023 aHdl.AddHdl(pGradHdl);
1025 break;
1027 case SDRDRAG_GRADIENT:
1029 // add interactive gradient handle
1030 ULONG nMarkAnz = GetMarkedObjectCount();
1031 if(nMarkAnz == 1)
1033 SdrObject* pObj = GetMarkedObjectByIndex(0);
1034 const SfxItemSet& rSet = pObj->GetMergedItemSet();
1035 XFillStyle eFillStyle = ((XFillStyleItem&)(rSet.Get(XATTR_FILLSTYLE))).GetValue();
1037 if(eFillStyle == XFILL_GRADIENT)
1039 // set values and transform to vector set
1040 GradTransformer aGradTransformer;
1041 GradTransVector aGradTransVector;
1042 GradTransGradient aGradTransGradient;
1043 Size aHdlSize(15, 15);
1045 aGradTransGradient.aGradient = ((XFillGradientItem&)rSet.Get(XATTR_FILLGRADIENT)).GetGradientValue();
1046 aGradTransformer.GradToVec(aGradTransGradient, aGradTransVector, pObj);
1048 // build handles
1049 const Point aTmpPos1(basegfx::fround(aGradTransVector.maPositionA.getX()), basegfx::fround(aGradTransVector.maPositionA.getY()));
1050 const Point aTmpPos2(basegfx::fround(aGradTransVector.maPositionB.getX()), basegfx::fround(aGradTransVector.maPositionB.getY()));
1051 SdrHdlColor* pColHdl1 = new SdrHdlColor(aTmpPos1, aGradTransVector.aCol1, aHdlSize, FALSE);
1052 SdrHdlColor* pColHdl2 = new SdrHdlColor(aTmpPos2, aGradTransVector.aCol2, aHdlSize, FALSE);
1053 SdrHdlGradient* pGradHdl = new SdrHdlGradient(aTmpPos1, aTmpPos2, TRUE);
1054 DBG_ASSERT(pColHdl1 && pColHdl2 && pGradHdl, "Got not all necessary handles!!");
1056 // link them
1057 pGradHdl->SetColorHandles(pColHdl1, pColHdl2);
1058 pGradHdl->SetObj(pObj);
1059 pColHdl1->SetColorChangeHdl(LINK(pGradHdl, SdrHdlGradient, ColorChangeHdl));
1060 pColHdl2->SetColorChangeHdl(LINK(pGradHdl, SdrHdlGradient, ColorChangeHdl));
1062 // insert them
1063 aHdl.AddHdl(pColHdl1);
1064 aHdl.AddHdl(pColHdl2);
1065 aHdl.AddHdl(pGradHdl);
1068 break;
1070 case SDRDRAG_CROP:
1072 // todo
1073 break;
1075 default: break;
1079 void SdrMarkView::ForceRefToMarked()
1081 switch(eDragMode)
1083 case SDRDRAG_ROTATE:
1085 Rectangle aR(GetMarkedObjRect());
1086 aRef1 = aR.Center();
1088 break;
1091 case SDRDRAG_MIRROR:
1093 // Erstmal die laenge der Spiegelachsenlinie berechnen
1094 long nOutMin=0;
1095 long nOutMax=0;
1096 long nMinLen=0;
1097 long nObjDst=0;
1098 long nOutHgt=0;
1099 OutputDevice* pOut=GetFirstOutputDevice();
1100 //OutputDevice* pOut=GetWin(0);
1101 if (pOut!=NULL) {
1102 // Mindestlaenge 50 Pixel
1103 nMinLen=pOut->PixelToLogic(Size(0,50)).Height();
1104 // 20 Pixel fuer RefPt-Abstand vom Obj
1105 nObjDst=pOut->PixelToLogic(Size(0,20)).Height();
1106 // MinY/MaxY
1107 // Abstand zum Rand = Mindestlaenge = 10 Pixel
1108 long nDst=pOut->PixelToLogic(Size(0,10)).Height();
1109 nOutMin=-pOut->GetMapMode().GetOrigin().Y();
1110 nOutMax=pOut->GetOutputSize().Height()-1+nOutMin;
1111 nOutMin+=nDst;
1112 nOutMax-=nDst;
1113 // Absolute Mindestlaenge jedoch 10 Pixel
1114 if (nOutMax-nOutMin<nDst) {
1115 nOutMin+=nOutMax+1;
1116 nOutMin/=2;
1117 nOutMin-=(nDst+1)/2;
1118 nOutMax=nOutMin+nDst;
1120 nOutHgt=nOutMax-nOutMin;
1121 // Sonst Mindestlaenge = 1/4 OutHgt
1122 long nTemp=nOutHgt/4;
1123 if (nTemp>nMinLen) nMinLen=nTemp;
1126 Rectangle aR(GetMarkedObjBoundRect());
1127 Point aCenter(aR.Center());
1128 long nMarkHgt=aR.GetHeight()-1;
1129 long nHgt=nMarkHgt+nObjDst*2; // 20 Pixel obej und unten ueberstehend
1130 if (nHgt<nMinLen) nHgt=nMinLen; // Mindestlaenge 50 Pixel bzw. 1/4 OutHgt
1132 long nY1=aCenter.Y()-(nHgt+1)/2;
1133 long nY2=nY1+nHgt;
1135 if (pOut!=NULL && nMinLen>nOutHgt) nMinLen=nOutHgt; // evtl. noch etwas verkuerzen
1137 if (pOut!=NULL) { // nun vollstaendig in den sichtbaren Bereich schieben
1138 if (nY1<nOutMin) {
1139 nY1=nOutMin;
1140 if (nY2<nY1+nMinLen) nY2=nY1+nMinLen;
1142 if (nY2>nOutMax) {
1143 nY2=nOutMax;
1144 if (nY1>nY2-nMinLen) nY1=nY2-nMinLen;
1148 aRef1.X()=aCenter.X();
1149 aRef1.Y()=nY1;
1150 aRef2.X()=aCenter.X();
1151 aRef2.Y()=nY2;
1153 break;
1156 case SDRDRAG_TRANSPARENCE:
1157 case SDRDRAG_GRADIENT:
1158 case SDRDRAG_CROP:
1160 Rectangle aRect(GetMarkedObjBoundRect());
1161 aRef1 = aRect.TopLeft();
1162 aRef2 = aRect.BottomRight();
1163 break;
1165 default: break;
1169 void SdrMarkView::SetRef1(const Point& rPt)
1171 if(eDragMode == SDRDRAG_ROTATE || eDragMode == SDRDRAG_MIRROR)
1173 aRef1 = rPt;
1174 SdrHdl* pH = aHdl.GetHdl(HDL_REF1);
1175 if(pH)
1176 pH->SetPos(rPt);
1177 //HMHShowMarkHdl();
1181 void SdrMarkView::SetRef2(const Point& rPt)
1183 if(eDragMode == SDRDRAG_MIRROR)
1185 aRef2 = rPt;
1186 SdrHdl* pH = aHdl.GetHdl(HDL_REF2);
1187 if(pH)
1188 pH->SetPos(rPt);
1189 //HMHShowMarkHdl();
1193 void SdrMarkView::CheckMarked()
1195 for (ULONG nm=GetMarkedObjectCount(); nm>0;) {
1196 nm--;
1197 SdrMark* pM=GetSdrMarkByIndex(nm);
1198 SdrObject* pObj=pM->GetMarkedSdrObj();
1199 SdrPageView* pPV=pM->GetPageView();
1200 SdrLayerID nLay=pObj->GetLayer();
1201 BOOL bRaus=!pObj->IsInserted(); // Obj geloescht?
1202 if (!pObj->Is3DObj()) {
1203 bRaus=bRaus || pObj->GetPage()!=pPV->GetPage(); // Obj ploetzlich in anderer Page oder Group
1205 bRaus=bRaus || pPV->GetLockedLayers().IsSet(nLay) || // Layer gesperrt?
1206 !pPV->GetVisibleLayers().IsSet(nLay); // Layer nicht sichtbar?
1207 if (!bRaus) {
1208 // Joe am 9.3.1997: Gruppierte Objekten koennen nun auch
1209 // markiert werden. Nach EnterGroup muessen aber die Objekte
1210 // der hoeheren Ebene deselektiert werden.
1211 const SdrObjList* pOOL=pObj->GetObjList();
1212 const SdrObjList* pVOL=pPV->GetObjList();
1213 while (pOOL!=NULL && pOOL!=pVOL) {
1214 pOOL=pOOL->GetUpList();
1216 bRaus=pOOL!=pVOL;
1219 if (bRaus)
1221 GetMarkedObjectListWriteAccess().DeleteMark(nm);
1223 else
1225 if (!IsGluePointEditMode()) { // Markierte GluePoints nur im GlueEditMode
1226 SdrUShortCont* pPts=pM->GetMarkedGluePoints();
1227 if (pPts!=NULL && pPts->GetCount()!=0) {
1228 pPts->Clear();
1234 // #97995# at least reset the remembered BoundRect to prevent handle
1235 // generation if bForceFrameHandles is TRUE.
1236 bMarkedObjRectDirty = TRUE;
1239 void SdrMarkView::SetMarkRects()
1241 SdrPageView* pPV = GetSdrPageView();
1243 if(pPV)
1245 pPV->SetHasMarkedObj(GetSnapRectFromMarkedObjects(pPV, pPV->MarkSnap()));
1246 GetBoundRectFromMarkedObjects(pPV, pPV->MarkBound());
1250 void SdrMarkView::SetFrameHandles(BOOL bOn)
1252 if (bOn!=bForceFrameHandles) {
1253 BOOL bOld=ImpIsFrameHandles();
1254 bForceFrameHandles=bOn;
1255 BOOL bNew=ImpIsFrameHandles();
1256 if (bNew!=bOld) {
1257 AdjustMarkHdl(); //HMHTRUE);
1258 MarkListHasChanged();
1263 void SdrMarkView::SetEditMode(SdrViewEditMode eMode)
1265 if (eMode!=eEditMode) {
1266 BOOL bGlue0=eEditMode==SDREDITMODE_GLUEPOINTEDIT;
1267 BOOL bEdge0=((SdrCreateView*)this)->IsEdgeTool();
1268 eEditMode0=eEditMode;
1269 eEditMode=eMode;
1270 BOOL bGlue1=eEditMode==SDREDITMODE_GLUEPOINTEDIT;
1271 BOOL bEdge1=((SdrCreateView*)this)->IsEdgeTool();
1272 // etwas Aufwand um Flackern zu verhindern beim Umschalten
1273 // zwischen GlueEdit und EdgeTool
1274 if (bGlue1 && !bGlue0) ImpSetGlueVisible2(bGlue1);
1275 if (bEdge1!=bEdge0) ImpSetGlueVisible3(bEdge1);
1276 if (!bGlue1 && bGlue0) ImpSetGlueVisible2(bGlue1);
1277 if (bGlue0 && !bGlue1) UnmarkAllGluePoints();
1281 ////////////////////////////////////////////////////////////////////////////////////////////////////
1283 BOOL SdrMarkView::IsObjMarkable(SdrObject* pObj, SdrPageView* pPV) const
1285 if (pObj)
1287 if (pObj->IsMarkProtect() ||
1288 (!bDesignMode && pObj->IsUnoObj()))
1290 // Objekt nicht selektierbar oder
1291 // SdrUnoObj nicht im DesignMode
1292 return FALSE;
1295 return pPV!=NULL ? pPV->IsObjMarkable(pObj) : TRUE;
1298 BOOL SdrMarkView::IsMarkedObjHit(const Point& rPnt, short nTol) const
1300 BOOL bRet=FALSE;
1301 nTol=ImpGetHitTolLogic(nTol,NULL);
1302 Point aPt(rPnt);
1303 for (ULONG nm=0; nm<GetMarkedObjectCount() && !bRet; nm++) {
1304 SdrMark* pM=GetSdrMarkByIndex(nm);
1305 bRet = 0 != CheckSingleSdrObjectHit(aPt,USHORT(nTol),pM->GetMarkedSdrObj(),pM->GetPageView(),0,0);
1307 return bRet;
1310 SdrHdl* SdrMarkView::PickHandle(const Point& rPnt, ULONG nOptions, SdrHdl* pHdl0) const
1312 if (bSomeObjChgdFlag) { // ggf. Handles neu berechnen lassen!
1313 FlushComeBackTimer();
1315 BOOL bBack=(nOptions & SDRSEARCH_BACKWARD) !=0;
1316 BOOL bNext=(nOptions & SDRSEARCH_NEXT) !=0;
1317 Point aPt(rPnt);
1318 return aHdl.IsHdlListHit(aPt,bBack,bNext,pHdl0);
1321 BOOL SdrMarkView::MarkObj(const Point& rPnt, short nTol, BOOL bToggle, BOOL bDeep)
1323 SdrObject* pObj;
1324 SdrPageView* pPV;
1325 nTol=ImpGetHitTolLogic(nTol,NULL);
1326 ULONG nOptions=SDRSEARCH_PICKMARKABLE;
1327 if (bDeep) nOptions=nOptions|SDRSEARCH_DEEP;
1328 BOOL bRet=PickObj(rPnt,(USHORT)nTol,pObj,pPV,nOptions);
1329 if (bRet) {
1330 BOOL bUnmark=bToggle && IsObjMarked(pObj);
1331 MarkObj(pObj,pPV,bUnmark);
1333 return bRet;
1336 BOOL SdrMarkView::MarkNextObj(BOOL bPrev)
1338 SdrPageView* pPageView = GetSdrPageView();
1340 if(!pPageView)
1342 return FALSE;
1345 SortMarkedObjects();
1346 ULONG nMarkAnz=GetMarkedObjectCount();
1347 ULONG nChgMarkNum = ULONG_MAX; // Nummer des zu ersetzenden MarkEntries
1348 ULONG nSearchObjNum = bPrev ? 0 : ULONG_MAX;
1349 if (nMarkAnz!=0) {
1350 nChgMarkNum=bPrev ? 0 : ULONG(nMarkAnz-1);
1351 SdrMark* pM=GetSdrMarkByIndex(nChgMarkNum);
1352 OSL_ASSERT(pM!=NULL);
1353 if (pM->GetMarkedSdrObj() != NULL)
1354 nSearchObjNum = pM->GetMarkedSdrObj()->GetNavigationPosition();
1357 SdrObject* pMarkObj=NULL;
1358 SdrObjList* pSearchObjList=pPageView->GetObjList();
1359 ULONG nObjAnz=pSearchObjList->GetObjCount();
1360 if (nObjAnz!=0) {
1361 if (nSearchObjNum>nObjAnz) nSearchObjNum=nObjAnz;
1362 while (pMarkObj==NULL && ((!bPrev && nSearchObjNum>0) || (bPrev && nSearchObjNum<nObjAnz)))
1364 if (!bPrev)
1365 nSearchObjNum--;
1366 SdrObject* pSearchObj = pSearchObjList->GetObjectForNavigationPosition(nSearchObjNum);
1367 if (IsObjMarkable(pSearchObj,pPageView))
1369 if (TryToFindMarkedObject(pSearchObj)==CONTAINER_ENTRY_NOTFOUND)
1371 pMarkObj=pSearchObj;
1374 if (bPrev) nSearchObjNum++;
1378 if(!pMarkObj)
1380 return FALSE;
1383 if (nChgMarkNum!=ULONG_MAX)
1385 GetMarkedObjectListWriteAccess().DeleteMark(nChgMarkNum);
1387 MarkObj(pMarkObj,pPageView); // ruft auch MarkListHasChanged(), AdjustMarkHdl()
1388 return TRUE;
1391 BOOL SdrMarkView::MarkNextObj(const Point& rPnt, short nTol, BOOL bPrev)
1393 SortMarkedObjects();
1394 nTol=ImpGetHitTolLogic(nTol,NULL);
1395 Point aPt(rPnt);
1396 SdrMark* pTopMarkHit=NULL;
1397 SdrMark* pBtmMarkHit=NULL;
1398 ULONG nTopMarkHit=0;
1399 ULONG nBtmMarkHit=0;
1400 // oberstes der markierten Objekte suchen, das von rPnt getroffen wird
1401 ULONG nMarkAnz=GetMarkedObjectCount();
1402 ULONG nm=0;
1403 for (nm=nMarkAnz; nm>0 && pTopMarkHit==NULL;) {
1404 nm--;
1405 SdrMark* pM=GetSdrMarkByIndex(nm);
1406 if(CheckSingleSdrObjectHit(aPt,USHORT(nTol),pM->GetMarkedSdrObj(),pM->GetPageView(),0,0))
1408 pTopMarkHit=pM;
1409 nTopMarkHit=nm;
1412 // Nichts gefunden, dann ganz normal ein Obj markieren.
1413 if (pTopMarkHit==NULL) return MarkObj(rPnt,USHORT(nTol),FALSE);
1415 SdrObject* pTopObjHit=pTopMarkHit->GetMarkedSdrObj();
1416 SdrObjList* pObjList=pTopObjHit->GetObjList();
1417 SdrPageView* pPV=pTopMarkHit->GetPageView();
1418 // unterstes der markierten Objekte suchen, das von rPnt getroffen wird
1419 // und auf der gleichen PageView liegt wie pTopMarkHit
1420 for (nm=0; nm<nMarkAnz && pBtmMarkHit==NULL; nm++) {
1421 SdrMark* pM=GetSdrMarkByIndex(nm);
1422 SdrPageView* pPV2=pM->GetPageView();
1423 if (pPV2==pPV && CheckSingleSdrObjectHit(aPt,USHORT(nTol),pM->GetMarkedSdrObj(),pPV2,0,0))
1425 pBtmMarkHit=pM;
1426 nBtmMarkHit=nm;
1429 if (pBtmMarkHit==NULL) { pBtmMarkHit=pTopMarkHit; nBtmMarkHit=nTopMarkHit; }
1430 SdrObject* pBtmObjHit=pBtmMarkHit->GetMarkedSdrObj();
1431 ULONG nObjAnz=pObjList->GetObjCount();
1433 // #110988#
1434 //ULONG nSearchBeg=bPrev ? pBtmObjHit->GetOrdNum()+1 : pTopObjHit->GetOrdNum();
1435 sal_uInt32 nSearchBeg;
1436 E3dScene* pScene = NULL;
1437 SdrObject* pObjHit = (bPrev) ? pBtmObjHit : pTopObjHit;
1438 sal_Bool bRemap = pObjHit->ISA(E3dCompoundObject)
1439 ? ((E3dCompoundObject*)pObjHit)->IsAOrdNumRemapCandidate(pScene)
1440 : sal_False;
1442 if(bPrev)
1444 sal_uInt32 nOrdNumBtm(pBtmObjHit->GetOrdNum());
1446 if(bRemap)
1448 nOrdNumBtm = pScene->RemapOrdNum(nOrdNumBtm);
1451 nSearchBeg = nOrdNumBtm + 1;
1453 else
1455 sal_uInt32 nOrdNumTop(pTopObjHit->GetOrdNum());
1457 if(bRemap)
1459 nOrdNumTop = pScene->RemapOrdNum(nOrdNumTop);
1462 nSearchBeg = nOrdNumTop;
1465 ULONG no=nSearchBeg;
1466 SdrObject* pFndObj=NULL;
1467 //SdrObject* pAktObj=NULL;
1468 while (pFndObj==NULL && ((!bPrev && no>0) || (bPrev && no<nObjAnz))) {
1469 if (!bPrev) no--;
1470 SdrObject* pObj;
1472 if(bRemap)
1474 pObj = pObjList->GetObj(pScene->RemapOrdNum(no));
1476 else
1478 pObj = pObjList->GetObj(no);
1481 if (CheckSingleSdrObjectHit(aPt,USHORT(nTol),pObj,pPV,SDRSEARCH_TESTMARKABLE,0))
1483 if (TryToFindMarkedObject(pObj)==CONTAINER_ENTRY_NOTFOUND) {
1484 pFndObj=pObj;
1485 } else {
1486 // hier wg. Performance ggf. noch no auf Top bzw. auf Btm stellen
1489 if (bPrev) no++;
1491 if (pFndObj!=NULL)
1493 GetMarkedObjectListWriteAccess().DeleteMark(bPrev?nBtmMarkHit:nTopMarkHit);
1494 GetMarkedObjectListWriteAccess().InsertEntry(SdrMark(pFndObj,pPV));
1495 MarkListHasChanged();
1496 AdjustMarkHdl(); //HMHTRUE);
1498 return pFndObj!=NULL;
1501 BOOL SdrMarkView::MarkObj(const Rectangle& rRect, BOOL bUnmark)
1503 BOOL bFnd=FALSE;
1504 Rectangle aR(rRect);
1505 SdrObject* pObj;
1506 SdrObjList* pObjList;
1507 BrkAction();
1508 SdrPageView* pPV = GetSdrPageView();
1510 if(pPV)
1512 pObjList=pPV->GetObjList();
1513 Rectangle aFrm1(aR);
1514 ULONG nObjAnz=pObjList->GetObjCount();
1515 for (ULONG nO=0; nO<nObjAnz; nO++) {
1516 pObj=pObjList->GetObj(nO);
1517 Rectangle aRect(pObj->GetCurrentBoundRect());
1518 if (aFrm1.IsInside(aRect)) {
1519 if (!bUnmark) {
1520 if (IsObjMarkable(pObj,pPV))
1522 GetMarkedObjectListWriteAccess().InsertEntry(SdrMark(pObj,pPV));
1523 bFnd=TRUE;
1525 } else {
1526 ULONG nPos=TryToFindMarkedObject(pObj);
1527 if (nPos!=CONTAINER_ENTRY_NOTFOUND)
1529 GetMarkedObjectListWriteAccess().DeleteMark(nPos);
1530 bFnd=TRUE;
1536 if (bFnd) {
1537 SortMarkedObjects();
1538 MarkListHasChanged();
1539 AdjustMarkHdl(); //HMHTRUE);
1540 //HMHShowMarkHdl();
1542 return bFnd;
1545 void SdrMarkView::MarkObj(SdrObject* pObj, SdrPageView* pPV, BOOL bUnmark, BOOL bImpNoSetMarkHdl)
1547 if (pObj!=NULL && pPV!=NULL && IsObjMarkable(pObj, pPV)) {
1548 BrkAction();
1549 if (!bUnmark)
1551 GetMarkedObjectListWriteAccess().InsertEntry(SdrMark(pObj,pPV));
1553 else
1555 ULONG nPos=TryToFindMarkedObject(pObj);
1556 if (nPos!=CONTAINER_ENTRY_NOTFOUND)
1558 GetMarkedObjectListWriteAccess().DeleteMark(nPos);
1561 if (!bImpNoSetMarkHdl) {
1562 MarkListHasChanged();
1563 AdjustMarkHdl(); //HMHTRUE);
1564 //HMHif (!bSomeObjChgdFlag) {
1565 // ShowMarkHdl kommt sonst mit dem AfterPaintTimer
1566 //HMHShowMarkHdl();
1567 //HMH}
1572 BOOL SdrMarkView::IsObjMarked(SdrObject* pObj) const
1574 // nicht so ganz die feine Art: Da FindObject() nicht const ist
1575 // muss ich mich hier auf non-const casten.
1576 ULONG nPos=((SdrMarkView*)this)->TryToFindMarkedObject(pObj);
1577 return nPos!=CONTAINER_ENTRY_NOTFOUND;
1580 USHORT SdrMarkView::GetMarkHdlSizePixel() const
1582 return aHdl.GetHdlSize()*2+1;
1585 void SdrMarkView::SetSolidMarkHdl(BOOL bOn)
1587 if (bOn!=aHdl.IsFineHdl()) {
1588 //HMHBOOL bMerk=IsMarkHdlShown();
1589 //HMHif (bMerk) HideMarkHdl();
1590 aHdl.SetFineHdl(bOn);
1591 //HMHif (bMerk) ShowMarkHdl();
1595 void SdrMarkView::SetMarkHdlSizePixel(USHORT nSiz)
1597 if (nSiz<3) nSiz=3;
1598 nSiz/=2;
1599 if (nSiz!=aHdl.GetHdlSize()) {
1600 //HMHBOOL bMerk=IsMarkHdlShown();
1601 //HMHif (bMerk) HideMarkHdl();
1602 aHdl.SetHdlSize(nSiz);
1603 //HMHif (bMerk) ShowMarkHdl();
1607 #define SDRSEARCH_IMPISMASTER 0x80000000 /* MasterPage wird gerade durchsucht */
1608 SdrObject* SdrMarkView::CheckSingleSdrObjectHit(const Point& rPnt, USHORT nTol, SdrObject* pObj, SdrPageView* pPV, ULONG nOptions, const SetOfByte* pMVisLay) const
1610 if((nOptions & SDRSEARCH_IMPISMASTER) && pObj->IsNotVisibleAsMaster())
1612 return NULL;
1615 const bool bCheckIfMarkable(nOptions & SDRSEARCH_TESTMARKABLE);
1616 const bool bDeep(nOptions & SDRSEARCH_DEEP);
1617 const bool bOLE(pObj->ISA(SdrOle2Obj));
1618 const bool bTXT(pObj->ISA(SdrTextObj) && ((SdrTextObj*)pObj)->IsTextFrame());
1619 SdrObject* pRet=NULL;
1620 Rectangle aRect(pObj->GetCurrentBoundRect());
1621 USHORT nTol2(nTol);
1623 // double tolerance for OLE, text frames and objects in
1624 // active text edit
1625 if(bOLE || bTXT || pObj==((SdrObjEditView*)this)->GetTextEditObject())
1627 nTol2*=2;
1630 aRect.Left ()-=nTol2; // Einmal Toleranz drauf fuer alle Objekte
1631 aRect.Top ()-=nTol2;
1632 aRect.Right ()+=nTol2;
1633 aRect.Bottom()+=nTol2;
1635 if (aRect.IsInside(rPnt))
1637 if ((!bCheckIfMarkable || IsObjMarkable(pObj,pPV)))
1639 SdrObjList* pOL=pObj->GetSubList();
1641 if (pOL!=NULL && pOL->GetObjCount()!=0)
1643 SdrObject* pTmpObj;
1644 // OD 30.06.2003 #108784# - adjustment hit point for virtual
1645 // objects.
1646 Point aPnt( rPnt );
1648 if ( pObj->ISA(SdrVirtObj) )
1650 Point aOffset = static_cast<SdrVirtObj*>(pObj)->GetOffset();
1651 aPnt.Move( -aOffset.X(), -aOffset.Y() );
1654 pRet=CheckSingleSdrObjectHit(aPnt,nTol,pOL,pPV,nOptions,pMVisLay,pTmpObj);
1656 else
1658 if(!pMVisLay || pMVisLay->IsSet(pObj->GetLayer()))
1660 pRet = SdrObjectPrimitiveHit(*pObj, rPnt, nTol2, *pPV, &pPV->GetVisibleLayers(), false);
1666 if (!bDeep && pRet!=NULL)
1668 pRet=pObj;
1671 return pRet;
1674 SdrObject* SdrMarkView::CheckSingleSdrObjectHit(const Point& rPnt, USHORT nTol, SdrObjList* pOL, SdrPageView* pPV, ULONG nOptions, const SetOfByte* pMVisLay, SdrObject*& rpRootObj) const
1676 BOOL bBack=(nOptions & SDRSEARCH_BACKWARD)!=0;
1677 SdrObject* pRet=NULL;
1678 rpRootObj=NULL;
1679 if (pOL!=NULL)
1681 // #110988#
1682 sal_Bool bRemap(pOL->GetOwnerObj() && pOL->GetOwnerObj()->ISA(E3dScene));
1683 E3dScene* pRemapScene = (bRemap ? (E3dScene*)pOL->GetOwnerObj() : 0L);
1685 ULONG nObjAnz=pOL->GetObjCount();
1686 ULONG nObjNum=bBack ? 0 : nObjAnz;
1687 while (pRet==NULL && (bBack ? nObjNum<nObjAnz : nObjNum>0)) {
1688 if (!bBack) nObjNum--;
1689 SdrObject* pObj;
1691 // #110988#
1692 if(bRemap)
1694 pObj = pOL->GetObj(pRemapScene->RemapOrdNum(nObjNum));
1696 else
1698 pObj = pOL->GetObj(nObjNum);
1701 pRet=CheckSingleSdrObjectHit(rPnt,nTol,pObj,pPV,nOptions,pMVisLay);
1702 if (pRet!=NULL) rpRootObj=pObj;
1703 if (bBack) nObjNum++;
1706 return pRet;
1709 BOOL SdrMarkView::PickObj(const Point& rPnt, short nTol, SdrObject*& rpObj, SdrPageView*& rpPV, ULONG nOptions) const
1711 return PickObj(rPnt,nTol,rpObj,rpPV,nOptions,NULL,NULL,NULL);
1714 BOOL SdrMarkView::PickObj(const Point& rPnt, short nTol, SdrObject*& rpObj, SdrPageView*& rpPV, ULONG nOptions, SdrObject** ppRootObj, ULONG* pnMarkNum, USHORT* pnPassNum) const
1715 { // Fehlt noch Pass2,Pass3
1716 SortMarkedObjects();
1717 if (ppRootObj!=NULL) *ppRootObj=NULL;
1718 if (pnMarkNum!=NULL) *pnMarkNum=CONTAINER_ENTRY_NOTFOUND;
1719 if (pnPassNum!=NULL) *pnPassNum=0;
1720 rpObj=NULL;
1721 rpPV=NULL;
1722 BOOL bWholePage=(nOptions & SDRSEARCH_WHOLEPAGE) !=0;
1723 BOOL bMarked=(nOptions & SDRSEARCH_MARKED) !=0;
1724 BOOL bMasters=!bMarked && (nOptions & SDRSEARCH_ALSOONMASTER) !=0;
1725 BOOL bBack=(nOptions & SDRSEARCH_BACKWARD) !=0;
1726 #if OSL_DEBUG_LEVEL > 0
1727 BOOL bNext=(nOptions & SDRSEARCH_NEXT) !=0; (void)bNext; // n.i.
1728 BOOL bBoundCheckOn2ndPass=(nOptions & SDRSEARCH_PASS2BOUND) !=0; (void)bBoundCheckOn2ndPass;// n.i.
1729 BOOL bCheckNearestOn3rdPass=(nOptions & SDRSEARCH_PASS3NEAREST) !=0; (void)bCheckNearestOn3rdPass;// n.i.
1730 #endif
1731 if (nTol<0) nTol=ImpGetHitTolLogic(nTol,NULL);
1732 Point aPt(rPnt);
1733 SdrObject* pObj=NULL;
1734 SdrObject* pHitObj=NULL;
1735 SdrPageView* pPV=NULL;
1736 if (!bBack && ((SdrObjEditView*)this)->IsTextEditFrameHit(rPnt)) {
1737 pObj=((SdrObjEditView*)this)->GetTextEditObject();
1738 pHitObj=pObj;
1739 pPV=((SdrObjEditView*)this)->GetTextEditPageView();
1741 if (bMarked) {
1742 ULONG nMrkAnz=GetMarkedObjectCount();
1743 ULONG nMrkNum=bBack ? 0 : nMrkAnz;
1744 while (pHitObj==NULL && (bBack ? nMrkNum<nMrkAnz : nMrkNum>0)) {
1745 if (!bBack) nMrkNum--;
1746 SdrMark* pM=GetSdrMarkByIndex(nMrkNum);
1747 pObj=pM->GetMarkedSdrObj();
1748 pPV=pM->GetPageView();
1749 pHitObj=CheckSingleSdrObjectHit(aPt,nTol,pObj,pPV,nOptions,NULL);
1750 if (bBack) nMrkNum++;
1753 else
1755 pPV = GetSdrPageView();
1757 if(pPV)
1759 SdrPage* pPage=pPV->GetPage();
1760 USHORT nPgAnz=1;
1762 if(bMasters && pPage->TRG_HasMasterPage())
1764 nPgAnz++;
1767 BOOL bExtraPassForWholePage=bWholePage && pPage!=pPV->GetObjList();
1768 if (bExtraPassForWholePage) nPgAnz++; // Suche erst in AktObjList, dann auf der gesamten Page
1769 USHORT nPgNum=bBack ? 0 : nPgAnz;
1770 while (pHitObj==NULL && (bBack ? nPgNum<nPgAnz : nPgNum>0)) {
1771 ULONG nTmpOptions=nOptions;
1772 if (!bBack) nPgNum--;
1773 const SetOfByte* pMVisLay=NULL;
1774 SdrObjList* pObjList=NULL;
1775 if (pnPassNum!=NULL) *pnPassNum&=~(SDRSEARCHPASS_MASTERPAGE|SDRSEARCHPASS_INACTIVELIST);
1776 if (nPgNum>=nPgAnz-1 || (bExtraPassForWholePage && nPgNum>=nPgAnz-2))
1778 pObjList=pPV->GetObjList();
1779 if (bExtraPassForWholePage && nPgNum==nPgAnz-2) {
1780 pObjList=pPage;
1781 if (pnPassNum!=NULL) *pnPassNum|=SDRSEARCHPASS_INACTIVELIST;
1784 else
1786 // sonst MasterPage
1787 SdrPage& rMasterPage = pPage->TRG_GetMasterPage();
1788 pMVisLay = &pPage->TRG_GetMasterPageVisibleLayers();
1789 pObjList = &rMasterPage;
1791 if (pnPassNum!=NULL) *pnPassNum|=SDRSEARCHPASS_MASTERPAGE;
1792 nTmpOptions=nTmpOptions | SDRSEARCH_IMPISMASTER;
1794 pHitObj=CheckSingleSdrObjectHit(aPt,nTol,pObjList,pPV,nTmpOptions,pMVisLay,pObj);
1795 if (bBack) nPgNum++;
1799 if (pHitObj!=NULL) {
1800 if (ppRootObj!=NULL) *ppRootObj=pObj;
1801 if ((nOptions & SDRSEARCH_DEEP) !=0) pObj=pHitObj;
1802 if ((nOptions & SDRSEARCH_TESTTEXTEDIT) !=0) {
1803 if (!pObj->HasTextEdit() || pPV->GetLockedLayers().IsSet(pObj->GetLayer())) {
1804 pObj=NULL;
1807 if (pObj!=NULL && (nOptions & SDRSEARCH_TESTMACRO) !=0) {
1808 SdrObjMacroHitRec aHitRec;
1809 aHitRec.aPos=aPt;
1810 aHitRec.aDownPos=aPt;
1811 aHitRec.nTol=nTol;
1812 aHitRec.pVisiLayer=&pPV->GetVisibleLayers();
1813 aHitRec.pPageView=pPV;
1814 if (!pObj->HasMacro() || !pObj->IsMacroHit(aHitRec)) pObj=NULL;
1816 if (pObj!=NULL && (nOptions & SDRSEARCH_WITHTEXT) !=0 && pObj->GetOutlinerParaObject()==NULL) pObj=NULL;
1817 if (pObj!=NULL && (nOptions & SDRSEARCH_TESTTEXTAREA) !=0)
1819 if(!SdrObjectPrimitiveHit(*pObj, aPt, 0, *pPV, 0, true))
1821 pObj = 0;
1824 if (pObj!=NULL) {
1825 rpObj=pObj;
1826 rpPV=pPV;
1827 if (pnPassNum!=NULL) *pnPassNum|=SDRSEARCHPASS_DIRECT;
1830 return rpObj!=NULL;
1833 BOOL SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageView*& rpPV, ULONG* pnMarkNum, ULONG nOptions) const
1835 SortMarkedObjects();
1836 BOOL bBoundCheckOn2ndPass=(nOptions & SDRSEARCH_PASS2BOUND) !=0;
1837 BOOL bCheckNearestOn3rdPass=(nOptions & SDRSEARCH_PASS3NEAREST) !=0;
1838 rpObj=NULL;
1839 rpPV=NULL;
1840 if (pnMarkNum!=NULL) *pnMarkNum=CONTAINER_ENTRY_NOTFOUND;
1841 Point aPt(rPnt);
1842 USHORT nTol=(USHORT)nHitTolLog;
1843 BOOL bFnd=FALSE;
1844 ULONG nMarkAnz=GetMarkedObjectCount();
1845 ULONG nMarkNum;
1846 for (nMarkNum=nMarkAnz; nMarkNum>0 && !bFnd;) {
1847 nMarkNum--;
1848 SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
1849 SdrPageView* pPV=pM->GetPageView();
1850 SdrObject* pObj=pM->GetMarkedSdrObj();
1851 bFnd = 0 != CheckSingleSdrObjectHit(aPt,nTol,pObj,pPV,SDRSEARCH_TESTMARKABLE,0);
1852 if (bFnd) {
1853 rpObj=pObj;
1854 rpPV=pPV;
1855 if (pnMarkNum!=NULL) *pnMarkNum=nMarkNum;
1858 if ((bBoundCheckOn2ndPass || bCheckNearestOn3rdPass) && !bFnd) {
1859 SdrObject* pBestObj=NULL;
1860 SdrPageView* pBestPV=NULL;
1861 ULONG nBestMarkNum=0;
1862 ULONG nBestDist=ULONG_MAX;
1863 for (nMarkNum=nMarkAnz; nMarkNum>0 && !bFnd;) {
1864 nMarkNum--;
1865 SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
1866 SdrPageView* pPV=pM->GetPageView();
1867 SdrObject* pObj=pM->GetMarkedSdrObj();
1868 Rectangle aRect(pObj->GetCurrentBoundRect());
1869 aRect.Left ()-=nTol;
1870 aRect.Top ()-=nTol;
1871 aRect.Right ()+=nTol;
1872 aRect.Bottom()+=nTol;
1873 if (aRect.IsInside(aPt)) {
1874 bFnd=TRUE;
1875 rpObj=pObj;
1876 rpPV=pPV;
1877 if (pnMarkNum!=NULL) *pnMarkNum=nMarkNum;
1878 } else if (bCheckNearestOn3rdPass) {
1879 ULONG nDist=0;
1880 if (aPt.X()<aRect.Left()) nDist+=aRect.Left()-aPt.X();
1881 if (aPt.X()>aRect.Right()) nDist+=aPt.X()-aRect.Right();
1882 if (aPt.Y()<aRect.Top()) nDist+=aRect.Top()-aPt.Y();
1883 if (aPt.Y()>aRect.Bottom()) nDist+=aPt.Y()-aRect.Bottom();
1884 if (nDist<nBestDist) {
1885 pBestObj=pObj;
1886 pBestPV=pPV;
1887 nBestMarkNum=nMarkNum;
1891 if (bCheckNearestOn3rdPass && !bFnd) {
1892 rpObj=pBestObj;
1893 rpPV=pBestPV;
1894 if (pnMarkNum!=NULL) *pnMarkNum=nBestMarkNum;
1895 bFnd=pBestObj!=NULL;
1898 return bFnd;
1901 SdrHitKind SdrMarkView::PickSomething(const Point& rPnt, short nTol) const
1903 nTol=ImpGetHitTolLogic(nTol,NULL);
1904 SdrHitKind eRet=SDRHIT_NONE;
1905 Point aPt(rPnt);
1906 SdrObject* pObj=NULL;
1907 SdrPageView* pPV=NULL;
1908 if (eRet==SDRHIT_NONE && PickObj(rPnt,USHORT(nTol),pObj,pPV,SDRSEARCH_PICKMARKABLE)) {
1909 Rectangle aRct1(aPt-Point(nTol,nTol),aPt+Point(nTol,nTol)); // HitRect fuer Toleranz
1910 Rectangle aBR(pObj->GetCurrentBoundRect());
1911 if (aRct1.IsInside(aBR.TopLeft())) eRet=SDRHIT_BOUNDTL;
1912 else if (aRct1.IsInside(aBR.TopCenter())) eRet=SDRHIT_BOUNDTC;
1913 else if (aRct1.IsInside(aBR.TopRight())) eRet=SDRHIT_BOUNDTR;
1914 else if (aRct1.IsInside(aBR.LeftCenter())) eRet=SDRHIT_BOUNDCL;
1915 else if (aRct1.IsInside(aBR.RightCenter())) eRet=SDRHIT_BOUNDCR;
1916 else if (aRct1.IsInside(aBR.BottomLeft())) eRet=SDRHIT_BOUNDBL;
1917 else if (aRct1.IsInside(aBR.BottomCenter())) eRet=SDRHIT_BOUNDBC;
1918 else if (aRct1.IsInside(aBR.BottomRight())) eRet=SDRHIT_BOUNDBR;
1919 else eRet=SDRHIT_OBJECT;
1921 return eRet;
1924 void SdrMarkView::UnmarkAllObj(SdrPageView* pPV)
1926 if (GetMarkedObjectCount()!=0) {
1927 BrkAction();
1928 //HMHBOOL bVis=bHdlShown;
1929 //HMHif (bVis) HideMarkHdl();
1930 if (pPV!=NULL)
1932 GetMarkedObjectListWriteAccess().DeletePageView(*pPV);
1934 else
1936 GetMarkedObjectListWriteAccess().Clear();
1938 pMarkedObj=NULL;
1939 pMarkedPV=NULL;
1940 MarkListHasChanged();
1941 AdjustMarkHdl(); //HMHTRUE);
1942 //HMHif (bVis) ShowMarkHdl(); // ggf. fuer die RefPoints
1946 void SdrMarkView::MarkAllObj(SdrPageView* _pPV)
1948 BrkAction();
1949 //HMHHideMarkHdl();
1951 if(!_pPV)
1953 _pPV = GetSdrPageView();
1956 // #i69171# _pPV may still be NULL if there is no SDrPageView (!), e.g. when inserting
1957 // other files
1958 if(_pPV)
1960 const bool bMarkChg(GetMarkedObjectListWriteAccess().InsertPageView(*_pPV));
1962 if(bMarkChg)
1964 MarkListHasChanged();
1968 if(GetMarkedObjectCount())
1970 AdjustMarkHdl(); //HMHTRUE);
1971 //HMHShowMarkHdl();
1975 void SdrMarkView::AdjustMarkHdl() //HMHBOOL bRestraintPaint)
1977 //HMHBOOL bVis=bHdlShown;
1978 //HMHif (bVis) HideMarkHdl();
1979 CheckMarked();
1980 SetMarkRects();
1981 SetMarkHandles();
1982 //HMHif(bRestraintPaint && bVis)
1983 //HMH{
1984 //HMH ShowMarkHdl();
1985 //HMH}
1988 Rectangle SdrMarkView::GetMarkedObjBoundRect() const
1990 Rectangle aRect;
1991 for (ULONG nm=0; nm<GetMarkedObjectCount(); nm++) {
1992 SdrMark* pM=GetSdrMarkByIndex(nm);
1993 SdrObject* pO=pM->GetMarkedSdrObj();
1994 Rectangle aR1(pO->GetCurrentBoundRect());
1995 if (aRect.IsEmpty()) aRect=aR1;
1996 else aRect.Union(aR1);
1998 return aRect;
2001 const Rectangle& SdrMarkView::GetMarkedObjRect() const
2003 if (bMarkedObjRectDirty) {
2004 ((SdrMarkView*)this)->bMarkedObjRectDirty=FALSE;
2005 Rectangle aRect;
2006 for (ULONG nm=0; nm<GetMarkedObjectCount(); nm++) {
2007 SdrMark* pM=GetSdrMarkByIndex(nm);
2008 SdrObject* pO=pM->GetMarkedSdrObj();
2009 Rectangle aR1(pO->GetSnapRect());
2010 if (aRect.IsEmpty()) aRect=aR1;
2011 else aRect.Union(aR1);
2013 ((SdrMarkView*)this)->aMarkedObjRect=aRect;
2015 return aMarkedObjRect;
2018 ////////////////////////////////////////////////////////////////////////////////////////////////////
2020 void SdrMarkView::ImpTakeDescriptionStr(USHORT nStrCacheID, XubString& rStr, USHORT nVal, USHORT nOpt) const
2022 rStr = ImpGetResStr(nStrCacheID);
2023 xub_StrLen nPos = rStr.SearchAscii("%1");
2025 if(nPos != STRING_NOTFOUND)
2027 rStr.Erase(nPos, 2);
2029 if(nOpt == IMPSDR_POINTSDESCRIPTION)
2031 rStr.Insert(GetDescriptionOfMarkedPoints(), nPos);
2033 else if(nOpt == IMPSDR_GLUEPOINTSDESCRIPTION)
2035 rStr.Insert(GetDescriptionOfMarkedGluePoints(), nPos);
2037 else
2039 rStr.Insert(GetDescriptionOfMarkedObjects(), nPos);
2043 nPos = rStr.SearchAscii("%2");
2045 if(nPos != STRING_NOTFOUND)
2047 rStr.Erase(nPos, 2);
2048 rStr.Insert(UniString::CreateFromInt32(nVal), nPos);
2052 ////////////////////////////////////////////////////////////////////////////////////////////////////
2054 BOOL SdrMarkView::EnterMarkedGroup()
2056 BOOL bRet=FALSE;
2057 // Es wird nur die erste gefundene Gruppe (also nur in einer PageView) geentert
2058 // Weil PageView::EnterGroup ein AdjustMarkHdl ruft.
2059 // Das muss ich per Flag mal unterbinden vvvvvvvv
2060 SdrPageView* pPV = GetSdrPageView();
2062 if(pPV)
2064 BOOL bEnter=FALSE;
2065 for (sal_uInt32 nm(GetMarkedObjectCount()); nm > 0 && !bEnter;)
2067 nm--;
2068 SdrMark* pM=GetSdrMarkByIndex(nm);
2069 if (pM->GetPageView()==pPV) {
2070 SdrObject* pObj=pM->GetMarkedSdrObj();
2071 if (pObj->IsGroupObject()) {
2072 if (pPV->EnterGroup(pObj)) {
2073 bRet=TRUE;
2074 bEnter=TRUE;
2080 return bRet;
2083 ////////////////////////////////////////////////////////////////////////////////////////////////////
2085 void SdrMarkView::MarkListHasChanged()
2087 GetMarkedObjectListWriteAccess().SetNameDirty();
2088 SetEdgesOfMarkedNodesDirty(); // bEdgesOfMarkedNodesDirty=TRUE;
2090 bMarkedObjRectDirty=TRUE;
2091 bMarkedPointsRectsDirty=TRUE;
2092 #ifdef DBG_UTIL
2093 if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
2094 #endif
2095 BOOL bOneEdgeMarked=FALSE;
2096 if (GetMarkedObjectCount()==1) {
2097 const SdrObject* pObj=GetMarkedObjectByIndex(0);
2098 if (pObj->GetObjInventor()==SdrInventor) {
2099 UINT16 nIdent=pObj->GetObjIdentifier();
2100 bOneEdgeMarked=nIdent==OBJ_EDGE;
2103 ImpSetGlueVisible4(bOneEdgeMarked);
2106 ////////////////////////////////////////////////////////////////////////////////////////////////////
2108 void SdrMarkView::SetMoveOutside(BOOL bOn)
2110 aHdl.SetMoveOutside(bOn);
2113 BOOL SdrMarkView::IsMoveOutside() const
2115 return aHdl.IsMoveOutside();
2118 void SdrMarkView::SetDesignMode( BOOL _bOn )
2120 if ( bDesignMode != _bOn )
2122 bDesignMode = _bOn;
2123 SdrPageView* pPageView = GetSdrPageView();
2124 if ( pPageView )
2125 pPageView->SetDesignMode( _bOn );
2129 // MarkHandles Objektaenderung:
2130 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2131 // - Bei Notify mit HINT_OBJCHG (oder so) werden die Handles erstmal versteckt
2132 // (wenn nicht schon wegen Dragging versteckt).
2133 // - XorHdl: Bei ModelHasChanged() werden sie dann wieder angezeigt.
2134 // - PaintEvents kommen nun durch.
2135 // - Die XorHandles werden z.T. wieder uebermalt.
2136 // - Xor: Nach dem Painten werden die Handles im (vom PaintHandler gerufenen)
2137 // CompleteRedraw per ToggleShownXor bei gesetzter ClipRegion nochmal gemalt
2138 // und damit ist alles in Butter.
2139 // - ToggleShownXor macht bei SolidHdl nix weil bHdlShown=FALSE
2140 // - Der AfterPaintTimer wird gestartet.
2141 // - SolidHdl: Im AfterPaintHandler wird ShowMarkHdl gerufen.
2142 // Da die Handles zu diesem Zeitpunkt nicht angezeigt sind wird:
2143 // - SaveBackground durchgefuehrt.
2144 // - DrawMarkHdl gerufen und bHdlShown gesetzt.
2146 // MarkHandles bei sonstigem Invalidate:
2147 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2148 // In diesem Fall bekomme ich kein Notify und beim Aufruf des
2149 // PaintHandlers->CompleteRedraw() sind auch die SolidHandles sichtbar.