tdf#95844 Refactor CommandInfoProvider

Instead of a singleton, CommandInfoProvider should just be a set of static methods.

Change-Id: I16d4406e361a72f013d78f18d6bd0ae20c0cc5e9
This commit is contained in:
Rohan Kumar 2017-01-24 21:18:00 +05:30 committed by Maxim Monastirsky
parent e25bf8505c
commit 33c51e8002
31 changed files with 151 additions and 288 deletions

View File

@ -197,7 +197,7 @@ OAppDetailPageHelper::OAppDetailPageHelper(vcl::Window* _pParent,OAppBorderWindo
m_aTBPreview->SetOutStyle(TOOLBOX_STYLE_FLAT);
m_aTBPreview->InsertItem(SID_DB_APP_DISABLE_PREVIEW,
vcl::CommandInfoProvider::Instance().GetCommandPropertyFromModule(".uno:DBDisablePreview", "com.sun.star.sdb.OfficeDatabaseDocument"),
vcl::CommandInfoProvider::GetCommandPropertyFromModule(".uno:DBDisablePreview", "com.sun.star.sdb.OfficeDatabaseDocument"),
ToolBoxItemBits::LEFT|ToolBoxItemBits::DROPDOWN|ToolBoxItemBits::AUTOSIZE|ToolBoxItemBits::RADIOCHECK);
m_aTBPreview->SetHelpId(HID_APP_VIEW_PREVIEW_CB);
m_aTBPreview->SetDropdownClickHdl( LINK( this, OAppDetailPageHelper, OnDropdownClickHdl ) );
@ -995,7 +995,7 @@ void OAppDetailPageHelper::switchPreview(PreviewMode _eMode,bool _bForce)
break;
}
OUString aCommandLabel = vcl::CommandInfoProvider::Instance().GetCommandPropertyFromModule(aCommand, "com.sun.star.sdb.OfficeDatabaseDocument");
OUString aCommandLabel = vcl::CommandInfoProvider::GetCommandPropertyFromModule(aCommand, "com.sun.star.sdb.OfficeDatabaseDocument");
m_aTBPreview->SetItemText(SID_DB_APP_DISABLE_PREVIEW, stripTrailingDots(aCommandLabel));
Resize();

View File

@ -118,7 +118,7 @@ namespace dbaui
m_sModule = OUString::createFromAscii( _pAsciiModuleName );
// our label should equal the UI text of the "Open" command
OUString sLabel(vcl::CommandInfoProvider::Instance().GetCommandPropertyFromModule(".uno:Open", m_sModule));
OUString sLabel(vcl::CommandInfoProvider::GetCommandPropertyFromModule(".uno:Open", m_sModule));
SetText(" " + sLabel.replaceAll("~", ""));
// Place icon left of text and both centered in the button.

View File

@ -287,7 +287,7 @@ namespace frm
OUString sCommandURL( lcl_getCommandURL( pSupportedFeatures->nId ) );
m_pToolbar->SetItemCommand( pSupportedFeatures->nId, sCommandURL );
m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId,
vcl::CommandInfoProvider::Instance().GetCommandPropertyFromModule(sCommandURL, m_sModuleId) );
vcl::CommandInfoProvider::GetCommandPropertyFromModule(sCommandURL, m_sModuleId) );
}
if ( pSupportedFeatures->bItemWindow )

View File

@ -122,14 +122,14 @@ static Image RetrieveImage( Reference< css::frame::XFrame >& rFrame,
if ( !!aImage )
return aImage;
else
aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aImageId, rFrame, eImageType);
aImage = vcl::CommandInfoProvider::GetImageForCommand(aImageId, rFrame, eImageType);
if ( !!aImage )
return aImage;
}
aImage = framework::AddonsOptions().GetImageFromURL( aURL, bBigImage );
if ( !aImage )
aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aImageId, rFrame, eImageType);
aImage = vcl::CommandInfoProvider::GetImageForCommand(aImageId, rFrame, eImageType);
return aImage;
}
@ -259,7 +259,7 @@ void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue
m_pToolBar->InsertItem( nId, aTitle );
OUString aShortcut(vcl::CommandInfoProvider::Instance().GetCommandShortcut(aURL, m_xFrame));
OUString aShortcut(vcl::CommandInfoProvider::GetCommandShortcut(aURL, m_xFrame));
if (!aShortcut.isEmpty())
m_pToolBar->SetQuickHelpText(nId, aTitle + " (" + aShortcut + ")");

View File

@ -83,7 +83,7 @@ void MacrosMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPo
// insert basic
OUString aCommand(".uno:MacroDialog");
OUString aDisplayName = vcl::CommandInfoProvider::Instance().GetMenuLabelForCommand(aCommand, m_xFrame);
OUString aDisplayName = vcl::CommandInfoProvider::GetMenuLabelForCommand(aCommand, m_xFrame);
pPopupMenu->InsertItem( 2, aDisplayName );
pPopupMenu->SetItemCommand( 2, aCommand );

View File

