[Libreoffice-commits] core.git: reportdesign/inc reportdesign/source reportdesign/uiconfig reportdesign/UIConfig_dbreport.mk

Caolán McNamara caolanm at redhat.com
Tue Apr 18 16:09:19 UTC 2017


 reportdesign/UIConfig_dbreport.mk                  |    1 
 reportdesign/inc/RptResId.hrc                      |    2 
 reportdesign/source/ui/dlg/Navigator.cxx           |   46 +++++++++---
 reportdesign/source/ui/dlg/Navigator.src           |   61 -----------------
 reportdesign/uiconfig/dbreport/ui/navigatormenu.ui |   75 +++++++++++++++++++++
 5 files changed, 111 insertions(+), 74 deletions(-)

New commits:
commit b44b97532196c39b3214618e00fa9cd456f8c0e8
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Apr 18 17:03:13 2017 +0100

    convert navigator menu to .ui
    
    Change-Id: I754da935de04dde6d94fa2a1331c771a4bd5ec88

diff --git a/reportdesign/UIConfig_dbreport.mk b/reportdesign/UIConfig_dbreport.mk
index b1b8a326e2db..d04dce4bbd64 100644
--- a/reportdesign/UIConfig_dbreport.mk
+++ b/reportdesign/UIConfig_dbreport.mk
@@ -48,6 +48,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/dbreport,\
 	reportdesign/uiconfig/dbreport/ui/floatingnavigator \
 	reportdesign/uiconfig/dbreport/ui/floatingsort \
 	reportdesign/uiconfig/dbreport/ui/groupsortmenu \
+	reportdesign/uiconfig/dbreport/ui/navigatormenu \
 	reportdesign/uiconfig/dbreport/ui/pagedialog \
 	reportdesign/uiconfig/dbreport/ui/pagenumberdialog \
 ))
diff --git a/reportdesign/inc/RptResId.hrc b/reportdesign/inc/RptResId.hrc
index 8535390c59c2..27cef2b7cc76 100644
--- a/reportdesign/inc/RptResId.hrc
+++ b/reportdesign/inc/RptResId.hrc
@@ -191,8 +191,6 @@
 #define RID_STR_VERTICALALIGN               (RID_STRING_START + 160)
 #define RID_STR_PARAADJUST                  (RID_STRING_START + 161)
 
-// menu -----------------------------------------------------------------------
-#define RID_MENU_NAVIGATOR                  ( RID_MENU_START + 1 )
 // bitmaps
 #define RID_SVXBMP_SELECT_REPORT            (RID_BITMAP_START + 0 )
 #define RID_SVXBMP_FM_FIXEDTEXT             (RID_BITMAP_START + 1 )
diff --git a/reportdesign/source/ui/dlg/Navigator.cxx b/reportdesign/source/ui/dlg/Navigator.cxx
index e3dbfd459c99..d4cba5f0958a 100644
--- a/reportdesign/source/ui/dlg/Navigator.cxx
+++ b/reportdesign/source/ui/dlg/Navigator.cxx
@@ -261,6 +261,26 @@ void NavigatorTree::dispose()
     SvTreeListBox::dispose();
 }
 
+namespace
+{
+    sal_uInt16 mapIdent(const OString& rIdent)
+    {
+        if (rIdent == "sorting")
+            return SID_SORTINGANDGROUPING;
+        else if (rIdent == "page")
+            return SID_PAGEHEADERFOOTER;
+        else if (rIdent == "report")
+            return SID_REPORTHEADERFOOTER;
+        else if (rIdent == "function")
+            return SID_RPT_NEW_FUNCTION;
+        else if (rIdent == "properties")
+            return SID_SHOW_PROPERTYBROWSER;
+        else if (rIdent == "delete")
+            return SID_DELETE;
+        return 0;
+    }
+}
+
 void NavigatorTree::Command( const CommandEvent& rEvt )
 {
     bool bHandled = false;
@@ -297,29 +317,33 @@ void NavigatorTree::Command( const CommandEvent& rEvt )
             uno::Reference< report::XGroup> xGroup(pData->getContent(),uno::UNO_QUERY);
             bool bDeleteAllowed = m_rController.isEditable() && (xGroup.is() ||
                                       uno::Reference< report::XFunction>(pData->getContent(),uno::UNO_QUERY).is());
-            ScopedVclPtrInstance<PopupMenu> aContextMenu( ModuleRes( RID_MENU_NAVIGATOR ) );
+
+            VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "modules/dbreport/ui/navigatormenu.ui", "");
+            VclPtr<PopupMenu> aContextMenu(aBuilder.get_menu("menu"));
 
             sal_uInt16 nCount = aContextMenu->GetItemCount();
             for (sal_uInt16 i = 0; i < nCount; ++i)
             {
                 if ( MenuItemType::SEPARATOR != aContextMenu->GetItemType(i))
                 {
-                    sal_uInt16 nId = aContextMenu->GetItemId(i);
+                    sal_uInt16 nMId = aContextMenu->GetItemId(i);
+                    sal_uInt16 nSId = mapIdent(aContextMenu->GetItemIdent(nMId));
 
-                    aContextMenu->CheckItem(nId,m_rController.isCommandChecked(nId));
-                    bool bEnabled = m_rController.isCommandEnabled(nId);
-                    if ( nId == SID_RPT_NEW_FUNCTION )
-                        aContextMenu->EnableItem(nId,m_rController.isEditable() && (xSupplier.is() || xFunctions.is()) );
+                    aContextMenu->CheckItem(nMId, m_rController.isCommandChecked(nSId));
+                    bool bEnabled = m_rController.isCommandEnabled(nSId);
+                    if (nSId == SID_RPT_NEW_FUNCTION)
+                        aContextMenu->EnableItem(nMId, m_rController.isEditable() && (xSupplier.is() || xFunctions.is()));
                     // special condition, check for function and group
-                    else if ( nId == SID_DELETE )
-                        aContextMenu->EnableItem(SID_DELETE,bDeleteAllowed);
+                    else if (nSId == SID_DELETE)
+                        aContextMenu->EnableItem(nMId, bDeleteAllowed);
                     else
-                        aContextMenu->EnableItem(nId,bEnabled);
+                        aContextMenu->EnableItem(nMId, bEnabled);
                 }
             }
