[Libreoffice-commits] core.git: extras/source include/toolkit include/vcl officecfg/registry sc/uiconfig svtools/Library_svt.mk svtools/source toolkit/source vcl/source

Maxim Monastirsky momonasmon at gmail.com
Thu Feb 9 22:50:13 UTC 2017


 extras/source/glade/libreoffice-catalog.xml.in                    |    3 
 include/toolkit/awt/vclxmenu.hxx                                  |    1 
 include/vcl/button.hxx                                            |    1 
 officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu |    4 
 sc/uiconfig/scalc/ui/notebookbar.ui                               |    2 
 sc/uiconfig/scalc/ui/notebookbar_groups.ui                        |  120 +--------
 svtools/Library_svt.mk                                            |    1 
 svtools/source/control/managedmenubutton.cxx                      |  122 ++++++++++
 toolkit/source/awt/vclxmenu.cxx                                   |    7 
 vcl/source/window/builder.cxx                                     |   13 +
 10 files changed, 170 insertions(+), 104 deletions(-)

New commits:
commit 54d5b1828ec73d0475e0ddb6e31394a7e1904a1b
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date:   Thu Feb 9 00:31:24 2017 +0200

    tdf#105672 framework managed menu button
    
    This adds a menu button that can use a popup menu controller
    to manage its menu. It supports 2 cases:
    
    - Use any controller that is registered in Controller.xcu,
      by specifing its .uno command.
    
    - Manage an arbitrary popup menu with MenuBarManager
      (assuming its items have proper .uno commands in their
      MenuItemData::aCommandStr). It means that a menu that
      was defined in a .ui file, can be used inside that .ui
      file without any additional code.
    
    This commit uses the new control to fix some currently
    non-working buttons in Calc's Notebookbar (but there are
    more that can be fixed the same way). It's not clear how
    long we will continue to use buttons (instead of
    toolboxes) for the Notebookbar, but hopefully this control
    will be useful in other places too.
    
    Change-Id: Ie00cde7cd7e39948948960ca2eff76e9db837109
    Reviewed-on: https://gerrit.libreoffice.org/34103
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Maxim Monastirsky <momonasmon at gmail.com>

diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index 82f9ab4..b842df2 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -850,5 +850,8 @@
     <glade-widget-class title="Vertical box hiding childs depending on context" name="sfxlo-ContextVBox"
                         generic-name="ContextVBox" parent="GtkBox"
                         icon-name="widget-gtk-box"/>
+    <glade-widget-class title="Managed Menu Button" name="svtlo-ManagedMenuButton"
+                        generic-name="ManagedMenuButton" parent="GtkButton"
+                        icon-name="widget-gtk-button"/>
   </glade-widget-classes>
 </glade-catalog>
diff --git a/include/toolkit/awt/vclxmenu.hxx b/include/toolkit/awt/vclxmenu.hxx
index afdd52b..e678d8b 100644
--- a/include/toolkit/awt/vclxmenu.hxx
+++ b/include/toolkit/awt/vclxmenu.hxx
@@ -71,6 +71,7 @@ protected:
     DECL_LINK( MenuEventListener, VclMenuEvent&, void );
 
     void ImplCreateMenu( bool bPopup );
+    void ImplAddListener();
 
 public:
     VCLXMenu();
diff --git a/include/vcl/button.hxx b/include/vcl/button.hxx
index d8588dc..b511db3 100644
--- a/include/vcl/button.hxx
+++ b/include/vcl/button.hxx
@@ -76,6 +76,7 @@ public:
 
     /// Setup handler for UNO commands so that commands like .uno:Something are handled automagically by this button.
     void                SetCommandHandler(const OUString& aCommand);
+    const OUString      GetCommand() const { return maCommand; }
 
     static OUString     GetStandardText( StandardButtonType eButton );
 
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
index 3621837..5ac0c6c 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
@@ -2189,7 +2189,7 @@
       </node>
       <node oor:name=".uno:ColumnOperations" oor:op="replace">
         <prop oor:name="Label" oor:type="xs:string">
-          <value xml:lang="en-US">Column Operations</value>
+          <value xml:lang="en-US">Column</value>
         </prop>
         <prop oor:name="Properties" oor:type="xs:int">
           <value>1</value>
@@ -2197,7 +2197,7 @@
       </node>
       <node oor:name=".uno:RowOperations" oor:op="replace">
         <prop oor:name="Label" oor:type="xs:string">
