Cleanup: Consolidate the different ways to get command labels/tooltips

Change-Id: Ieab809a3122c9d592894b84ec2e68195a4e02dde
This commit is contained in:
Samuel Mehrbrodt
2015-11-13 17:00:03 +01:00
parent 773a07a94e
commit 099f1016fa
10 changed files with 100 additions and 195 deletions

View File

@@ -118,7 +118,7 @@ bool DeletedSpecial::VisitCXXMethodDecl(CXXMethodDecl const * decl) {
|| whitelist(decl, "sd::IconCache", "sd/source/ui/inc/tools/IconCache.hxx") || whitelist(decl, "sd::IconCache", "sd/source/ui/inc/tools/IconCache.hxx")
|| whitelist(decl, "sd::RemoteServer", "sd/source/ui/inc/RemoteServer.hxx") || whitelist(decl, "sd::RemoteServer", "sd/source/ui/inc/RemoteServer.hxx")
|| whitelist(decl, "sd::slidesorter::cache::PageCacheManager", "sd/source/ui/slidesorter/inc/cache/SlsPageCacheManager.hxx") || whitelist(decl, "sd::slidesorter::cache::PageCacheManager", "sd/source/ui/slidesorter/inc/cache/SlsPageCacheManager.hxx")
|| whitelist(decl, "sfx2::sidebar::CommandInfoProvider", "include/sfx2/sidebar/CommandInfoProvider.hxx") || whitelist(decl, "svt::CommandInfoProvider", "include/svt/commandinfoprovider.hxx")
|| whitelist(decl, "vcl::SettingsConfigItem", "include/vcl/configsettings.hxx") || whitelist(decl, "vcl::SettingsConfigItem", "include/vcl/configsettings.hxx")
|| whitelist(decl, "writerfilter::ooxml::OOXMLFactory", "writerfilter/source/ooxml/OOXMLFactory.hxx")) || whitelist(decl, "writerfilter::ooxml::OOXMLFactory", "writerfilter/source/ooxml/OOXMLFactory.hxx"))
{ {

View File

@@ -69,9 +69,9 @@
#include <vcl/toolbox.hxx> #include <vcl/toolbox.hxx>
#include <vcl/settings.hxx> #include <vcl/settings.hxx>
#include <svtools/commandinfoprovider.hxx>
#include <svtools/menuoptions.hxx> #include <svtools/menuoptions.hxx>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <svtools/acceleratorexecute.hxx>
// namespaces // namespaces
@@ -1272,8 +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( RetrieveFromCommand( "Name", aCommandURL )); OUString aString(svt::CommandInfoProvider::Instance().GetLabelForCommand(aCommandURL, m_xFrame));
OUString aTooltipFromCommand( RetrieveFromCommand( "TooltipLabel", aCommandURL )); OUString aTooltipFromCommand(svt::CommandInfoProvider::Instance().GetTooltipForCommand(aCommandURL, m_xFrame, false));
ToolBoxItemBits nItemBits = ConvertStyleToToolboxItemBits( nStyle ); ToolBoxItemBits nItemBits = ConvertStyleToToolboxItemBits( nStyle );
if ( aMenuDesc.is() ) if ( aMenuDesc.is() )
@@ -1289,8 +1289,8 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
sQuickHelp = aTooltip; sQuickHelp = aTooltip;
else if ( !aTooltipFromCommand.isEmpty() ) // Tooltip from uno command (TooltipLabel) else if ( !aTooltipFromCommand.isEmpty() ) // Tooltip from uno command (TooltipLabel)
sQuickHelp = aTooltipFromCommand; sQuickHelp = aTooltipFromCommand;
OUString sShortCut; OUString sShortCut = svt::CommandInfoProvider::Instance().GetCommandShortcut(aCommandURL, m_xFrame);
if( RetrieveShortcut( aCommandURL, sShortCut ) ) if( !sShortCut.isEmpty() )
{ {
sQuickHelp += " ("; sQuickHelp += " (";
sQuickHelp += sShortCut; sQuickHelp += sShortCut;
@@ -2167,121 +2167,6 @@ Image ToolBarManager::QueryAddonsImage( const OUString& aCommandURL, bool bBigIm
Image aImage = framework::AddonsOptions().GetImageFromURL( aCommandURL, bBigImages ); Image aImage = framework::AddonsOptions().GetImageFromURL( aCommandURL, bBigImages );
return aImage; return aImage;
} }
bool ToolBarManager::impl_RetrieveShortcutsFromConfiguration(
const Reference< XAcceleratorConfiguration >& rAccelCfg,
const OUString& rCommand,
OUString& rShortCut )
{
if ( rAccelCfg.is() )
{
try
{
css::awt::KeyEvent aKeyEvent;
Sequence< OUString > aCommands { rCommand };
Sequence< Any > aSeqKeyCode( rAccelCfg->getPreferredKeyEventsForCommandList( aCommands ) );
if( aSeqKeyCode.getLength() == 1 )
{
if ( aSeqKeyCode[0] >>= aKeyEvent )
{
rShortCut = svt::AcceleratorExecute::st_AWTKey2VCLKey( aKeyEvent ).GetName();
return true;
}
}
}
catch (const IllegalArgumentException&)
{
}
}
return false;
}
bool ToolBarManager::RetrieveShortcut( const OUString& rCommandURL, OUString& rShortCut )
{
if ( m_bModuleIdentified )
{
Reference< XAcceleratorConfiguration > xDocAccelCfg( m_xDocAcceleratorManager );
Reference< XAcceleratorConfiguration > xModuleAccelCfg( m_xModuleAcceleratorManager );
Reference< XAcceleratorConfiguration > xGlobalAccelCfg( m_xGlobalAcceleratorManager );
if ( !m_bAcceleratorCfg )
{
// Retrieve references on demand
m_bAcceleratorCfg = true;
if ( !xDocAccelCfg.is() )
{
Reference< XController > xController = m_xFrame->getController();
Reference< XModel > xModel;
if ( xController.is() )
{
xModel = xController->getModel();
if ( xModel.is() )
{
Reference< XUIConfigurationManagerSupplier > xSupplier( xModel, UNO_QUERY );
if ( xSupplier.is() )
{
Reference< XUIConfigurationManager > xDocUICfgMgr( xSupplier->getUIConfigurationManager(), UNO_QUERY );
if ( xDocUICfgMgr.is() )
{
xDocAccelCfg = xDocUICfgMgr->getShortCutManager();
m_xDocAcceleratorManager = xDocAccelCfg;
}
}
}
}
}
if ( !xModuleAccelCfg.is() )
{
Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgMgrSupplier =
theModuleUIConfigurationManagerSupplier::get( m_xContext );
try
{
Reference< XUIConfigurationManager > xUICfgMgr = xModuleCfgMgrSupplier->getUIConfigurationManager( m_aModuleIdentifier );
if ( xUICfgMgr.is() )
{
xModuleAccelCfg = xUICfgMgr->getShortCutManager();
m_xModuleAcceleratorManager = xModuleAccelCfg;
}
}
catch (const RuntimeException&)
{
throw;
}
catch (const Exception&)
{
}
}
if ( !xGlobalAccelCfg.is() ) try
{
xGlobalAccelCfg = GlobalAcceleratorConfiguration::create( m_xContext );
m_xGlobalAcceleratorManager = xGlobalAccelCfg;
}
catch ( const css::uno::DeploymentException& )
{
SAL_WARN("fwk.uielement", "GlobalAcceleratorConfiguration"
" not available. This should happen only on mobile platforms.");
}
}
bool bFound = false;
if ( m_xGlobalAcceleratorManager.is() )
bFound = impl_RetrieveShortcutsFromConfiguration( xGlobalAccelCfg, rCommandURL, rShortCut );
if ( !bFound && m_xModuleAcceleratorManager.is() )
bFound = impl_RetrieveShortcutsFromConfiguration( xModuleAccelCfg, rCommandURL, rShortCut );
if ( !bFound && m_xDocAcceleratorManager.is() )
impl_RetrieveShortcutsFromConfiguration( xGlobalAccelCfg, rCommandURL, rShortCut );
if( bFound )
return true;
}
return false;
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -94,11 +94,6 @@ public:
*/ */
void RequestUpdate(); void RequestUpdate();
/** Return the label for the command. It contains the keyboard
accelerator when one exists.
*/
::rtl::OUString GetLabel() const;
/** Return the extended help text for the command. /** Return the extended help text for the command.
Returns an empty string when the UNO command name is not available. Returns an empty string when the UNO command name is not available.
*/ */

View File

@@ -16,22 +16,22 @@
* except in compliance with the License. You may obtain a copy of * except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#ifndef INCLUDED_SFX2_SIDEBAR_COMMANDINFOPROVIDER_HXX #ifndef INCLUDED_COMPHELPER_COMMANDINFOPROVIDER_HXX
#define INCLUDED_SFX2_SIDEBAR_COMMANDINFOPROVIDER_HXX #define INCLUDED_COMPHELPER_COMMANDINFOPROVIDER_HXX
#include <sfx2/dllapi.h> #include <svtools/svtdllapi.h>
#include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/ui/XAcceleratorConfiguration.hpp> #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
namespace sfx2 { namespace sidebar { namespace svt {
/** Provide information about UNO commands like tooltip text with /** Provide information about UNO commands like tooltip text with
keyboard accelerator. keyboard accelerator.
*/ */
class SFX2_DLLPUBLIC CommandInfoProvider class SVT_DLLPUBLIC CommandInfoProvider
{ {
public: public:
/** Return the singleton instance. /** Return the singleton instance.
@@ -51,13 +51,32 @@ public:
@param rxFrame @param rxFrame
The frame is used to identify the module and document. The frame is used to identify the module and document.
@return @return
The returned label contains the keyboard accelerator, if The command labe.
one is defined.
*/ */
::rtl::OUString GetLabelForCommand ( OUString GetLabelForCommand (
const ::rtl::OUString& rsCommandName, const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame); const css::uno::Reference<css::frame::XFrame>& rxFrame);
/** Return a tooltip for the given command. Falls back to label if command has no tooltip.
@param rsCommandName
The command name is expected to start with .uno:
@param rxFrame
The frame is used to identify the module and document.
@param bIncludeShortcut
Whether the shortcut should be appended in brackets
@return
The returned label contains the keyboard accelerator, if
one is defined and bIncludeShortcut is true.
*/
OUString GetTooltipForCommand (
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame,
bool bIncludeShortcut = true);
/** Returns the shortcut for a command in human-readable form */
OUString GetCommandShortcut (const OUString& rCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame);
/** Do not call. Should be part of a local and hidden interface. /** Do not call. Should be part of a local and hidden interface.
*/ */
void SetFrame (const css::uno::Reference<css::frame::XFrame>& rxFrame); void SetFrame (const css::uno::Reference<css::frame::XFrame>& rxFrame);
@@ -68,7 +87,7 @@ public:
css::uno::Reference<css::ui::XAcceleratorConfiguration> mxCachedDocumentAcceleratorConfiguration; css::uno::Reference<css::ui::XAcceleratorConfiguration> mxCachedDocumentAcceleratorConfiguration;
css::uno::Reference<css::ui::XAcceleratorConfiguration> mxCachedModuleAcceleratorConfiguration; css::uno::Reference<css::ui::XAcceleratorConfiguration> mxCachedModuleAcceleratorConfiguration;
css::uno::Reference<css::ui::XAcceleratorConfiguration> mxCachedGlobalAcceleratorConfiguration; css::uno::Reference<css::ui::XAcceleratorConfiguration> mxCachedGlobalAcceleratorConfiguration;
::rtl::OUString msCachedModuleIdentifier; OUString msCachedModuleIdentifier;
css::uno::Reference<css::lang::XComponent> mxFrameListener; css::uno::Reference<css::lang::XComponent> mxFrameListener;
CommandInfoProvider(); CommandInfoProvider();
@@ -77,18 +96,17 @@ public:
css::uno::Reference<css::ui::XAcceleratorConfiguration> GetDocumentAcceleratorConfiguration(); css::uno::Reference<css::ui::XAcceleratorConfiguration> GetDocumentAcceleratorConfiguration();
css::uno::Reference<css::ui::XAcceleratorConfiguration> GetModuleAcceleratorConfiguration(); css::uno::Reference<css::ui::XAcceleratorConfiguration> GetModuleAcceleratorConfiguration();
css::uno::Reference<css::ui::XAcceleratorConfiguration> GetGlobalAcceleratorConfiguration(); css::uno::Reference<css::ui::XAcceleratorConfiguration> GetGlobalAcceleratorConfiguration();
::rtl::OUString GetModuleIdentifier(); OUString GetModuleIdentifier();
::rtl::OUString GetCommandShortcut (const ::rtl::OUString& rCommandName);
css::uno::Sequence<css::beans::PropertyValue> GetCommandProperties ( css::uno::Sequence<css::beans::PropertyValue> GetCommandProperties (
const ::rtl::OUString& rsCommandName); const OUString& rsCommandName);
::rtl::OUString GetCommandLabel (const ::rtl::OUString& rsCommandName); OUString GetCommandProperty(const OUString& rsProperty, const OUString& rsCommandName);
static rtl::OUString RetrieveShortcutsFromConfiguration( static OUString RetrieveShortcutsFromConfiguration(
const css::uno::Reference<css::ui::XAcceleratorConfiguration>& rxConfiguration, const css::uno::Reference<css::ui::XAcceleratorConfiguration>& rxConfiguration,
const rtl::OUString& rsCommandName); const OUString& rsCommandName);
}; };
} } // end of namespace sfx2/framework } // end of namespace svt
#endif #endif // INCLUDED_COMPHELPER_COMMANDINFOPROVIDER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -257,7 +257,6 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/sidebar/Accessible \ sfx2/source/sidebar/Accessible \
sfx2/source/sidebar/AccessibleTitleBar \ sfx2/source/sidebar/AccessibleTitleBar \
sfx2/source/sidebar/AsynchronousCall \ sfx2/source/sidebar/AsynchronousCall \
sfx2/source/sidebar/CommandInfoProvider \
sfx2/source/sidebar/Context \ sfx2/source/sidebar/Context \
sfx2/source/sidebar/ContextChangeBroadcaster \ sfx2/source/sidebar/ContextChangeBroadcaster \
sfx2/source/sidebar/ContextList \ sfx2/source/sidebar/ContextList \

View File

@@ -18,7 +18,6 @@
*/ */
#include <sfx2/sidebar/ControllerFactory.hxx> #include <sfx2/sidebar/ControllerFactory.hxx>
#include <sfx2/sidebar/CommandInfoProvider.hxx>
#include <sfx2/sidebar/Tools.hxx> #include <sfx2/sidebar/Tools.hxx>
#include <com/sun/star/frame/XToolbarController.hpp> #include <com/sun/star/frame/XToolbarController.hpp>
@@ -28,6 +27,7 @@
#include <framework/sfxhelperfunctions.hxx> #include <framework/sfxhelperfunctions.hxx>
#include <svtools/generictoolboxcontroller.hxx> #include <svtools/generictoolboxcontroller.hxx>
#include <svtools/commandinfoprovider.hxx>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <toolkit/helper/vclunohelper.hxx> #include <toolkit/helper/vclunohelper.hxx>
@@ -120,13 +120,13 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController(
if (xUpdatable.is()) if (xUpdatable.is())
xUpdatable->update(); xUpdatable->update();
// Add label. // Add tooltip.
if (xController.is()) if (xController.is())
{ {
const OUString sLabel (sfx2::sidebar::CommandInfoProvider::Instance().GetLabelForCommand( const OUString sTooltip (svt::CommandInfoProvider::Instance().GetTooltipForCommand(
rsCommandName, rsCommandName,
rxFrame)); rxFrame));
pToolBox->SetQuickHelpText(nItemId, sLabel); pToolBox->SetQuickHelpText(nItemId, sTooltip);
pToolBox->EnableItem(nItemId); pToolBox->EnableItem(nItemId);
} }
} }

View File

@@ -23,7 +23,7 @@
#include <sfx2/imagemgr.hxx> #include <sfx2/imagemgr.hxx>
#include <sfx2/bindings.hxx> #include <sfx2/bindings.hxx>
#include <unotools/cmdoptions.hxx> #include <unotools/cmdoptions.hxx>
#include <sfx2/sidebar/CommandInfoProvider.hxx> #include <svtools/commandinfoprovider.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <vcl/toolbox.hxx> #include <vcl/toolbox.hxx>
#include <vcl/help.hxx> #include <vcl/help.hxx>
@@ -179,13 +179,6 @@ void ControllerItem::ResetFrame()
mxFrame = nullptr; mxFrame = nullptr;
} }
::rtl::OUString ControllerItem::GetLabel() const
{
return CommandInfoProvider::Instance().GetLabelForCommand(
".uno:" + msCommandName,
mxFrame);
}
::rtl::OUString ControllerItem::GetHelpText() const ::rtl::OUString ControllerItem::GetHelpText() const
{ {
Help* pHelp = Application::GetHelp(); Help* pHelp = Application::GetHelp();
@@ -211,7 +204,7 @@ ControllerItem::ItemUpdateReceiverInterface::~ItemUpdateReceiverInterface()
void ControllerItem::SetupToolBoxItem (ToolBox& rToolBox, const sal_uInt16 nIndex) void ControllerItem::SetupToolBoxItem (ToolBox& rToolBox, const sal_uInt16 nIndex)
{ {
rToolBox.SetQuickHelpText(nIndex, GetLabel()); rToolBox.SetQuickHelpText(nIndex,svt::CommandInfoProvider::Instance().GetTooltipForCommand(".uno:" + msCommandName, mxFrame));
rToolBox.SetHelpText(nIndex, GetHelpText()); rToolBox.SetHelpText(nIndex, GetHelpText());
rToolBox.SetItemImage(nIndex, GetIcon()); rToolBox.SetItemImage(nIndex, GetIcon());
} }

View File

@@ -172,6 +172,7 @@ $(eval $(call gb_Library_add_exception_objects,svt,\
svtools/source/misc/acceleratorexecute \ svtools/source/misc/acceleratorexecute \
svtools/source/misc/bindablecontrolhelper \ svtools/source/misc/bindablecontrolhelper \
svtools/source/misc/cliplistener \ svtools/source/misc/cliplistener \
svtools/source/misc/commandinfoprovider \
svtools/source/misc/dialogclosedlistener \ svtools/source/misc/dialogclosedlistener \
svtools/source/misc/dialogcontrolling \ svtools/source/misc/dialogcontrolling \
svtools/source/misc/ehdl \ svtools/source/misc/ehdl \

View File

@@ -17,10 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <sfx2/sidebar/CommandInfoProvider.hxx> #include <svtools/commandinfoprovider.hxx>
#include <comphelper/processfactory.hxx>
#include <svtools/acceleratorexecute.hxx> #include <svtools/acceleratorexecute.hxx>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/compbase.hxx> #include <cppuhelper/compbase.hxx>
#include <cppuhelper/basemutex.hxx> #include <cppuhelper/basemutex.hxx>
@@ -32,7 +31,6 @@
using namespace css; using namespace css;
using namespace css::uno; using namespace css::uno;
using ::rtl::OUString;
namespace namespace
@@ -45,7 +43,7 @@ namespace
public FrameListenerInterfaceBase public FrameListenerInterfaceBase
{ {
public: public:
FrameListener (sfx2::sidebar::CommandInfoProvider& rInfoProvider, const Reference<frame::XFrame>& rxFrame) FrameListener (svt::CommandInfoProvider& rInfoProvider, const Reference<frame::XFrame>& rxFrame)
: FrameListenerInterfaceBase(m_aMutex), : FrameListenerInterfaceBase(m_aMutex),
mrInfoProvider(rInfoProvider), mrInfoProvider(rInfoProvider),
mxFrame(rxFrame) mxFrame(rxFrame)
@@ -70,12 +68,12 @@ namespace
} }
private: private:
sfx2::sidebar::CommandInfoProvider& mrInfoProvider; svt::CommandInfoProvider& mrInfoProvider;
Reference<frame::XFrame> mxFrame; Reference<frame::XFrame> mxFrame;
}; };
} }
namespace sfx2 { namespace sidebar { namespace svt {
CommandInfoProvider& CommandInfoProvider::Instance() CommandInfoProvider& CommandInfoProvider::Instance()
{ {
@@ -110,12 +108,48 @@ OUString CommandInfoProvider::GetLabelForCommand (
{ {
SetFrame(rxFrame); SetFrame(rxFrame);
const OUString sLabel (GetCommandLabel(rsCommandName)); return GetCommandProperty("Name", rsCommandName);
const OUString sShortCut (GetCommandShortcut(rsCommandName)); }
if (sShortCut.getLength() > 0)
return sLabel + " (" + sShortCut + ")"; OUString CommandInfoProvider::GetTooltipForCommand (
else const OUString& rsCommandName,
return sLabel; const Reference<frame::XFrame>& rxFrame,
bool bIncludeShortcut)
{
SetFrame(rxFrame);
OUString sLabel (GetCommandProperty("TooltipLabel", rsCommandName));
if (sLabel.isEmpty())
sLabel = GetLabelForCommand(rsCommandName, rxFrame);
if (bIncludeShortcut) {
const OUString sShortCut(GetCommandShortcut(rsCommandName, rxFrame));
if (!sShortCut.isEmpty())
return sLabel + " (" + sShortCut + ")";
}
return sLabel;
}
OUString CommandInfoProvider::GetCommandShortcut (const OUString& rsCommandName,
const Reference<frame::XFrame>& rxFrame)
{
SetFrame(rxFrame);
OUString sShortcut;
sShortcut = RetrieveShortcutsFromConfiguration(GetDocumentAcceleratorConfiguration(), rsCommandName);
if (sShortcut.getLength() > 0)
return sShortcut;
sShortcut = RetrieveShortcutsFromConfiguration(GetModuleAcceleratorConfiguration(), rsCommandName);
if (sShortcut.getLength() > 0)
return sShortcut;
sShortcut = RetrieveShortcutsFromConfiguration(GetGlobalAcceleratorConfiguration(), rsCommandName);
if (sShortcut.getLength() > 0)
return sShortcut;
return OUString();
} }
void CommandInfoProvider::SetFrame (const Reference<frame::XFrame>& rxFrame) void CommandInfoProvider::SetFrame (const Reference<frame::XFrame>& rxFrame)
@@ -214,25 +248,6 @@ OUString CommandInfoProvider::GetModuleIdentifier()
return msCachedModuleIdentifier; return msCachedModuleIdentifier;
} }
OUString CommandInfoProvider::GetCommandShortcut (const OUString& rsCommandName)
{
OUString sShortcut;
sShortcut = RetrieveShortcutsFromConfiguration(GetDocumentAcceleratorConfiguration(), rsCommandName);
if (sShortcut.getLength() > 0)
return sShortcut;
sShortcut = RetrieveShortcutsFromConfiguration(GetModuleAcceleratorConfiguration(), rsCommandName);
if (sShortcut.getLength() > 0)
return sShortcut;
sShortcut = RetrieveShortcutsFromConfiguration(GetGlobalAcceleratorConfiguration(), rsCommandName);
if (sShortcut.getLength() > 0)
return sShortcut;
return OUString();
}
OUString CommandInfoProvider::RetrieveShortcutsFromConfiguration( OUString CommandInfoProvider::RetrieveShortcutsFromConfiguration(
const Reference<ui::XAcceleratorConfiguration>& rxConfiguration, const Reference<ui::XAcceleratorConfiguration>& rxConfiguration,
const OUString& rsCommandName) const OUString& rsCommandName)
@@ -260,7 +275,7 @@ OUString CommandInfoProvider::RetrieveShortcutsFromConfiguration(
return OUString(); return OUString();
} }
Sequence<beans::PropertyValue> CommandInfoProvider::GetCommandProperties (const OUString& rsCommandName) Sequence<beans::PropertyValue> CommandInfoProvider::GetCommandProperties(const OUString& rsCommandName)
{ {
Sequence<beans::PropertyValue> aProperties; Sequence<beans::PropertyValue> aProperties;
@@ -282,12 +297,12 @@ Sequence<beans::PropertyValue> CommandInfoProvider::GetCommandProperties (const
return aProperties; return aProperties;
} }
OUString CommandInfoProvider::GetCommandLabel (const OUString& rsCommandName) OUString CommandInfoProvider::GetCommandProperty(const OUString& rsProperty, const OUString& rsCommandName)
{ {
const Sequence<beans::PropertyValue> aProperties (GetCommandProperties(rsCommandName)); const Sequence<beans::PropertyValue> aProperties (GetCommandProperties(rsCommandName));
for (sal_Int32 nIndex=0; nIndex<aProperties.getLength(); ++nIndex) for (sal_Int32 nIndex=0; nIndex<aProperties.getLength(); ++nIndex)
{ {
if (aProperties[nIndex].Name == "Name") if (aProperties[nIndex].Name == rsProperty)
{ {
OUString sLabel; OUString sLabel;
aProperties[nIndex].Value >>= sLabel; aProperties[nIndex].Value >>= sLabel;
@@ -297,6 +312,6 @@ OUString CommandInfoProvider::GetCommandLabel (const OUString& rsCommandName)
return OUString(); return OUString();
} }
} } // end of namespace sfx2/framework } // end of namespace svt
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -17,7 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include "InsertPropertyPanel.hxx" #include "InsertPropertyPanel.hxx"
#include "sfx2/sidebar/CommandInfoProvider.hxx"
#include <sfx2/sidebar/Theme.hxx> #include <sfx2/sidebar/Theme.hxx>
#include <sfx2/sidebar/Tools.hxx> #include <sfx2/sidebar/Tools.hxx>