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

Takeshi Abe tabe at fixedpoint.jp
Sat Sep 2 06:08:12 UTC 2017


 include/svx/svdopath.hxx       |    4 ++--
 svx/source/svdraw/svdopath.cxx |   24 +++++-------------------
 2 files changed, 7 insertions(+), 21 deletions(-)

New commits:
commit cba232f91898af9e57a5c6980e11974e1a68f2a1
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Sat Sep 2 07:09:21 2017 +0900

    svx: Simplify code with std::unique_ptr
    
    as SdrPathObj owns mpDAC.
    
    Change-Id: I3e4411046fa55ae8ffae2da5e406ad7d20a7ca6e
    Reviewed-on: https://gerrit.libreoffice.org/41818
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/svx/svdopath.hxx b/include/svx/svdopath.hxx
index 9b527eb3843e..aa93f3cfca91 100644
--- a/include/svx/svdopath.hxx
+++ b/include/svx/svdopath.hxx
@@ -24,6 +24,7 @@
 #include <svx/xpoly.hxx>
 #include <svx/svxdllapi.h>
 #include <basegfx/vector/b2enums.hxx>
+#include <memory>
 
 class ImpPathForDragAndCreate;
 
@@ -53,7 +54,7 @@ protected:
     SdrObjKind                  meKind;
 
     // for isolation of old Drag/Create code
-    ImpPathForDragAndCreate*    mpDAC;
+    std::unique_ptr<ImpPathForDragAndCreate> mpDAC;
 
     // brightness - used in EnhancedCustomShapes2d.cxx for DARKEN[LESS] and LIGHTEN[LESS] segments implementation
     double mdBrightness;
@@ -63,7 +64,6 @@ protected:
     void ImpForceKind();
     void ImpForceLineAngle();
     ImpPathForDragAndCreate& impGetDAC() const;
-    void impDeleteDAC() const;
 
 public:
     double GetBrightness() { return mdBrightness; }
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index 49df3cb8cb34..b079c6ae3393 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -1658,7 +1658,6 @@ sdr::contact::ViewContact* SdrPathObj::CreateObjectSpecificViewContact()
 
 SdrPathObj::SdrPathObj(SdrObjKind eNewKind)
 :   meKind(eNewKind),
-    mpDAC(nullptr),
     mdBrightness(0.0)
 {
     bClosedObj = IsClosed();
@@ -1667,17 +1666,13 @@ SdrPathObj::SdrPathObj(SdrObjKind eNewKind)
 SdrPathObj::SdrPathObj(SdrObjKind eNewKind, const basegfx::B2DPolyPolygon& rPathPoly, double dBrightness)
 :   maPathPolygon(rPathPoly),
     meKind(eNewKind),
-    mpDAC(nullptr),
     mdBrightness(dBrightness)
 {
     bClosedObj = IsClosed();
     ImpForceKind();
 }
 
-SdrPathObj::~SdrPathObj()
-{
-    impDeleteDAC();
-}
+SdrPathObj::~SdrPathObj() = default;
 
 static bool lcl_ImpIsLine(const basegfx::B2DPolyPolygon& rPolyPolygon)
 {
@@ -2224,7 +2219,7 @@ basegfx::B2DPolyPolygon SdrPathObj::getSpecialDragPoly(const SdrDragStat& rDrag)
 
 bool SdrPathObj::BegCreate(SdrDragStat& rStat)
 {
-    impDeleteDAC();
+    mpDAC.reset();
     return impGetDAC().BegCreate(rStat);
 }
 
@@ -2274,7 +2269,7 @@ bool SdrPathObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
             }
         }
 
-        impDeleteDAC();
+        mpDAC.reset();
     }
 
     return bRetval;
@@ -2288,7 +2283,7 @@ bool SdrPathObj::BckCreate(SdrDragStat& rStat)
 void SdrPathObj::BrkCreate(SdrDragStat& rStat)
 {
     impGetDAC().BrkCreate(rStat);
-    impDeleteDAC();
+    mpDAC.reset();
 }
 
 // polygons
@@ -2817,21 +2812,12 @@ ImpPathForDragAndCreate& SdrPathObj::impGetDAC() const
 {
     if(!mpDAC)
     {
-        const_cast<SdrPathObj*>(this)->mpDAC = new ImpPathForDragAndCreate(*const_cast<SdrPathObj*>(this));
+        const_cast<SdrPathObj*>(this)->mpDAC.reset(new ImpPathForDragAndCreate(*const_cast<SdrPathObj*>(this)));
     }
 
     return *mpDAC;
 }
 
-void SdrPathObj::impDeleteDAC() const
-{
-    if(mpDAC)
-    {
-        delete mpDAC;
-        const_cast<SdrPathObj*>(this)->mpDAC = nullptr;
-    }
-}
-
 
 // transformation interface for StarOfficeAPI. This implements support for
 // homogeneous 3x3 matrices containing the transformation of the SdrObject. At the


More information about the Libreoffice-commits mailing list