From 5649c4b26401b56736b9eb56ef47b73b95e43c67 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 3 Mar 2021 14:03:12 +0000 Subject: create GetElementParentWindow on demand MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5c7182986206483ab8b1993a360767425870d69e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111940 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- include/sfx2/sidebar/Panel.hxx | 4 ++-- include/sfx2/sidebar/SidebarController.hxx | 4 ++-- sfx2/source/sidebar/Panel.cxx | 16 +++++++++++++--- sfx2/source/sidebar/SidebarController.cxx | 5 ++--- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/include/sfx2/sidebar/Panel.hxx b/include/sfx2/sidebar/Panel.hxx index cd820ff937b2..92e57abc13fd 100644 --- a/include/sfx2/sidebar/Panel.hxx +++ b/include/sfx2/sidebar/Panel.hxx @@ -70,7 +70,7 @@ public: { return mxPanelComponent; } - css::uno::Reference GetElementParentWindow() const { return mxXWindow; } + css::uno::Reference GetElementParentWindow(); css::uno::Reference GetElementWindow(); void SetExpanded(const bool bIsExpanded); bool IsExpanded() const { return mbIsExpanded; } @@ -98,7 +98,7 @@ private: const css::uno::Reference& mxFrame; std::unique_ptr mxTitleBar; std::unique_ptr mxContents; - css::uno::Reference mxXWindow; + css::uno::Reference mxAwtXWindow; }; typedef std::vector> SharedPanelContainer; diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx index 1c38211d11c1..8bcaa858ff1c 100644 --- a/include/sfx2/sidebar/SidebarController.hxx +++ b/include/sfx2/sidebar/SidebarController.hxx @@ -39,7 +39,7 @@ #include #include -namespace com::sun::star::awt { class XWindowPeer; } +namespace com::sun::star::awt { class XWindow; } namespace com::sun::star::frame { class XDispatch; } namespace com::sun::star::ui { class XUIElement; } @@ -231,7 +231,7 @@ private: void UpdateConfigurations(); css::uno::Reference CreateUIElement ( - const css::uno::Reference& rxWindow, + const css::uno::Reference& rxWindow, const OUString& rsImplementationURL, const bool bWantsCanvas, const Context& rContext); diff --git a/sfx2/source/sidebar/Panel.cxx b/sfx2/source/sidebar/Panel.cxx index 7c66838b2d8e..41cfbc096abb 100644 --- a/sfx2/source/sidebar/Panel.cxx +++ b/sfx2/source/sidebar/Panel.cxx @@ -60,7 +60,7 @@ Panel::Panel(const PanelDescriptor& rPanelDescriptor, , mxFrame(rxFrame) , mxTitleBar(new PanelTitleBar(rPanelDescriptor.msTitle, *m_xBuilder, this)) , mxContents(m_xBuilder->weld_container("contents")) - , mxXWindow(mxContents->CreateChildFrame()) + , mxAwtXWindow(mxContents->CreateChildFrame()) { SetText(rPanelDescriptor.msTitle); mxContents->set_visible(mbIsExpanded); @@ -111,8 +111,11 @@ void Panel::dispose() mxTitleBar.reset(); - mxXWindow->dispose(); - mxXWindow.clear(); + if (mxAwtXWindow) + { + mxAwtXWindow->dispose(); + mxAwtXWindow.clear(); + } mxContents.reset(); InterimItemWindow::dispose(); @@ -181,6 +184,13 @@ Reference Panel::GetElementWindow() return nullptr; } +Reference Panel::GetElementParentWindow() +{ + if (!mxAwtXWindow) + mxAwtXWindow = mxContents->CreateChildFrame(); + return mxAwtXWindow; +} + } // end of namespace sfx2::sidebar /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index e6a24e3b632a..dce668892c16 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -954,9 +954,8 @@ VclPtr SidebarController::CreatePanel ( mxFrame); // Create the XUIElement. - Reference xPeer(pPanel->GetElementParentWindow(), UNO_QUERY); Reference xUIElement (CreateUIElement( - xPeer, + pPanel->GetElementParentWindow(), xPanelDescriptor->msImplementationURL, xPanelDescriptor->mbWantsCanvas, rContext)); @@ -974,7 +973,7 @@ VclPtr SidebarController::CreatePanel ( } Reference SidebarController::CreateUIElement ( - const Reference& rxWindow, + const Reference& rxWindow, const OUString& rsImplementationURL, const bool bWantsCanvas, const Context& rContext) -- cgit