@ -1085,9 +1085,9 @@ OUString MenuBarManager::RetrieveLabelFromCommand(const OUString& rCmdURL)
if ( !m_bHasMenuBar )
{
// This is a context menu, prefer "PopupLabel" over "Label".
return vcl::CommandInfoProvider::Instance().GetPopupLabelForCommand(rCmdURL, m_xFrame);
return vcl::CommandInfoProvider::GetPopupLabelForCommand(rCmdURL, m_xFrame);
}
return vcl::CommandInfoProvider::Instance().GetMenuLabelForCommand(rCmdURL, m_xFrame);
return vcl::CommandInfoProvider::GetMenuLabelForCommand(rCmdURL, m_xFrame);
}
bool MenuBarManager::CreatePopupMenuController( MenuItemHandler* pMenuItemHandler )
@ -1183,7 +1183,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF
}
// Command can be just an alias to another command.
OUString aRealCommand = vcl::CommandInfoProvider::Instance().GetRealCommandForCommand( aItemCommand, m_xFrame );
OUString aRealCommand = vcl::CommandInfoProvider::GetRealCommandForCommand( aItemCommand, m_xFrame );
if ( !aRealCommand.isEmpty() )
aItemCommand = aRealCommand;
@ -1289,7 +1289,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF
// Set image for the addon popup menu item
if ( bItemShowMenuImages && !pPopup->GetItemImage( ITEMID_ADDONLIST ))
{
Image aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aItemCommand, rFrame);
Image aImage = vcl::CommandInfoProvider::GetImageForCommand(aItemCommand, rFrame);
if ( !!aImage )
pPopup->SetItemImage( ITEMID_ADDONLIST, aImage );
}
@ -1320,12 +1320,12 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF
if ( pMenuAttributes && !pMenuAttributes->aImageId.isEmpty() )
{
// Retrieve image id from menu attributes
aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aImageId, m_xFrame);
aImage = vcl::CommandInfoProvider::GetImageForCommand(aImageId, m_xFrame);
}
if ( !aImage )
{
aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aItemCommand, m_xFrame);
aImage = vcl::CommandInfoProvider::GetImageForCommand(aItemCommand, m_xFrame);
if ( !aImage )
aImage = AddonsOptions().GetImageFromURL( aItemCommand, false );
}
@ -1648,7 +1648,7 @@ void MenuBarManager::FillMenu(
aProp[i].Value >>= bEnabled;
}
if (vcl::CommandInfoProvider::Instance().IsExperimental(aCommandURL, rModuleIdentifier) &&
if (vcl::CommandInfoProvider::IsExperimental(aCommandURL, rModuleIdentifier) &&
!SvtMiscOptions().IsExperimentalMode())
{
continue;
@ -2086,7 +2086,7 @@ void MenuBarManager::FillMenuImages(Reference< XFrame >& _xFrame, Menu* _pMenu,b
if ( !aImageId.isEmpty() )
{
Image aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aImageId, _xFrame);
Image aImage = vcl::CommandInfoProvider::GetImageForCommand(aImageId, _xFrame);
if ( !!aImage )
{
bImageSet = true;
@ -2097,7 +2097,7 @@ void MenuBarManager::FillMenuImages(Reference< XFrame >& _xFrame, Menu* _pMenu,b
if ( !bImageSet )
{
OUString aMenuItemCommand = _pMenu->GetItemCommand( nId );
Image aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aMenuItemCommand, _xFrame);
Image aImage = vcl::CommandInfoProvider::GetImageForCommand(aMenuItemCommand, _xFrame);
if ( !aImage )
aImage = aAddonOptions.GetImageFromURL( aMenuItemCommand, false );

View File

@ -91,7 +91,7 @@ void NewMenuController::setMenuImages( PopupMenu* pPopupMenu, bool bSetImages )
INetURLObject aURLObj( aImageId.isEmpty() ? aCmd : aImageId );
Image aImage = SvFileInformationManager::GetImageNoDefault( aURLObj );
if ( !aImage )
aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aCmd, xFrame);
aImage = vcl::CommandInfoProvider::GetImageForCommand(aCmd, xFrame);
if ( !!aImage )
pPopupMenu->SetItemImage( nItemId, aImage );

View File

@ -370,7 +370,7 @@ void GenericPopupToolbarController::functionExecuted( const OUString& rCommand )
{
removeStatusListener( m_aCommandURL );
OUString aRealCommand( vcl::CommandInfoProvider::Instance().GetRealCommandForCommand( rCommand, m_xFrame ) );
OUString aRealCommand( vcl::CommandInfoProvider::GetRealCommandForCommand( rCommand, m_xFrame ) );
m_aCommandURL = aRealCommand.isEmpty() ? rCommand : aRealCommand;
addStatusListener( m_aCommandURL );
@ -380,12 +380,12 @@ void GenericPopupToolbarController::functionExecuted( const OUString& rCommand )
{
pToolBox->SetItemCommand( nId, rCommand );
pToolBox->SetHelpText( nId, OUString() ); // Will retrieve the new one from help.
pToolBox->SetItemText( nId, vcl::CommandInfoProvider::Instance().GetLabelForCommand( rCommand, m_xFrame ) );
pToolBox->SetQuickHelpText( nId, vcl::CommandInfoProvider::Instance().GetTooltipForCommand( rCommand, m_xFrame ) );
pToolBox->SetItemText( nId, vcl::CommandInfoProvider::GetLabelForCommand( rCommand, m_xFrame ) );
pToolBox->SetQuickHelpText( nId, vcl::CommandInfoProvider::GetTooltipForCommand( rCommand, m_xFrame ) );
vcl::ImageType eImageType = getImageType(pToolBox->GetToolboxButtonSize());
Image aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(rCommand, m_xFrame, eImageType);
Image aImage = vcl::CommandInfoProvider::GetImageForCommand(rCommand, m_xFrame, eImageType);
if ( !!aImage )
pToolBox->SetItemImage( nId, aImage );
}
@ -503,7 +503,7 @@ void SaveToolbarController::updateImage()
if ( m_bReadOnly )
{
aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(".uno:SaveAs", m_xFrame, eImageType);
aImage = vcl::CommandInfoProvider::GetImageForCommand(".uno:SaveAs", m_xFrame, eImageType);
}
else if ( m_bModified )
{
@ -512,7 +512,7 @@ void SaveToolbarController::updateImage()
}
if ( !aImage )
aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(m_aCommandURL, m_xFrame, eImageType);
aImage = vcl::CommandInfoProvider::GetImageForCommand(m_aCommandURL, m_xFrame, eImageType);
if ( !!aImage )
pToolBox->SetItemImage( nId, aImage );
@ -530,7 +530,7 @@ void SaveToolbarController::statusChanged( const css::frame::FeatureStateEvent&
if ( bLastReadOnly != m_bReadOnly )
{
pToolBox->SetQuickHelpText( nId,
vcl::CommandInfoProvider::Instance().GetTooltipForCommand( m_bReadOnly ? OUString( ".uno:SaveAs" ) : m_aCommandURL, m_xFrame ) );
vcl::CommandInfoProvider::GetTooltipForCommand( m_bReadOnly ? OUString( ".uno:SaveAs" ) : m_aCommandURL, m_xFrame ) );
pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) & ~( m_bReadOnly ? ToolBoxItemBits::DROPDOWN : ToolBoxItemBits::DROPDOWNONLY ) );
pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ( m_bReadOnly ? ToolBoxItemBits::DROPDOWNONLY : ToolBoxItemBits::DROPDOWN ) );
updateImage();

View File

@ -450,7 +450,7 @@ void StatusBarManager::FillStatusBar( const uno::Reference< container::XIndexAcc
if (( nType == css::ui::ItemType::DEFAULT ) && !aCommandURL.isEmpty() )
{
OUString aString( vcl::CommandInfoProvider::Instance().GetLabelForCommand(aCommandURL, m_xFrame));
OUString aString( vcl::CommandInfoProvider::GetLabelForCommand(aCommandURL, m_xFrame));
StatusBarItemBits nItemBits( impl_convertItemStyleToItemBits( nStyle ));
m_pStatusBar->InsertItem( nId, nWidth, nItemBits, nOffset );

View File

@ -291,7 +291,7 @@ void SubToolBarController::updateImage()
else if (pToolBox->GetToolboxButtonSize() == ToolBoxButtonSize::Size32)
eImageType = vcl::ImageType::Size32;
Image aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(m_aLastCommand, getFrameInterface(), eImageType);
Image aImage = vcl::CommandInfoProvider::GetImageForCommand(m_aLastCommand, getFrameInterface(), eImageType);
if ( !!aImage )
pToolBox->SetItemImage( nId, aImage );
}

View File

@ -99,7 +99,7 @@ void ThesaurusMenuController::fillPopupMenu()
pVCLMenu->InsertSeparator();
OUString aThesaurusDialogCmd( ".uno:ThesaurusDialog" );
pVCLMenu->InsertItem( nId, vcl::CommandInfoProvider::Instance().GetPopupLabelForCommand( aThesaurusDialogCmd, m_xFrame ) );
pVCLMenu->InsertItem( nId, vcl::CommandInfoProvider::GetPopupLabelForCommand( aThesaurusDialogCmd, m_xFrame ) );
pVCLMenu->SetItemCommand( nId, aThesaurusDialogCmd );
}
}

View File

@ -315,7 +315,7 @@ void ToolBarManager::RefreshImages()
else
{
OUString aCommandURL = m_pToolBar->GetItemCommand( it.first );
Image aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aCommandURL, m_xFrame, eImageType);
Image aImage = vcl::CommandInfoProvider::GetImageForCommand(aCommandURL, m_xFrame, eImageType);
// Try also to query for add-on images before giving up and use an
// empty image.
bool bBigImages = eImageType != vcl::ImageType::Size16;
@ -684,7 +684,7 @@ void ToolBarManager::CreateControllers()
OUString aCommandURL( m_pToolBar->GetItemCommand( nId ) );
// Command can be just an alias to another command.
OUString aRealCommandURL( vcl::CommandInfoProvider::Instance().GetRealCommandForCommand( aCommandURL, m_xFrame ) );
OUString aRealCommandURL( vcl::CommandInfoProvider::GetRealCommandForCommand( aCommandURL, m_xFrame ) );
if ( !aRealCommandURL.isEmpty() )
aCommandURL = aRealCommandURL;
@ -764,7 +764,7 @@ void ToolBarManager::CreateControllers()
new GenericToolbarController( m_xContext, m_xFrame, m_pToolBar, nId, aCommandURL ));
// Accessibility support: Set toggle button role for specific commands
sal_Int32 nProps = vcl::CommandInfoProvider::Instance().GetPropertiesForCommand(aCommandURL, m_xFrame);
sal_Int32 nProps = vcl::CommandInfoProvider::GetPropertiesForCommand(aCommandURL, m_xFrame);
if ( nProps & UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON )
m_pToolBar->SetItemBits( nId, m_pToolBar->GetItemBits( nId ) | ToolBoxItemBits::CHECKABLE );
}
@ -1013,7 +1013,7 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
aProp[i].Value >>= nStyle;
}
if (vcl::CommandInfoProvider::Instance().IsExperimental(aCommandURL, m_aModuleIdentifier) &&
if (vcl::CommandInfoProvider::IsExperimental(aCommandURL, m_aModuleIdentifier) &&
!SvtMiscOptions().IsExperimentalMode())
{
continue;
@ -1021,7 +1021,7 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
if (( nType == css::ui::ItemType::DEFAULT ) && !aCommandURL.isEmpty() )
{
OUString aString(vcl::CommandInfoProvider::Instance().GetLabelForCommand(aCommandURL, m_xFrame));
OUString aString(vcl::CommandInfoProvider::GetLabelForCommand(aCommandURL, m_xFrame));
ToolBoxItemBits nItemBits = ConvertStyleToToolboxItemBits( nStyle );
m_pToolBar->InsertItem( nId, aString, nItemBits );
@ -1029,7 +1029,7 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
if ( !aTooltip.isEmpty() )
m_pToolBar->SetQuickHelpText( nId, aTooltip );
else
m_pToolBar->SetQuickHelpText( nId, vcl::CommandInfoProvider::Instance().GetTooltipForCommand(aCommandURL, m_xFrame) );
m_pToolBar->SetQuickHelpText( nId, vcl::CommandInfoProvider::GetTooltipForCommand(aCommandURL, m_xFrame) );
if ( !aLabel.isEmpty() )
{
@ -1468,7 +1468,7 @@ void ToolBarManager::AddCustomizeMenuItems(ToolBox* pToolBar)
pVisibleItemsPopupMenu->InsertItem( STARTID_CUSTOMIZE_POPUPMENU+nPos, m_pToolBar->GetItemText( nId ), MenuItemBits::CHECKABLE );
pVisibleItemsPopupMenu->CheckItem( STARTID_CUSTOMIZE_POPUPMENU+nPos, m_pToolBar->IsItemVisible( nId ) );
pVisibleItemsPopupMenu->SetItemCommand( STARTID_CUSTOMIZE_POPUPMENU+nPos, aCommandURL );
Image aImage(vcl::CommandInfoProvider::Instance().GetImageForCommand(aCommandURL, m_xFrame));
Image aImage(vcl::CommandInfoProvider::GetImageForCommand(aCommandURL, m_xFrame));
commandToImage[aCommandURL] = aImage;
pVisibleItemsPopupMenu->SetItemImage( STARTID_CUSTOMIZE_POPUPMENU+nPos, aImage );
}

View File

@ -147,7 +147,7 @@ void ToolbarsMenuController::addCommand(
OUString aLabel;
if ( rLabel.isEmpty() )
aLabel = vcl::CommandInfoProvider::Instance().GetMenuLabelForCommand( rCommandURL, m_xFrame );
aLabel = vcl::CommandInfoProvider::GetMenuLabelForCommand( rCommandURL, m_xFrame );
else
aLabel = rLabel;
@ -167,7 +167,7 @@ void ToolbarsMenuController::addCommand(
const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
if ( rSettings.GetUseImagesInMenus() )
aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(rCommandURL, m_xFrame);
aImage = vcl::CommandInfoProvider::GetImageForCommand(rCommandURL, m_xFrame);
VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(VCLXPopupMenu::GetImplementation( rPopupMenu ));
if ( pPopupMenu )

View File

@ -27,6 +27,9 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
using namespace css;
using namespace css::uno;
namespace vcl {
@ -36,16 +39,8 @@ namespace vcl {
class VCL_DLLPUBLIC CommandInfoProvider
{
public:
/** Return the singleton instance.
It caches some objects for the last XFrame object given to
GetLabelForCommand. These objects are release and created new
when that method is called with a different XFrame from the
last call.
Lifetime control should work but could be more elegant.
*/
static CommandInfoProvider& Instance();
CommandInfoProvider();
~CommandInfoProvider();
/** Return a label for the given command.
@param rsCommandName
@ -55,15 +50,15 @@ public:
@return
The command labe.
*/
OUString GetLabelForCommand (
static OUString GetLabelForCommand (
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame);
OUString GetMenuLabelForCommand (
static OUString GetMenuLabelForCommand (
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame);
OUString GetPopupLabelForCommand (
static OUString GetPopupLabelForCommand (
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame);
@ -76,67 +71,54 @@ public:
The returned label contains the keyboard accelerator, if
one is defined and bIncludeShortcut is true.
*/
OUString GetTooltipForCommand (
static OUString GetTooltipForCommand (
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame);
/** Returns the shortcut for a command in human-readable form */
OUString GetCommandShortcut (const OUString& rCommandName,
static OUString GetCommandShortcut (const OUString& rCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame);
OUString GetRealCommandForCommand( const OUString& rCommandName,
static OUString GetRealCommandForCommand( const OUString& rCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame );
OUString GetCommandPropertyFromModule( const OUString& rCommandName, const OUString& rModuleName );
static OUString GetCommandPropertyFromModule( const OUString& rCommandName, const OUString& rModuleName );
BitmapEx GetBitmapForCommand(
static BitmapEx GetBitmapForCommand(
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame,
vcl::ImageType eImageType = vcl::ImageType::Small);
Image GetImageForCommand(
static Image GetImageForCommand(
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame,
vcl::ImageType eImageType = vcl::ImageType::Small);
sal_Int32 GetPropertiesForCommand(
static sal_Int32 GetPropertiesForCommand(
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame);
bool IsRotated(const OUString& rsCommandName);
bool IsMirrored(const OUString& rsCommandName);
static bool IsRotated(const OUString& rsCommandName,const Reference<frame::XFrame>& rxFrame);
static bool IsMirrored(const OUString& rsCommandName, const Reference<frame::XFrame>& rxFrame);
/** Returns whether the command is experimental. */
bool IsExperimental(
static bool IsExperimental(
const OUString& rsCommandName,
const OUString& rModuleName);
/** Do not call. Should be part of a local and hidden interface.
*/
void SetFrame (const css::uno::Reference<css::frame::XFrame>& rxFrame);
void dispose();
static void SetFrame (const css::uno::Reference<css::frame::XFrame>& rxFrame);
private:
css::uno::Reference<css::uno::XComponentContext> mxContext;
css::uno::Reference<css::frame::XFrame> mxCachedDataFrame;
css::uno::Reference<css::ui::XAcceleratorConfiguration> mxCachedDocumentAcceleratorConfiguration;
css::uno::Reference<css::ui::XAcceleratorConfiguration> mxCachedModuleAcceleratorConfiguration;
css::uno::Reference<css::ui::XAcceleratorConfiguration> mxCachedGlobalAcceleratorConfiguration;
OUString msCachedModuleIdentifier;
css::uno::Reference<css::lang::XComponent> mxFrameListener;
CommandInfoProvider();
~CommandInfoProvider();
css::uno::Reference<css::ui::XAcceleratorConfiguration> const & GetDocumentAcceleratorConfiguration();
css::uno::Reference<css::ui::XAcceleratorConfiguration> const & GetModuleAcceleratorConfiguration();
css::uno::Reference<css::ui::XAcceleratorConfiguration> const & GetGlobalAcceleratorConfiguration();
OUString const & GetModuleIdentifier();
css::uno::Sequence<css::beans::PropertyValue> GetCommandProperties (
const OUString& rsCommandName);
OUString GetCommandProperty(const OUString& rsProperty, const OUString& rsCommandName);
bool ResourceHasKey(const OUString& rsResourceName, const OUString& rsCommandName);
static css::uno::Reference<css::ui::XAcceleratorConfiguration> const GetDocumentAcceleratorConfiguration(const Reference<frame::XFrame>& rxFrame);
static css::uno::Reference<css::ui::XAcceleratorConfiguration> const GetModuleAcceleratorConfiguration(const Reference<frame::XFrame>& rxFrame);
static css::uno::Reference<css::ui::XAcceleratorConfiguration> const GetGlobalAcceleratorConfiguration();
static OUString const GetModuleIdentifier(const Reference<frame::XFrame>& rxFrame);
static css::uno::Sequence<css::beans::PropertyValue> GetCommandProperties (
const OUString& rsCommandName, const Reference<frame::XFrame>& rxFrame);
static OUString GetCommandProperty(const OUString& rsProperty, const OUString& rsCommandName,const Reference<frame::XFrame>& rxFrame);
static bool ResourceHasKey(const OUString& rsResourceName, const OUString& rsCommandName, const Reference<frame::XFrame>& rxFrame);
static OUString RetrieveShortcutsFromConfiguration(
const css::uno::Reference<css::ui::XAcceleratorConfiguration>& rxConfiguration,
const OUString& rsCommandName);

View File

@ -32,12 +32,15 @@ private:
/** Dispatcher. Need to keep a reference to it as long as this StatusListener exists. */
css::uno::Reference<css::frame::XDispatch> mxDispatch;
css::util::URL maCommandURL;
css::uno::Reference<css::frame::XFrame> mxFrame;
public:
void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& rEvent) override;
void SAL_CALL disposing(const css::lang::EventObject& /*Source*/) override;
const css::uno::Reference<css::frame::XFrame>& getFrame() { return mxFrame; }
void dispose();
};
@ -52,6 +55,8 @@ VclStatusListener<T>::VclStatusListener(T* widget, const rtl::OUString& aCommand
if (!xFrame.is())
xFrame = css::uno::Reference<css::frame::XFrame>(xDesktop, css::uno::UNO_QUERY);
mxFrame = xFrame;
css::uno::Reference<css::frame::XDispatchProvider> xDispatchProvider(xFrame, css::uno::UNO_QUERY);
if (!xDispatchProvider.is())
return;
@ -86,6 +91,7 @@ void VclStatusListener<T>::dispose()
mxDispatch->removeStatusListener(this, maCommandURL);
mxDispatch.clear();
}
mxFrame.clear();
mWidget.clear();
}

View File

@ -241,11 +241,11 @@ LayoutToolbarMenu::LayoutToolbarMenu( SlideLayoutController& rController, vcl::W
sSlotStr = ".uno:DuplicatePage";
else
sSlotStr = ".uno:Undo";
aSlotImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(sSlotStr, xFrame);
aSlotImage = vcl::CommandInfoProvider::GetImageForCommand(sSlotStr, xFrame);
OUString sSlotTitle;
if( bInsertPage )
sSlotTitle = vcl::CommandInfoProvider::Instance().GetLabelForCommand( sSlotStr, xFrame );
sSlotTitle = vcl::CommandInfoProvider::GetLabelForCommand( sSlotStr, xFrame );
else
sSlotTitle = SD_RESSTR( STR_RESET_LAYOUT );
appendEntry( 2, sSlotTitle, aSlotImage);

View File

@ -976,7 +976,7 @@ vcl::Window* ViewShellBase::GetViewWindow()
OUString ViewShellBase::RetrieveLabelFromCommand( const OUString& aCmdURL ) const
{
Reference< XFrame > xFrame( GetMainViewShell()->GetViewFrame()->GetFrame().GetFrameInterface(), UNO_QUERY );
return vcl::CommandInfoProvider::Instance().GetLabelForCommand( aCmdURL, xFrame );
return vcl::CommandInfoProvider::GetLabelForCommand( aCmdURL, xFrame );
}
int ViewShellBase::getPart() const

View File

@ -446,7 +446,7 @@ SfxHelpWindow_Impl* impl_createHelp(Reference< XFrame2 >& rHelpTask ,
OUString SfxHelp::GetHelpText( const OUString& aCommandURL, const vcl::Window* pWindow )
{
OUString sModuleName = GetHelpModuleName_Impl();
OUString sRealCommand = vcl::CommandInfoProvider::Instance().GetRealCommandForCommand( aCommandURL, getCurrentFrame() );
OUString sRealCommand = vcl::CommandInfoProvider::GetRealCommandForCommand( aCommandURL, getCurrentFrame() );
OUString sHelpText = SfxHelp_Impl::GetHelpText( sRealCommand.isEmpty() ? aCommandURL : sRealCommand, sModuleName );
OString aNewHelpId;
@ -564,7 +564,7 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow, const
if ( nProtocol == INetProtocol::Uno )
// Command can be just an alias to another command.
aRealCommand = vcl::CommandInfoProvider::Instance().GetRealCommandForCommand( rURL, getCurrentFrame() );
aRealCommand = vcl::CommandInfoProvider::GetRealCommandForCommand( rURL, getCurrentFrame() );
// no URL, just a HelpID (maybe empty in case of keyword search)
aHelpURL = CreateHelpURL_Impl( aRealCommand.isEmpty() ? rURL : aRealCommand, aHelpModuleName );

View File

@ -125,7 +125,7 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController(
// Add tooltip.
if (xController.is())
{
const OUString sTooltip (vcl::CommandInfoProvider::Instance().GetTooltipForCommand(
const OUString sTooltip (vcl::CommandInfoProvider::GetTooltipForCommand(
rsCommandName,
rxFrame));
pToolBox->SetQuickHelpText(nItemId, sTooltip);

View File

@ -275,7 +275,7 @@ IMPL_LINK_NOARG(SidebarToolBox, ChangedIconSizeHandler, LinkParamNone*, void)
{
OUString aCommandURL = GetItemCommand(it.first);
css::uno::Reference<frame::XFrame> xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
Image aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aCommandURL, xFrame, eImageType);
Image aImage = vcl::CommandInfoProvider::GetImageForCommand(aCommandURL, xFrame, eImageType);
SetItemImage(it.first, aImage);
}
}

View File

@ -718,7 +718,7 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet )
uno::Reference < frame::XFrame > xFrame( pFrame->GetFrame().GetFrameInterface() );
OUStringBuffer aBuffer( 60 );
aBuffer.append( vcl::CommandInfoProvider::Instance().GetLabelForCommand(
aBuffer.append( vcl::CommandInfoProvider::GetLabelForCommand(
".uno:PrintDefault",
xFrame ));
aBuffer.append( " (" );

View File

@ -180,7 +180,7 @@ void SmartTagMenuController::FillMenu()
{
const OUString aCommand = ".uno:AutoCorrectDlg?OpenSmartTag:bool=true";
pVCLMenu->InsertSeparator();
pVCLMenu->InsertItem( nMenuId, vcl::CommandInfoProvider::Instance().GetPopupLabelForCommand( aCommand, m_xFrame ) );
pVCLMenu->InsertItem( nMenuId, vcl::CommandInfoProvider::GetPopupLabelForCommand( aCommand, m_xFrame ) );
pVCLMenu->SetItemCommand( nMenuId, aCommand );
}
}

View File

@ -132,7 +132,7 @@ void DefaultShapesPanel::populateShapes()
{
sSlotStr = aSet.second[i];
aSlotImage = ::GetImage(mxFrame, sSlotStr, false);
sLabel = vcl::CommandInfoProvider::Instance().GetTooltipForCommand(sSlotStr, mxFrame);
sLabel = vcl::CommandInfoProvider::GetTooltipForCommand(sSlotStr, mxFrame);
aSet.first->InsertItem(i, aSlotImage, sLabel);
}
}

View File

@ -1312,7 +1312,7 @@ SvxColorWindow::SvxColorWindow(const OUString& rCommand,
}
}
OUString aWindowTitle = vcl::CommandInfoProvider::Instance().GetLabelForCommand( rCommand, rFrame );
OUString aWindowTitle = vcl::CommandInfoProvider::GetLabelForCommand( rCommand, rFrame );
SetText( aWindowTitle );
mpColorSet->SetAccessibleName( aWindowTitle );

View File

@ -810,15 +810,15 @@ void SwFrameShell::GetState(SfxItemSet& rSet)
{
case SID_OBJECT_ALIGN_UP :
case FN_FRAME_ALIGN_VERT_TOP:
sNewLabel = vcl::CommandInfoProvider::Instance().GetLabelForCommand(".uno:AlignTop", GetFrame()->GetFrame().GetFrameInterface());
sNewLabel = vcl::CommandInfoProvider::GetLabelForCommand(".uno:AlignTop", GetFrame()->GetFrame().GetFrameInterface());
break;
case SID_OBJECT_ALIGN_MIDDLE:
case FN_FRAME_ALIGN_VERT_CENTER:
sNewLabel = vcl::CommandInfoProvider::Instance().GetLabelForCommand(".uno:AlignVerticalCenter", GetFrame()->GetFrame().GetFrameInterface());
sNewLabel = vcl::CommandInfoProvider::GetLabelForCommand(".uno:AlignVerticalCenter", GetFrame()->GetFrame().GetFrameInterface());
break;
case SID_OBJECT_ALIGN_DOWN:
case FN_FRAME_ALIGN_VERT_BOTTOM:
sNewLabel = vcl::CommandInfoProvider::Instance().GetLabelForCommand(".uno:AlignBottom", GetFrame()->GetFrame().GetFrameInterface());
sNewLabel = vcl::CommandInfoProvider::GetLabelForCommand(".uno:AlignBottom", GetFrame()->GetFrame().GetFrameInterface());
break;
}
}

View File

@ -526,7 +526,6 @@ void DeInitVCL()
if (pSVData->mpCommandInfoProvider)
{
pSVData->mpCommandInfoProvider->dispose();
pSVData->mpCommandInfoProvider = nullptr;
}

View File

@ -39,128 +39,49 @@ using namespace css;
using namespace css::uno;
namespace
{
typedef ::cppu::WeakComponentImplHelper <
css::frame::XFrameActionListener
> FrameListenerInterfaceBase;
class FrameListener
: public ::cppu::BaseMutex,
public FrameListenerInterfaceBase
{
public:
FrameListener (vcl::CommandInfoProvider& rInfoProvider, const Reference<frame::XFrame>& rxFrame)
: FrameListenerInterfaceBase(m_aMutex),
mrInfoProvider(rInfoProvider),
mxFrame(rxFrame)
{
if (mxFrame.is())
mxFrame->addFrameActionListener(this);
}
virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent& aEvent) override
{
// The same frame can be reused for a different component, e.g.
// starting component from the start center, so need to re-init the cached data.
if (aEvent.Action == css::frame::FrameAction_COMPONENT_DETACHING)
mrInfoProvider.SetFrame(nullptr);
}
virtual void SAL_CALL disposing() override
{
if (mxFrame.is())
mxFrame->removeFrameActionListener(this);
}
virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent) override
{
(void)rEvent;
mrInfoProvider.SetFrame(nullptr);
mxFrame = nullptr;
}
private:
vcl::CommandInfoProvider& mrInfoProvider;
Reference<frame::XFrame> mxFrame;
};
}
namespace vcl {
CommandInfoProvider& CommandInfoProvider::Instance()
{
static CommandInfoProvider aProvider;
return aProvider;
}
CommandInfoProvider::CommandInfoProvider()
: mxContext(comphelper::getProcessComponentContext()),
mxCachedDataFrame(),
mxCachedDocumentAcceleratorConfiguration(),
mxCachedModuleAcceleratorConfiguration(),
mxCachedGlobalAcceleratorConfiguration(),
msCachedModuleIdentifier(),
mxFrameListener()
{
ImplGetSVData()->mpCommandInfoProvider = this;
}
void CommandInfoProvider::dispose()
{
if (mxFrameListener.is())
{
mxFrameListener->dispose();
mxFrameListener.clear();
}
mxCachedGlobalAcceleratorConfiguration.clear();
mxCachedModuleAcceleratorConfiguration.clear();
mxCachedDocumentAcceleratorConfiguration.clear();
mxCachedDataFrame.clear();
mxContext.clear();
}
CommandInfoProvider::CommandInfoProvider() { }
CommandInfoProvider::~CommandInfoProvider()
{
dispose();
}
OUString CommandInfoProvider::GetLabelForCommand (
const OUString& rsCommandName,
const Reference<frame::XFrame>& rxFrame)
{
SetFrame(rxFrame);
return GetCommandProperty("Name", rsCommandName);
return GetCommandProperty("Name", rsCommandName, rxFrame);
}
OUString CommandInfoProvider::GetMenuLabelForCommand (
const OUString& rsCommandName,
const Reference<frame::XFrame>& rxFrame)
{
SetFrame(rxFrame);
// Here we want to use "Label", not "Name". "Name" is a stripped-down version of "Label" without accelerators
// and ellipsis. In the menu, we want to have those accelerators and ellipsis.
return GetCommandProperty("Label", rsCommandName);
return GetCommandProperty("Label", rsCommandName, rxFrame);
}
OUString CommandInfoProvider::GetPopupLabelForCommand (
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame)
{
SetFrame(rxFrame);
OUString sPopupLabel(GetCommandProperty("PopupLabel", rsCommandName));
OUString sPopupLabel(GetCommandProperty("PopupLabel", rsCommandName, rxFrame));
if (!sPopupLabel.isEmpty())
return sPopupLabel;
return GetCommandProperty("Label", rsCommandName);
return GetCommandProperty("Label", rsCommandName, rxFrame);
}
OUString CommandInfoProvider::GetTooltipForCommand (
const OUString& rsCommandName,
const Reference<frame::XFrame>& rxFrame)
{
SetFrame(rxFrame);
OUString sLabel (GetCommandProperty("TooltipLabel", rsCommandName));
OUString sLabel (GetCommandProperty("TooltipLabel", rsCommandName, rxFrame));
if (sLabel.isEmpty()) {
sLabel = GetPopupLabelForCommand(rsCommandName, rxFrame);
// Remove '...' at the end and mnemonics (we don't want those in tooltips)
@ -180,15 +101,14 @@ OUString CommandInfoProvider::GetTooltipForCommand (
OUString CommandInfoProvider::GetCommandShortcut (const OUString& rsCommandName,
const Reference<frame::XFrame>& rxFrame)
{
SetFrame(rxFrame);
OUString sShortcut;
sShortcut = RetrieveShortcutsFromConfiguration(GetDocumentAcceleratorConfiguration(), rsCommandName);
sShortcut = RetrieveShortcutsFromConfiguration(GetDocumentAcceleratorConfiguration(rxFrame), rsCommandName);
if (sShortcut.getLength() > 0)
return sShortcut;
sShortcut = RetrieveShortcutsFromConfiguration(GetModuleAcceleratorConfiguration(), rsCommandName);
sShortcut = RetrieveShortcutsFromConfiguration(GetModuleAcceleratorConfiguration(rxFrame), rsCommandName);
if (sShortcut.getLength() > 0)
return sShortcut;
@ -202,16 +122,14 @@ OUString CommandInfoProvider::GetCommandShortcut (const OUString& rsCommandName,
OUString CommandInfoProvider::GetRealCommandForCommand(const OUString& rCommandName,
const css::uno::Reference<frame::XFrame>& rxFrame)
{
SetFrame(rxFrame);
return GetCommandProperty("TargetURL", rCommandName);
return GetCommandProperty("TargetURL", rCommandName, rxFrame);
}
BitmapEx CommandInfoProvider::GetBitmapForCommand(const OUString& rsCommandName,
const Reference<frame::XFrame>& rxFrame,
vcl::ImageType eImageType)
{
SetFrame(rxFrame);
if (rsCommandName.isEmpty())
return BitmapEx();
@ -251,8 +169,8 @@ BitmapEx CommandInfoProvider::GetBitmapForCommand(const OUString& rsCommandName,
}
try {
Reference<ui::XModuleUIConfigurationManagerSupplier> xModuleCfgMgrSupplier(ui::theModuleUIConfigurationManagerSupplier::get(mxContext));
Reference<ui::XUIConfigurationManager> xUICfgMgr(xModuleCfgMgrSupplier->getUIConfigurationManager(GetModuleIdentifier()));
Reference<ui::XModuleUIConfigurationManagerSupplier> xModuleCfgMgrSupplier(ui::theModuleUIConfigurationManagerSupplier::get(comphelper::getProcessComponentContext()));
Reference<ui::XUIConfigurationManager> xUICfgMgr(xModuleCfgMgrSupplier->getUIConfigurationManager(GetModuleIdentifier(rxFrame)));
Sequence< Reference<graphic::XGraphic> > aGraphicSeq;
Reference<ui::XImageManager> xModuleImageManager(xUICfgMgr->getImageManager(), UNO_QUERY);
@ -285,10 +203,9 @@ sal_Int32 CommandInfoProvider::GetPropertiesForCommand (
const OUString& rsCommandName,
const Reference<frame::XFrame>& rxFrame)
{
SetFrame(rxFrame);
sal_Int32 nValue = 0;
const Sequence<beans::PropertyValue> aProperties (GetCommandProperties(rsCommandName));
const Sequence<beans::PropertyValue> aProperties (GetCommandProperties(rsCommandName, rxFrame));
for (sal_Int32 nIndex=0; nIndex<aProperties.getLength(); ++nIndex)
{
if (aProperties[nIndex].Name == "Properties")
@ -300,14 +217,14 @@ sal_Int32 CommandInfoProvider::GetPropertiesForCommand (
return nValue;
}
bool CommandInfoProvider::IsRotated(const OUString& rsCommandName)
bool CommandInfoProvider::IsRotated(const OUString& rsCommandName, const Reference<frame::XFrame>& rxFrame)
{
return ResourceHasKey("private:resource/image/commandrotateimagelist", rsCommandName);
return ResourceHasKey("private:resource/image/commandrotateimagelist", rsCommandName, rxFrame);
}
bool CommandInfoProvider::IsMirrored(const OUString& rsCommandName)
bool CommandInfoProvider::IsMirrored(const OUString& rsCommandName, const Reference<frame::XFrame>& rxFrame)
{
return ResourceHasKey("private:resource/image/commandmirrorimagelist", rsCommandName);
return ResourceHasKey("private:resource/image/commandmirrorimagelist", rsCommandName, rxFrame);
}
bool CommandInfoProvider::IsExperimental(const OUString& rsCommandName,
@ -318,7 +235,7 @@ bool CommandInfoProvider::IsExperimental(const OUString& rsCommandName,
{
if( rModuleName.getLength() > 0)
{
Reference<container::XNameAccess> xNameAccess = frame::theUICommandDescription::get(mxContext);
Reference<container::XNameAccess> xNameAccess = frame::theUICommandDescription::get(comphelper::getProcessComponentContext());
Reference<container::XNameAccess> xUICommandLabels;
if (xNameAccess->getByName( rModuleName ) >>= xUICommandLabels )
xUICommandLabels->getByName(rsCommandName) >>= aProperties;
@ -339,100 +256,60 @@ bool CommandInfoProvider::IsExperimental(const OUString& rsCommandName,
return false;
}
void CommandInfoProvider::SetFrame (const Reference<frame::XFrame>& rxFrame)
Reference<ui::XAcceleratorConfiguration> const CommandInfoProvider::GetDocumentAcceleratorConfiguration(const Reference<frame::XFrame>& rxFrame)
{
if (rxFrame != mxCachedDataFrame)
Reference<frame::XController> xController = rxFrame->getController();
if (xController.is())
{
// Detach from the old frame.
if (mxFrameListener.is())
Reference<frame::XModel> xModel (xController->getModel());
if (xModel.is())
{
mxFrameListener->dispose();
mxFrameListener = nullptr;
}
// Release objects that are tied to the old frame.
mxCachedDocumentAcceleratorConfiguration = nullptr;
mxCachedModuleAcceleratorConfiguration = nullptr;
msCachedModuleIdentifier.clear();
mxCachedDataFrame = rxFrame;
// Connect to the new frame.
if (rxFrame.is())
mxFrameListener = new FrameListener(*this, rxFrame);
}
}
Reference<ui::XAcceleratorConfiguration> const & CommandInfoProvider::GetDocumentAcceleratorConfiguration()
{
if ( ! mxCachedDocumentAcceleratorConfiguration.is())
{
// Get the accelerator configuration for the document.
if (mxCachedDataFrame.is())
{
Reference<frame::XController> xController = mxCachedDataFrame->getController();
if (xController.is())
Reference<ui::XUIConfigurationManagerSupplier> xSupplier (xModel, UNO_QUERY);
if (xSupplier.is())
{
Reference<frame::XModel> xModel (xController->getModel());
if (xModel.is())
Reference<ui::XUIConfigurationManager> xConfigurationManager(
xSupplier->getUIConfigurationManager(),
UNO_QUERY);
if (xConfigurationManager.is())
{
Reference<ui::XUIConfigurationManagerSupplier> xSupplier (xModel, UNO_QUERY);
if (xSupplier.is())
{
Reference<ui::XUIConfigurationManager> xConfigurationManager(
xSupplier->getUIConfigurationManager(),
UNO_QUERY);
if (xConfigurationManager.is())
{
mxCachedDocumentAcceleratorConfiguration = xConfigurationManager->getShortCutManager();
}
}
return xConfigurationManager->getShortCutManager();
}
}
}
}
return mxCachedDocumentAcceleratorConfiguration;
return nullptr;
}
Reference<ui::XAcceleratorConfiguration> const & CommandInfoProvider::GetModuleAcceleratorConfiguration()
Reference<ui::XAcceleratorConfiguration> const CommandInfoProvider::GetModuleAcceleratorConfiguration(const Reference<frame::XFrame>& rxFrame)
{
if ( ! mxCachedModuleAcceleratorConfiguration.is())
css::uno::Reference<css::ui::XAcceleratorConfiguration> curModuleAcceleratorConfiguration;
try
{
try
{
Reference<ui::XModuleUIConfigurationManagerSupplier> xSupplier = ui::theModuleUIConfigurationManagerSupplier::get(mxContext);
Reference<ui::XUIConfigurationManager> xManager (
xSupplier->getUIConfigurationManager(GetModuleIdentifier()));
if (xManager.is())
{
mxCachedModuleAcceleratorConfiguration = xManager->getShortCutManager();
}
}
catch (Exception&)
Reference<ui::XModuleUIConfigurationManagerSupplier> xSupplier = ui::theModuleUIConfigurationManagerSupplier::get(comphelper::getProcessComponentContext());
Reference<ui::XUIConfigurationManager> xManager (
xSupplier->getUIConfigurationManager(GetModuleIdentifier(rxFrame)));
if (xManager.is())
{
curModuleAcceleratorConfiguration = xManager->getShortCutManager();
}
}
return mxCachedModuleAcceleratorConfiguration;
catch (Exception&)
{
}
return curModuleAcceleratorConfiguration;
}
Reference<ui::XAcceleratorConfiguration> const & CommandInfoProvider::GetGlobalAcceleratorConfiguration()
Reference<ui::XAcceleratorConfiguration> const CommandInfoProvider::GetGlobalAcceleratorConfiguration()
{
// Get the global accelerator configuration.
if ( ! mxCachedGlobalAcceleratorConfiguration.is())
{
mxCachedGlobalAcceleratorConfiguration = ui::GlobalAcceleratorConfiguration::create(mxContext);
}
return ui::GlobalAcceleratorConfiguration::create(comphelper::getProcessComponentContext());
return mxCachedGlobalAcceleratorConfiguration;
}
OUString const & CommandInfoProvider::GetModuleIdentifier()
OUString const CommandInfoProvider::GetModuleIdentifier(const Reference<frame::XFrame>& rxFrame)
{
if (msCachedModuleIdentifier.getLength() == 0)
{
Reference<frame::XModuleManager2> xModuleManager = frame::ModuleManager::create(mxContext);
msCachedModuleIdentifier = xModuleManager->identify(mxCachedDataFrame);
}
return msCachedModuleIdentifier;
Reference<frame::XModuleManager2> xModuleManager = frame::ModuleManager::create(comphelper::getProcessComponentContext());
return xModuleManager->identify(rxFrame);
}
OUString CommandInfoProvider::RetrieveShortcutsFromConfiguration(
@ -462,15 +339,15 @@ OUString CommandInfoProvider::RetrieveShortcutsFromConfiguration(
return OUString();
}
bool CommandInfoProvider::ResourceHasKey(const OUString& rsResourceName, const OUString& rsCommandName)
bool CommandInfoProvider::ResourceHasKey(const OUString& rsResourceName, const OUString& rsCommandName, const Reference<frame::XFrame>& rxFrame)
{
Sequence< OUString > aSequence;
try
{
const OUString sModuleIdentifier (GetModuleIdentifier());
const OUString sModuleIdentifier (GetModuleIdentifier(rxFrame));
if (!sModuleIdentifier.isEmpty())
{
Reference<container::XNameAccess> xNameAccess = frame::theUICommandDescription::get(mxContext);
Reference<container::XNameAccess> xNameAccess = frame::theUICommandDescription::get(comphelper::getProcessComponentContext());
Reference<container::XNameAccess> xUICommandLabels;
if (xNameAccess->getByName(sModuleIdentifier) >>= xUICommandLabels) {
xUICommandLabels->getByName(rsResourceName) >>= aSequence;
@ -488,16 +365,16 @@ bool CommandInfoProvider::ResourceHasKey(const OUString& rsResourceName, const O
return false;
}
Sequence<beans::PropertyValue> CommandInfoProvider::GetCommandProperties(const OUString& rsCommandName)
Sequence<beans::PropertyValue> CommandInfoProvider::GetCommandProperties(const OUString& rsCommandName, const Reference<frame::XFrame>& rxFrame)
{
Sequence<beans::PropertyValue> aProperties;
try
{
const OUString sModuleIdentifier (GetModuleIdentifier());
const OUString sModuleIdentifier (GetModuleIdentifier(rxFrame));
if (sModuleIdentifier.getLength() > 0)
{
Reference<container::XNameAccess> xNameAccess = frame::theUICommandDescription::get(mxContext);
Reference<container::XNameAccess> xNameAccess = frame::theUICommandDescription::get(comphelper::getProcessComponentContext());
Reference<container::XNameAccess> xUICommandLabels;
if (xNameAccess->getByName(sModuleIdentifier) >>= xUICommandLabels)
xUICommandLabels->getByName(rsCommandName) >>= aProperties;
@ -510,9 +387,9 @@ Sequence<beans::PropertyValue> CommandInfoProvider::GetCommandProperties(const O
return aProperties;
}
OUString CommandInfoProvider::GetCommandProperty(const OUString& rsProperty, const OUString& rsCommandName)
OUString CommandInfoProvider::GetCommandProperty(const OUString& rsProperty, const OUString& rsCommandName, const Reference<frame::XFrame>& rxFrame)
{
const Sequence<beans::PropertyValue> aProperties (GetCommandProperties(rsCommandName));
const Sequence<beans::PropertyValue> aProperties (GetCommandProperties(rsCommandName, rxFrame));
for (sal_Int32 nIndex=0; nIndex<aProperties.getLength(); ++nIndex)
{
if (aProperties[nIndex].Name == rsProperty)
@ -536,7 +413,7 @@ OUString CommandInfoProvider::GetCommandPropertyFromModule( const OUString& rCom
{
if( rModuleName.getLength() > 0)
{
Reference<container::XNameAccess> xNameAccess = frame::theUICommandDescription::get(mxContext);
Reference<container::XNameAccess> xNameAccess = frame::theUICommandDescription::get(comphelper::getProcessComponentContext());
Reference<container::XNameAccess> xUICommandLabels;
if (xNameAccess->getByName( rModuleName ) >>= xUICommandLabels )
xUICommandLabels->getByName(rCommandName) >>= aProperties;

View File

@ -879,15 +879,15 @@ namespace
if (aCommand.isEmpty())
return;
OUString aLabel(vcl::CommandInfoProvider::Instance().GetLabelForCommand(aCommand, rFrame));
OUString aLabel(vcl::CommandInfoProvider::GetLabelForCommand(aCommand, rFrame));
if (!aLabel.isEmpty())
pButton->SetText(aLabel);
OUString aTooltip(vcl::CommandInfoProvider::Instance().GetTooltipForCommand(aCommand, rFrame));
OUString aTooltip(vcl::CommandInfoProvider::GetTooltipForCommand(aCommand, rFrame));
if (!aTooltip.isEmpty())
pButton->SetQuickHelpText(aTooltip);
Image aImage(vcl::CommandInfoProvider::Instance().GetImageForCommand(aCommand, rFrame));
Image aImage(vcl::CommandInfoProvider::GetImageForCommand(aCommand, rFrame));
pButton->SetModeImage(aImage);
pButton->SetCommandHandler(aCommand);

View File

@ -510,9 +510,9 @@ void Menu::InsertItem(const OUString& rCommand, const css::uno::Reference<css::f
if (rFrame.is())
{
OUString aLabel(CommandInfoProvider::Instance().GetPopupLabelForCommand(rCommand, rFrame));
OUString aTooltip(CommandInfoProvider::Instance().GetTooltipForCommand(rCommand, rFrame));
Image aImage(CommandInfoProvider::Instance().GetImageForCommand(rCommand, rFrame));
OUString aLabel(CommandInfoProvider::GetPopupLabelForCommand(rCommand, rFrame));
OUString aTooltip(CommandInfoProvider::GetTooltipForCommand(rCommand, rFrame));
Image aImage(CommandInfoProvider::GetImageForCommand(rCommand, rFrame));
InsertItem(nItemId, aLabel, aImage);
SetHelpText(nItemId, aTooltip);

View File

@ -4540,9 +4540,9 @@ void ToolBox::statusChanged( const css::frame::FeatureStateEvent& Event )
// update image orientation
for (std::vector<ImplToolItem>::const_iterator it = mpData->m_aItems.begin(); it != mpData->m_aItems.end(); ++it)
{
if (vcl::CommandInfoProvider::Instance().IsMirrored(it->maCommandStr))
if (vcl::CommandInfoProvider::IsMirrored(it->maCommandStr, mpStatusListener->getFrame()))
SetItemImageMirrorMode(it->mnId, mbImagesMirrored);
if (vcl::CommandInfoProvider::Instance().IsRotated(it->maCommandStr))
if (vcl::CommandInfoProvider::IsRotated(it->maCommandStr, mpStatusListener->getFrame()))
SetItemImageAngle(it->mnId, mnImagesRotationAngle);
}
}

View File

@ -432,8 +432,8 @@ void ToolBox::InsertItem( sal_uInt16 nItemId, const OUString& rText, ToolBoxItem
void ToolBox::InsertItem(const OUString& rCommand, const css::uno::Reference<css::frame::XFrame>& rFrame, ToolBoxItemBits nBits,
const Size& rRequestedSize, sal_uInt16 nPos)
{
OUString aLabel(vcl::CommandInfoProvider::Instance().GetLabelForCommand(rCommand, rFrame));
OUString aTooltip(vcl::CommandInfoProvider::Instance().GetTooltipForCommand(rCommand, rFrame));
OUString aLabel(vcl::CommandInfoProvider::GetLabelForCommand(rCommand, rFrame));
OUString aTooltip(vcl::CommandInfoProvider::GetTooltipForCommand(rCommand, rFrame));
vcl::ImageType eImageType = vcl::ImageType::Size16;
@ -442,8 +442,7 @@ void ToolBox::InsertItem(const OUString& rCommand, const css::uno::Reference<css
else if (GetToolboxButtonSize() == ToolBoxButtonSize::Size32)
eImageType = vcl::ImageType::Size32;
CommandInfoProvider& rInfoProvider = vcl::CommandInfoProvider::Instance();
Image aImage(rInfoProvider.GetImageForCommand(rCommand, rFrame, eImageType));
Image aImage(CommandInfoProvider::GetImageForCommand(rCommand, rFrame, eImageType));
sal_uInt16 nItemId = GetItemCount() + 1;
InsertItem(nItemId, aImage, aLabel, nBits, nPos);