diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2015-11-12 17:04:36 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2015-11-12 17:13:14 +0100 |
commit | 9c2f197e8e945f584e718e889938c06fbf644897 (patch) | |
tree | 1f1cda9888862f35f13d62aca72b5e2eac314b5e /framework/source | |
parent | 82abd23f3ee1900b7579e5a0afa23581d5836f01 (diff) |
Add a new TooltipLabel property for uno commands
This allows buttons to have different labels and tooltips.
Change-Id: Icbc3fe5f3b4db8a2e6b7177c21341f2df3520f19
Diffstat (limited to 'framework/source')
-rw-r--r-- | framework/source/uielement/toolbarmanager.cxx | 11 | ||||
-rw-r--r-- | framework/source/uielement/uicommanddescription.cxx | 12 |
2 files changed, 18 insertions, 5 deletions
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 3847e2d68c70..efc6a489456b 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -809,7 +809,7 @@ uno::Sequence< beans::PropertyValue > ToolBarManager::GetPropsForCommand( const return aPropSeq; } -OUString ToolBarManager::RetrieveLabelFromCommand( const OUString& aCmdURL ) +OUString ToolBarManager::RetrieveFromCommand( const OUString aName, const OUString& aCmdURL ) { OUString aLabel; Sequence< PropertyValue > aPropSeq; @@ -818,7 +818,7 @@ OUString ToolBarManager::RetrieveLabelFromCommand( const OUString& aCmdURL ) aPropSeq = GetPropsForCommand( aCmdURL ); for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) { - if ( aPropSeq[i].Name == "Name" ) + if ( aPropSeq[i].Name == aName ) { aPropSeq[i].Value >>= aLabel; break; @@ -1272,7 +1272,8 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine 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 ); if ( aMenuDesc.is() ) @@ -1284,8 +1285,10 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine m_pToolBar->SetItemCommand( nId, aCommandURL ); OUString sQuickHelp( aString ); // Use custom tooltip if available - if ( !aTooltip.isEmpty() ) + if ( !aTooltip.isEmpty() ) // Tooltip from menu xml file (toolbar:tooltip) sQuickHelp = aTooltip; + else if ( !aTooltipFromCommand.isEmpty() ) // Tooltip from uno command (TooltipLabel) + sQuickHelp = aTooltipFromCommand; OUString sShortCut; if( RetrieveShortcut( aCommandURL, sShortCut ) ) { diff --git a/framework/source/uielement/uicommanddescription.cxx b/framework/source/uielement/uicommanddescription.cxx index 3f6bc545f83a..926f5c094be1 100644 --- a/framework/source/uielement/uicommanddescription.cxx +++ b/framework/source/uielement/uicommanddescription.cxx @@ -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_CONTEXT_LABEL[] = "ContextLabel"; static const char CONFIGURATION_PROPERTY_POPUP_LABEL[] = "PopupLabel"; +static const char CONFIGURATION_PROPERTY_TOOLTIP_LABEL[] = "TooltipLabel"; // 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_TOOLTIPLABEL[] = "TooltipLabel"; static const char PROPSET_PROPERTIES[] = "Properties"; // Special resource URLs to retrieve additional information @@ -126,6 +128,7 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa OUString aContextLabel; OUString aCommandName; OUString aPopupLabel; + OUString aTooltipLabel; bool bPopup : 1, bCommandNameCreated : 1; sal_Int32 nProperties; @@ -155,10 +158,12 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa OUString m_aPropUILabel; OUString m_aPropUIContextLabel; OUString m_aPropUIPopupLabel; + OUString m_aPropUITooltipLabel; OUString m_aPropLabel; OUString m_aPropName; OUString m_aPropPopup; OUString m_aPropPopupLabel; + OUString m_aPropTooltipLabel; OUString m_aPropProperties; OUString m_aPrivateResourceURL; Reference< XNameAccess > m_xGenericUICommands; @@ -184,10 +189,12 @@ ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( const OUString& aM m_aPropUILabel( CONFIGURATION_PROPERTY_LABEL ), m_aPropUIContextLabel( CONFIGURATION_PROPERTY_CONTEXT_LABEL ), m_aPropUIPopupLabel( CONFIGURATION_PROPERTY_POPUP_LABEL ), + m_aPropUITooltipLabel( CONFIGURATION_PROPERTY_TOOLTIP_LABEL ), m_aPropLabel( PROPSET_LABEL ), m_aPropName( PROPSET_NAME ), m_aPropPopup( PROPSET_POPUP ), m_aPropPopupLabel( PROPSET_POPUPLABEL ), + m_aPropTooltipLabel( PROPSET_TOOLTIPLABEL ), m_aPropProperties( PROPSET_PROPERTIES ), m_aPrivateResourceURL( PRIVATE_RESOURCE_URL ), m_xGenericUICommands( rGenericUICommands ), @@ -306,7 +313,7 @@ Any ConfigurationAccess_UICommand::getSequenceFromCache( const OUString& aComman if ( !pIter->second.bCommandNameCreated ) fillInfoFromResult( pIter->second, pIter->second.aLabel ); - Sequence< PropertyValue > aPropSeq( 5 ); + Sequence< PropertyValue > aPropSeq( 6 ); aPropSeq[0].Name = m_aPropLabel; aPropSeq[0].Value = !pIter->second.aContextLabel.isEmpty() ? makeAny( pIter->second.aContextLabel ): makeAny( pIter->second.aLabel ); @@ -318,6 +325,8 @@ Any ConfigurationAccess_UICommand::getSequenceFromCache( const OUString& aComman aPropSeq[3].Value <<= pIter->second.nProperties; aPropSeq[4].Name = m_aPropPopupLabel; aPropSeq[4].Value <<= pIter->second.aPopupLabel; + aPropSeq[5].Name = m_aPropTooltipLabel; + aPropSeq[5].Value <<= pIter->second.aTooltipLabel; return makeAny( aPropSeq ); } @@ -345,6 +354,7 @@ void ConfigurationAccess_UICommand::impl_fill(const Reference< XNameAccess >& _x xNameAccess->getByName( m_aPropUILabel ) >>= aCmdToInfo.aLabel; xNameAccess->getByName( m_aPropUIContextLabel ) >>= aCmdToInfo.aContextLabel; xNameAccess->getByName( m_aPropUIPopupLabel ) >>= aCmdToInfo.aPopupLabel; + xNameAccess->getByName( m_aPropUITooltipLabel ) >>= aCmdToInfo.aTooltipLabel; xNameAccess->getByName( m_aPropProperties ) >>= aCmdToInfo.nProperties; m_aCmdInfoCache.insert( CommandToInfoCache::value_type( aNameSeq[i], aCmdToInfo )); |