[Libreoffice-commits] core.git: framework/inc framework/source
Maxim Monastirsky (via logerrit)
logerrit at kemper.freedesktop.org
Thu Nov 7 22:57:59 UTC 2019
framework/inc/uielement/menubarmanager.hxx | 2 ++
framework/source/uielement/menubarmanager.cxx | 18 ++++++++++--------
2 files changed, 12 insertions(+), 8 deletions(-)
New commits:
commit f17fb8824ce511270f23b00a425e0b839f77a46c
Author: Maxim Monastirsky <momonasmon at gmail.com>
AuthorDate: Wed Nov 6 15:07:42 2019 +0200
Commit: Maxim Monastirsky <momonasmon at gmail.com>
CommitDate: Thu Nov 7 23:57:05 2019 +0100
MenuBarManager: Honor visible property of menu items
This became a problem recently with the introduction of
notebookbar customization, as it allows to hide menu items.
As a solution, use the same approach as for toolbars (see
GenericToolbarController::statusChanged): Force menu item
visibility only if it was previously hidden via a special
status update of css::frame::status::Visibility.
Change-Id: Ief9f70a289bd2e6a4855c1f92dbc20e31c62924c
Reviewed-on: https://gerrit.libreoffice.org/82222
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky <momonasmon at gmail.com>
diff --git a/framework/inc/uielement/menubarmanager.hxx b/framework/inc/uielement/menubarmanager.hxx
index a1fbdb82d0fe..407814a7640b 100644
--- a/framework/inc/uielement/menubarmanager.hxx
+++ b/framework/inc/uielement/menubarmanager.hxx
@@ -153,10 +153,12 @@ class MenuBarManager final :
css::uno::Reference< css::frame::XStatusListener > const & xManager,
css::uno::Reference< css::frame::XDispatch > const & rDispatch ) :
nItemId( aItemId ),
+ bMadeInvisible ( false ),
xSubMenuManager( xManager ),
xMenuItemDispatch( rDispatch ) {}
sal_uInt16 nItemId;
+ bool bMadeInvisible;
OUString aTargetFrame;
OUString aMenuItemURL;
OUString aParsedItemURL;
diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx
index 316cd2e6d2c9..ea679171f898 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -338,13 +338,14 @@ void SAL_CALL MenuBarManager::statusChanged( const FeatureStateEvent& Event )
if ( Event.State >>= bCheckmark )
{
// Checkmark or RadioButton
- m_pVCLMenu->ShowItem( menuItemHandler->nItemId );
m_pVCLMenu->CheckItem( menuItemHandler->nItemId, bCheckmark );
-
+ // If not already designated RadioButton set as CheckMark
MenuItemBits nBits = m_pVCLMenu->GetItemBits( menuItemHandler->nItemId );
- //If not already designated RadioButton set as CheckMark
if (!(nBits & MenuItemBits::RADIOCHECK))
m_pVCLMenu->SetItemBits( menuItemHandler->nItemId, nBits | MenuItemBits::CHECKABLE );
+
+ if ( menuItemHandler->bMadeInvisible )
+ m_pVCLMenu->ShowItem( menuItemHandler->nItemId );
}
else if ( Event.State >>= aItemText )
{
@@ -353,11 +354,9 @@ void SAL_CALL MenuBarManager::statusChanged( const FeatureStateEvent& Event )
if ( !aEnumPart.isEmpty() && aURL.GetProtocol() == INetProtocol::Uno )
{
// Checkmark or RadioButton
- m_pVCLMenu->ShowItem( menuItemHandler->nItemId );
m_pVCLMenu->CheckItem( menuItemHandler->nItemId, aItemText == aEnumPart );
-
+ // If not already designated RadioButton set as CheckMark
MenuItemBits nBits = m_pVCLMenu->GetItemBits( menuItemHandler->nItemId );
- //If not already designated RadioButton set as CheckMark
if (!(nBits & MenuItemBits::RADIOCHECK))
m_pVCLMenu->SetItemBits( menuItemHandler->nItemId, nBits | MenuItemBits::CHECKABLE );
}
@@ -377,16 +376,19 @@ void SAL_CALL MenuBarManager::statusChanged( const FeatureStateEvent& Event )
aItemText = FwkResId(STR_SAVECOPYDOC) + aItemText.copy( 4 );
}
- m_pVCLMenu->ShowItem( menuItemHandler->nItemId );
m_pVCLMenu->SetItemText( menuItemHandler->nItemId, aItemText );
}
+
+ if ( menuItemHandler->bMadeInvisible )
+ m_pVCLMenu->ShowItem( menuItemHandler->nItemId );
}
else if ( Event.State >>= aVisibilityStatus )
{
// Visibility
m_pVCLMenu->ShowItem( menuItemHandler->nItemId, aVisibilityStatus.bVisible );
+ menuItemHandler->bMadeInvisible = !aVisibilityStatus.bVisible;
}
- else
+ else if ( menuItemHandler->bMadeInvisible )
m_pVCLMenu->ShowItem( menuItemHandler->nItemId );
}
More information about the Libreoffice-commits
mailing list