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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Sep 25 11:58:00 UTC 2018


 chart2/source/controller/main/SelectionHelper.cxx |    7 -
 include/svx/svdhdl.hxx                            |   10 +-
 sc/source/ui/view/gridwin3.cxx                    |    2 
 sd/source/ui/animations/motionpathtag.cxx         |   29 +++-----
 sd/source/ui/annotations/annotationtag.cxx        |    4 -
 sd/source/ui/view/viewoverlaymanager.cxx          |    4 -
 svx/source/engine3d/obj3d.cxx                     |    5 -
 svx/source/svdraw/svdhdl.cxx                      |   69 ++++++++-----------
 svx/source/svdraw/svdmrkv.cxx                     |   79 ++++++++++------------
 svx/source/svdraw/svdoashp.cxx                    |    4 -
 svx/source/svdraw/svdobj.cxx                      |   20 ++---
 svx/source/svdraw/svdocapt.cxx                    |    4 -
 svx/source/svdraw/svdocirc.cxx                    |    5 -
 svx/source/svdraw/svdoedge.cxx                    |   23 ++----
 svx/source/svdraw/svdograf.cxx                    |   20 ++---
 svx/source/svdraw/svdomeas.cxx                    |    4 -
 svx/source/svdraw/svdopath.cxx                    |    8 +-
 svx/source/svdraw/svdorect.cxx                    |    8 +-
 svx/source/svdraw/svdotxdr.cxx                    |    5 -
 svx/source/table/svdotable.cxx                    |   35 +++++----
 sw/source/core/draw/dflyobj.cxx                   |   16 ++--
 sw/source/core/draw/dview.cxx                     |    2 
 22 files changed, 175 insertions(+), 188 deletions(-)

New commits:
commit b4fc996520b47a6212661a9de3a1c72ccfc379a4
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Sep 21 15:30:02 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Sep 25 13:57:36 2018 +0200

    loplugin:useuniqueptr in SdrHdlList
    
    Change-Id: I83241bd2ed172594704f4b115b584dc39b234086
    Reviewed-on: https://gerrit.libreoffice.org/60959
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/chart2/source/controller/main/SelectionHelper.cxx b/chart2/source/controller/main/SelectionHelper.cxx
index 30fbfdb648cd..083e7e0f71e7 100644
--- a/chart2/source/controller/main/SelectionHelper.cxx
+++ b/chart2/source/controller/main/SelectionHelper.cxx
@@ -29,6 +29,7 @@
 #include <vcl/svapp.hxx>
 #include <basegfx/point/b2dpoint.hxx>
 #include <com/sun/star/beans/XPropertySet.hpp>
+#include <o3tl/make_unique.hxx>
 
 namespace chart
 {
@@ -595,8 +596,7 @@ bool SelectionHelper::getMarkHandles( SdrHdlList& rHdlList )
                 for( sal_uInt32 nM = 0; nM < aPolygon.count(); nM++)
                 {
                     const ::basegfx::B2DPoint aPoint(aPolygon.getB2DPoint(nM));
-                    SdrHdl* pHdl = new SdrHdl(Point(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY())), SdrHdlKind::Poly);
-                    rHdlList.AddHdl(pHdl);
+                    rHdlList.AddHdl(o3tl::make_unique<SdrHdl>(Point(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY())), SdrHdlKind::Poly));
                 }
             }
             return true;
@@ -641,8 +641,7 @@ bool SelectionHelper::getMarkHandles( SdrHdlList& rHdlList )
         }
 
         Point aPos = pSubObj->GetCurrentBoundRect().Center();
-        SdrHdl* pHdl = new SdrHdl(aPos,SdrHdlKind::Poly);
-        rHdlList.AddHdl(pHdl);
+        rHdlList.AddHdl(o3tl::make_unique<SdrHdl>(aPos,SdrHdlKind::Poly));
     }
     return true;
 }
diff --git a/include/svx/svdhdl.hxx b/include/svx/svdhdl.hxx
index 5416ec71c68d..075c7fe743e9 100644
--- a/include/svx/svdhdl.hxx
+++ b/include/svx/svdhdl.hxx
@@ -415,7 +415,7 @@ class SVX_DLLPUBLIC SdrHdlList
 protected:
     size_t                      mnFocusIndex;
     SdrMarkView*                pView;
-    std::deque<SdrHdl*>         aList;
+    std::deque<std::unique_ptr<SdrHdl>> maList;
     sal_uInt16                  nHdlSize;
 
     bool                        bRotateShear : 1;
@@ -443,8 +443,8 @@ public:
     //          2.Level PageView (Pointer)
     //          3.Level Position (x+y)
     void     Sort();
-    size_t   GetHdlCount() const { return aList.size(); }
-    SdrHdl*  GetHdl(size_t nNum) const { return nNum<aList.size() ? aList[nNum] : nullptr; }
+    size_t   GetHdlCount() const { return maList.size(); }
+    SdrHdl*  GetHdl(size_t nNum) const { return maList[nNum].get(); }
     size_t   GetHdlNum(const SdrHdl* pHdl) const;
     void     SetHdlSize(sal_uInt16 nSiz);
     sal_uInt16   GetHdlSize() const                        { return nHdlSize; }
@@ -457,8 +457,8 @@ public:
 
     // AddHdl takes ownership of the handle. It should be on the Heap
     // as Clear() deletes it.
-    void    AddHdl(SdrHdl* pHdl);
-    SdrHdl* RemoveHdl(size_t nNum);
+    void    AddHdl(std::unique_ptr<SdrHdl> pHdl);
+    std::unique_ptr<SdrHdl> RemoveHdl(size_t nNum);
     void RemoveAllByKind(SdrHdlKind eKind);
 
     // move the ownership of all the SdrHdl to rOther
diff --git a/sc/source/ui/view/gridwin3.cxx b/sc/source/ui/view/gridwin3.cxx
index 337bb7a72beb..c2ea2346cb86 100644
--- a/sc/source/ui/view/gridwin3.cxx
+++ b/sc/source/ui/view/gridwin3.cxx
@@ -303,7 +303,7 @@ void ScGridWindow::CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddres
             bool bNegativePage = pViewData->GetDocument()->IsNegativePage( pViewData->GetTabNo() );
             Point aPos = pViewData->GetScrPos( rAddress.Col(), rAddress.Row(), eWhich, true );
             aPos = PixelToLogic(aPos);
-            rHdl.AddHdl(new SdrHdl(aPos, bNegativePage ? SdrHdlKind::Anchor_TR : SdrHdlKind::Anchor));
+            rHdl.AddHdl(o3tl::make_unique<SdrHdl>(aPos, bNegativePage ? SdrHdlKind::Anchor_TR : SdrHdlKind::Anchor));
         }
     }
 }
diff --git a/sd/source/ui/animations/motionpathtag.cxx b/sd/source/ui/animations/motionpathtag.cxx
index c6e83af4b701..0b8701956796 100644
--- a/sd/source/ui/animations/motionpathtag.cxx
+++ b/sd/source/ui/animations/motionpathtag.cxx
@@ -879,12 +879,11 @@ void MotionPathTag::addCustomHandles( SdrHdlList& rHandlerList )
         }
 
         SmartTagReference xThis( this );
-        SdPathHdl* pHdl = new SdPathHdl( xThis, mpPathObj );
+        std::unique_ptr<SdPathHdl> pHdl(new SdPathHdl( xThis, mpPathObj ));
         pHdl->SetObjHdlNum( SMART_TAG_HDL_NUM );
         pHdl->SetPageView( mrView.GetSdrPageView() );
-
         pHdl->SetObj(mpPathObj);
