Kaydet (Commit) fed40ef8 authored tarafından Matteo Casalin's avatar Matteo Casalin

Return early

Change-Id: I2b420141b5986b1d23460d5432c1b7051b11663e
üst b30499e2
...@@ -1913,24 +1913,23 @@ bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageVie ...@@ -1913,24 +1913,23 @@ bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageVie
bool bCheckNearestOn3rdPass(nOptions & SdrSearchOptions::PASS3NEAREST); bool bCheckNearestOn3rdPass(nOptions & SdrSearchOptions::PASS3NEAREST);
rpObj=nullptr; rpObj=nullptr;
rpPV=nullptr; rpPV=nullptr;
bool bFnd=false;
const size_t nMarkCount=GetMarkedObjectCount(); const size_t nMarkCount=GetMarkedObjectCount();
for (size_t nMarkNum=nMarkCount; nMarkNum>0 && !bFnd;) { for (size_t nMarkNum=nMarkCount; nMarkNum>0;) {
--nMarkNum; --nMarkNum;
SdrMark* pM=GetSdrMarkByIndex(nMarkNum); SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
SdrPageView* pPV=pM->GetPageView(); SdrPageView* pPV=pM->GetPageView();
SdrObject* pObj=pM->GetMarkedSdrObj(); SdrObject* pObj=pM->GetMarkedSdrObj();
bFnd = nullptr != CheckSingleSdrObjectHit(rPnt,mnHitTolLog,pObj,pPV,SdrSearchOptions::TESTMARKABLE,nullptr); if (CheckSingleSdrObjectHit(rPnt,mnHitTolLog,pObj,pPV,SdrSearchOptions::TESTMARKABLE,nullptr)) {
if (bFnd) {
rpObj=pObj; rpObj=pObj;
rpPV=pPV; rpPV=pPV;
return true;
} }
} }
if ((bBoundCheckOn2ndPass || bCheckNearestOn3rdPass) && !bFnd) { if (bBoundCheckOn2ndPass || bCheckNearestOn3rdPass) {
SdrObject* pBestObj=nullptr; SdrObject* pBestObj=nullptr;
SdrPageView* pBestPV=nullptr; SdrPageView* pBestPV=nullptr;
sal_uIntPtr nBestDist=ULONG_MAX; sal_uIntPtr nBestDist=ULONG_MAX;
for (size_t nMarkNum=nMarkCount; nMarkNum>0 && !bFnd;) { for (size_t nMarkNum=nMarkCount; nMarkNum>0;) {
--nMarkNum; --nMarkNum;
SdrMark* pM=GetSdrMarkByIndex(nMarkNum); SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
SdrPageView* pPV=pM->GetPageView(); SdrPageView* pPV=pM->GetPageView();
...@@ -1941,10 +1940,11 @@ bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageVie ...@@ -1941,10 +1940,11 @@ bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageVie
aRect.Right ()+=mnHitTolLog; aRect.Right ()+=mnHitTolLog;
aRect.Bottom()+=mnHitTolLog; aRect.Bottom()+=mnHitTolLog;
if (aRect.IsInside(rPnt)) { if (aRect.IsInside(rPnt)) {
bFnd=true;
rpObj=pObj; rpObj=pObj;
rpPV=pPV; rpPV=pPV;
} else if (bCheckNearestOn3rdPass) { return true;
}
if (bCheckNearestOn3rdPass) {
sal_uIntPtr nDist=0; sal_uIntPtr nDist=0;
if (rPnt.X()<aRect.Left()) nDist+=aRect.Left()-rPnt.X(); if (rPnt.X()<aRect.Left()) nDist+=aRect.Left()-rPnt.X();
if (rPnt.X()>aRect.Right()) nDist+=rPnt.X()-aRect.Right(); if (rPnt.X()>aRect.Right()) nDist+=rPnt.X()-aRect.Right();
...@@ -1957,13 +1957,13 @@ bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageVie ...@@ -1957,13 +1957,13 @@ bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageVie
} }
} }
} }
if (bCheckNearestOn3rdPass && !bFnd) { if (bCheckNearestOn3rdPass) {
rpObj=pBestObj; rpObj=pBestObj;
rpPV=pBestPV; rpPV=pBestPV;
bFnd=pBestObj!=nullptr; return pBestObj!=nullptr;
} }
} }
return bFnd; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment