diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2015-10-28 14:21:03 +0200 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2015-11-11 15:03:37 +0200 |
commit | 737555eb2ff5f4f90b9794784e1ac8f0451b9b97 (patch) | |
tree | cfeca6c43dfa3e93b34ab2923fd7fac6aa67125d | |
parent | 5c142dd31de4a6d1c6ce9885ad06d84aca492152 (diff) |
tdf#93837 Add a new PopupLabel property
Some commands in context menus use different labels than in
the menu bar. In the old resource format those labels are
defined in the resource file itself. Note that the menu xml
has the menu:label attribute, but we can't use it because it
lacks localization support, and as such useful only for user
customization.
The order of consideration now is:
1. Label - Used if Context/PopupLabel isn't defined. (It's
also used as the base for toolbar tooltips.)
2. ContextLabel - Overrides Label when in menu or context menu.
Useful to drop the context, e.g. "Insert Image" should be only
"Image" under "Insert" menu. If exists, that's what returned
when asking for the "Label" property, instead of the full label.
3. PopupLabel - Overrides Label/ContextLabel when in context menu.
Used to give items in a context menu different labels than in
the main menu, e.g. "Paste Special" from the main menu turns to
"More Options" when in context menu. It doesn't affect the Label
property, and should be asked separately.
Change-Id: I7408fc2bfb8d384b0f1a72a78b8c5d7c50de38da
-rw-r--r-- | framework/source/uielement/menubarmanager.cxx | 7 | ||||
-rw-r--r-- | framework/source/uielement/uicommanddescription.cxx | 12 | ||||
-rw-r--r-- | officecfg/registry/schema/org/openoffice/Office/UI/Commands.xcs | 5 |
3 files changed, 23 insertions, 1 deletions
diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 2c0db7b83eea..399c667a3487 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -1096,6 +1096,13 @@ bool MenuBarManager::MustBeHidden( PopupMenu* pPopupMenu, const Reference< XURLT OUString MenuBarManager::RetrieveLabelFromCommand(const OUString& rCmdURL) { + if ( !m_bHasMenuBar ) + { + // This is a context menu, prefer "PopupLabel" over "Label". + OUString aPopupLabel = framework::RetrieveLabelFromCommand(rCmdURL, m_xContext, m_xUICommandLabels,m_xFrame,m_aModuleIdentifier,m_bModuleIdentified,"PopupLabel"); + if ( !aPopupLabel.isEmpty() ) + return aPopupLabel; + } return framework::RetrieveLabelFromCommand(rCmdURL, m_xContext, m_xUICommandLabels,m_xFrame,m_aModuleIdentifier,m_bModuleIdentified,"Label"); } diff --git a/framework/source/uielement/uicommanddescription.cxx b/framework/source/uielement/uicommanddescription.cxx index de99a7be0962..3f6bc545f83a 100644 --- a/framework/source/uielement/uicommanddescription.cxx +++ b/framework/source/uielement/uicommanddescription.cxx @@ -59,11 +59,13 @@ static const char CONFIGURATION_CMD_ELEMENT_ACCESS[] = "/UserInterface/Comman static const char CONFIGURATION_POP_ELEMENT_ACCESS[] = "/UserInterface/Popups"; static const char CONFIGURATION_PROPERTY_LABEL[] = "Label"; static const char CONFIGURATION_PROPERTY_CONTEXT_LABEL[] = "ContextLabel"; +static const char CONFIGURATION_PROPERTY_POPUP_LABEL[] = "PopupLabel"; // Property names of the resulting Property Set static const char PROPSET_LABEL[] = "Label"; static const char PROPSET_NAME[] = "Name"; static const char PROPSET_POPUP[] = "Popup"; +static const char PROPSET_POPUPLABEL[] = "PopupLabel"; static const char PROPSET_PROPERTIES[] = "Properties"; // Special resource URLs to retrieve additional information @@ -123,6 +125,7 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa OUString aLabel; OUString aContextLabel; OUString aCommandName; + OUString aPopupLabel; bool bPopup : 1, bCommandNameCreated : 1; sal_Int32 nProperties; @@ -151,9 +154,11 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa OUString m_aConfigPopupAccess; OUString m_aPropUILabel; OUString m_aPropUIContextLabel; + OUString m_aPropUIPopupLabel; OUString m_aPropLabel; OUString m_aPropName; OUString m_aPropPopup; + OUString m_aPropPopupLabel; OUString m_aPropProperties; OUString m_aPrivateResourceURL; Reference< XNameAccess > m_xGenericUICommands; @@ -178,9 +183,11 @@ ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( const OUString& aM m_aConfigPopupAccess( CONFIGURATION_ROOT_ACCESS ), m_aPropUILabel( CONFIGURATION_PROPERTY_LABEL ), m_aPropUIContextLabel( CONFIGURATION_PROPERTY_CONTEXT_LABEL ), + m_aPropUIPopupLabel( CONFIGURATION_PROPERTY_POPUP_LABEL ), m_aPropLabel( PROPSET_LABEL ), m_aPropName( PROPSET_NAME ), m_aPropPopup( PROPSET_POPUP ), + m_aPropPopupLabel( PROPSET_POPUPLABEL ), m_aPropProperties( PROPSET_PROPERTIES ), m_aPrivateResourceURL( PRIVATE_RESOURCE_URL ), m_xGenericUICommands( rGenericUICommands ), @@ -299,7 +306,7 @@ Any ConfigurationAccess_UICommand::getSequenceFromCache( const OUString& aComman if ( !pIter->second.bCommandNameCreated ) fillInfoFromResult( pIter->second, pIter->second.aLabel ); - Sequence< PropertyValue > aPropSeq( 4 ); + Sequence< PropertyValue > aPropSeq( 5 ); aPropSeq[0].Name = m_aPropLabel; aPropSeq[0].Value = !pIter->second.aContextLabel.isEmpty() ? makeAny( pIter->second.aContextLabel ): makeAny( pIter->second.aLabel ); @@ -309,6 +316,8 @@ Any ConfigurationAccess_UICommand::getSequenceFromCache( const OUString& aComman aPropSeq[2].Value <<= pIter->second.bPopup; aPropSeq[3].Name = m_aPropProperties; aPropSeq[3].Value <<= pIter->second.nProperties; + aPropSeq[4].Name = m_aPropPopupLabel; + aPropSeq[4].Value <<= pIter->second.aPopupLabel; return makeAny( aPropSeq ); } @@ -335,6 +344,7 @@ void ConfigurationAccess_UICommand::impl_fill(const Reference< XNameAccess >& _x aCmdToInfo.bPopup = _bPopup; xNameAccess->getByName( m_aPropUILabel ) >>= aCmdToInfo.aLabel; xNameAccess->getByName( m_aPropUIContextLabel ) >>= aCmdToInfo.aContextLabel; + xNameAccess->getByName( m_aPropUIPopupLabel ) >>= aCmdToInfo.aPopupLabel; xNameAccess->getByName( m_aPropProperties ) >>= aCmdToInfo.nProperties; m_aCmdInfoCache.insert( CommandToInfoCache::value_type( aNameSeq[i], aCmdToInfo )); diff --git a/officecfg/registry/schema/org/openoffice/Office/UI/Commands.xcs b/officecfg/registry/schema/org/openoffice/Office/UI/Commands.xcs index f5e12241dec7..85460d2cbc37 100644 --- a/officecfg/registry/schema/org/openoffice/Office/UI/Commands.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/UI/Commands.xcs @@ -36,6 +36,11 @@ <desc>A localized text that describes the identifier of a command in a structured menu. </desc> </info> </prop> + <prop oor:name="PopupLabel" oor:type="xs:string" oor:localized="true"> + <info> + <desc>A localized text that describes the identifier of a command in a popup menu.</desc> + </info> + </prop> <prop oor:name="Properties" oor:type="xs:int" oor:nillable="false"> <info> <desc> |