[Libreoffice-commits] core.git: extras/source include/vcl sw/uiconfig vcl/source

Sumit Chauhan (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 26 16:37:16 UTC 2019


 extras/source/glade/libreoffice-catalog.xml.in |    6 
 include/vcl/NotebookBarAddonsMerger.hxx        |   11 -
 sw/uiconfig/swriter/ui/notebookbar.ui          |  203 ++++++++++++++++++++++++-
 vcl/source/window/NotebookBarAddonsMerger.cxx  |   94 ++++++++---
 vcl/source/window/builder.cxx                  |   11 -
 5 files changed, 288 insertions(+), 37 deletions(-)

New commits:
commit 7b0dd98941911c686c0d127810d1c333df5026c3
Author:     Sumit Chauhan <sumitcn25 at gmail.com>
AuthorDate: Thu Jul 25 02:51:10 2019 +0530
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri Jul 26 18:36:08 2019 +0200

    Extension support for gtkmenuItem and notebookbar.ui file added for writer
    
    Change-Id: I65a07fbef7726cdaa9061ebf2227fbedd725d4db
    Reviewed-on: https://gerrit.libreoffice.org/76278
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index 655e5b8dbe1f..3cf70cfc456f 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -363,5 +363,11 @@
     <glade-widget-class title="Color Config Control" name="cuilo-ColorConfigCtrl"
                         generic-name="ColorConfigCtrl" parent="GtkBox"
                         icon-name="widget-gtk-box"/>
+    <glade-widget-class title="NotebookBar Toolbar Addons" name="NotebookBarAddonsToolMergePoint"
+                        generic-name="ShowText" parent="GtkToolButton"
+                        icon-name="widget-gtk-toolbutton"/>
+    <glade-widget-class title="NotebookBar MenuItem Addons" name="NotebookBarAddonsMenuMergePoint"
+                        generic-name="ShowText" parent="GtkMenuItem"
+                        icon-name="widget-gtk-menuitem"/>
   </glade-widget-classes>
 </glade-catalog>
diff --git a/include/vcl/NotebookBarAddonsMerger.hxx b/include/vcl/NotebookBarAddonsMerger.hxx
index c3b9998c7750..fde1196e4a63 100644
--- a/include/vcl/NotebookBarAddonsMerger.hxx
+++ b/include/vcl/NotebookBarAddonsMerger.hxx
@@ -24,12 +24,15 @@
 #include <vcl/window.hxx>
 #include <vcl/vclptr.hxx>
 #include <vcl/image.hxx>
+#include <vcl/menu.hxx>
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/frame/XFrame.hpp>
 #include <com/sun/star/uno/Sequence.h>
 #include <memory>
 #include <vector>
 
+class PopupMenu;
+
 struct NotebookBarAddonsItem
 {
     Image aImage;
@@ -59,12 +62,14 @@ struct AddonNotebookBarItem
 class NotebookBarAddonsMerger
 {
 public:
-    NotebookBarAddonsMerger(vcl::Window* pParent,
-                            const css::uno::Reference<css::frame::XFrame>& rFrame,
-                            const NotebookBarAddonsItem& aNotebookBarAddonsItem);
+    NotebookBarAddonsMerger();
+    ~NotebookBarAddonsMerger();
     static void MergeNotebookBarAddons(vcl::Window* pParent,
                                        const css::uno::Reference<css::frame::XFrame>& rFrame,
                                        const NotebookBarAddonsItem& aNotebookBarAddonsItem);
+    static void MergeNotebookBarMenuAddons(PopupMenu* pPopupMenu, sal_Int16 nItemId,
+                                           const OString& sItemIdName,
+                                           NotebookBarAddonsItem& aNotebookBarAddonsItem);
 };
 
 #endif
diff --git a/sw/uiconfig/swriter/ui/notebookbar.ui b/sw/uiconfig/swriter/ui/notebookbar.ui
index f6935d190cab..c2ea3f405612 100644
--- a/sw/uiconfig/swriter/ui/notebookbar.ui
+++ b/sw/uiconfig/swriter/ui/notebookbar.ui
@@ -1,9 +1,33 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.1 -->
+<!-- Generated with glade 3.22.0 -->
 <interface domain="sw">
   <requires lib="gtk+" version="3.18"/>
   <requires lib="LibreOffice" version="1.0"/>
   <!-- interface-local-resource-path ../../../icon-themes/colibre/cmd/ -->
+  <object class="GtkMenu" id="MenuAddons">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child>
+      <object class="NotebookBarAddonsMenuMergePoint" id="AddonCommands-Menu">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="action_name">AddonCommand</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkSeparatorMenuItem" id="AddonSection-Separator">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="Menu-Extension-PackageManagerDialog">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="action_name">service:com.sun.star.deployment.ui.PackageManagerDialog</property>
+      </object>
+    </child>
+  </object>
   <object class="GtkMenu" id="MenuDraw">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -17314,6 +17338,175 @@
               </packing>
             </child>
             <child>
+              <object class="sfxlo-PriorityHBox" id="ExtensionBox">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <child>
+                  <object class="sfxlo-DropdownBox" id="Extension-Menu">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="halign">end</property>
+                    <property name="valign">center</property>
+                    <property name="vexpand">True</property>
+                    <child>
+                      <object class="GtkBox" id="Extension-Section">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="valign">center</property>
+                        <property name="vexpand">True</property>
+                        <property name="orientation">vertical</property>
+                        <child>
+                          <object class="svtlo-ManagedMenuButton" id="Extension-ExtensionButton:MenuAddons">
+                            <property name="label" translatable="yes" context="WriterNotebookbar|FormMenuButton">E_xtension</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="focus_on_click">False</property>
+                            <property name="receives_default">False</property>
+                            <property name="halign">end</property>
+                            <property name="valign">center</property>
+                            <property name="vexpand">True</property>
+                            <property name="relief">none</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="sfxlo-NotebookbarToolBox" id="SectionBottom21">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="halign">end</property>
+                            <property name="hexpand">True</property>
+                            <property name="toolbar_style">both-horiz</property>
+                            <property name="show_arrow">False</property>
+                            <property name="icon_size">1</property>
+                            <child>
+                              <object class="GtkToolButton" id="ExtensionMenu-ExtensionDialog">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="action_name">service:com.sun.star.deployment.ui.PackageManagerDialog</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="homogeneous">True</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="pack_type">end</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkSeparator" id="separator11">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="halign">end</property>
+                    <property name="margin_top">5</property>
+                    <property name="margin_bottom">5</property>
+                    <property name="orientation">vertical</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="padding">5</property>
+                    <property name="pack_type">end</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="sfxlo-PriorityMergedHBox" id="Extension-Container">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="valign">center</property>
+                    <property name="vexpand">True</property>
+                    <child>
+                      <object class="sfxlo-OptionalBox" id="AddonSections">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="valign">center</property>
+                        <property name="vexpand">True</property>
+                        <child>
+                          <object class="sfxlo-NotebookbarToolBox" id="SectionBottom52">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="valign">center</property>
+                            <property name="vexpand">True</property>
+                            <property name="toolbar_style">both</property>
+                            <property name="show_arrow">False</property>
+                            <property name="icon_size">3</property>
+                            <child>
+                              <object class="NotebookBarAddonsToolMergePoint" id="AddonCommand">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="action_name">AddonCommand</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="homogeneous">True</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <style>
+                          <class name="priority-30"/>
+                        </style>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">14</property>
+              </packing>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="ExtensionLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes" context="WriterNotebookbar|ExtensionLabel">E~xtension</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="position">14</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
               <object class="sfxlo-PriorityHBox" id="ToolBox">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
@@ -17881,7 +18074,7 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="sfxlo-NotebookbarToolBox" id="SectionBottom21">
+                              <object class="sfxlo-NotebookbarToolBox" id="SectionBottom68">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
                                 <property name="toolbar_style">icons</property>
@@ -18224,7 +18417,7 @@
                         <property name="valign">center</property>
                         <property name="vexpand">True</property>
                         <child>
-                          <object class="GtkSeparator" id="separator11">
+                          <object class="GtkSeparator" id="separator50">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="margin_top">5</property>
@@ -18363,7 +18556,7 @@
                 </child>
               </object>
               <packing>
-                <property name="position">14</property>
+                <property name="position">15</property>
               </packing>
             </child>
             <child type="tab">
@@ -18374,7 +18567,7 @@
                 <property name="use_underline">True</property>
               </object>
               <packing>
-                <property name="position">14</property>
+                <property name="position">15</property>
                 <property name="tab_fill">False</property>
               </packing>
             </child>
diff --git a/vcl/source/window/NotebookBarAddonsMerger.cxx b/vcl/source/window/NotebookBarAddonsMerger.cxx
index d65aba9624f8..5fc0b14b8087 100644
--- a/vcl/source/window/NotebookBarAddonsMerger.cxx
+++ b/vcl/source/window/NotebookBarAddonsMerger.cxx
@@ -19,6 +19,7 @@
 
 #include <vcl/NotebookBarAddonsMerger.hxx>
 #include <vcl/commandinfoprovider.hxx>
+#include <vcl/vclenum.hxx>
 #include <vcl/toolbox.hxx>
 
 static const char STYLE_TEXT[] = "Text";
@@ -33,13 +34,34 @@ static const char MERGE_NOTEBOOKBAR_CONTROLTYPE[] = "ControlType";
 static const char MERGE_NOTEBOOKBAR_WIDTH[] = "Width";
 static const char MERGE_NOTEBOOKBAR_STYLE[] = "Style";
 
-NotebookBarAddonsMerger::NotebookBarAddonsMerger(
-    vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& m_xFrame,
-    const NotebookBarAddonsItem& aNotebookBarAddonsItem)
+static void GetAddonNotebookBarItem(const css::uno::Sequence<css::beans::PropertyValue>& pExtension,
+                                    AddonNotebookBarItem& aAddonNotebookBarItem)
 {
-    MergeNotebookBarAddons(pParent, m_xFrame, aNotebookBarAddonsItem);
+    for (int nIdx = 0; nIdx < pExtension.getLength(); nIdx++)
+    {
+        if (pExtension[nIdx].Name == MERGE_NOTEBOOKBAR_URL)
+            pExtension[nIdx].Value >>= aAddonNotebookBarItem.sCommandURL;
+        else if (pExtension[nIdx].Name == MERGE_NOTEBOOKBAR_TITLE)
+            pExtension[nIdx].Value >>= aAddonNotebookBarItem.sLabel;
+        else if (pExtension[nIdx].Name == MERGE_NOTEBOOKBAR_IMAGEID)
+            pExtension[nIdx].Value >>= aAddonNotebookBarItem.sImageIdentifier;
+        else if (pExtension[nIdx].Name == MERGE_NOTEBOOKBAR_CONTEXT)
+            pExtension[nIdx].Value >>= aAddonNotebookBarItem.sContext;
+        else if (pExtension[nIdx].Name == MERGE_NOTEBOOKBAR_TARGET)
+            pExtension[nIdx].Value >>= aAddonNotebookBarItem.sTarget;
+        else if (pExtension[nIdx].Name == MERGE_NOTEBOOKBAR_CONTROLTYPE)
+            pExtension[nIdx].Value >>= aAddonNotebookBarItem.sControlType;
+        else if (pExtension[nIdx].Name == MERGE_NOTEBOOKBAR_WIDTH)
+            pExtension[nIdx].Value >>= aAddonNotebookBarItem.nWidth;
+        else if (pExtension[nIdx].Name == MERGE_NOTEBOOKBAR_STYLE)
+            pExtension[nIdx].Value >>= aAddonNotebookBarItem.sStyle;
+    }
 }
 
+NotebookBarAddonsMerger::NotebookBarAddonsMerger() {}
+
+NotebookBarAddonsMerger::~NotebookBarAddonsMerger() {}
+
 void NotebookBarAddonsMerger::MergeNotebookBarAddons(
     vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& m_xFrame,
     const NotebookBarAddonsItem& aNotebookBarAddonsItem)
@@ -53,29 +75,10 @@ void NotebookBarAddonsMerger::MergeNotebookBarAddons(
 
         for (int nSecIdx = 0; nSecIdx < aExtension.getLength(); nSecIdx++)
         {
+            sal_uInt16 nItemId = 0;
             AddonNotebookBarItem aAddonNotebookBarItem;
             const css::uno::Sequence<css::beans::PropertyValue> pExtension = aExtension[nSecIdx];
-            for (int nRes = 0; nRes < pExtension.getLength(); nRes++)
-            {
-                if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_URL)
-                    pExtension[nRes].Value >>= aAddonNotebookBarItem.sCommandURL;
-                else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_TITLE)
-                    pExtension[nRes].Value >>= aAddonNotebookBarItem.sLabel;
-                else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_IMAGEID)
-                    pExtension[nRes].Value >>= aAddonNotebookBarItem.sImageIdentifier;
-                else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_CONTEXT)
-                    pExtension[nRes].Value >>= aAddonNotebookBarItem.sContext;
-                else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_TARGET)
-                    pExtension[nRes].Value >>= aAddonNotebookBarItem.sTarget;
-                else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_CONTROLTYPE)
-                    pExtension[nRes].Value >>= aAddonNotebookBarItem.sControlType;
-                else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_WIDTH)
-                    pExtension[nRes].Value >>= aAddonNotebookBarItem.nWidth;
-                else if (pExtension[nRes].Name == MERGE_NOTEBOOKBAR_STYLE)
-                    pExtension[nRes].Value >>= aAddonNotebookBarItem.sStyle;
-            }
-
-            sal_uInt16 nItemId = 0;
+            GetAddonNotebookBarItem(pExtension, aAddonNotebookBarItem);
             ToolBox* pToolbox = dynamic_cast<ToolBox*>(pParent);
             if (pToolbox)
             {
@@ -108,7 +111,46 @@ void NotebookBarAddonsMerger::MergeNotebookBarAddons(
                     pToolbox->SetItemImage(nItemId, sImage);
                 }
             }
