Kaydet (Commit) 3b8cd4f9 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in SvgNode

Change-Id: I7ab382bd90050302c24464eed645d20a435dbd63
Reviewed-on: https://gerrit.libreoffice.org/50657Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst a7205fd0
...@@ -91,7 +91,7 @@ namespace svgio ...@@ -91,7 +91,7 @@ namespace svgio
const SvgNode* mpAlternativeParent; const SvgNode* mpAlternativeParent;
/// sub hierarchy /// sub hierarchy
SvgNodeVector maChildren; std::vector< std::unique_ptr<SvgNode> > maChildren;
/// Id svan value /// Id svan value
std::unique_ptr<OUString> mpId; std::unique_ptr<OUString> mpId;
...@@ -111,7 +111,7 @@ namespace svgio ...@@ -111,7 +111,7 @@ namespace svgio
::std::vector< const SvgStyleAttributes* > maCssStyleVector; ::std::vector< const SvgStyleAttributes* > maCssStyleVector;
/// possible local CssStyle, e.g. style="fill:red; stroke:red;" /// 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) // flag if maCssStyleVector is already computed (done only once)
bool mbCssStyleVectorBuilt : 1; bool mbCssStyleVectorBuilt : 1;
...@@ -152,7 +152,7 @@ namespace svgio ...@@ -152,7 +152,7 @@ namespace svgio
SVGToken getType() const { return maType; } SVGToken getType() const { return maType; }
const SvgDocument& getDocument() const { return mrDocument; } const SvgDocument& getDocument() const { return mrDocument; }
const SvgNode* getParent() const { if(mpAlternativeParent) return mpAlternativeParent; return mpParent; } 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 /// InfoProvider support for %, em and ex values
virtual const basegfx::B2DRange getCurrentViewPort() const override; virtual const basegfx::B2DRange getCurrentViewPort() const override;
......
...@@ -54,12 +54,12 @@ namespace ...@@ -54,12 +54,12 @@ namespace
{ {
if(pNode) if(pNode)
{ {
const svgio::svgreader::SvgNodeVector& rChilds = pNode->getChildren(); const auto& rChilds = pNode->getChildren();
const sal_uInt32 nCount(rChilds.size()); const sal_uInt32 nCount(rChilds.size());
for(sal_uInt32 a(0); a < nCount; a++) for(sal_uInt32 a(0); a < nCount; a++)
{ {
svgio::svgreader::SvgNode* pCandidate = rChilds[a]; svgio::svgreader::SvgNode* pCandidate = rChilds[a].get();
if(pCandidate) if(pCandidate)
{ {
...@@ -564,12 +564,12 @@ namespace svgio ...@@ -564,12 +564,12 @@ namespace svgio
case SVGTokenTspan: case SVGTokenTspan:
case SVGTokenTextPath: case SVGTokenTextPath:
{ {
const SvgNodeVector& rChilds = mpTarget->getChildren(); const auto& rChilds = mpTarget->getChildren();
SvgCharacterNode* pTarget = nullptr; SvgCharacterNode* pTarget = nullptr;
if(rChilds.size()) if(rChilds.size())
{ {
pTarget = dynamic_cast< SvgCharacterNode* >(rChilds[rChilds.size() - 1]); pTarget = dynamic_cast< SvgCharacterNode* >(rChilds[rChilds.size() - 1].get());
} }
if(pTarget) if(pTarget)
......
...@@ -257,7 +257,7 @@ namespace svgio ...@@ -257,7 +257,7 @@ namespace svgio
for(sal_uInt32 a(0); a < nCount; a++) 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) if(pCandidate)
{ {
......
...@@ -185,7 +185,7 @@ namespace svgio ...@@ -185,7 +185,7 @@ namespace svgio
if(mpLocalCssStyle) if(mpLocalCssStyle)
{ {
// if we have one, use as first entry // 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 // check the hierarchy for concatenated patterns of Selectors
...@@ -275,7 +275,7 @@ namespace svgio ...@@ -275,7 +275,7 @@ namespace svgio
if(pParent) if(pParent)
{ {
pParent->maChildren.push_back(this); pParent->maChildren.emplace_back(this);
} }
else else
{ {
...@@ -290,13 +290,6 @@ namespace svgio ...@@ -290,13 +290,6 @@ namespace svgio
SvgNode::~SvgNode() SvgNode::~SvgNode()
{ {
while(maChildren.size())
{
delete maChildren[maChildren.size() - 1];
maChildren.pop_back();
}
delete mpLocalCssStyle;
} }
void SvgNode::readLocalCssStyle(const OUString& aContent) void SvgNode::readLocalCssStyle(const OUString& aContent)
...@@ -304,7 +297,7 @@ namespace svgio ...@@ -304,7 +297,7 @@ namespace svgio
if(!mpLocalCssStyle) if(!mpLocalCssStyle)
{ {
// create LocalCssStyle if needed but not yet added // create LocalCssStyle if needed but not yet added
mpLocalCssStyle = new SvgStyleAttributes(*this); mpLocalCssStyle.reset(new SvgStyleAttributes(*this));
} }
else else
{ {
...@@ -504,7 +497,7 @@ namespace svgio ...@@ -504,7 +497,7 @@ namespace svgio
} }
} }
const SvgNodeVector& rChildren = getChildren(); const auto& rChildren = getChildren();
if(!rChildren.empty()) if(!rChildren.empty())
{ {
...@@ -512,11 +505,11 @@ namespace svgio ...@@ -512,11 +505,11 @@ namespace svgio
for(sal_uInt32 a(0); a < nCount; a++) for(sal_uInt32 a(0); a < nCount; a++)
{ {
SvgNode* pCandidate = rChildren[a]; SvgNode* pCandidate = rChildren[a].get();
if(pCandidate && Display_none != pCandidate->getDisplay()) if(pCandidate && Display_none != pCandidate->getDisplay())
{ {
const SvgNodeVector& rGrandChildren = pCandidate->getChildren(); const auto& rGrandChildren = pCandidate->getChildren();
const SvgStyleAttributes* pChildStyles = pCandidate->getSvgStyleAttributes(); const SvgStyleAttributes* pChildStyles = pCandidate->getSvgStyleAttributes();
// decompose: // decompose:
// - visible terminal nodes // - visible terminal nodes
......
...@@ -123,7 +123,7 @@ namespace svgio ...@@ -123,7 +123,7 @@ namespace svgio
{ {
// direct TextPath decompose // direct TextPath decompose
const SvgTextPathNode& rSvgTextPathNode = static_cast< const SvgTextPathNode& >(rCandidate); const SvgTextPathNode& rSvgTextPathNode = static_cast< const SvgTextPathNode& >(rCandidate);
const SvgNodeVector& rChildren = rSvgTextPathNode.getChildren(); const auto& rChildren = rSvgTextPathNode.getChildren();
const sal_uInt32 nCount(rChildren.size()); const sal_uInt32 nCount(rChildren.size());
if(nCount && rSvgTextPathNode.isValid()) if(nCount && rSvgTextPathNode.isValid())
...@@ -159,7 +159,7 @@ namespace svgio ...@@ -159,7 +159,7 @@ namespace svgio
{ {
// Tspan may have children, call recursively // Tspan may have children, call recursively
const SvgTspanNode& rSvgTspanNode = static_cast< const SvgTspanNode& >(rCandidate); const SvgTspanNode& rSvgTspanNode = static_cast< const SvgTspanNode& >(rCandidate);
const SvgNodeVector& rChildren = rSvgTspanNode.getChildren(); const auto& rChildren = rSvgTspanNode.getChildren();
const sal_uInt32 nCount(rChildren.size()); const sal_uInt32 nCount(rChildren.size());
if(nCount) if(nCount)
...@@ -188,7 +188,7 @@ namespace svgio ...@@ -188,7 +188,7 @@ namespace svgio
if(pRefText) if(pRefText)
{ {
const SvgNodeVector& rChildren = pRefText->getChildren(); const auto& rChildren = pRefText->getChildren();
const sal_uInt32 nCount(rChildren.size()); const sal_uInt32 nCount(rChildren.size());
drawinglayer::primitive2d::Primitive2DContainer aNewTarget; drawinglayer::primitive2d::Primitive2DContainer aNewTarget;
...@@ -234,7 +234,7 @@ namespace svgio ...@@ -234,7 +234,7 @@ namespace svgio
{ {
SvgTextPosition aSvgTextPosition(nullptr, *this, maSvgTextPositions); SvgTextPosition aSvgTextPosition(nullptr, *this, maSvgTextPositions);
drawinglayer::primitive2d::Primitive2DContainer aNewTarget; drawinglayer::primitive2d::Primitive2DContainer aNewTarget;
const SvgNodeVector& rChildren = getChildren(); const auto& rChildren = getChildren();
const sal_uInt32 nCount(rChildren.size()); const sal_uInt32 nCount(rChildren.size());
for(sal_uInt32 a(0); a < nCount; a++) for(sal_uInt32 a(0); a < nCount; a++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment