Kaydet (Commit) 737555eb authored tarafından Maxim Monastirsky's avatar Maxim Monastirsky

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
üst 5c142dd3
...@@ -1096,6 +1096,13 @@ bool MenuBarManager::MustBeHidden( PopupMenu* pPopupMenu, const Reference< XURLT ...@@ -1096,6 +1096,13 @@ bool MenuBarManager::MustBeHidden( PopupMenu* pPopupMenu, const Reference< XURLT
OUString MenuBarManager::RetrieveLabelFromCommand(const OUString& rCmdURL) 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"); return framework::RetrieveLabelFromCommand(rCmdURL, m_xContext, m_xUICommandLabels,m_xFrame,m_aModuleIdentifier,m_bModuleIdentified,"Label");
} }
......
...@@ -59,11 +59,13 @@ static const char CONFIGURATION_CMD_ELEMENT_ACCESS[] = "/UserInterface/Comman ...@@ -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_POP_ELEMENT_ACCESS[] = "/UserInterface/Popups";
static const char CONFIGURATION_PROPERTY_LABEL[] = "Label"; static const char CONFIGURATION_PROPERTY_LABEL[] = "Label";
static const char CONFIGURATION_PROPERTY_CONTEXT_LABEL[] = "ContextLabel"; static const char CONFIGURATION_PROPERTY_CONTEXT_LABEL[] = "ContextLabel";
static const char CONFIGURATION_PROPERTY_POPUP_LABEL[] = "PopupLabel";
// Property names of the resulting Property Set // Property names of the resulting Property Set
static const char PROPSET_LABEL[] = "Label"; static const char PROPSET_LABEL[] = "Label";
static const char PROPSET_NAME[] = "Name"; static const char PROPSET_NAME[] = "Name";
static const char PROPSET_POPUP[] = "Popup"; static const char PROPSET_POPUP[] = "Popup";
static const char PROPSET_POPUPLABEL[] = "PopupLabel";
static const char PROPSET_PROPERTIES[] = "Properties"; static const char PROPSET_PROPERTIES[] = "Properties";
// Special resource URLs to retrieve additional information // Special resource URLs to retrieve additional information
...@@ -123,6 +125,7 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa ...@@ -123,6 +125,7 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa
OUString aLabel; OUString aLabel;
OUString aContextLabel; OUString aContextLabel;
OUString aCommandName; OUString aCommandName;
OUString aPopupLabel;
bool bPopup : 1, bool bPopup : 1,
bCommandNameCreated : 1; bCommandNameCreated : 1;
sal_Int32 nProperties; sal_Int32 nProperties;
...@@ -151,9 +154,11 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa ...@@ -151,9 +154,11 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa
OUString m_aConfigPopupAccess; OUString m_aConfigPopupAccess;
OUString m_aPropUILabel; OUString m_aPropUILabel;
OUString m_aPropUIContextLabel; OUString m_aPropUIContextLabel;
OUString m_aPropUIPopupLabel;
OUString m_aPropLabel; OUString m_aPropLabel;
OUString m_aPropName; OUString m_aPropName;
OUString m_aPropPopup; OUString m_aPropPopup;
OUString m_aPropPopupLabel;
OUString m_aPropProperties; OUString m_aPropProperties;
OUString m_aPrivateResourceURL; OUString m_aPrivateResourceURL;
Reference< XNameAccess > m_xGenericUICommands; Reference< XNameAccess > m_xGenericUICommands;
...@@ -178,9 +183,11 @@ ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( const OUString& aM ...@@ -178,9 +183,11 @@ ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( const OUString& aM
m_aConfigPopupAccess( CONFIGURATION_ROOT_ACCESS ), m_aConfigPopupAccess( CONFIGURATION_ROOT_ACCESS ),
m_aPropUILabel( CONFIGURATION_PROPERTY_LABEL ), m_aPropUILabel( CONFIGURATION_PROPERTY_LABEL ),
m_aPropUIContextLabel( CONFIGURATION_PROPERTY_CONTEXT_LABEL ), m_aPropUIContextLabel( CONFIGURATION_PROPERTY_CONTEXT_LABEL ),
m_aPropUIPopupLabel( CONFIGURATION_PROPERTY_POPUP_LABEL ),
m_aPropLabel( PROPSET_LABEL ), m_aPropLabel( PROPSET_LABEL ),
m_aPropName( PROPSET_NAME ), m_aPropName( PROPSET_NAME ),
m_aPropPopup( PROPSET_POPUP ), m_aPropPopup( PROPSET_POPUP ),
m_aPropPopupLabel( PROPSET_POPUPLABEL ),
m_aPropProperties( PROPSET_PROPERTIES ), m_aPropProperties( PROPSET_PROPERTIES ),
m_aPrivateResourceURL( PRIVATE_RESOURCE_URL ), m_aPrivateResourceURL( PRIVATE_RESOURCE_URL ),
m_xGenericUICommands( rGenericUICommands ), m_xGenericUICommands( rGenericUICommands ),
...@@ -299,7 +306,7 @@ Any ConfigurationAccess_UICommand::getSequenceFromCache( const OUString& aComman ...@@ -299,7 +306,7 @@ Any ConfigurationAccess_UICommand::getSequenceFromCache( const OUString& aComman
if ( !pIter->second.bCommandNameCreated ) if ( !pIter->second.bCommandNameCreated )
fillInfoFromResult( pIter->second, pIter->second.aLabel ); fillInfoFromResult( pIter->second, pIter->second.aLabel );
Sequence< PropertyValue > aPropSeq( 4 ); Sequence< PropertyValue > aPropSeq( 5 );
aPropSeq[0].Name = m_aPropLabel; aPropSeq[0].Name = m_aPropLabel;
aPropSeq[0].Value = !pIter->second.aContextLabel.isEmpty() ? aPropSeq[0].Value = !pIter->second.aContextLabel.isEmpty() ?
makeAny( pIter->second.aContextLabel ): makeAny( pIter->second.aLabel ); makeAny( pIter->second.aContextLabel ): makeAny( pIter->second.aLabel );
...@@ -309,6 +316,8 @@ Any ConfigurationAccess_UICommand::getSequenceFromCache( const OUString& aComman ...@@ -309,6 +316,8 @@ Any ConfigurationAccess_UICommand::getSequenceFromCache( const OUString& aComman
aPropSeq[2].Value <<= pIter->second.bPopup; aPropSeq[2].Value <<= pIter->second.bPopup;
aPropSeq[3].Name = m_aPropProperties; aPropSeq[3].Name = m_aPropProperties;
aPropSeq[3].Value <<= pIter->second.nProperties; aPropSeq[3].Value <<= pIter->second.nProperties;
aPropSeq[4].Name = m_aPropPopupLabel;
aPropSeq[4].Value <<= pIter->second.aPopupLabel;
return makeAny( aPropSeq ); return makeAny( aPropSeq );
} }
...@@ -335,6 +344,7 @@ void ConfigurationAccess_UICommand::impl_fill(const Reference< XNameAccess >& _x ...@@ -335,6 +344,7 @@ void ConfigurationAccess_UICommand::impl_fill(const Reference< XNameAccess >& _x
aCmdToInfo.bPopup = _bPopup; aCmdToInfo.bPopup = _bPopup;
xNameAccess->getByName( m_aPropUILabel ) >>= aCmdToInfo.aLabel; xNameAccess->getByName( m_aPropUILabel ) >>= aCmdToInfo.aLabel;
xNameAccess->getByName( m_aPropUIContextLabel ) >>= aCmdToInfo.aContextLabel; xNameAccess->getByName( m_aPropUIContextLabel ) >>= aCmdToInfo.aContextLabel;
xNameAccess->getByName( m_aPropUIPopupLabel ) >>= aCmdToInfo.aPopupLabel;
xNameAccess->getByName( m_aPropProperties ) >>= aCmdToInfo.nProperties; xNameAccess->getByName( m_aPropProperties ) >>= aCmdToInfo.nProperties;
m_aCmdInfoCache.insert( CommandToInfoCache::value_type( aNameSeq[i], aCmdToInfo )); m_aCmdInfoCache.insert( CommandToInfoCache::value_type( aNameSeq[i], aCmdToInfo ));
......
...@@ -36,6 +36,11 @@ ...@@ -36,6 +36,11 @@
<desc>A localized text that describes the identifier of a command in a structured menu. </desc> <desc>A localized text that describes the identifier of a command in a structured menu. </desc>
</info> </info>
</prop> </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"> <prop oor:name="Properties" oor:type="xs:int" oor:nillable="false">
<info> <info>
<desc> <desc>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment