framework/inc/uielement/menubarmanager.hxx    |    1 
 framework/source/uielement/menubarmanager.cxx |   59 ++------------------------
 2 files changed, 6 insertions(+), 54 deletions(-)

New commits:
commit 34a09c9c61bff30e8c4d16132bb47b2b1b16e422
Author:     Maxim Monastirsky <momonas...@gmail.com>
AuthorDate: Wed Sep 2 02:05:54 2020 +0300
Commit:     Maxim Monastirsky <momonas...@gmail.com>
CommitDate: Mon Sep 7 00:19:24 2020 +0200

    MenuBarManager: Simplify module id handling
    
    Now that we have a single ctor, which always calls
    FillMenuManager.
    
    Change-Id: Ib6b04882ddde252a1dc81670576f76b4fc21ea09
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102138
    Tested-by: Jenkins
    Reviewed-by: Maxim Monastirsky <momonas...@gmail.com>

diff --git a/framework/inc/uielement/menubarmanager.hxx 
b/framework/inc/uielement/menubarmanager.hxx
index c688994313b8..67f5d95dd87c 100644
--- a/framework/inc/uielement/menubarmanager.hxx
+++ b/framework/inc/uielement/menubarmanager.hxx
@@ -172,7 +172,6 @@ class MenuBarManager final :
         bool                                                         
m_bShowMenuImages;
         bool                                                         
m_bRetrieveImages;
         bool                                                         
m_bAcceleratorCfg;
-        bool                                                         
m_bModuleIdentified;
         bool                                                         
m_bHasMenuBar;
         OUString                                                     
m_aModuleIdentifier;
         VclPtr<Menu>                                                 
m_pVCLMenu;
diff --git a/framework/source/uielement/menubarmanager.cxx 
b/framework/source/uielement/menubarmanager.cxx
index 21817bd36b93..6bcee628e1df 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -36,7 +36,6 @@
 #include <com/sun/star/ui/GlobalAcceleratorConfiguration.hpp>
 #include <com/sun/star/ui/ItemType.hpp>
 #include <com/sun/star/ui/ImageType.hpp>
-#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
 #include <com/sun/star/ui/ItemStyle.hpp>
@@ -92,7 +91,6 @@ MenuBarManager::MenuBarManager(
     WeakComponentImplHelper( m_aMutex )
     , m_bRetrieveImages( false )
     , m_bAcceleratorCfg( false )
-    , m_bModuleIdentified( false )
     , m_bHasMenuBar( bHasMenuBar )
     , m_xContext(rxContext)
     , m_xURLTransformer(_xURLTransformer)
@@ -927,6 +925,12 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const 
Reference< XFrame >& rF
     m_bShowMenuImages   = rSettings.GetUseImagesInMenus();
     m_bRetrieveImages   = false;
 
+    // Set module identifier when provided from outside
+    if (!rModuleIdentifier.isEmpty())
+        m_aModuleIdentifier = rModuleIdentifier;
+    else
+        m_aModuleIdentifier = 
vcl::CommandInfoProvider::GetModuleIdentifier(m_xFrame);
+
     // Add root as ui configuration listener
     RetrieveImageManagers();
 
@@ -958,13 +962,6 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const 
Reference< XFrame >& rF
     {
         sal_uInt16 nItemId = FillItemCommand(aItemCommand,pMenu, i );
 
-        // Set module identifier when provided from outside
-        if ( !rModuleIdentifier.isEmpty() )
-        {
-            m_aModuleIdentifier = rModuleIdentifier;
-            m_bModuleIdentified = true;
-        }
-
         if (( pMenu->IsMenuBar() || bAccessibilityEnabled ) &&
             ( pMenu->GetItemText( nItemId ).isEmpty() ))
         {
@@ -1128,23 +1125,6 @@ void 
MenuBarManager::impl_RetrieveShortcutsFromConfiguration(
 
 void MenuBarManager::RetrieveShortcuts( std::vector< 
std::unique_ptr<MenuItemHandler> >& aMenuShortCuts )
 {
-    if ( !m_bModuleIdentified )
-    {
-        m_bModuleIdentified = true;
-        Reference< XModuleManager2 > xModuleManager = ModuleManager::create( 
m_xContext );
-
-        try
-        {
-            m_aModuleIdentifier = xModuleManager->identify( m_xFrame );
-        }
-        catch( const Exception& )
-        {
-        }
-    }
-
-    if ( !m_bModuleIdentified )
-        return;
-
     Reference< XAcceleratorConfiguration > xDocAccelCfg( 
m_xDocAcceleratorManager );
     Reference< XAcceleratorConfiguration > xModuleAccelCfg( 
m_xModuleAcceleratorManager );
     Reference< XAcceleratorConfiguration > xGlobalAccelCfg( 
m_xGlobalAcceleratorManager );
@@ -1251,19 +1231,6 @@ void MenuBarManager::RetrieveImageManagers()
         }
     }
 
-    Reference< XModuleManager2 > xModuleManager;
-    if ( m_aModuleIdentifier.isEmpty() )
-        xModuleManager.set( ModuleManager::create( m_xContext ) );
-
-    try
-    {
-        if ( xModuleManager.is() )
-            m_aModuleIdentifier = xModuleManager->identify( Reference< 
XInterface >( m_xFrame, UNO_QUERY ) );
-    }
-    catch( const Exception& )
-    {
-    }
-
     if ( !m_xModuleImageManager.is() )
     {
         Reference< XModuleUIConfigurationManagerSupplier > 
xModuleCfgMgrSupplier =
@@ -1483,20 +1450,6 @@ void MenuBarManager::SetItemContainer( const Reference< 
XIndexAccess >& rItemCon
 
     Reference< XFrame > xFrame = m_xFrame;
 
-    if ( !m_bModuleIdentified )
-    {
-        m_bModuleIdentified = true;
-        Reference< XModuleManager2 > xModuleManager = ModuleManager::create( 
m_xContext );
-
-        try
-        {
-            m_aModuleIdentifier = xModuleManager->identify( xFrame );
-        }
-        catch( const Exception& )
-        {
-        }
-    }
-
     // Clear MenuBarManager structures
     {
         // Check active state as we cannot change our VCL menu during 
activation by the user
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to