[Libreoffice-commits] core.git: 2 commits - svgio/inc svgio/source
Noel Grandin
noel.grandin at collabora.co.uk
Mon Mar 5 06:26:57 UTC 2018
svgio/inc/svgnode.hxx | 6 +++---
svgio/inc/svgpolynode.hxx | 10 +++++-----
svgio/source/svgreader/svgdocumenthandler.cxx | 8 ++++----
svgio/source/svgreader/svggradientnode.cxx | 2 +-
svgio/source/svgreader/svgnode.cxx | 19 ++++++-------------
svgio/source/svgreader/svgpolynode.cxx | 2 --
svgio/source/svgreader/svgtextnode.cxx | 8 ++++----
7 files changed, 23 insertions(+), 32 deletions(-)
New commits:
commit 3b8cd4f95d214e79ffc7e69af094ed0df1cc4788
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed Feb 28 10:03:07 2018 +0200
loplugin:useuniqueptr in SvgNode
Change-Id: I7ab382bd90050302c24464eed645d20a435dbd63
Reviewed-on: https://gerrit.libreoffice.org/50657
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/svgio/inc/svgnode.hxx b/svgio/inc/svgnode.hxx
index fd4e45c5ccc4..7fd8129a48b8 100644
--- a/svgio/inc/svgnode.hxx
+++ b/svgio/inc/svgnode.hxx
@@ -91,7 +91,7 @@ namespace svgio
const SvgNode* mpAlternativeParent;
/// sub hierarchy
- SvgNodeVector maChildren;
+ std::vector< std::unique_ptr<SvgNode> > maChildren;
/// Id svan value
std::unique_ptr<OUString> mpId;
@@ -111,7 +111,7 @@ namespace svgio
::std::vector< const SvgStyleAttributes* > maCssStyleVector;
/// possible local CssStyle, e.g. style="fill:red; stroke:red;"
- SvgStyleAttributes* mpLocalCssStyle;
+ std::unique_ptr<SvgStyleAttributes> mpLocalCssStyle;
// flag if maCssStyleVector is already computed (done only once)
bool mbCssStyleVectorBuilt : 1;
@@ -152,7 +152,7 @@ namespace svgio
SVGToken getType() const { return maType; }
const SvgDocument& getDocument() const { return mrDocument; }
const SvgNode* getParent() const { if(mpAlternativeParent) return mpAlternativeParent; return mpParent; }
- const SvgNodeVector& getChildren() const { return maChildren; }
+ const std::vector< std::unique_ptr<SvgNode> > & getChildren() const { return maChildren; }
/// InfoProvider support for %, em and ex values
virtual const basegfx::B2DRange getCurrentViewPort() const override;
diff --git a/svgio/source/svgreader/svgdocumenthandler.cxx b/svgio/source/svgreader/svgdocumenthandler.cxx
index 8288a40be6ce..87dc67e00273 100644
--- a/svgio/source/svgreader/svgdocumenthandler.cxx
+++ b/svgio/source/svgreader/svgdocumenthandler.cxx
@@ -54,12 +54,12 @@ namespace
{
if(pNode)
{
- const svgio::svgreader::SvgNodeVector& rChilds = pNode->getChildren();
+ const auto& rChilds = pNode->getChildren();
const sal_uInt32 nCount(rChilds.size());
for(sal_uInt32 a(0); a < nCount; a++)
{
- svgio::svgreader::SvgNode* pCandidate = rChilds[a];
+ svgio::svgreader::SvgNode* pCandidate = rChilds[a].get();
if(pCandidate)
{
@@ -564,12 +564,12 @@ namespace svgio
case SVGTokenTspan:
case SVGTokenTextPath:
{
- const SvgNodeVector& rChilds = mpTarget->getChildren();
+ const auto& rChilds = mpTarget->getChildren();
SvgCharacterNode* pTarget = nullptr;
if(rChilds.size())
{
- pTarget = dynamic_cast< SvgCharacterNode* >(rChilds[rChilds.size() - 1]);
+ pTarget = dynamic_cast< SvgCharacterNode* >(rChilds[rChilds.size() - 1].get());
}
if(pTarget)
diff --git a/svgio/source/svgreader/svggradientnode.cxx b/svgio/source/svgreader/svggradientnode.cxx
index 81617c8814dc..4496a809a8cf 100644
--- a/svgio/source/svgreader/svggradientnode.cxx
+++ b/svgio/source/svgreader/svggradientnode.cxx
@@ -257,7 +257,7 @@ namespace svgio
for(sal_uInt32 a(0); a < nCount; a++)
{
- const SvgGradientStopNode* pCandidate = dynamic_cast< const SvgGradientStopNode* >(getChildren()[a]);
+ const SvgGradientStopNode* pCandidate = dynamic_cast< const SvgGradientStopNode* >(getChildren()[a].get());
if(pCandidate)
{
diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx
index f953ec5667c0..9f3687e67a25 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -185,7 +185,7 @@ namespace svgio
if(mpLocalCssStyle)
{
// if we have one, use as first entry
- maCssStyleVector.push_back(mpLocalCssStyle);
+ maCssStyleVector.push_back(mpLocalCssStyle.get());
}
// check the hierarchy for concatenated patterns of Selectors
@@ -275,7 +275,7 @@ namespace svgio
if(pParent)
{
- pParent->maChildren.push_back(this);
+ pParent->maChildren.emplace_back(this);
}
else
{
@@ -290,13 +290,6 @@ namespace svgio
SvgNode::~SvgNode()
{
- while(maChildren.size())
- {
- delete maChildren[maChildren.size() - 1];
- maChildren.pop_back();
- }
-
- delete mpLocalCssStyle;
}
void SvgNode::readLocalCssStyle(const OUString& aContent)
@@ -304,7 +297,7 @@ namespace svgio
if(!mpLocalCssStyle)
{
// create LocalCssStyle if needed but not yet added
- mpLocalCssStyle = new SvgStyleAttributes(*this);
+ mpLocalCssStyle.reset(new SvgStyleAttributes(*this));
}
else
{
@@ -504,7 +497,7 @@ namespace svgio
}
}
- const SvgNodeVector& rChildren = getChildren();
+ const auto& rChildren = getChildren();
if(!rChildren.empty())
{
@@ -512,11 +505,11 @@ namespace svgio
for(sal_uInt32 a(0); a < nCount; a++)
{
- SvgNode* pCandidate = rChildren[a];
+ SvgNode* pCandidate = rChildren[a].get();
if(pCandidate && Display_none != pCandidate->getDisplay())
{
- const SvgNodeVector& rGrandChildren = pCandidate->getChildren();
+ const auto& rGrandChildren = pCandidate->getChildren();
const SvgStyleAttributes* pChildStyles = pCandidate->getSvgStyleAttributes();
// decompose:
// - visible terminal nodes
diff --git a/svgio/source/svgreader/svgtextnode.cxx b/svgio/source/svgreader/svgtextnode.cxx
index 0760f2c184b5..3cb5ea9fce38 100644
--- a/svgio/source/svgreader/svgtextnode.cxx
+++ b/svgio/source/svgreader/svgtextnode.cxx
@@ -123,7 +123,7 @@ namespace svgio
{
// direct TextPath decompose
const SvgTextPathNode& rSvgTextPathNode = static_cast< const SvgTextPathNode& >(rCandidate);
- const SvgNodeVector& rChildren = rSvgTextPathNode.getChildren();
+ const auto& rChildren = rSvgTextPathNode.getChildren();
const sal_uInt32 nCount(rChildren.size());
if(nCount && rSvgTextPathNode.isValid())
@@ -159,7 +159,7 @@ namespace svgio
{
// Tspan may have children, call recursively
const SvgTspanNode& rSvgTspanNode = static_cast< const SvgTspanNode& >(rCandidate);
- const SvgNodeVector& rChildren = rSvgTspanNode.getChildren();
+ const auto& rChildren = rSvgTspanNode.getChildren();
const sal_uInt32 nCount(rChildren.size());
if(nCount)
@@ -188,7 +188,7 @@ namespace svgio
if(pRefText)
{
- const SvgNodeVector& rChildren = pRefText->getChildren();
+ const auto& rChildren = pRefText->getChildren();
const sal_uInt32 nCount(rChildren.size());
drawinglayer::primitive2d::Primitive2DContainer aNewTarget;
@@ -234,7 +234,7 @@ namespace svgio
{
SvgTextPosition aSvgTextPosition(nullptr, *this, maSvgTextPositions);
drawinglayer::primitive2d::Primitive2DContainer aNewTarget;
- const SvgNodeVector& rChildren = getChildren();
+ const auto& rChildren = getChildren();
const sal_uInt32 nCount(rChildren.size());
for(sal_uInt32 a(0); a < nCount; a++)
commit a7205fd02331a8c5710a8ea44ed6157dbb6120cf
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed Feb 28 09:53:44 2018 +0200
loplugin:useuniqueptr in SvgPolyNode
Change-Id: I0227c8a36abbdb88f17cfea186eea28c9f566bd5
Reviewed-on: https://gerrit.libreoffice.org/50656
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/svgio/inc/svgpolynode.hxx b/svgio/inc/svgpolynode.hxx
index 5a867fdb5e85..5e3e27d78888 100644
--- a/svgio/inc/svgpolynode.hxx
+++ b/svgio/inc/svgpolynode.hxx
@@ -35,8 +35,8 @@ namespace svgio
SvgStyleAttributes maSvgStyleAttributes;
/// variable scan values, dependent of given XAttributeList
- basegfx::B2DPolygon* mpPolygon;
- basegfx::B2DHomMatrix* mpaTransform;
+ std::unique_ptr<basegfx::B2DPolygon> mpPolygon;
+ std::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
bool mbIsPolyline : 1; // true = polyline, false = polygon
@@ -52,11 +52,11 @@ namespace svgio
virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
/// Polygon content, set if found in current context
- void setPolygon(const basegfx::B2DPolygon* pPolygon) { if(mpPolygon) delete mpPolygon; mpPolygon = nullptr; if(pPolygon) mpPolygon = new basegfx::B2DPolygon(*pPolygon); }
+ void setPolygon(const basegfx::B2DPolygon* pPolygon) { mpPolygon.reset(); if(pPolygon) mpPolygon.reset(new basegfx::B2DPolygon(*pPolygon)); }
/// 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)); }
};
} // end of namespace svgreader
} // end of namespace svgio
diff --git a/svgio/source/svgreader/svgpolynode.cxx b/svgio/source/svgreader/svgpolynode.cxx
index 5de5fc87cc0d..14792a838678 100644
--- a/svgio/source/svgreader/svgpolynode.cxx
+++ b/svgio/source/svgreader/svgpolynode.cxx
@@ -40,8 +40,6 @@ namespace svgio
SvgPolyNode::~SvgPolyNode()
{
- delete mpaTransform;
- delete mpPolygon;
}
const SvgStyleAttributes* SvgPolyNode::getSvgStyleAttributes() const
More information about the Libreoffice-commits
mailing list