[Libreoffice-commits] core.git: 2 commits - svgio/inc svgio/source

Noel Grandin noel.grandin at collabora.co.uk
Mon Mar 5 06:26:30 UTC 2018


 svgio/inc/svgpathnode.hxx                 |   12 ++++++------
 svgio/inc/svgpatternnode.hxx              |   10 ++++++----
 svgio/source/svgreader/svgpathnode.cxx    |    2 --
 svgio/source/svgreader/svgpatternnode.cxx |    6 ++----
 4 files changed, 14 insertions(+), 16 deletions(-)

New commits:
commit ed50afb3c06cb7eb0df7a4633bbff2498577e7e9
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Feb 28 09:52:12 2018 +0200

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

diff --git a/svgio/inc/svgpatternnode.hxx b/svgio/inc/svgpatternnode.hxx
index d0b2ca02cc93..5aa93b373217 100644
--- a/svgio/inc/svgpatternnode.hxx
+++ b/svgio/inc/svgpatternnode.hxx
@@ -38,7 +38,8 @@ namespace svgio
             SvgStyleAttributes      maSvgStyleAttributes;
 
             /// variable scan values, dependent of given XAttributeList
-            basegfx::B2DRange*      mpViewBox;
+            std::unique_ptr<basegfx::B2DRange>
+                                    mpViewBox;
             SvgAspectRatio          maSvgAspectRatio;
             SvgNumber               maX;
             SvgNumber               maY;
@@ -48,7 +49,8 @@ namespace svgio
                                     mpPatternUnits;
             std::unique_ptr<SvgUnits>
                                     mpPatternContentUnits;
-            basegfx::B2DHomMatrix*  mpaPatternTransform;
+            std::unique_ptr<basegfx::B2DHomMatrix>
+                                    mpaPatternTransform;
 
             /// link to another pattern used as style. If maXLink
             /// is set, the node can be fetched on demand by using
@@ -79,7 +81,7 @@ namespace svgio
 
             /// viewBox content
             const basegfx::B2DRange* getViewBox() const;
-            void setViewBox(const basegfx::B2DRange* pViewBox) { if(mpViewBox) delete mpViewBox; mpViewBox = nullptr; if(pViewBox) mpViewBox = new basegfx::B2DRange(*pViewBox); }
+            void setViewBox(const basegfx::B2DRange* pViewBox) { mpViewBox.reset(); if(pViewBox) mpViewBox.reset(new basegfx::B2DRange(*pViewBox)); }
 
             /// SvgAspectRatio content
             const SvgAspectRatio& getSvgAspectRatio() const;
@@ -106,7 +108,7 @@ namespace svgio
 
             /// PatternTransform content
             const basegfx::B2DHomMatrix* getPatternTransform() const;
-            void setPatternTransform(const basegfx::B2DHomMatrix* pMatrix) { if(mpaPatternTransform) delete mpaPatternTransform; mpaPatternTransform = nullptr; if(pMatrix) mpaPatternTransform = new basegfx::B2DHomMatrix(*pMatrix); }
+            void setPatternTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaPatternTransform.reset(); if(pMatrix) mpaPatternTransform.reset(new basegfx::B2DHomMatrix(*pMatrix)); }
 
         };
     } // end of namespace svgreader
diff --git a/svgio/source/svgreader/svgpatternnode.cxx b/svgio/source/svgreader/svgpatternnode.cxx
index 50e2a38b6fe8..758a6022f841 100644
--- a/svgio/source/svgreader/svgpatternnode.cxx
+++ b/svgio/source/svgreader/svgpatternnode.cxx
@@ -54,8 +54,6 @@ namespace svgio
 
         SvgPatternNode::~SvgPatternNode()
         {
-            delete mpViewBox;
-            delete mpaPatternTransform;
         }
 
         const SvgStyleAttributes* SvgPatternNode::getSvgStyleAttributes() const
@@ -298,7 +296,7 @@ namespace svgio
         {
             if(mpViewBox)
             {
-                return mpViewBox;
+                return mpViewBox.get();
             }
 
             const_cast< SvgPatternNode* >(this)->tryToFindLink();
@@ -434,7 +432,7 @@ namespace svgio
         {
             if(mpaPatternTransform)
             {
-                return mpaPatternTransform;
+                return mpaPatternTransform.get();
             }
 
             const_cast< SvgPatternNode* >(this)->tryToFindLink();
commit 8a9f8d35b000e37f08d391958eca0d51269a23dd
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Feb 28 09:49:08 2018 +0200

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

diff --git a/svgio/inc/svgpathnode.hxx b/svgio/inc/svgpathnode.hxx
index 3cd23232a8ee..a96910560b2e 100644
--- a/svgio/inc/svgpathnode.hxx
+++ b/svgio/inc/svgpathnode.hxx
@@ -35,8 +35,8 @@ namespace svgio
             SvgStyleAttributes                  maSvgStyleAttributes;
 
             /// variable scan values, dependent of given XAttributeList
-            basegfx::B2DPolyPolygon*            mpPolyPolygon;
-            basegfx::B2DHomMatrix*              mpaTransform;
+            std::unique_ptr<basegfx::B2DPolyPolygon>  mpPolyPolygon;
+            std::unique_ptr<basegfx::B2DHomMatrix>    mpaTransform;
             SvgNumber                           maPathLength;
             basegfx::utils::PointIndexSet       maHelpPointIndices;
 
@@ -51,12 +51,12 @@ namespace svgio
             virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
 
             /// path content, set if found in current context
-            const basegfx::B2DPolyPolygon* getPath() const { return mpPolyPolygon; }
-            void setPath(const basegfx::B2DPolyPolygon* pPath) { if(mpPolyPolygon) delete mpPolyPolygon; mpPolyPolygon = nullptr; if(pPath) mpPolyPolygon = new basegfx::B2DPolyPolygon(*pPath); }
+            const basegfx::B2DPolyPolygon* getPath() const { return mpPolyPolygon.get(); }
+            void setPath(const basegfx::B2DPolyPolygon* pPath) { mpPolyPolygon.reset(); if(pPath) mpPolyPolygon.reset(new basegfx::B2DPolyPolygon(*pPath)); }
 
             /// transform content, set if found in current context
-            const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform; }
-            void setTransform(const basegfx::B2DHomMatrix* pMatrix) { if(mpaTransform) delete mpaTransform; mpaTransform = nullptr; if(pMatrix) mpaTransform = new basegfx::B2DHomMatrix(*pMatrix); }
+            const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
+            void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset(new basegfx::B2DHomMatrix(*pMatrix)); }
 
             /// PathLength content
             const SvgNumber& getPathLength() const { return maPathLength; }
diff --git a/svgio/source/svgreader/svgpathnode.cxx b/svgio/source/svgreader/svgpathnode.cxx
index 50fe2e52151e..051f4fb9972b 100644
--- a/svgio/source/svgreader/svgpathnode.cxx
+++ b/svgio/source/svgreader/svgpathnode.cxx
@@ -37,8 +37,6 @@ namespace svgio
 
         SvgPathNode::~SvgPathNode()
         {
-            delete mpPolyPolygon;
-            delete mpaTransform;
         }
 
         const SvgStyleAttributes* SvgPathNode::getSvgStyleAttributes() const


More information about the Libreoffice-commits mailing list