LCOV - code coverage report
Current view: top level - svx/source/svdraw - svddrag.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 58 86 67.4 %
Date: 2015-06-13 12:38:46 Functions: 9 13 69.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             : #include <svx/svdview.hxx>
      21             : #include <svx/svddrag.hxx>
      22             : 
      23       18944 : void SdrDragStat::Clear(bool bLeaveOne)
      24             : {
      25       47330 :     while (!aPnts.empty()) {
      26        9442 :         delete aPnts.back();
      27        9442 :         aPnts.pop_back();
      28             :     }
      29       18944 :     delete pUser;
      30       18944 :     pUser=NULL;
      31       18944 :     aPnts.clear();
      32       18944 :     if (bLeaveOne) {
      33        9506 :         aPnts.push_back(new Point);
      34             :     }
      35       18944 : }
      36             : 
      37        9506 : void SdrDragStat::Reset()
      38             : {
      39        9506 :     pView=NULL;
      40        9506 :     pPageView=NULL;
      41        9506 :     bShown=false;
      42        9506 :     nMinMov=1;
      43        9506 :     bMinMoved=false;
      44        9506 :     bHorFixed=false;
      45        9506 :     bVerFixed=false;
      46        9506 :     bWantNoSnap=false;
      47        9506 :     pHdl=NULL;
      48        9506 :     bOrtho4=false;
      49        9506 :     bOrtho8=false;
      50        9506 :     pDragMethod=NULL;
      51        9506 :     bEndDragChangesAttributes=false;
      52        9506 :     bEndDragChangesGeoAndAttributes=false;
      53        9506 :     bMouseIsUp=false;
      54        9506 :     Clear(true);
      55        9506 :     aActionRect=Rectangle();
      56        9506 : }
      57             : 
      58           2 : void SdrDragStat::Reset(const Point& rPnt)
      59             : {
      60           2 :     Reset();
      61           2 :     Start()=rPnt;
      62           2 :     aPos0=rPnt;
      63           2 :     RealNow()=rPnt;
      64           2 : }
      65             : 
      66           2 : void SdrDragStat::NextMove(const Point& rPnt)
      67             : {
      68           2 :     aPos0=GetNow();
      69           2 :     RealNow()=rPnt;
      70           2 :     Point aBla=KorregPos(GetRealNow(),GetPrev());
      71           2 :     Now()=aBla;
      72           2 : }
      73             : 
      74           2 : void SdrDragStat::NextPoint(bool bSaveReal)
      75             : {
      76           2 :     Point aPnt(GetNow());
      77           2 :     if (bSaveReal) aPnt=aRealNow;
      78           2 :     aPnts.push_back(new Point(KorregPos(GetRealNow(),aPnt)));
      79           2 :     Prev()=aPnt;
      80           2 : }
      81             : 
      82           0 : void SdrDragStat::PrevPoint()
      83             : {
      84           0 :     if (aPnts.size()>=2) { // one has to remain at all times
      85           0 :         Point* pPnt=aPnts[aPnts.size()-2];
      86           0 :         aPnts.erase(aPnts.begin()+aPnts.size()-2);
      87           0 :         delete pPnt;
      88           0 :         Now()=KorregPos(GetRealNow(),GetPrev());
      89             :     }
      90           0 : }
      91             : 
      92           4 : Point SdrDragStat::KorregPos(const Point& rNow, const Point& /*rPrev*/)
      93             : {
      94           4 :     Point aRet(rNow);
      95           4 :     return aRet;
      96             : }
      97             : 
      98           3 : bool SdrDragStat::CheckMinMoved(const Point& rPnt)
      99             : {
     100           3 :     if (!bMinMoved) {
     101           3 :         long dx=rPnt.X()-GetPrev().X(); if (dx<0) dx=-dx;
     102           3 :         long dy=rPnt.Y()-GetPrev().Y(); if (dy<0) dy=-dy;
     103           3 :         if (dx>=long(nMinMov) || dy>=long(nMinMov))
     104           2 :             bMinMoved=true;
     105             :     }
     106           3 :     return bMinMoved;
     107             : }
     108             : 
     109           0 : Fraction SdrDragStat::GetXFact() const
     110             : {
     111           0 :     long nMul=GetNow().X()-aRef1.X();
     112           0 :     long nDiv=GetPrev().X()-aRef1.X();
     113           0 :     if (nDiv==0) nDiv=1;
     114           0 :     if (bHorFixed) { nMul=1; nDiv=1; }
     115           0 :     return Fraction(nMul,nDiv);
     116             : }
     117             : 
     118           0 : Fraction SdrDragStat::GetYFact() const
     119             : {
     120           0 :     long nMul=GetNow().Y()-aRef1.Y();
     121           0 :     long nDiv=GetPrev().Y()-aRef1.Y();
     122           0 :     if (nDiv==0) nDiv=1;
     123           0 :     if (bVerFixed) { nMul=1; nDiv=1; }
     124           0 :     return Fraction(nMul,nDiv);
     125             : }
     126             : 
     127           0 : void SdrDragStat::TakeCreateRect(Rectangle& rRect) const
     128             : {
     129           0 :     rRect=Rectangle(GetStart(),GetNow());
     130           0 :     if (GetPointAnz()>=2) {
     131           0 :         Point aBtmRgt(GetPoint(1));
     132           0 :         rRect.Right()=aBtmRgt.X();
     133           0 :         rRect.Bottom()=aBtmRgt.Y();
     134             :     }
     135           0 :     if (pView!=NULL && pView->IsCreate1stPointAsCenter()) {
     136           0 :         rRect.Top()+=rRect.Top()-rRect.Bottom();
     137           0 :         rRect.Left()+=rRect.Left()-rRect.Right();
     138             :     }
     139         435 : }
     140             : 
     141             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11