-            sal_uInt16 nId = aContextMenu->Execute(this, aWhere);
-            if ( nId )
+
+            if (aContextMenu->Execute(this, aWhere))
             {
+                sal_uInt16 nId = mapIdent(aContextMenu->GetCurItemIdent());
                 uno::Sequence< beans::PropertyValue> aArgs;
                 if ( nId == SID_RPT_NEW_FUNCTION )
                 {
diff --git a/reportdesign/source/ui/dlg/Navigator.src b/reportdesign/source/ui/dlg/Navigator.src
index c2547457764c..dc13f2b395a2 100644
--- a/reportdesign/source/ui/dlg/Navigator.src
+++ b/reportdesign/source/ui/dlg/Navigator.src
@@ -117,65 +117,4 @@ String RID_STR_GROUPS
     Text [ en-US ] = "Groups" ;
 };
 
-Menu RID_MENU_NAVIGATOR
-{
-    ItemList =
-    {
-        MenuItem
-        {
-            Identifier = SID_SORTINGANDGROUPING;
-            Command = ".uno:DbSortingAndGrouping";
-            Text [ en-US ] = "Sorting and Grouping...";
-        };
-        MenuItem
-        {
-            Separator = TRUE;
-        };
-        MenuItem
-        {
-            Identifier = SID_PAGEHEADERFOOTER;
-            Command = ".uno:PageHeaderFooter";
-            Checkable = TRUE;
-            Text [ en-US ] = "Page Header/Footer...";
-        };
-        MenuItem
-        {
-            Identifier = SID_REPORTHEADERFOOTER;
-            Command = ".uno:ReportHeaderFooter";
-            Checkable = TRUE;
-            Text [ en-US ] = "Report Header/Footer...";
-        };
-        MenuItem
-        {
-            Separator = TRUE;
-        };
-        MenuItem
-        {
-            Identifier = SID_RPT_NEW_FUNCTION;
-            Command = ".uno:NewFunction";
-            Text [ en-US ] = "New Function";
-        };
-        MenuItem
-        {
-            Separator = TRUE;
-        };
-        MenuItem
-        {
-            Identifier = SID_SHOW_PROPERTYBROWSER;
-            Command = ".uno:FormProperties";
-            Text [ en-US ] = "Properties...";
-        };
-        MenuItem
-        {
-            Separator = TRUE;
-        };
-        MenuItem
-        {
-            Identifier = SID_DELETE ;
-            Command = ".uno:Delete" ;
-            Text [ en-US ] = "~Delete" ;
-        };
-    };
-};
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/reportdesign/uiconfig/dbreport/ui/navigatormenu.ui b/reportdesign/uiconfig/dbreport/ui/navigatormenu.ui
new file mode 100644
index 000000000000..2b3cab082f74
--- /dev/null
+++ b/reportdesign/uiconfig/dbreport/ui/navigatormenu.ui
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.0 -->
+<interface>
+  <requires lib="gtk+" version="3.10"/>
+  <object class="GtkMenu" id="menu">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkMenuItem" id="sorting">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Sorting and Grouping...</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkSeparatorMenuItem" id="menuitem5">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkCheckMenuItem" id="page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Page Header/Footer...</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkCheckMenuItem" id="report">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Report Header/Footer...</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkSeparatorMenuItem" id="menuitem1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="function">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">New Function</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkSeparatorMenuItem" id="menuitem2">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="properties">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Properties...</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="delete">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">_Delete</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+  </object>
+</interface>


More information about the Libreoffice-commits mailing list