-          <value xml:lang="en-US">Row Operations</value>
+          <value xml:lang="en-US">Row</value>
         </prop>
         <prop oor:name="Properties" oor:type="xs:int">
           <value>1</value>
diff --git a/sc/uiconfig/scalc/ui/notebookbar.ui b/sc/uiconfig/scalc/ui/notebookbar.ui
index 8772510..f922d4b 100644
--- a/sc/uiconfig/scalc/ui/notebookbar.ui
+++ b/sc/uiconfig/scalc/ui/notebookbar.ui
@@ -1381,7 +1381,7 @@
                             <property name="can_focus">False</property>
                             <property name="orientation">vertical</property>
                             <child>
-                              <object class="GtkButton" id="ConditionalFormatMenu">
+                              <object class="svtlo-ManagedMenuButton" id="ConditionalFormatMenu">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">True</property>
diff --git a/sc/uiconfig/scalc/ui/notebookbar_groups.ui b/sc/uiconfig/scalc/ui/notebookbar_groups.ui
index 5011d96..a23f08d 100644
--- a/sc/uiconfig/scalc/ui/notebookbar_groups.ui
+++ b/sc/uiconfig/scalc/ui/notebookbar_groups.ui
@@ -148,6 +148,7 @@
       <object class="GtkMenuItem" id="stylemenudefault">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="action_name">.uno:StyleApply?Style:string=Default&FamilyName:string=CellStyles</property>
         <property name="label" translatable="yes">Default</property>
         <property name="use_underline">True</property>
       </object>
@@ -162,6 +163,7 @@
       <object class="GtkMenuItem" id="stylemenuacc1">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="action_name">.uno:StyleApply?Style:string=Accent%201&FamilyName:string=CellStyles</property>
         <property name="label" translatable="yes">Accent 1</property>
         <property name="use_underline">True</property>
       </object>
@@ -170,6 +172,7 @@
       <object class="GtkMenuItem" id="stylemenuacc2">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="action_name">.uno:StyleApply?Style:string=Accent%202&FamilyName:string=CellStyles</property>
         <property name="label" translatable="yes">Accent 2</property>
         <property name="use_underline">True</property>
       </object>
@@ -178,6 +181,7 @@
       <object class="GtkMenuItem" id="stylemenuacc3">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="action_name">.uno:StyleApply?Style:string=Accent%203&FamilyName:string=CellStyles</property>
         <property name="label" translatable="yes">Accent 3</property>
         <property name="use_underline">True</property>
       </object>
@@ -192,6 +196,7 @@
       <object class="GtkMenuItem" id="stylemenuhed1">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="action_name">.uno:StyleApply?Style:string=Heading%201&FamilyName:string=CellStyles</property>
         <property name="label" translatable="yes">Heading 1</property>
         <property name="use_underline">True</property>
       </object>
@@ -200,6 +205,7 @@
       <object class="GtkMenuItem" id="stylemenuhed2">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="action_name">.uno:StyleApply?Style:string=Heading%202&FamilyName:string=CellStyles</property>
         <property name="label" translatable="yes">Heading 2</property>
         <property name="use_underline">True</property>
       </object>
@@ -214,6 +220,7 @@
       <object class="GtkMenuItem" id="stylemenustatg">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="action_name">.uno:StyleApply?Style:string=Good&FamilyName:string=CellStyles</property>
         <property name="label" translatable="yes">Good</property>
         <property name="use_underline">True</property>
       </object>
@@ -222,6 +229,7 @@
       <object class="GtkMenuItem" id="stylemenustatn">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="action_name">.uno:StyleApply?Style:string=Neutral&FamilyName:string=CellStyles</property>
         <property name="label" translatable="yes">Neutral</property>
         <property name="use_underline">True</property>
       </object>
@@ -230,6 +238,7 @@
       <object class="GtkMenuItem" id="stylemenustatb">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="action_name">.uno:StyleApply?Style:string=Bad&FamilyName:string=CellStyles</property>
         <property name="label" translatable="yes">Bad</property>
         <property name="use_underline">True</property>
       </object>
@@ -238,6 +247,7 @@
       <object class="GtkMenuItem" id="stylemenustatw">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="action_name">.uno:StyleApply?Style:string=Warning&FamilyName:string=CellStyles</property>
         <property name="label" translatable="yes">Warning</property>
         <property name="use_underline">True</property>
       </object>
@@ -246,6 +256,7 @@
       <object class="GtkMenuItem" id="stylemenustate">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="action_name">.uno:StyleApply?Style:string=Error&FamilyName:string=CellStyles</property>
         <property name="label" translatable="yes">Error</property>
         <property name="use_underline">True</property>
       </object>
