summaryrefslogtreecommitdiff
path: root/svx/source/stbctrls/pszctrl.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-04-14 15:27:27 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-04-14 15:34:40 +0100
commitaca25d6123da5e6da9b3f25ac0347a479b1d5526 (patch)
tree9e8c79ccaa261c354609e31505554e39a1e6c3c8 /svx/source/stbctrls/pszctrl.cxx
parentc2511f27768341e33b452429b6dac38efa039804 (diff)
convert function menu to .ui
Change-Id: I6ff1ccc0fb20c638c7bdb587c8fe81a710a49d21
Diffstat (limited to 'svx/source/stbctrls/pszctrl.cxx')
-rw-r--r--svx/source/stbctrls/pszctrl.cxx84
1 files changed, 65 insertions, 19 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 );
}
}
}