From aca25d6123da5e6da9b3f25ac0347a479b1d5526 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 14 Apr 2017 15:27:27 +0100 Subject: convert function menu to .ui Change-Id: I6ff1ccc0fb20c638c7bdb587c8fe81a710a49d21 --- svx/UIConfig_svx.mk | 1 + svx/inc/helpid.hrc | 8 ---- svx/source/stbctrls/pszctrl.cxx | 84 +++++++++++++++++++++++++++++++--------- svx/source/stbctrls/stbctrls.src | 56 --------------------------- svx/uiconfig/ui/functionmenu.ui | 66 +++++++++++++++++++++++++++++++ 5 files changed, 132 insertions(+), 83 deletions(-) create mode 100644 svx/uiconfig/ui/functionmenu.ui (limited to 'svx') 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 +#include #include #include #include @@ -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 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 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 @@ + + + + + + True + False + + + True + False + Average + True + + + + + True + False + CountA + + + + + True + False + Count + + + + + True + False + Maximum + + + + + True + False + Minimum + + + + + True + False + Sum + + + + + True + False + Selection count + + + + + True + False + None + + + + -- cgit