@@ -260,6 +271,7 @@
       <object class="GtkMenuItem" id="stylemenutxtn">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="action_name">.uno:StyleApply?Style:string=Note&FamilyName:string=CellStyles</property>
         <property name="label" translatable="yes">Note</property>
         <property name="use_underline">True</property>
       </object>
@@ -268,16 +280,12 @@
       <object class="GtkMenuItem" id="stylemenutxtf">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="action_name">.uno:StyleApply?Style:string=Footnote&FamilyName:string=CellStyles</property>
         <property name="label" translatable="yes">Footnote</property>
         <property name="use_underline">True</property>
       </object>
     </child>
   </object>
-  <object class="GtkImage" id="tablecolumnsi">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="pixbuf">cmd/lc_entirecolumn.png</property>
-  </object>
   <object class="GtkMenu" id="tablemenu">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -330,94 +338,6 @@
       </object>
     </child>
   </object>
-  <object class="GtkImage" id="tablerowsi">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="pixbuf">cmd/lc_entirerow.png</property>
-  </object>
-  <object class="GtkMenu" id="tcolumnmenu">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-  </object>
-  <object class="GtkMenu" id="trowmenu">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <child>
-      <object class="GtkMenuItem" id="rowmenuaddup">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="action_name">.uno:InsertRowsBefore</property>
-        <property name="label" translatable="yes">Insert Rows Above</property>
-        <property name="use_underline">True</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkMenuItem" id="rowmenuadddown">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="action_name">.uno:InsertRowsAfter</property>
-        <property name="label" translatable="yes">Insert Rows Below</property>
-        <property name="use_underline">True</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkSeparatorMenuItem" id="rowmenusep1">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkMenuItem" id="rowmenudel">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="action_name">.uno:DeleteRows</property>
-        <property name="label" translatable="yes">Delete Rows</property>
-        <property name="use_underline">True</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkMenuItem" id="rowmenuselect">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="action_name">.uno:EntireRow</property>
-        <property name="label" translatable="yes">Select Rows</property>
-        <property name="use_underline">True</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkSeparatorMenuItem" id="rowmenusep2">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkMenuItem" id="rowmenuheight">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="action_name">.uno:SetRowHeight</property>
-        <property name="label" translatable="yes">Row Height...</property>
-        <property name="use_underline">True</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkMenuItem" id="rowmenuoptimalrow">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="action_name">.uno:SetOptimalRowHeight</property>
-        <property name="label" translatable="yes">Optimal Row Height</property>
-        <property name="use_underline">True</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkMenuItem" id="rowmenudistribute">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="action_name">.uno:DistributeRows</property>
-        <property name="label" translatable="yes">Distribute Rows Evenly</property>
-        <property name="use_underline">True</property>
-      </object>
-    </child>
-  </object>
   <object class="GtkImage" id="undoi">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -805,7 +725,7 @@
                 <property name="can_focus">False</property>
                 <property name="spacing">3</property>
                 <child>
-                  <object class="GtkButton" id="paragraphstyleb:stylemenu">
+                  <object class="svtlo-ManagedMenuButton" id="paragraphstyleb:stylemenu">
                     <property name="label" translatable="yes">Style</property>
                     <property name="width_request">70</property>
                     <property name="visible">True</property>
@@ -1406,14 +1326,13 @@
                         <property name="can_focus">False</property>
                         <property name="orientation">vertical</property>
                         <child>
-                          <object class="GtkButton" id="tablerowsb:trowmenu">
-                            <property name="label" translatable="yes">Row</property>
+                          <object class="svtlo-ManagedMenuButton" id="tablerowsb">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">True</property>
                             <property name="valign">center</property>
                             <property name="vexpand">True</property>
-                            <property name="image">tablerowsi</property>
+                            <property name="action_name">.uno:RowOperations</property>
                             <property name="relief">none</property>
                             <property name="xalign">0</property>
                           </object>
@@ -1424,14 +1343,13 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkButton" id="tablecolumnsb:tcolumnmenu">
-                            <property name="label" translatable="yes">Column</property>
+                          <object class="svtlo-ManagedMenuButton" id="tablecolumnsb">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">True</property>
                             <property name="valign">center</property>
                             <property name="vexpand">True</property>
-                            <property name="image">tablecolumnsi</property>
+                            <property name="action_name">.uno:ColumnOperations</property>
                             <property name="relief">none</property>
                             <property name="xalign">0</property>
                           </object>
