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

Noel Grandin noel.grandin at collabora.co.uk
Thu May 3 06:21:22 UTC 2018


 chart2/source/controller/main/DragMethod_PieSegment.cxx |    2 
 include/svx/svdcrtv.hxx                                 |    3 
 include/svx/svddrgmt.hxx                                |    5 -
 sd/source/ui/animations/motionpathtag.cxx               |    6 -
 svx/source/svdraw/svdcrtv.cxx                           |    9 --
 svx/source/svdraw/svddrgmt.cxx                          |   58 ++++++----------
 6 files changed, 35 insertions(+), 48 deletions(-)

New commits:
commit 09cfe07c20636445c330e8a86b7e1bf9492144fb
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed May 2 10:08:38 2018 +0200

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

diff --git a/chart2/source/controller/main/DragMethod_PieSegment.cxx b/chart2/source/controller/main/DragMethod_PieSegment.cxx
index e9fbde74357a..4731c8252ee7 100644
--- a/chart2/source/controller/main/DragMethod_PieSegment.cxx
+++ b/chart2/source/controller/main/DragMethod_PieSegment.cxx
@@ -142,7 +142,7 @@ void DragMethod_PieSegment::createSdrDragEntries()
     if( pObj && pPV )
     {
         const basegfx::B2DPolyPolygon aNewPolyPolygon(pObj->TakeXorPoly());
-        addSdrDragEntry(new SdrDragEntryPolyPolygon(aNewPolyPolygon));
+        addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(aNewPolyPolygon)));
     }
 }
 } //namespace chart
diff --git a/include/svx/svddrgmt.hxx b/include/svx/svddrgmt.hxx
index ab6a87344511..b51769d0e740 100644
--- a/include/svx/svddrgmt.hxx
+++ b/include/svx/svddrgmt.hxx
@@ -23,6 +23,7 @@
 #include <svx/svddrgv.hxx>
 #include <svx/svxdllapi.h>
 #include <svx/sdr/contact/objectcontact.hxx>
+#include <memory>
 
 class SdrDragView;
 class SdrDragStat;
@@ -113,7 +114,7 @@ public:
 class SVX_DLLPUBLIC SdrDragMethod
 {
 private:
-    std::vector< SdrDragEntry* >            maSdrDragEntries;
+    std::vector< std::unique_ptr<SdrDragEntry> > maSdrDragEntries;
     sdr::overlay::OverlayObjectList         maOverlayObjectList;
     SdrDragView&                            mrSdrDragView;
 
@@ -124,7 +125,7 @@ private:
 protected:
     // access for derivated classes to maSdrDragEntries
     void clearSdrDragEntries();
-    void addSdrDragEntry(SdrDragEntry* pNew);
+    void addSdrDragEntry(std::unique_ptr<SdrDragEntry> pNew);
     virtual void createSdrDragEntries();
     virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact);
 
diff --git a/sd/source/ui/animations/motionpathtag.cxx b/sd/source/ui/animations/motionpathtag.cxx
index 165d67b87516..6699ade88ff7 100644
--- a/sd/source/ui/animations/motionpathtag.cxx
+++ b/sd/source/ui/animations/motionpathtag.cxx
@@ -106,7 +106,7 @@ void PathDragMove::createSdrDragEntries()
 
     if(maPathPolyPolygon.count())
     {
-        addSdrDragEntry(new SdrDragEntryPolyPolygon(maPathPolyPolygon));
+        addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(maPathPolyPolygon)));
     }
 }
 
@@ -167,7 +167,7 @@ void PathDragResize::createSdrDragEntries()
 
     if(maPathPolyPolygon.count())
     {
-        addSdrDragEntry(new SdrDragEntryPolyPolygon(maPathPolyPolygon));
+        addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(maPathPolyPolygon)));
     }
 }
 
@@ -221,7 +221,7 @@ void PathDragObjOwn::createSdrDragEntries()
 
     if(maPathPolyPolygon.count())
     {
-        addSdrDragEntry(new SdrDragEntryPolyPolygon(maPathPolyPolygon));
+        addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(maPathPolyPolygon)));
     }
 }
 
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx
index be78cd90fc93..430d98006fa5 100644
--- a/svx/source/svdraw/svddrgmt.cxx
+++ b/svx/source/svdraw/svddrgmt.cxx
@@ -306,20 +306,13 @@ basegfx::B2DRange SdrDragMethod::getCurrentRange() const
 
 void SdrDragMethod::clearSdrDragEntries()
 {
-    for(SdrDragEntry* p : maSdrDragEntries)
-    {
-        delete p;
-    }
-
     maSdrDragEntries.clear();
 }
 
