diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-11-08 15:17:02 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-11-10 12:36:41 +0100 |
commit | e88c98f81c7ff515c3cf44db43c4961a1050a03b (patch) | |
tree | ffbb7a71fe8899acba587e11d979b656ed00c8a4 /framework | |
parent | b048814f5eb2ed58c302a880a2eabf69473955e0 (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/inc/uielement/menubarmanager.hxx | 4 | ||||
-rw-r--r-- | framework/source/uielement/menubarmanager.cxx | 25 |
2 files changed, 11 insertions, 18 deletions
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) ); |