diff options
-rw-r--r-- | include/svx/svddrag.hxx | 8 | ||||
-rw-r--r-- | svx/source/svdraw/svddrag.cxx | 30 |
2 files changed, 18 insertions, 20 deletions
diff --git a/include/svx/svddrag.hxx b/include/svx/svddrag.hxx index d8dc4acbc1a9..7bedb45fc5b9 100644 --- a/include/svx/svddrag.hxx +++ b/include/svx/svddrag.hxx @@ -77,6 +77,8 @@ class SVX_DLLPUBLIC SdrDragStat final void Clear(); + sal_Int32 GetPrevPos() const { return mvPnts.size()-(mvPnts.size()>1 ? 2 : 1); } + public: SdrDragStat() { Reset(); } ~SdrDragStat(); @@ -88,14 +90,10 @@ public: const Point& GetPoint(sal_Int32 nNum) const { return mvPnts[nNum]; } sal_Int32 GetPointCount() const { return mvPnts.size(); } const Point& GetStart() const { return mvPnts[0]; } - void SetStart(const Point &pt) { mvPnts[0] = pt; } - const Point& GetPrev() const { return mvPnts[GetPointCount()-(GetPointCount()>=2 ? 2:1)]; } - void SetPrev(const Point &pt) { mvPnts[GetPointCount()-(GetPointCount()>=2 ? 2:1)] = pt; } + const Point& GetPrev() const { return mvPnts[GetPrevPos()]; } const Point& GetPos0() const { return aPos0; } const Point& GetNow() const { return mvPnts.back(); } void SetNow(Point const &pt) { mvPnts.back() = pt; } - const Point& GetRealNow() const { return aRealNow; } - void SetRealNow(Point const &pt) { aRealNow = pt; } const Point& GetRef1() const { return aRef1; } void SetRef1(const Point &pt) { aRef1 = pt; } const Point& GetRef2() const { return aRef2; } diff --git a/svx/source/svdraw/svddrag.cxx b/svx/source/svdraw/svddrag.cxx index e2d5cb5e5d39..ce0637eebb61 100644 --- a/svx/source/svdraw/svddrag.cxx +++ b/svx/source/svdraw/svddrag.cxx @@ -58,30 +58,30 @@ void SdrDragStat::Reset() void SdrDragStat::Reset(const Point& rPnt) { Reset(); - SetStart(rPnt); + mvPnts[0]=rPnt; aPos0=rPnt; - SetRealNow(rPnt); + aRealNow=rPnt; } void SdrDragStat::NextMove(const Point& rPnt) { - aPos0=GetNow(); - SetRealNow(rPnt); - SetNow(GetRealNow()); + aPos0=mvPnts.back(); + aRealNow=rPnt; + mvPnts.back()=rPnt; } void SdrDragStat::NextPoint() { - Point aPnt(GetNow()); - mvPnts.emplace_back(GetRealNow()); - SetPrev(aPnt); + Point aPnt(mvPnts.back()); + mvPnts.emplace_back(aRealNow); + mvPnts[GetPrevPos()] = aPnt; } void SdrDragStat::PrevPoint() { - if (mvPnts.size()>=2) { // one has to remain at all times + if (mvPnts.size()>1) { // one has to remain at all times mvPnts.erase(mvPnts.begin()+mvPnts.size()-2); - SetNow( GetRealNow() ); + mvPnts.back() = aRealNow; } } @@ -98,7 +98,7 @@ bool SdrDragStat::CheckMinMoved(const Point& rPnt) Fraction SdrDragStat::GetXFact() const { - long nMul=GetNow().X()-aRef1.X(); + long nMul=mvPnts.back().X()-aRef1.X(); long nDiv=GetPrev().X()-aRef1.X(); if (nDiv==0) nDiv=1; if (bHorFixed) { nMul=1; nDiv=1; } @@ -107,7 +107,7 @@ Fraction SdrDragStat::GetXFact() const Fraction SdrDragStat::GetYFact() const { - long nMul=GetNow().Y()-aRef1.Y(); + long nMul=mvPnts.back().Y()-aRef1.Y(); long nDiv=GetPrev().Y()-aRef1.Y(); if (nDiv==0) nDiv=1; if (bVerFixed) { nMul=1; nDiv=1; } @@ -116,9 +116,9 @@ Fraction SdrDragStat::GetYFact() const void SdrDragStat::TakeCreateRect(tools::Rectangle& rRect) const { - rRect=tools::Rectangle(GetStart(),GetNow()); - if (GetPointCount()>=2) { - Point aBtmRgt(GetPoint(1)); + rRect=tools::Rectangle(mvPnts[0], mvPnts.back()); + if (mvPnts.size()>1) { + Point aBtmRgt(mvPnts[1]); rRect.Right()=aBtmRgt.X(); rRect.Bottom()=aBtmRgt.Y(); } |