From 54d5b1828ec73d0475e0ddb6e31394a7e1904a1b Mon Sep 17 00:00:00 2001 From: Maxim Monastirsky Date: Thu, 9 Feb 2017 00:31:24 +0200 Subject: tdf#105672 framework managed menu button This adds a menu button that can use a popup menu controller to manage its menu. It supports 2 cases: - Use any controller that is registered in Controller.xcu, by specifing its .uno command. - Manage an arbitrary popup menu with MenuBarManager (assuming its items have proper .uno commands in their MenuItemData::aCommandStr). It means that a menu that was defined in a .ui file, can be used inside that .ui file without any additional code. This commit uses the new control to fix some currently non-working buttons in Calc's Notebookbar (but there are more that can be fixed the same way). It's not clear how long we will continue to use buttons (instead of toolboxes) for the Notebookbar, but hopefully this control will be useful in other places too. Change-Id: Ie00cde7cd7e39948948960ca2eff76e9db837109 Reviewed-on: https://gerrit.libreoffice.org/34103 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky --- toolkit/source/awt/vclxmenu.cxx | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'toolkit') diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx index bcf081c89ee1..2650fa802cbd 100644 --- a/toolkit/source/awt/vclxmenu.cxx +++ b/toolkit/source/awt/vclxmenu.cxx @@ -79,6 +79,12 @@ void VCLXMenu::ImplCreateMenu( bool bPopup ) mpMenu->AddEventListener( LINK( this, VCLXMenu, MenuEventListener ) ); } +void VCLXMenu::ImplAddListener() +{ + assert(mpMenu); + mpMenu->AddEventListener( LINK( this, VCLXMenu, MenuEventListener ) ); +} + IMPL_LINK( VCLXMenu, MenuEventListener, VclMenuEvent&, rMenuEvent, void ) { DBG_ASSERT( rMenuEvent.GetMenu() && mpMenu, "Menu???" ); @@ -858,6 +864,7 @@ VCLXPopupMenu::VCLXPopupMenu() VCLXPopupMenu::VCLXPopupMenu( PopupMenu* pPopMenu ) : VCLXMenu( static_cast(pPopMenu) ) { + ImplAddListener(); } extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL -- cgit