diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-25 13:23:48 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-26 08:58:42 +0200 |
commit | 6cc5c6dea2b03a14e051728aa513fb206929ea86 (patch) | |
tree | 1f7f38dbc0ffdf59addbbac239f16bd125bfad36 /svgio/source | |
parent | 0699a18c622149ac6dbc898bf920c47c45ccd5b9 (diff) |
loplugin:useuniqueptr in SvgDocument
Change-Id: I299e97c276b60be86491bfeee22d46774739ca44
Reviewed-on: https://gerrit.libreoffice.org/60969
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svgio/source')
-rw-r--r-- | svgio/source/svgreader/svgdocument.cxx | 12 | ||||
-rw-r--r-- | svgio/source/svgreader/svgdocumenthandler.cxx | 5 | ||||
-rw-r--r-- | svgio/source/svguno/xsvgparser.cxx | 7 |
3 files changed, 7 insertions, 17 deletions
diff --git a/svgio/source/svgreader/svgdocument.cxx b/svgio/source/svgreader/svgdocument.cxx index 44fb0d507eec..716db822a83c 100644 --- a/svgio/source/svgreader/svgdocument.cxx +++ b/svgio/source/svgreader/svgdocument.cxx @@ -33,18 +33,12 @@ namespace svgio SvgDocument::~SvgDocument() { - while(!maNodes.empty()) - { - SvgNode* pCandidate = maNodes[maNodes.size() - 1]; - delete pCandidate; - maNodes.pop_back(); - } } - void SvgDocument::appendNode(SvgNode* pNode) + void SvgDocument::appendNode(std::unique_ptr<SvgNode> pNode) { - OSL_ENSURE(pNode, "OOps, empty node added (!)"); - maNodes.push_back(pNode); + assert(pNode); + maNodes.push_back(std::move(pNode)); } void SvgDocument::addSvgNodeToMapper(const OUString& rStr, const SvgNode& rNode) diff --git a/svgio/source/svgreader/svgdocumenthandler.cxx b/svgio/source/svgreader/svgdocumenthandler.cxx index d8a36c99c073..447221b55215 100644 --- a/svgio/source/svgreader/svgdocumenthandler.cxx +++ b/svgio/source/svgreader/svgdocumenthandler.cxx @@ -153,7 +153,8 @@ namespace svgio mpTarget = const_cast< SvgNode* >(mpTarget->getParent()); const SvgNodeVector& rOwnedTopLevels = maDocument.getSvgNodeVector(); - if (std::find(rOwnedTopLevels.begin(), rOwnedTopLevels.end(), mpTarget) == rOwnedTopLevels.end()) + if (std::none_of(rOwnedTopLevels.begin(), rOwnedTopLevels.end(), + [&](std::unique_ptr<SvgNode> const & p) { return p.get() == mpTarget; })) delete mpTarget; } OSL_ENSURE(!maCssContents.size(), "SvgDocHdl destructed with active css style stack entry (!)"); @@ -487,7 +488,7 @@ namespace svgio if(!mpTarget->getParent()) { // last element closing, save this tree - maDocument.appendNode(mpTarget); + maDocument.appendNode(std::unique_ptr<SvgNode>(mpTarget)); } mpTarget = const_cast< SvgNode* >(mpTarget->getParent()); diff --git a/svgio/source/svguno/xsvgparser.cxx b/svgio/source/svguno/xsvgparser.cxx index 46ada4858a42..2f2a51c5c318 100644 --- a/svgio/source/svguno/xsvgparser.cxx +++ b/svgio/source/svguno/xsvgparser.cxx @@ -143,13 +143,8 @@ namespace svgio } // decompose to primitives - const SvgNodeVector& rResults = pSvgDocHdl->getSvgDocument().getSvgNodeVector(); - const sal_uInt32 nCount(rResults.size()); - - for(sal_uInt32 a(0); a < nCount; a++) + for(std::unique_ptr<SvgNode> const & pCandidate : pSvgDocHdl->getSvgDocument().getSvgNodeVector()) { - SvgNode* pCandidate = rResults[a]; - if(Display_none != pCandidate->getDisplay()) { pCandidate->decomposeSvgNode(aRetval, false); |