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

Caolán McNamara caolanm at redhat.com
Wed Apr 12 08:58:58 UTC 2017


 include/svx/dialogs.hrc          |    5 -----
 svx/UIConfig_svx.mk              |    1 +
 svx/source/tbxctrls/tbcontrl.cxx |   34 ++++++++++++++++++----------------
 svx/source/tbxctrls/tbcontrl.src |   17 -----------------
 svx/uiconfig/ui/stylemenu.ui     |   25 +++++++++++++++++++++++++
 5 files changed, 44 insertions(+), 38 deletions(-)

New commits:
commit 3cee2b2d5823e83fbfa01b2987df2452f75fc777
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Apr 12 09:58:00 2017 +0100

    convert style menu to .ui
    
    Change-Id: I85683007062c4cc1160ace7b3bf962ee5c021b6e

diff --git a/include/svx/dialogs.hrc b/include/svx/dialogs.hrc
index 575bba598d64..d384997129c8 100644
--- a/include/svx/dialogs.hrc
+++ b/include/svx/dialogs.hrc
@@ -198,11 +198,6 @@
 #define RID_SVXBMP_SIGNET_BROKEN            (RID_SVX_START + 114)
 #define RID_SVXBMP_SIGNET_NOTVALIDATED      (RID_SVX_START + 115)
 
-// for Toolbox-Control style
-#define RID_SVX_STYLE_MENU                  (RID_SVX_START + 121)
-#define RID_SVX_UPDATE_STYLE                (RID_SVX_START + 122)
-#define RID_SVX_MODIFY_STYLE                (RID_SVX_START + 123)
-
 #define RID_SVXCTRL_RECTBTNS                (RID_SVX_START + 226)
 
 // ResId's for Starone impl. bitmaps
diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk
index 82e6e7ad7c64..20c0eaae0919 100644
--- a/svx/UIConfig_svx.mk
+++ b/svx/UIConfig_svx.mk
@@ -77,6 +77,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\
 	svx/uiconfig/ui/sidebarpossize \
 	svx/uiconfig/ui/sidebarstylespanel \
 	svx/uiconfig/ui/sidebartextpanel \
+	svx/uiconfig/ui/stylemenu \
 	svx/uiconfig/ui/textcharacterspacingcontrol \
 	svx/uiconfig/ui/textcontrolchardialog \
 	svx/uiconfig/ui/textcontrolparadialog \
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index e21eb758fbee..e15a571fb1e2 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -169,7 +169,8 @@ private:
     OUString                        sDefaultStyle;
     bool                            bInSpecialMode;
     VclPtr<MenuButton>              m_pButtons[MAX_STYLES_ENTRIES];
-    ScopedVclPtr<PopupMenu>         m_pMenu;
+    VclBuilder                      m_aBuilder;
+    VclPtr<PopupMenu>               m_pMenu;
 
     void            ReleaseFocus();
     static Color    TestColorsVisible(const Color &FontCol, const Color &BackCol);
@@ -360,7 +361,8 @@ SvxStyleBox_Impl::SvxStyleBox_Impl(vcl::Window* pParent,
     , aClearFormatKey( rClearFormatKey )
     , aMoreKey( rMoreKey )
     , bInSpecialMode( bInSpec )
-    , m_pMenu( VclPtr<PopupMenu>::Create(SVX_RES( RID_SVX_STYLE_MENU )) )
+    , m_aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "svx/ui/stylemenu.ui", "")
+    , m_pMenu(m_aBuilder.get_menu("menu"))
 {
     SetHelpId(HID_STYLE_LISTBOX);
     m_pMenu->SetSelectHdl( LINK( this, SvxStyleBox_Impl, MenuSelectHdl ) );
@@ -387,6 +389,9 @@ void SvxStyleBox_Impl::dispose()
         rButton.disposeAndClear();
     }
 
+    m_pMenu.clear();
+    m_aBuilder.disposeBuilder();
+
     ComboBox::dispose();
 }
 
@@ -404,7 +409,7 @@ void SvxStyleBox_Impl::ReleaseFocus()
 IMPL_LINK( SvxStyleBox_Impl, MenuSelectHdl, Menu*, pMenu, bool)
 {
     OUString sEntry = GetSelectEntry();
-    sal_uInt16 nMenuId = pMenu->GetCurItemId();
+    OString sMenuIdent = pMenu->GetCurItemIdent();
     ReleaseFocus(); // It must be after getting entry pos!
     if (IsInDropDown())
         ToggleDropDown();
@@ -414,20 +419,17 @@ IMPL_LINK( SvxStyleBox_Impl, MenuSelectHdl, Menu*, pMenu, bool)
     aArgs[1].Name   = "Family";
     aArgs[1].Value  <<= sal_Int16( eStyleFamily );
 
-    switch(nMenuId) {
-        case RID_SVX_UPDATE_STYLE:
-        {
-            SfxToolBoxControl::Dispatch( m_xDispatchProvider,
-                ".uno:StyleUpdateByExample", aArgs );
-            break;
-        }
-        case RID_SVX_MODIFY_STYLE:
-        {
-            SfxToolBoxControl::Dispatch( m_xDispatchProvider,
-                ".uno:EditStyle", aArgs );
-            break;
-        }
+    if (sMenuIdent == "update")
+    {
+        SfxToolBoxControl::Dispatch( m_xDispatchProvider,
+            ".uno:StyleUpdateByExample", aArgs );
     }
+    else if (sMenuIdent == "edit")
+    {
+        SfxToolBoxControl::Dispatch( m_xDispatchProvider,
+            ".uno:EditStyle", aArgs );
+    }
+
     return false;
 }
 
diff --git a/svx/source/tbxctrls/tbcontrl.src b/svx/source/tbxctrls/tbcontrl.src
index 6b22d064dce0..18bab3e22a08 100644
--- a/svx/source/tbxctrls/tbcontrl.src
+++ b/svx/source/tbxctrls/tbcontrl.src
@@ -114,23 +114,6 @@ String RID_SVXSTR_MOREBULLETS
     Text [ en-US ] = "More Bullets..." ;
 };
 
-Menu RID_SVX_STYLE_MENU
-{
-    ItemList =
-    {
-        MenuItem
-        {
-            Identifier = RID_SVX_UPDATE_STYLE ;
-            Text [ en-US ] = "Update to Match Selection" ;
-        };
-        MenuItem
-        {
-            Identifier = RID_SVX_MODIFY_STYLE ;
-            Text [ en-US ] = "Edit Style..." ;
-        };
-    };
-};
-
 String RID_SVXSTR_BY_AUTHOR
 {
     Text [ en-US ] = "By author";
diff --git a/svx/uiconfig/ui/stylemenu.ui b/svx/uiconfig/ui/stylemenu.ui
new file mode 100644
index 000000000000..8773fcfcf066
--- /dev/null
+++ b/svx/uiconfig/ui/stylemenu.ui
@@ -0,0 +1,25 @@
+<?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="update">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Update to Match Selection</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 Style...</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+  </object>
+</interface>


More information about the Libreoffice-commits mailing list