[Libreoffice-commits] core.git: 2 commits - include/svx svx/inc svx/source svx/uiconfig svx/UIConfig_svx.mk

Caolán McNamara caolanm at redhat.com
Sat Apr 15 20:45:14 UTC 2017


 include/svx/fmresids.hrc        |    1 
 svx/UIConfig_svx.mk             |    1 
 svx/inc/fmhelp.hrc              |    6 ---
 svx/source/form/datanavi.cxx    |   61 +++++++++++++++++++++++-----------------
 svx/source/form/datanavi.src    |   53 ----------------------------------
 svx/source/inc/datanavi.hrc     |   37 ------------------------
 svx/source/inc/datanavi.hxx     |    2 +
 svx/uiconfig/ui/formdatamenu.ui |   55 ++++++++++++++++++++++++++++++++++++
 svx/uiconfig/ui/formnavimenu.ui |    4 +-
 9 files changed, 96 insertions(+), 124 deletions(-)

New commits:
commit d8a98a551c1831141b5462416d0ba3a31d38ef6a
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Apr 15 19:46:16 2017 +0100

    convert form data navigator menu to .ui
    
    which has the advantage of also fixing it
    
    Change-Id: Ida23826c9ce334d517c9d70096d5fb478d53b891

diff --git a/include/svx/fmresids.hrc b/include/svx/fmresids.hrc
index c33dbe73ff9e..bd6422a3c731 100644
--- a/include/svx/fmresids.hrc
+++ b/include/svx/fmresids.hrc
@@ -64,7 +64,6 @@
 // Menu-Id's -----------------------------------------------------------
 #define RID_FMSHELL_CONVERSIONMENU                  (RID_FORMS_START + 4)
 #define RID_FM_FILTER_MENU                          (RID_FORMS_START + 5)
-#define RID_MENU_DATANAVIGATOR                      (RID_FORMS_START + 10)
 
 // String-Id's -----------------------------------------------------------
 #define RID_STR_INVALID_XMLNAME                     (RID_FORMS_START + 1)
diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk
index 032a64019d36..cfe6260de78f 100644
--- a/svx/UIConfig_svx.mk
+++ b/svx/UIConfig_svx.mk
@@ -44,6 +44,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\
 	svx/uiconfig/ui/floatingundoredo \
 	svx/uiconfig/ui/fontworkgallerydialog \
 	svx/uiconfig/ui/fontworkspacingdialog \
+	svx/uiconfig/ui/formdatamenu \
 	svx/uiconfig/ui/formlinkwarndialog \
 	svx/uiconfig/ui/formnavimenu \
 	svx/uiconfig/ui/functionmenu \
diff --git a/svx/inc/fmhelp.hrc b/svx/inc/fmhelp.hrc
index b0f5365c5372..7e7495492430 100644
--- a/svx/inc/fmhelp.hrc
+++ b/svx/inc/fmhelp.hrc
@@ -32,12 +32,6 @@
 #define HID_GRID_TRAVEL_NEW                                   "SVX_HID_GRID_TRAVEL_NEW"
 #define HID_GRID_TRAVEL_ABSOLUTE                              "SVX_HID_GRID_TRAVEL_ABSOLUTE"
 #define HID_GRID_NUMBEROFRECORDS                              "SVX_HID_GRID_NUMBEROFRECORDS"
-#define HID_XFORMS_TOOLBOX_ITEM_ADD                           "SVX_HID_XFORMS_TOOLBOX_ITEM_ADD"
-#define HID_XFORMS_TOOLBOX_ITEM_ADD_ELEMENT                   "SVX_HID_XFORMS_TOOLBOX_ITEM_ADD_ELEMENT"
-#define HID_XFORMS_TOOLBOX_ITEM_ADD_ATTRIBUTE                 "SVX_HID_XFORMS_TOOLBOX_ITEM_ADD_ATTRIBUTE"
-#define HID_XFORMS_TOOLBOX_ITEM_EDIT                          "SVX_HID_XFORMS_TOOLBOX_ITEM_EDIT"
-#define HID_XFORMS_TOOLBOX_ITEM_REMOVE                        "SVX_HID_XFORMS_TOOLBOX_ITEM_REMOVE"
-#define HID_XFORMS_MID_INSERT_CONTROL                         "SVX_HID_XFORMS_MID_INSERT_CONTROL"
 #define HID_FM_DELETE                                         "SVX_HID_FM_DELETE"
 #define HID_FM_FILTER_EDIT                                    "SVX_HID_FM_EDIT"
 #define HID_FM_FILTER_IS_NULL                                 "SVX_HID_FM_FILTER_IS_NULL"
diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx
index 2bedc2332605..fffdcba33636 100644
--- a/svx/source/form/datanavi.cxx
+++ b/svx/source/form/datanavi.cxx
@@ -25,7 +25,6 @@
 #include "datanavi.hxx"
 #include "fmservs.hxx"
 
-#include "datanavi.hrc"
 #include "fmhelp.hrc"
 #include <svx/svxids.hrc>
 #include <tools/rcid.h>
@@ -152,6 +151,8 @@ namespace svxform
     void DataTreeListBox::dispose()
     {
         DeleteAndClear();
+        m_xMenu.clear();
+        m_xBuilder.reset();
         m_pXFormsPage.clear();
         SvTreeListBox::dispose();
     }
@@ -160,10 +161,12 @@ namespace svxform
     {
         return DND_ACTION_NONE;
     }
+
     sal_Int8 DataTreeListBox::ExecuteDrop( const ExecuteDropEvent& /*rEvt*/ )
     {
         return DND_ACTION_NONE;
     }
+
     void DataTreeListBox::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ )
     {
         SvTreeListEntry* pSelected = FirstSelected();
@@ -222,34 +225,46 @@ namespace svxform
 
     VclPtr<PopupMenu> DataTreeListBox::CreateContextMenu()
     {
-        VclPtrInstance<PopupMenu> pMenu( SVX_RES( RID_MENU_DATANAVIGATOR ) );
+        m_xMenu.disposeAndClear();
+        m_xBuilder.reset(new VclBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "svx/ui/formdatamenu.ui", ""));
+        m_xMenu.set(m_xBuilder->get_menu("menu"));
+
         if ( DGTInstance == m_eGroup )
-            pMenu->RemoveItem( pMenu->GetItemPos( m_nAddId ) );
+            m_xMenu->RemoveItem(m_xMenu->GetItemPos(m_xMenu->GetItemId("additem")));
         else
         {
-            pMenu->RemoveItem( pMenu->GetItemPos( m_nAddElementId ) );
-            pMenu->RemoveItem( pMenu->GetItemPos( m_nAddAttributeId ) );
+            m_xMenu->RemoveItem(m_xMenu->GetItemPos(m_xMenu->GetItemId("addelement")));
+            m_xMenu->RemoveItem(m_xMenu->GetItemPos(m_xMenu->GetItemId("addattribute")));
 
             if ( DGTSubmission == m_eGroup )
             {
-                pMenu->SetItemText( m_nAddId, SVX_RESSTR( RID_STR_DATANAV_ADD_SUBMISSION ) );
-                pMenu->SetItemText( m_nEditId, SVX_RESSTR( RID_STR_DATANAV_EDIT_SUBMISSION ) );
-                pMenu->SetItemText( m_nRemoveId, SVX_RESSTR( RID_STR_DATANAV_REMOVE_SUBMISSION ) );
+                m_xMenu->SetItemText(m_xMenu->GetItemId("additem"), SVX_RESSTR(RID_STR_DATANAV_ADD_SUBMISSION));
+                m_xMenu->SetItemText(m_xMenu->GetItemId("edit"), SVX_RESSTR(RID_STR_DATANAV_EDIT_SUBMISSION));
+                m_xMenu->SetItemText(m_xMenu->GetItemId("delete"), SVX_RESSTR(RID_STR_DATANAV_REMOVE_SUBMISSION));
             }
             else
             {
-                pMenu->SetItemText( m_nAddId, SVX_RESSTR( RID_STR_DATANAV_ADD_BINDING ) );
-                pMenu->SetItemText( m_nEditId, SVX_RESSTR( RID_STR_DATANAV_EDIT_BINDING ) );
-                pMenu->SetItemText( m_nRemoveId, SVX_RESSTR( RID_STR_DATANAV_REMOVE_BINDING ) );
+                m_xMenu->SetItemText(m_xMenu->GetItemId("additem"), SVX_RESSTR(RID_STR_DATANAV_ADD_BINDING));
+                m_xMenu->SetItemText(m_xMenu->GetItemId("edit"), SVX_RESSTR(RID_STR_DATANAV_EDIT_BINDING));
+                m_xMenu->SetItemText(m_xMenu->GetItemId("delete"), SVX_RESSTR(RID_STR_DATANAV_REMOVE_BINDING));
             }
         }
-        m_pXFormsPage->EnableMenuItems( pMenu.get() );
-        return pMenu;
+        m_pXFormsPage->EnableMenuItems(m_xMenu.get());
+        return m_xMenu;
     }
 
     void DataTreeListBox::ExecuteContextMenuAction( sal_uInt16 _nSelectedPopupEntry )
     {
-        m_pXFormsPage->DoMenuAction( _nSelectedPopupEntry );
+        if (m_xMenu->GetItemId("additem") == _nSelectedPopupEntry)
+            m_pXFormsPage->DoMenuAction(m_nAddId);
+        else if (m_xMenu->GetItemId("addelement") == _nSelectedPopupEntry)
+            m_pXFormsPage->DoMenuAction(m_nAddElementId);
+        else if (m_xMenu->GetItemId("addattribute") == _nSelectedPopupEntry)
+            m_pXFormsPage->DoMenuAction(m_nAddAttributeId);
+        else if (m_xMenu->GetItemId("edit") == _nSelectedPopupEntry)
+            m_pXFormsPage->DoMenuAction(m_nEditId);
+        else if (m_xMenu->GetItemId("delete") == _nSelectedPopupEntry)
+            m_pXFormsPage->DoMenuAction(m_nRemoveId);
     }
 
     void DataTreeListBox::RemoveEntry( SvTreeListEntry* _pEntry )
@@ -766,10 +781,6 @@ namespace svxform
             }
             bIsDocModified = RemoveEntry();
         }
-        else if(_nToolBoxID == MID_INSERT_CONTROL)
-        {
-            OSL_FAIL( "XFormsPage::DoToolboxAction: MID_INSERT_CONTROL not implemented, yet!" );
-        }
         else
         {
             OSL_FAIL( "XFormsPage::DoToolboxAction: unknown ID!" );
@@ -1304,11 +1315,11 @@ namespace svxform
 
         if ( _pMenu )
         {
-            _pMenu->EnableItem( m_nAddId, bEnableAdd );
-            _pMenu->EnableItem( m_nAddElementId, bEnableAdd );
-            _pMenu->EnableItem( m_nAddAttributeId, bEnableAdd );
-            _pMenu->EnableItem( m_nEditId, bEnableEdit );
-            _pMenu->EnableItem( m_nRemoveId, bEnableRemove );
+            _pMenu->EnableItem(_pMenu->GetItemId("additem"), bEnableAdd);
+            _pMenu->EnableItem(_pMenu->GetItemId("addelement"), bEnableAdd);
+            _pMenu->EnableItem(_pMenu->GetItemId("addattribute"), bEnableAdd);
+            _pMenu->EnableItem(_pMenu->GetItemId("edit"), bEnableEdit);
+            _pMenu->EnableItem(_pMenu->GetItemId("delete"), bEnableRemove);
         }
         if ( DGTInstance == m_eGroup )
         {
@@ -1338,8 +1349,8 @@ namespace svxform
             m_pToolBox->SetItemText( m_nRemoveId, SVX_RESSTR( nResId2 ) );
             if ( _pMenu )
             {
-                _pMenu->SetItemText( m_nEditId, SVX_RESSTR( nResId1 ) );
-                _pMenu->SetItemText( m_nRemoveId, SVX_RESSTR( nResId2 ) );
+                _pMenu->SetItemText(_pMenu->GetItemId("edit"), SVX_RESSTR( nResId1 ) );
+                _pMenu->SetItemText(_pMenu->GetItemId("delete"), SVX_RESSTR( nResId2 ) );
             }
         }
     }
diff --git a/svx/source/form/datanavi.src b/svx/source/form/datanavi.src
index 76c1c886febe..429b48fc38e2 100644
--- a/svx/source/form/datanavi.src
+++ b/svx/source/form/datanavi.src
@@ -17,7 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "datanavi.hrc"
 #include "svx/dialogs.hrc"
 #include "svx/fmresids.hrc"
 #include "fmhelp.hrc"
@@ -117,58 +116,6 @@ String RID_STR_EMPTY_SUBMISSIONNAME
     Text [ en-US ] = "The submission must have a name." ;
 };
 