@@ -1535,7 +1453,7 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkButton" id="conditionalb">
+                          <object class="svtlo-ManagedMenuButton" id="conditionalb">
                             <property name="label" translatable="yes">Conditional</property>
                             <property name="height_request">24</property>
                             <property name="visible">True</property>
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk
index f778453..2f3ca6a 100644
--- a/svtools/Library_svt.mk
+++ b/svtools/Library_svt.mk
@@ -122,6 +122,7 @@ $(eval $(call gb_Library_add_exception_objects,svt,\
     svtools/source/control/hyperlabel \
     svtools/source/control/indexentryres \
     svtools/source/control/inettbc \
+    svtools/source/control/managedmenubutton \
     svtools/source/control/roadmap \
     svtools/source/control/ruler \
     svtools/source/control/scriptedtext \
diff --git a/svtools/source/control/managedmenubutton.cxx b/svtools/source/control/managedmenubutton.cxx
new file mode 100644
index 0000000..45e9d98
--- /dev/null
+++ b/svtools/source/control/managedmenubutton.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
+#include <toolkit/awt/vclxmenu.hxx>
+#include <vcl/builderfactory.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/menubtn.hxx>
+
+#include <com/sun/star/frame/theDesktop.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
+#include <com/sun/star/frame/thePopupMenuControllerFactory.hpp>
+#include <com/sun/star/frame/XPopupMenuController.hpp>
+
+namespace {
+
+class ManagedMenuButton : public MenuButton
+{
+public:
+    ManagedMenuButton(vcl::Window* pParent, WinBits nStyle);
+    ~ManagedMenuButton() override;
+
+    void Activate() override;
+    void dispose() override;
+
+private:
+    rtl::Reference<VCLXPopupMenu> m_xPopupMenu;
+    css::uno::Reference<css::frame::XPopupMenuController> m_xPopupController;
+};
+
+ManagedMenuButton::ManagedMenuButton(vcl::Window* pParent, WinBits nStyle)
+    : MenuButton(pParent, nStyle)
+{
+    SetImageAlign(ImageAlign::Left);
+}
+
+ManagedMenuButton::~ManagedMenuButton()
+{
+    disposeOnce();
+}
+
+void ManagedMenuButton::dispose()
+{
+    css::uno::Reference<css::lang::XComponent> xComponent(m_xPopupController, css::uno::UNO_QUERY);
+    if (xComponent.is())
+        xComponent->dispose();
+
+    m_xPopupMenu.clear();
+    m_xPopupController.clear();
+    MenuButton::dispose();
+}
+
+void ManagedMenuButton::Activate()
+{
+    if (!GetPopupMenu())
+        SetPopupMenu(VclPtr<PopupMenu>::Create());
+
+    MenuButton::Activate();
+
+    if (m_xPopupController.is())
+    {
+        m_xPopupController->updatePopupMenu();
+        return;
+    }
+
+    if (!m_xPopupMenu.is())
+        m_xPopupMenu.set(new VCLXPopupMenu(GetPopupMenu()));
+
+    // FIXME: get the frame from the parent VclBuilder.
+    css::uno::Reference<css::uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
+    css::uno::Reference<css::frame::XDesktop2> xDesktop(css::frame::theDesktop::get(xContext));
+    css::uno::Reference<css::frame::XFrame> xFrame(xDesktop->getActiveFrame());
+    if (!xFrame.is())
+        return;
+
+    OUString aModuleName;
+    try
+    {
+        css::uno::Reference<css::frame::XModuleManager> xModuleManager(css::frame::ModuleManager::create(xContext));
+        aModuleName = xModuleManager->identify(xFrame);
+    }
+    catch( const css::uno::Exception& )
+    {}
+
+    css::uno::Sequence<css::uno::Any> aArgs {
+        css::uno::makeAny(comphelper::makePropertyValue("ModuleIdentifier", aModuleName)),
+        css::uno::makeAny(comphelper::makePropertyValue("Frame", css::uno::makeAny(xFrame))),
+        css::uno::makeAny(comphelper::makePropertyValue("InToolbar", css::uno::makeAny(true)))
+    };
+
+    const OUString aCommand(GetCommand());
+    if (!aCommand.isEmpty() && GetPopupMenu()->GetItemCount() == 0)
+    {
+        css::uno::Reference<css::frame::XUIControllerFactory> xPopupMenuControllerFactory =
+            css::frame::thePopupMenuControllerFactory::get(xContext);
+
+        if (xPopupMenuControllerFactory->hasController(aCommand, aModuleName))
+            m_xPopupController.set(xPopupMenuControllerFactory->createInstanceWithArgumentsAndContext(
+                aCommand, aArgs, xContext), css::uno::UNO_QUERY);
+    }
+
+    // No registered controller found, use one the can handle arbitrary menus (e.g. defined in .ui file).
+    if (!m_xPopupController.is())
+        m_xPopupController.set(xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+            "com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext), css::uno::UNO_QUERY);
+
+    if (m_xPopupController.is())
+        m_xPopupController->setPopupMenu(m_xPopupMenu.get());
+}
+
+}
+
+VCL_BUILDER_FACTORY_ARGS(ManagedMenuButton, WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER|WB_FLATBUTTON)
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx
index bcf081c..2650fa8 100644
--- a/toolkit/source/awt/vclxmenu.cxx
+++ b/toolkit/source/awt/vclxmenu.cxx
@@ -79,6 +79,12 @@ void VCLXMenu::ImplCreateMenu( bool bPopup )
     mpMenu->AddEventListener( LINK( this, VCLXMenu, MenuEventListener ) );
 }
 
+void VCLXMenu::ImplAddListener()
+{
+    assert(mpMenu);
+    mpMenu->AddEventListener( LINK( this, VCLXMenu, MenuEventListener ) );
+}
+
 IMPL_LINK( VCLXMenu, MenuEventListener, VclMenuEvent&, rMenuEvent, void )
 {
     DBG_ASSERT( rMenuEvent.GetMenu() && mpMenu, "Menu???" );
@@ -858,6 +864,7 @@ VCLXPopupMenu::VCLXPopupMenu()
 
 VCLXPopupMenu::VCLXPopupMenu( PopupMenu* pPopMenu ) : VCLXMenu( static_cast<Menu *>(pPopMenu) )
 {
+    ImplAddListener();
 }
 
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index d622502..c627cf1 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1790,6 +1790,13 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
                 pFunction(xWindow, xParent, rMap);
                 if (xWindow->GetType() == WINDOW_PUSHBUTTON)
                     setupFromActionName(static_cast<Button*>(xWindow.get()), rMap, m_xFrame);
+                else if (xWindow->GetType() == WINDOW_MENUBUTTON)
+                {
+                    OString sMenu = extractCustomProperty(rMap);
+                    if (!sMenu.isEmpty())
+                        m_pParserState->m_aButtonMenuMaps.push_back(ButtonMenuMap(id, sMenu));
+                    setupFromActionName(static_cast<Button*>(xWindow.get()), rMap, m_xFrame);
+                }
             }
         }
     }
