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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Nov 19 15:52:25 UTC 2020


 sfx2/inc/sidebar/ControllerFactory.hxx    |    1 
 sfx2/inc/sidebar/PanelTitleBar.hxx        |    7 +++-
 sfx2/source/sidebar/ControllerFactory.cxx |    6 ++-
 sfx2/source/sidebar/PanelTitleBar.cxx     |   50 ++++++++++++++++--------------
 sfx2/source/sidebar/SidebarController.cxx |    2 -
 sfx2/source/toolbox/weldutils.cxx         |    4 +-
 6 files changed, 40 insertions(+), 30 deletions(-)

New commits:
commit 60b568714eebcdfd53b3da5c23664909e64c42dc
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Nov 19 11:42:37 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Nov 19 16:51:43 2020 +0100

    tdf#138315 make More options buttons in Chart Sidebar deck work again
    
    Change-Id: I513c09bcec21fcb9a6c7c08ba528822ba06474f7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106161
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sfx2/inc/sidebar/ControllerFactory.hxx b/sfx2/inc/sidebar/ControllerFactory.hxx
index dbf609775a39..d33f00d2e8b6 100644
--- a/sfx2/inc/sidebar/ControllerFactory.hxx
+++ b/sfx2/inc/sidebar/ControllerFactory.hxx
@@ -54,6 +54,7 @@ public:
         weld::Builder& rBuilder,
         const OUString& rsCommandName,
         const css::uno::Reference<css::frame::XFrame>& rxFrame,
+        const css::uno::Reference<css::frame::XController>& rxController,
         bool bSideBar);
 
 private:
diff --git a/sfx2/inc/sidebar/PanelTitleBar.hxx b/sfx2/inc/sidebar/PanelTitleBar.hxx
index 7be18d71f1fd..63b7a3b9e7af 100644
--- a/sfx2/inc/sidebar/PanelTitleBar.hxx
+++ b/sfx2/inc/sidebar/PanelTitleBar.hxx
@@ -19,6 +19,7 @@
 #pragma once
 
 #include <sidebar/TitleBar.hxx>
+#include <com/sun/star/frame/XToolbarController.hpp>
 
 namespace com::sun::star::frame { class XController; }
 namespace com::sun::star::frame { class XFrame; }
@@ -39,7 +40,8 @@ public:
     virtual OUString GetTitle() const override;
 
     void SetMoreOptionsCommand(const OUString& rsCommandName,
-                               const css::uno::Reference<css::frame::XFrame>& rxFrame);
+                               const css::uno::Reference<css::frame::XFrame>& rxFrame,
+                               const css::uno::Reference<css::frame::XController>& rxController);
 
     void UpdateExpandedState();
 
@@ -51,10 +53,11 @@ private:
     DECL_LINK(ExpandHdl, weld::Expander&, void);
 
     std::unique_ptr<weld::Expander> mxExpander;
+    css::uno::Reference<css::frame::XToolbarController> mxController;
 
     VclPtr<Panel> mpPanel;
-    static const sal_uInt16 mnMenuItemIndex = 1;
     css::uno::Reference<css::frame::XFrame> mxFrame;
+    OString msIdent;
     OUString msMoreOptionsCommand;
 };
 
diff --git a/sfx2/source/sidebar/ControllerFactory.cxx b/sfx2/source/sidebar/ControllerFactory.cxx
index 692ee10628d4..24bb15c3ec98 100644
--- a/sfx2/source/sidebar/ControllerFactory.cxx
+++ b/sfx2/source/sidebar/ControllerFactory.cxx
@@ -142,7 +142,9 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController(
 Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController(
     weld::Toolbar& rToolbar, weld::Builder& rBuilder,
     const OUString& rsCommandName,
-    const Reference<frame::XFrame>& rxFrame, bool bSideBar)
+    const Reference<frame::XFrame>& rxFrame,
+    const Reference<frame::XController>& rxController,
+    bool bSideBar)
 {
     css::uno::Reference<css::awt::XWindow> xWidget(new weld::TransportAsXWindow(&rToolbar, &rBuilder));
 
@@ -150,7 +152,7 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController(
         CreateToolBarController(
             xWidget,
             rsCommandName,
-            rxFrame, rxFrame->getController(),
+            rxFrame, rxController,
             -1, bSideBar));
 
     if (!xController.is())
diff --git a/sfx2/source/sidebar/PanelTitleBar.cxx b/sfx2/source/sidebar/PanelTitleBar.cxx
index 3cf1cff8fbb1..d1ce0ef700e0 100644
--- a/sfx2/source/sidebar/PanelTitleBar.cxx
+++ b/sfx2/source/sidebar/PanelTitleBar.cxx
@@ -44,6 +44,7 @@ PanelTitleBar::PanelTitleBar(const OUString& rsTitle,
       mxExpander(m_xBuilder->weld_expander("expander")),
       mpPanel(pPanel),
       mxFrame(),
+      msIdent("button"),
       msMoreOptionsCommand()
 {
     mxExpander->set_label(rsTitle);
@@ -80,49 +81,52 @@ PanelTitleBar::~PanelTitleBar()
 
 void PanelTitleBar::dispose()
 {
+    Reference<lang::XComponent> xComponent(mxController, UNO_QUERY);
+    if (xComponent.is())
+        xComponent->dispose();
+    mxController.clear();
     mpPanel.clear();
     mxExpander.reset();
     TitleBar::dispose();
 }
 
 void PanelTitleBar::SetMoreOptionsCommand(const OUString& rsCommandName,
-                                          const css::uno::Reference<css::frame::XFrame>& rxFrame)
+                                          const css::uno::Reference<css::frame::XFrame>& rxFrame,
+                                          const css::uno::Reference<css::frame::XController>& rxController)
 {
     if (rsCommandName == msMoreOptionsCommand)
         return;
 
-    if (msMoreOptionsCommand.getLength() > 0)
-        mxToolBox->set_item_visible("button", false);
+    if (!msMoreOptionsCommand.isEmpty())
+        mxToolBox->set_item_visible(msIdent, false);
 
     msMoreOptionsCommand = rsCommandName;
     mxFrame = rxFrame;
 
-    if (msMoreOptionsCommand.getLength() <= 0)
+    if (msMoreOptionsCommand.isEmpty())
         return;
 
-    mxToolBox->set_item_visible("button", true);
-    mxToolBox->set_item_icon_name("button", "sfx2/res/symphony/morebutton.png");
-    mxToolBox->set_item_tooltip_text(
-        "button",
-        SfxResId(SFX_STR_SIDEBAR_MORE_OPTIONS));
+    msIdent = msMoreOptionsCommand.toUtf8();
+    mxToolBox->set_item_ident(0, msIdent);
+
+    Reference<lang::XComponent> xComponent(mxController, UNO_QUERY);
+    if (xComponent.is())
+        xComponent->dispose();
+    mxController =
+        ControllerFactory::CreateToolBoxController(
+            *mxToolBox, *m_xBuilder, msMoreOptionsCommand, rxFrame, rxController, true);
+
+    mxToolBox->set_item_visible(msIdent, true);
+    mxToolBox->set_item_icon_name(msIdent, "sfx2/res/symphony/morebutton.png");
+    mxToolBox->set_item_tooltip_text(msIdent, SfxResId(SFX_STR_SIDEBAR_MORE_OPTIONS));
 }
 
 void PanelTitleBar::HandleToolBoxItemClick()
 {
-    if (msMoreOptionsCommand.getLength() <= 0)
+    if (!mxController)
         return;
-
-    try
-    {
-        const util::URL aURL (Tools::GetURL(msMoreOptionsCommand));
-        Reference<frame::XDispatch> xDispatch (Tools::GetDispatch(mxFrame, aURL));
-        if (xDispatch.is())
-            xDispatch->dispatch(aURL, Sequence<beans::PropertyValue>());
-    }
-    catch(Exception const &)
-    {
-        DBG_UNHANDLED_EXCEPTION("sfx");
-    }
+    mxController->click();
+    mxController->execute(0);
 }
 
 IMPL_LINK(PanelTitleBar, ExpandHdl, weld::Expander&, rExpander, void)
@@ -134,7 +138,7 @@ IMPL_LINK(PanelTitleBar, ExpandHdl, weld::Expander&, rExpander, void)
 
 void PanelTitleBar::DataChanged (const DataChangedEvent& rEvent)
 {
-    mxToolBox->set_item_icon_name("button", "sfx2/res/symphony/morebutton.png");
+    mxToolBox->set_item_icon_name(msIdent, "sfx2/res/symphony/morebutton.png");
     TitleBar::DataChanged(rEvent);
 }
 
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 8a0e851cff66..4a0ff69f93ce 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -734,7 +734,7 @@ void SidebarController::CreatePanels(const OUString& rDeckId, const Context& rCo
                     {
                         pTitleBar->SetMoreOptionsCommand(
                             rPanelContexDescriptor.msMenuCommand,
-                            mxFrame);
+                            mxFrame, xController);
                     }
                     ++nWriteIndex;
                 }
diff --git a/sfx2/source/toolbox/weldutils.cxx b/sfx2/source/toolbox/weldutils.cxx
index fc97aefa404a..b0055e027ac8 100644
--- a/sfx2/source/toolbox/weldutils.cxx
+++ b/sfx2/source/toolbox/weldutils.cxx
@@ -115,8 +115,8 @@ ToolbarUnoDispatcher::ToolbarUnoDispatcher(weld::Toolbar& rToolbar, weld::Builde
 void ToolbarUnoDispatcher::CreateController(const OUString& rCommand)
 {
     css::uno::Reference<css::frame::XToolbarController> xController(
-        sfx2::sidebar::ControllerFactory::CreateToolBoxController(*m_pToolbar, *m_pBuilder,
-                                                                  rCommand, m_xFrame, m_bSideBar));
+        sfx2::sidebar::ControllerFactory::CreateToolBoxController(
+            *m_pToolbar, *m_pBuilder, rCommand, m_xFrame, m_xFrame->getController(), m_bSideBar));
 
     if (xController.is())
         maControllers.insert(std::make_pair(rCommand, xController));


More information about the Libreoffice-commits mailing list