diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-04-14 15:27:27 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-04-14 15:34:40 +0100 |
commit | aca25d6123da5e6da9b3f25ac0347a479b1d5526 (patch) | |
tree | 9e8c79ccaa261c354609e31505554e39a1e6c3c8 /svx | |
parent | c2511f27768341e33b452429b6dac38efa039804 (diff) |
convert function menu to .ui
Change-Id: I6ff1ccc0fb20c638c7bdb587c8fe81a710a49d21
Diffstat (limited to 'svx')
-rw-r--r-- | svx/UIConfig_svx.mk | 1 | ||||
-rw-r--r-- | svx/inc/helpid.hrc | 8 | ||||
-rw-r--r-- | svx/source/stbctrls/pszctrl.cxx | 84 | ||||
-rw-r--r-- | svx/source/stbctrls/stbctrls.src | 56 | ||||
-rw-r--r-- | svx/uiconfig/ui/functionmenu.ui | 66 |
5 files changed, 132 insertions, 83 deletions
diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index f68a66650128..6223380663a1 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -43,6 +43,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\ svx/uiconfig/ui/fontworkgallerydialog \ svx/uiconfig/ui/fontworkspacingdialog \ svx/uiconfig/ui/formlinkwarndialog \ + svx/uiconfig/ui/functionmenu \ svx/uiconfig/ui/gallerymenu1 \ svx/uiconfig/ui/gallerymenu2 \ svx/uiconfig/ui/headfootformatpage \ diff --git a/svx/inc/helpid.hrc b/svx/inc/helpid.hrc index 75e7079434ea..8312e935d7fe 100644 --- a/svx/inc/helpid.hrc +++ b/svx/inc/helpid.hrc @@ -41,14 +41,6 @@ #define HID_GALLERY_RENAME "SVX_HID_GALLERY_RENAME" #define HID_GALLERY_THEMELIST "SVX_HID_GALLERY_THEMELIST" #define HID_GALLERY_WINDOW "SVX_HID_GALLERY_WINDOW" -#define HID_MNU_FUNC_AVG "SVX_HID_MNU_FUNC_AVG" -#define HID_MNU_FUNC_COUNT "SVX_HID_MNU_FUNC_COUNT" -#define HID_MNU_FUNC_COUNT2 "SVX_HID_MNU_FUNC_COUNT2" -#define HID_MNU_FUNC_MAX "SVX_HID_MNU_FUNC_MAX" -#define HID_MNU_FUNC_MIN "SVX_HID_MNU_FUNC_MIN" -#define HID_MNU_FUNC_NONE "SVX_HID_MNU_FUNC_NONE" -#define HID_MNU_FUNC_SUM "SVX_HID_MNU_FUNC_SUM" -#define HID_MNU_FUNC_SELECTION_COUNT "SVX_HID_MNU_FUNC_SELECTION_COUNT" #define HID_POPUP_COLOR "SVX_HID_POPUP_COLOR" #define HID_POPUP_COLOR_CTRL "SVX_HID_POPUP_COLOR_CTRL" #define HID_POPUP_FRAME "SVX_HID_POPUP_FRAME" diff --git a/svx/source/stbctrls/pszctrl.cxx b/svx/source/stbctrls/pszctrl.cxx index a6cc6bb0aec0..c19f02cb3114 100644 --- a/svx/source/stbctrls/pszctrl.cxx +++ b/svx/source/stbctrls/pszctrl.cxx @@ -18,6 +18,7 @@ */ #include <limits.h> +#include <vcl/builder.hxx> #include <vcl/status.hxx> #include <vcl/menu.hxx> #include <vcl/image.hxx> @@ -89,33 +90,78 @@ OUString SvxPosSizeStatusBarControl::GetMetricStr_Impl( long nVal ) SFX_IMPL_STATUSBAR_CONTROL(SvxPosSizeStatusBarControl, SvxSizeItem); -class FunctionPopup_Impl : public PopupMenu +class FunctionPopup_Impl { + VclBuilder m_aBuilder; + VclPtr<PopupMenu> m_xMenu; + sal_uInt32 m_nSelected; + static sal_uInt16 id_to_function(const OString& rIdent); + sal_uInt16 function_to_id(sal_uInt16 nFunc) const; public: explicit FunctionPopup_Impl( sal_uInt32 nCheckEncoded ); - - sal_uInt32 GetSelected() const { return nSelected; } - -private: - sal_uInt32 nSelected; - - virtual void Select() override; + sal_uInt16 Execute(vcl::Window* pWindow, const Point& rPopupPos) { return m_xMenu->Execute(pWindow, rPopupPos); } + sal_uInt32 GetSelected() const; }; +sal_uInt16 FunctionPopup_Impl::id_to_function(const OString& rIdent) +{ + if (rIdent == "avg") + return PSZ_FUNC_AVG; + else if (rIdent == "counta") + return PSZ_FUNC_COUNT2; + else if (rIdent == "count") + return PSZ_FUNC_COUNT; + else if (rIdent == "max") + return PSZ_FUNC_MAX; + else if (rIdent == "min") + return PSZ_FUNC_MIN; + else if (rIdent == "sum") + return PSZ_FUNC_SUM; + else if (rIdent == "selection") + return PSZ_FUNC_SELECTION_COUNT; + else if (rIdent == "none") + return PSZ_FUNC_NONE; + return 0; +} -FunctionPopup_Impl::FunctionPopup_Impl( sal_uInt32 nCheckEncoded ) : - PopupMenu( ResId( RID_SVXMNU_PSZ_FUNC, DIALOG_MGR() ) ), - nSelected( nCheckEncoded ) +sal_uInt16 FunctionPopup_Impl::function_to_id(sal_uInt16 nFunc) const +{ + switch (nFunc) + { + case PSZ_FUNC_AVG: + return m_xMenu->GetItemId("avg"); + case PSZ_FUNC_COUNT2: + return m_xMenu->GetItemId("counta"); + case PSZ_FUNC_COUNT: + return m_xMenu->GetItemId("count"); + case PSZ_FUNC_MAX: + return m_xMenu->GetItemId("max"); + case PSZ_FUNC_MIN: + return m_xMenu->GetItemId("min"); + case PSZ_FUNC_SUM: + return m_xMenu->GetItemId("sum"); + case PSZ_FUNC_SELECTION_COUNT: + return m_xMenu->GetItemId("selection"); + case PSZ_FUNC_NONE: + return m_xMenu->GetItemId("none"); + } + return 0; +} + +FunctionPopup_Impl::FunctionPopup_Impl(sal_uInt32 nCheckEncoded) + : m_aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "svx/ui/functionmenu.ui", "") + , m_xMenu(m_aBuilder.get_menu("menu")) + , m_nSelected(nCheckEncoded) { for ( sal_uInt16 nCheck = 1; nCheck < 32; ++nCheck ) if ( nCheckEncoded & (1 << nCheck) ) - CheckItem( nCheck ); + m_xMenu->CheckItem(function_to_id(nCheck)); } - -void FunctionPopup_Impl::Select() +sal_uInt32 FunctionPopup_Impl::GetSelected() const { - sal_uInt16 nCurItemId = GetCurItemId(); + sal_uInt32 nSelected = m_nSelected; + sal_uInt16 nCurItemId = id_to_function(m_xMenu->GetCurItemIdent()); if ( nCurItemId == PSZ_FUNC_NONE ) nSelected = ( 1 << PSZ_FUNC_NONE ); else @@ -125,6 +171,7 @@ void FunctionPopup_Impl::Select() if ( !nSelected ) nSelected = ( 1 << PSZ_FUNC_NONE ); } + return nSelected; } struct SvxPosSizeStatusBarControl_Impl @@ -305,10 +352,10 @@ void SvxPosSizeStatusBarControl::Command( const CommandEvent& rCEvt ) sal_uInt32 nSelect = pImpl->nFunctionSet; if (!nSelect) nSelect = ( 1 << PSZ_FUNC_NONE ); - ScopedVclPtrInstance<FunctionPopup_Impl> aMenu( nSelect ); - if ( aMenu->Execute( &GetStatusBar(), rCEvt.GetMousePosPixel() ) ) + FunctionPopup_Impl aMenu(nSelect); + if (aMenu.Execute(&GetStatusBar(), rCEvt.GetMousePosPixel())) { - nSelect = aMenu->GetSelected(); + nSelect = aMenu.GetSelected(); if (nSelect) { if (nSelect == (1 << PSZ_FUNC_NONE)) @@ -323,7 +370,6 @@ void SvxPosSizeStatusBarControl::Command( const CommandEvent& rCEvt ) aArgs[0].Value = a; execute( ".uno:StatusBarFunc", aArgs ); -// GetBindings().GetDispatcher()->Execute( SID_PSZ_FUNCTION, SfxCallMode::RECORD, &aItem, 0L ); } } } diff --git a/svx/source/stbctrls/stbctrls.src b/svx/source/stbctrls/stbctrls.src index 0039a2be2958..f68fbf243795 100644 --- a/svx/source/stbctrls/stbctrls.src +++ b/svx/source/stbctrls/stbctrls.src @@ -156,62 +156,6 @@ String RID_SIDEBAR_EMPTY_PANEL_TEXT Text [ en-US ] = "Properties for the task that you are performing are not available for the current selection" ; }; -// Choice of functions on the SvxPosSizeStatusBarControl for Calc -Menu RID_SVXMNU_PSZ_FUNC -{ - ItemList = - { - MenuItem - { - Identifier = PSZ_FUNC_AVG ; - HelpId = HID_MNU_FUNC_AVG ; - Text [ en-US ] = "Average" ; - }; - MenuItem - { - Identifier = PSZ_FUNC_COUNT2 ; - HelpId = HID_MNU_FUNC_COUNT2 ; - Text [ en-US ] = "CountA" ; - }; - MenuItem - { - Identifier = PSZ_FUNC_COUNT ; - HelpId = HID_MNU_FUNC_COUNT ; - Text [ en-US ] = "Count" ; - }; - MenuItem - { - Identifier = PSZ_FUNC_MAX ; - HelpId = HID_MNU_FUNC_MAX ; - Text [ en-US ] = "Maximum" ; - }; - MenuItem - { - Identifier = PSZ_FUNC_MIN ; - HelpId = HID_MNU_FUNC_MIN ; - Text [ en-US ] = "Minimum" ; - }; - MenuItem - { - Identifier = PSZ_FUNC_SUM ; - HelpId = HID_MNU_FUNC_SUM ; - Text [ en-US ] = "Sum" ; - }; - MenuItem - { - Identifier = PSZ_FUNC_SELECTION_COUNT ; - HelpId = HID_MNU_FUNC_SELECTION_COUNT ; - Text [ en-US ] = "Selection count" ; - }; - MenuItem - { - Identifier = PSZ_FUNC_NONE ; - HelpId = HID_MNU_FUNC_NONE ; - Text [ en-US ] = "None" ; - }; - }; -}; - Bitmap RID_SVXBMP_POSITION { File = "sc10223.png" ; diff --git a/svx/uiconfig/ui/functionmenu.ui b/svx/uiconfig/ui/functionmenu.ui new file mode 100644 index 000000000000..bc7d064f0712 --- /dev/null +++ b/svx/uiconfig/ui/functionmenu.ui @@ -0,0 +1,66 @@ +<?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="GtkCheckMenuItem" id="avg"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Average</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkCheckMenuItem" id="counta"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">CountA</property> + </object> + </child> + <child> + <object class="GtkCheckMenuItem" id="count"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Count</property> + </object> + </child> + <child> + <object class="GtkCheckMenuItem" id="max"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Maximum</property> + </object> + </child> + <child> + <object class="GtkCheckMenuItem" id="min"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Minimum</property> + </object> + </child> + <child> + <object class="GtkCheckMenuItem" id="sum"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Sum</property> + </object> + </child> + <child> + <object class="GtkCheckMenuItem" id="selection"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Selection count</property> + </object> + </child> + <child> + <object class="GtkCheckMenuItem" id="none"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">None</property> + </object> + </child> + </object> +</interface> |