LCOV - code coverage report
Current view: top level - svx/source/svdraw - svdsnpv.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 50 344 14.5 %
Date: 2014-04-11 Functions: 7 33 21.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <svx/svdsnpv.hxx>
      22             : #include <math.h>
      23             : 
      24             : #include <svx/svdetc.hxx>
      25             : #include <svx/svdobj.hxx>
      26             : #include <svx/svdpagv.hxx>
      27             : #include <svx/svdpage.hxx>
      28             : #include "svx/svditer.hxx"
      29             : #include <svx/sdr/overlay/overlayobjectlist.hxx>
      30             : #include <svx/sdr/overlay/overlaycrosshair.hxx>
      31             : #include <svx/sdr/overlay/overlayhelpline.hxx>
      32             : #include <svx/sdr/overlay/overlaymanager.hxx>
      33             : #include <basegfx/matrix/b2dhommatrix.hxx>
      34             : #include <svx/sdrpaintwindow.hxx>
      35             : 
      36             : 
      37             : class ImplPageOriginOverlay
      38             : {
      39             :     // The OverlayObjects
      40             :     ::sdr::overlay::OverlayObjectList               maObjects;
      41             : 
      42             :     // The current position in logical coodinates
      43             :     basegfx::B2DPoint                               maPosition;
      44             : 
      45             : public:
      46             :     ImplPageOriginOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos);
      47             :     ~ImplPageOriginOverlay();
      48             : 
      49             :     void SetPosition(const basegfx::B2DPoint& rNewPosition);
      50             : };
      51             : 
      52           0 : ImplPageOriginOverlay::ImplPageOriginOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos)
      53           0 : :   maPosition(rStartPos)
      54             : {
      55           0 :     for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
      56             :     {
      57           0 :         SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
      58           0 :         rtl::Reference< ::sdr::overlay::OverlayManager > xTargetOverlay = pCandidate->GetOverlayManager();
      59             : 
      60           0 :         if (xTargetOverlay.is())
      61             :         {
      62             :             ::sdr::overlay::OverlayCrosshairStriped* aNew = new ::sdr::overlay::OverlayCrosshairStriped(
      63           0 :                 maPosition);
      64           0 :             xTargetOverlay->add(*aNew);
      65           0 :             maObjects.append(*aNew);
      66             :         }
      67           0 :     }
      68           0 : }
      69             : 
      70           0 : ImplPageOriginOverlay::~ImplPageOriginOverlay()
      71             : {
      72             :     // The OverlayObjects are cleared using the destructor of OverlayObjectList.
      73             :     // That destructor calls clear() at the list which removes all objects from the
      74             :     // OverlayManager and deletes them.
      75           0 : }
      76             : 
      77           0 : void ImplPageOriginOverlay::SetPosition(const basegfx::B2DPoint& rNewPosition)
      78             : {
      79           0 :     if(rNewPosition != maPosition)
      80             :     {
      81             :         // apply to OverlayObjects
      82           0 :         for(sal_uInt32 a(0); a < maObjects.count(); a++)
      83             :         {
      84             :             sdr::overlay::OverlayCrosshairStriped* pCandidate =
      85           0 :                 static_cast< sdr::overlay::OverlayCrosshairStriped* >(&maObjects.getOverlayObject(a));
      86             : 
      87           0 :             if(pCandidate)
      88             :             {
      89           0 :                 pCandidate->setBasePosition(rNewPosition);
      90             :             }
      91             :         }
      92             : 
      93             :         // remember new position
      94           0 :         maPosition = rNewPosition;
      95             :     }
      96           0 : }
      97             : 
      98             : 
      99             : class ImplHelpLineOverlay
     100             : {
     101             :     // The OverlayObjects
     102             :     ::sdr::overlay::OverlayObjectList               maObjects;
     103             : 
     104             :     // The current position in logical coodinates
     105             :     basegfx::B2DPoint                               maPosition;
     106             : 
     107             :     // HelpLine specific stuff
     108             :     SdrPageView*                                    mpPageView;
     109             :     sal_uInt16                                      mnHelpLineNumber;
     110             :     SdrHelpLineKind                                 meHelpLineKind;
     111             : 
     112             : public:
     113             :     ImplHelpLineOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos,
     114             :         SdrPageView* pPageView, sal_uInt16 nHelpLineNumber, SdrHelpLineKind eKind);
     115             :     ~ImplHelpLineOverlay();
     116             : 
     117             :     void SetPosition(const basegfx::B2DPoint& rNewPosition);
     118             : 
     119             :     // access to HelpLine specific stuff
     120           0 :     SdrPageView* GetPageView() const { return mpPageView; }
     121           0 :     sal_uInt16 GetHelpLineNumber() const { return mnHelpLineNumber; }
     122           0 :     SdrHelpLineKind GetHelpLineKind() const { return meHelpLineKind; }
     123             : };
     124             : 
     125           0 : ImplHelpLineOverlay::ImplHelpLineOverlay(
     126             :     const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos,
     127             :     SdrPageView* pPageView, sal_uInt16 nHelpLineNumber, SdrHelpLineKind eKind)
     128             : :   maPosition(rStartPos),
     129             :     mpPageView(pPageView),
     130             :     mnHelpLineNumber(nHelpLineNumber),
     131           0 :     meHelpLineKind(eKind)
     132             : {
     133           0 :     for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
     134             :     {
     135           0 :         SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
     136           0 :         rtl::Reference< ::sdr::overlay::OverlayManager > xTargetOverlay = pCandidate->GetOverlayManager();
     137             : 
     138           0 :         if (xTargetOverlay.is())
     139             :         {
     140             :             ::sdr::overlay::OverlayHelplineStriped* aNew = new ::sdr::overlay::OverlayHelplineStriped(
     141           0 :                 maPosition, meHelpLineKind);
     142           0 :             xTargetOverlay->add(*aNew);
     143           0 :             maObjects.append(*aNew);
     144             :         }
     145           0 :     }
     146           0 : }
     147             : 
     148           0 : ImplHelpLineOverlay::~ImplHelpLineOverlay()
     149             : {
     150             :     // The OverlayObjects are cleared using the destructor of OverlayObjectList.
     151             :     // That destructor calls clear() at the list which removes all objects from the
     152             :     // OverlayManager and deletes them.
     153           0 : }
     154             : 
     155           0 : void ImplHelpLineOverlay::SetPosition(const basegfx::B2DPoint& rNewPosition)
     156             : {
     157           0 :     if(rNewPosition != maPosition)
     158             :     {
     159             :         // apply to OverlayObjects
     160           0 :         for(sal_uInt32 a(0); a < maObjects.count(); a++)
     161             :         {
     162             :             sdr::overlay::OverlayHelplineStriped* pCandidate =
     163           0 :                 static_cast< sdr::overlay::OverlayHelplineStriped* >(&maObjects.getOverlayObject(a));
     164             : 
     165           0 :             if(pCandidate)
     166             :             {
     167           0 :                 pCandidate->setBasePosition(rNewPosition);
     168             :             }
     169             :         }
     170             : 
     171             :         // remember new position
     172           0 :         maPosition = rNewPosition;
     173             :     }
     174           0 : }
     175             : 
     176             : 
     177        5800 : void SdrSnapView::ClearVars()
     178             : {
     179        5800 :     nMagnSizPix=4;
     180        5800 :     bSnapEnab=true;
     181        5800 :     bGridSnap=true;
     182        5800 :     bSnapTo1Pix=true;
     183        5800 :     bBordSnap=true;
     184        5800 :     bHlplSnap=true;
     185        5800 :     bOFrmSnap=true;
     186        5800 :     bOPntSnap=false;
     187        5800 :     bOConSnap=true;
     188        5800 :     bMoveMFrmSnap=true;
     189        5800 :     bMoveOFrmSnap=true;
     190        5800 :     bMoveOPntSnap=true;
     191        5800 :     bMoveOConSnap=true;
     192        5800 :     bMoveSnapOnlyTopLeft=false;
     193        5800 :     bOrtho=false;
     194        5800 :     bBigOrtho=true;
     195        5800 :     nSnapAngle=1500;
     196        5800 :     bAngleSnapEnab=false;
     197        5800 :     bMoveOnlyDragging=false;
     198        5800 :     bSlantButShear=false;
     199        5800 :     bCrookNoContortion=false;
     200        5800 :     eCrookMode=SDRCROOK_ROTATE;
     201        5800 :     bHlplFixed=false;
     202        5800 :     bEliminatePolyPoints=false;
     203        5800 :     nEliminatePolyPointLimitAngle=0;
     204             : 
     205        5800 :     BrkSetPageOrg();
     206        5800 :     BrkDragHelpLine();
     207        5800 : }
     208             : 
     209        5800 : SdrSnapView::SdrSnapView(SdrModel* pModel1, OutputDevice* pOut):
     210             :     SdrPaintView(pModel1,pOut),
     211             :     mpPageOriginOverlay(0L),
     212        5800 :     mpHelpLineOverlay(0L)
     213             : {
     214        5800 :     ClearVars();
     215        5800 : }
     216             : 
     217       11170 : SdrSnapView::~SdrSnapView()
     218             : {
     219        5585 :     BrkSetPageOrg();
     220        5585 :     BrkDragHelpLine();
     221        5585 : }
     222             : 
     223             : 
     224             : 
     225        1337 : bool SdrSnapView::IsAction() const
     226             : {
     227        1337 :     return IsSetPageOrg() || IsDragHelpLine() || SdrPaintView::IsAction();
     228             : }
     229             : 
     230           0 : void SdrSnapView::MovAction(const Point& rPnt)
     231             : {
     232           0 :     SdrPaintView::MovAction(rPnt);
     233           0 :     if (IsSetPageOrg()) {
     234           0 :         MovSetPageOrg(rPnt);
     235             :     }
     236           0 :     if (IsDragHelpLine()) {
     237           0 :         MovDragHelpLine(rPnt);
     238             :     }
     239           0 : }
     240             : 
     241           0 : void SdrSnapView::EndAction()
     242             : {
     243           0 :     if (IsSetPageOrg()) {
     244           0 :         EndSetPageOrg();
     245             :     }
     246           0 :     if (IsDragHelpLine()) {
     247           0 :         EndDragHelpLine();
     248             :     }
     249           0 :     SdrPaintView::EndAction();
     250           0 : }
     251             : 
     252           0 : void SdrSnapView::BckAction()
     253             : {
     254           0 :     BrkSetPageOrg();
     255           0 :     BrkDragHelpLine();
     256           0 :     SdrPaintView::BckAction();
     257           0 : }
     258             : 
     259        3348 : void SdrSnapView::BrkAction()
     260             : {
     261        3348 :     BrkSetPageOrg();
     262        3348 :     BrkDragHelpLine();
     263        3348 :     SdrPaintView::BrkAction();
     264        3348 : }
     265             : 
     266           0 : void SdrSnapView::TakeActionRect(Rectangle& rRect) const
     267             : {
     268           0 :     if (IsSetPageOrg() || IsDragHelpLine()) {
     269           0 :         rRect=Rectangle(aDragStat.GetNow(),aDragStat.GetNow());
     270             :     } else {
     271           0 :         SdrPaintView::TakeActionRect(rRect);
     272             :     }
     273           0 : }
     274             : 
     275             : 
     276             : 
     277           0 : Point SdrSnapView::GetSnapPos(const Point& rPnt, const SdrPageView* pPV) const
     278             : {
     279           0 :     Point aPt(rPnt);
     280           0 :     SnapPos(aPt,pPV);
     281           0 :     return aPt;
     282             : }
     283             : 
     284             : #define NOT_SNAPPED 0x7FFFFFFF
     285           0 : sal_uInt16 SdrSnapView::SnapPos(Point& rPnt, const SdrPageView* pPV) const
     286             : {
     287           0 :     if (!bSnapEnab) return SDRSNAP_NOTSNAPPED;
     288           0 :     long x=rPnt.X();
     289           0 :     long y=rPnt.Y();
     290           0 :     if (pPV==NULL) {
     291           0 :         pPV=GetSdrPageView();
     292           0 :         if (pPV==NULL) return SDRSNAP_NOTSNAPPED;
     293             :     }
     294             : 
     295           0 :     long dx=NOT_SNAPPED;
     296           0 :     long dy=NOT_SNAPPED;
     297             :     long dx1,dy1;
     298           0 :     long mx=aMagnSiz.Width();
     299           0 :     long my=aMagnSiz.Height();
     300           0 :     if (bHlplVisible && bHlplSnap && !IsDragHelpLine())
     301             :     {
     302           0 :         const SdrHelpLineList& rHLL=pPV->GetHelpLines();
     303           0 :         sal_uInt16 nAnz=rHLL.GetCount();
     304           0 :         for (sal_uInt16 i=nAnz; i>0;) {
     305           0 :             i--;
     306           0 :             const SdrHelpLine& rHL=rHLL[i];
     307           0 :             const Point& rPos=rHL.GetPos();
     308           0 :             switch (rHL.GetKind()) {
     309             :                 case SDRHELPLINE_VERTICAL: {
     310           0 :                     long a=x-rPos.X();
     311           0 :                     if (std::abs(a)<=mx) { dx1=-a; if (std::abs(dx1)<std::abs(dx)) dx=dx1; }
     312           0 :                 } break;
     313             :                 case SDRHELPLINE_HORIZONTAL: {
     314           0 :                     long b=y-rPos.Y();
     315           0 :                     if (std::abs(b)<=my) { dy1=-b; if (std::abs(dy1)<std::abs(dy)) dy=dy1; }
     316           0 :                 } break;
     317             :                 case SDRHELPLINE_POINT: {
     318           0 :                     long a=x-rPos.X();
     319           0 :                     long b=y-rPos.Y();
     320           0 :                     if (std::abs(a)<=mx && std::abs(b)<=my) {
     321           0 :                         dx1=-a; dy1=-b;
     322           0 :                         if (std::abs(dx1)<std::abs(dx) && std::abs(dy1)<std::abs(dy)) { dx=dx1; dy=dy1; }
     323             :                     }
     324           0 :                 } break;
     325             :             } // switch
     326             :         }
     327             :     }
     328           0 :     if (bBordVisible && bBordSnap) {
     329           0 :         SdrPage* pPage=pPV->GetPage();
     330           0 :         long xs=pPage->GetWdt();
     331           0 :         long ys=pPage->GetHgt();
     332           0 :         long lft=pPage->GetLftBorder();
     333           0 :         long rgt=pPage->GetRgtBorder();
     334           0 :         long upp=pPage->GetUppBorder();
     335           0 :         long lwr=pPage->GetLwrBorder();
     336             :         long a;
     337           0 :         a=x- lft    ; if (std::abs(a)<=mx) { dx1=-a; if (std::abs(dx1)<std::abs(dx)) dx=dx1; } // left margin
     338           0 :         a=x-(xs-rgt); if (std::abs(a)<=mx) { dx1=-a; if (std::abs(dx1)<std::abs(dx)) dx=dx1; } // right margin
     339           0 :         a=x         ; if (std::abs(a)<=mx) { dx1=-a; if (std::abs(dx1)<std::abs(dx)) dx=dx1; } // left edge of paper
     340           0 :         a=x- xs     ; if (std::abs(a)<=mx) { dx1=-a; if (std::abs(dx1)<std::abs(dx)) dx=dx1; } // right edge of paper
     341           0 :         a=y- upp    ; if (std::abs(a)<=my) { dy1=-a; if (std::abs(dy1)<std::abs(dy)) dy=dy1; } // left margin
     342           0 :         a=y-(ys-lwr); if (std::abs(a)<=my) { dy1=-a; if (std::abs(dy1)<std::abs(dy)) dy=dy1; } // right margin
     343           0 :         a=y         ; if (std::abs(a)<=my) { dy1=-a; if (std::abs(dy1)<std::abs(dy)) dy=dy1; } // left edge of paper
     344           0 :         a=y- ys     ; if (std::abs(a)<=my) { dy1=-a; if (std::abs(dy1)<std::abs(dy)) dy=dy1; } // right edge of paper
     345             :     }
     346           0 :     if (bOFrmSnap || bOPntSnap) {
     347           0 :         sal_uIntPtr nMaxPointSnapCount=200;
     348           0 :         sal_uIntPtr nMaxFrameSnapCount=200;
     349             : 
     350             :         // go back to IM_DEEPNOGROUPS runthrough for snap to object comparisons
     351           0 :         SdrObjListIter aIter(*pPV->GetPage(),IM_DEEPNOGROUPS,true);
     352             : 
     353           0 :         while (aIter.IsMore() && (nMaxPointSnapCount>0 || nMaxFrameSnapCount>0)) {
     354           0 :             SdrObject* pO=aIter.Next();
     355           0 :             Rectangle aRect(pO->GetCurrentBoundRect());
     356           0 :             aRect.Left  ()-=mx;
     357           0 :             aRect.Right ()+=mx;
     358           0 :             aRect.Top   ()-=my;
     359           0 :             aRect.Bottom()+=my;
     360           0 :             if (aRect.IsInside(rPnt)) {
     361           0 :                 if (bOPntSnap && nMaxPointSnapCount>0)
     362             :                 {
     363           0 :                     sal_uInt32 nAnz(pO->GetSnapPointCount());
     364           0 :                     for (sal_uInt32 i(0L); i < nAnz && nMaxPointSnapCount > 0L; i++)
     365             :                     {
     366           0 :                         Point aP(pO->GetSnapPoint(i));
     367           0 :                         dx1=x-aP.X();
     368           0 :                         dy1=y-aP.Y();
     369           0 :                         if (std::abs(dx1)<=mx && std::abs(dy1)<=my && std::abs(dx1)<std::abs(dx) && std::abs(dy1)<std::abs(dy)) {
     370           0 :                             dx=-dx1;
     371           0 :                             dy=-dy1;
     372             :                         }
     373           0 :                         nMaxPointSnapCount--;
     374             :                     }
     375             :                 }
     376           0 :                 if (bOFrmSnap && nMaxFrameSnapCount>0) {
     377           0 :                     Rectangle aLog(pO->GetSnapRect());
     378           0 :                     Rectangle aR1(aLog);
     379           0 :                     aR1.Left  ()-=mx;
     380           0 :                     aR1.Right ()+=mx;
     381           0 :                     aR1.Top   ()-=my;
     382           0 :                     aR1.Bottom()+=my;
     383           0 :                     if (aR1.IsInside(rPnt)) {
     384           0 :                         if (std::abs(x-aLog.Left  ())<=mx) { dx1=-(x-aLog.Left  ()); if (std::abs(dx1)<std::abs(dx)) dx=dx1; }
     385           0 :                         if (std::abs(x-aLog.Right ())<=mx) { dx1=-(x-aLog.Right ()); if (std::abs(dx1)<std::abs(dx)) dx=dx1; }
     386           0 :                         if (std::abs(y-aLog.Top   ())<=my) { dy1=-(y-aLog.Top   ()); if (std::abs(dy1)<std::abs(dy)) dy=dy1; }
     387           0 :                         if (std::abs(y-aLog.Bottom())<=my) { dy1=-(y-aLog.Bottom()); if (std::abs(dy1)<std::abs(dy)) dy=dy1; }
     388             :                     }
     389           0 :                     nMaxFrameSnapCount--;
     390             :                 }
     391             :             }
     392           0 :         }
     393             :     }
     394           0 :     if(bGridSnap)
     395             :     {
     396           0 :         double fSnapWidth = aSnapWdtX;
     397           0 :         if(dx == NOT_SNAPPED && fSnapWidth != 0.0)
     398             :         {
     399           0 :             double fx = (double)x;
     400             : 
     401             :             // round instead of trunc
     402           0 :             if(fx - (double)pPV->GetPageOrigin().X() >= 0.0)
     403           0 :                 fx += fSnapWidth / 2.0;
     404             :             else
     405           0 :                 fx -= fSnapWidth / 2.0;
     406             : 
     407           0 :             x = (long)((fx - (double)pPV->GetPageOrigin().X()) / fSnapWidth);
     408           0 :             x = (long)((double)x * fSnapWidth + (double)pPV->GetPageOrigin().X());
     409           0 :             dx = 0;
     410             :         }
     411           0 :         fSnapWidth = aSnapWdtY;
     412           0 :         if(dy == NOT_SNAPPED && fSnapWidth)
     413             :         {
     414           0 :             double fy = (double)y;
     415             : 
     416             :             // round instead of trunc
     417           0 :             if(fy - (double)pPV->GetPageOrigin().Y() >= 0.0)
     418           0 :                 fy += fSnapWidth / 2.0;
     419             :             else
     420           0 :                 fy -= fSnapWidth / 2.0;
     421             : 
     422           0 :             y = (long)((fy - (double)pPV->GetPageOrigin().Y()) / fSnapWidth);
     423           0 :             y = (long)((double)y * fSnapWidth + (double)pPV->GetPageOrigin().Y());
     424           0 :             dy = 0;
     425             :         }
     426             :     }
     427           0 :     sal_uInt16 bRet=SDRSNAP_NOTSNAPPED;
     428           0 :     if (dx==NOT_SNAPPED) dx=0; else bRet|=SDRSNAP_XSNAPPED;
     429           0 :     if (dy==NOT_SNAPPED) dy=0; else bRet|=SDRSNAP_YSNAPPED;
     430           0 :     rPnt.X()=x+dx;
     431           0 :     rPnt.Y()=y+dy;
     432           0 :     return bRet;
     433             : }
     434             : 
     435           0 : void SdrSnapView::CheckSnap(const Point& rPt, const SdrPageView* pPV, long& nBestXSnap, long& nBestYSnap, bool& bXSnapped, bool& bYSnapped) const
     436             : {
     437           0 :     Point aPt(rPt);
     438           0 :     sal_uInt16 nRet=SnapPos(aPt,pPV);
     439           0 :     aPt-=rPt;
     440           0 :     if ((nRet & SDRSNAP_XSNAPPED) !=0) {
     441           0 :         if (bXSnapped) {
     442           0 :             if (std::abs(aPt.X())<std::abs(nBestXSnap)) {
     443           0 :                 nBestXSnap=aPt.X();
     444             :             }
     445             :         } else {
     446           0 :             nBestXSnap=aPt.X();
     447           0 :             bXSnapped=true;
     448             :         }
     449             :     }
     450           0 :     if ((nRet & SDRSNAP_YSNAPPED) !=0) {
     451           0 :         if (bYSnapped) {
     452           0 :             if (std::abs(aPt.Y())<std::abs(nBestYSnap)) {
     453           0 :                 nBestYSnap=aPt.Y();
     454             :             }
     455             :         } else {
     456           0 :             nBestYSnap=aPt.Y();
     457           0 :             bYSnapped=true;
     458             :         }
     459             :     }
     460           0 : }
     461             : 
     462             : 
     463             : 
     464           0 : bool SdrSnapView::BegSetPageOrg(const Point& rPnt)
     465             : {
     466           0 :     BrkAction();
     467             : 
     468             :     DBG_ASSERT(0L == mpPageOriginOverlay, "SdrSnapView::BegSetPageOrg: There exists a ImplPageOriginOverlay (!)");
     469           0 :     basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
     470           0 :     mpPageOriginOverlay = new ImplPageOriginOverlay(*this, aStartPos);
     471           0 :     aDragStat.Reset(GetSnapPos(rPnt,NULL));
     472             : 
     473           0 :     return true;
     474             : }
     475             : 
     476           0 : void SdrSnapView::MovSetPageOrg(const Point& rPnt)
     477             : {
     478           0 :     if(IsSetPageOrg())
     479             :     {
     480           0 :         aDragStat.NextMove(GetSnapPos(rPnt,NULL));
     481             :         DBG_ASSERT(mpPageOriginOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
     482           0 :         basegfx::B2DPoint aNewPos(aDragStat.GetNow().X(), aDragStat.GetNow().Y());
     483           0 :         mpPageOriginOverlay->SetPosition(aNewPos);
     484             :     }
     485           0 : }
     486             : 
     487           0 : bool SdrSnapView::EndSetPageOrg()
     488             : {
     489           0 :     bool bRet(false);
     490             : 
     491           0 :     if(IsSetPageOrg())
     492             :     {
     493           0 :         SdrPageView* pPV = GetSdrPageView();
     494             : 
     495           0 :         if(pPV)
     496             :         {
     497           0 :             Point aPnt(aDragStat.GetNow());
     498           0 :             pPV->SetPageOrigin(aPnt);
     499           0 :             bRet = true;
     500             :         }
     501             : 
     502             :         // cleanup
     503           0 :         BrkSetPageOrg();
     504             :     }
     505             : 
     506           0 :     return bRet;
     507             : }
     508             : 
     509       14733 : void SdrSnapView::BrkSetPageOrg()
     510             : {
     511       14733 :     if(IsSetPageOrg())
     512             :     {
     513             :         DBG_ASSERT(mpPageOriginOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
     514           0 :         delete mpPageOriginOverlay;
     515           0 :         mpPageOriginOverlay = 0L;
     516             :     }
     517       14733 : }
     518             : 
     519             : 
     520             : 
     521           0 : bool SdrSnapView::PickHelpLine(const Point& rPnt, short nTol, const OutputDevice& rOut, sal_uInt16& rnHelpLineNum, SdrPageView*& rpPV) const
     522             : {
     523           0 :     rpPV=NULL;
     524           0 :     nTol=ImpGetHitTolLogic(nTol,&rOut);
     525           0 :     SdrPageView* pPV = GetSdrPageView();
     526             : 
     527           0 :     if(pPV)
     528             :     {
     529           0 :         Point aPnt(rPnt);
     530           0 :         sal_uInt16 nIndex=pPV->GetHelpLines().HitTest(aPnt,sal_uInt16(nTol),rOut);
     531           0 :         if (nIndex!=SDRHELPLINE_NOTFOUND) {
     532           0 :             rpPV=pPV;
     533           0 :             rnHelpLineNum=nIndex;
     534           0 :             return true;
     535             :         }
     536             :     }
     537           0 :     return false;
     538             : }
     539             : 
     540             : // start HelpLine drag for new HelpLine
     541           0 : bool SdrSnapView::BegDragHelpLine(sal_uInt16 nHelpLineNum, SdrPageView* pPV)
     542             : {
     543           0 :     bool bRet(false);
     544             : 
     545           0 :     if(!bHlplFixed)
     546             :     {
     547           0 :         BrkAction();
     548             : 
     549           0 :         if(pPV && nHelpLineNum < pPV->GetHelpLines().GetCount())
     550             :         {
     551           0 :             const SdrHelpLineList& rHelpLines = pPV->GetHelpLines();
     552           0 :             const SdrHelpLine& rHelpLine = rHelpLines[nHelpLineNum];
     553           0 :             Point aHelpLinePos = rHelpLine.GetPos();
     554           0 :             basegfx::B2DPoint aStartPos(aHelpLinePos.X(), aHelpLinePos.Y());
     555             : 
     556             :             DBG_ASSERT(0L == mpHelpLineOverlay, "SdrSnapView::BegDragHelpLine: There exists a ImplHelpLineOverlay (!)");
     557           0 :             mpHelpLineOverlay = new ImplHelpLineOverlay(*this, aStartPos, pPV, nHelpLineNum, rHelpLine.GetKind());
     558             : 
     559           0 :             aDragStat.Reset(GetSnapPos(aHelpLinePos, pPV));
     560           0 :             aDragStat.SetMinMove(ImpGetMinMovLogic(-3, 0L));
     561             : 
     562           0 :             bRet = true;
     563             :         }
     564             :     }
     565             : 
     566           0 :     return bRet;
     567             : }
     568             : 
     569             : // start HelpLine drag with existing HelpLine
     570           0 : bool SdrSnapView::BegDragHelpLine(const Point& rPnt, SdrHelpLineKind eNewKind)
     571             : {
     572           0 :     bool bRet(false);
     573             : 
     574           0 :     BrkAction();
     575             : 
     576           0 :     if(GetSdrPageView())
     577             :     {
     578             :         DBG_ASSERT(0L == mpHelpLineOverlay, "SdrSnapView::BegDragHelpLine: There exists a ImplHelpLineOverlay (!)");
     579           0 :         basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
     580           0 :         mpHelpLineOverlay = new ImplHelpLineOverlay(*this, aStartPos, 0L, 0, eNewKind);
     581           0 :         aDragStat.Reset(GetSnapPos(rPnt, 0L));
     582           0 :         bRet = true;
     583             :     }
     584             : 
     585           0 :     return bRet;
     586             : }
     587             : 
     588           0 : Pointer SdrSnapView::GetDraggedHelpLinePointer() const
     589             : {
     590           0 :     if(IsDragHelpLine())
     591             :     {
     592           0 :         switch(mpHelpLineOverlay->GetHelpLineKind())
     593             :         {
     594           0 :             case SDRHELPLINE_VERTICAL  : return Pointer(POINTER_ESIZE);
     595           0 :             case SDRHELPLINE_HORIZONTAL: return Pointer(POINTER_SSIZE);
     596           0 :             default                    : return Pointer(POINTER_MOVE);
     597             :         }
     598             :     }
     599             : 
     600           0 :     return Pointer(POINTER_MOVE);
     601             : }
     602             : 
     603           0 : void SdrSnapView::MovDragHelpLine(const Point& rPnt)
     604             : {
     605           0 :     if(IsDragHelpLine() && aDragStat.CheckMinMoved(rPnt))
     606             :     {
     607           0 :         Point aPnt(GetSnapPos(rPnt, 0L));
     608             : 
     609           0 :         if(aPnt != aDragStat.GetNow())
     610             :         {
     611           0 :             aDragStat.NextMove(aPnt);
     612             :             DBG_ASSERT(mpHelpLineOverlay, "SdrSnapView::MovDragHelpLine: no ImplHelpLineOverlay (!)");
     613           0 :             basegfx::B2DPoint aNewPos(aDragStat.GetNow().X(), aDragStat.GetNow().Y());
     614           0 :             mpHelpLineOverlay->SetPosition(aNewPos);
     615             :         }
     616             :     }
     617           0 : }
     618             : 
     619           0 : bool SdrSnapView::EndDragHelpLine()
     620             : {
     621           0 :     bool bRet(false);
     622             : 
     623           0 :     if(IsDragHelpLine())
     624             :     {
     625           0 :         if(aDragStat.IsMinMoved())
     626             :         {
     627           0 :             SdrPageView* pPageView = mpHelpLineOverlay->GetPageView();
     628             : 
     629           0 :             if(pPageView)
     630             :             {
     631             :                 // moved existing one
     632           0 :                 Point aPnt(aDragStat.GetNow());
     633           0 :                 const SdrHelpLineList& rHelpLines = pPageView->GetHelpLines();
     634           0 :                 SdrHelpLine aChangedHelpLine = rHelpLines[mpHelpLineOverlay->GetHelpLineNumber()];
     635           0 :                 aChangedHelpLine.SetPos(aPnt);
     636           0 :                 pPageView->SetHelpLine(mpHelpLineOverlay->GetHelpLineNumber(), aChangedHelpLine);
     637             : 
     638           0 :                 bRet = true;
     639             :             }
     640             :             else
     641             :             {
     642             :                 // create new one
     643           0 :                 pPageView = GetSdrPageView();
     644             : 
     645           0 :                 if(pPageView)
     646             :                 {
     647           0 :                     Point aPnt(aDragStat.GetNow());
     648           0 :                     SdrHelpLine aNewHelpLine(mpHelpLineOverlay->GetHelpLineKind(), aPnt);
     649           0 :                     pPageView->InsertHelpLine(aNewHelpLine);
     650             : 
     651           0 :                     bRet = true;
     652             :                 }
     653             :             }
     654             :         }
     655             : 
     656             :         // cleanup
     657           0 :         BrkDragHelpLine();
     658             :     }
     659             : 
     660           0 :     return bRet;
     661             : }
     662             : 
     663       14733 : void SdrSnapView::BrkDragHelpLine()
     664             : {
     665       14733 :     if(IsDragHelpLine())
     666             :     {
     667             :         DBG_ASSERT(mpHelpLineOverlay, "SdrSnapView::EndDragHelpLine: no ImplHelpLineOverlay (!)");
     668           0 :         delete mpHelpLineOverlay;
     669           0 :         mpHelpLineOverlay = 0L;
     670             :     }
     671       14733 : }
     672             : 
     673             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10