diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-20 14:23:13 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-21 15:46:54 +0200 |
commit | f74b888244fcefa7c03fa25db4d42c839ebbf642 (patch) | |
tree | ac0a93f54098b5c206718fb067fecca6791e8d82 /svx | |
parent | 8d7012b65650a7b2e379bc53b1d93ee616c32ae9 (diff) |
simplify PlusHdl logic
like we did with the AddToHdlList stuff, all the client code cares about
is fetching the entire list
Change-Id: Id3cefa5f316a3f979a276c64f9125943d0981842
Reviewed-on: https://gerrit.libreoffice.org/60813
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdmrkv.cxx | 17 | ||||
-rw-r--r-- | svx/source/svdraw/svdmrkv1.cxx | 17 | ||||
-rw-r--r-- | svx/source/svdraw/svdobj.cxx | 8 | ||||
-rw-r--r-- | svx/source/svdraw/svdopath.cxx | 84 | ||||
-rw-r--r-- | svx/source/svdraw/svdovirt.cxx | 19 |
5 files changed, 53 insertions, 92 deletions
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index 084d936e1baa..d3133ee49301 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -918,18 +918,17 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell) pHdl->SetSelected(bSelected); if (mbPlusHdlAlways || bSelected) { - sal_uInt32 nPlusHdlCnt=pObj->GetPlusHdlCount(*pHdl); + SdrHdlList plusList(nullptr); + pObj->AddToPlusHdlList(plusList, *pHdl); + sal_uInt32 nPlusHdlCnt=plusList.GetHdlCount(); for (sal_uInt32 nPlusNum=0; nPlusNum<nPlusHdlCnt; nPlusNum++) { - SdrHdl* pPlusHdl=pObj->GetPlusHdl(*pHdl,nPlusNum); - if (pPlusHdl!=nullptr) - { - pPlusHdl->SetObj(pObj); - pPlusHdl->SetPageView(pPV); - pPlusHdl->SetPlusHdl(true); - maHdlList.AddHdl(pPlusHdl); - } + SdrHdl* pPlusHdl=plusList.GetHdl(nPlusNum); + pPlusHdl->SetObj(pObj); + pPlusHdl->SetPageView(pPV); + pPlusHdl->SetPlusHdl(true); } + plusList.MoveTo(maHdlList); } } } diff --git a/svx/source/svdraw/svdmrkv1.cxx b/svx/source/svdraw/svdmrkv1.cxx index 335368c4ed65..6b4e4c67c09f 100644 --- a/svx/source/svdraw/svdmrkv1.cxx +++ b/svx/source/svdraw/svdmrkv1.cxx @@ -152,18 +152,17 @@ bool SdrMarkView::ImpMarkPoint(SdrHdl* pHdl, SdrMark* pMark, bool bUnmark) { if (!bUnmark) { - sal_uInt32 nCount(pObj->GetPlusHdlCount(*pHdl)); + SdrHdlList plusList(nullptr); + pObj->AddToPlusHdlList(plusList, *pHdl); + sal_uInt32 nCount(plusList.GetHdlCount()); for (sal_uInt32 i=0; i<nCount; i++) { - SdrHdl* pPlusHdl=pObj->GetPlusHdl(*pHdl,i); - if (pPlusHdl!=nullptr) - { - pPlusHdl->SetObj(pObj); - pPlusHdl->SetPageView(pMark->GetPageView()); - pPlusHdl->SetPlusHdl(true); - maHdlList.AddHdl(pPlusHdl); - } + SdrHdl* pPlusHdl=plusList.GetHdl(i); + pPlusHdl->SetObj(pObj); + pPlusHdl->SetPageView(pMark->GetPageView()); + pPlusHdl->SetPlusHdl(true); } + plusList.MoveTo(maHdlList); } else { diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 9e37ca84c16c..ac8754d29473 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -1194,14 +1194,8 @@ void SdrObject::AddToHdlList(SdrHdlList& rHdlList) const } } -sal_uInt32 SdrObject::GetPlusHdlCount(const SdrHdl& /*rHdl*/) const +void SdrObject::AddToPlusHdlList(SdrHdlList&, SdrHdl&) const { - return 0L; -} - -SdrHdl* SdrObject::GetPlusHdl(const SdrHdl& /*rHdl*/, sal_uInt32 /*nPlNum*/) const -{ - return nullptr; } void SdrObject::addCropHandles(SdrHdlList& /*rTarget*/) const diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index 55a66abd85e5..86f2adf9400b 100644 --- a/svx/source/svdraw/svdopath.cxx +++ b/svx/source/svdraw/svdopath.cxx @@ -2012,80 +2012,48 @@ void SdrPathObj::AddToHdlList(SdrHdlList& rHdlList) const } } -sal_uInt32 SdrPathObj::GetPlusHdlCount(const SdrHdl& rHdl) const +void SdrPathObj::AddToPlusHdlList(SdrHdlList& rHdlList, SdrHdl& rHdl) const { // keep old stuff to be able to keep old SdrHdl stuff, too const XPolyPolygon aOldPathPolygon(GetPathPoly()); - sal_uInt16 nCnt = 0; sal_uInt16 nPnt = static_cast<sal_uInt16>(rHdl.GetPointNum()); sal_uInt16 nPolyNum = static_cast<sal_uInt16>(rHdl.GetPolyNum()); - if(nPolyNum < aOldPathPolygon.Count()) - { - const XPolygon& rXPoly = aOldPathPolygon[nPolyNum]; - sal_uInt16 nPntMax = rXPoly.GetPointCount(); - if (nPntMax>0) - { - nPntMax--; - if (nPnt<=nPntMax) - { - if (rXPoly.GetFlags(nPnt)!=PolyFlags::Control) - { - if (nPnt==0 && IsClosed()) nPnt=nPntMax; - if (nPnt>0 && rXPoly.GetFlags(nPnt-1)==PolyFlags::Control) nCnt++; - if (nPnt==nPntMax && IsClosed()) nPnt=0; - if (nPnt<nPntMax && rXPoly.GetFlags(nPnt+1)==PolyFlags::Control) nCnt++; - } - } - } - } + if (nPolyNum>=aOldPathPolygon.Count()) + return; - return nCnt; -} + const XPolygon& rXPoly = aOldPathPolygon[nPolyNum]; + sal_uInt16 nPntMax = rXPoly.GetPointCount(); -SdrHdl* SdrPathObj::GetPlusHdl(const SdrHdl& rHdl, sal_uInt32 nPlusNum) const -{ - // keep old stuff to be able to keep old SdrHdl stuff, too - const XPolyPolygon aOldPathPolygon(GetPathPoly()); - SdrHdl* pHdl = nullptr; - sal_uInt16 nPnt = static_cast<sal_uInt16>(rHdl.GetPointNum()); - sal_uInt16 nPolyNum = static_cast<sal_uInt16>(rHdl.GetPolyNum()); + if (nPntMax<=0) + return; - if (nPolyNum<aOldPathPolygon.Count()) + nPntMax--; + for (sal_uInt32 nPlusNum = 0; nPlusNum <= nPntMax; ++nPlusNum) { - const XPolygon& rXPoly = aOldPathPolygon[nPolyNum]; - sal_uInt16 nPntMax = rXPoly.GetPointCount(); + SdrHdl* pHdl=new SdrHdlBezWgt(&rHdl); + pHdl->SetPolyNum(rHdl.GetPolyNum()); - if (nPntMax>0) + if (nPnt==0 && IsClosed()) nPnt=nPntMax; + if (nPnt>0 && rXPoly.GetFlags(nPnt-1)==PolyFlags::Control && nPlusNum==0) + { + pHdl->SetPos(rXPoly[nPnt-1]); + pHdl->SetPointNum(nPnt-1); + } + else { - nPntMax--; - if (nPnt<=nPntMax) + if (nPnt==nPntMax && IsClosed()) nPnt=0; + if (nPnt<rXPoly.GetPointCount()-1 && rXPoly.GetFlags(nPnt+1)==PolyFlags::Control) { - pHdl=new SdrHdlBezWgt(&rHdl); - pHdl->SetPolyNum(rHdl.GetPolyNum()); - - if (nPnt==0 && IsClosed()) nPnt=nPntMax; - if (nPnt>0 && rXPoly.GetFlags(nPnt-1)==PolyFlags::Control && nPlusNum==0) - { - pHdl->SetPos(rXPoly[nPnt-1]); - pHdl->SetPointNum(nPnt-1); - } - else - { - if (nPnt==nPntMax && IsClosed()) nPnt=0; - if (nPnt<rXPoly.GetPointCount()-1 && rXPoly.GetFlags(nPnt+1)==PolyFlags::Control) - { - pHdl->SetPos(rXPoly[nPnt+1]); - pHdl->SetPointNum(nPnt+1); - } - } - - pHdl->SetSourceHdlNum(rHdl.GetSourceHdlNum()); - pHdl->SetPlusHdl(true); + pHdl->SetPos(rXPoly[nPnt+1]); + pHdl->SetPointNum(nPnt+1); } } + + pHdl->SetSourceHdlNum(rHdl.GetSourceHdlNum()); + pHdl->SetPlusHdl(true); + rHdlList.AddHdl(pHdl); } - return pHdl; } // dragging diff --git a/svx/source/svdraw/svdovirt.cxx b/svx/source/svdraw/svdovirt.cxx index b625ae9fcf3d..bfdd163c2391 100644 --- a/svx/source/svdraw/svdovirt.cxx +++ b/svx/source/svdraw/svdovirt.cxx @@ -212,16 +212,17 @@ void SdrVirtObj::AddToHdlList(SdrHdlList& rHdlList) const tempList.MoveTo(rHdlList); } -sal_uInt32 SdrVirtObj::GetPlusHdlCount(const SdrHdl& rHdl) const +void SdrVirtObj::AddToPlusHdlList(SdrHdlList& rHdlList, SdrHdl& rHdl) const { - return rRefObj.GetPlusHdlCount(rHdl); -} - -SdrHdl* SdrVirtObj::GetPlusHdl(const SdrHdl& rHdl, sal_uInt32 nPlNum) const -{ - SdrHdl* pHdl=rRefObj.GetPlusHdl(rHdl,nPlNum); - pHdl->SetPos(pHdl->GetPos() + aAnchor); - return pHdl; + SdrHdlList tempList(nullptr); + rRefObj.AddToPlusHdlList(tempList, rHdl); + for (size_t i=0; i<tempList.GetHdlCount(); ++i) + { + SdrHdl* pHdl = tempList.GetHdl(i); + Point aP(pHdl->GetPos()+aAnchor); + pHdl->SetPos(aP); + } + tempList.MoveTo(rHdlList); } bool SdrVirtObj::hasSpecialDrag() const |