framework/inc/uielement/addonstoolbarwrapper.hxx    |    5 ++--
 framework/inc/uielement/menubarmanager.hxx          |    4 +--
 framework/source/uielement/addonstoolbarwrapper.cxx |   20 ++++------------
 framework/source/uielement/menubarmanager.cxx       |   25 +++++++-------------
 4 files changed, 20 insertions(+), 34 deletions(-)

New commits:
commit 28756e84e48330b12087f6fc7d043c2fc5d67f28
Author:     Noel Grandin <[email protected]>
AuthorDate: Wed Nov 8 15:18:22 2023 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Fri Nov 10 12:36:48 2023 +0100

    loplugin:fieldcast in framework::AddonsToolBarWrapper
    
    Change-Id: I1fc692581acc805d6c84156d6df57093cf9dff93
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159281
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/framework/inc/uielement/addonstoolbarwrapper.hxx 
b/framework/inc/uielement/addonstoolbarwrapper.hxx
index 68cfc0ff31d0..fc09465eea5a 100644
--- a/framework/inc/uielement/addonstoolbarwrapper.hxx
+++ b/framework/inc/uielement/addonstoolbarwrapper.hxx
@@ -20,12 +20,13 @@
 #pragma once
 
 #include <helper/uielementwrapperbase.hxx>
-
+#include <rtl/ref.hxx>
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
 
 namespace framework
 {
+class ToolBarManager;
 
 class AddonsToolBarWrapper final : public UIElementWrapperBase
 {
@@ -47,7 +48,7 @@ class AddonsToolBarWrapper final : public UIElementWrapperBase
 
     private:
         css::uno::Reference< css::uno::XComponentContext >                     
   m_xContext;
-        css::uno::Reference< css::lang::XComponent >                           
   m_xToolBarManager;
+        rtl::Reference< ToolBarManager >                                       
   m_xToolBarManager;
         css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >  
   m_aConfigData;
         bool                                                                   
   m_bCreatedImages;
 };
diff --git a/framework/source/uielement/addonstoolbarwrapper.cxx 
b/framework/source/uielement/addonstoolbarwrapper.cxx
index 6547d1c6bcde..f0bb99549fcf 100644
--- a/framework/source/uielement/addonstoolbarwrapper.cxx
+++ b/framework/source/uielement/addonstoolbarwrapper.cxx
@@ -134,14 +134,10 @@ Reference< XInterface > SAL_CALL 
AddonsToolBarWrapper::getRealInterface()
 {
     SolarMutexGuard g;
 
-    if ( m_xToolBarManager.is() )
+    if ( m_xToolBarManager )
     {
-        ToolBarManager* pToolBarManager = static_cast< ToolBarManager *>( 
m_xToolBarManager.get() );
-        if ( pToolBarManager )
-        {
-            vcl::Window* pWindow = pToolBarManager->GetToolBar();
-            return Reference< XInterface >( VCLUnoHelper::GetInterface( 
pWindow ), UNO_QUERY );
-        }
+        vcl::Window* pWindow = m_xToolBarManager->GetToolBar();
+        return Reference< XInterface >( VCLUnoHelper::GetInterface( pWindow ), 
UNO_QUERY );
     }
 
     return Reference< XInterface >();
@@ -155,14 +151,10 @@ void AddonsToolBarWrapper::populateImages()
     if (m_bCreatedImages)
         return;
 
-    if ( m_xToolBarManager.is() )
+    if (m_xToolBarManager)
     {
-        ToolBarManager* pToolBarManager = static_cast< ToolBarManager *>( 
m_xToolBarManager.get() );
-        if (pToolBarManager)
-        {
-            pToolBarManager->RequestImages();
-            m_bCreatedImages = true;
-        }
+        m_xToolBarManager->RequestImages();
+        m_bCreatedImages = true;
     }
 }
 
commit e88c98f81c7ff515c3cf44db43c4961a1050a03b
Author:     Noel Grandin <[email protected]>
AuthorDate: Wed Nov 8 15:17:02 2023 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Fri Nov 10 12:36:41 2023 +0100

    loplugin:fieldcast in framework::MenuBarManager::MenuItemHandler
    
    Change-Id: I5a98f1bc5783bbd78ba6596ced9bb77cd3037f95
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159280
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/framework/inc/uielement/menubarmanager.hxx 
b/framework/inc/uielement/menubarmanager.hxx
index 61bec0443240..7036be08a21b 100644
--- a/framework/inc/uielement/menubarmanager.hxx
+++ b/framework/inc/uielement/menubarmanager.hxx
@@ -131,7 +131,7 @@ class MenuBarManager final :
         struct MenuItemHandler
         {
             MenuItemHandler( sal_uInt16             aItemId,
-                             css::uno::Reference< css::frame::XStatusListener 
> xManager,
+                             rtl::Reference< MenuBarManager > xManager,
                              css::uno::Reference< css::frame::XDispatch > 
xDispatch ) :
                              nItemId( aItemId ),
                              bMadeInvisible ( false ),
@@ -143,7 +143,7 @@ class MenuBarManager final :
             OUString                                                          
aTargetFrame;
             OUString                                                          
aMenuItemURL;
             OUString                                                          
aParsedItemURL;
-            css::uno::Reference< css::frame::XStatusListener >                
xSubMenuManager;
+            rtl::Reference< MenuBarManager >                                  
xSubMenuManager;
             css::uno::Reference< css::frame::XDispatch >                      
xMenuItemDispatch;
             css::uno::Reference< css::frame::XPopupMenuController >           
xPopupMenuController;
             css::uno::Reference< css::awt::XPopupMenu >                       
xPopupMenu;
diff --git a/framework/source/uielement/menubarmanager.cxx 
b/framework/source/uielement/menubarmanager.cxx
index bd0a326a3574..2abd58434827 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -376,10 +376,7 @@ void MenuBarManager::RequestImages()
     for (auto const& menuItemHandler : m_aMenuItemHandlerVector)
     {
         if ( menuItemHandler->xSubMenuManager.is() )
-        {
-            MenuBarManager* pMenuBarManager = 
static_cast<MenuBarManager*>(menuItemHandler->xSubMenuManager.get());
-            pMenuBarManager->RequestImages();
-        }
+            menuItemHandler->xSubMenuManager->RequestImages();
     }
 }
 
@@ -439,9 +436,8 @@ void MenuBarManager::RemoveListener()
             menuItemHandler->xPopupMenu.clear();
         }
 
