diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-17 09:37:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-19 08:45:42 +0200 |
commit | cde84694f094a317e3bb57aaaf244b0363ef5cc5 (patch) | |
tree | 9d1e61bc579151054f8d0c6de6ac2217590f4689 /xmloff | |
parent | 9fe3839fed4488ee7ad47bd877a6978d118891a3 (diff) |
loplugin:useuniqueptr in XMLEventImportHelper
Change-Id: I44e6e1fdb49f4392b22745581205b840b8a8af49
Reviewed-on: https://gerrit.libreoffice.org/60617
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/inc/XMLEventImportHelper.hxx | 4 | ||||
-rw-r--r-- | xmloff/source/core/xmlimp.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/script/XMLEventImportHelper.cxx | 13 |
3 files changed, 8 insertions, 15 deletions
diff --git a/xmloff/inc/XMLEventImportHelper.hxx b/xmloff/inc/XMLEventImportHelper.hxx index 99d03999ec25..6e4c8dce9fd6 100644 --- a/xmloff/inc/XMLEventImportHelper.hxx +++ b/xmloff/inc/XMLEventImportHelper.hxx @@ -35,7 +35,7 @@ class XMLEventContextFactory; class XMLEventsImportContext; struct XMLEventNameTranslation; -typedef ::std::map< OUString, XMLEventContextFactory* > FactoryMap; +typedef ::std::map< OUString, std::unique_ptr<XMLEventContextFactory> > FactoryMap; typedef ::std::map< XMLEventName, OUString > NameMap; @@ -70,7 +70,7 @@ public: /// register a handler for a particular language type void RegisterFactory( const OUString& rLanguage, - XMLEventContextFactory* aFactory ); + std::unique_ptr<XMLEventContextFactory> aFactory ); /// add event name translation to the internal table void AddTranslationTable( const XMLEventNameTranslation* pTransTable ); diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 841487b296cf..d2186d706bde 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -1594,15 +1594,15 @@ XMLEventImportHelper& SvXMLImport::GetEventImport() mpEventImportHelper = o3tl::make_unique<XMLEventImportHelper>(); const OUString& sStarBasic(GetXMLToken(XML_STARBASIC)); mpEventImportHelper->RegisterFactory(sStarBasic, - new XMLStarBasicContextFactory()); + o3tl::make_unique<XMLStarBasicContextFactory>()); const OUString& sScript(GetXMLToken(XML_SCRIPT)); mpEventImportHelper->RegisterFactory(sScript, - new XMLScriptContextFactory()); + o3tl::make_unique<XMLScriptContextFactory>()); mpEventImportHelper->AddTranslationTable(aStandardEventTable); // register StarBasic event handler with capitalized spelling mpEventImportHelper->RegisterFactory("StarBasic", - new XMLStarBasicContextFactory()); + o3tl::make_unique<XMLStarBasicContextFactory>()); } return *mpEventImportHelper; diff --git a/xmloff/source/script/XMLEventImportHelper.cxx b/xmloff/source/script/XMLEventImportHelper.cxx index 0a719dee5d31..6626598f5688 100644 --- a/xmloff/source/script/XMLEventImportHelper.cxx +++ b/xmloff/source/script/XMLEventImportHelper.cxx @@ -40,10 +40,6 @@ XMLEventImportHelper::XMLEventImportHelper() : XMLEventImportHelper::~XMLEventImportHelper() { // delete factories - for(auto& rEntry : aFactoryMap) - { - delete rEntry.second; - } aFactoryMap.clear(); // delete name map @@ -52,13 +48,10 @@ XMLEventImportHelper::~XMLEventImportHelper() void XMLEventImportHelper::RegisterFactory( const OUString& rLanguage, - XMLEventContextFactory* pFactory ) + std::unique_ptr<XMLEventContextFactory> pFactory ) { - DBG_ASSERT(pFactory != nullptr, "I need a factory."); - if (nullptr != pFactory) - { - aFactoryMap[rLanguage] = pFactory; - } + assert(pFactory); + aFactoryMap[rLanguage] = std::move(pFactory); } void XMLEventImportHelper::AddTranslationTable( |