merge the formfield patch from ooo-build
[ooovba.git] / svx / source / svdraw / svdsnpv.cxx
blob4f051f8ecbe107276d98f4668b4477d4ad2f7694
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: svdsnpv.cxx,v $
10 * $Revision: 1.14 $
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/svdsnpv.hxx>
35 #include <math.h>
37 #include <svx/svdetc.hxx>
38 #include <svx/svdobj.hxx>
39 #include <svx/svdpagv.hxx>
40 #include <svx/svdpage.hxx>
41 #include "svditer.hxx"
42 #include <svx/sdr/overlay/overlayobjectlist.hxx>
43 #include <svx/sdr/overlay/overlaycrosshair.hxx>
44 #include <svx/sdr/overlay/overlayhelpline.hxx>
45 #include <svx/sdr/overlay/overlaymanager.hxx>
46 #include <basegfx/matrix/b2dhommatrix.hxx>
47 #include <sdrpaintwindow.hxx>
49 ////////////////////////////////////////////////////////////////////////////////////////////////////
50 // #114409#-1 Migrate PageOrigin
51 class ImplPageOriginOverlay
53 // The OverlayObjects
54 ::sdr::overlay::OverlayObjectList maObjects;
56 // The current position in logical coodinates
57 basegfx::B2DPoint maPosition;
59 public:
60 ImplPageOriginOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos);
61 ~ImplPageOriginOverlay();
63 void SetPosition(const basegfx::B2DPoint& rNewPosition);
66 ImplPageOriginOverlay::ImplPageOriginOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos)
67 : maPosition(rStartPos)
69 for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
71 SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
72 ::sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager();
74 if(pTargetOverlay)
76 ::sdr::overlay::OverlayCrosshairStriped* aNew = new ::sdr::overlay::OverlayCrosshairStriped(
77 maPosition);
78 pTargetOverlay->add(*aNew);
79 maObjects.append(*aNew);
84 ImplPageOriginOverlay::~ImplPageOriginOverlay()
86 // The OverlayObjects are cleared using the destructor of OverlayObjectList.
87 // That destructor calls clear() at the list which removes all objects from the
88 // OverlayManager and deletes them.
91 void ImplPageOriginOverlay::SetPosition(const basegfx::B2DPoint& rNewPosition)
93 if(rNewPosition != maPosition)
95 // apply to OverlayObjects
96 for(sal_uInt32 a(0); a < maObjects.count(); a++)
98 sdr::overlay::OverlayCrosshairStriped* pCandidate =
99 static_cast< sdr::overlay::OverlayCrosshairStriped* >(&maObjects.getOverlayObject(a));
101 if(pCandidate)
103 pCandidate->setBasePosition(rNewPosition);
107 // remember new position
108 maPosition = rNewPosition;
112 ////////////////////////////////////////////////////////////////////////////////////////////////////
113 // #114409#-2 Migrate HelpLine
114 class ImplHelpLineOverlay
116 // The OverlayObjects
117 ::sdr::overlay::OverlayObjectList maObjects;
119 // The current position in logical coodinates
120 basegfx::B2DPoint maPosition;
122 // HelpLine specific stuff
123 SdrPageView* mpPageView;
124 sal_uInt16 mnHelpLineNumber;
125 SdrHelpLineKind meHelpLineKind;
127 public:
128 ImplHelpLineOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos,
129 SdrPageView* pPageView, sal_uInt16 nHelpLineNumber, SdrHelpLineKind eKind);
130 ~ImplHelpLineOverlay();
132 void SetPosition(const basegfx::B2DPoint& rNewPosition);
134 // access to HelpLine specific stuff
135 SdrPageView* GetPageView() const { return mpPageView; }
136 sal_uInt16 GetHelpLineNumber() const { return mnHelpLineNumber; }
137 SdrHelpLineKind GetHelpLineKind() const { return meHelpLineKind; }
140 ImplHelpLineOverlay::ImplHelpLineOverlay(
141 const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos,
142 SdrPageView* pPageView, sal_uInt16 nHelpLineNumber, SdrHelpLineKind eKind)
143 : maPosition(rStartPos),
144 mpPageView(pPageView),
145 mnHelpLineNumber(nHelpLineNumber),
146 meHelpLineKind(eKind)
148 for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
150 SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
151 ::sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager();
153 if(pTargetOverlay)
155 ::sdr::overlay::OverlayHelplineStriped* aNew = new ::sdr::overlay::OverlayHelplineStriped(
156 maPosition, meHelpLineKind);
157 pTargetOverlay->add(*aNew);
158 maObjects.append(*aNew);
163 ImplHelpLineOverlay::~ImplHelpLineOverlay()
165 // The OverlayObjects are cleared using the destructor of OverlayObjectList.
166 // That destructor calls clear() at the list which removes all objects from the
167 // OverlayManager and deletes them.
170 void ImplHelpLineOverlay::SetPosition(const basegfx::B2DPoint& rNewPosition)
172 if(rNewPosition != maPosition)
174 // apply to OverlayObjects
175 // apply to OverlayObjects
176 for(sal_uInt32 a(0); a < maObjects.count(); a++)
178 sdr::overlay::OverlayHelplineStriped* pCandidate =
179 static_cast< sdr::overlay::OverlayHelplineStriped* >(&maObjects.getOverlayObject(a));
181 if(pCandidate)
183 pCandidate->setBasePosition(rNewPosition);
187 // remember new position
188 maPosition = rNewPosition;
192 ////////////////////////////////////////////////////////////////////////////////////////////////////
193 ////////////////////////////////////////////////////////////////////////////////////////////////////
195 // @@@@ @@ @@ @@@@ @@@@@ @@ @@ @@ @@@@@ @@ @@
196 // @@ @@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
197 // @@ @@@@@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@
198 // @@@@ @@@@@@ @@@@@@ @@@@@ @@@@@ @@ @@@@ @@@@@@@
199 // @@ @@ @@@ @@ @@ @@ @@@ @@ @@ @@@@@@@
200 // @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@@ @@@
201 // @@@@ @@ @@ @@ @@ @@ @ @@ @@@@@ @@ @@
203 ////////////////////////////////////////////////////////////////////////////////////////////////////
204 ////////////////////////////////////////////////////////////////////////////////////////////////////
206 void SdrSnapView::ClearVars()
208 nMagnSizPix=4;
209 bSnapEnab=TRUE;
210 bGridSnap=TRUE;
211 bSnapTo1Pix=TRUE;
212 bBordSnap=TRUE;
213 bHlplSnap=TRUE;
214 bOFrmSnap=TRUE;
215 bOPntSnap=FALSE;
216 bOConSnap=TRUE;
217 bMoveMFrmSnap=TRUE;
218 bMoveOFrmSnap=TRUE;
219 bMoveOPntSnap=TRUE;
220 bMoveOConSnap=TRUE;
221 bMoveSnapOnlyTopLeft=FALSE;
222 bOrtho=FALSE;
223 bBigOrtho=TRUE;
224 nSnapAngle=1500;
225 bAngleSnapEnab=FALSE;
226 bMoveOnlyDragging=FALSE;
227 bSlantButShear=FALSE;
228 bCrookNoContortion=FALSE;
229 eCrookMode=SDRCROOK_ROTATE;
230 bHlplFixed=FALSE;
231 bEliminatePolyPoints=FALSE;
232 nEliminatePolyPointLimitAngle=0;
234 // #114409#-1 Migrate PageOrigin
235 BrkSetPageOrg();
237 // #114409#-2 Migrate HelpLine
238 BrkDragHelpLine();
241 SdrSnapView::SdrSnapView(SdrModel* pModel1, OutputDevice* pOut):
242 SdrPaintView(pModel1,pOut),
243 // #114409#-1 Migrate PageOrigin
244 mpPageOriginOverlay(0L),
245 // #114409#-2 Migrate HelpLine
246 mpHelpLineOverlay(0L)
248 ClearVars();
251 // #114409#-1 Migrate PageOrigin
252 SdrSnapView::~SdrSnapView()
254 // #114409#-1 Migrate PageOrigin
255 BrkSetPageOrg();
257 // #114409#-2 Migrate HelpLine
258 BrkDragHelpLine();
261 ////////////////////////////////////////////////////////////////////////////////////////////////////
263 BOOL SdrSnapView::IsAction() const
265 return IsSetPageOrg() || IsDragHelpLine() || SdrPaintView::IsAction();
268 void SdrSnapView::MovAction(const Point& rPnt)
270 SdrPaintView::MovAction(rPnt);
271 if (IsSetPageOrg()) {
272 MovSetPageOrg(rPnt);
274 if (IsDragHelpLine()) {
275 MovDragHelpLine(rPnt);
279 void SdrSnapView::EndAction()
281 if (IsSetPageOrg()) {
282 EndSetPageOrg();
284 if (IsDragHelpLine()) {
285 EndDragHelpLine();
287 SdrPaintView::EndAction();
290 void SdrSnapView::BckAction()
292 BrkSetPageOrg();
293 BrkDragHelpLine();
294 SdrPaintView::BckAction();
297 void SdrSnapView::BrkAction()
299 BrkSetPageOrg();
300 BrkDragHelpLine();
301 SdrPaintView::BrkAction();
304 void SdrSnapView::TakeActionRect(Rectangle& rRect) const
306 if (IsSetPageOrg() || IsDragHelpLine()) {
307 rRect=Rectangle(aDragStat.GetNow(),aDragStat.GetNow());
308 } else {
309 SdrPaintView::TakeActionRect(rRect);
313 ////////////////////////////////////////////////////////////////////////////////////////////////////
315 Point SdrSnapView::GetSnapPos(const Point& rPnt, const SdrPageView* pPV) const
317 Point aPt(rPnt);
318 SnapPos(aPt,pPV);
319 return aPt;
322 #define NOT_SNAPPED 0x7FFFFFFF
323 USHORT SdrSnapView::SnapPos(Point& rPnt, const SdrPageView* pPV) const
325 if (!bSnapEnab) return SDRSNAP_NOTSNAPPED;
326 BOOL bPVOfs=FALSE;
327 long x=rPnt.X();
328 long y=rPnt.Y();
329 if (pPV==NULL) {
330 bPVOfs=TRUE;
331 pPV=GetSdrPageView();
332 if (pPV==NULL) return SDRSNAP_NOTSNAPPED;
335 long dx=NOT_SNAPPED;
336 long dy=NOT_SNAPPED;
337 long dx1,dy1;
338 long mx=aMagnSiz.Width();
339 long my=aMagnSiz.Height();
340 if (bHlplVisible && bHlplSnap && !IsDragHelpLine())
342 const SdrHelpLineList& rHLL=pPV->GetHelpLines();
343 USHORT nAnz=rHLL.GetCount();
344 for (USHORT i=nAnz; i>0;) {
345 i--;
346 const SdrHelpLine& rHL=rHLL[i];
347 const Point& rPos=rHL.GetPos();
348 switch (rHL.GetKind()) {
349 case SDRHELPLINE_VERTICAL: {
350 long a=x-rPos.X();
351 if (Abs(a)<=mx) { dx1=-a; if (Abs(dx1)<Abs(dx)) dx=dx1; }
352 } break;
353 case SDRHELPLINE_HORIZONTAL: {
354 long b=y-rPos.Y();
355 if (Abs(b)<=my) { dy1=-b; if (Abs(dy1)<Abs(dy)) dy=dy1; }
356 } break;
357 case SDRHELPLINE_POINT: {
358 long a=x-rPos.X();
359 long b=y-rPos.Y();
360 if (Abs(a)<=mx && Abs(b)<=my) {
361 dx1=-a; dy1=-b;
362 if (Abs(dx1)<Abs(dx) && Abs(dy1)<Abs(dy)) { dx=dx1; dy=dy1; }
364 } break;
365 } // switch
368 if (bBordVisible && bBordSnap) {
369 SdrPage* pPage=pPV->GetPage();
370 long xs=pPage->GetWdt();
371 long ys=pPage->GetHgt();
372 long lft=pPage->GetLftBorder();
373 long rgt=pPage->GetRgtBorder();
374 long upp=pPage->GetUppBorder();
375 long lwr=pPage->GetLwrBorder();
376 long a;
377 a=x- lft ; if (Abs(a)<=mx) { dx1=-a; if (Abs(dx1)<Abs(dx)) dx=dx1; } // linker Rand
378 a=x-(xs-rgt); if (Abs(a)<=mx) { dx1=-a; if (Abs(dx1)<Abs(dx)) dx=dx1; } // rechter Rand
379 a=x ; if (Abs(a)<=mx) { dx1=-a; if (Abs(dx1)<Abs(dx)) dx=dx1; } // linke Papierkante
380 a=x- xs ; if (Abs(a)<=mx) { dx1=-a; if (Abs(dx1)<Abs(dx)) dx=dx1; } // rechte Papierkante
381 a=y- upp ; if (Abs(a)<=my) { dy1=-a; if (Abs(dy1)<Abs(dy)) dy=dy1; } // linker Rand
382 a=y-(ys-lwr); if (Abs(a)<=my) { dy1=-a; if (Abs(dy1)<Abs(dy)) dy=dy1; } // rechter Rand
383 a=y ; if (Abs(a)<=my) { dy1=-a; if (Abs(dy1)<Abs(dy)) dy=dy1; } // linke Papierkante
384 a=y- ys ; if (Abs(a)<=my) { dy1=-a; if (Abs(dy1)<Abs(dy)) dy=dy1; } // rechte Papierkante
386 if (bOFrmSnap || bOPntSnap /*|| (bConnVisible && bOConSnap)*/) {
387 ULONG nMaxPointSnapCount=200;
388 ULONG nMaxFrameSnapCount=200;
390 // #97981# go back to IM_DEEPNOGROUPS runthrough for snap to object comparisons
391 SdrObjListIter aIter(*pPV->GetPage(),/*IM_FLAT*/IM_DEEPNOGROUPS,TRUE);
393 while (aIter.IsMore() && (nMaxPointSnapCount>0 || nMaxFrameSnapCount>0)) {
394 SdrObject* pO=aIter.Next();
395 Rectangle aRect(pO->GetCurrentBoundRect());
396 aRect.Left ()-=mx;
397 aRect.Right ()+=mx;
398 aRect.Top ()-=my;
399 aRect.Bottom()+=my;
400 if (aRect.IsInside(rPnt)) {
401 if (bOPntSnap && nMaxPointSnapCount>0)
403 sal_uInt32 nAnz(pO->GetSnapPointCount());
404 for (sal_uInt32 i(0L); i < nAnz && nMaxPointSnapCount > 0L; i++)
406 Point aP(pO->GetSnapPoint(i));
407 dx1=x-aP.X();
408 dy1=y-aP.Y();
409 if (Abs(dx1)<=mx && Abs(dy1)<=my && Abs(dx1)<Abs(dx) && Abs(dy1)<Abs(dy)) {
410 dx=-dx1;
411 dy=-dy1;
413 nMaxPointSnapCount--;
416 if (bOFrmSnap && nMaxFrameSnapCount>0) {
417 Rectangle aLog(pO->GetSnapRect());
418 Rectangle aR1(aLog);
419 aR1.Left ()-=mx;
420 aR1.Right ()+=mx;
421 aR1.Top ()-=my;
422 aR1.Bottom()+=my;
423 if (aR1.IsInside(rPnt)) {
424 if (Abs(x-aLog.Left ())<=mx) { dx1=-(x-aLog.Left ()); if (Abs(dx1)<Abs(dx)) dx=dx1; }
425 if (Abs(x-aLog.Right ())<=mx) { dx1=-(x-aLog.Right ()); if (Abs(dx1)<Abs(dx)) dx=dx1; }
426 if (Abs(y-aLog.Top ())<=my) { dy1=-(y-aLog.Top ()); if (Abs(dy1)<Abs(dy)) dy=dy1; }
427 if (Abs(y-aLog.Bottom())<=my) { dy1=-(y-aLog.Bottom()); if (Abs(dy1)<Abs(dy)) dy=dy1; }
429 nMaxFrameSnapCount--;
434 if(bGridSnap)
436 double fSnapWidth = aSnapWdtX;
437 if(dx == NOT_SNAPPED && fSnapWidth != 0.0)
439 double fx = (double)x;
441 // round statt trunc
442 if(fx - (double)pPV->GetPageOrigin().X() >= 0.0)
443 fx += fSnapWidth / 2.0;
444 else
445 fx -= fSnapWidth / 2.0;
447 x = (long)((fx - (double)pPV->GetPageOrigin().X()) / fSnapWidth);
448 x = (long)((double)x * fSnapWidth + (double)pPV->GetPageOrigin().X());
449 dx = 0;
451 fSnapWidth = aSnapWdtY;
452 if(dy == NOT_SNAPPED && fSnapWidth)
454 double fy = (double)y;
456 // round statt trunc
457 if(fy - (double)pPV->GetPageOrigin().Y() >= 0.0)
458 fy += fSnapWidth / 2.0;
459 else
460 fy -= fSnapWidth / 2.0;
462 y = (long)((fy - (double)pPV->GetPageOrigin().Y()) / fSnapWidth);
463 y = (long)((double)y * fSnapWidth + (double)pPV->GetPageOrigin().Y());
464 dy = 0;
467 BOOL bRet=SDRSNAP_NOTSNAPPED;
468 if (dx==NOT_SNAPPED) dx=0; else bRet|=SDRSNAP_XSNAPPED;
469 if (dy==NOT_SNAPPED) dy=0; else bRet|=SDRSNAP_YSNAPPED;
470 rPnt.X()=x+dx;
471 rPnt.Y()=y+dy;
472 return bRet;
475 void SdrSnapView::CheckSnap(const Point& rPt, const SdrPageView* pPV, long& nBestXSnap, long& nBestYSnap, bool& bXSnapped, bool& bYSnapped) const
477 Point aPt(rPt);
478 USHORT nRet=SnapPos(aPt,pPV);
479 aPt-=rPt;
480 if ((nRet & SDRSNAP_XSNAPPED) !=0) {
481 if (bXSnapped) {
482 if (Abs(aPt.X())<Abs(nBestXSnap)) {
483 nBestXSnap=aPt.X();
485 } else {
486 nBestXSnap=aPt.X();
487 bXSnapped=TRUE;
490 if ((nRet & SDRSNAP_YSNAPPED) !=0) {
491 if (bYSnapped) {
492 if (Abs(aPt.Y())<Abs(nBestYSnap)) {
493 nBestYSnap=aPt.Y();
495 } else {
496 nBestYSnap=aPt.Y();
497 bYSnapped=TRUE;
502 USHORT SdrSnapView::SnapRect(const Rectangle& rRect, const SdrPageView* pPV, long& rDX, long& rDY) const
504 long nBestXSnap=0;
505 long nBestYSnap=0;
506 bool bXSnapped=FALSE;
507 bool bYSnapped=FALSE;
508 CheckSnap(rRect.TopLeft() ,pPV,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped);
509 if (!bMoveSnapOnlyTopLeft) {
510 CheckSnap(rRect.TopRight() ,pPV,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped);
511 CheckSnap(rRect.BottomLeft() ,pPV,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped);
512 CheckSnap(rRect.BottomRight(),pPV,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped);
514 rDX=nBestXSnap;
515 rDY=nBestYSnap;
516 USHORT nRet=0;
517 if (bXSnapped) nRet+=SDRSNAP_XSNAPPED;
518 if (bYSnapped) nRet+=SDRSNAP_YSNAPPED;
519 return nRet;
522 ////////////////////////////////////////////////////////////////////////////////////////////////////
524 sal_Bool SdrSnapView::BegSetPageOrg(const Point& rPnt)
526 BrkAction();
528 DBG_ASSERT(0L == mpPageOriginOverlay, "SdrSnapView::BegSetPageOrg: There exists a ImplPageOriginOverlay (!)");
529 basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
530 mpPageOriginOverlay = new ImplPageOriginOverlay(*this, aStartPos);
531 aDragStat.Reset(GetSnapPos(rPnt,NULL));
533 return sal_True;
536 void SdrSnapView::MovSetPageOrg(const Point& rPnt)
538 if(IsSetPageOrg())
540 aDragStat.NextMove(GetSnapPos(rPnt,NULL));
541 DBG_ASSERT(mpPageOriginOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
542 basegfx::B2DPoint aNewPos(aDragStat.GetNow().X(), aDragStat.GetNow().Y());
543 mpPageOriginOverlay->SetPosition(aNewPos);
547 sal_Bool SdrSnapView::EndSetPageOrg()
549 sal_Bool bRet(sal_False);
551 if(IsSetPageOrg())
553 SdrPageView* pPV = GetSdrPageView();
555 if(pPV)
557 Point aPnt(aDragStat.GetNow());
558 pPV->SetPageOrigin(aPnt);
559 bRet = sal_True;
562 // cleanup
563 BrkSetPageOrg();
566 return bRet;
569 void SdrSnapView::BrkSetPageOrg()
571 if(IsSetPageOrg())
573 DBG_ASSERT(mpPageOriginOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
574 delete mpPageOriginOverlay;
575 mpPageOriginOverlay = 0L;
579 ////////////////////////////////////////////////////////////////////////////////////////////////////
581 sal_Bool SdrSnapView::PickHelpLine(const Point& rPnt, short nTol, const OutputDevice& rOut, USHORT& rnHelpLineNum, SdrPageView*& rpPV) const
583 rpPV=NULL;
584 nTol=ImpGetHitTolLogic(nTol,&rOut);
585 SdrPageView* pPV = GetSdrPageView();
587 if(pPV)
589 Point aPnt(rPnt);
590 USHORT nIndex=pPV->GetHelpLines().HitTest(aPnt,USHORT(nTol),rOut);
591 if (nIndex!=SDRHELPLINE_NOTFOUND) {
592 rpPV=pPV;
593 rnHelpLineNum=nIndex;
594 return sal_True;
597 return sal_False;
600 // start HelpLine drag for new HelpLine
601 sal_Bool SdrSnapView::BegDragHelpLine(USHORT nHelpLineNum, SdrPageView* pPV)
603 sal_Bool bRet(sal_False);
605 if(!bHlplFixed)
607 BrkAction();
609 if(pPV && nHelpLineNum < pPV->GetHelpLines().GetCount())
611 const SdrHelpLineList& rHelpLines = pPV->GetHelpLines();
612 const SdrHelpLine& rHelpLine = rHelpLines[nHelpLineNum];
613 Point aHelpLinePos = rHelpLine.GetPos(); // + pPV->GetOffset();
614 basegfx::B2DPoint aStartPos(aHelpLinePos.X(), aHelpLinePos.Y());
616 DBG_ASSERT(0L == mpHelpLineOverlay, "SdrSnapView::BegDragHelpLine: There exists a ImplHelpLineOverlay (!)");
617 mpHelpLineOverlay = new ImplHelpLineOverlay(*this, aStartPos, pPV, nHelpLineNum, rHelpLine.GetKind());
619 aDragStat.Reset(GetSnapPos(aHelpLinePos, pPV));
620 aDragStat.SetMinMove(ImpGetMinMovLogic(-3, 0L));
622 bRet = sal_True;
626 return bRet;
629 // start HelpLine drag with existing HelpLine
630 sal_Bool SdrSnapView::BegDragHelpLine(const Point& rPnt, SdrHelpLineKind eNewKind)
632 sal_Bool bRet(sal_False);
634 BrkAction();
636 if(GetSdrPageView())
638 DBG_ASSERT(0L == mpHelpLineOverlay, "SdrSnapView::BegDragHelpLine: There exists a ImplHelpLineOverlay (!)");
639 basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
640 mpHelpLineOverlay = new ImplHelpLineOverlay(*this, aStartPos, 0L, 0, eNewKind);
641 aDragStat.Reset(GetSnapPos(rPnt, 0L));
642 bRet = sal_True;
645 return bRet;
648 Pointer SdrSnapView::GetDraggedHelpLinePointer() const
650 if(IsDragHelpLine())
652 switch(mpHelpLineOverlay->GetHelpLineKind())
654 case SDRHELPLINE_VERTICAL : return Pointer(POINTER_ESIZE);
655 case SDRHELPLINE_HORIZONTAL: return Pointer(POINTER_SSIZE);
656 default : return Pointer(POINTER_MOVE);
660 return Pointer(POINTER_MOVE);
663 void SdrSnapView::MovDragHelpLine(const Point& rPnt)
665 if(IsDragHelpLine() && aDragStat.CheckMinMoved(rPnt))
667 Point aPnt(GetSnapPos(rPnt, 0L));
669 if(aPnt != aDragStat.GetNow())
671 aDragStat.NextMove(aPnt);
672 DBG_ASSERT(mpHelpLineOverlay, "SdrSnapView::MovDragHelpLine: no ImplHelpLineOverlay (!)");
673 basegfx::B2DPoint aNewPos(aDragStat.GetNow().X(), aDragStat.GetNow().Y());
674 mpHelpLineOverlay->SetPosition(aNewPos);
679 sal_Bool SdrSnapView::EndDragHelpLine()
681 sal_Bool bRet(sal_False);
683 if(IsDragHelpLine())
685 if(aDragStat.IsMinMoved())
687 SdrPageView* pPageView = mpHelpLineOverlay->GetPageView();
689 if(pPageView)
691 // moved existing one
692 Point aPnt(aDragStat.GetNow());
693 const SdrHelpLineList& rHelpLines = pPageView->GetHelpLines();
694 SdrHelpLine aChangedHelpLine = rHelpLines[mpHelpLineOverlay->GetHelpLineNumber()];
695 aChangedHelpLine.SetPos(aPnt);
696 pPageView->SetHelpLine(mpHelpLineOverlay->GetHelpLineNumber(), aChangedHelpLine);
698 bRet = sal_True;
700 else
702 // create new one
703 pPageView = GetSdrPageView();
705 if(pPageView)
707 Point aPnt(aDragStat.GetNow());
708 SdrHelpLine aNewHelpLine(mpHelpLineOverlay->GetHelpLineKind(), aPnt);
709 pPageView->InsertHelpLine(aNewHelpLine);
711 bRet = sal_True;
716 // cleanup
717 BrkDragHelpLine();
720 return bRet;
723 void SdrSnapView::BrkDragHelpLine()
725 if(IsDragHelpLine())
727 DBG_ASSERT(mpHelpLineOverlay, "SdrSnapView::EndDragHelpLine: no ImplHelpLineOverlay (!)");
728 delete mpHelpLineOverlay;
729 mpHelpLineOverlay = 0L;
733 // eof