summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga.extern@allotropia.de>2023-07-26 12:17:19 +0200
committerBalazs Varga <balazs.varga.extern@allotropia.de>2023-07-28 09:22:49 +0200
commit630303ad8e94bd634b98e691935a1f4c19582a3a (patch)
tree11a76e5579147ec527caca5dbe94bf0b1a123f71 /framework
parent9c071c148afce0b95a16b36c27b709380d1130b5 (diff)
tdf#104382 - Menus should be disabled when they have no enabled submenus
Disable menu elements if they only have disabled submenu elemets. TODO: GTK3 Change-Id: I83cdc58846afd61719ceeba9f993df894ce6fd01 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154938 Tested-by: Jenkins Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
Diffstat (limited to 'framework')
-rw-r--r--framework/source/uielement/menubarmanager.cxx31
1 files changed, 28 insertions, 3 deletions
diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx
index b445324d70d5..f86ede8eb052 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -515,7 +515,7 @@ void SAL_CALL MenuBarManager::disposing( const EventObject& Source )
static void lcl_CheckForChildren(Menu* pMenu, sal_uInt16 nItemId)
{
if (PopupMenu* pThisPopup = pMenu->GetPopupMenu( nItemId ))
- pMenu->EnableItem( nItemId, pThisPopup->GetItemCount() != 0 );
+ pMenu->EnableItem( nItemId, pThisPopup->GetItemCount() != 0 && pThisPopup->HasValidEntries(true));
}
// vcl handler
@@ -672,6 +672,15 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu, bool )
{
if( xMenuItemDispatch.is() || menuItemHandler->aMenuItemURL != ".uno:RecentFileList" )
bPopupMenu = CreatePopupMenuController(menuItemHandler.get(), m_xDispatchProvider, m_aModuleIdentifier);
+
+ if (bPopupMenu && menuItemHandler->xPopupMenuController.is())
+ {
+ if (PopupMenu* pThisPopup = pMenu->GetPopupMenu(menuItemHandler->nItemId))
+ {
+ pThisPopup->Activate();
+ pThisPopup->Deactivate();
+ }
+ }
}
else if ( menuItemHandler->xPopupMenuController.is() )
{
@@ -679,7 +688,10 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu, bool )
menuItemHandler->xPopupMenuController->updatePopupMenu();
bPopupMenu = true;
if (PopupMenu* pThisPopup = pMenu->GetPopupMenu( menuItemHandler->nItemId ))
- pMenu->EnableItem( menuItemHandler->nItemId, pThisPopup->GetItemCount() != 0 );
+ {
+ pThisPopup->Activate();
+ pThisPopup->Deactivate();
+ }
}
lcl_CheckForChildren(pMenu, menuItemHandler->nItemId);
@@ -703,6 +715,11 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu, bool )
{
// Force update of popup menu
menuItemHandler->xPopupMenuController->updatePopupMenu();
+ if (PopupMenu* pThisPopup = pMenu->GetPopupMenu(menuItemHandler->nItemId))
+ {
+ pThisPopup->Activate();
+ pThisPopup->Deactivate();
+ }
lcl_CheckForChildren(pMenu, menuItemHandler->nItemId);
}
else if ( menuItemHandler->xMenuItemDispatch.is() )
@@ -722,8 +739,16 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu, bool )
{
}
}
- else if ( menuItemHandler->xSubMenuManager.is() )
+ else if (menuItemHandler->xSubMenuManager.is())
+ {
+ MenuBarManager* pMenuBarManager = static_cast<MenuBarManager*>(menuItemHandler->xSubMenuManager.get());
+ if (pMenuBarManager)
+ {
+ pMenuBarManager->Activate(pMenuBarManager->GetMenuBar());
+ pMenuBarManager->Deactivate(pMenuBarManager->GetMenuBar());
+ }
lcl_CheckForChildren(pMenu, menuItemHandler->nItemId);
+ }
}
}