-        rHandlerList.AddHdl( pHdl );
+        rHandlerList.AddHdl( std::move(pHdl) );
 
         if( isSelected() )
         {
@@ -908,7 +907,7 @@ void MotionPathTag::addCustomHandles( SdrHdlList& rHandlerList )
                     pSmartHdl->SetSourceHdlNum( pTempHdl->GetSourceHdlNum() );
                     pSmartHdl->SetPageView( mrView.GetSdrPageView() );
 
-                    rHandlerList.AddHdl( pSmartHdl );
+                    rHandlerList.AddHdl( std::unique_ptr<SmartHdl>(pSmartHdl) );
 
                     const bool bSelected = rMrkPnts.find( sal_uInt16(nHandle) ) != rMrkPnts.end();
                     pSmartHdl->SetSelected(bSelected);
@@ -941,23 +940,23 @@ void MotionPathTag::addCustomHandles( SdrHdlList& rHandlerList )
                     bool bHgt0=aRect.Top()==aRect.Bottom();
                     if (bWdt0 && bHgt0)
                     {
-                        rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopLeft(),SdrHdlKind::UpperLeft));
+                        rHandlerList.AddHdl(o3tl::make_unique<SmartHdl>( xThis, mpPathObj, aRect.TopLeft(),SdrHdlKind::UpperLeft));
                     }
                     else if (bWdt0 || bHgt0)
                     {
-                        rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopLeft()    ,SdrHdlKind::UpperLeft));
-                        rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomRight(),SdrHdlKind::LowerRight));
+                        rHandlerList.AddHdl(o3tl::make_unique<SmartHdl>( xThis, mpPathObj, aRect.TopLeft()    ,SdrHdlKind::UpperLeft));
+                        rHandlerList.AddHdl(o3tl::make_unique<SmartHdl>( xThis, mpPathObj, aRect.BottomRight(),SdrHdlKind::LowerRight));
                     }
                     else
                     {
-                        if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopLeft()     ,SdrHdlKind::UpperLeft));
-                        if (          !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopCenter()   ,SdrHdlKind::Upper));
-                        if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopRight()    ,SdrHdlKind::UpperRight));
-                        if (!bWdt0          ) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.LeftCenter()  ,SdrHdlKind::Left ));
-                        if (!bWdt0          ) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.RightCenter() ,SdrHdlKind::Right));
-                        if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomLeft()  ,SdrHdlKind::LowerLeft));
-                        if (          !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomCenter(),SdrHdlKind::Lower));
-                        if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomRight() ,SdrHdlKind::LowerRight));
+                        if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(o3tl::make_unique<SmartHdl>( xThis, mpPathObj, aRect.TopLeft()     ,SdrHdlKind::UpperLeft));
+                        if (          !bHgt0) rHandlerList.AddHdl(o3tl::make_unique<SmartHdl>( xThis, mpPathObj, aRect.TopCenter()   ,SdrHdlKind::Upper));
+                        if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(o3tl::make_unique<SmartHdl>( xThis, mpPathObj, aRect.TopRight()    ,SdrHdlKind::UpperRight));
+                        if (!bWdt0          ) rHandlerList.AddHdl(o3tl::make_unique<SmartHdl>( xThis, mpPathObj, aRect.LeftCenter()  ,SdrHdlKind::Left ));
+                        if (!bWdt0          ) rHandlerList.AddHdl(o3tl::make_unique<SmartHdl>( xThis, mpPathObj, aRect.RightCenter() ,SdrHdlKind::Right));
+                        if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(o3tl::make_unique<SmartHdl>( xThis, mpPathObj, aRect.BottomLeft()  ,SdrHdlKind::LowerLeft));
+                        if (          !bHgt0) rHandlerList.AddHdl(o3tl::make_unique<SmartHdl>( xThis, mpPathObj, aRect.BottomCenter(),SdrHdlKind::Lower));
+                        if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(o3tl::make_unique<SmartHdl>( xThis, mpPathObj, aRect.BottomRight() ,SdrHdlKind::LowerRight));
                     }
 
                     while( nCount < rHandlerList.GetHdlCount() )
diff --git a/sd/source/ui/annotations/annotationtag.cxx b/sd/source/ui/annotations/annotationtag.cxx
index 0a3d017798a6..1b5d9bd86585 100644
--- a/sd/source/ui/annotations/annotationtag.cxx
+++ b/sd/source/ui/annotations/annotationtag.cxx
@@ -451,7 +451,7 @@ void AnnotationTag::addCustomHandles( SdrHdlList& rHandlerList )
     if( mxAnnotation.is() )
     {
         SmartTagReference xThis( this );
-        AnnotationHdl* pHdl = new AnnotationHdl( xThis, mxAnnotation, Point() );
+        std::unique_ptr<AnnotationHdl> pHdl(new AnnotationHdl( xThis, mxAnnotation, Point() ));
         pHdl->SetObjHdlNum( SMART_TAG_HDL_NUM );
         pHdl->SetPageView( mrView.GetSdrPageView() );
 
@@ -459,7 +459,7 @@ void AnnotationTag::addCustomHandles( SdrHdlList& rHandlerList )
         Point aBasePos( static_cast<long>(aPosition.X * 100.0), static_cast<long>(aPosition.Y * 100.0) );
         pHdl->SetPos( aBasePos );
 
-        rHandlerList.AddHdl( pHdl );
+        rHandlerList.AddHdl( std::move(pHdl) );
     }
 }
 
diff --git a/sd/source/ui/view/viewoverlaymanager.cxx b/sd/source/ui/view/viewoverlaymanager.cxx
index 0e3b48ca369a..9331b53d50f9 100644
--- a/sd/source/ui/view/viewoverlaymanager.cxx
+++ b/sd/source/ui/view/viewoverlaymanager.cxx
@@ -387,13 +387,13 @@ void ChangePlaceholderTag::addCustomHandles( SdrHdlList& rHandlerList )
         aPos.AdjustX( -(all_width >> 1) );
         aPos.AdjustY( -(all_height >> 1) );
 
-        ImageButtonHdl* pHdl = new ImageButtonHdl( xThis, aPoint );
+        std::unique_ptr<ImageButtonHdl> pHdl(new ImageButtonHdl( xThis, aPoint ));
         pHdl->SetObjHdlNum( SMART_TAG_HDL_NUM );
         pHdl->SetPageView( mrView.GetSdrPageView() );
 
         pHdl->SetPos( aPos );
 
-        rHandlerList.AddHdl( pHdl );
+        rHandlerList.AddHdl( std::move(pHdl) );
     }
 }
 
diff --git a/svx/source/engine3d/obj3d.cxx b/svx/source/engine3d/obj3d.cxx
index 139b98d170ac..f9723ff93992 100644
--- a/svx/source/engine3d/obj3d.cxx
+++ b/svx/source/engine3d/obj3d.cxx
@@ -574,7 +574,7 @@ void E3dCompoundObject::AddToHdlList(SdrHdlList& rHdlList) const
                 // to 2d world coor
                 aPos2D *= rVCScene.getObjectTransformation();
 
-                rHdlList.AddHdl(new SdrHdl(Point(basegfx::fround(aPos2D.getX()), basegfx::fround(aPos2D.getY())), SdrHdlKind::BezierWeight));
+                rHdlList.AddHdl(o3tl::make_unique<SdrHdl>(Point(basegfx::fround(aPos2D.getX()), basegfx::fround(aPos2D.getY())), SdrHdlKind::BezierWeight));
             }
         }
     }
@@ -583,8 +583,7 @@ void E3dCompoundObject::AddToHdlList(SdrHdlList& rHdlList) const
 
     if(aPolyPolygon.count())
     {
-        E3dVolumeMarker* pVolMarker = new E3dVolumeMarker(aPolyPolygon);
-        rHdlList.AddHdl(pVolMarker);
+        rHdlList.AddHdl(o3tl::make_unique<E3dVolumeMarker>(aPolyPolygon));
     }
 }
 
diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx
index 31f232de4703..7cdf414996f2 100644
--- a/svx/source/svdraw/svdhdl.cxx
+++ b/svx/source/svdraw/svdhdl.cxx
@@ -1797,7 +1797,7 @@ void ImpTextframeHdl::CreateB2dIAObject()
 }
 
 
-static bool ImpSdrHdlListSorter(SdrHdl* const& lhs, SdrHdl* const& rhs)
+static bool ImpSdrHdlListSorter(std::unique_ptr<SdrHdl> const& lhs, std::unique_ptr<SdrHdl> const& rhs)
 {
     SdrHdlKind eKind1=lhs->GetKind();
     SdrHdlKind eKind2=rhs->GetKind();
@@ -1950,7 +1950,7 @@ void SdrHdlList::TravelFocusHdl(bool bForward)
     if (mnFocusIndex >= GetHdlCount())
         mnFocusIndex = SAL_MAX_SIZE;
 
-    if(aList.empty())
+    if(maList.empty())
         return;
 
     // take care of old handle
@@ -1965,23 +1965,23 @@ void SdrHdlList::TravelFocusHdl(bool bForward)
     }
 
     // allocate pointer array for sorted handle list
-    std::unique_ptr<ImplHdlAndIndex[]> pHdlAndIndex(new ImplHdlAndIndex[aList.size()]);
+    std::unique_ptr<ImplHdlAndIndex[]> pHdlAndIndex(new ImplHdlAndIndex[maList.size()]);
 
     // build sorted handle list
-    for( size_t a = 0; a < aList.size(); ++a)
+    for( size_t a = 0; a < maList.size(); ++a)
     {
-        pHdlAndIndex[a].mpHdl = aList[a];
+        pHdlAndIndex[a].mpHdl = maList[a].get();
         pHdlAndIndex[a].mnIndex = a;
     }
 
-    qsort(pHdlAndIndex.get(), aList.size(), sizeof(ImplHdlAndIndex), ImplSortHdlFunc);
+    qsort(pHdlAndIndex.get(), maList.size(), sizeof(ImplHdlAndIndex), ImplSortHdlFunc);
 
     // look for old num in sorted array
     size_t nOldHdl(nOldHdlNum);
 
     if(nOldHdlNum != SAL_MAX_SIZE)
     {
-        for(size_t a = 0; a < aList.size(); ++a)
+        for(size_t a = 0; a < maList.size(); ++a)
         {
             if(pHdlAndIndex[a].mpHdl == pOld)
             {
@@ -1999,7 +1999,7 @@ void SdrHdlList::TravelFocusHdl(bool bForward)
     {
         if(nOldHdl != SAL_MAX_SIZE)
         {
-            if(nOldHdl == aList.size() - 1)
+            if(nOldHdl == maList.size() - 1)
             {
                 // end forward run
                 nNewHdl = SAL_MAX_SIZE;
@@ -2021,7 +2021,7 @@ void SdrHdlList::TravelFocusHdl(bool bForward)
         if(nOldHdl == SAL_MAX_SIZE)
         {
             // start backward run at last entry
-            nNewHdl = aList.size() - 1;
+            nNewHdl = maList.size() - 1;
 
         }
         else
@@ -2047,9 +2047,9 @@ void SdrHdlList::TravelFocusHdl(bool bForward)
     {
         SdrHdl* pNew = pHdlAndIndex[nNewHdl].mpHdl;
 
-        for(size_t a = 0; a < aList.size(); ++a)
+        for(size_t a = 0; a < maList.size(); ++a)
         {
-            if(aList[a] == pNew)
+            if(maList[a].get() == pNew)
             {
                 nNewHdlNum = a;
                 break;
@@ -2122,8 +2122,7 @@ void SdrHdlList::ResetFocusHdl()
 
 SdrHdlList::SdrHdlList(SdrMarkView* pV)
 :   mnFocusIndex(SAL_MAX_SIZE),
-    pView(pV),
-    aList()
+    pView(pV)
 {
     nHdlSize = 3;
     bRotateShear = false;
@@ -2178,24 +2177,20 @@ void SdrHdlList::SetDistortShear(bool bOn)
     bDistortShear = bOn;
 }
 
-SdrHdl* SdrHdlList::RemoveHdl(size_t nNum)
+std::unique_ptr<SdrHdl> SdrHdlList::RemoveHdl(size_t nNum)
 {
-    SdrHdl* pRetval = aList[nNum];
-    aList.erase(aList.begin() + nNum);
+    std::unique_ptr<SdrHdl> pRetval = std::move(maList[nNum]);
+    maList.erase(maList.begin() + nNum);
 
     return pRetval;
 }
 
 void SdrHdlList::RemoveAllByKind(SdrHdlKind eKind)
 {
-    for(std::deque<SdrHdl*>::iterator it = aList.begin(); it != aList.end(); )
+    for(auto it = maList.begin(); it != maList.end(); )
     {
-        SdrHdl* p = *it;
-        if (p->GetKind() == eKind)
-        {
-            it = aList.erase( it );
-            delete p;
-        }
+        if ((*it)->GetKind() == eKind)
+            it = maList.erase( it );
         else
             ++it;
     }
@@ -2203,12 +2198,7 @@ void SdrHdlList::RemoveAllByKind(SdrHdlKind eKind)
 
 void SdrHdlList::Clear()
 {
-    for (size_t i=0; i<GetHdlCount(); ++i)
-    {
-        SdrHdl* pHdl=GetHdl(i);
-        delete pHdl;
-    }
-    aList.clear();
+    maList.clear();
 
     bRotateShear=false;
     bDistortShear=false;
@@ -2219,7 +2209,7 @@ void SdrHdlList::Sort()
     // remember currently focused handle
     SdrHdl* pPrev = GetFocusHdl();
 
-    std::sort( aList.begin(), aList.end(), ImpSdrHdlListSorter );
+    std::sort( maList.begin(), maList.end(), ImpSdrHdlListSorter );
 
     // get now and compare
     SdrHdl* pNow = GetFocusHdl();
@@ -2243,17 +2233,19 @@ size_t SdrHdlList::GetHdlNum(const SdrHdl* pHdl) const
 {
     if (pHdl==nullptr)
         return SAL_MAX_SIZE;
-    std::deque<SdrHdl*>::const_iterator it = std::find( aList.begin(), aList.end(), pHdl);
-    if( it == aList.end() )
+    auto it = std::find_if( maList.begin(), maList.end(),
+        [&](const std::unique_ptr<SdrHdl> & p) { return p.get() == pHdl; });
+    assert(it != maList.end());
+    if( it == maList.end() )
         return SAL_MAX_SIZE;
-    return it - aList.begin();
+    return it - maList.begin();
 }
 
-void SdrHdlList::AddHdl(SdrHdl* pHdl)
+void SdrHdlList::AddHdl(std::unique_ptr<SdrHdl> pHdl)
 {
     assert(pHdl);
-    aList.push_back(pHdl);
     pHdl->SetHdlList(this);
+    maList.push_back(std::move(pHdl));
 }
 
 SdrHdl* SdrHdlList::IsHdlListHit(const Point& rPnt) const
@@ -2285,8 +2277,11 @@ SdrHdl* SdrHdlList::GetHdl(SdrHdlKind eKind1) const
 
 void SdrHdlList::MoveTo(SdrHdlList& rOther)
 {
-    rOther.aList.insert(rOther.aList.end(), aList.begin(), aList.end());
-    aList.clear();
+    for (auto & pHdl : maList)
+        pHdl->SetHdlList(&rOther);
+    rOther.maList.insert(rOther.maList.end(),
+        std::make_move_iterator(maList.begin()), std::make_move_iterator(maList.end()));
+    maList.clear();
 }
 
 SdrCropHdl::SdrCropHdl(
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index d3133ee49301..7a9048761e0c 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -826,53 +826,53 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
 
                 if (bWdt0 && bHgt0)
                 {
-                    maHdlList.AddHdl(new SdrHdl(aRect.TopLeft(), SdrHdlKind::UpperLeft));
+                    maHdlList.AddHdl(o3tl::make_unique<SdrHdl>(aRect.TopLeft(), SdrHdlKind::UpperLeft));
                 }
                 else if (!bStdDrag && (bWdt0 || bHgt0))
                 {
-                    maHdlList.AddHdl(new SdrHdl(aRect.TopLeft(), SdrHdlKind::UpperLeft));
-                    maHdlList.AddHdl(new SdrHdl(aRect.BottomRight(), SdrHdlKind::LowerRight));
+                    maHdlList.AddHdl(o3tl::make_unique<SdrHdl>(aRect.TopLeft(), SdrHdlKind::UpperLeft));
+                    maHdlList.AddHdl(o3tl::make_unique<SdrHdl>(aRect.BottomRight(), SdrHdlKind::LowerRight));
                 }
                 else
                 {
                     if (!bWdt0 && !bHgt0)
                     {
-                        maHdlList.AddHdl(new SdrHdl(aRect.TopLeft(), SdrHdlKind::UpperLeft));
+                        maHdlList.AddHdl(o3tl::make_unique<SdrHdl>(aRect.TopLeft(), SdrHdlKind::UpperLeft));
                     }
 
                     if (!bLimitedRotation && !bHgt0)
                     {
-                        maHdlList.AddHdl(new SdrHdl(aRect.TopCenter(), SdrHdlKind::Upper));
+                        maHdlList.AddHdl(o3tl::make_unique<SdrHdl>(aRect.TopCenter(), SdrHdlKind::Upper));
                     }
 
                     if (!bWdt0 && !bHgt0)
                     {
-                        maHdlList.AddHdl(new SdrHdl(aRect.TopRight(), SdrHdlKind::UpperRight));
+                        maHdlList.AddHdl(o3tl::make_unique<SdrHdl>(aRect.TopRight(), SdrHdlKind::UpperRight));
                     }
 
                     if (!bLimitedRotation && !bWdt0)
                     {
-                        maHdlList.AddHdl(new SdrHdl(aRect.LeftCenter(), SdrHdlKind::Left ));
+                        maHdlList.AddHdl(o3tl::make_unique<SdrHdl>(aRect.LeftCenter(), SdrHdlKind::Left ));
                     }
 
                     if (!bLimitedRotation && !bWdt0)
                     {
-                        maHdlList.AddHdl(new SdrHdl(aRect.RightCenter(), SdrHdlKind::Right));
+                        maHdlList.AddHdl(o3tl::make_unique<SdrHdl>(aRect.RightCenter(), SdrHdlKind::Right));
                     }
 
                     if (!bWdt0 && !bHgt0)
                     {
-                        maHdlList.AddHdl(new SdrHdl(aRect.BottomLeft(), SdrHdlKind::LowerLeft));
+                        maHdlList.AddHdl(o3tl::make_unique<SdrHdl>(aRect.BottomLeft(), SdrHdlKind::LowerLeft));
                     }
 
                     if (!bLimitedRotation && !bHgt0)
                     {
-                        maHdlList.AddHdl(new SdrHdl(aRect.BottomCenter(), SdrHdlKind::Lower));
+                        maHdlList.AddHdl(o3tl::make_unique<SdrHdl>(aRect.BottomCenter(), SdrHdlKind::Lower));
                     }
 
                     if (!bWdt0 && !bHgt0)
                     {
-                        maHdlList.AddHdl(new SdrHdl(aRect.BottomRight(), SdrHdlKind::LowerRight));
+                        maHdlList.AddHdl(o3tl::make_unique<SdrHdl>(aRect.BottomRight(), SdrHdlKind::LowerRight));
                     }
                 }
             }
@@ -956,11 +956,11 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
             {
                 const SdrGluePoint& rGP=(*pGPL)[nNumGP];
                 Point aPos(rGP.GetAbsolutePos(*pObj));
-                SdrHdl* pGlueHdl=new SdrHdl(aPos,SdrHdlKind::Glue);
+                std::unique_ptr<SdrHdl> pGlueHdl(new SdrHdl(aPos,SdrHdlKind::Glue));
                 pGlueHdl->SetObj(pObj);
                 pGlueHdl->SetPageView(pPV);
                 pGlueHdl->SetObjHdlNum(nId);
-                maHdlList.AddHdl(pGlueHdl);
+                maHdlList.AddHdl(std::move(pGlueHdl));
             }
         }
     }
@@ -1023,26 +1023,23 @@ void SdrMarkView::AddDragModeHdl(SdrDragMode eMode)
         case SdrDragMode::Rotate:
         {
             // add rotation center
-            SdrHdl* pHdl = new SdrHdl(maRef1, SdrHdlKind::Ref1);
-
-            maHdlList.AddHdl(pHdl);
-
+            maHdlList.AddHdl(o3tl::make_unique<SdrHdl>(maRef1, SdrHdlKind::Ref1));
             break;
         }
         case SdrDragMode::Mirror:
         {
             // add axis of reflection
-            SdrHdl* pHdl3 = new SdrHdl(maRef2, SdrHdlKind::Ref2);
-            SdrHdl* pHdl2 = new SdrHdl(maRef1, SdrHdlKind::Ref1);
-            SdrHdl* pHdl1 = new SdrHdlLine(*pHdl2, *pHdl3, SdrHdlKind::MirrorAxis);
+            std::unique_ptr<SdrHdl> pHdl3(new SdrHdl(maRef2, SdrHdlKind::Ref2));
+            std::unique_ptr<SdrHdl> pHdl2(new SdrHdl(maRef1, SdrHdlKind::Ref1));
+            std::unique_ptr<SdrHdl> pHdl1(new SdrHdlLine(*pHdl2, *pHdl3, SdrHdlKind::MirrorAxis));
 
             pHdl1->SetObjHdlNum(1); // for sorting
             pHdl2->SetObjHdlNum(2); // for sorting
             pHdl3->SetObjHdlNum(3); // for sorting
 
-            maHdlList.AddHdl(pHdl1); // line comes first, so it is the last in HitTest
-            maHdlList.AddHdl(pHdl2);
-            maHdlList.AddHdl(pHdl3);
+            maHdlList.AddHdl(std::move(pHdl1)); // line comes first, so it is the last in HitTest
+            maHdlList.AddHdl(std::move(pHdl2));
+            maHdlList.AddHdl(std::move(pHdl3));
 
             break;
         }
@@ -1091,21 +1088,21 @@ void SdrMarkView::AddDragModeHdl(SdrDragMode eMode)
                 // build handles
                 const Point aTmpPos1(basegfx::fround(aGradTransVector.maPositionA.getX()), basegfx::fround(aGradTransVector.maPositionA.getY()));
                 const Point aTmpPos2(basegfx::fround(aGradTransVector.maPositionB.getX()), basegfx::fround(aGradTransVector.maPositionB.getY()));
-                SdrHdlColor* pColHdl1 = new SdrHdlColor(aTmpPos1, aGradTransVector.aCol1, SDR_HANDLE_COLOR_SIZE_NORMAL, true);
-                SdrHdlColor* pColHdl2 = new SdrHdlColor(aTmpPos2, aGradTransVector.aCol2, SDR_HANDLE_COLOR_SIZE_NORMAL, true);
-                SdrHdlGradient* pGradHdl = new SdrHdlGradient(aTmpPos1, aTmpPos2, false);
+                std::unique_ptr<SdrHdlColor> pColHdl1(new SdrHdlColor(aTmpPos1, aGradTransVector.aCol1, SDR_HANDLE_COLOR_SIZE_NORMAL, true));
+                std::unique_ptr<SdrHdlColor> pColHdl2(new SdrHdlColor(aTmpPos2, aGradTransVector.aCol2, SDR_HANDLE_COLOR_SIZE_NORMAL, true));
+                std::unique_ptr<SdrHdlGradient> pGradHdl(new SdrHdlGradient(aTmpPos1, aTmpPos2, false));
                 DBG_ASSERT(pColHdl1 && pColHdl2 && pGradHdl, "Could not get all necessary handles!");
 
                 // link them
-                pGradHdl->SetColorHandles(pColHdl1, pColHdl2);
+                pGradHdl->SetColorHandles(pColHdl1.get(), pColHdl2.get());
                 pGradHdl->SetObj(pObj);
-                pColHdl1->SetColorChangeHdl(LINK(pGradHdl, SdrHdlGradient, ColorChangeHdl));
-                pColHdl2->SetColorChangeHdl(LINK(pGradHdl, SdrHdlGradient, ColorChangeHdl));
+                pColHdl1->SetColorChangeHdl(LINK(pGradHdl.get(), SdrHdlGradient, ColorChangeHdl));
+                pColHdl2->SetColorChangeHdl(LINK(pGradHdl.get(), SdrHdlGradient, ColorChangeHdl));
 
                 // insert them
-                maHdlList.AddHdl(pColHdl1);
-                maHdlList.AddHdl(pColHdl2);
-                maHdlList.AddHdl(pGradHdl);
+                maHdlList.AddHdl(std::move(pColHdl1));
+                maHdlList.AddHdl(std::move(pColHdl2));
+                maHdlList.AddHdl(std::move(pGradHdl));
             }
             break;
         }
@@ -1133,21 +1130,21 @@ void SdrMarkView::AddDragModeHdl(SdrDragMode eMode)
                     // build handles
                     const Point aTmpPos1(basegfx::fround(aGradTransVector.maPositionA.getX()), basegfx::fround(aGradTransVector.maPositionA.getY()));
                     const Point aTmpPos2(basegfx::fround(aGradTransVector.maPositionB.getX()), basegfx::fround(aGradTransVector.maPositionB.getY()));
-                    SdrHdlColor* pColHdl1 = new SdrHdlColor(aTmpPos1, aGradTransVector.aCol1, aHdlSize, false);
-                    SdrHdlColor* pColHdl2 = new SdrHdlColor(aTmpPos2, aGradTransVector.aCol2, aHdlSize, false);
-                    SdrHdlGradient* pGradHdl = new SdrHdlGradient(aTmpPos1, aTmpPos2, true);
+                    std::unique_ptr<SdrHdlColor> pColHdl1(new SdrHdlColor(aTmpPos1, aGradTransVector.aCol1, aHdlSize, false));
+                    std::unique_ptr<SdrHdlColor> pColHdl2(new SdrHdlColor(aTmpPos2, aGradTransVector.aCol2, aHdlSize, false));
+                    std::unique_ptr<SdrHdlGradient> pGradHdl(new SdrHdlGradient(aTmpPos1, aTmpPos2, true));
                     DBG_ASSERT(pColHdl1 && pColHdl2 && pGradHdl, "Could not get all necessary handles!");
 
                     // link them
-                    pGradHdl->SetColorHandles(pColHdl1, pColHdl2);
+                    pGradHdl->SetColorHandles(pColHdl1.get(), pColHdl2.get());
                     pGradHdl->SetObj(pObj);
-                    pColHdl1->SetColorChangeHdl(LINK(pGradHdl, SdrHdlGradient, ColorChangeHdl));
-                    pColHdl2->SetColorChangeHdl(LINK(pGradHdl, SdrHdlGradient, ColorChangeHdl));
+                    pColHdl1->SetColorChangeHdl(LINK(pGradHdl.get(), SdrHdlGradient, ColorChangeHdl));
+                    pColHdl2->SetColorChangeHdl(LINK(pGradHdl.get(), SdrHdlGradient, ColorChangeHdl));
 
                     // insert them
-                    maHdlList.AddHdl(pColHdl1);
-                    maHdlList.AddHdl(pColHdl2);
-                    maHdlList.AddHdl(pGradHdl);
+                    maHdlList.AddHdl(std::move(pColHdl1));
+                    maHdlList.AddHdl(std::move(pColHdl2));
+                    maHdlList.AddHdl(std::move(pGradHdl));
                 }
             }
             break;
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index c94432421aa0..b87dc21c6a2e 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -1816,10 +1816,10 @@ void SdrObjCustomShape::AddToHdlList(SdrHdlList& rHdlList) const
             try
             {
                 css::awt::Point aPosition( rInteraction.xInteraction->getPosition() );
-                SdrHdl* pH = new SdrHdl( Point( aPosition.X, aPosition.Y ), SdrHdlKind::CustomShape1 );
+                std::unique_ptr<SdrHdl> pH(new SdrHdl( Point( aPosition.X, aPosition.Y ), SdrHdlKind::CustomShape1 ));
                 pH->SetPointNum( nCustomShapeHdlNum );
                 pH->SetObj( const_cast<SdrObjCustomShape*>(this) );
-                rHdlList.AddHdl(pH);
+                rHdlList.AddHdl(std::move(pH));
             }
             catch ( const uno::RuntimeException& )
             {
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index ac8754d29473..83b35d8d4c1c 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -1179,18 +1179,18 @@ void SdrObject::AddToHdlList(SdrHdlList& rHdlList) const
     const tools::Rectangle& rR=GetSnapRect();
     for (sal_uInt32 nHdlNum=0; nHdlNum<8; ++nHdlNum)
     {
-        SdrHdl* pH=nullptr;
+        std::unique_ptr<SdrHdl> pH;
         switch (nHdlNum) {
-            case 0: pH=new SdrHdl(rR.TopLeft(),     SdrHdlKind::UpperLeft); break;
-            case 1: pH=new SdrHdl(rR.TopCenter(),   SdrHdlKind::Upper); break;
-            case 2: pH=new SdrHdl(rR.TopRight(),    SdrHdlKind::UpperRight); break;
-            case 3: pH=new SdrHdl(rR.LeftCenter(),  SdrHdlKind::Left ); break;
-            case 4: pH=new SdrHdl(rR.RightCenter(), SdrHdlKind::Right); break;
-            case 5: pH=new SdrHdl(rR.BottomLeft(),  SdrHdlKind::LowerLeft); break;
-            case 6: pH=new SdrHdl(rR.BottomCenter(),SdrHdlKind::Lower); break;
-            case 7: pH=new SdrHdl(rR.BottomRight(), SdrHdlKind::LowerRight); break;
+            case 0: pH.reset(new SdrHdl(rR.TopLeft(),     SdrHdlKind::UpperLeft)); break;
+            case 1: pH.reset(new SdrHdl(rR.TopCenter(),   SdrHdlKind::Upper)); break;
+            case 2: pH.reset(new SdrHdl(rR.TopRight(),    SdrHdlKind::UpperRight)); break;
+            case 3: pH.reset(new SdrHdl(rR.LeftCenter(),  SdrHdlKind::Left )); break;
+            case 4: pH.reset(new SdrHdl(rR.RightCenter(), SdrHdlKind::Right)); break;
+            case 5: pH.reset(new SdrHdl(rR.BottomLeft(),  SdrHdlKind::LowerLeft)); break;
+            case 6: pH.reset(new SdrHdl(rR.BottomCenter(),SdrHdlKind::Lower)); break;
+            case 7: pH.reset(new SdrHdl(rR.BottomRight(), SdrHdlKind::LowerRight)); break;
         }
-        rHdlList.AddHdl(pH);
+        rHdlList.AddHdl(std::move(pH));
     }
 }
 
diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx
index 4be0d6687a78..2fea3adbec97 100644
--- a/svx/source/svdraw/svdocapt.cxx
+++ b/svx/source/svdraw/svdocapt.cxx
@@ -302,10 +302,10 @@ void SdrCaptionObj::AddToHdlList(SdrHdlList& rHdlList) const
     sal_uInt32 nCnt = aTailPoly.GetSize();
     for(sal_uInt32 i = 0; i<nCnt; ++i)
     {
-        SdrHdl* pHdl = new SdrHdl(aTailPoly.GetPoint(i), SdrHdlKind::Poly);
+        std::unique_ptr<SdrHdl> pHdl(new SdrHdl(aTailPoly.GetPoint(i), SdrHdlKind::Poly));
         pHdl->SetPolyNum(1);
         pHdl->SetPointNum(nRectHdlCnt + i);
-        rHdlList.AddHdl(pHdl);
+        rHdlList.AddHdl(std::move(pHdl));
     }
 }
 
diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx
index 10272e0fec67..347efdc30716 100644
--- a/svx/source/svdraw/svdocirc.cxx
+++ b/svx/source/svdraw/svdocirc.cxx
@@ -414,7 +414,6 @@ void SdrCircObj::AddToHdlList(SdrHdlList& rHdlList) const
 
     for (sal_uInt32 nHdlNum=0; nHdlNum<nHdlCnt; ++nHdlNum)
     {
-        SdrHdl* pH = nullptr;
         Point aPnt;
         SdrHdlKind eLocalKind(SdrHdlKind::Move);
         sal_uInt32 nPNum(0);
@@ -475,11 +474,11 @@ void SdrCircObj::AddToHdlList(SdrHdlList& rHdlList) const
             RotatePoint(aPnt,maRect.TopLeft(),aGeo.nSin,aGeo.nCos);
         }
 
-        pH = new SdrHdl(aPnt,eLocalKind);
+        std::unique_ptr<SdrHdl> pH(new SdrHdl(aPnt,eLocalKind));
         pH->SetPointNum(nPNum);
         pH->SetObj(const_cast<SdrCircObj*>(this));
         pH->SetRotationAngle(aGeo.nRotationAngle);
-        rHdlList.AddHdl(pH);
+        rHdlList.AddHdl(std::move(pH));
     }
 }
 
diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx
index 8c9ef410a446..c32fdefe51d2 100644
--- a/svx/source/svdraw/svdoedge.cxx
+++ b/svx/source/svdraw/svdoedge.cxx
@@ -1774,16 +1774,16 @@ void SdrEdgeObj::AddToHdlList(SdrHdlList& rHdlList) const
         return;
 
     {
-        SdrHdl* pHdl=new ImpEdgeHdl((*pEdgeTrack)[0],SdrHdlKind::Poly);
+        std::unique_ptr<SdrHdl> pHdl(new ImpEdgeHdl((*pEdgeTrack)[0],SdrHdlKind::Poly));
         if (aCon1.pObj!=nullptr && aCon1.bBestVertex) pHdl->Set1PixMore();
         pHdl->SetPointNum(0);
-        rHdlList.AddHdl(pHdl);
+        rHdlList.AddHdl(std::move(pHdl));
     }
     {
-        SdrHdl* pHdl=new ImpEdgeHdl((*pEdgeTrack)[sal_uInt16(nPointCount-1)],SdrHdlKind::Poly);
+        std::unique_ptr<SdrHdl> pHdl(new ImpEdgeHdl((*pEdgeTrack)[sal_uInt16(nPointCount-1)],SdrHdlKind::Poly));
         if (aCon2.pObj!=nullptr && aCon2.bBestVertex) pHdl->Set1PixMore();
         pHdl->SetPointNum(1);
-        rHdlList.AddHdl(pHdl);
+        rHdlList.AddHdl(std::move(pHdl));
     }
     {
         SdrEdgeKind eKind=GetObjectItem(SDRATTR_EDGEKIND).GetValue();
@@ -1795,7 +1795,7 @@ void SdrEdgeObj::AddToHdlList(SdrHdlList& rHdlList) const
             for(sal_uInt32 nNum = 0; nNum < (nO1 + nO2 + nM); ++nNum)
             {
                 sal_Int32 nPt(0);
-                ImpEdgeHdl* pHdl=new ImpEdgeHdl(Point(),SdrHdlKind::Poly);
+                std::unique_ptr<ImpEdgeHdl> pHdl(new ImpEdgeHdl(Point(),SdrHdlKind::Poly));
                 if (nNum<nO1) {
                     nPt=nNum+1;
                     if (nNum==0) pHdl->SetLineCode(SdrEdgeLineCode::Obj1Line2);
@@ -1821,10 +1821,7 @@ void SdrEdgeObj::AddToHdlList(SdrHdlList& rHdlList) const
                     aPos.setY( aPos.Y() / 2 );
                     pHdl->SetPos(aPos);
                     pHdl->SetPointNum(nNum + 2);
-                    rHdlList.AddHdl(pHdl);
-                } else {
-                    delete pHdl;
-                    pHdl=nullptr;
+                    rHdlList.AddHdl(std::move(pHdl));
                 }
             }
         }
@@ -1833,18 +1830,18 @@ void SdrEdgeObj::AddToHdlList(SdrHdlList& rHdlList) const
             if(GetConnectedNode(true))
             {
                 Point aPos((*pEdgeTrack)[1]);
-                ImpEdgeHdl* pHdl=new ImpEdgeHdl(aPos,SdrHdlKind::Poly);
+                std::unique_ptr<ImpEdgeHdl> pHdl(new ImpEdgeHdl(aPos,SdrHdlKind::Poly));
                 pHdl->SetLineCode(SdrEdgeLineCode::Obj1Line2);
                 pHdl->SetPointNum(2);
-                rHdlList.AddHdl(pHdl);
+                rHdlList.AddHdl(std::move(pHdl));
             }
             if(GetConnectedNode(false))
             {
                 Point aPos((*pEdgeTrack)[2]);
-                ImpEdgeHdl* pHdl=new ImpEdgeHdl(aPos,SdrHdlKind::Poly);
+                std::unique_ptr<ImpEdgeHdl> pHdl(new ImpEdgeHdl(aPos,SdrHdlKind::Poly));
                 pHdl->SetLineCode(SdrEdgeLineCode::Obj2Line2);
                 pHdl->SetPointNum(3);
-                rHdlList.AddHdl(pHdl);
+                rHdlList.AddHdl(std::move(pHdl));
             }
         }
     }
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index b22cdfac5412..87e93a1914c1 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -755,7 +755,7 @@ void SdrGrafObj::AddToHdlList(SdrHdlList& rHdlList) const
 {
     SdrHdlList tempList(nullptr);
     SdrRectObj::AddToHdlList( tempList );
-    delete tempList.RemoveHdl(0);
+    tempList.RemoveHdl(0);
     tempList.MoveTo(rHdlList);
 }
 
