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/source/stbctrls | |
parent | c2511f27768341e33b452429b6dac38efa039804 (diff) |
convert function menu to .ui
Change-Id: I6ff1ccc0fb20c638c7bdb587c8fe81a710a49d21
Diffstat (limited to 'svx/source/stbctrls')
-rw-r--r-- | svx/source/stbctrls/pszctrl.cxx | 84 | ||||
-rw-r--r-- | svx/source/stbctrls/stbctrls.src | 56 |
2 files changed, 65 insertions, 75 deletions
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" ; |