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

Generated by: LCOV version 1.10