diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-04-14 16:32:02 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-04-14 16:33:32 +0100 |
commit | 7a01268f3fccd9cb43097f27696fec563f21b336 (patch) | |
tree | 817c6128b81246b69b93c3e027d7050784ab0cf6 /svx/source/fmcomp | |
parent | 975440b9189602b5a10059d892cb09e6849148f7 (diff) |
convert rows menu to .ui
Change-Id: If81b5e23c1699822899c929b486850ac06776c76
Diffstat (limited to 'svx/source/fmcomp')
-rw-r--r-- | svx/source/fmcomp/gridctrl.cxx | 39 | ||||
-rw-r--r-- | svx/source/fmcomp/gridctrl.src | 24 |
2 files changed, 16 insertions, 47 deletions
diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx index 275b19b96910..c4ee149afe30 100644 --- a/svx/source/fmcomp/gridctrl.cxx +++ b/svx/source/fmcomp/gridctrl.cxx @@ -44,6 +44,7 @@ #include <tools/resid.hxx> #include <tools/diagnose_ex.h> #include <tools/fract.hxx> +#include <vcl/builder.hxx> #include <vcl/menu.hxx> #include <vcl/settings.hxx> @@ -2698,8 +2699,8 @@ void DbGridControl::PreExecuteRowContextMenu(sal_uInt16 /*nRow*/, PopupMenu& rMe // if only a blank row is selected than do not delete bDelete = bDelete && !((m_nOptions & DbGridControlOptions::Insert) && GetSelectRowCount() == 1 && IsRowSelected(GetRowCount() - 1)); - rMenu.EnableItem(SID_FM_DELETEROWS, bDelete); - rMenu.EnableItem(SID_FM_RECORD_SAVE, IsModified()); + rMenu.EnableItem(rMenu.GetItemId("delete"), bDelete); + rMenu.EnableItem(rMenu.GetItemId("save"), IsModified()); // the undo is more difficult bool bCanUndo = IsModified(); @@ -2708,28 +2709,22 @@ void DbGridControl::PreExecuteRowContextMenu(sal_uInt16 /*nRow*/, PopupMenu& rMe nState = m_aMasterStateProvider.Call(DbGridControlNavigationBarState::Undo); bCanUndo &= ( 0 != nState ); - rMenu.EnableItem(SID_FM_RECORD_UNDO, bCanUndo); + rMenu.EnableItem(rMenu.GetItemId("undo"), bCanUndo); } -void DbGridControl::PostExecuteRowContextMenu(sal_uInt16 /*nRow*/, const PopupMenu& /*rMenu*/, sal_uInt16 nExecutionResult) +void DbGridControl::PostExecuteRowContextMenu(sal_uInt16 /*nRow*/, const PopupMenu& rMenu, sal_uInt16 nExecutionResult) { - switch (nExecutionResult) + if (nExecutionResult == rMenu.GetItemId("delete")) { - case SID_FM_DELETEROWS: - // delete asynchronously - if (m_nDeleteEvent) - Application::RemoveUserEvent(m_nDeleteEvent); - m_nDeleteEvent = Application::PostUserEvent(LINK(this,DbGridControl,OnDelete), nullptr, true); - break; - case SID_FM_RECORD_UNDO: - Undo(); - break; - case SID_FM_RECORD_SAVE: - SaveRow(); - break; - default: - break; + // delete asynchronously + if (m_nDeleteEvent) + Application::RemoveUserEvent(m_nDeleteEvent); + m_nDeleteEvent = Application::PostUserEvent(LINK(this,DbGridControl,OnDelete), nullptr, true); } + else if (nExecutionResult == rMenu.GetItemId("undo")) + Undo(); + else if (nExecutionResult == rMenu.GetItemId("save")) + SaveRow(); } void DbGridControl::DataSourcePropertyChanged(const PropertyChangeEvent& evt) @@ -2822,14 +2817,12 @@ void DbGridControl::copyCellText(sal_Int32 _nRow, sal_uInt16 _nColId) void DbGridControl::executeRowContextMenu( long _nRow, const Point& _rPreferredPos ) { - ScopedVclPtrInstance<PopupMenu> aContextMenu( SVX_RES( RID_SVXMNU_ROWS ) ); + VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "svx/ui/rowsmenu.ui", ""); + VclPtr<PopupMenu> aContextMenu(aBuilder.get_menu("menu")); PreExecuteRowContextMenu( (sal_uInt16)_nRow, *aContextMenu.get() ); aContextMenu->RemoveDisabledEntries( true, true ); PostExecuteRowContextMenu( (sal_uInt16)_nRow, *aContextMenu.get(), aContextMenu->Execute( this, _rPreferredPos ) ); - - // TODO: why this weird cast to sal_uInt16? What if we really have more than 65535 lines? - // -> change this to sal_uInt32 } void DbGridControl::Command(const CommandEvent& rEvt) diff --git a/svx/source/fmcomp/gridctrl.src b/svx/source/fmcomp/gridctrl.src index 112f77f6161a..b5365864420e 100644 --- a/svx/source/fmcomp/gridctrl.src +++ b/svx/source/fmcomp/gridctrl.src @@ -22,30 +22,6 @@ #include "fmhelp.hrc" #include <svx/svxcommands.h> -Menu RID_SVXMNU_ROWS -{ - ItemList = - { - MenuItem - { - Identifier = SID_FM_DELETEROWS ; - HelpId = HID_FM_DELETEROWS ; - Text [ en-US ] = "Delete Rows" ; - }; - MenuItem - { - Identifier = SID_FM_RECORD_SAVE ; - HelpId = CMD_SID_FM_RECORD_SAVE ; - Text [ en-US ] = "Save Record" ; - }; - MenuItem - { - Identifier = SID_FM_RECORD_UNDO ; - HelpId = CMD_SID_FM_RECORD_UNDO ; - Text [ en-US ] = "Undo: Data entry" ; - }; - }; -}; Menu RID_SVXMNU_COLS { ItemList = |