-void SdrDragMethod::addSdrDragEntry(SdrDragEntry* pNew)
+void SdrDragMethod::addSdrDragEntry(std::unique_ptr<SdrDragEntry> pNew)
 {
-    if(pNew)
-    {
-        maSdrDragEntries.push_back(pNew);
-    }
+    assert(pNew);
+    maSdrDragEntries.push_back(std::move(pNew));
 }
 
 void SdrDragMethod::createSdrDragEntries()
@@ -352,7 +345,7 @@ void SdrDragMethod::createSdrDragEntryForSdrObject(const SdrObject& rOriginal, s
 {
     // add full object drag; Clone() at the object has to work
     // for this
-    addSdrDragEntry(new SdrDragEntrySdrObject(rOriginal, rObjectContact, true/*bModify*/));
+    addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntrySdrObject(rOriginal, rObjectContact, true/*bModify*/)));
 }
 
 void SdrDragMethod::createSdrDragEntries_SolidDrag()
@@ -404,7 +397,7 @@ void SdrDragMethod::createSdrDragEntries_SolidDrag()
                                     // when dragging a 50% transparent copy of a filled or not filled object without
                                     // outline, this is normally hard to see. Add extra wireframe in that case. This
                                     // works nice e.g. with text frames etc.
-                                    addSdrDragEntry(new SdrDragEntryPolyPolygon(pCandidate->TakeXorPoly()));
+                                    addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(pCandidate->TakeXorPoly())));
                                 }
                             }
                         }
@@ -458,7 +451,7 @@ void SdrDragMethod::createSdrDragEntries_PolygonDrag()
 
     if(aResult.count())
     {
-        addSdrDragEntry(new SdrDragEntryPolyPolygon(aResult));
+        addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(aResult)));
     }
 }
 
@@ -504,7 +497,7 @@ void SdrDragMethod::createSdrDragEntries_PointDrag()
 
     if(!aPositions.empty())
     {
-        addSdrDragEntry(new SdrDragEntryPointGlueDrag(aPositions, true));
+        addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPointGlueDrag(aPositions, true)));
     }
 }
 
@@ -546,7 +539,7 @@ void SdrDragMethod::createSdrDragEntries_GlueDrag()
 
     if(!aPositions.empty())
     {
-        addSdrDragEntry(new SdrDragEntryPointGlueDrag(aPositions, false));
+        addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPointGlueDrag(aPositions, false)));
     }
 }
 
@@ -691,7 +684,7 @@ void SdrDragMethod::CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlay
         // clone, remember edges
         for(auto const & a: maSdrDragEntries)
         {
-            SdrDragEntrySdrObject* pSdrDragEntrySdrObject = dynamic_cast< SdrDragEntrySdrObject*>(a);
+            SdrDragEntrySdrObject* pSdrDragEntrySdrObject = dynamic_cast< SdrDragEntrySdrObject*>(a.get());
 
             if(pSdrDragEntrySdrObject)
             {
@@ -746,22 +739,19 @@ void SdrDragMethod::CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlay
         drawinglayer::primitive2d::Primitive2DContainer aResult;
         drawinglayer::primitive2d::Primitive2DContainer aResultTransparent;
 
-        for(SdrDragEntry* pCandidate: maSdrDragEntries)
+        for(auto & pCandidate: maSdrDragEntries)
         {
-            if(pCandidate)
-            {
-                const drawinglayer::primitive2d::Primitive2DContainer aCandidateResult(pCandidate->createPrimitive2DSequenceInCurrentState(*this));
+            const drawinglayer::primitive2d::Primitive2DContainer aCandidateResult(pCandidate->createPrimitive2DSequenceInCurrentState(*this));
 
-                if(!aCandidateResult.empty())
+            if(!aCandidateResult.empty())
+            {
+                if(pCandidate->getAddToTransparent())
                 {
-                    if(pCandidate->getAddToTransparent())
-                    {
-                        aResultTransparent.append(aCandidateResult);
-                    }
-                    else
-                    {
-                        aResult.append(aCandidateResult);
-                    }
+                    aResultTransparent.append(aCandidateResult);
+                }
+                else
+                {
+                    aResult.append(aCandidateResult);
                 }
             }
         }
@@ -1175,7 +1165,7 @@ void SdrDragObjOwn::createSdrDragEntries()
             if(pPV && pPV->PageWindowCount())
             {
                 sdr::contact::ObjectContact& rOC = pPV->GetPageWindow(0)->GetObjectContact();
-                addSdrDragEntry(new SdrDragEntrySdrObject(*mpClone, rOC, false));
+                addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntrySdrObject(*mpClone, rOC, false)));
 
                 // potentially no wireframe needed, full drag works
                 bAddWireframe = false;
@@ -1208,7 +1198,7 @@ void SdrDragObjOwn::createSdrDragEntries()
 
         if(aDragPolyPolygon.count())
         {
-            addSdrDragEntry(new SdrDragEntryPolyPolygon(aDragPolyPolygon));
+            addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(aDragPolyPolygon)));
         }
     }
 }
