summaryrefslogtreecommitdiff
path: root/vcl/source/window/menu.cxx
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 /vcl/source/window/menu.cxx
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 'vcl/source/window/menu.cxx')
-rw-r--r--vcl/source/window/menu.cxx18
1 files changed, 18 insertions, 0 deletions
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<sal_uInt16>(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;