diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-10-17 12:39:08 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-10-17 14:05:14 +0200 |
commit | d6831a8a34257789a920491747e12ebe62f927fe (patch) | |
tree | 31f12e3b237b75710ddf064ad367e195fde10c2c /xmlscript | |
parent | 7a72f593dada6a7b3231a599772aed8be7d5a62f (diff) |
loplugin:useuniqueptr in StyleBag
Change-Id: I965b086338935aa91691b96a63c9bc95f8b7f7ca
Reviewed-on: https://gerrit.libreoffice.org/43452
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlscript')
-rw-r--r-- | xmlscript/source/xmldlg_imexp/exp_share.hxx | 3 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_export.cxx | 14 |
2 files changed, 7 insertions, 10 deletions
diff --git a/xmlscript/source/xmldlg_imexp/exp_share.hxx b/xmlscript/source/xmldlg_imexp/exp_share.hxx index 661f356c5869..825db80f598c 100644 --- a/xmlscript/source/xmldlg_imexp/exp_share.hxx +++ b/xmlscript/source/xmldlg_imexp/exp_share.hxx @@ -31,6 +31,7 @@ #include <com/sun/star/awt/FontDescriptor.hpp> #include <com/sun/star/awt/FontEmphasisMark.hpp> #include <com/sun/star/awt/FontRelief.hpp> +#include <memory> #include <vector> @@ -75,7 +76,7 @@ struct Style }; class StyleBag { - ::std::vector< Style * > _styles; + ::std::vector< std::unique_ptr<Style> > _styles; public: ~StyleBag() ; diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx index 6238f6945e76..9dab7b525b9b 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx @@ -1262,7 +1262,7 @@ OUString StyleBag::getStyleId( Style const & rStyle ) } // lookup existing style - for (Style* pStyle : _styles) + for (auto const & pStyle : _styles) { short demanded_defaults = ~rStyle._set & rStyle._all; // test, if defaults are not set @@ -1324,18 +1324,14 @@ OUString StyleBag::getStyleId( Style const & rStyle ) } // no appr style found, append new - Style * pStyle = new Style( rStyle ); + std::unique_ptr<Style> pStyle(new Style( rStyle )); pStyle->_id = OUString::number( _styles.size() ); - _styles.push_back( pStyle ); - return pStyle->_id; + _styles.push_back( std::move(pStyle) ); + return _styles.back()->_id; } StyleBag::~StyleBag() { - for (Style* _style : _styles) - { - delete _style; - } } void StyleBag::dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOut ) @@ -1346,7 +1342,7 @@ void StyleBag::dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOu xOut->ignorableWhitespace( OUString() ); xOut->startElement( aStylesName, Reference< xml::sax::XAttributeList >() ); // export styles - for (Style* _style : _styles) + for (auto const & _style : _styles) { Reference< xml::sax::XAttributeList > xAttr( _style->createElement() ); static_cast< ElementDescriptor * >( xAttr.get() )->dump( xOut.get() ); |