sd/source/ui/framework/module/ModuleController.cxx | 16 ++++++++-------- sd/source/ui/inc/framework/ModuleController.hxx | 13 ++++++++++--- 2 files changed, 18 insertions(+), 11 deletions(-)
New commits: commit 6ccb93486099798b8759b7e6e0ba0cdbb63c7d77 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sat Jun 28 21:50:33 2025 +0200 Commit: Noel Grandin <noelgran...@gmail.com> CommitDate: Sun Jun 29 18:42:34 2025 +0200 use enum class for factory in ModuleController it is one of 3 options, no need to use strings here Change-Id: I77bedaabd202272e657fac3cda670fe7847b6725 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187141 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 2ed5fe2e3c10..e253a4fa28be 100644 --- a/sd/source/ui/framework/module/ModuleController.cxx +++ b/sd/source/ui/framework/module/ModuleController.cxx @@ -48,13 +48,13 @@ ModuleController::ModuleController(const rtl::Reference<::sd::DrawController>& r mpResourceToFactoryMap member. */ ProcessFactory( - u"com.sun.star.drawing.framework.BasicPaneFactory"_ustr, + ResourceFactoryId::BasicPaneFactory, { u"private:resource/pane/CenterPane"_ustr, u"private:resource/pane/LeftImpressPane"_ustr, u"private:resource/pane/BottomImpressPane"_ustr, u"private:resource/pane/LeftDrawPane"_ustr }); ProcessFactory( - u"com.sun.star.drawing.framework.BasicViewFactory"_ustr, + ResourceFactoryId::BasicViewFactory, { u"private:resource/view/ImpressView"_ustr, u"private:resource/view/GraphicView"_ustr, u"private:resource/view/OutlineView"_ustr, @@ -64,7 +64,7 @@ ModuleController::ModuleController(const rtl::Reference<::sd::DrawController>& r u"private:resource/view/SlideSorter"_ustr, u"private:resource/view/PresentationView"_ustr }); ProcessFactory( - u"com.sun.star.drawing.framework.BasicToolBarFactory"_ustr, + ResourceFactoryId::BasicToolBarFactory, { u"private:resource/toolbar/ViewTabBar"_ustr }); try @@ -89,11 +89,11 @@ void ModuleController::disposing(std::unique_lock<std::mutex>&) mxController.clear(); } -void ModuleController::ProcessFactory (const OUString& sServiceName, ::std::vector<OUString> aURLs) +void ModuleController::ProcessFactory (ResourceFactoryId sServiceName, ::std::vector<OUString> aURLs) { // Get all resource URLs that are created by the factory. - SAL_INFO("sd.fwk", __func__ << ": ModuleController::adding factory " << sServiceName); + SAL_INFO("sd.fwk", __func__ << ": ModuleController::adding factory " << static_cast<int>(sServiceName)); // Add the resource URLs to the map. for (const auto& rResource : aURLs) @@ -136,11 +136,11 @@ void ModuleController::requestResource (const OUString& rsResourceURL) return; // Create the factory service. - if (iFactory->second == "com.sun.star.drawing.framework.BasicPaneFactory") + if (iFactory->second == ResourceFactoryId::BasicPaneFactory) xFactory = new BasicPaneFactory(mxController); - else if (iFactory->second == "com.sun.star.drawing.framework.BasicViewFactory") + else if (iFactory->second == ResourceFactoryId::BasicViewFactory) xFactory = new BasicViewFactory(mxController); - else if (iFactory->second == "com.sun.star.drawing.framework.BasicToolBarFactory") + else if (iFactory->second == ResourceFactoryId::BasicToolBarFactory) xFactory = new BasicToolBarFactory(mxController); else throw RuntimeException(u"unknown factory"_ustr); diff --git a/sd/source/ui/inc/framework/ModuleController.hxx b/sd/source/ui/inc/framework/ModuleController.hxx index 4471235eb8d8..268b0a5ad453 100644 --- a/sd/source/ui/inc/framework/ModuleController.hxx +++ b/sd/source/ui/inc/framework/ModuleController.hxx @@ -31,6 +31,13 @@ namespace sd { class DrawController; } namespace sd::framework { class ResourceFactory; +enum class ResourceFactoryId +{ + BasicPaneFactory, + BasicViewFactory, + BasicToolBarFactory +}; + typedef comphelper::WeakComponentImplHelper <> ModuleControllerInterfaceBase; /** The ModuleController has two tasks: @@ -67,15 +74,15 @@ public: private: rtl::Reference<::sd::DrawController> mxController; - std::unordered_map<OUString, OUString> maResourceToFactoryMap; - std::unordered_map<OUString, unotools::WeakReference<sd::framework::ResourceFactory>> maLoadedFactories; + std::unordered_map<OUString, ResourceFactoryId> maResourceToFactoryMap; + std::unordered_map<ResourceFactoryId, unotools::WeakReference<sd::framework::ResourceFactory>> maLoadedFactories; ModuleController (const ModuleController&) = delete; virtual ~ModuleController() noexcept override; /** Called for every entry in the ResourceFactories configuration entry. */ - void ProcessFactory (const OUString& ServiceName, ::std::vector<OUString> aURLs); + void ProcessFactory (ResourceFactoryId ServiceName, ::std::vector<OUString> aURLs); /** Instantiate startup services. This method is called once when a new ModuleController object is created.