merge the formfield patch from ooo-build
[ooovba.git] / svx / source / svdraw / svdmrkv1.cxx
blobf039060b0818ea08db5a159a8a863302beaa6bb0
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: svdmrkv1.cxx,v $
10 * $Revision: 1.15 $
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 <svx/svdpagv.hxx>
39 #include <svx/svdpage.hxx>
40 #include "svddrgm1.hxx"
42 ////////////////////////////////////////////////////////////////////////////////////////////////////
43 ////////////////////////////////////////////////////////////////////////////////////////////////////
44 ////////////////////////////////////////////////////////////////////////////////////////////////////
46 // @@@@@ @@ @@ @@ @@ @@ @@ @@@@@@ @@ @@ @@@@ @@@@@ @@ @@ @@ @@@@@ @@@@@ @@ @@ @@ @@ @@@@
47 // @@ @@ @@ @@ @@@ @@ @@ @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@
48 // @@ @@ @@ @@ @@@@@@ @@ @@ @@ @@@@@@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@@@@@ @@
49 // @@@@@ @@ @@ @@@@@@ @@@@ @@ @@@@@@@ @@@@@@ @@@@@ @@@@ @@ @@@@ @@@@@ @@ @@ @@@@@@ @@ @@@
50 // @@ @@ @@ @@ @@@ @@ @@ @@ @@ @ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@
51 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
52 // @@ @@@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@@@@ @@ @@ @@@@ @@ @@ @@@@@
54 ////////////////////////////////////////////////////////////////////////////////////////////////////
56 BOOL SdrMarkView::HasMarkablePoints() const
58 ForceUndirtyMrkPnt();
59 bool bRet=false;
60 if (!ImpIsFrameHandles()) {
61 ULONG nMarkAnz=GetMarkedObjectCount();
62 if (nMarkAnz<=nFrameHandlesLimit) {
63 for (ULONG nMarkNum=0; nMarkNum<nMarkAnz && !bRet; nMarkNum++) {
64 const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
65 const SdrObject* pObj=pM->GetMarkedSdrObj();
66 bRet=pObj->IsPolyObj();
70 return bRet;
73 ULONG SdrMarkView::GetMarkablePointCount() const
75 ForceUndirtyMrkPnt();
76 ULONG nAnz=0;
77 if (!ImpIsFrameHandles()) {
78 ULONG nMarkAnz=GetMarkedObjectCount();
79 if (nMarkAnz<=nFrameHandlesLimit) {
80 for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) {
81 const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
82 const SdrObject* pObj=pM->GetMarkedSdrObj();
83 if (pObj->IsPolyObj()) {
84 nAnz+=pObj->GetPointCount();
89 return nAnz;
92 BOOL SdrMarkView::HasMarkedPoints() const
94 ForceUndirtyMrkPnt();
95 BOOL bRet=FALSE;
96 if (!ImpIsFrameHandles()) {
97 ULONG nMarkAnz=GetMarkedObjectCount();
98 if (nMarkAnz<=nFrameHandlesLimit) {
99 for (ULONG nMarkNum=0; nMarkNum<nMarkAnz && !bRet; nMarkNum++) {
100 const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
101 const SdrUShortCont* pPts=pM->GetMarkedPoints();
102 bRet=pPts!=NULL && pPts->GetCount()!=0;
106 return bRet;
109 ULONG SdrMarkView::GetMarkedPointCount() const
111 ForceUndirtyMrkPnt();
112 ULONG nAnz=0;
113 if (!ImpIsFrameHandles()) {
114 ULONG nMarkAnz=GetMarkedObjectCount();
115 if (nMarkAnz<=nFrameHandlesLimit) {
116 for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) {
117 const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
118 const SdrUShortCont* pPts=pM->GetMarkedPoints();
119 if (pPts!=NULL) nAnz+=pPts->GetCount();
123 return nAnz;
126 BOOL SdrMarkView::IsPointMarkable(const SdrHdl& rHdl) const
128 return !ImpIsFrameHandles() && &rHdl!=NULL && !rHdl.IsPlusHdl() && rHdl.GetKind()!=HDL_GLUE && rHdl.GetKind()!=HDL_SMARTTAG && rHdl.GetObj()!=NULL && rHdl.GetObj()->IsPolyObj();
131 BOOL SdrMarkView::MarkPointHelper(SdrHdl* pHdl, SdrMark* pMark, BOOL bUnmark)
133 return ImpMarkPoint( pHdl, pMark, bUnmark );
136 BOOL SdrMarkView::ImpMarkPoint(SdrHdl* pHdl, SdrMark* pMark, BOOL bUnmark)
138 if (pHdl==NULL || pHdl->IsPlusHdl() || pHdl->GetKind()==HDL_GLUE)
139 return FALSE;
141 if (pHdl->IsSelected() != bUnmark)
142 return FALSE;
144 SdrObject* pObj=pHdl->GetObj();
145 if (pObj==NULL || !pObj->IsPolyObj())
146 return FALSE;
148 if (pMark==NULL)
150 ULONG nMarkNum=TryToFindMarkedObject(pObj);
151 if (nMarkNum==CONTAINER_ENTRY_NOTFOUND)
152 return FALSE;
153 pMark=GetSdrMarkByIndex(nMarkNum);
155 const sal_uInt32 nHdlNum(pHdl->GetObjHdlNum());
156 SdrUShortCont* pPts=pMark->ForceMarkedPoints();
157 if (!bUnmark)
159 pPts->Insert((sal_uInt16)nHdlNum);
161 else
163 ULONG nBla=pPts->GetPos((sal_uInt16)nHdlNum);
164 if (nBla!=CONTAINER_ENTRY_NOTFOUND)
166 pPts->Remove(nBla);
168 else
170 return FALSE; // Fehlerfall!
174 pHdl->SetSelected(!bUnmark);
175 if (!bPlusHdlAlways)
177 if (!bUnmark)
179 sal_uInt32 nAnz(pObj->GetPlusHdlCount(*pHdl));
180 for (sal_uInt32 i=0; i<nAnz; i++)
182 SdrHdl* pPlusHdl=pObj->GetPlusHdl(*pHdl,i);
183 if (pPlusHdl!=NULL)
185 pPlusHdl->SetObj(pObj);
186 pPlusHdl->SetPageView(pMark->GetPageView());
187 pPlusHdl->SetPlusHdl(TRUE);
188 aHdl.AddHdl(pPlusHdl);
192 else
194 for (ULONG i = aHdl.GetHdlCount(); i>0;)
196 i--;
197 SdrHdl* pPlusHdl=aHdl.GetHdl(i);
198 if (pPlusHdl->IsPlusHdl() && pPlusHdl->GetSourceHdlNum()==nHdlNum)
200 aHdl.RemoveHdl(i);
201 delete pPlusHdl;
207 // #97016# II: Sort handles. This was missing in ImpMarkPoint all the time.
208 aHdl.Sort();
210 return TRUE;
214 BOOL SdrMarkView::MarkPoint(SdrHdl& rHdl, BOOL bUnmark)
216 if (&rHdl==NULL) return FALSE;
217 ForceUndirtyMrkPnt();
218 BOOL bRet=FALSE;
219 const SdrObject* pObj=rHdl.GetObj();
220 if (IsPointMarkable(rHdl) && rHdl.IsSelected()==bUnmark) {
221 ULONG nMarkNum=TryToFindMarkedObject(pObj);
222 if (nMarkNum!=CONTAINER_ENTRY_NOTFOUND) {
223 SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
224 SdrUShortCont* pPts=pM->ForceMarkedPoints();
225 pPts->ForceSort();
226 if (ImpMarkPoint(&rHdl,pM,bUnmark)) {
227 pPts->ForceSort();
228 MarkListHasChanged();
229 bRet=TRUE;
234 return bRet;
237 BOOL SdrMarkView::MarkPoints(const Rectangle* pRect, BOOL bUnmark)
239 ForceUndirtyMrkPnt();
240 BOOL bChgd=FALSE;
241 SortMarkedObjects();
242 const SdrObject* pObj0=NULL;
243 const SdrPageView* pPV0=NULL;
244 SdrMark* pM=NULL;
245 aHdl.Sort();
246 //HMHBOOL bHideHdl=IsMarkHdlShown() && IsSolidMarkHdl() && !bPlusHdlAlways;
247 ULONG nHdlAnz=aHdl.GetHdlCount();
248 for (ULONG nHdlNum=nHdlAnz; nHdlNum>0;) {
249 nHdlNum--;
250 SdrHdl* pHdl=aHdl.GetHdl(nHdlNum);
251 if (IsPointMarkable(*pHdl) && pHdl->IsSelected()==bUnmark) {
252 const SdrObject* pObj=pHdl->GetObj();
253 const SdrPageView* pPV=pHdl->GetPageView();
254 if (pObj!=pObj0 || pPV!=pPV0 || pM==NULL) { // Dieser Abschnitt dient zur Optimierung,
255 if (pM!=NULL) {
256 SdrUShortCont* pPts=pM->GetMarkedPoints();
257 if (pPts!=NULL) pPts->ForceSort();
259 ULONG nMarkNum=TryToFindMarkedObject(pObj); // damit ImpMarkPoint() nicht staendig das
260 if (nMarkNum!=CONTAINER_ENTRY_NOTFOUND) { // Objekt in der MarkList suchen muss.
261 pM=GetSdrMarkByIndex(nMarkNum);
262 pObj0=pObj;
263 pPV0=pPV;
264 SdrUShortCont* pPts=pM->ForceMarkedPoints();
265 pPts->ForceSort();
266 } else {
267 #ifdef DBG_UTIL
268 if (pObj->IsInserted()) {
269 DBG_ERROR("SdrMarkView::MarkPoints(const Rectangle* pRect): Markiertes Objekt nicht gefunden");
271 #endif
272 pM=NULL;
275 Point aPos(pHdl->GetPos());
276 if (pM!=NULL && (pRect==NULL || pRect->IsInside(aPos))) {
277 //HMHif (bHideHdl && IsMarkHdlShown() && pHdl->GetObj()!=NULL) {
278 //HMHsal_uInt32 nAnz=pHdl->GetObj()->GetPlusHdlCount(*pHdl);
279 //HMHif (nAnz!=0L) HideMarkHdl(); // #36987#
280 //HMH}
281 if (ImpMarkPoint(pHdl,pM,bUnmark)) bChgd=TRUE;
285 if (pM!=NULL) { // Den zuletzt geaenderten MarkEntry ggf. noch aufraeumen
286 SdrUShortCont* pPts=pM->GetMarkedPoints();
287 if (pPts!=NULL) pPts->ForceSort();
289 //HMHif (bHideHdl) ShowMarkHdl(); // #36987#
290 if (bChgd) {
291 MarkListHasChanged();
294 return bChgd;
297 BOOL SdrMarkView::MarkNextPoint(BOOL /*bPrev*/)
299 ForceUndirtyMrkPnt();
300 BOOL bChgd=FALSE;
301 SortMarkedObjects();
302 // ...
303 if (bChgd) {
304 MarkListHasChanged();
306 return bChgd;
309 BOOL SdrMarkView::MarkNextPoint(const Point& /*rPnt*/, BOOL /*bPrev*/)
311 ForceUndirtyMrkPnt();
312 BOOL bChgd=FALSE;
313 SortMarkedObjects();
314 // ...
315 if (bChgd) {
316 MarkListHasChanged();
318 return bChgd;
321 const Rectangle& SdrMarkView::GetMarkedPointsRect() const
323 ForceUndirtyMrkPnt();
324 if (bMarkedPointsRectsDirty) ImpSetPointsRects();
325 return aMarkedPointsRect;
328 void SdrMarkView::SetPlusHandlesAlwaysVisible(BOOL bOn)
329 { // HandlePaint optimieren !!!!!!!
330 ForceUndirtyMrkPnt();
331 if (bOn!=bPlusHdlAlways) {
332 //HMHBOOL bVis=IsMarkHdlShown();
333 //HMHif (bVis) HideMarkHdl();
334 bPlusHdlAlways=bOn;
335 SetMarkHandles();
336 //HMHif (bVis) ShowMarkHdl();
337 MarkListHasChanged();
341 ////////////////////////////////////////////////////////////////////////////////////////////////////
342 // ImpSetPointsRects() ist fuer PolyPoints und GluePoints!
343 ////////////////////////////////////////////////////////////////////////////////////////////////////
345 void SdrMarkView::ImpSetPointsRects() const
347 Rectangle aPnts;
348 Rectangle aGlue;
349 ULONG nHdlAnz=aHdl.GetHdlCount();
350 for (ULONG nHdlNum=0; nHdlNum<nHdlAnz; nHdlNum++) {
351 const SdrHdl* pHdl=aHdl.GetHdl(nHdlNum);
352 SdrHdlKind eKind=pHdl->GetKind();
353 if ((eKind==HDL_POLY && pHdl->IsSelected()) || eKind==HDL_GLUE) {
354 Point aPt(pHdl->GetPos());
355 Rectangle& rR=eKind==HDL_GLUE ? aGlue : aPnts;
356 if (rR.IsEmpty()) {
357 rR=Rectangle(aPt,aPt);
358 } else {
359 if (aPt.X()<rR.Left ()) rR.Left ()=aPt.X();
360 if (aPt.X()>rR.Right ()) rR.Right ()=aPt.X();
361 if (aPt.Y()<rR.Top ()) rR.Top ()=aPt.Y();
362 if (aPt.Y()>rR.Bottom()) rR.Bottom()=aPt.Y();
366 ((SdrMarkView*)this)->aMarkedPointsRect=aPnts;
367 ((SdrMarkView*)this)->aMarkedGluePointsRect=aGlue;
368 ((SdrMarkView*)this)->bMarkedPointsRectsDirty=FALSE;
371 ////////////////////////////////////////////////////////////////////////////////////////////////////
372 // UndirtyMrkPnt() ist fuer PolyPoints und GluePoints!
373 ////////////////////////////////////////////////////////////////////////////////////////////////////
375 void SdrMarkView::UndirtyMrkPnt() const
377 BOOL bChg=FALSE;
378 ULONG nMarkAnz=GetMarkedObjectCount();
379 for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) {
380 SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
381 const SdrObject* pObj=pM->GetMarkedSdrObj();
382 // PolyPoints
383 SdrUShortCont* pPts=pM->GetMarkedPoints();
384 if (pPts!=NULL) {
385 if (pObj->IsPolyObj()) {
386 // Ungueltig markierte Punkte entfernen, also alle
387 // Eintraege die groesser sind als die Punktanzahl des Objekts
388 sal_uInt32 nMax(pObj->GetPointCount());
389 sal_uInt32 nPtNum(0xffffffff);
391 pPts->ForceSort();
393 for (sal_uInt32 nIndex(pPts->GetCount()); nIndex > 0L && nPtNum >= nMax;)
395 nIndex--;
396 nPtNum = pPts->GetObject(nIndex);
398 if(nPtNum >= nMax)
400 pPts->Remove(nIndex);
401 bChg = TRUE;
405 else
407 DBG_ERROR("SdrMarkView::UndirtyMrkPnt(): Markierte Punkte an einem Objekt, dass kein PolyObj ist!");
408 if(pPts && pPts->GetCount())
410 pPts->Clear();
411 bChg = TRUE;
416 // GluePoints
417 pPts=pM->GetMarkedGluePoints();
418 const SdrGluePointList* pGPL=pObj->GetGluePointList();
419 if (pPts!=NULL) {
420 if (pGPL!=NULL) {
421 // Ungueltig markierte Klebepunkte entfernen, also alle
422 // Eintraege (Id's) die nicht in der GluePointList des
423 // Objekts enthalten sind
424 pPts->ForceSort();
425 for (ULONG nIndex=pPts->GetCount(); nIndex>0;) {
426 nIndex--;
427 USHORT nId=pPts->GetObject(nIndex);
428 if (pGPL->FindGluePoint(nId)==SDRGLUEPOINT_NOTFOUND) {
429 pPts->Remove(nIndex);
430 bChg=TRUE;
433 } else {
434 if (pPts!=NULL && pPts->GetCount()!=0) {
435 pPts->Clear(); // Objekt hat keine Klebepunkte (mehr)
436 bChg=TRUE;
441 if (bChg) ((SdrMarkView*)this)->bMarkedPointsRectsDirty=TRUE;
442 ((SdrMarkView*)this)->bMrkPntDirty=FALSE;
445 ////////////////////////////////////////////////////////////////////////////////////////////////////
446 ////////////////////////////////////////////////////////////////////////////////////////////////////
447 ////////////////////////////////////////////////////////////////////////////////////////////////////
449 BOOL SdrMarkView::HasMarkableGluePoints() const
451 BOOL bRet=FALSE;
452 if (IsGluePointEditMode()) {
453 ForceUndirtyMrkPnt();
454 ULONG nMarkAnz=GetMarkedObjectCount();
455 for (ULONG nMarkNum=0; nMarkNum<nMarkAnz && !bRet; nMarkNum++) {
456 const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
457 const SdrObject* pObj=pM->GetMarkedSdrObj();
458 const SdrGluePointList* pGPL=pObj->GetGluePointList();
460 // #i38892#
461 if(pGPL && pGPL->GetCount())
463 for(sal_uInt16 a(0); !bRet && a < pGPL->GetCount(); a++)
465 if((*pGPL)[a].IsUserDefined())
467 bRet = TRUE;
473 return bRet;
476 ULONG SdrMarkView::GetMarkableGluePointCount() const
478 ULONG nAnz=0;
479 if (IsGluePointEditMode()) {
480 ForceUndirtyMrkPnt();
481 ULONG nMarkAnz=GetMarkedObjectCount();
482 for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) {
483 const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
484 const SdrObject* pObj=pM->GetMarkedSdrObj();
485 const SdrGluePointList* pGPL=pObj->GetGluePointList();
487 // #i38892#
488 if(pGPL && pGPL->GetCount())
490 for(sal_uInt16 a(0); a < pGPL->GetCount(); a++)
492 if((*pGPL)[a].IsUserDefined())
494 nAnz++;
500 return nAnz;
503 BOOL SdrMarkView::HasMarkedGluePoints() const
505 ForceUndirtyMrkPnt();
506 BOOL bRet=FALSE;
507 ULONG nMarkAnz=GetMarkedObjectCount();
508 for (ULONG nMarkNum=0; nMarkNum<nMarkAnz && !bRet; nMarkNum++) {
509 const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
510 const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
511 bRet=pPts!=NULL && pPts->GetCount()!=0;
513 return bRet;
516 ULONG SdrMarkView::GetMarkedGluePointCount() const
518 ForceUndirtyMrkPnt();
519 ULONG nAnz=0;
520 ULONG nMarkAnz=GetMarkedObjectCount();
521 for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) {
522 const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
523 const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
524 if (pPts!=NULL) nAnz+=pPts->GetCount();
526 return nAnz;
529 BOOL SdrMarkView::MarkGluePoints(const Rectangle* pRect, BOOL bUnmark)
531 if (!IsGluePointEditMode() && !bUnmark) return FALSE;
532 ForceUndirtyMrkPnt();
533 BOOL bChgd=FALSE;
534 SortMarkedObjects();
535 ULONG nMarkAnz=GetMarkedObjectCount();
536 for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) {
537 SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
538 const SdrObject* pObj=pM->GetMarkedSdrObj();
539 const SdrGluePointList* pGPL=pObj->GetGluePointList();
540 SdrUShortCont* pPts=pM->GetMarkedGluePoints();
541 if (bUnmark && pRect==NULL) { // UnmarkAll
542 if (pPts!=NULL && pPts->GetCount()!=0) {
543 pPts->Clear();
544 bChgd=TRUE;
546 } else {
547 if (pGPL!=NULL && (pPts!=NULL || !bUnmark)) {
548 USHORT nGPAnz=pGPL->GetCount();
549 for (USHORT nGPNum=0; nGPNum<nGPAnz; nGPNum++) {
550 const SdrGluePoint& rGP=(*pGPL)[nGPNum];
552 // #i38892#
553 if(rGP.IsUserDefined())
555 Point aPos(rGP.GetAbsolutePos(*pObj));
556 if (pRect==NULL || pRect->IsInside(aPos)) {
557 if (pPts==NULL) pPts=pM->ForceMarkedGluePoints();
558 else pPts->ForceSort();
559 ULONG nPos=pPts->GetPos(rGP.GetId());
560 if (!bUnmark && nPos==CONTAINER_ENTRY_NOTFOUND) {
561 bChgd=TRUE;
562 pPts->Insert(rGP.GetId());
564 if (bUnmark && nPos!=CONTAINER_ENTRY_NOTFOUND) {
565 bChgd=TRUE;
566 pPts->Remove(nPos);
574 if (bChgd) {
575 AdjustMarkHdl();
576 MarkListHasChanged();
578 return bChgd;
581 BOOL SdrMarkView::PickGluePoint(const Point& rPnt, SdrObject*& rpObj, USHORT& rnId, SdrPageView*& rpPV, ULONG nOptions) const
583 SdrObject* pObj0=rpObj;
584 //SdrPageView* pPV0=rpPV;
585 USHORT nId0=rnId;
586 rpObj=NULL; rpPV=NULL; rnId=0;
587 if (!IsGluePointEditMode()) return FALSE;
588 BOOL bBack=(nOptions & SDRSEARCH_BACKWARD) !=0;
589 BOOL bNext=(nOptions & SDRSEARCH_NEXT) !=0;
590 OutputDevice* pOut=(OutputDevice*)pActualOutDev;
591 if (pOut==NULL) pOut=GetFirstOutputDevice(); //GetWin(0);
592 if (pOut==NULL) return FALSE;
593 SortMarkedObjects();
594 ULONG nMarkAnz=GetMarkedObjectCount();
595 ULONG nMarkNum=bBack ? 0 : nMarkAnz;
596 if (bNext) {
597 nMarkNum=((SdrMarkView*)this)->TryToFindMarkedObject(pObj0);
598 if (nMarkNum==CONTAINER_ENTRY_NOTFOUND) return FALSE;
599 if (!bBack) nMarkNum++;
601 while (bBack ? nMarkNum<nMarkAnz : nMarkNum>0) {
602 if (!bBack) nMarkNum--;
603 const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
604 SdrObject* pObj=pM->GetMarkedSdrObj();
605 SdrPageView* pPV=pM->GetPageView();
606 const SdrGluePointList* pGPL=pObj->GetGluePointList();
607 if (pGPL!=NULL) {
608 USHORT nNum=pGPL->HitTest(rPnt,*pOut,pObj,bBack,bNext,nId0);
609 if (nNum!=SDRGLUEPOINT_NOTFOUND)
611 // #i38892#
612 const SdrGluePoint& rCandidate = (*pGPL)[nNum];
614 if(rCandidate.IsUserDefined())
616 rpObj=pObj;
617 rnId=(*pGPL)[nNum].GetId();
618 rpPV=pPV;
619 return TRUE;
623 bNext=FALSE; // HitNextGluePoint nur beim ersten Obj
624 if (bBack) nMarkNum++;
626 return FALSE;
629 BOOL SdrMarkView::MarkGluePoint(const SdrObject* pObj, USHORT nId, const SdrPageView* /*pPV*/, BOOL bUnmark)
631 if (!IsGluePointEditMode()) return FALSE;
632 ForceUndirtyMrkPnt();
633 BOOL bChgd=FALSE;
634 if (pObj!=NULL) {
635 ULONG nMarkPos=TryToFindMarkedObject(pObj);
636 if (nMarkPos!=CONTAINER_ENTRY_NOTFOUND) {
637 SdrMark* pM=GetSdrMarkByIndex(nMarkPos);
638 SdrUShortCont* pPts=bUnmark ? pM->GetMarkedGluePoints() : pM->ForceMarkedGluePoints();
639 if (pPts!=NULL) {
640 ULONG nPointPos=pPts->GetPos(nId);
641 if (!bUnmark && nPointPos==CONTAINER_ENTRY_NOTFOUND) {
642 bChgd=TRUE;
643 pPts->Insert(nId);
645 if (bUnmark && nPointPos!=CONTAINER_ENTRY_NOTFOUND) {
646 bChgd=TRUE;
647 pPts->Remove(nPointPos);
650 } else {
651 // Objekt implizit markieren ...
652 // ... fehlende Implementation
655 if (bChgd) {
656 AdjustMarkHdl();
657 MarkListHasChanged();
659 return bChgd;
662 BOOL SdrMarkView::IsGluePointMarked(const SdrObject* pObj, USHORT nId) const
664 ForceUndirtyMrkPnt();
665 BOOL bRet=FALSE;
666 ULONG nPos=((SdrMarkView*)this)->TryToFindMarkedObject(pObj); // casting auf NonConst
667 if (nPos!=CONTAINER_ENTRY_NOTFOUND) {
668 const SdrMark* pM=GetSdrMarkByIndex(nPos);
669 const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
670 if (pPts!=NULL) {
671 bRet=pPts->Exist(nId);
674 return bRet;
677 BOOL SdrMarkView::UnmarkGluePoint(const SdrHdl& rHdl)
679 if (&rHdl!=NULL && rHdl.GetKind()==HDL_GLUE && rHdl.GetObj()!=NULL) {
680 return MarkGluePoint(rHdl.GetObj(),(sal_uInt16)rHdl.GetObjHdlNum(),rHdl.GetPageView(),TRUE);
681 } else return FALSE;
684 SdrHdl* SdrMarkView::GetGluePointHdl(const SdrObject* pObj, USHORT nId) const
686 ForceUndirtyMrkPnt();
687 ULONG nHdlAnz=aHdl.GetHdlCount();
688 for (ULONG nHdlNum=0; nHdlNum<nHdlAnz; nHdlNum++) {
689 SdrHdl* pHdl=aHdl.GetHdl(nHdlNum);
690 if (pHdl->GetObj()==pObj &&
691 pHdl->GetKind()==HDL_GLUE &&
692 pHdl->GetObjHdlNum()==nId ) return pHdl;
694 return NULL;
697 BOOL SdrMarkView::MarkNextGluePoint(BOOL /*bPrev*/)
699 ForceUndirtyMrkPnt();
700 BOOL bChgd=FALSE;
701 SortMarkedObjects();
702 // ...
703 if (bChgd) {
704 MarkListHasChanged();
706 return bChgd;
709 BOOL SdrMarkView::MarkNextGluePoint(const Point& /*rPnt*/, BOOL /*bPrev*/)
711 ForceUndirtyMrkPnt();
712 BOOL bChgd=FALSE;
713 SortMarkedObjects();
714 // ...
715 if (bChgd) {
716 MarkListHasChanged();
718 return bChgd;
721 const Rectangle& SdrMarkView::GetMarkedGluePointsRect() const
723 ForceUndirtyMrkPnt();
724 if (bMarkedPointsRectsDirty) ImpSetPointsRects();
725 return aMarkedGluePointsRect;