[Libreoffice-commits] core.git: include/svx sd/source svx/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Sep 21 13:47:24 UTC 2018


 include/svx/svdobj.hxx                    |    3 -
 include/svx/svdopath.hxx                  |    3 -
 include/svx/svdovirt.hxx                  |    3 -
 sd/source/ui/animations/motionpathtag.cxx |   17 ++----
 svx/source/svdraw/svdmrkv.cxx             |   17 ++----
 svx/source/svdraw/svdmrkv1.cxx            |   17 ++----
 svx/source/svdraw/svdobj.cxx              |    8 --
 svx/source/svdraw/svdopath.cxx            |   84 +++++++++---------------------
 svx/source/svdraw/svdovirt.cxx            |   19 +++---
 9 files changed, 64 insertions(+), 107 deletions(-)

New commits:
commit f74b888244fcefa7c03fa25db4d42c839ebbf642
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Sep 20 14:23:13 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Sep 21 15:46:54 2018 +0200

    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 at collabora.co.uk>

diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 5c5fb75ca26a..91225c243545 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -521,8 +521,7 @@ public:
     /// An object that returns true from HasSpacialDrag() must provide these
     /// methods (incl. FillHdlList()).
     virtual sal_uInt32 GetHdlCount() const;
-    virtual sal_uInt32 GetPlusHdlCount(const SdrHdl& rHdl) const;
-    virtual SdrHdl* GetPlusHdl(const SdrHdl& rHdl, sal_uInt32 nPlNum) const;
+    virtual void AddToPlusHdlList(SdrHdlList& rHdlList, SdrHdl& rHdl) const;
     virtual void AddToHdlList(SdrHdlList& rHdlList) const;
     virtual void addCropHandles(SdrHdlList& rTarget) const;
 
diff --git a/include/svx/svdopath.hxx b/include/svx/svdopath.hxx
index 66c3b0410e5b..0dc07e11d5d0 100644
--- a/include/svx/svdopath.hxx
+++ b/include/svx/svdopath.hxx
@@ -87,8 +87,7 @@ public:
     virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
     virtual sal_uInt32 GetHdlCount() const override;
     virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
-    virtual sal_uInt32 GetPlusHdlCount(const SdrHdl& rHdl) const override;
-    virtual SdrHdl* GetPlusHdl(const SdrHdl& rHdl, sal_uInt32 nPlNum) const override;
+    virtual void AddToPlusHdlList(SdrHdlList& rHdlList, SdrHdl& rHdl) const override;
 
     // special drag methods
     virtual bool hasSpecialDrag() const override;
diff --git a/include/svx/svdovirt.hxx b/include/svx/svdovirt.hxx
index 5d562a73e2c9..47ed2f4b1d03 100644
--- a/include/svx/svdovirt.hxx
+++ b/include/svx/svdovirt.hxx
@@ -77,8 +77,7 @@ public:
 
     virtual basegfx::B2DPolyPolygon TakeXorPoly() const override;
     virtual sal_uInt32 GetHdlCount() const override;
-    virtual sal_uInt32 GetPlusHdlCount(const SdrHdl& rHdl) const override;
-    virtual SdrHdl* GetPlusHdl(const SdrHdl& rHdl, sal_uInt32 nPlNum) const override;
+    virtual void AddToPlusHdlList(SdrHdlList& rHdlList, SdrHdl& rHdl) const override;
     virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
 
     // special drag methods
diff --git a/sd/source/ui/animations/motionpathtag.cxx b/sd/source/ui/animations/motionpathtag.cxx
index 0a6a5ca6e94b..c6e83af4b701 100644
--- a/sd/source/ui/animations/motionpathtag.cxx
+++ b/sd/source/ui/animations/motionpathtag.cxx
@@ -915,18 +915,17 @@ void MotionPathTag::addCustomHandles( SdrHdlList& rHandlerList )
 
                     if( mrView.IsPlusHandlesAlwaysVisible() || bSelected )
                     {
-                        sal_uInt32 nPlusHdlCnt=mpPathObj->GetPlusHdlCount(*pSmartHdl);
+                        SdrHdlList plusList(nullptr);
+                        mpPathObj->AddToPlusHdlList(plusList, *pSmartHdl);
+                        sal_uInt32 nPlusHdlCnt=plusList.GetHdlCount();
                         for (sal_uInt32 nPlusNum=0; nPlusNum<nPlusHdlCnt; nPlusNum++)
                         {
-                            SdrHdl* pPlusHdl = mpPathObj->GetPlusHdl(*pSmartHdl,nPlusNum);
-                            if (pPlusHdl!=nullptr)
-                            {
-                                pPlusHdl->SetObj(mpPathObj);
-                                pPlusHdl->SetPageView(mrView.GetSdrPageView());
-                                pPlusHdl->SetPlusHdl(true);
-                                rHandlerList.AddHdl(pPlusHdl);
-                            }
+                            SdrHdl* pPlusHdl = plusList.GetHdl(nPlusNum);
+                            pPlusHdl->SetObj(mpPathObj);
+                            pPlusHdl->SetPageView(mrView.GetSdrPageView());
+                            pPlusHdl->SetPlusHdl(true);
                         }
+                        plusList.MoveTo(rHandlerList);
                     }
                 }
             }
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


More information about the Libreoffice-commits mailing list