@@ -1227,7 +1227,7 @@ void SdrGrafObj::addCropHandles(SdrHdlList& rTarget) const
             }
 
             rTarget.AddHdl(
-                new SdrCropViewHdl(
+                o3tl::make_unique<SdrCropViewHdl>(
                     aMatrixForCropViewHdl,
                     GetGraphicObject().GetGraphic(),
                     fCropLeft,
@@ -1240,21 +1240,21 @@ void SdrGrafObj::addCropHandles(SdrHdlList& rTarget) const
     basegfx::B2DPoint aPos;
 
     aPos = aMatrix * basegfx::B2DPoint(0.0, 0.0);
-    rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::UpperLeft, fShearX, fRotate));
+    rTarget.AddHdl(o3tl::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::UpperLeft, fShearX, fRotate));
     aPos = aMatrix * basegfx::B2DPoint(0.5, 0.0);
-    rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Upper, fShearX, fRotate));
+    rTarget.AddHdl(o3tl::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Upper, fShearX, fRotate));
     aPos = aMatrix * basegfx::B2DPoint(1.0, 0.0);
-    rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::UpperRight, fShearX, fRotate));
+    rTarget.AddHdl(o3tl::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::UpperRight, fShearX, fRotate));
     aPos = aMatrix * basegfx::B2DPoint(0.0, 0.5);