@@ -1462,7 +1452,7 @@ void SdrDragMove::createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr
     // here we want the complete primitive sequence without visible clippings
     rObjectContact.resetViewPort();
 
-    addSdrDragEntry(new SdrDragEntryPrimitive2DSequence(rVOC.getPrimitive2DSequenceHierarchy(aDisplayInfo)));
+    addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPrimitive2DSequence(rVOC.getPrimitive2DSequenceHierarchy(aDisplayInfo))));
 }
 
 void SdrDragMove::applyCurrentTransformationToSdrObject(SdrObject& rTarget)
@@ -2887,7 +2877,7 @@ void SdrDragCrook::createSdrDragEntries()
 
         if(aDragRaster.count())
         {
-            addSdrDragEntry(new SdrDragEntryPolyPolygon(aDragRaster));
+            addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(aDragRaster)));
         }
     }
 
@@ -3420,7 +3410,7 @@ void SdrDragDistort::createSdrDragEntries()
 
         if(aDragRaster.count())
         {
-            addSdrDragEntry(new SdrDragEntryPolyPolygon(aDragRaster));
+            addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(aDragRaster)));
         }
     }
 
commit 72ec9cc3ace02e1ba15aa5843bc110b34b1d30a4
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed May 2 09:06:14 2018 +0200

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

diff --git a/include/svx/svdcrtv.hxx b/include/svx/svdcrtv.hxx
index 47858b29cf4e..add5d962ed59 100644
--- a/include/svx/svdcrtv.hxx
+++ b/include/svx/svdcrtv.hxx
@@ -22,6 +22,7 @@
 
 #include <svx/svddrgv.hxx>
 #include <svx/svxdllapi.h>
+#include <memory>
 
 class XLineAttrSetItem;
 class XFillAttrSetItem;
@@ -38,7 +39,7 @@ class SVX_DLLPUBLIC SdrCreateView : public SdrDragView
 protected:
     SdrObject*                  pCurrentCreate;   // The currently being created object
     SdrPageView*                pCreatePV;    // Here, the creation is started
-    ImplConnectMarkerOverlay*   mpCoMaOverlay;
+    std::unique_ptr<ImplConnectMarkerOverlay> mpCoMaOverlay;
 
     // for migrating stuff from XOR, use ImpSdrCreateViewExtraData ATM to not need to
     // compile the apps all the time
diff --git a/svx/source/svdraw/svdcrtv.cxx b/svx/source/svdraw/svdcrtv.cxx
index c015fe69a848..a1529088dbae 100644
--- a/svx/source/svdraw/svdcrtv.cxx
+++ b/svx/source/svdraw/svdcrtv.cxx
@@ -175,11 +175,7 @@ void ImpSdrCreateViewExtraData::HideOverlay()
 
 void SdrCreateView::ImpClearConnectMarker()
 {
-    if(mpCoMaOverlay)
-    {
-        delete mpCoMaOverlay;
-        mpCoMaOverlay = nullptr;
-    }
+    mpCoMaOverlay.reset();
 }
 
 void SdrCreateView::ImpClearVars()
@@ -201,7 +197,6 @@ SdrCreateView::SdrCreateView(
     SdrModel& rSdrModel,
     OutputDevice* pOut)
 :   SdrDragView(rSdrModel, pOut),
-    mpCoMaOverlay(nullptr),
     mpCreateViewExtraData(new ImpSdrCreateViewExtraData())
 {
     ImpClearVars();
@@ -295,7 +290,7 @@ void SdrCreateView::SetConnectMarker(const SdrObjConnection& rCon)
 
         if(!mpCoMaOverlay)
         {
-            mpCoMaOverlay = new ImplConnectMarkerOverlay(*this, *pTargetObject);
+            mpCoMaOverlay.reset(new ImplConnectMarkerOverlay(*this, *pTargetObject));
         }
     }
     else


More information about the Libreoffice-commits mailing list