@@ -2721,17 +2728,23 @@ void VclBuilder::insertMenuObject(PopupMenu *pParent, const OString &rClass, con
     if (rClass == "GtkMenuItem")
     {
         OUString sLabel(OStringToOUString(convertMnemonicMarkup(extractLabel(rProps)), RTL_TEXTENCODING_UTF8));
+        OUString aCommand(OStringToOUString(extractActionName(rProps), RTL_TEXTENCODING_UTF8));
         pParent->InsertItem(nNewId, sLabel, MenuItemBits::TEXT, rID);
+        pParent->SetItemCommand(nNewId, aCommand);
     }
     else if (rClass == "GtkCheckMenuItem")
     {
         OUString sLabel(OStringToOUString(convertMnemonicMarkup(extractLabel(rProps)), RTL_TEXTENCODING_UTF8));
+        OUString aCommand(OStringToOUString(extractActionName(rProps), RTL_TEXTENCODING_UTF8));
         pParent->InsertItem(nNewId, sLabel, MenuItemBits::CHECKABLE, rID);
+        pParent->SetItemCommand(nNewId, aCommand);
     }
     else if (rClass == "GtkRadioMenuItem")
     {
         OUString sLabel(OStringToOUString(convertMnemonicMarkup(extractLabel(rProps)), RTL_TEXTENCODING_UTF8));
+        OUString aCommand(OStringToOUString(extractActionName(rProps), RTL_TEXTENCODING_UTF8));
         pParent->InsertItem(nNewId, sLabel, MenuItemBits::CHECKABLE | MenuItemBits::RADIOCHECK, rID);
+        pParent->SetItemCommand(nNewId, aCommand);
     }
 
     else if (rClass == "GtkSeparatorMenuItem")


More information about the Libreoffice-commits mailing list