From 630303ad8e94bd634b98e691935a1f4c19582a3a Mon Sep 17 00:00:00 2001 From: Balazs Varga Date: Wed, 26 Jul 2023 12:17:19 +0200 Subject: 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 --- vcl/source/window/menu.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'vcl/source/window/menu.cxx') diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 284a54a0a3a7..b33219c82c8d 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -579,6 +579,24 @@ sal_uInt16 Menu::GetItemCount() const return static_cast(pItemList->size()); } +bool Menu::HasValidEntries(bool bCheckPopups) const +{ + bool bValidEntries = false; + sal_uInt16 nCount = GetItemCount(); + for (sal_uInt16 n = 0; !bValidEntries && (n < nCount); n++) + { + MenuItemData* pItem = pItemList->GetDataFromPos(n); + if (pItem->bEnabled && (pItem->eType != MenuItemType::SEPARATOR)) + { + if (bCheckPopups && pItem->pSubMenu) + bValidEntries = pItem->pSubMenu->HasValidEntries(true); + else + bValidEntries = true; + } + } + return bValidEntries; +} + sal_uInt16 Menu::ImplGetVisibleItemCount() const { sal_uInt16 nItems = 0; -- cgit