From 259a1ebd879f1cfe7e9db9af97d3842fcd51f640 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 31 May 2022 14:59:09 +0200 Subject: Rework UUIInteractionHelper construction ...to remove the need to construct a fresh m_pImpl in UUIInteractionHandler::initialize Change-Id: Ia3f1b89903448f74242a5fec3dcf87c2b1f5e764 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135187 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- uui/source/iahndl.cxx | 10 ---------- uui/source/iahndl.hxx | 11 +++-------- uui/source/interactionhandler.cxx | 17 +++++++---------- 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx index 251a642e509f..9f6a3d34b9d6 100644 --- a/uui/source/iahndl.cxx +++ b/uui/source/iahndl.cxx @@ -120,16 +120,6 @@ public: } /* namespace */ -UUIInteractionHelper::UUIInteractionHelper( - uno::Reference< uno::XComponentContext > const & rxContext, - uno::Reference< awt::XWindow > const & rxWindowParam, - const OUString & rContextParam) - : m_xContext(rxContext), - m_xWindowParam(rxWindowParam), - m_aContextParam(rContextParam) -{ -} - UUIInteractionHelper::UUIInteractionHelper( uno::Reference< uno::XComponentContext > const & rxContext) : m_xContext(rxContext) diff --git a/uui/source/iahndl.hxx b/uui/source/iahndl.hxx index df2bdd054b47..a43122b7adb4 100644 --- a/uui/source/iahndl.hxx +++ b/uui/source/iahndl.hxx @@ -73,22 +73,20 @@ class UUIInteractionHelper private: css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::awt::XWindow > m_xWindowParam; - const OUString m_aContextParam; + OUString m_aContextParam; StringHashMap m_aTypedCustomHandlers; UUIInteractionHelper(UUIInteractionHelper const &) = delete; UUIInteractionHelper& operator =(UUIInteractionHelper const &) = delete; public: - UUIInteractionHelper( - css::uno::Reference< css::uno::XComponentContext > const & rxContext, - css::uno::Reference< css::awt::XWindow > const & rxWindow, - const OUString & rContextParam); explicit UUIInteractionHelper( css::uno::Reference< css::uno::XComponentContext > const & rxContext); const css::uno::Reference & GetParentWindow() const { return m_xWindowParam; } void SetParentWindow(const css::uno::Reference& rWindow) { m_xWindowParam = rWindow; } + void setContext(OUString const & context) { m_aContextParam = context; } + ~UUIInteractionHelper(); bool handleRequest( css::uno::Reference< css::task::XInteractionRequest > const & rRequest); @@ -103,9 +101,6 @@ public: const OUString& aMessage, std::vector< OUString > const & rArguments ); - const css::uno::Reference< css::uno::XComponentContext >& - getORB() const - { return m_xContext; } private: bool handleRequest_impl( diff --git a/uui/source/interactionhandler.cxx b/uui/source/interactionhandler.cxx index b9e3f4d788a1..ea6ebf6d36a4 100644 --- a/uui/source/interactionhandler.cxx +++ b/uui/source/interactionhandler.cxx @@ -34,7 +34,6 @@ #include #include #include -#include using namespace com::sun::star; @@ -47,7 +46,7 @@ class UUIInteractionHandler: css::beans::XPropertySet> { private: - std::optional m_pImpl; + UUIInteractionHelper m_pImpl; public: explicit UUIInteractionHandler(css::uno::Reference< css::uno::XComponentContext > const & rxContext); @@ -114,7 +113,7 @@ public: { css::uno::Reference xWindow; rValue >>= xWindow; - m_pImpl->SetParentWindow(xWindow); + m_pImpl.SetParentWindow(xWindow); return; } throw css::beans::UnknownPropertyException(rPropertyName); @@ -124,7 +123,7 @@ public: { if (rPropertyName == "ParentWindow") { - return uno::Any(m_pImpl->GetParentWindow()); + return uno::Any(m_pImpl.GetParentWindow()); } throw css::beans::UnknownPropertyException(rPropertyName); } @@ -161,9 +160,6 @@ void SAL_CALL UUIInteractionHandler::initialize( uno::Sequence< uno::Any > const & rArguments) { - uno::Reference xContext = m_pImpl->getORB(); - m_pImpl.reset(); - // The old-style InteractionHandler service supported a sequence of // PropertyValue, while the new-style service now uses constructors to pass // in Parent and Context values; for backwards compatibility, keep support @@ -185,7 +181,8 @@ UUIInteractionHandler::initialize( } } - m_pImpl.emplace( xContext, xWindow, aContext ); + m_pImpl.SetParentWindow(xWindow); + m_pImpl.setContext(aContext); } void SAL_CALL @@ -194,7 +191,7 @@ UUIInteractionHandler::handle( { try { - m_pImpl->handleRequest(rRequest); + m_pImpl.handleRequest(rRequest); } catch (uno::RuntimeException const & ex) { @@ -209,7 +206,7 @@ sal_Bool SAL_CALL UUIInteractionHandler::handleInteractionRequest( { try { - return m_pImpl->handleRequest( Request ); + return m_pImpl.handleRequest( Request ); } catch (uno::RuntimeException const & ex) { -- cgit