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

loplugin:useuniqueptr in XMLEventImportHelper

Change-Id: I44e6e1fdb49f4392b22745581205b840b8a8af49
Reviewed-on: https://gerrit.libreoffice.org/60617
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 9fe3839f
......@@ -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 );
......
......@@ -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;
......
......@@ -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(
......
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