[Libreoffice-commits] core.git: include/sfx2 sfx2/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Mar 11 13:31:10 UTC 2021


 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(-)

New commits:
commit 5649c4b26401b56736b9eb56ef47b73b95e43c67
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Mar 3 14:03:12 2021 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Mar 11 14:30:23 2021 +0100

    create GetElementParentWindow on demand
    
    Change-Id: I5c7182986206483ab8b1993a360767425870d69e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111940
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

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<css::awt::XWindow> GetElementParentWindow() const { return mxXWindow; }
+    css::uno::Reference<css::awt::XWindow> GetElementParentWindow();
     css::uno::Reference<css::awt::XWindow> GetElementWindow();
     void SetExpanded(const bool bIsExpanded);
     bool IsExpanded() const { return mbIsExpanded; }
@@ -98,7 +98,7 @@ private:
     const css::uno::Reference<css::frame::XFrame>& mxFrame;
     std::unique_ptr<PanelTitleBar> mxTitleBar;
     std::unique_ptr<weld::Container> mxContents;
-    css::uno::Reference<css::awt::XWindow> mxXWindow;
+    css::uno::Reference<css::awt::XWindow> mxAwtXWindow;
 };
 typedef std::vector<VclPtr<Panel>> 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 <cppuhelper/compbase.hxx>
 #include <cppuhelper/basemutex.hxx>
 
-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<css::ui::XUIElement> CreateUIElement (
-        const css::uno::Reference<css::awt::XWindowPeer>& rxWindow,
+        const css::uno::Reference<css::awt::XWindow>& 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<awt::XWindow> Panel::GetElementWindow()
     return nullptr;
 }
 
+Reference<awt::XWindow> 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<Panel> SidebarController::CreatePanel (
         mxFrame);
 
     // Create the XUIElement.
-    Reference<awt::XWindowPeer> xPeer(pPanel->GetElementParentWindow(), UNO_QUERY);
     Reference<ui::XUIElement> xUIElement (CreateUIElement(
-            xPeer,
+            pPanel->GetElementParentWindow(),
             xPanelDescriptor->msImplementationURL,
             xPanelDescriptor->mbWantsCanvas,
             rContext));
@@ -974,7 +973,7 @@ VclPtr<Panel> SidebarController::CreatePanel (
 }
 
 Reference<ui::XUIElement> SidebarController::CreateUIElement (
-    const Reference<awt::XWindowPeer>& rxWindow,
+    const Reference<awt::XWindow>& rxWindow,
     const OUString& rsImplementationURL,
     const bool bWantsCanvas,
     const Context& rContext)


More information about the Libreoffice-commits mailing list