[Libreoffice-commits] core.git: 8 commits - include/svx svx/source
Matteo Casalin
matteo.casalin at yahoo.com
Wed Dec 27 15:35:01 UTC 2017
include/svx/svddrag.hxx | 8 +--
include/svx/svdmrkv.hxx | 5 +
svx/source/svdraw/svddrag.cxx | 28 ++++------
svx/source/svdraw/svdmrkv.cxx | 112 ++++++++++++++++--------------------------
4 files changed, 63 insertions(+), 90 deletions(-)
New commits:
commit 7cccb79f541404f6d317da49cee431294b9121c6
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Dec 27 13:23:49 2017 +0100
Remove leading _ from some variable names
Change-Id: I640bf41ad073fcf1d5b8fcc55c63558f208db73d
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 7b990127cd52..0ca03c2dca26 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -1986,20 +1986,20 @@ void SdrMarkView::UnmarkAllObj(SdrPageView const * pPV)
}
}
-void SdrMarkView::MarkAllObj(SdrPageView* _pPV)
+void SdrMarkView::MarkAllObj(SdrPageView* pPV)
{
BrkAction();
- if(!_pPV)
+ if(!pPV)
{
- _pPV = GetSdrPageView();
+ pPV = GetSdrPageView();
}
- // #i69171# _pPV may still be NULL if there is no SDrPageView (!), e.g. when inserting
+ // #i69171# pPV may still be NULL if there is no SDrPageView (!), e.g. when inserting
// other files
- if(_pPV)
+ if(pPV)
{
- const bool bMarkChg(GetMarkedObjectListWriteAccess().InsertPageView(*_pPV));
+ const bool bMarkChg(GetMarkedObjectListWriteAccess().InsertPageView(*pPV));
if(bMarkChg)
{
@@ -2154,14 +2154,14 @@ void SdrMarkView::SetMoveOutside(bool bOn)
maHdlList.SetMoveOutside(bOn);
}
-void SdrMarkView::SetDesignMode( bool _bOn )
+void SdrMarkView::SetDesignMode( bool bOn )
{
- if ( mbDesignMode != _bOn )
+ if ( mbDesignMode != bOn )
{
- mbDesignMode = _bOn;
+ mbDesignMode = bOn;
SdrPageView* pPageView = GetSdrPageView();
if ( pPageView )
- pPageView->SetDesignMode( _bOn );
+ pPageView->SetDesignMode( bOn );
}
}
commit 03caa2f611265efce1d379df55a5f27c70d9a46c
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Dec 27 13:04:57 2017 +0100
Make some bool const
Change-Id: Icede71af1edfc0671f5b0bc0dbfd3cfc6af79fcd
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index cb5f4fe0f972..7b990127cd52 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -1909,8 +1909,8 @@ SdrObject* SdrMarkView::PickObj(const Point& rPnt, short nTol, SdrPageView*& rpP
bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageView*& rpPV, SdrSearchOptions nOptions) const
{
SortMarkedObjects();
- bool bBoundCheckOn2ndPass(nOptions & SdrSearchOptions::PASS2BOUND);
- bool bCheckNearestOn3rdPass(nOptions & SdrSearchOptions::PASS3NEAREST);
+ const bool bBoundCheckOn2ndPass(nOptions & SdrSearchOptions::PASS2BOUND);
+ const bool bCheckNearestOn3rdPass(nOptions & SdrSearchOptions::PASS3NEAREST);
rpObj=nullptr;
rpPV=nullptr;
const size_t nMarkCount=GetMarkedObjectCount();
commit fed40ef827f2ee8db583a13bcb439fe625c7527f
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Dec 27 13:00:39 2017 +0100
Return early
Change-Id: I2b420141b5986b1d23460d5432c1b7051b11663e
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index f0043d4aa824..cb5f4fe0f972 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -1913,24 +1913,23 @@ bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageVie
bool bCheckNearestOn3rdPass(nOptions & SdrSearchOptions::PASS3NEAREST);
rpObj=nullptr;
rpPV=nullptr;
- bool bFnd=false;
const size_t nMarkCount=GetMarkedObjectCount();
- for (size_t nMarkNum=nMarkCount; nMarkNum>0 && !bFnd;) {
+ for (size_t nMarkNum=nMarkCount; nMarkNum>0;) {
--nMarkNum;
SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
SdrPageView* pPV=pM->GetPageView();
SdrObject* pObj=pM->GetMarkedSdrObj();
- bFnd = nullptr != CheckSingleSdrObjectHit(rPnt,mnHitTolLog,pObj,pPV,SdrSearchOptions::TESTMARKABLE,nullptr);
- if (bFnd) {
+ if (CheckSingleSdrObjectHit(rPnt,mnHitTolLog,pObj,pPV,SdrSearchOptions::TESTMARKABLE,nullptr)) {
rpObj=pObj;
rpPV=pPV;
+ return true;
}
}
- if ((bBoundCheckOn2ndPass || bCheckNearestOn3rdPass) && !bFnd) {
+ if (bBoundCheckOn2ndPass || bCheckNearestOn3rdPass) {
SdrObject* pBestObj=nullptr;
SdrPageView* pBestPV=nullptr;
sal_uIntPtr nBestDist=ULONG_MAX;
- for (size_t nMarkNum=nMarkCount; nMarkNum>0 && !bFnd;) {
+ for (size_t nMarkNum=nMarkCount; nMarkNum>0;) {
--nMarkNum;
SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
SdrPageView* pPV=pM->GetPageView();
@@ -1941,10 +1940,11 @@ bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageVie
aRect.Right ()+=mnHitTolLog;
aRect.Bottom()+=mnHitTolLog;
if (aRect.IsInside(rPnt)) {
- bFnd=true;
rpObj=pObj;
rpPV=pPV;
- } else if (bCheckNearestOn3rdPass) {
+ return true;
+ }
+ if (bCheckNearestOn3rdPass) {
sal_uIntPtr nDist=0;
if (rPnt.X()<aRect.Left()) nDist+=aRect.Left()-rPnt.X();
if (rPnt.X()>aRect.Right()) nDist+=rPnt.X()-aRect.Right();
@@ -1957,13 +1957,13 @@ bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageVie
}
}
}
- if (bCheckNearestOn3rdPass && !bFnd) {
+ if (bCheckNearestOn3rdPass) {
rpObj=pBestObj;
rpPV=pBestPV;
- bFnd=pBestObj!=nullptr;
+ return pBestObj!=nullptr;
}
}
- return bFnd;
+ return false;
}
commit b30499e288b923483c3d00edce6af72cb5eef5b9
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Dec 27 12:52:27 2017 +0100
mnHitTolLog is already sal_uInt16
Change-Id: I4a0e55818ad8e2f61845484a71b6283e0a7c326a
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 14443e767d10..f0043d4aa824 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -1913,7 +1913,6 @@ bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageVie
bool bCheckNearestOn3rdPass(nOptions & SdrSearchOptions::PASS3NEAREST);
rpObj=nullptr;
rpPV=nullptr;
- sal_uInt16 nTol=(sal_uInt16)mnHitTolLog;
bool bFnd=false;
const size_t nMarkCount=GetMarkedObjectCount();
for (size_t nMarkNum=nMarkCount; nMarkNum>0 && !bFnd;) {
@@ -1921,7 +1920,7 @@ bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageVie
SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
SdrPageView* pPV=pM->GetPageView();
SdrObject* pObj=pM->GetMarkedSdrObj();
- bFnd = nullptr != CheckSingleSdrObjectHit(rPnt,nTol,pObj,pPV,SdrSearchOptions::TESTMARKABLE,nullptr);
+ bFnd = nullptr != CheckSingleSdrObjectHit(rPnt,mnHitTolLog,pObj,pPV,SdrSearchOptions::TESTMARKABLE,nullptr);
if (bFnd) {
rpObj=pObj;
rpPV=pPV;
@@ -1937,10 +1936,10 @@ bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageVie
SdrPageView* pPV=pM->GetPageView();
SdrObject* pObj=pM->GetMarkedSdrObj();
tools::Rectangle aRect(pObj->GetCurrentBoundRect());
- aRect.Left ()-=nTol;
- aRect.Top ()-=nTol;
- aRect.Right ()+=nTol;
- aRect.Bottom()+=nTol;
+ aRect.Left ()-=mnHitTolLog;
+ aRect.Top ()-=mnHitTolLog;
+ aRect.Right ()+=mnHitTolLog;
+ aRect.Bottom()+=mnHitTolLog;
if (aRect.IsInside(rPnt)) {
bFnd=true;
rpObj=pObj;
commit 541f369f30527687af010db5bfa75008a7013dd7
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Tue Dec 26 19:29:33 2017 +0100
Avoid temporary Point
Change-Id: I09ce2859f7bda468399629fda1336788ed65bcb2
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 2afc197bb8b8..14443e767d10 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -1403,10 +1403,9 @@ bool SdrMarkView::IsMarkedObjHit(const Point& rPnt, short nTol) const
{
bool bRet=false;
nTol=ImpGetHitTolLogic(nTol,nullptr);
- Point aPt(rPnt);
for (size_t nm=0; nm<GetMarkedObjectCount() && !bRet; ++nm) {
SdrMark* pM=GetSdrMarkByIndex(nm);
- bRet = nullptr != CheckSingleSdrObjectHit(aPt,sal_uInt16(nTol),pM->GetMarkedSdrObj(),pM->GetPageView(),SdrSearchOptions::NONE,nullptr);
+ bRet = nullptr != CheckSingleSdrObjectHit(rPnt,sal_uInt16(nTol),pM->GetMarkedSdrObj(),pM->GetPageView(),SdrSearchOptions::NONE,nullptr);
}
return bRet;
}
@@ -1416,8 +1415,7 @@ SdrHdl* SdrMarkView::PickHandle(const Point& rPnt) const
if (mbSomeObjChgdFlag) { // recalculate handles, if necessary
FlushComeBackTimer();
}
- Point aPt(rPnt);
- return maHdlList.IsHdlListHit(aPt);
+ return maHdlList.IsHdlListHit(rPnt);
}
bool SdrMarkView::MarkObj(const Point& rPnt, short nTol, bool bToggle, bool bDeep)
@@ -1493,7 +1491,6 @@ bool SdrMarkView::MarkNextObj(const Point& rPnt, short nTol, bool bPrev)
{
SortMarkedObjects();
nTol=ImpGetHitTolLogic(nTol,nullptr);
- Point aPt(rPnt);
SdrMark* pTopMarkHit=nullptr;
SdrMark* pBtmMarkHit=nullptr;
size_t nTopMarkHit=0;
@@ -1503,7 +1500,7 @@ bool SdrMarkView::MarkNextObj(const Point& rPnt, short nTol, bool bPrev)
for (size_t nm=nMarkCount; nm>0 && pTopMarkHit==nullptr;) {
--nm;
SdrMark* pM=GetSdrMarkByIndex(nm);
- if(CheckSingleSdrObjectHit(aPt,sal_uInt16(nTol),pM->GetMarkedSdrObj(),pM->GetPageView(),SdrSearchOptions::NONE,nullptr))
+ if(CheckSingleSdrObjectHit(rPnt,sal_uInt16(nTol),pM->GetMarkedSdrObj(),pM->GetPageView(),SdrSearchOptions::NONE,nullptr))
{
pTopMarkHit=pM;
nTopMarkHit=nm;
@@ -1520,7 +1517,7 @@ bool SdrMarkView::MarkNextObj(const Point& rPnt, short nTol, bool bPrev)
for (size_t nm=0; nm<nMarkCount && pBtmMarkHit==nullptr; ++nm) {
SdrMark* pM=GetSdrMarkByIndex(nm);
SdrPageView* pPV2=pM->GetPageView();
- if (pPV2==pPV && CheckSingleSdrObjectHit(aPt,sal_uInt16(nTol),pM->GetMarkedSdrObj(),pPV2,SdrSearchOptions::NONE,nullptr))
+ if (pPV2==pPV && CheckSingleSdrObjectHit(rPnt,sal_uInt16(nTol),pM->GetMarkedSdrObj(),pPV2,SdrSearchOptions::NONE,nullptr))
{
pBtmMarkHit=pM;
nBtmMarkHit=nm;
@@ -1574,7 +1571,7 @@ bool SdrMarkView::MarkNextObj(const Point& rPnt, short nTol, bool bPrev)
pObj = pObjList->GetObj(no);
}
- if (CheckSingleSdrObjectHit(aPt,sal_uInt16(nTol),pObj,pPV,SdrSearchOptions::TESTMARKABLE,nullptr))
+ if (CheckSingleSdrObjectHit(rPnt,sal_uInt16(nTol),pObj,pPV,SdrSearchOptions::TESTMARKABLE,nullptr))
{
if (TryToFindMarkedObject(pObj)==SAL_MAX_SIZE) {
pFndObj=pObj;
@@ -1810,7 +1807,6 @@ SdrObject* SdrMarkView::PickObj(const Point& rPnt, short nTol, SdrPageView*& rpP
// nOptions & SdrSearchOptions::PASS2BOUND: n.i.
// nOptions & SdrSearchOptions::PASS3NEAREST// n.i.
if (nTol<0) nTol=ImpGetHitTolLogic(nTol,nullptr);
- Point aPt(rPnt);
SdrObject* pObj=nullptr;
SdrObject* pHitObj=nullptr;
SdrPageView* pPV=nullptr;
@@ -1827,7 +1823,7 @@ SdrObject* SdrMarkView::PickObj(const Point& rPnt, short nTol, SdrPageView*& rpP
SdrMark* pM=GetSdrMarkByIndex(nMrkNum);
pObj=pM->GetMarkedSdrObj();
pPV=pM->GetPageView();
- pHitObj=CheckSingleSdrObjectHit(aPt,nTol,pObj,pPV,nOptions,nullptr);
+ pHitObj=CheckSingleSdrObjectHit(rPnt,nTol,pObj,pPV,nOptions,nullptr);
if (bBack) nMrkNum++;
}
}
@@ -1872,7 +1868,7 @@ SdrObject* SdrMarkView::PickObj(const Point& rPnt, short nTol, SdrPageView*& rpP
if (pbHitPassDirect!=nullptr) *pbHitPassDirect = false;
nTmpOptions=nTmpOptions | SdrSearchOptions::IMPISMASTER;
}
- pHitObj=CheckSingleSdrObjectHit(aPt,nTol,pObjList,pPV,nTmpOptions,pMVisLay,pObj,&(GetMarkedObjectList()));
+ pHitObj=CheckSingleSdrObjectHit(rPnt,nTol,pObjList,pPV,nTmpOptions,pMVisLay,pObj,&(GetMarkedObjectList()));
if (bBack) nPgNum++;
}
}
@@ -1887,8 +1883,8 @@ SdrObject* SdrMarkView::PickObj(const Point& rPnt, short nTol, SdrPageView*& rpP
}
if (pObj!=nullptr && (nOptions & SdrSearchOptions::TESTMACRO)) {
SdrObjMacroHitRec aHitRec;
- aHitRec.aPos=aPt;
- aHitRec.aDownPos=aPt;
+ aHitRec.aPos=rPnt;
+ aHitRec.aDownPos=rPnt;
aHitRec.nTol=nTol;
aHitRec.pVisiLayer=&pPV->GetVisibleLayers();
aHitRec.pPageView=pPV;
@@ -1897,7 +1893,7 @@ SdrObject* SdrMarkView::PickObj(const Point& rPnt, short nTol, SdrPageView*& rpP
if (pObj!=nullptr && (nOptions & SdrSearchOptions::WITHTEXT) && pObj->GetOutlinerParaObject()==nullptr) pObj=nullptr;
if (pObj!=nullptr && (nOptions & SdrSearchOptions::TESTTEXTAREA) && pPV)
{
- if(!SdrObjectPrimitiveHit(*pObj, aPt, 0, *pPV, nullptr, true))
+ if(!SdrObjectPrimitiveHit(*pObj, rPnt, 0, *pPV, nullptr, true))
{
pObj = nullptr;
}
@@ -1917,7 +1913,6 @@ bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageVie
bool bCheckNearestOn3rdPass(nOptions & SdrSearchOptions::PASS3NEAREST);
rpObj=nullptr;
rpPV=nullptr;
- Point aPt(rPnt);
sal_uInt16 nTol=(sal_uInt16)mnHitTolLog;
bool bFnd=false;
const size_t nMarkCount=GetMarkedObjectCount();
@@ -1926,7 +1921,7 @@ bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageVie
SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
SdrPageView* pPV=pM->GetPageView();
SdrObject* pObj=pM->GetMarkedSdrObj();
- bFnd = nullptr != CheckSingleSdrObjectHit(aPt,nTol,pObj,pPV,SdrSearchOptions::TESTMARKABLE,nullptr);
+ bFnd = nullptr != CheckSingleSdrObjectHit(rPnt,nTol,pObj,pPV,SdrSearchOptions::TESTMARKABLE,nullptr);
if (bFnd) {
rpObj=pObj;
rpPV=pPV;
@@ -1946,16 +1941,16 @@ bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageVie
aRect.Top ()-=nTol;
aRect.Right ()+=nTol;
aRect.Bottom()+=nTol;
- if (aRect.IsInside(aPt)) {
+ if (aRect.IsInside(rPnt)) {
bFnd=true;
rpObj=pObj;
rpPV=pPV;
} else if (bCheckNearestOn3rdPass) {
sal_uIntPtr nDist=0;
- if (aPt.X()<aRect.Left()) nDist+=aRect.Left()-aPt.X();
- if (aPt.X()>aRect.Right()) nDist+=aPt.X()-aRect.Right();
- if (aPt.Y()<aRect.Top()) nDist+=aRect.Top()-aPt.Y();
- if (aPt.Y()>aRect.Bottom()) nDist+=aPt.Y()-aRect.Bottom();
+ if (rPnt.X()<aRect.Left()) nDist+=aRect.Left()-rPnt.X();
+ if (rPnt.X()>aRect.Right()) nDist+=rPnt.X()-aRect.Right();
+ if (rPnt.Y()<aRect.Top()) nDist+=aRect.Top()-rPnt.Y();
+ if (rPnt.Y()>aRect.Bottom()) nDist+=rPnt.Y()-aRect.Bottom();
if (nDist<nBestDist) {
nBestDist = nDist;
pBestObj=pObj;
commit aa109e6a6fe771965acd17c00126aff74ca6f5c2
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Fri Dec 22 23:36:55 2017 +0100
Share common code
Change-Id: Ia6ee42c799e566ad837e89d6456c50c7217da1eb
diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx
index 1741f7c8ca38..b670782d3137 100644
--- a/include/svx/svdmrkv.hxx
+++ b/include/svx/svdmrkv.hxx
@@ -162,6 +162,7 @@ protected:
bool MarkGluePoints(const tools::Rectangle* pRect, bool bUnmark);
void SetMoveOutside(bool bOn);
+ bool MarkableObjectsExceed( int n ) const;
protected:
// #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
@@ -200,7 +201,7 @@ public:
bool IsFrameHandles() const { return mbForceFrameHandles; }
// returns true if number of markable objects is greater than 1
- bool HasMultipleMarkableObjects() const;
+ bool HasMultipleMarkableObjects() const { return MarkableObjectsExceed(1); };
void SetEditMode(SdrViewEditMode eMode);
SdrViewEditMode GetEditMode() const { return meEditMode; }
@@ -218,7 +219,7 @@ public:
void SetFrameDragSingles(bool bOn=true) { SetFrameHandles(bOn); }
bool IsFrameDragSingles() const { return IsFrameHandles(); }
- bool HasMarkableObj() const;
+ bool HasMarkableObj() const { return MarkableObjectsExceed(0); };
// migrate selections
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index d02758a6eee8..2afc197bb8b8 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -522,41 +522,23 @@ void SdrMarkView::BrkMarkGluePoints()
}
}
-bool SdrMarkView::HasMultipleMarkableObjects() const
+bool SdrMarkView::MarkableObjectsExceed( int n ) const
{
SdrPageView* pPV = GetSdrPageView();
if (!pPV)
return false;
- int nCount=0;
SdrObjList* pOL=pPV->GetObjList();
const size_t nObjCount = pOL->GetObjCount();
for (size_t nObjNum=0; nObjNum<nObjCount; ++nObjNum) {
SdrObject* pObj=pOL->GetObj(nObjNum);
- if (IsObjMarkable(pObj,pPV) && ++nCount>1)
+ if (IsObjMarkable(pObj,pPV) && --n<0)
return true;
}
return false;
}
-bool SdrMarkView::HasMarkableObj() const
-{
- SdrPageView* pPV = GetSdrPageView();
- if(pPV)
- {
- SdrObjList* pOL=pPV->GetObjList();
- const size_t nObjCount = pOL->GetObjCount();
- for (size_t nObjNum = 0; nObjNum<nObjCount; ++nObjNum) {
- SdrObject* pObj=pOL->GetObj(nObjNum);
- if (IsObjMarkable(pObj,pPV)) {
- return true;
- }
- }
- }
- return false;
-}
-
void SdrMarkView::hideMarkHandles()
{
if(!mbMarkHandlesHidden)
commit 828a7ffd3e76d21d65edb822299ca0c5a2b70ef2
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Thu Dec 21 07:49:35 2017 +0100
Do not overwrite data with same value
After emplace_back there are at least 2 elements, and GetPrevPos
would point to previous back().
Commit 5e913234da65484778d53179ee2005aec01d0f0e removed
a possible modification of such data, so this operation is now
pointless.
Change-Id: Ia5bec5e9b16e9dc9f34c7cf1dbb8e3f17510d83b
diff --git a/svx/source/svdraw/svddrag.cxx b/svx/source/svdraw/svddrag.cxx
index ce0637eebb61..5e123ffbd4c1 100644
--- a/svx/source/svdraw/svddrag.cxx
+++ b/svx/source/svdraw/svddrag.cxx
@@ -72,9 +72,7 @@ void SdrDragStat::NextMove(const Point& rPnt)
void SdrDragStat::NextPoint()
{
- Point aPnt(mvPnts.back());
mvPnts.emplace_back(aRealNow);
- mvPnts[GetPrevPos()] = aPnt;
}
void SdrDragStat::PrevPoint()
commit df1a10dafd3a2263d6e46edcaa6e6c0a64a80598
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Thu Dec 21 07:13:16 2017 +0100
Directly access own data members, remove unused methods
Change-Id: Id86d66738da2f6e4b86d4a4ee8da54940c751787
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();
}
More information about the Libreoffice-commits
mailing list