-            pToolbox->InsertSeparator();
+            if (nSecIdx == aExtension.getLength() - 1)
+                pToolbox->InsertSeparator();
+        }
+    }
+}
+
+void NotebookBarAddonsMerger::MergeNotebookBarMenuAddons(
+    PopupMenu* pPopupMenu, sal_Int16 nItemId, const OString& sItemIdName,
+    NotebookBarAddonsItem& aNotebookBarAddonsItem)
+{
+    std::vector<Image> aImageVec = aNotebookBarAddonsItem.aImageValues;
+    unsigned long nIter = 0;
+    css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>> aExtension;
+    for (unsigned long nIdx = 0; nIdx < aNotebookBarAddonsItem.aAddonValues.size(); nIdx++)
+    {
+        aExtension = aNotebookBarAddonsItem.aAddonValues[nIdx];
+
+        for (int nSecIdx = 0; nSecIdx < aExtension.getLength(); nSecIdx++)
+        {
+            AddonNotebookBarItem aAddonNotebookBarItem;
+            Image sImage;
+            MenuItemBits nBits = MenuItemBits::ICON;
+            const css::uno::Sequence<css::beans::PropertyValue> pExtension = aExtension[nSecIdx];
+
+            GetAddonNotebookBarItem(pExtension, aAddonNotebookBarItem);
+
+            pPopupMenu->InsertItem(nItemId, aAddonNotebookBarItem.sLabel, nBits, sItemIdName);
+            pPopupMenu->SetItemCommand(nItemId, aAddonNotebookBarItem.sCommandURL);
+
+            if (nIter < aImageVec.size())
+            {
+                sImage = aImageVec[nIter];
+                nIter++;
+            }
+            pPopupMenu->SetItemImage(nItemId, sImage);
+
+            if (nSecIdx == aExtension.getLength() - 1)
+                pPopupMenu->InsertSeparator();
+
+            ++nItemId;
         }
     }
 }
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 0a4c66e0cbf1..75112c8514a4 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -2170,9 +2170,9 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
     {
         xWindow = VclPtr<ToolBox>::Create(pParent, WB_3DLOOK | WB_TABSTOP);
     }
