framework/inc/classes/resource.hrc | 1 framework/inc/uielement/menubarmanager.hxx | 20 -- framework/source/classes/resource.src | 5 framework/source/fwe/classes/addonmenu.cxx | 89 +-------- framework/source/fwe/xml/menudocumenthandler.cxx | 10 - framework/source/uielement/menubarmanager.cxx | 227 +++++------------------ include/framework/addonmenu.hxx | 49 ---- include/framework/menuconfiguration.hxx | 12 - include/sfx2/sfxsids.hrc | 1 sfx2/sdi/appslots.sdi | 3 sfx2/sdi/sfx.sdi | 17 - vcl/source/window/menu.cxx | 5 12 files changed, 81 insertions(+), 358 deletions(-)
New commits: commit 3884bb38f0712b6b1616b5d788cd00e90b14fcd3 Author: Maxim Monastirsky <momonas...@gmail.com> Date: Thu May 18 00:08:39 2017 +0300 Remove slot usage from MenuBarManager Change-Id: I9d6a8c541da3bfeb1fddbf8aa3c9cef6e37cc917 diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 499b207133e4..fac26401f590 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -92,21 +92,9 @@ const sal_uInt16 ADDONMENU_MERGE_ITEMID_START = 1500; namespace framework { -// special menu ids/command ids for dynamic popup menus -#define SID_SFX_START 5000 -#define SID_MDIWINDOWLIST (SID_SFX_START + 610) -#define SID_HELPMENU (SID_SFX_START + 410) - #define aCmdHelpIndex ".uno:HelpIndex" #define aCmdToolsMenu ".uno:ToolsMenu" #define aCmdHelpMenu ".uno:HelpMenu" -#define aSlotHelpMenu "slot:5410" - -#define aSpecialWindowMenu "window" -#define aSlotSpecialWindowMenu "slot:5610" -#define aSlotSpecialToolsMenu "slot:6677" - -// special uno commands for window list #define aSpecialWindowCommand ".uno:WindowList" static sal_Int16 getImageTypeFromBools( bool bBig ) @@ -696,10 +684,7 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu, bool ) m_bActive = true; - OUString aMenuCommand( m_aMenuItemCommand ); - if ( m_aMenuItemCommand == aSpecialWindowMenu || - m_aMenuItemCommand == aSlotSpecialWindowMenu || - aMenuCommand == aSpecialWindowCommand ) + if ( m_aMenuItemCommand == aSpecialWindowCommand ) UpdateSpecialWindowMenu( pMenu, m_xContext ); // Check if some modes have changed so we have to update our menu images @@ -1087,8 +1072,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF { sal_uInt16 nItemId = pMenu->GetItemId( nPos ); OUString aCommand = pMenu->GetItemCommand( nItemId ); - if ( nItemId == SID_MDIWINDOWLIST || aCommand == aSpecialWindowCommand || - nItemId == SID_HELPMENU || aCommand == aCmdHelpMenu ) + if ( aCommand == aSpecialWindowCommand || aCommand == aCmdHelpMenu ) { // Retrieve addon popup menus and add them to our menu bar framework::AddonMenuManager::MergeAddonPopupMenus( rFrame, nPos, static_cast<MenuBar *>(pMenu) ); @@ -1165,13 +1149,12 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF xPopupMenuDispatchProvider = pAttributes->xDispatchProvider; // Check if this is the help menu. Add menu item if needed - if ( nItemId == SID_HELPMENU || aItemCommand == aSlotHelpMenu || aItemCommand == aCmdHelpMenu ) + if ( aItemCommand == aCmdHelpMenu ) { // Check if this is the help menu. Add menu item if needed CheckAndAddMenuExtension( pPopup ); } - else if (( aItemCommand == aSlotSpecialToolsMenu || aItemCommand == aCmdToolsMenu ) && - AddonMenuManager::HasAddonMenuElements() ) + else if ( aItemCommand == aCmdToolsMenu && AddonMenuManager::HasAddonMenuElements() ) { // Create addon popup menu if there exist elements and this is the tools popup menu VclPtr<PopupMenu> pSubMenu = AddonMenuManager::CreateAddonMenu(rFrame); commit 005f4a75e129dcbc74261b90432e2944ca99b131 Author: Maxim Monastirsky <momonas...@gmail.com> Date: Wed May 17 23:24:24 2017 +0300 Popup menu controllers never attached to empty menus ... in our xml files, only to plain menu items. Change-Id: I1614a1b31a05e08cf317d2637d64d3e450855fc9 diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 3a1b2bd4d157..499b207133e4 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -1147,31 +1147,9 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF pMenu->SetHelpCommand( nItemId, "" ); } - if ( m_xPopupMenuControllerFactory.is() && - pPopup->GetItemCount() == 0 && - m_xPopupMenuControllerFactory->hasController( aItemCommand, m_aModuleIdentifier ) - ) - { - // Check if we have to create a popup menu for a uno based popup menu controller. - // We have to set an empty popup menu into our menu structure so the controller also - // works with inplace OLE. Remove old dummy popup menu! - MenuItemHandler* pItemHandler = new MenuItemHandler( nItemId, xStatusListener, xDispatch ); - VCLXPopupMenu* pVCLXPopupMenu = new VCLXPopupMenu; - PopupMenu* pNewPopupMenu = static_cast<PopupMenu *>(pVCLXPopupMenu->GetMenu()); - pMenu->SetPopupMenu( nItemId, pNewPopupMenu ); - pItemHandler->xPopupMenu.set( static_cast<OWeakObject *>(pVCLXPopupMenu), UNO_QUERY ); - pItemHandler->aMenuItemURL = aItemCommand; - m_aMenuItemHandlerVector.push_back( pItemHandler ); - pPopup.disposeAndClear(); + assert(!m_xPopupMenuControllerFactory.is() || !m_xPopupMenuControllerFactory->hasController( aItemCommand, m_aModuleIdentifier )); - if ( bAccessibilityEnabled ) - { - if ( CreatePopupMenuController( pItemHandler )) - pItemHandler->xPopupMenuController->updatePopupMenu(); - } - lcl_CheckForChildren(pMenu, nItemId); - } - else if ( aItemCommand.startsWith( ADDONSPOPUPMENU_URL_PREFIX_STR ) ) + if ( aItemCommand.startsWith( ADDONSPOPUPMENU_URL_PREFIX_STR ) ) { // A special addon popup menu, must be created with a different ctor MenuBarManager* pSubMenuManager = new MenuBarManager( m_xContext, m_xFrame, m_xURLTransformer, pPopup, true ); commit 7e6b62825032ff6610ab83c3e4f3b7085d2def0c Author: Maxim Monastirsky <momonas...@gmail.com> Date: Wed May 17 22:58:30 2017 +0300 Use WeakComponentImplHelper for MenuBarManager Change-Id: Ia0c47186f5f266d512c02e92d7983872e207f878 diff --git a/framework/inc/uielement/menubarmanager.hxx b/framework/inc/uielement/menubarmanager.hxx index aab70b1f12be..4f3a1ac5163d 100644 --- a/framework/inc/uielement/menubarmanager.hxx +++ b/framework/inc/uielement/menubarmanager.hxx @@ -51,9 +51,8 @@ #include <vcl/accel.hxx> #include <vcl/timer.hxx> #include <toolkit/awt/vclxmenu.hxx> -#include <cppuhelper/implbase.hxx> -#include <cppuhelper/weakref.hxx> -#include <cppuhelper/interfacecontainer.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase.hxx> #include <framework/addonsoptions.hxx> namespace framework @@ -67,11 +66,11 @@ struct PopupControllerEntry typedef std::unordered_map< OUString, PopupControllerEntry, OUStringHash > PopupControllerCache; class MenuBarManager: - public cppu::WeakImplHelper< + protected cppu::BaseMutex, + public cppu::WeakComponentImplHelper< css::frame::XStatusListener, css::frame::XFrameActionListener, css::ui::XUIConfigurationListener, - css::lang::XComponent, css::awt::XSystemDependentMenuPeer> { protected: @@ -95,11 +94,6 @@ class MenuBarManager: virtual ~MenuBarManager() override; - // XComponent - virtual void SAL_CALL dispose() override; - virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; - virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; - // XStatusListener virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; @@ -145,6 +139,7 @@ class MenuBarManager: DECL_LINK( Deactivate, Menu *, bool ); DECL_LINK( AsyncSettingsHdl, Timer *, void ); + void SAL_CALL disposing() override; void RemoveListener(); void RequestImages(); void RetrieveImageManagers(); @@ -191,7 +186,6 @@ class MenuBarManager: void Init(const css::uno::Reference< css::frame::XFrame >& rFrame,Menu* pAddonMenu,bool _bHandlePopUp); void SetHdl(); - bool m_bDisposed; bool m_bDeleteMenu; bool m_bActive; bool m_bIsBookmarkMenu; @@ -207,8 +201,6 @@ class MenuBarManager: css::uno::Reference< css::container::XNameAccess > m_xUICommandLabels; css::uno::Reference< css::frame::XUIControllerFactory > m_xPopupMenuControllerFactory; ::std::vector< MenuItemHandler* > m_aMenuItemHandlerVector; - osl::Mutex m_mutex; - ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchProvider; css::uno::Reference< css::ui::XImageManager > m_xDocImageManager; css::uno::Reference< css::ui::XImageManager > m_xModuleImageManager; diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 8a187f204152..3a1b2bd4d157 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -71,10 +71,7 @@ #include <vcl/menu.hxx> #include <vcl/settings.hxx> #include <vcl/commandinfoprovider.hxx> -#include <osl/mutex.hxx> #include <osl/file.hxx> -#include <cppuhelper/implbase.hxx> -#include <cppuhelper/queryinterface.hxx> #include <svtools/acceleratorexecute.hxx> #include <svtools/miscopt.hxx> #include <uielement/menubarmerger.hxx> @@ -127,12 +124,11 @@ MenuBarManager::MenuBarManager( const Reference< XDispatchProvider >& rDispatchProvider, const OUString& rModuleIdentifier, Menu* pMenu, bool bDelete, bool bHasMenuBar ): - m_bDisposed( false ) + WeakComponentImplHelper( m_aMutex ) , m_bRetrieveImages( false ) , m_bAcceleratorCfg( false ) , m_bModuleIdentified( false ) , m_bHasMenuBar( bHasMenuBar ) - , m_aListenerContainer( m_mutex ) , m_xContext(rxContext) , m_xURLTransformer(_xURLTransformer) , m_sIconTheme( SvtMiscOptions().GetIconTheme() ) @@ -148,12 +144,11 @@ MenuBarManager::MenuBarManager( const Reference< XURLTransformer >& _xURLTransformer, Menu* pAddonMenu, bool popup): - m_bDisposed( false ) + WeakComponentImplHelper( m_aMutex ) , m_bRetrieveImages( true ) , m_bAcceleratorCfg( false ) , m_bModuleIdentified( false ) , m_bHasMenuBar( true ) - , m_aListenerContainer( m_mutex ) , m_xContext(rxContext) , m_xURLTransformer(_xURLTransformer) , m_sIconTheme( SvtMiscOptions().GetIconTheme() ) @@ -166,7 +161,7 @@ Any SAL_CALL MenuBarManager::getMenuHandle( const Sequence< sal_Int8 >& /*Proces { SolarMutexGuard aSolarGuard; - if ( m_bDisposed ) + if ( rBHelper.bDisposed || rBHelper.bInDispose ) throw css::lang::DisposedException(); Any a; @@ -203,7 +198,7 @@ void MenuBarManager::Destroy() { SolarMutexGuard aGuard; - if ( !m_bDisposed ) + if ( !rBHelper.bDisposed ) { // stop asynchronous settings timer and // release defered item container reference @@ -230,69 +225,45 @@ void MenuBarManager::Destroy() } // XComponent -void SAL_CALL MenuBarManager::dispose() +void SAL_CALL MenuBarManager::disposing() { Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY ); - EventObject aEvent( xThis ); - m_aListenerContainer.disposeAndClear( aEvent ); + SolarMutexGuard g; + Destroy(); + if ( m_xDocImageManager.is() ) { - SolarMutexGuard g; - Destroy(); - m_bDisposed = true; - - if ( m_xDocImageManager.is() ) + try { - try - { - m_xDocImageManager->removeConfigurationListener( - Reference< XUIConfigurationListener >( - static_cast< OWeakObject* >( this ), UNO_QUERY )); - } - catch ( const Exception& ) - { - } + m_xDocImageManager->removeConfigurationListener( + Reference< XUIConfigurationListener >( + static_cast< OWeakObject* >( this ), UNO_QUERY )); } - if ( m_xModuleImageManager.is() ) + catch ( const Exception& ) { - try - { - m_xModuleImageManager->removeConfigurationListener( - Reference< XUIConfigurationListener >( - static_cast< OWeakObject* >( this ), UNO_QUERY )); - } - catch ( const Exception& ) - { - } } - m_xDocImageManager.clear(); - m_xModuleImageManager.clear(); - m_xGlobalAcceleratorManager.clear(); - m_xModuleAcceleratorManager.clear(); - m_xDocAcceleratorManager.clear(); - m_xUICommandLabels.clear(); - m_xPopupMenuControllerFactory.clear(); - m_xContext.clear(); } -} - -void SAL_CALL MenuBarManager::addEventListener( const Reference< XEventListener >& xListener ) -{ - SolarMutexGuard g; - - /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - if ( m_bDisposed ) - throw DisposedException(); - - m_aListenerContainer.addInterface( cppu::UnoType<XEventListener>::get(), xListener ); -} - -void SAL_CALL MenuBarManager::removeEventListener( const Reference< XEventListener >& xListener ) -{ - SolarMutexGuard g; - /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - m_aListenerContainer.removeInterface( cppu::UnoType<XEventListener>::get(), xListener ); + if ( m_xModuleImageManager.is() ) + { + try + { + m_xModuleImageManager->removeConfigurationListener( + Reference< XUIConfigurationListener >( + static_cast< OWeakObject* >( this ), UNO_QUERY )); + } + catch ( const Exception& ) + { + } + } + m_xDocImageManager.clear(); + m_xModuleImageManager.clear(); + m_xGlobalAcceleratorManager.clear(); + m_xModuleAcceleratorManager.clear(); + m_xDocAcceleratorManager.clear(); + m_xUICommandLabels.clear(); + m_xPopupMenuControllerFactory.clear(); + m_xContext.clear(); } void SAL_CALL MenuBarManager::elementInserted( const css::ui::ConfigurationEvent& Event ) @@ -300,7 +271,7 @@ void SAL_CALL MenuBarManager::elementInserted( const css::ui::ConfigurationEvent SolarMutexGuard g; /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - if ( m_bDisposed ) + if ( rBHelper.bDisposed || rBHelper.bInDispose ) return; sal_Int16 nImageType = sal_Int16(); @@ -325,7 +296,7 @@ void SAL_CALL MenuBarManager::frameAction( const FrameActionEvent& Action ) { SolarMutexGuard g; - if ( m_bDisposed ) + if ( rBHelper.bDisposed || rBHelper.bInDispose ) throw css::lang::DisposedException(); if ( Action.Action == FrameAction_CONTEXT_CHANGED ) @@ -356,7 +327,7 @@ void SAL_CALL MenuBarManager::statusChanged( const FeatureStateEvent& Event ) SolarMutexGuard aSolarGuard; { - if ( m_bDisposed ) + if ( rBHelper.bDisposed || rBHelper.bInDispose ) return; // We have to check all menu entries as there can be identical entries in a popup menu. commit 29dd77c749f6bdae19ba1e81b0470f9009c42537 Author: Maxim Monastirsky <momonas...@gmail.com> Date: Wed May 17 20:58:48 2017 +0300 Use CommandInfoProvider::GetModuleIdentifier Change-Id: I09f23360259e794ab2a0d8ad6d8bf6fc18d08597 diff --git a/framework/source/fwe/classes/addonmenu.cxx b/framework/source/fwe/classes/addonmenu.cxx index f4a326235e43..5a7c7344b674 100644 --- a/framework/source/fwe/classes/addonmenu.cxx +++ b/framework/source/fwe/classes/addonmenu.cxx @@ -26,10 +26,9 @@ #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/util/URL.hpp> #include <com/sun/star/util/XURLTransformer.hpp> -#include <com/sun/star/frame/ModuleManager.hpp> -#include <com/sun/star/frame/XModuleManager.hpp> #include <tools/config.hxx> +#include <vcl/commandinfoprovider.hxx> #include <vcl/svapp.hxx> #include <svtools/menuoptions.hxx> #include <svl/solar.hrc> @@ -46,31 +45,13 @@ const sal_uInt16 SID_HELPMENU = (SID_SFX_START + 410); namespace framework { -static OUString GetModuleIdentifier(const Reference<XComponentContext>& rContext, - const Reference< XFrame >& rFrame) -{ - Reference< XModuleManager > xModuleManager(ModuleManager::create(rContext)); - if ( xModuleManager.is() ) - { - try - { - return xModuleManager->identify( rFrame ); - } - catch ( Exception& ) - { - } - } - return OUString(); -} - bool AddonMenuManager::HasAddonMenuElements() { return AddonsOptions().HasAddonsMenu(); } // Create the Add-Ons menu -VclPtr<PopupMenu> AddonMenuManager::CreateAddonMenu( const Reference< XFrame >& rFrame, - const Reference< XComponentContext >& rContext ) +VclPtr<PopupMenu> AddonMenuManager::CreateAddonMenu( const Reference< XFrame >& rFrame ) { AddonsOptions aOptions; VclPtr<PopupMenu> pAddonMenu; @@ -80,7 +61,7 @@ VclPtr<PopupMenu> AddonMenuManager::CreateAddonMenu( const Reference< XFrame >& if ( rAddonMenuEntries.getLength() > 0 ) { pAddonMenu = VclPtr<PopupMenu>::Create(); - ::rtl::OUString aModuleIdentifier = GetModuleIdentifier( rContext, rFrame ); + ::rtl::OUString aModuleIdentifier = vcl::CommandInfoProvider::GetModuleIdentifier( rFrame ); AddonMenuManager::BuildMenu( pAddonMenu, MENU_APPEND, nUniqueMenuId, rAddonMenuEntries, rFrame, aModuleIdentifier ); // Don't return an empty Add-On menu @@ -116,8 +97,7 @@ static sal_uInt16 FindMenuId( Menu* pMenu, const OUString& aCommand ) // Merge the Add-Ons help menu items into the given menu bar at a defined pos void AddonMenuManager::MergeAddonHelpMenu( const Reference< XFrame >& rFrame, - MenuBar* pMergeMenuBar, - const Reference<XComponentContext>& rContext ) + MenuBar* pMergeMenuBar ) { if ( pMergeMenuBar ) { @@ -146,7 +126,7 @@ void AddonMenuManager::MergeAddonHelpMenu( const Reference< XFrame >& rFrame, if ( nInsPos < nItemCount && pHelpMenu->GetItemType( nInsPos ) != MenuItemType::SEPARATOR ) nInsSepAfterPos = nInsPos; - ::rtl::OUString aModuleIdentifier = GetModuleIdentifier(rContext, rFrame); + ::rtl::OUString aModuleIdentifier = vcl::CommandInfoProvider::GetModuleIdentifier(rFrame); AddonMenuManager::BuildMenu( pHelpMenu, nInsPos, nUniqueMenuId, rAddonHelpMenuEntries, rFrame, aModuleIdentifier ); if ( pHelpMenu->GetItemCount() > nItemCount ) @@ -166,8 +146,7 @@ void AddonMenuManager::MergeAddonHelpMenu( const Reference< XFrame >& rFrame, // Merge the addon popup menus into the given menu bar at the provided pos. void AddonMenuManager::MergeAddonPopupMenus( const Reference< XFrame >& rFrame, sal_uInt16 nMergeAtPos, - MenuBar* pMergeMenuBar, - const Reference< XComponentContext >& rContext ) + MenuBar* pMergeMenuBar ) { if ( pMergeMenuBar ) { @@ -181,7 +160,8 @@ void AddonMenuManager::MergeAddonPopupMenus( const Reference< XFrame >& rFrame, OUString aContext; Sequence< Sequence< PropertyValue > > aAddonSubMenu; sal_uInt16 nUniqueMenuId = ADDONMENU_ITEMID_START; - OUString aModuleIdentifier = GetModuleIdentifier(rContext, rFrame); + + OUString aModuleIdentifier = vcl::CommandInfoProvider::GetModuleIdentifier(rFrame); const Sequence< Sequence< PropertyValue > >& rAddonMenuEntries = aAddonsOptions.GetAddonsMenuBarPart(); for ( sal_Int32 i = 0; i < rAddonMenuEntries.getLength(); i++ ) diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index cf7e938b3bb5..8a187f204152 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -1120,13 +1120,13 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF nItemId == SID_HELPMENU || aCommand == aCmdHelpMenu ) { // Retrieve addon popup menus and add them to our menu bar - framework::AddonMenuManager::MergeAddonPopupMenus( rFrame, nPos, static_cast<MenuBar *>(pMenu), m_xContext ); + framework::AddonMenuManager::MergeAddonPopupMenus( rFrame, nPos, static_cast<MenuBar *>(pMenu) ); break; } } // Merge the Add-Ons help menu items into the Office help menu - framework::AddonMenuManager::MergeAddonHelpMenu( rFrame, static_cast<MenuBar *>(pMenu), m_xContext ); + framework::AddonMenuManager::MergeAddonHelpMenu( rFrame, static_cast<MenuBar *>(pMenu) ); } bool bAccessibilityEnabled( Application::GetSettings().GetMiscSettings().GetEnableATToolSupport() ); @@ -1225,7 +1225,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF AddonMenuManager::HasAddonMenuElements() ) { // Create addon popup menu if there exist elements and this is the tools popup menu - VclPtr<PopupMenu> pSubMenu = AddonMenuManager::CreateAddonMenu(rFrame, m_xContext); + VclPtr<PopupMenu> pSubMenu = AddonMenuManager::CreateAddonMenu(rFrame); if ( pSubMenu && ( pSubMenu->GetItemCount() > 0 )) { sal_uInt16 nCount = 0; diff --git a/include/framework/addonmenu.hxx b/include/framework/addonmenu.hxx index 52f6cc79d7e8..363982f777d1 100644 --- a/include/framework/addonmenu.hxx +++ b/include/framework/addonmenu.hxx @@ -43,19 +43,16 @@ class FWE_DLLPUBLIC AddonMenuManager static bool IsCorrectContext(const OUString& rModuleIdentifier, const OUString& rContext); // Create the Add-Ons menu - static VclPtr<PopupMenu> CreateAddonMenu( const css::uno::Reference< css::frame::XFrame >& rFrame, - const css::uno::Reference< css::uno::XComponentContext >& rContext ); + static VclPtr<PopupMenu> CreateAddonMenu( const css::uno::Reference< css::frame::XFrame >& rFrame ); // Merge the Add-Ons help menu items into the given menu bar at a defined pos static void MergeAddonHelpMenu( const css::uno::Reference< css::frame::XFrame >& rFrame, - MenuBar* pMergeMenuBar, - const css::uno::Reference< css::uno::XComponentContext >& rContext ); + MenuBar* pMergeMenuBar ); // Merge the addon popup menus into the given menu bar at the provided pos. static void MergeAddonPopupMenus( const css::uno::Reference< css::frame::XFrame >& rFrame, sal_uInt16 nMergeAtPos, - MenuBar* pMergeMenuBar, - const css::uno::Reference< css::uno::XComponentContext >& rContext ); + MenuBar* pMergeMenuBar ); // Returns the next position to insert a menu item/sub menu static sal_uInt16 GetNextPos( sal_uInt16 nPos ); commit 7d2ca8f226e3566e7e097f2eba940d98c5b5089e Author: Maxim Monastirsky <momonas...@gmail.com> Date: Wed May 17 20:42:09 2017 +0300 Remove the useless AddonMenu and AddonPopupMenu Change-Id: I3022d609e813d90e52990b570aa471540c9e2c18 diff --git a/framework/inc/uielement/menubarmanager.hxx b/framework/inc/uielement/menubarmanager.hxx index 67f598247964..aab70b1f12be 100644 --- a/framework/inc/uielement/menubarmanager.hxx +++ b/framework/inc/uielement/menubarmanager.hxx @@ -66,8 +66,6 @@ struct PopupControllerEntry typedef std::unordered_map< OUString, PopupControllerEntry, OUStringHash > PopupControllerCache; -class AddonMenu; -class AddonPopupMenu; class MenuBarManager: public cppu::WeakImplHelper< css::frame::XStatusListener, diff --git a/framework/source/fwe/classes/addonmenu.cxx b/framework/source/fwe/classes/addonmenu.cxx index 4fd79253dafb..f4a326235e43 100644 --- a/framework/source/fwe/classes/addonmenu.cxx +++ b/framework/source/fwe/classes/addonmenu.cxx @@ -46,24 +46,6 @@ const sal_uInt16 SID_HELPMENU = (SID_SFX_START + 410); namespace framework { -AddonMenu::AddonMenu() -{ -} - -AddonMenu::~AddonMenu() -{ - disposeOnce(); -} - -AddonPopupMenu::AddonPopupMenu() : - AddonMenu() -{ -} - -AddonPopupMenu::~AddonPopupMenu() -{ -} - static OUString GetModuleIdentifier(const Reference<XComponentContext>& rContext, const Reference< XFrame >& rFrame) { @@ -86,31 +68,20 @@ bool AddonMenuManager::HasAddonMenuElements() return AddonsOptions().HasAddonsMenu(); } -// Factory method to create different Add-On menu types -VclPtr<PopupMenu> AddonMenuManager::CreatePopupMenuType( MenuType eMenuType ) -{ - if ( eMenuType == ADDON_MENU ) - return VclPtr<AddonMenu>::Create(); - else if ( eMenuType == ADDON_POPUPMENU ) - return VclPtr<AddonPopupMenu>::Create(); - else - return nullptr; -} - // Create the Add-Ons menu -VclPtr<AddonMenu> AddonMenuManager::CreateAddonMenu( const Reference< XFrame >& rFrame, - const Reference< XComponentContext >& rContext ) +VclPtr<PopupMenu> AddonMenuManager::CreateAddonMenu( const Reference< XFrame >& rFrame, + const Reference< XComponentContext >& rContext ) { AddonsOptions aOptions; - VclPtr<AddonMenu> pAddonMenu; + VclPtr<PopupMenu> pAddonMenu; sal_uInt16 nUniqueMenuId = ADDONMENU_ITEMID_START; const Sequence< Sequence< PropertyValue > >& rAddonMenuEntries = aOptions.GetAddonsMenu(); if ( rAddonMenuEntries.getLength() > 0 ) { - pAddonMenu = static_cast<AddonMenu *>(AddonMenuManager::CreatePopupMenuType( ADDON_MENU ).get()); + pAddonMenu = VclPtr<PopupMenu>::Create(); ::rtl::OUString aModuleIdentifier = GetModuleIdentifier( rContext, rFrame ); - AddonMenuManager::BuildMenu( pAddonMenu, ADDON_MENU, MENU_APPEND, nUniqueMenuId, rAddonMenuEntries, rFrame, aModuleIdentifier ); + AddonMenuManager::BuildMenu( pAddonMenu, MENU_APPEND, nUniqueMenuId, rAddonMenuEntries, rFrame, aModuleIdentifier ); // Don't return an empty Add-On menu if ( pAddonMenu->GetItemCount() == 0 ) @@ -176,7 +147,7 @@ void AddonMenuManager::MergeAddonHelpMenu( const Reference< XFrame >& rFrame, nInsSepAfterPos = nInsPos; ::rtl::OUString aModuleIdentifier = GetModuleIdentifier(rContext, rFrame); - AddonMenuManager::BuildMenu( pHelpMenu, ADDON_MENU, nInsPos, nUniqueMenuId, rAddonHelpMenuEntries, rFrame, aModuleIdentifier ); + AddonMenuManager::BuildMenu( pHelpMenu, nInsPos, nUniqueMenuId, rAddonHelpMenuEntries, rFrame, aModuleIdentifier ); if ( pHelpMenu->GetItemCount() > nItemCount ) { @@ -228,13 +199,12 @@ void AddonMenuManager::MergeAddonPopupMenus( const Reference< XFrame >& rFrame, AddonMenuManager::IsCorrectContext( aModuleIdentifier, aContext )) { sal_uInt16 nId = nUniqueMenuId++; - VclPtr<AddonPopupMenu> pAddonPopupMenu = static_cast<AddonPopupMenu *>(AddonMenuManager::CreatePopupMenuType( ADDON_POPUPMENU ).get()); + VclPtrInstance<PopupMenu> pAddonPopupMenu; - AddonMenuManager::BuildMenu( pAddonPopupMenu, ADDON_MENU, MENU_APPEND, nUniqueMenuId, aAddonSubMenu, rFrame, aModuleIdentifier ); + AddonMenuManager::BuildMenu( pAddonPopupMenu, MENU_APPEND, nUniqueMenuId, aAddonSubMenu, rFrame, aModuleIdentifier ); if ( pAddonPopupMenu->GetItemCount() > 0 ) { - pAddonPopupMenu->SetCommandURL( aURL ); pMergeMenuBar->InsertItem( nId, aTitle, MenuItemBits::NONE, OString(), nInsertPos++ ); pMergeMenuBar->SetPopupMenu( nId, pAddonPopupMenu ); @@ -250,7 +220,6 @@ void AddonMenuManager::MergeAddonPopupMenus( const Reference< XFrame >& rFrame, // Insert the menu and sub menu entries into pCurrentMenu with the aAddonMenuDefinition provided void AddonMenuManager::BuildMenu( PopupMenu* pCurrentMenu, - MenuType nSubMenuType, sal_uInt16 nInsPos, sal_uInt16& nUniqueMenuId, const Sequence< Sequence< PropertyValue > >& aAddonMenuDefinition, @@ -284,8 +253,8 @@ void AddonMenuManager::BuildMenu( PopupMenu* pCurrent VclPtr<PopupMenu> pSubMenu; if ( aAddonSubMenu.getLength() > 0 ) { - pSubMenu = AddonMenuManager::CreatePopupMenuType( nSubMenuType ); - AddonMenuManager::BuildMenu( pSubMenu, nSubMenuType, MENU_APPEND, nUniqueMenuId, aAddonSubMenu, rFrame, rModuleIdentifier ); + pSubMenu = VclPtr<PopupMenu>::Create(); + AddonMenuManager::BuildMenu( pSubMenu, MENU_APPEND, nUniqueMenuId, aAddonSubMenu, rFrame, rModuleIdentifier ); // Don't create a menu item for an empty sub menu if ( pSubMenu->GetItemCount() == 0 ) diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 092a1db76ac6..cf7e938b3bb5 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -1225,7 +1225,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF AddonMenuManager::HasAddonMenuElements() ) { // Create addon popup menu if there exist elements and this is the tools popup menu - VclPtr<AddonMenu> pSubMenu = AddonMenuManager::CreateAddonMenu(rFrame, m_xContext); + VclPtr<PopupMenu> pSubMenu = AddonMenuManager::CreateAddonMenu(rFrame, m_xContext); if ( pSubMenu && ( pSubMenu->GetItemCount() > 0 )) { sal_uInt16 nCount = 0; diff --git a/include/framework/addonmenu.hxx b/include/framework/addonmenu.hxx index 9da7ec714a69..52f6cc79d7e8 100644 --- a/include/framework/addonmenu.hxx +++ b/include/framework/addonmenu.hxx @@ -34,51 +34,17 @@ namespace framework { -class FWE_DLLPUBLIC AddonMenu : public PopupMenu -{ - public: - AddonMenu(); - virtual ~AddonMenu() override; -}; - -class AddonMenuManager; - -class FWE_DLLPUBLIC AddonPopupMenu : public AddonMenu -{ - public: - virtual ~AddonPopupMenu() override; - - void SetCommandURL( const OUString& aCmdURL ) { m_aCommandURL = aCmdURL; } - - private: - AddonPopupMenu(); - - OUString m_aCommandURL; - - friend class AddonMenuManager; - friend class ::VclPtr<AddonPopupMenu>; -}; - class FWE_DLLPUBLIC AddonMenuManager { public: - enum MenuType - { - ADDON_MENU, - ADDON_POPUPMENU - }; - static bool HasAddonMenuElements(); // Check if the context string matches the provided xModel context static bool IsCorrectContext(const OUString& rModuleIdentifier, const OUString& rContext); - // Factory method to create different Add-On menu types - static VclPtr<PopupMenu> CreatePopupMenuType( MenuType eMenuType ); - // Create the Add-Ons menu - static VclPtr<AddonMenu> CreateAddonMenu( const css::uno::Reference< css::frame::XFrame >& rFrame, - const css::uno::Reference< css::uno::XComponentContext >& rContext ); + static VclPtr<PopupMenu> CreateAddonMenu( const css::uno::Reference< css::frame::XFrame >& rFrame, + const css::uno::Reference< css::uno::XComponentContext >& rContext ); // Merge the Add-Ons help menu items into the given menu bar at a defined pos static void MergeAddonHelpMenu( const css::uno::Reference< css::frame::XFrame >& rFrame, @@ -96,7 +62,6 @@ class FWE_DLLPUBLIC AddonMenuManager // Build up the menu item and sub menu into the provided pCurrentMenu. The sub menus should be of type nSubMenuType. static void BuildMenu( PopupMenu* pCurrentMenu, - MenuType nSubMenuType, sal_uInt16 nInsPos, sal_uInt16& nUniqueMenuId, const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& aAddonMenuDefinition, commit fb1814900590e3a6d60a877fdd897aa6b9aaba97 Author: Maxim Monastirsky <momonas...@gmail.com> Date: Wed May 17 19:14:33 2017 +0300 Clean obsolete code from menu document writer Remove special handling of New, Wizards, and Addon sub-menus. Many years ago they used to be injected into the menu structure at runtime, so we had to not write their contents back to xml. Now we have a clear separation between the contents of a menu at UNO API level, and the actual contents of the VCL menubar. Change-Id: I5e791e8963faca9f26ad31c9b4e6b8763b70d1d9 diff --git a/framework/source/fwe/classes/addonmenu.cxx b/framework/source/fwe/classes/addonmenu.cxx index ebfcb0a494ae..4fd79253dafb 100644 --- a/framework/source/fwe/classes/addonmenu.cxx +++ b/framework/source/fwe/classes/addonmenu.cxx @@ -55,12 +55,6 @@ AddonMenu::~AddonMenu() disposeOnce(); } -// Check if command URL string has the unique prefix to identify addon popup menus -bool AddonPopupMenu::IsCommandURLPrefix( const OUString& aCmdURL ) -{ - return aCmdURL.startsWith( ADDONSPOPUPMENU_URL_PREFIX_STR ); -} - AddonPopupMenu::AddonPopupMenu() : AddonMenu() { diff --git a/framework/source/fwe/xml/menudocumenthandler.cxx b/framework/source/fwe/xml/menudocumenthandler.cxx index ea6473771d77..a7d8bd0e1acf 100644 --- a/framework/source/fwe/xml/menudocumenthandler.cxx +++ b/framework/source/fwe/xml/menudocumenthandler.cxx @@ -22,7 +22,6 @@ #include <xml/menudocumenthandler.hxx> #include <framework/menuconfiguration.hxx> -#include <framework/addonmenu.hxx> #include <com/sun/star/xml/sax/SAXException.hpp> #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> @@ -790,14 +789,7 @@ void OWriteMenuDocumentHandler::WriteMenu( const Reference< XIndexAccess >& rMen ExtractMenuParameters( aProps, aCommandURL, aLabel, aHelpURL, xSubMenu, nType, nItemBits ); if ( xSubMenu.is() ) { - // special popup menus (filled during runtime) must be saved as an empty popup menu or menuitem!!! - if ( aCommandURL == ".uno:AddDirect" || - aCommandURL == ".uno:AutoPilotMenu" ) - { - WriteMenuItem( aCommandURL, aLabel, aHelpURL, nItemBits ); - bSeparator = false; - } - else if ( !aCommandURL.isEmpty() && !AddonPopupMenu::IsCommandURLPrefix( aCommandURL )) + if ( !aCommandURL.isEmpty() ) { ::comphelper::AttributeList* pListMenu = new ::comphelper::AttributeList; Reference< XAttributeList > xListMenu( static_cast<XAttributeList *>(pListMenu) , UNO_QUERY ); diff --git a/include/framework/addonmenu.hxx b/include/framework/addonmenu.hxx index 859c1b428f8e..9da7ec714a69 100644 --- a/include/framework/addonmenu.hxx +++ b/include/framework/addonmenu.hxx @@ -48,9 +48,6 @@ class FWE_DLLPUBLIC AddonPopupMenu : public AddonMenu public: virtual ~AddonPopupMenu() override; - // Check if command URL string has the unique prefix to identify addon popup menus - static bool IsCommandURLPrefix( const OUString& aCmdURL ); - void SetCommandURL( const OUString& aCmdURL ) { m_aCommandURL = aCmdURL; } private: commit de67c7b13f984b10cd745510783298b110d63ab2 Author: Maxim Monastirsky <momonas...@gmail.com> Date: Wed May 17 18:55:55 2017 +0300 Unused consts Change-Id: I4ff37a15fd7aae8c0bb1b9aea60c0ca33a1e520b diff --git a/include/framework/menuconfiguration.hxx b/include/framework/menuconfiguration.hxx index ef266b454ac0..066d0634b7e4 100644 --- a/include/framework/menuconfiguration.hxx +++ b/include/framework/menuconfiguration.hxx @@ -36,9 +36,6 @@ #include <vcl/menu.hxx> #include <vcl/toolbox.hxx> -const sal_uInt16 START_ITEMID_PICKLIST = 4500; -const sal_uInt16 END_ITEMID_PICKLIST = 4599; -const sal_uInt16 MAX_ITEMCOUNT_PICKLIST = 99; // difference between START_... & END_... for picklist / must be changed too, if these values are changed! const sal_uInt16 START_ITEMID_WINDOWLIST = 4600; const sal_uInt16 END_ITEMID_WINDOWLIST = 4699; const sal_uInt16 ITEMID_ADDONLIST = 6678; // used to be a SID in sfx2, now just a unique id... commit d5d020327bdd37cf490a2e1931d5d8dd6f221dbb Author: Maxim Monastirsky <momonas...@gmail.com> Date: Wed May 17 18:46:00 2017 +0300 Remove sfx2 include from vcl (And we don't have menus with item ids from sfx2 anymore.) Change-Id: Ic4d0f3c6a2d15cfda6498617a45ba2e25b5dd7f1 diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index ab458216eca9..ead4e91eff10 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -63,8 +63,6 @@ #include <vcl/lazydelete.hxx> -#include <sfx2/sfxsids.hrc> - #include <map> #include <vector> @@ -1205,8 +1203,7 @@ bool Menu::ImplIsVisible( sal_uInt16 nPos ) const else if ( pData->eType != MenuItemType::SEPARATOR ) // separators handled above { // tdf#86850 Always display clipboard functions - if ( pData->nId == SID_CUT || pData->nId == SID_COPY || pData->nId == SID_PASTE || - pData->aCommandStr == ".uno:Cut" || pData->aCommandStr == ".uno:Copy" || pData->aCommandStr == ".uno:Paste" ) + if ( pData->aCommandStr == ".uno:Cut" || pData->aCommandStr == ".uno:Copy" || pData->aCommandStr == ".uno:Paste" ) bVisible = true; else // bVisible = pData->bEnabled && ( !pData->pSubMenu || pData->pSubMenu->HasValidEntries( true ) ); commit 3f738f81398095377ac736c2363be84141e25b9a Author: Maxim Monastirsky <momonas...@gmail.com> Date: Wed May 17 18:40:59 2017 +0300 SID_ADDONS sdi slot is unused We only need a label in officecfg, and an icon in icon-themes. Change-Id: I88482f85b282742c5d6dc7f6ec7ba6442c09a639 diff --git a/include/framework/menuconfiguration.hxx b/include/framework/menuconfiguration.hxx index 15cb3c768fe0..ef266b454ac0 100644 --- a/include/framework/menuconfiguration.hxx +++ b/include/framework/menuconfiguration.hxx @@ -36,19 +36,12 @@ #include <vcl/menu.hxx> #include <vcl/toolbox.hxx> -// Prepare for inclusion by framework and sfx -// Please consider that there is a corresponding define also in sfxsids.hrc!! (SID_SFX_START)/(SID_ADDONS) -#define FWK_SID_SFX_START 5000 -#define FWK_SID_ADDONS (FWK_SID_SFX_START+1678) -#define FWK_SID_ADDONHELP (FWK_SID_SFX_START+1684) - const sal_uInt16 START_ITEMID_PICKLIST = 4500; const sal_uInt16 END_ITEMID_PICKLIST = 4599; const sal_uInt16 MAX_ITEMCOUNT_PICKLIST = 99; // difference between START_... & END_... for picklist / must be changed too, if these values are changed! const sal_uInt16 START_ITEMID_WINDOWLIST = 4600; const sal_uInt16 END_ITEMID_WINDOWLIST = 4699; -const sal_uInt16 ITEMID_ADDONLIST = FWK_SID_ADDONS; -const sal_uInt16 ITEMID_ADDONHELP = FWK_SID_ADDONHELP; +const sal_uInt16 ITEMID_ADDONLIST = 6678; // used to be a SID in sfx2, now just a unique id... namespace framework { diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc index e425071874a8..f061b163428a 100644 --- a/include/sfx2/sfxsids.hrc +++ b/include/sfx2/sfxsids.hrc @@ -194,7 +194,6 @@ #define SID_STOP_RECORDING (SID_SFX_START + 1671) #define SID_INTERACTIONHANDLER (SID_SFX_START + 1675) #define SID_OPENHYPERLINK (SID_SFX_START + 1676) -#define SID_ADDONS (SID_SFX_START + 1678) #define SID_CONTENT (SID_SFX_START + 1679) #define SID_SHOW_IME_STATUS_WINDOW (SID_SFX_START + 1680) #define SID_VIEWONLY (SID_SFX_START + 1682) diff --git a/sfx2/sdi/appslots.sdi b/sfx2/sdi/appslots.sdi index 6ce38e1129a7..12ad63616f37 100644 --- a/sfx2/sdi/appslots.sdi +++ b/sfx2/sdi/appslots.sdi @@ -120,9 +120,6 @@ interface Application ExecMethod = MiscExec_Impl ; StateMethod = MiscState_Impl ; ] - SID_ADDONS - [ - ] SID_SHOW_IME_STATUS_WINDOW [ ExecMethod = MiscExec_Impl ; diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index cf7868c41cd5..4622d3f838c9 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -4760,23 +4760,6 @@ SfxImageItem ImageOrientation SID_IMAGE_ORIENTATION ] -SfxVoidItem Addons SID_ADDONS -[ - AutoUpdate = FALSE, - FastCall = FALSE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = FALSE, - RecordAbsolute = FALSE, - RecordPerSet; - - - AccelConfig = FALSE, - MenuConfig = FALSE, - ToolBoxConfig = FALSE, - GroupId = GID_APPLICATION; -] - SfxBoolItem ShowImeStatusWindow SID_SHOW_IME_STATUS_WINDOW [ AutoUpdate = FALSE, commit 33900a71ab7955d9d2d6009e58c5b5b149c1ce0f Author: Maxim Monastirsky <momonas...@gmail.com> Date: Wed May 17 18:21:04 2017 +0300 Addon items will get their icons in Activate anyway (This piece of code is about the "OfficeHelp" feature of Addons.xcu. "AddonMenu" and "OfficeMenuBar" use a different MenuBarManager ctor, which never calls FillMenuManager.) Change-Id: Iab9ac5c606dd23a208de7f99d2883168fd2b588a diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 895a5392a80b..092a1db76ac6 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -1254,36 +1254,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF else if ( pMenu->GetItemType( i ) != MenuItemType::SEPARATOR ) { if ( bItemShowMenuImages ) - { - if ( AddonMenuManager::IsAddonMenuId( nItemId )) - { - // Add-Ons uses images from different places - Image aImage; - OUString aImageId; - - MenuAttributes* pMenuAttributes = - reinterpret_cast<MenuAttributes*>(pMenu->GetUserValue( nItemId )); - - if ( pMenuAttributes && !pMenuAttributes->aImageId.isEmpty() ) - { - // Retrieve image id from menu attributes - aImage = vcl::CommandInfoProvider::GetImageForCommand(aImageId, m_xFrame); - } - - if ( !aImage ) - { - aImage = vcl::CommandInfoProvider::GetImageForCommand(aItemCommand, m_xFrame); - if ( !aImage ) - aImage = AddonsOptions().GetImageFromURL( aItemCommand, false ); - } - - if ( !!aImage ) - pMenu->SetItemImage( nItemId, aImage ); - else - m_bRetrieveImages = true; - } m_bRetrieveImages = true; - } MenuItemHandler* pItemHandler = new MenuItemHandler( nItemId, xStatusListener, xDispatch ); pItemHandler->aMenuItemURL = aItemCommand; diff --git a/include/framework/addonmenu.hxx b/include/framework/addonmenu.hxx index c11eea13b177..859c1b428f8e 100644 --- a/include/framework/addonmenu.hxx +++ b/include/framework/addonmenu.hxx @@ -73,8 +73,6 @@ class FWE_DLLPUBLIC AddonMenuManager static bool HasAddonMenuElements(); - static bool IsAddonMenuId( sal_uInt16 nId ) { return (( nId >= ADDONMENU_ITEMID_START ) && ( nId < ADDONMENU_ITEMID_END )); } - // Check if the context string matches the provided xModel context static bool IsCorrectContext(const OUString& rModuleIdentifier, const OUString& rContext); commit 598d033c1f345b0f84e43ec7ff2b21fe8c4ce062 Author: Maxim Monastirsky <momonas...@gmail.com> Date: Wed May 17 17:48:43 2017 +0300 Fix AddonMenu icon Another victim of tdf#96059. CommandInfoProvider can only handle .uno:Something, not slot:12345. Also, given that we're using the .uno command name, we can just get the label from officecfg, dropping the local framework string resource. Change-Id: Ia0c32bacb67699311f6bbbec0f350321802f75a0 diff --git a/framework/inc/classes/resource.hrc b/framework/inc/classes/resource.hrc index 4c66725c370f..72a45931b048 100644 --- a/framework/inc/classes/resource.hrc +++ b/framework/inc/classes/resource.hrc @@ -24,7 +24,6 @@ #define RID_MENU_START 10000 #define RID_IMAGE_START 15000 -#define STR_MENU_ADDONS (RID_STR_START+0) #define STR_MENU_HEADFOOTALL (RID_STR_START+2) #define STR_UPDATEDOC (RID_STR_START+3) #define STR_CLOSEDOC_ANDRETURN (RID_STR_START+4) diff --git a/framework/source/classes/resource.src b/framework/source/classes/resource.src index 7cec9dc7b914..62e7b616b6ff 100644 --- a/framework/source/classes/resource.src +++ b/framework/source/classes/resource.src @@ -19,11 +19,6 @@ #include <classes/resource.hrc> -String STR_MENU_ADDONS -{ - Text [ en-US ] = "Add-Ons" ; -}; - String STR_MENU_HEADFOOTALL { Text [ en-US ] = "All" ; diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 62aba551fcad..895a5392a80b 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -1232,45 +1232,23 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF if ( pPopup->GetItemType( nCount-1 ) != MenuItemType::SEPARATOR ) pPopup->InsertSeparator(); - // Use resource to load popup menu title - OUString aAddonsStrRes(FwkResId(STR_MENU_ADDONS)); - pPopup->InsertItem( ITEMID_ADDONLIST, aAddonsStrRes ); + pPopup->InsertItem( ITEMID_ADDONLIST, OUString() ); pPopup->SetPopupMenu( ITEMID_ADDONLIST, pSubMenu ); - - // Set item command for popup menu to enable it for GetImageFromURL - OUString aNewItemCommand = "slot:" + OUString::number( ITEMID_ADDONLIST ); - pPopup->SetItemCommand( ITEMID_ADDONLIST, aNewItemCommand ); + pPopup->SetItemCommand( ITEMID_ADDONLIST, ".uno:Addons" ); } else pSubMenu.disposeAndClear(); } + MenuBarManager* pSubMenuManager; if ( nItemId == ITEMID_ADDONLIST ) - { - AddonMenu* pSubMenu = dynamic_cast< AddonMenu* >( pPopup.get() ); - if ( pSubMenu ) - { - MenuBarManager* pSubMenuManager = new MenuBarManager( m_xContext, m_xFrame, - m_xURLTransformer,pSubMenu, false ); - AddMenu(pSubMenuManager,aItemCommand,nItemId); - (pSubMenuManager->m_aMenuItemCommand).clear(); - - // Set image for the addon popup menu item - if ( bItemShowMenuImages && !pPopup->GetItemImage( ITEMID_ADDONLIST )) - { - Image aImage = vcl::CommandInfoProvider::GetImageForCommand(aItemCommand, rFrame); - if ( !!aImage ) - pPopup->SetItemImage( ITEMID_ADDONLIST, aImage ); - } - } - } + pSubMenuManager = new MenuBarManager( m_xContext, m_xFrame, m_xURLTransformer, pPopup, false ); else - { - MenuBarManager* pSubMenuMgr = new MenuBarManager( m_xContext, rFrame, m_xURLTransformer, - rDispatchProvider, aModuleIdentifier, - pPopup, false, m_bHasMenuBar ); - AddMenu(pSubMenuMgr,aItemCommand,nItemId); - } + pSubMenuManager = new MenuBarManager( m_xContext, rFrame, m_xURLTransformer, + rDispatchProvider, aModuleIdentifier, + pPopup, false, m_bHasMenuBar ); + + AddMenu(pSubMenuManager, aItemCommand, nItemId); } } else if ( pMenu->GetItemType( i ) != MenuItemType::SEPARATOR ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits