sd/source/ui/framework/module/ModuleController.cxx |   39 ++++-----------------
 sd/source/ui/inc/framework/ModuleController.hxx    |    8 ++--
 2 files changed, 12 insertions(+), 35 deletions(-)

New commits:
commit 3365e860d44b3396a5c1dd10e3f8db9c5da0ce02
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Tue Dec 28 17:15:59 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Dec 29 10:58:10 2021 +0100

    flatten ModuleController a little
    
    no need to allocate these maps separately
    
    Change-Id: If83f6540933716ab720778740a1e20f0bb14fd7d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127649
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sd/source/ui/framework/module/ModuleController.cxx 
b/sd/source/ui/framework/module/ModuleController.cxx
index 855a4bdd3efe..acd12ec8ad4b 100644
--- a/sd/source/ui/framework/module/ModuleController.cxx
+++ b/sd/source/ui/framework/module/ModuleController.cxx
@@ -24,8 +24,6 @@
 
 #include <tools/ConfigurationAccess.hxx>
 #include <comphelper/processfactory.hxx>
-#include <cppuhelper/weakref.hxx>
-#include <unordered_map>
 
 #include <tools/diagnose_ex.h>
 #include <sal/log.hxx>
@@ -40,24 +38,6 @@ namespace sd::framework {
 const sal_uInt32 snFactoryPropertyCount (2);
 const sal_uInt32 snStartupPropertyCount (1);
 
-class ModuleController::ResourceToFactoryMap
-    : public std::unordered_map<
-    OUString,
-    OUString>
-{
-public:
-    ResourceToFactoryMap() {}
-};
-
-class ModuleController::LoadedFactoryContainer
-    : public std::unordered_map<
-    OUString,
-    WeakReference<XInterface>>
-{
-public:
-    LoadedFactoryContainer() {}
-};
-
 //===== ModuleController ======================================================
 Reference<XModuleController> ModuleController::CreateInstance (
     const Reference<XComponentContext>& rxContext)
@@ -66,8 +46,6 @@ Reference<XModuleController> ModuleController::CreateInstance 
(
 }
 
 ModuleController::ModuleController (const Reference<XComponentContext>& 
rxContext)
-    : mpResourceToFactoryMap(new ResourceToFactoryMap()),
-      mpLoadedFactories(new LoadedFactoryContainer())
 {
     /** Load a list of URL to service mappings from the
         /org.openoffice.Office.Impress/MultiPaneGUI/Framework/ResourceFactories
@@ -106,8 +84,8 @@ ModuleController::~ModuleController() noexcept
 void ModuleController::disposing(std::unique_lock<std::mutex>&)
 {
     // Break the cyclic reference back to DrawController object
-    mpLoadedFactories.reset();
-    mpResourceToFactoryMap.reset();
+    maLoadedFactories.clear();
+    maResourceToFactoryMap.clear();
     mxController.clear();
 }
 
@@ -132,7 +110,7 @@ void ModuleController::ProcessFactory (const 
::std::vector<Any>& rValues)
     // Add the resource URLs to the map.
     for (const auto& rResource : aURLs)
     {
-        (*mpResourceToFactoryMap)[rResource] = sServiceName;
+        maResourceToFactoryMap[rResource] = sServiceName;
         SAL_INFO("sd.fwk", __func__ << ":    " << rResource);
     }
 }
@@ -196,16 +174,15 @@ void ModuleController::ProcessStartupService (const 
::std::vector<Any>& rValues)
 
 void SAL_CALL ModuleController::requestResource (const OUString& rsResourceURL)
 {
-    ResourceToFactoryMap::const_iterator iFactory 
(mpResourceToFactoryMap->find(rsResourceURL));
-    if (iFactory == mpResourceToFactoryMap->end())
+    auto iFactory = maResourceToFactoryMap.find(rsResourceURL);
+    if (iFactory == maResourceToFactoryMap.end())
         return;
 
     // Check that the factory has already been loaded and not been
     // destroyed in the meantime.
     Reference<XInterface> xFactory;
-    LoadedFactoryContainer::const_iterator iLoadedFactory (
-        mpLoadedFactories->find(iFactory->second));
-    if (iLoadedFactory != mpLoadedFactories->end())
+    auto iLoadedFactory = maLoadedFactories.find(iFactory->second);
+    if (iLoadedFactory != maLoadedFactories.end())
         xFactory.set(iLoadedFactory->second, UNO_QUERY);
     if (  xFactory.is())
         return;
@@ -229,7 +206,7 @@ void SAL_CALL ModuleController::requestResource (const 
OUString& rsResourceURL)
     }
 
     // Remember that this factory has been instanced.
-    (*mpLoadedFactories)[iFactory->second] = xFactory;
+    maLoadedFactories[iFactory->second] = xFactory;
 }
 
 //----- XInitialization -------------------------------------------------------
diff --git a/sd/source/ui/inc/framework/ModuleController.hxx 
b/sd/source/ui/inc/framework/ModuleController.hxx
index fb9e4bc2d92d..cd4d4e92ca3b 100644
--- a/sd/source/ui/inc/framework/ModuleController.hxx
+++ b/sd/source/ui/inc/framework/ModuleController.hxx
@@ -22,8 +22,10 @@
 #include <com/sun/star/drawing/framework/XModuleController.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <comphelper/compbase.hxx>
+#include <cppuhelper/weakref.hxx>
 
 #include <memory>
+#include <unordered_map>
 
 namespace com::sun::star::frame { class XController; }
 namespace com::sun::star::uno { class XComponentContext; }
@@ -78,10 +80,8 @@ private:
     css::uno::Reference<
         css::frame::XController> mxController;
 
-    class ResourceToFactoryMap;
-    std::unique_ptr<ResourceToFactoryMap> mpResourceToFactoryMap;
-    class LoadedFactoryContainer;
-    std::unique_ptr<LoadedFactoryContainer> mpLoadedFactories;
+    std::unordered_map<OUString, OUString> maResourceToFactoryMap;
+    std::unordered_map<OUString, 
css::uno::WeakReference<css::uno::XInterface>> maLoadedFactories;
 
     /// @throws std::exception
     ModuleController (

Reply via email to