Kaydet (Commit) 9c2f197e authored tarafından Samuel Mehrbrodt's avatar Samuel Mehrbrodt

Add a new TooltipLabel property for uno commands

This allows buttons to have different labels and tooltips.

Change-Id: Icbc3fe5f3b4db8a2e6b7177c21341f2df3520f19
üst 82abd23f
...@@ -144,7 +144,7 @@ class ToolBarManager : public ToolbarManager_Base ...@@ -144,7 +144,7 @@ class ToolBarManager : public ToolbarManager_Base
virtual bool MenuItemAllowed( sal_uInt16 ) const; virtual bool MenuItemAllowed( sal_uInt16 ) const;
void RemoveControllers(); void RemoveControllers();
OUString RetrieveLabelFromCommand( const OUString& aCmdURL ); OUString RetrieveFromCommand( const OUString aName, const OUString& aCmdURL );
sal_Int32 RetrievePropertiesFromCommand( const OUString& aCmdURL ); sal_Int32 RetrievePropertiesFromCommand( const OUString& aCmdURL );
css::uno::Sequence< css::beans::PropertyValue > GetPropsForCommand( const OUString& rCmdURL ); css::uno::Sequence< css::beans::PropertyValue > GetPropsForCommand( const OUString& rCmdURL );
void CreateControllers(); void CreateControllers();
......
...@@ -809,7 +809,7 @@ uno::Sequence< beans::PropertyValue > ToolBarManager::GetPropsForCommand( const ...@@ -809,7 +809,7 @@ uno::Sequence< beans::PropertyValue > ToolBarManager::GetPropsForCommand( const
return aPropSeq; return aPropSeq;
} }
OUString ToolBarManager::RetrieveLabelFromCommand( const OUString& aCmdURL ) OUString ToolBarManager::RetrieveFromCommand( const OUString aName, const OUString& aCmdURL )
{ {
OUString aLabel; OUString aLabel;
Sequence< PropertyValue > aPropSeq; Sequence< PropertyValue > aPropSeq;
...@@ -818,7 +818,7 @@ OUString ToolBarManager::RetrieveLabelFromCommand( const OUString& aCmdURL ) ...@@ -818,7 +818,7 @@ OUString ToolBarManager::RetrieveLabelFromCommand( const OUString& aCmdURL )
aPropSeq = GetPropsForCommand( aCmdURL ); aPropSeq = GetPropsForCommand( aCmdURL );
for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
{ {
if ( aPropSeq[i].Name == "Name" ) if ( aPropSeq[i].Name == aName )
{ {
aPropSeq[i].Value >>= aLabel; aPropSeq[i].Value >>= aLabel;
break; break;
...@@ -1272,7 +1272,8 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine ...@@ -1272,7 +1272,8 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
if (( nType == css::ui::ItemType::DEFAULT ) && !aCommandURL.isEmpty() ) if (( nType == css::ui::ItemType::DEFAULT ) && !aCommandURL.isEmpty() )
{ {
OUString aString( RetrieveLabelFromCommand( aCommandURL )); OUString aString( RetrieveFromCommand( "Label", aCommandURL ));
OUString aTooltipFromCommand( RetrieveFromCommand( "TooltipLabel", aCommandURL ));
ToolBoxItemBits nItemBits = ConvertStyleToToolboxItemBits( nStyle ); ToolBoxItemBits nItemBits = ConvertStyleToToolboxItemBits( nStyle );
if ( aMenuDesc.is() ) if ( aMenuDesc.is() )
...@@ -1284,8 +1285,10 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine ...@@ -1284,8 +1285,10 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
m_pToolBar->SetItemCommand( nId, aCommandURL ); m_pToolBar->SetItemCommand( nId, aCommandURL );
OUString sQuickHelp( aString ); OUString sQuickHelp( aString );
// Use custom tooltip if available // Use custom tooltip if available
if ( !aTooltip.isEmpty() ) if ( !aTooltip.isEmpty() ) // Tooltip from menu xml file (toolbar:tooltip)
sQuickHelp = aTooltip; sQuickHelp = aTooltip;
else if ( !aTooltipFromCommand.isEmpty() ) // Tooltip from uno command (TooltipLabel)
sQuickHelp = aTooltipFromCommand;
OUString sShortCut; OUString sShortCut;
if( RetrieveShortcut( aCommandURL, sShortCut ) ) if( RetrieveShortcut( aCommandURL, sShortCut ) )
{ {
......
...@@ -60,12 +60,14 @@ static const char CONFIGURATION_POP_ELEMENT_ACCESS[] = "/UserInterface/Popups ...@@ -60,12 +60,14 @@ 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"; static const char CONFIGURATION_PROPERTY_POPUP_LABEL[] = "PopupLabel";
static const char CONFIGURATION_PROPERTY_TOOLTIP_LABEL[] = "TooltipLabel";
// 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_POPUPLABEL[] = "PopupLabel";
static const char PROPSET_TOOLTIPLABEL[] = "TooltipLabel";
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
...@@ -126,6 +128,7 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa ...@@ -126,6 +128,7 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa
OUString aContextLabel; OUString aContextLabel;
OUString aCommandName; OUString aCommandName;
OUString aPopupLabel; OUString aPopupLabel;
OUString aTooltipLabel;
bool bPopup : 1, bool bPopup : 1,
bCommandNameCreated : 1; bCommandNameCreated : 1;
sal_Int32 nProperties; sal_Int32 nProperties;
...@@ -155,10 +158,12 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa ...@@ -155,10 +158,12 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa
OUString m_aPropUILabel; OUString m_aPropUILabel;
OUString m_aPropUIContextLabel; OUString m_aPropUIContextLabel;
OUString m_aPropUIPopupLabel; OUString m_aPropUIPopupLabel;
OUString m_aPropUITooltipLabel;
OUString m_aPropLabel; OUString m_aPropLabel;
OUString m_aPropName; OUString m_aPropName;
OUString m_aPropPopup; OUString m_aPropPopup;
OUString m_aPropPopupLabel; OUString m_aPropPopupLabel;
OUString m_aPropTooltipLabel;
OUString m_aPropProperties; OUString m_aPropProperties;
OUString m_aPrivateResourceURL; OUString m_aPrivateResourceURL;
Reference< XNameAccess > m_xGenericUICommands; Reference< XNameAccess > m_xGenericUICommands;
...@@ -184,10 +189,12 @@ ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( const OUString& aM ...@@ -184,10 +189,12 @@ ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( const OUString& aM
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_aPropUIPopupLabel( CONFIGURATION_PROPERTY_POPUP_LABEL ),
m_aPropUITooltipLabel( CONFIGURATION_PROPERTY_TOOLTIP_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_aPropPopupLabel( PROPSET_POPUPLABEL ),
m_aPropTooltipLabel( PROPSET_TOOLTIPLABEL ),
m_aPropProperties( PROPSET_PROPERTIES ), m_aPropProperties( PROPSET_PROPERTIES ),
m_aPrivateResourceURL( PRIVATE_RESOURCE_URL ), m_aPrivateResourceURL( PRIVATE_RESOURCE_URL ),
m_xGenericUICommands( rGenericUICommands ), m_xGenericUICommands( rGenericUICommands ),
...@@ -306,7 +313,7 @@ Any ConfigurationAccess_UICommand::getSequenceFromCache( const OUString& aComman ...@@ -306,7 +313,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( 5 ); Sequence< PropertyValue > aPropSeq( 6 );
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 );
...@@ -318,6 +325,8 @@ Any ConfigurationAccess_UICommand::getSequenceFromCache( const OUString& aComman ...@@ -318,6 +325,8 @@ Any ConfigurationAccess_UICommand::getSequenceFromCache( const OUString& aComman
aPropSeq[3].Value <<= pIter->second.nProperties; aPropSeq[3].Value <<= pIter->second.nProperties;
aPropSeq[4].Name = m_aPropPopupLabel; aPropSeq[4].Name = m_aPropPopupLabel;
aPropSeq[4].Value <<= pIter->second.aPopupLabel; aPropSeq[4].Value <<= pIter->second.aPopupLabel;
aPropSeq[5].Name = m_aPropTooltipLabel;
aPropSeq[5].Value <<= pIter->second.aTooltipLabel;
return makeAny( aPropSeq ); return makeAny( aPropSeq );
} }
...@@ -345,6 +354,7 @@ void ConfigurationAccess_UICommand::impl_fill(const Reference< XNameAccess >& _x ...@@ -345,6 +354,7 @@ void ConfigurationAccess_UICommand::impl_fill(const Reference< XNameAccess >& _x
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_aPropUIPopupLabel ) >>= aCmdToInfo.aPopupLabel;
xNameAccess->getByName( m_aPropUITooltipLabel ) >>= aCmdToInfo.aTooltipLabel;
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 ));
......
...@@ -28,17 +28,22 @@ ...@@ -28,17 +28,22 @@
</info> </info>
<prop oor:name="Label" oor:type="xs:string" oor:localized="true"> <prop oor:name="Label" oor:type="xs:string" oor:localized="true">
<info> <info>
<desc>A localized text that describes the command or identifier. Can be used as a label inside a menu or as short tool tip help.</desc> <desc>A localized text that describes the command. Will be used instead of ContextLabel, PopupLabel and TooltipLabel if those are not specified.</desc>
</info> </info>
</prop> </prop>
<prop oor:name="ContextLabel" oor:type="xs:string" oor:localized="true"> <prop oor:name="ContextLabel" oor:type="xs:string" oor:localized="true">
<info> <info>
<desc>A localized text that describes the identifier of a command in a structured menu. </desc> <desc>Used in Menus and also in popup menus if PopupLabel is not specified.</desc>
</info> </info>
</prop> </prop>
<prop oor:name="PopupLabel" oor:type="xs:string" oor:localized="true"> <prop oor:name="PopupLabel" oor:type="xs:string" oor:localized="true">
<info> <info>
<desc>A localized text that describes the identifier of a command in a popup menu.</desc> <desc>Used in popup menus to give commands a different label than in the main menu.</desc>
</info>
</prop>
<prop oor:name="TooltipLabel" oor:type="xs:string" oor:localized="true">
<info>
<desc>Used for Tooltips (Toolbar and Glade Widgets that have their 'action_name' specified.)</desc>
</info> </info>
</prop> </prop>
<prop oor:name="Properties" oor:type="xs:int" oor:nillable="false"> <prop oor:name="Properties" oor:type="xs:int" oor:nillable="false">
......
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