-    rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Left , fShearX, fRotate));
+    rTarget.AddHdl(o3tl::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Left , fShearX, fRotate));
     aPos = aMatrix * basegfx::B2DPoint(1.0, 0.5);
-    rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Right, fShearX, fRotate));
+    rTarget.AddHdl(o3tl::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Right, fShearX, fRotate));
     aPos = aMatrix * basegfx::B2DPoint(0.0, 1.0);
-    rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::LowerLeft, fShearX, fRotate));
+    rTarget.AddHdl(o3tl::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::LowerLeft, fShearX, fRotate));
     aPos = aMatrix * basegfx::B2DPoint(0.5, 1.0);
-    rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Lower, fShearX, fRotate));
+    rTarget.AddHdl(o3tl::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Lower, fShearX, fRotate));
     aPos = aMatrix * basegfx::B2DPoint(1.0, 1.0);
-    rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::LowerRight, fShearX, fRotate));
+    rTarget.AddHdl(o3tl::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::LowerRight, fShearX, fRotate));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index 70b4a9f00169..ac7ec1328437 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -770,10 +770,10 @@ void SdrMeasureObj::AddToHdlList(SdrHdlList& rHdlList) const
             case 4: aPt=aMPol.aHelpline1.aP2; break;
             case 5: aPt=aMPol.aHelpline2.aP2; break;
         } // switch
