sd/source/ui/framework/factories/BasicPaneFactory.cxx | 56 ++++++-------- sd/source/ui/framework/module/ModuleController.cxx | 6 - sd/source/ui/inc/framework/factories/BasicPaneFactory.hxx | 10 +- 3 files changed, 29 insertions(+), 43 deletions(-)
New commits: commit 9d4f9cd2c560feb821b368097ec86079b316e7f6 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue May 13 20:45:07 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu May 15 06:48:01 2025 +0200 sd: Don't use std::unique_ptr for BasicPaneFactory::mpPaneContainer There's no need for it, so use a simple PaneContainer (a.k.a. std::vector<PaneDescriptor>). Change-Id: I57f67cadb2eeb9f328bdf229827d50810bb54574 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185277 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/sd/source/ui/framework/factories/BasicPaneFactory.cxx b/sd/source/ui/framework/factories/BasicPaneFactory.cxx index 4b07d5892c3a..7ff9043d330c 100644 --- a/sd/source/ui/framework/factories/BasicPaneFactory.cxx +++ b/sd/source/ui/framework/factories/BasicPaneFactory.cxx @@ -81,8 +81,7 @@ public: BasicPaneFactory::BasicPaneFactory( const rtl::Reference<::sd::DrawController>& rxController) - : mpViewShellBase(nullptr), - mpPaneContainer(new PaneContainer) + : mpViewShellBase(nullptr) { try { @@ -100,27 +99,27 @@ BasicPaneFactory::BasicPaneFactory( aDescriptor.msPaneURL = FrameworkHelper::msCenterPaneURL; aDescriptor.mePaneId = CenterPaneId; aDescriptor.mbIsReleased = false; - mpPaneContainer->push_back(aDescriptor); + maPaneContainer.push_back(aDescriptor); xCC->addResourceFactory(aDescriptor.msPaneURL, this); aDescriptor.msPaneURL = FrameworkHelper::msFullScreenPaneURL; aDescriptor.mePaneId = FullScreenPaneId; - mpPaneContainer->push_back(aDescriptor); + maPaneContainer.push_back(aDescriptor); xCC->addResourceFactory(aDescriptor.msPaneURL, this); aDescriptor.msPaneURL = FrameworkHelper::msLeftImpressPaneURL; aDescriptor.mePaneId = LeftImpressPaneId; - mpPaneContainer->push_back(aDescriptor); + maPaneContainer.push_back(aDescriptor); xCC->addResourceFactory(aDescriptor.msPaneURL, this); aDescriptor.msPaneURL = FrameworkHelper::msBottomImpressPaneURL; aDescriptor.mePaneId = BottomImpressPaneId; - mpPaneContainer->push_back(aDescriptor); + maPaneContainer.push_back(aDescriptor); xCC->addResourceFactory(aDescriptor.msPaneURL, this); aDescriptor.msPaneURL = FrameworkHelper::msLeftDrawPaneURL; aDescriptor.mePaneId = LeftDrawPaneId; - mpPaneContainer->push_back(aDescriptor); + maPaneContainer.push_back(aDescriptor); xCC->addResourceFactory(aDescriptor.msPaneURL, this); } @@ -159,7 +158,7 @@ void BasicPaneFactory::disposing(std::unique_lock<std::mutex>&) mxConfigurationControllerWeak.clear(); } - for (const auto& rDescriptor : *mpPaneContainer) + for (const auto& rDescriptor : maPaneContainer) { if (rDescriptor.mbIsReleased) { @@ -186,13 +185,13 @@ Reference<XResource> SAL_CALL BasicPaneFactory::createResource ( // corresponding factory descriptor. PaneContainer::iterator iDescriptor ( ::std::find_if ( - mpPaneContainer->begin(), - mpPaneContainer->end(), + maPaneContainer.begin(), + maPaneContainer.end(), [&] (PaneDescriptor const& rPane) { return rPane.CompareURL(rxPaneId->getResourceURL()); } )); - if (iDescriptor == mpPaneContainer->end()) + if (iDescriptor == maPaneContainer.end()) { // The requested pane can not be created by any of the factories // managed by the called BasicPaneFactory object. @@ -250,11 +249,11 @@ void SAL_CALL BasicPaneFactory::releaseResource ( // descriptor. PaneContainer::iterator iDescriptor ( ::std::find_if( - mpPaneContainer->begin(), - mpPaneContainer->end(), + maPaneContainer.begin(), + maPaneContainer.end(), [&] (PaneDescriptor const& rPane) { return rPane.ComparePane(rxPane); } )); - if (iDescriptor == mpPaneContainer->end()) + if (iDescriptor == maPaneContainer.end()) { // The given XPane reference is either empty or the pane was not // created by any of the factories managed by the called @@ -313,11 +312,11 @@ void SAL_CALL BasicPaneFactory::disposing ( // reference to that pane, but not the pane descriptor. Reference<XResource> xPane (rEventObject.Source, UNO_QUERY); PaneContainer::iterator iDescriptor ( - ::std::find_if ( - mpPaneContainer->begin(), - mpPaneContainer->end(), + ::std::find_if( + maPaneContainer.begin(), + maPaneContainer.end(), [&] (PaneDescriptor const& rPane) { return rPane.ComparePane(xPane); } )); - if (iDescriptor != mpPaneContainer->end()) + if (iDescriptor != maPaneContainer.end()) { iDescriptor->mxPane = nullptr; } diff --git a/sd/source/ui/inc/framework/factories/BasicPaneFactory.hxx b/sd/source/ui/inc/framework/factories/BasicPaneFactory.hxx index 1867bc01167c..7af0d2cd5515 100644 --- a/sd/source/ui/inc/framework/factories/BasicPaneFactory.hxx +++ b/sd/source/ui/inc/framework/factories/BasicPaneFactory.hxx @@ -88,7 +88,8 @@ private: ViewShellBase* mpViewShellBase; class PaneDescriptor; using PaneContainer = std::vector<PaneDescriptor>; - std::unique_ptr<PaneContainer> mpPaneContainer; + + PaneContainer maPaneContainer; /** Create a new instance of FrameWindowPane. @param rPaneId commit 925b644ee1d3ad74539f91410e6fbdcb0d015c1a Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue May 13 20:41:01 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu May 15 06:47:53 2025 +0200 sd: Don't subclass std::vector ... without adding any additional functionality. Just use a std::vector. Change-Id: I159c789cbf88ae7a4c781829a75eb20b5cd39b6d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185276 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/sd/source/ui/framework/factories/BasicPaneFactory.cxx b/sd/source/ui/framework/factories/BasicPaneFactory.cxx index b4f616514518..4b07d5892c3a 100644 --- a/sd/source/ui/framework/factories/BasicPaneFactory.cxx +++ b/sd/source/ui/framework/factories/BasicPaneFactory.cxx @@ -77,13 +77,6 @@ public: bool ComparePane(const Reference<XResource>& rxPane) const { return mxPane == rxPane; } }; -class BasicPaneFactory::PaneContainer - : public ::std::vector<PaneDescriptor> -{ -public: - PaneContainer() {} -}; - //===== PaneFactory =========================================================== BasicPaneFactory::BasicPaneFactory( diff --git a/sd/source/ui/inc/framework/factories/BasicPaneFactory.hxx b/sd/source/ui/inc/framework/factories/BasicPaneFactory.hxx index 0cdbf05adf64..1867bc01167c 100644 --- a/sd/source/ui/inc/framework/factories/BasicPaneFactory.hxx +++ b/sd/source/ui/inc/framework/factories/BasicPaneFactory.hxx @@ -87,7 +87,7 @@ private: mxConfigurationControllerWeak; ViewShellBase* mpViewShellBase; class PaneDescriptor; - class PaneContainer; + using PaneContainer = std::vector<PaneDescriptor>; std::unique_ptr<PaneContainer> mpPaneContainer; /** Create a new instance of FrameWindowPane. commit 8eea65864995b01009bec187fa924e90e57b960f Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue May 13 20:30:01 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu May 15 06:47:46 2025 +0200 sd: Retrieve component context where needed Call comphelper::getProcessComponentContext in BasicPaneFactory::CreateFullScreenPane instead of further up and then passing it all the way down there. Change-Id: I150ec095fe9f590db403adcf07dc0a8e72613c98 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185275 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/sd/source/ui/framework/factories/BasicPaneFactory.cxx b/sd/source/ui/framework/factories/BasicPaneFactory.cxx index 3eb22471dbdf..b4f616514518 100644 --- a/sd/source/ui/framework/factories/BasicPaneFactory.cxx +++ b/sd/source/ui/framework/factories/BasicPaneFactory.cxx @@ -26,6 +26,7 @@ #include "FrameWindowPane.hxx" #include "FullScreenPane.hxx" +#include <comphelper/processfactory.hxx> #include <comphelper/servicehelper.hxx> #include <framework/FrameworkHelper.hxx> #include <framework/ConfigurationController.hxx> @@ -85,11 +86,9 @@ public: //===== PaneFactory =========================================================== -BasicPaneFactory::BasicPaneFactory ( - const Reference<XComponentContext>& rxContext, +BasicPaneFactory::BasicPaneFactory( const rtl::Reference<::sd::DrawController>& rxController) - : mxComponentContext(rxContext), - mpViewShellBase(nullptr), + : mpViewShellBase(nullptr), mpPaneContainer(new PaneContainer) { try @@ -225,7 +224,7 @@ Reference<XResource> SAL_CALL BasicPaneFactory::createResource ( break; case FullScreenPaneId: - xPane = CreateFullScreenPane(mxComponentContext, rxPaneId); + xPane = CreateFullScreenPane(rxPaneId); break; case LeftImpressPaneId: @@ -341,13 +340,14 @@ Reference<XResource> BasicPaneFactory::CreateFrameWindowPane ( return new FrameWindowPane(rxPaneId, mpViewShellBase->GetViewWindow()); } -Reference<XResource> BasicPaneFactory::CreateFullScreenPane ( - const Reference<XComponentContext>& rxComponentContext, +Reference<XResource> BasicPaneFactory::CreateFullScreenPane( const Reference<XResourceId>& rxPaneId) { + const Reference<uno::XComponentContext>& xContext = comphelper::getProcessComponentContext(); + Reference<XResource> xPane ( new FullScreenPane( - rxComponentContext, + xContext, rxPaneId, mpViewShellBase->GetViewWindow(), mpViewShellBase->GetDocShell())); diff --git a/sd/source/ui/framework/module/ModuleController.cxx b/sd/source/ui/framework/module/ModuleController.cxx index 4afbefe19642..1e53089d7c6b 100644 --- a/sd/source/ui/framework/module/ModuleController.cxx +++ b/sd/source/ui/framework/module/ModuleController.cxx @@ -138,13 +138,9 @@ void SAL_CALL ModuleController::requestResource (const OUString& rsResourceURL) if ( xFactory.is()) return; - // Create a new instance of the factory. - const Reference<uno::XComponentContext>& xContext = - ::comphelper::getProcessComponentContext(); - // Create the factory service. if (iFactory->second == "com.sun.star.drawing.framework.BasicPaneFactory") - xFactory = uno::Reference<css::drawing::framework::XResourceFactory>(new BasicPaneFactory(xContext, mxController)); + xFactory = uno::Reference<css::drawing::framework::XResourceFactory>(new BasicPaneFactory(mxController)); else if (iFactory->second == "com.sun.star.drawing.framework.BasicViewFactory") xFactory = uno::Reference<css::drawing::framework::XResourceFactory>(new BasicViewFactory(mxController)); else if (iFactory->second == "com.sun.star.drawing.framework.BasicToolBarFactory") diff --git a/sd/source/ui/inc/framework/factories/BasicPaneFactory.hxx b/sd/source/ui/inc/framework/factories/BasicPaneFactory.hxx index f12cfcefdbb1..0cdbf05adf64 100644 --- a/sd/source/ui/inc/framework/factories/BasicPaneFactory.hxx +++ b/sd/source/ui/inc/framework/factories/BasicPaneFactory.hxx @@ -56,8 +56,7 @@ class BasicPaneFactory final : public BasicPaneFactoryInterfaceBase { public: - explicit BasicPaneFactory ( - const css::uno::Reference<css::uno::XComponentContext>& rxContext, + explicit BasicPaneFactory( const rtl::Reference<::sd::DrawController>& rxController); virtual ~BasicPaneFactory() override; @@ -84,7 +83,6 @@ public: const css::lang::EventObject& rEventObject) override; private: - css::uno::Reference<css::uno::XComponentContext> mxComponentContext; unotools::WeakReference<sd::framework::ConfigurationController> mxConfigurationControllerWeak; ViewShellBase* mpViewShellBase; @@ -106,7 +104,6 @@ private: */ css::uno::Reference<css::drawing::framework::XResource> CreateFullScreenPane ( - const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext, const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId); /** Create a new instance of ChildWindowPane.