LCOV - code coverage report
Current view: top level - svx/source/svdraw - svddrag.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 30 86 34.9 %
Date: 2014-11-03 Functions: 4 13 30.8 %
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       31908 : void SdrDragStat::Clear(bool bLeaveOne)
      24             : {
      25       79735 :     while (!aPnts.empty()) {
      26       15919 :         delete aPnts.back();
      27       15919 :         aPnts.pop_back();
      28             :     }
      29       31908 :     delete pUser;
      30       31908 :     pUser=NULL;
      31       31908 :     aPnts.clear();
      32       31908 :     if (bLeaveOne) {
      33       15989 :         aPnts.push_back(new Point);
      34             :     }
      35       31908 : }
      36             : 
      37       15989 : void SdrDragStat::Reset()
      38             : {
      39       15989 :     pView=NULL;
      40       15989 :     pPageView=NULL;
      41       15989 :     bShown=false;
      42       15989 :     nMinMov=1;
      43       15989 :     bMinMoved=false;
      44       15989 :     bHorFixed=false;
      45       15989 :     bVerFixed=false;
      46       15989 :     bWantNoSnap=false;
      47       15989 :     pHdl=NULL;
      48       15989 :     bOrtho4=false;
      49       15989 :     bOrtho8=false;
      50       15989 :     pDragMethod=NULL;
      51       15989 :     bEndDragChangesAttributes=false;
      52       15989 :     bEndDragChangesGeoAndAttributes=false;
      53       15989 :     bMouseIsUp=false;
      54       15989 :     Clear(true);
      55       15989 :     aActionRect=Rectangle();
      56       15989 : }
      57             : 
      58           0 : void SdrDragStat::Reset(const Point& rPnt)
      59             : {
      60           0 :     Reset();
      61           0 :     Start()=rPnt;
      62           0 :     aPos0=rPnt;
      63           0 :     RealNow()=rPnt;
      64           0 : }
      65             : 
      66           0 : void SdrDragStat::NextMove(const Point& rPnt)
      67             : {
      68           0 :     aPos0=GetNow();
      69           0 :     RealNow()=rPnt;
      70           0 :     Point aBla=KorregPos(GetRealNow(),GetPrev());
      71           0 :     Now()=aBla;
      72           0 : }
      73             : 
      74           0 : void SdrDragStat::NextPoint(bool bSaveReal)
      75             : {
      76           0 :     Point aPnt(GetNow());
      77           0 :     if (bSaveReal) aPnt=aRealNow;
      78           0 :     aPnts.push_back(new Point(KorregPos(GetRealNow(),aPnt)));
      79           0 :     Prev()=aPnt;
      80           0 : }
      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           0 : Point SdrDragStat::KorregPos(const Point& rNow, const Point& /*rPrev*/) const
      93             : {
      94           0 :     Point aRet(rNow);
      95           0 :     return aRet;
      96             : }
      97             : 
      98           0 : bool SdrDragStat::CheckMinMoved(const Point& rPnt)
      99             : {
     100           0 :     if (!bMinMoved) {
     101           0 :         long dx=rPnt.X()-GetPrev().X(); if (dx<0) dx=-dx;
     102           0 :         long dy=rPnt.Y()-GetPrev().Y(); if (dy<0) dy=-dy;
     103           0 :         if (dx>=long(nMinMov) || dy>=long(nMinMov))
     104           0 :             bMinMoved=true;
     105             :     }
     106           0 :     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         651 : }
     140             : 
     141             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10