-        SdrHdl* pHdl=new ImpMeasureHdl(aPt,SdrHdlKind::User);
+        std::unique_ptr<SdrHdl> pHdl(new ImpMeasureHdl(aPt,SdrHdlKind::User));
         pHdl->SetObjHdlNum(nHdlNum);
         pHdl->SetRotationAngle(aMPol.nLineAngle);
-        rHdlList.AddHdl(pHdl);
+        rHdlList.AddHdl(std::move(pHdl));
     }
 }
 
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index 86f2adf9400b..3bd275795bdb 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -2000,13 +2000,13 @@ void SdrPathObj::AddToHdlList(SdrHdlList& rHdlList) const
         for (sal_uInt16 j=0; j<nPntCnt; j++) {
             if (rXPoly.GetFlags(j)!=PolyFlags::Control) {
                 const Point& rPnt=rXPoly[j];
-                SdrHdl* pHdl=new SdrHdl(rPnt,SdrHdlKind::Poly);
+                std::unique_ptr<SdrHdl> pHdl(new SdrHdl(rPnt,SdrHdlKind::Poly));
                 pHdl->SetPolyNum(i);
                 pHdl->SetPointNum(j);
                 pHdl->Set1PixMore(j==0);
                 pHdl->SetSourceHdlNum(nIdx);
                 nIdx++;
-                rHdlList.AddHdl(pHdl);
+                rHdlList.AddHdl(std::move(pHdl));
             }
         }
     }
@@ -2031,7 +2031,7 @@ void SdrPathObj::AddToPlusHdlList(SdrHdlList& rHdlList, SdrHdl& rHdl) const
     nPntMax--;
     for (sal_uInt32 nPlusNum = 0; nPlusNum <= nPntMax; ++nPlusNum)
     {
-        SdrHdl* pHdl=new SdrHdlBezWgt(&rHdl);
+        std::unique_ptr<SdrHdl> pHdl(new SdrHdlBezWgt(&rHdl));
         pHdl->SetPolyNum(rHdl.GetPolyNum());
 
         if (nPnt==0 && IsClosed()) nPnt=nPntMax;
@@ -2052,7 +2052,7 @@ void SdrPathObj::AddToPlusHdlList(SdrHdlList& rHdlList, SdrHdl& rHdl) const
 
         pHdl->SetSourceHdlNum(rHdl.GetSourceHdlNum());
         pHdl->SetPlusHdl(true);
-        rHdlList.AddHdl(pHdl);
+        rHdlList.AddHdl(std::move(pHdl));
     }
 }
 
diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx
index fe727ae9b52b..e182c7e64960 100644
--- a/svx/source/svdraw/svdorect.cxx
+++ b/svx/source/svdraw/svdorect.cxx
@@ -315,7 +315,7 @@ void SdrRectObj::AddToHdlList(SdrHdlList& rHdlList) const
     sal_Int32 nCount = IsTextFrame() ? 10 : 9;
     for(sal_Int32 nHdlNum = 0; nHdlNum < nCount; ++nHdlNum)
     {
-        SdrHdl* pH = nullptr;
+        std::unique_ptr<SdrHdl> pH;
         Point aPnt;
         SdrHdlKind eKind = SdrHdlKind::Move;
 
@@ -326,7 +326,7 @@ void SdrRectObj::AddToHdlList(SdrHdlList& rHdlList) const
                 OSL_ENSURE(!IsTextEditActive(), "Do not use a ImpTextframeHdl for highlighting text in active text edit, this will collide with EditEngine paints (!)");
                 // hack for calc grid sync to ensure the hatched area
                 // for a textbox is displayed at correct position
-                pH = new ImpTextframeHdl(maRect + GetGridOffset() );
+                pH.reset(new ImpTextframeHdl(maRect + GetGridOffset() ));
                 pH->SetObj(const_cast<SdrRectObj*>(this));
                 pH->SetRotationAngle(aGeo.nRotationAngle);
                 break;
@@ -364,11 +364,11 @@ void SdrRectObj::AddToHdlList(SdrHdlList& rHdlList) const
                 RotatePoint(aPnt,maRect.TopLeft(),aGeo.nSin,aGeo.nCos);
             }
 
-            pH = new SdrHdl(aPnt,eKind);
+            pH.reset(new SdrHdl(aPnt,eKind));
             pH->SetObj(const_cast<SdrRectObj*>(this));
             pH->SetRotationAngle(aGeo.nRotationAngle);
         }
-        rHdlList.AddHdl(pH);
+        rHdlList.AddHdl(std::move(pH));
     }
 }
 
diff --git a/svx/source/svdraw/svdotxdr.cxx b/svx/source/svdraw/svdotxdr.cxx
index 5ce1e60583d2..0a24ccdf5a3b 100644
--- a/svx/source/svdraw/svdotxdr.cxx
+++ b/svx/source/svdraw/svdotxdr.cxx
@@ -40,7 +40,6 @@ void SdrTextObj::AddToHdlList(SdrHdlList& rHdlList) const
 {
     for(sal_uInt32 nHdlNum=0; nHdlNum<8; ++nHdlNum)
     {
-        SdrHdl* pH=nullptr;
         Point aPnt;
         SdrHdlKind eKind = SdrHdlKind::UpperLeft;
         switch (nHdlNum) {
@@ -55,10 +54,10 @@ void SdrTextObj::AddToHdlList(SdrHdlList& rHdlList) const
         }
         if (aGeo.nShearAngle!=0) ShearPoint(aPnt,maRect.TopLeft(),aGeo.nTan);
         if (aGeo.nRotationAngle!=0) RotatePoint(aPnt,maRect.TopLeft(),aGeo.nSin,aGeo.nCos);
-        pH=new SdrHdl(aPnt,eKind);
+        std::unique_ptr<SdrHdl> pH(new SdrHdl(aPnt,eKind));
         pH->SetObj(const_cast<SdrTextObj*>(this));
         pH->SetRotationAngle(aGeo.nRotationAngle);
-        rHdlList.AddHdl(pH);
+        rHdlList.AddHdl(std::move(pH));
     }
 }
 
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index a77655f40166..8a9dbac463da 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -2110,10 +2110,10 @@ void SdrTableObj::AddToHdlList(SdrHdlList& rHdlList) const
         Point aPoint( maRect.TopLeft() );
         aPoint.AdjustY(nEdge );
 