-Menu RID_MENU_DATANAVIGATOR
-{
-    ItemList =
-    {
-        // MID_INSERT_CONTROL not implemented, yet (#i99890#)
-        /*MenuItem
-        {
-            Identifier = MID_INSERT_CONTROL ;
-            HelpId = HID_XFORMS_MID_INSERT_CONTROL ;
-            Text [ en-US ] = "Insert Control" ;
-        };
-        MenuItem
-        {
-            Separator = TRUE;
-        };*/
-        MenuItem
-        {
-            Identifier = TBI_ITEM_ADD ;
-            HelpId = HID_XFORMS_TOOLBOX_ITEM_ADD ;
-            Text [ en-US ] = "Add Item" ;
-        };
-        MenuItem
-        {
-            Identifier = TBI_ITEM_ADD_ELEMENT ;
-            HelpId = HID_XFORMS_TOOLBOX_ITEM_ADD_ELEMENT ;
-            Text [ en-US ] = "Add Element" ;
-        };
-        MenuItem
-        {
-            Identifier = TBI_ITEM_ADD_ATTRIBUTE ;
-            HelpId = HID_XFORMS_TOOLBOX_ITEM_ADD_ATTRIBUTE ;
-            Text [ en-US ] = "Add Attribute" ;
-        };
-        MenuItem
-        {
-            Identifier = TBI_ITEM_EDIT ;
-            HelpId = HID_XFORMS_TOOLBOX_ITEM_EDIT ;
-            Text [ en-US ] = "Edit" ;
-        };
-        MenuItem
-        {
-            Separator = TRUE;
-        };
-        MenuItem
-        {
-            Identifier = TBI_ITEM_REMOVE ;
-            HelpId = HID_XFORMS_TOOLBOX_ITEM_REMOVE ;
-            Text [ en-US ] = "Delete" ;
-        };
-    };
-};
-
 String RID_STR_METHOD_POST
 {
     Text [ en-US ] = "Post" ;
diff --git a/svx/source/inc/datanavi.hrc b/svx/source/inc/datanavi.hrc
deleted file mode 100644
index f51cec3bc48a..000000000000
--- a/svx/source/inc/datanavi.hrc
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_SVX_SOURCE_INC_DATANAVI_HRC
-#define INCLUDED_SVX_SOURCE_INC_DATANAVI_HRC
-
-// class XFormsInstancePage
-
-// Menu items
-#define MID_INSERT_CONTROL      100
-
-// ToolBox items
-#define TBI_ITEM_ADD            10
-#define TBI_ITEM_ADD_ELEMENT    11
-#define TBI_ITEM_ADD_ATTRIBUTE  12
-#define TBI_ITEM_EDIT           13
-#define TBI_ITEM_REMOVE         14
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/datanavi.hxx b/svx/source/inc/datanavi.hxx
index 123c986cbb44..b40eb78daeee 100644
--- a/svx/source/inc/datanavi.hxx
+++ b/svx/source/inc/datanavi.hxx
@@ -103,6 +103,8 @@ namespace svxform
     class DataTreeListBox : public SvTreeListBox
     {
     private:
+        std::unique_ptr<VclBuilder> m_xBuilder;
+        VclPtr<PopupMenu>       m_xMenu;
         VclPtr<XFormsPage>      m_pXFormsPage;
         DataGroupType           m_eGroup;
         sal_uInt16              m_nAddId;
diff --git a/svx/uiconfig/ui/formdatamenu.ui b/svx/uiconfig/ui/formdatamenu.ui
new file mode 100644
index 000000000000..31efe171edee
--- /dev/null
+++ b/svx/uiconfig/ui/formdatamenu.ui
@@ -0,0 +1,55 @@
+<?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="additem">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Add Item</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="addelement">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Add Element</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="addattribute">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Add Attribute</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="edit">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Edit</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="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>
commit 89fbccd2ae0a0fdf1b71e37e6edac6bf85e2e766
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Apr 15 19:26:28 2017 +0100

    these should be check buttons
    
    Change-Id: Ied247b0304cca552d55a826c8b224dc917df7a75

diff --git a/svx/uiconfig/ui/formnavimenu.ui b/svx/uiconfig/ui/formnavimenu.ui
index f1325a52d98e..e63337c02e73 100644
--- a/svx/uiconfig/ui/formnavimenu.ui
+++ b/svx/uiconfig/ui/formnavimenu.ui
@@ -100,7 +100,7 @@
       </object>
     </child>
     <child>
-      <object class="GtkMenuItem" id="designmode">
+      <object class="GtkCheckMenuItem" id="designmode">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="label" translatable="yes">Open in Design Mode</property>
@@ -108,7 +108,7 @@
       </object>
     </child>
     <child>
-      <object class="GtkMenuItem" id="controlfocus">
+      <object class="GtkCheckMenuItem" id="controlfocus">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="label" translatable="yes">Automatic Control Focus</property>


More information about the Libreoffice-commits mailing list