diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-04 15:04:57 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-11 08:26:23 +0200 |
commit | 8a6722f6453900424b21809bafb649a0592e7626 (patch) | |
tree | b6b2318357ad1a407ff1de8d347452f143b5ed46 /filter/source/xsltdialog | |
parent | eec9f6c8b928de38dd9e683f46bfab00f3243048 (diff) |
loplugin:useuniqueptr in TypeDetectionImporter
Change-Id: I0bb696ccf8555fe597aaff1cb6ab74bf16d81731
Reviewed-on: https://gerrit.libreoffice.org/55520
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'filter/source/xsltdialog')
-rw-r--r-- | filter/source/xsltdialog/typedetectionimport.cxx | 19 | ||||
-rw-r--r-- | filter/source/xsltdialog/typedetectionimport.hxx | 7 |
2 files changed, 11 insertions, 15 deletions
diff --git a/filter/source/xsltdialog/typedetectionimport.cxx b/filter/source/xsltdialog/typedetectionimport.cxx index 2fa37c8c40eb..fd9960e36726 100644 --- a/filter/source/xsltdialog/typedetectionimport.cxx +++ b/filter/source/xsltdialog/typedetectionimport.cxx @@ -70,16 +70,14 @@ void TypeDetectionImporter::fillFilterVector( XMLFilterVector& rFilters ) // create filter infos from imported filter nodes for (auto const& filterNode : maFilterNodes) { - filter_info_impl* pFilter = createFilterForNode(filterNode); + filter_info_impl* pFilter = createFilterForNode(filterNode.get()); if( pFilter ) rFilters.push_back( pFilter ); - - delete filterNode; } + maFilterNodes.clear(); // now delete type nodes - for (auto const& typeNode : maTypeNodes) - delete typeNode; + maTypeNodes.clear(); } static OUString getSubdata( int index, sal_Unicode delimiter, const OUString& rData ) @@ -115,11 +113,10 @@ static OUString getSubdata( int index, sal_Unicode delimiter, const OUString& rD Node* TypeDetectionImporter::findTypeNode( const OUString& rType ) { - // now delete type nodes - for (NodeVector::const_iterator aIter(maTypeNodes.begin()), aEnd(maTypeNodes.end()); aIter != aEnd; ++aIter) + for (auto aIter(maTypeNodes.begin()), aEnd(maTypeNodes.end()); aIter != aEnd; ++aIter) { if( (*aIter)->maName == rType ) - return (*aIter); + return aIter->get(); } return nullptr; @@ -277,18 +274,18 @@ void SAL_CALL TypeDetectionImporter::endElement( const OUString& /* aName */ ) case e_Filter: case e_Type: { - Node* pNode = new Node; + std::unique_ptr<Node> pNode(new Node); pNode->maName = maNodeName; pNode->maPropertyMap = maPropertyMap; maPropertyMap.clear(); if( eCurrentState == e_Filter ) { - maFilterNodes.push_back( pNode ); + maFilterNodes.push_back( std::move(pNode) ); } else { - maTypeNodes.push_back( pNode ); + maTypeNodes.push_back( std::move(pNode) ); } } break; diff --git a/filter/source/xsltdialog/typedetectionimport.hxx b/filter/source/xsltdialog/typedetectionimport.hxx index 1af2b442c824..440e650db9ae 100644 --- a/filter/source/xsltdialog/typedetectionimport.hxx +++ b/filter/source/xsltdialog/typedetectionimport.hxx @@ -28,6 +28,7 @@ #include "xmlfilterjar.hxx" #include <map> +#include <memory> #include <vector> #include <stack> @@ -56,8 +57,6 @@ struct Node PropertyMap maPropertyMap; }; -typedef std::vector< Node* > NodeVector; - class TypeDetectionImporter : public cppu::WeakImplHelper < css::xml::sax::XDocumentHandler > { public: @@ -83,8 +82,8 @@ private: std::stack< ImportState > maStack; PropertyMap maPropertyMap; - NodeVector maFilterNodes; - NodeVector maTypeNodes; + std::vector< std::unique_ptr<Node> > maFilterNodes; + std::vector< std::unique_ptr<Node> > maTypeNodes; OUString maValue; OUString maNodeName; |