-        Reference< XComponent > xComponent( menuItemHandler->xSubMenuManager, 
UNO_QUERY );
-        if ( xComponent.is() )
-            xComponent->dispose();
+        if ( menuItemHandler->xSubMenuManager )
+            menuItemHandler->xSubMenuManager->dispose();
     }
 
     try
@@ -741,7 +737,7 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu, bool )
             }
             else if (menuItemHandler->xSubMenuManager.is())
             {
-                MenuBarManager* pMenuBarManager = 
static_cast<MenuBarManager*>(menuItemHandler->xSubMenuManager.get());
+                MenuBarManager* pMenuBarManager = 
menuItemHandler->xSubMenuManager.get();
                 if (pMenuBarManager)
                 {
                     pMenuBarManager->Activate(pMenuBarManager->GetMenuBar());
@@ -987,7 +983,6 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const 
Reference< XFrame >& rF
             aItemCommand = aRealCommand;
 
         Reference< XDispatch > xDispatch;
-        Reference< XStatusListener > xStatusListener;
         VclPtr<PopupMenu> pPopup = pMenu->GetPopupMenu( nItemId );
         // overwrite the show icons on menu option?
         MenuItemBits nBits = pMenu->GetItemBits( nItemId ) & ( 
MenuItemBits::ICON | MenuItemBits::TEXT );
@@ -1016,7 +1011,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const 
Reference< XFrame >& rF
                 // 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.
-                MenuItemHandler* pItemHandler = new MenuItemHandler( nItemId, 
xStatusListener, xDispatch );
+                MenuItemHandler* pItemHandler = new MenuItemHandler( nItemId, 
nullptr, xDispatch );
                 rtl::Reference<VCLXPopupMenu> pVCLXPopupMenu = new 
VCLXPopupMenu(pPopup);
                 pItemHandler->xPopupMenu = pVCLXPopupMenu;
                 pItemHandler->aMenuItemURL = aItemCommand;
@@ -1060,7 +1055,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const 
Reference< XFrame >& rF
             if ( bItemShowMenuImages )
                 m_bRetrieveImages = true;
 
-            std::unique_ptr<MenuItemHandler> pItemHandler(new MenuItemHandler( 
nItemId, xStatusListener, xDispatch ));
+            std::unique_ptr<MenuItemHandler> pItemHandler(new MenuItemHandler( 
nItemId, nullptr, xDispatch ));
             // Retrieve possible attributes struct
             MenuAttributes* pAttributes = static_cast<MenuAttributes 
*>(pMenu->GetUserValue( nItemId ));
             if ( pAttributes )
@@ -1520,11 +1515,9 @@ void MenuBarManager::GetPopupController( 
PopupControllerCache& rPopupController
                 rPopupController.emplace( aMainURL, aPopupControllerEntry );
             }
         }
-        if ( menuItemHandler->xSubMenuManager.is() )
+        if ( menuItemHandler->xSubMenuManager )
         {
-            MenuBarManager* pMenuBarManager = 
static_cast<MenuBarManager*>(menuItemHandler->xSubMenuManager.get());
-            if ( pMenuBarManager )
-                pMenuBarManager->GetPopupController( rPopupController );
+            menuItemHandler->xSubMenuManager->GetPopupController( 
rPopupController );
         }
     }
 }
@@ -1537,7 +1530,7 @@ void MenuBarManager::AddMenu(MenuBarManager* 
pSubMenuManager,const OUString& _sI
     Reference< XDispatch > xDispatch;
     std::unique_ptr<MenuItemHandler> pMenuItemHandler(new MenuItemHandler(
                                                 _nItemId,
-                                                xSubMenuManager,
+                                                pSubMenuManager,
                                                 xDispatch ));
     pMenuItemHandler->aMenuItemURL = _sItemCommand;
     m_aMenuItemHandlerVector.push_back( std::move(pMenuItemHandler) );

Reply via email to