summaryrefslogtreecommitdiff
path: root/svgio
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-08-21 19:54:07 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-08-22 10:31:12 +0200
commit523bba89cd5ad6372fb0431cecabdca02ea2b9e3 (patch)
tree5eb36b43d72584c2bc11ac7ef08bb7dc2420d881 /svgio
parenta1759769804a7f3b9895b481229d497a9eb4c70a (diff)
no need to use unique_ptr for B2DPolyPolygon
it is already a COW type Change-Id: Iaf8bf1671781923555df3e43b0db78e87c2c5a87 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120826 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svgio')
-rw-r--r--svgio/inc/svgpathnode.hxx7
-rw-r--r--svgio/source/svgreader/svgpathnode.cxx2
-rw-r--r--svgio/source/svgreader/svgtextpathnode.cxx4
3 files changed, 7 insertions, 6 deletions
diff --git a/svgio/inc/svgpathnode.hxx b/svgio/inc/svgpathnode.hxx
index 3bb0327db559..59daac852891 100644
--- a/svgio/inc/svgpathnode.hxx
+++ b/svgio/inc/svgpathnode.hxx
@@ -24,6 +24,7 @@
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <optional>
namespace svgio::svgreader
{
@@ -34,7 +35,7 @@ namespace svgio::svgreader
SvgStyleAttributes maSvgStyleAttributes;
/// variable scan values, dependent of given XAttributeList
- std::unique_ptr<basegfx::B2DPolyPolygon> mpPolyPolygon;
+ std::optional<basegfx::B2DPolyPolygon> mpPolyPolygon;
std::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
SvgNumber maPathLength;
basegfx::utils::PointIndexSet maHelpPointIndices;
@@ -50,8 +51,8 @@ namespace svgio::svgreader
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.get(); }
- void setPath(const basegfx::B2DPolyPolygon* pPath) { mpPolyPolygon.reset(); if(pPath) mpPolyPolygon.reset(new basegfx::B2DPolyPolygon(*pPath)); }
+ const std::optional<basegfx::B2DPolyPolygon>& getPath() const { return mpPolyPolygon; }
+ void setPath(const std::optional<basegfx::B2DPolyPolygon>& pPath) { mpPolyPolygon = pPath; }
/// transform content, set if found in current context
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
diff --git a/svgio/source/svgreader/svgpathnode.cxx b/svgio/source/svgreader/svgpathnode.cxx
index 773f34f2cf4d..5187df877261 100644
--- a/svgio/source/svgreader/svgpathnode.cxx
+++ b/svgio/source/svgreader/svgpathnode.cxx
@@ -64,7 +64,7 @@ namespace svgio::svgreader
{
if(aPath.count())
{
- setPath(&aPath);
+ setPath(aPath);
}
}
break;
diff --git a/svgio/source/svgreader/svgtextpathnode.cxx b/svgio/source/svgreader/svgtextpathnode.cxx
index 210d674b09ac..e04b8380735e 100644
--- a/svgio/source/svgreader/svgtextpathnode.cxx
+++ b/svgio/source/svgreader/svgtextpathnode.cxx
@@ -320,7 +320,7 @@ namespace svgio::svgreader
return false;
}
- const basegfx::B2DPolyPolygon* pPolyPolyPath = pSvgPathNode->getPath();
+ const std::optional<basegfx::B2DPolyPolygon>& pPolyPolyPath = pSvgPathNode->getPath();
if(!pPolyPolyPath || !pPolyPolyPath->count())
{
@@ -352,7 +352,7 @@ namespace svgio::svgreader
if(!pSvgPathNode)
return;
- const basegfx::B2DPolyPolygon* pPolyPolyPath = pSvgPathNode->getPath();
+ const std::optional<basegfx::B2DPolyPolygon>& pPolyPolyPath = pSvgPathNode->getPath();
if(!(pPolyPolyPath && pPolyPolyPath->count()))
return;