-        TableEdgeHdl* pHdl= new TableEdgeHdl(aPoint,true,nEdgeMin,nEdgeMax,nColCount+1);
+        std::unique_ptr<TableEdgeHdl> pHdl(new TableEdgeHdl(aPoint,true,nEdgeMin,nEdgeMax,nColCount+1));
         pHdl->SetPointNum( nRow );
-        rHdlList.AddHdl( pHdl );
-        aRowEdges[nRow] = pHdl;
+        aRowEdges[nRow] = pHdl.get();
+        rHdlList.AddHdl( std::move(pHdl) );
     }
 
     // second add column handles
@@ -2129,10 +2129,10 @@ void SdrTableObj::AddToHdlList(SdrHdlList& rHdlList) const
         Point aPoint( maRect.TopLeft() );
         aPoint.AdjustX(nEdge );
 
-        TableEdgeHdl* pHdl = new TableEdgeHdl(aPoint,false,nEdgeMin,nEdgeMax, nRowCount+1);
+        std::unique_ptr<TableEdgeHdl> pHdl(new TableEdgeHdl(aPoint,false,nEdgeMin,nEdgeMax, nRowCount+1));
         pHdl->SetPointNum( nCol );
-        rHdlList.AddHdl( pHdl );
-        aColEdges[nCol] = pHdl;
+        aColEdges[nCol] = pHdl.get();
+        rHdlList.AddHdl( std::move(pHdl) );
     }
 
     // now add visible edges to row and column handles
@@ -2171,16 +2171,19 @@ void SdrTableObj::AddToHdlList(SdrHdlList& rHdlList) const
     }
 
     // add remaining handles
-    SdrHdl* pH=nullptr;
-    rHdlList.AddHdl( pH = new TableBorderHdl( maRect, !IsTextEditActive() ) ); pH->SetMoveOutside( true );
-    rHdlList.AddHdl( pH = new SdrHdl(maRect.TopLeft(),SdrHdlKind::UpperLeft) ); pH->SetMoveOutside( true );
-    rHdlList.AddHdl( pH = new SdrHdl(maRect.TopCenter(),SdrHdlKind::Upper) ); pH->SetMoveOutside( true );
-    rHdlList.AddHdl( pH = new SdrHdl(maRect.TopRight(),SdrHdlKind::UpperRight) ); pH->SetMoveOutside( true );
-    rHdlList.AddHdl( pH = new SdrHdl(maRect.LeftCenter(),SdrHdlKind::Left) ); pH->SetMoveOutside( true );
-    rHdlList.AddHdl( pH = new SdrHdl(maRect.RightCenter(),SdrHdlKind::Right) ); pH->SetMoveOutside( true );
-    rHdlList.AddHdl( pH = new SdrHdl(maRect.BottomLeft(),SdrHdlKind::LowerLeft) ); pH->SetMoveOutside( true );
-    rHdlList.AddHdl( pH = new SdrHdl(maRect.BottomCenter(),SdrHdlKind::Lower) ); pH->SetMoveOutside( true );
-    rHdlList.AddHdl( pH = new SdrHdl(maRect.BottomRight(),SdrHdlKind::LowerRight) ); pH->SetMoveOutside( true );
+    SdrHdlList tempList(nullptr);
+    tempList.AddHdl( o3tl::make_unique<TableBorderHdl>( maRect, !IsTextEditActive() ) );
+    tempList.AddHdl( o3tl::make_unique<SdrHdl>(maRect.TopLeft(),SdrHdlKind::UpperLeft) );
+    tempList.AddHdl( o3tl::make_unique<SdrHdl>(maRect.TopCenter(),SdrHdlKind::Upper) );
+    tempList.AddHdl( o3tl::make_unique<SdrHdl>(maRect.TopRight(),SdrHdlKind::UpperRight) );
+    tempList.AddHdl( o3tl::make_unique<SdrHdl>(maRect.LeftCenter(),SdrHdlKind::Left) );
+    tempList.AddHdl( o3tl::make_unique<SdrHdl>(maRect.RightCenter(),SdrHdlKind::Right) );
+    tempList.AddHdl( o3tl::make_unique<SdrHdl>(maRect.BottomLeft(),SdrHdlKind::LowerLeft) );
+    tempList.AddHdl( o3tl::make_unique<SdrHdl>(maRect.BottomCenter(),SdrHdlKind::Lower) );
+    tempList.AddHdl( o3tl::make_unique<SdrHdl>(maRect.BottomRight(),SdrHdlKind::LowerRight) );
+    for( size_t nHdl = 0; nHdl < tempList.GetHdlCount(); ++nHdl )
+        tempList.GetHdl(nHdl)->SetMoveOutside(true);
+    tempList.MoveTo(rHdlList);
 
     const size_t nHdlCount = rHdlList.GetHdlCount();
     for( size_t nHdl = 0; nHdl < nHdlCount; ++nHdl )
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index 74341ab1115f..a35152c4ca07 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -1209,21 +1209,21 @@ void SwVirtFlyDrawObj::addCropHandles(SdrHdlList& rTarget) const
             basegfx::B2DPoint aPos;
 
             aPos = aTargetTransform * basegfx::B2DPoint(0.0, 0.0);
-            rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::UpperLeft, fShearX, fRotate));
+            rTarget.AddHdl(o3tl::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::UpperLeft, fShearX, fRotate));
             aPos = aTargetTransform * basegfx::B2DPoint(0.5, 0.0);
-            rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Upper, fShearX, fRotate));
+            rTarget.AddHdl(o3tl::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Upper, fShearX, fRotate));
             aPos = aTargetTransform * basegfx::B2DPoint(1.0, 0.0);
-            rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::UpperRight, fShearX, fRotate));
+            rTarget.AddHdl(o3tl::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::UpperRight, fShearX, fRotate));
             aPos = aTargetTransform * basegfx::B2DPoint(0.0, 0.5);
-            rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Left , fShearX, fRotate));
+            rTarget.AddHdl(o3tl::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Left , fShearX, fRotate));
             aPos = aTargetTransform * basegfx::B2DPoint(1.0, 0.5);
-            rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Right, fShearX, fRotate));
+            rTarget.AddHdl(o3tl::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Right, fShearX, fRotate));
             aPos = aTargetTransform * basegfx::B2DPoint(0.0, 1.0);
-            rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::LowerLeft, fShearX, fRotate));
+            rTarget.AddHdl(o3tl::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::LowerLeft, fShearX, fRotate));
             aPos = aTargetTransform * basegfx::B2DPoint(0.5, 1.0);
-            rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Lower, fShearX, fRotate));
+            rTarget.AddHdl(o3tl::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Lower, fShearX, fRotate));
             aPos = aTargetTransform * basegfx::B2DPoint(1.0, 1.0);
-            rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::LowerRight, fShearX, fRotate));
+            rTarget.AddHdl(o3tl::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::LowerRight, fShearX, fRotate));
         }
     }
 }
diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx
index d02eb2e6f2f6..e97a4a70954f 100644
--- a/sw/source/core/draw/dview.cxx
+++ b/sw/source/core/draw/dview.cxx
@@ -244,7 +244,7 @@ void SwDrawView::AddCustomHdl()
     }
 
     // add anchor handle:
-    maHdlList.AddHdl( new SwSdrHdl( aPos, ( pAnch->IsVertical() && !pAnch->IsVertLR() ) ||
+    maHdlList.AddHdl( o3tl::make_unique<SwSdrHdl>( aPos, ( pAnch->IsVertical() && !pAnch->IsVertLR() ) ||
                                      pAnch->IsRightToLeft() ) );
 }
 


More information about the Libreoffice-commits mailing list