-    else if (name == "NotebookBarAddonsMergePoint")
+    else if (name == "NotebookBarAddonsToolMergePoint")
     {
-        NotebookBarAddonsMerger aNotebookBarAddonsMerger(pParent,m_xFrame, m_pNotebookBarAddonsItem);
+        NotebookBarAddonsMerger::MergeNotebookBarAddons(pParent, m_xFrame, m_pNotebookBarAddonsItem);
         return nullptr;
     }
     else if (name == "GtkToolButton" || name == "GtkMenuToolButton" ||
@@ -3514,7 +3514,12 @@ void VclBuilder::insertMenuObject(PopupMenu *pParent, PopupMenu *pSubMenu, const
     sal_uInt16 nOldCount = pParent->GetItemCount();
     sal_uInt16 nNewId = ++m_pParserState->m_nLastMenuItemId;
 
-    if (rClass == "GtkMenuItem")
+    if(rClass == "NotebookBarAddonsMenuMergePoint")
+    {
+        NotebookBarAddonsMerger::MergeNotebookBarMenuAddons(pParent, nNewId, rID, m_pNotebookBarAddonsItem);
+        m_pParserState->m_nLastMenuItemId = pParent->GetItemCount();
+    }
+    else if (rClass == "GtkMenuItem")
     {
         OUString sLabel(BuilderUtils::convertMnemonicMarkup(extractLabel(rProps)));
         OUString aCommand(extractActionName(rProps));


More information about the Libreoffice-commits mailing list