diff --git a/dbaccess/source/ui/control/dbtreelistbox.cxx b/dbaccess/source/ui/control/dbtreelistbox.cxx index ccfca86..4b65cb6 100644 --- a/dbaccess/source/ui/control/dbtreelistbox.cxx +++ b/dbaccess/source/ui/control/dbtreelistbox.cxx @@ -500,7 +500,7 @@ namespace } if ( xFrame.is() ) - _rMenu.SetItemImage(nId, vcl::CommandInfoProvider::Instance().GetImageForCommand(aCommand, xFrame)); + _rMenu.SetItemImage(nId, vcl::CommandInfoProvider::GetImageForCommand(aCommand, xFrame)); } } // SelectionSupplier diff --git a/dbaccess/source/ui/control/opendoccontrols.cxx b/dbaccess/source/ui/control/opendoccontrols.cxx index daac412..dff3368 100644 --- a/dbaccess/source/ui/control/opendoccontrols.cxx +++ b/dbaccess/source/ui/control/opendoccontrols.cxx @@ -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. diff --git a/forms/source/solar/control/navtoolbar.cxx b/forms/source/solar/control/navtoolbar.cxx index 66b9109..0a66584 100644 --- a/forms/source/solar/control/navtoolbar.cxx +++ b/forms/source/solar/control/navtoolbar.cxx @@ -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 ) diff --git a/framework/source/uielement/addonstoolbarmanager.cxx b/framework/source/uielement/addonstoolbarmanager.cxx index b307448..e91d5f3 100644 --- a/framework/source/uielement/addonstoolbarmanager.cxx +++ b/framework/source/uielement/addonstoolbarmanager.cxx @@ -123,14 +123,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; } @@ -260,7 +260,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 + ")"); diff --git a/framework/source/uielement/macrosmenucontroller.cxx b/framework/source/uielement/macrosmenucontroller.cxx index bbfaf0e..aaeaeb3 100644 --- a/framework/source/uielement/macrosmenucontroller.cxx +++ b/framework/source/uielement/macrosmenucontroller.cxx @@ -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 ); diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 0a50c02..685856a 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -1089,9 +1089,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 ) @@ -1187,7 +1187,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; @@ -1293,7 +1293,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 ); } @@ -1324,12 +1324,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 ); } @@ -1652,7 +1652,7 @@ void MenuBarManager::FillMenu( aProp[i].Value >>= bEnabled; } - if (vcl::CommandInfoProvider::Instance().IsExperimental(aCommandURL, rModuleIdentifier) && + if (vcl::CommandInfoProvider::IsExperimental(aCommandURL, rModuleIdentifier) && !SvtMiscOptions().IsExperimentalMode()) { continue; @@ -2090,7 +2090,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; @@ -2101,7 +2101,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 ); diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx index e8963fd..1cd1bef 100644 --- a/framework/source/uielement/newmenucontroller.cxx +++ b/framework/source/uielement/newmenucontroller.cxx @@ -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 ); diff --git a/framework/source/uielement/popuptoolbarcontroller.cxx b/framework/source/uielement/popuptoolbarcontroller.cxx index c4e627d..1e8adbb 100644 --- a/framework/source/uielement/popuptoolbarcontroller.cxx +++ b/framework/source/uielement/popuptoolbarcontroller.cxx @@ -373,7 +373,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 ); @@ -383,12 +383,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 ); } @@ -511,7 +511,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 ) { @@ -520,7 +520,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 ); @@ -539,7 +539,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(); diff --git a/framework/source/uielement/statusbarmanager.cxx b/framework/source/uielement/statusbarmanager.cxx index 0c0e0e6..0f803e6 100644 --- a/framework/source/uielement/statusbarmanager.cxx +++ b/framework/source/uielement/statusbarmanager.cxx @@ -451,7 +451,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 ); diff --git a/framework/source/uielement/subtoolbarcontroller.cxx b/framework/source/uielement/subtoolbarcontroller.cxx index 36f679a..7c3086a 100644 --- a/framework/source/uielement/subtoolbarcontroller.cxx +++ b/framework/source/uielement/subtoolbarcontroller.cxx @@ -297,7 +297,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 ); } diff --git a/framework/source/uielement/thesaurusmenucontroller.cxx b/framework/source/uielement/thesaurusmenucontroller.cxx index 360fd2f..c7227c4 100644 --- a/framework/source/uielement/thesaurusmenucontroller.cxx +++ b/framework/source/uielement/thesaurusmenucontroller.cxx @@ -100,7 +100,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 ); } } diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 489ad87..42be968 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -313,7 +313,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; @@ -679,7 +679,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; @@ -758,7 +758,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 ); } @@ -1046,7 +1046,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; @@ -1054,7 +1054,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 ); if ( aMenuDesc.is() ) @@ -1064,7 +1064,7 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine } m_pToolBar->InsertItem( nId, aString, nItemBits ); m_pToolBar->SetItemCommand( nId, aCommandURL ); - OUString sTooltip = vcl::CommandInfoProvider::Instance().GetTooltipForCommand(aCommandURL, m_xFrame); + OUString sTooltip = vcl::CommandInfoProvider::GetTooltipForCommand(aCommandURL, m_xFrame); if (!sTooltip.isEmpty()) m_pToolBar->SetQuickHelpText( nId, sTooltip ); @@ -1483,7 +1483,7 @@ bool ToolBarManager::MenuItemAllowed( sal_uInt16 ) const 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 ); } diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx b/framework/source/uielement/toolbarsmenucontroller.cxx index 003c74c..7a94b80 100644 --- a/framework/source/uielement/toolbarsmenucontroller.cxx +++ b/framework/source/uielement/toolbarsmenucontroller.cxx @@ -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::GetImplementation( rPopupMenu )); if ( pPopupMenu ) diff --git a/include/vcl/commandinfoprovider.hxx b/include/vcl/commandinfoprovider.hxx index 93f4f3f..6bf3c26 100644 --- a/include/vcl/commandinfoprovider.hxx +++ b/include/vcl/commandinfoprovider.hxx @@ -27,6 +27,9 @@ #include #include +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& rxFrame); - OUString GetMenuLabelForCommand ( + static OUString GetMenuLabelForCommand ( const OUString& rsCommandName, const css::uno::Reference& rxFrame); - OUString GetPopupLabelForCommand ( + static OUString GetPopupLabelForCommand ( const OUString& rsCommandName, const css::uno::Reference& rxFrame); @@ -76,62 +71,53 @@ 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& 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& rxFrame); - OUString GetRealCommandForCommand( const OUString& rCommandName, + static OUString GetRealCommandForCommand( const OUString& rCommandName, const css::uno::Reference& rxFrame ); - OUString GetCommandPropertyFromModule( const OUString& rCommandName, const OUString& rModuleName ); + static OUString GetCommandPropertyFromModule( const OUString& rCommandName, const OUString& rModuleName ); - Image GetImageForCommand( + static Image GetImageForCommand( const OUString& rsCommandName, const css::uno::Reference& rxFrame, vcl::ImageType eImageType = vcl::ImageType::Small); - sal_Int32 GetPropertiesForCommand( + static sal_Int32 GetPropertiesForCommand( const OUString& rsCommandName, const css::uno::Reference& rxFrame); - bool IsRotated(const OUString& rsCommandName); - bool IsMirrored(const OUString& rsCommandName); + static bool IsRotated(const OUString& rsCommandName,const Reference& rxFrame); + static bool IsMirrored(const OUString& rsCommandName, const Reference& 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& rxFrame); + static void SetFrame (const css::uno::Reference& rxFrame); - void dispose(); + static void dispose(); private: - css::uno::Reference mxContext; - css::uno::Reference mxCachedDataFrame; - css::uno::Reference mxCachedDocumentAcceleratorConfiguration; - css::uno::Reference mxCachedModuleAcceleratorConfiguration; - css::uno::Reference mxCachedGlobalAcceleratorConfiguration; - OUString msCachedModuleIdentifier; - css::uno::Reference mxFrameListener; - - CommandInfoProvider(); - ~CommandInfoProvider(); - - css::uno::Reference const & GetDocumentAcceleratorConfiguration(); - css::uno::Reference const & GetModuleAcceleratorConfiguration(); - css::uno::Reference const & GetGlobalAcceleratorConfiguration(); - OUString const & GetModuleIdentifier(); - css::uno::Sequence GetCommandProperties ( - const OUString& rsCommandName); - OUString GetCommandProperty(const OUString& rsProperty, const OUString& rsCommandName); - bool ResourceHasKey(const OUString& rsResourceName, const OUString& rsCommandName); + static css::uno::Reference mxFrameListener; + + static css::uno::Reference const GetDocumentAcceleratorConfiguration(const Reference& rxFrame); + static css::uno::Reference const GetModuleAcceleratorConfiguration(const Reference& rxFrame); + static css::uno::Reference const GetGlobalAcceleratorConfiguration(); + static OUString const GetModuleIdentifier(const Reference& rxFrame); + static css::uno::Sequence GetCommandProperties ( + const OUString& rsCommandName, const Reference& rxFrame); + static OUString GetCommandProperty(const OUString& rsProperty, const OUString& rsCommandName,const Reference& rxFrame); + static bool ResourceHasKey(const OUString& rsResourceName, const OUString& rsCommandName, const Reference& rxFrame); static OUString RetrieveShortcutsFromConfiguration( const css::uno::Reference& rxConfiguration, const OUString& rsCommandName); diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx index cda7949..f6916c0 100644 --- a/reportdesign/source/ui/report/ReportSection.cxx +++ b/reportdesign/source/ui/report/ReportSection.cxx @@ -447,7 +447,7 @@ void lcl_insertMenuItemImages( else { const OUString sCommand = rContextMenu.GetItemCommand(nId); - rContextMenu.SetItemImage(nId, vcl::CommandInfoProvider::Instance().GetImageForCommand(sCommand, _rFrame)); + rContextMenu.SetItemImage(nId, vcl::CommandInfoProvider::GetImageForCommand(sCommand, _rFrame)); if ( nId == SID_PAGEHEADERFOOTER ) { OUString sText = ModuleRes((_xReportDefinition.is() && _xReportDefinition->getPageHeaderOn()) ? RID_STR_PAGEHEADERFOOTER_DELETE : RID_STR_PAGEHEADERFOOTER_INSERT); diff --git a/sd/source/ui/controller/slidelayoutcontroller.cxx b/sd/source/ui/controller/slidelayoutcontroller.cxx index dc799a1..f3c4452 100644 --- a/sd/source/ui/controller/slidelayoutcontroller.cxx +++ b/sd/source/ui/controller/slidelayoutcontroller.cxx @@ -239,11 +239,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); diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx index 8a3665b..378747e 100644 --- a/sd/source/ui/view/ViewShellBase.cxx +++ b/sd/source/ui/view/ViewShellBase.cxx @@ -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 diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx index e992cc9..6c613f7 100644 --- a/sfx2/source/appl/sfxhelp.cxx +++ b/sfx2/source/appl/sfxhelp.cxx @@ -447,7 +447,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; @@ -565,7 +565,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 ); diff --git a/sfx2/source/sidebar/ControllerFactory.cxx b/sfx2/source/sidebar/ControllerFactory.cxx index 45d26eb8..40a89a1 100644 --- a/sfx2/source/sidebar/ControllerFactory.cxx +++ b/sfx2/source/sidebar/ControllerFactory.cxx @@ -125,7 +125,7 @@ Reference 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); diff --git a/sfx2/source/sidebar/SidebarToolBox.cxx b/sfx2/source/sidebar/SidebarToolBox.cxx index bb948b0..5cbb1be 100644 --- a/sfx2/source/sidebar/SidebarToolBox.cxx +++ b/sfx2/source/sidebar/SidebarToolBox.cxx @@ -293,7 +293,7 @@ IMPL_LINK_NOARG(SidebarToolBox, ChangedIconSizeHandler, LinkParamNone*, void) if(SfxViewFrame::Current()) { css::uno::Reference xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); - Image aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aCommandURL, xFrame, eImageType); + Image aImage = vcl::CommandInfoProvider::GetImageForCommand(aCommandURL, xFrame, eImageType); // Try also to query for add-on images before giving up and use an // empty image. if (!aImage) diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 91e1c28..1686321 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -724,7 +724,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( " (" ); diff --git a/svx/source/mnuctrls/smarttagmenu.cxx b/svx/source/mnuctrls/smarttagmenu.cxx index fea4e30..0837033 100644 --- a/svx/source/mnuctrls/smarttagmenu.cxx +++ b/svx/source/mnuctrls/smarttagmenu.cxx @@ -181,7 +181,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 ); } } diff --git a/svx/source/sidebar/shapes/DefaultShapesPanel.cxx b/svx/source/sidebar/shapes/DefaultShapesPanel.cxx index dfc62187..5bc7620 100644 --- a/svx/source/sidebar/shapes/DefaultShapesPanel.cxx +++ b/svx/source/sidebar/shapes/DefaultShapesPanel.cxx @@ -131,7 +131,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); } } diff --git a/sw/source/uibase/shells/frmsh.cxx b/sw/source/uibase/shells/frmsh.cxx index 4631e6c..fb2961e 100644 --- a/sw/source/uibase/shells/frmsh.cxx +++ b/sw/source/uibase/shells/frmsh.cxx @@ -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; } } diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx index d398d6b..ce2c440 100644 --- a/vcl/source/app/svmain.cxx +++ b/vcl/source/app/svmain.cxx @@ -528,7 +528,7 @@ void DeInitVCL() if (pSVData->mpCommandInfoProvider) { - pSVData->mpCommandInfoProvider->dispose(); + vcl::CommandInfoProvider::dispose(); pSVData->mpCommandInfoProvider = nullptr; } diff --git a/vcl/source/helper/commandinfoprovider.cxx b/vcl/source/helper/commandinfoprovider.cxx index e48367c..5d7144f 100644 --- a/vcl/source/helper/commandinfoprovider.cxx +++ b/vcl/source/helper/commandinfoprovider.cxx @@ -38,7 +38,6 @@ using namespace css; using namespace css::uno; - namespace { typedef ::cppu::WeakComponentImplHelper < @@ -49,9 +48,8 @@ namespace public FrameListenerInterfaceBase { public: - FrameListener (vcl::CommandInfoProvider& rInfoProvider, const Reference& rxFrame) + FrameListener (const Reference& rxFrame) : FrameListenerInterfaceBase(m_aMutex), - mrInfoProvider(rInfoProvider), mxFrame(rxFrame) { if (mxFrame.is()) @@ -64,7 +62,7 @@ namespace // 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); + vcl::CommandInfoProvider::SetFrame(nullptr); } virtual void SAL_CALL disposing() override { @@ -75,35 +73,18 @@ namespace throw (RuntimeException, std::exception) override { (void)rEvent; - mrInfoProvider.SetFrame(nullptr); + vcl::CommandInfoProvider::SetFrame(nullptr); mxFrame = nullptr; } private: - vcl::CommandInfoProvider& mrInfoProvider; Reference 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; -} +CommandInfoProvider::CommandInfoProvider() { } void CommandInfoProvider::dispose() { @@ -112,11 +93,6 @@ void CommandInfoProvider::dispose() mxFrameListener->dispose(); mxFrameListener.clear(); } - mxCachedGlobalAcceleratorConfiguration.clear(); - mxCachedModuleAcceleratorConfiguration.clear(); - mxCachedDocumentAcceleratorConfiguration.clear(); - mxCachedDataFrame.clear(); - mxContext.clear(); } CommandInfoProvider::~CommandInfoProvider() @@ -130,7 +106,7 @@ OUString CommandInfoProvider::GetLabelForCommand ( { SetFrame(rxFrame); - return GetCommandProperty("Name", rsCommandName); + return GetCommandProperty("Name", rsCommandName, rxFrame); } OUString CommandInfoProvider::GetMenuLabelForCommand ( @@ -141,7 +117,7 @@ OUString CommandInfoProvider::GetMenuLabelForCommand ( // 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 ( @@ -150,10 +126,10 @@ OUString CommandInfoProvider::GetPopupLabelForCommand ( { 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 ( @@ -162,7 +138,7 @@ OUString CommandInfoProvider::GetTooltipForCommand ( { 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) @@ -186,11 +162,11 @@ OUString CommandInfoProvider::GetCommandShortcut (const OUString& rsCommandName, 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; @@ -206,7 +182,7 @@ OUString CommandInfoProvider::GetRealCommandForCommand(const OUString& rCommandN { SetFrame(rxFrame); - return GetCommandProperty("TargetURL", rCommandName); + return GetCommandProperty("TargetURL", rCommandName, rxFrame); } Image CommandInfoProvider::GetImageForCommand(const OUString& rsCommandName, @@ -252,8 +228,8 @@ Image CommandInfoProvider::GetImageForCommand(const OUString& rsCommandName, } try { - Reference xModuleCfgMgrSupplier(ui::theModuleUIConfigurationManagerSupplier::get(mxContext)); - Reference xUICfgMgr(xModuleCfgMgrSupplier->getUIConfigurationManager(GetModuleIdentifier())); + Reference xModuleCfgMgrSupplier(ui::theModuleUIConfigurationManagerSupplier::get(comphelper::getProcessComponentContext())); + Reference xUICfgMgr(xModuleCfgMgrSupplier->getUIConfigurationManager(GetModuleIdentifier(rxFrame))); Sequence< Reference > aGraphicSeq; Reference xModuleImageManager(xUICfgMgr->getImageManager(), UNO_QUERY); @@ -280,7 +256,7 @@ sal_Int32 CommandInfoProvider::GetPropertiesForCommand ( SetFrame(rxFrame); sal_Int32 nValue = 0; - const Sequence aProperties (GetCommandProperties(rsCommandName)); + const Sequence aProperties (GetCommandProperties(rsCommandName, rxFrame)); for (sal_Int32 nIndex=0; nIndex& 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& rxFrame) { - return ResourceHasKey("private:resource/image/commandmirrorimagelist", rsCommandName); + return ResourceHasKey("private:resource/image/commandmirrorimagelist", rsCommandName, rxFrame); } bool CommandInfoProvider::IsExperimental(const OUString& rsCommandName, @@ -310,7 +286,7 @@ bool CommandInfoProvider::IsExperimental(const OUString& rsCommandName, { if( rModuleName.getLength() > 0) { - Reference xNameAccess = frame::theUICommandDescription::get(mxContext); + Reference xNameAccess = frame::theUICommandDescription::get(comphelper::getProcessComponentContext()); Reference xUICommandLabels; if (xNameAccess->getByName( rModuleName ) >>= xUICommandLabels ) xUICommandLabels->getByName(rsCommandName) >>= aProperties; @@ -333,98 +309,70 @@ bool CommandInfoProvider::IsExperimental(const OUString& rsCommandName, void CommandInfoProvider::SetFrame (const Reference& rxFrame) { - if (rxFrame != mxCachedDataFrame) + if (mxFrameListener.is()) { - // Detach from the old frame. - if (mxFrameListener.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); + mxFrameListener->dispose(); + mxFrameListener = nullptr; } + // Connect to the new frame. + if (rxFrame.is()) + mxFrameListener = new FrameListener(rxFrame); } -Reference const & CommandInfoProvider::GetDocumentAcceleratorConfiguration() +Reference const CommandInfoProvider::GetDocumentAcceleratorConfiguration(const Reference& rxFrame) { - if ( ! mxCachedDocumentAcceleratorConfiguration.is()) + Reference xController = rxFrame->getController(); + if (xController.is()) { - // Get the accelerator configuration for the document. - if (mxCachedDataFrame.is()) + Reference xModel (xController->getModel()); + if (xModel.is()) { - Reference xController = mxCachedDataFrame->getController(); - if (xController.is()) + Reference xSupplier (xModel, UNO_QUERY); + if (xSupplier.is()) { - Reference xModel (xController->getModel()); - if (xModel.is()) + Reference xConfigurationManager( + xSupplier->getUIConfigurationManager(), + UNO_QUERY); + if (xConfigurationManager.is()) { - Reference xSupplier (xModel, UNO_QUERY); - if (xSupplier.is()) - { - Reference xConfigurationManager( - xSupplier->getUIConfigurationManager(), - UNO_QUERY); - if (xConfigurationManager.is()) - { - mxCachedDocumentAcceleratorConfiguration = xConfigurationManager->getShortCutManager(); - } - } + return xConfigurationManager->getShortCutManager(); } } } } - return mxCachedDocumentAcceleratorConfiguration; + return nullptr; } -Reference const & CommandInfoProvider::GetModuleAcceleratorConfiguration() +Reference const CommandInfoProvider::GetModuleAcceleratorConfiguration(const Reference& rxFrame) { - if ( ! mxCachedModuleAcceleratorConfiguration.is()) + css::uno::Reference curModuleAcceleratorConfiguration; + try { - try - { - Reference xSupplier = ui::theModuleUIConfigurationManagerSupplier::get(mxContext); - Reference xManager ( - xSupplier->getUIConfigurationManager(GetModuleIdentifier())); - if (xManager.is()) - { - mxCachedModuleAcceleratorConfiguration = xManager->getShortCutManager(); - } - } - catch (Exception&) + Reference xSupplier = ui::theModuleUIConfigurationManagerSupplier::get(comphelper::getProcessComponentContext()); + Reference xManager ( + xSupplier->getUIConfigurationManager(GetModuleIdentifier(rxFrame))); + if (xManager.is()) { + curModuleAcceleratorConfiguration = xManager->getShortCutManager(); } } - return mxCachedModuleAcceleratorConfiguration; + catch (Exception&) + { + } + return curModuleAcceleratorConfiguration; } -Reference const & CommandInfoProvider::GetGlobalAcceleratorConfiguration() +Reference 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& rxFrame) { - if (msCachedModuleIdentifier.getLength() == 0) - { - Reference xModuleManager = frame::ModuleManager::create(mxContext); - msCachedModuleIdentifier = xModuleManager->identify(mxCachedDataFrame); - } - return msCachedModuleIdentifier; + Reference xModuleManager = frame::ModuleManager::create(comphelper::getProcessComponentContext()); + return xModuleManager->identify(rxFrame); } OUString CommandInfoProvider::RetrieveShortcutsFromConfiguration( @@ -454,15 +402,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& rxFrame) { Sequence< OUString > aSequence; try { - const OUString sModuleIdentifier (GetModuleIdentifier()); + const OUString sModuleIdentifier (GetModuleIdentifier(rxFrame)); if (!sModuleIdentifier.isEmpty()) { - Reference xNameAccess = frame::theUICommandDescription::get(mxContext); + Reference xNameAccess = frame::theUICommandDescription::get(comphelper::getProcessComponentContext()); Reference xUICommandLabels; if (xNameAccess->getByName(sModuleIdentifier) >>= xUICommandLabels) { xUICommandLabels->getByName(rsResourceName) >>= aSequence; @@ -480,16 +428,16 @@ bool CommandInfoProvider::ResourceHasKey(const OUString& rsResourceName, const O return false; } -Sequence CommandInfoProvider::GetCommandProperties(const OUString& rsCommandName) +Sequence CommandInfoProvider::GetCommandProperties(const OUString& rsCommandName, const Reference& rxFrame) { Sequence aProperties; try { - const OUString sModuleIdentifier (GetModuleIdentifier()); + const OUString sModuleIdentifier (GetModuleIdentifier(rxFrame)); if (sModuleIdentifier.getLength() > 0) { - Reference xNameAccess = frame::theUICommandDescription::get(mxContext); + Reference xNameAccess = frame::theUICommandDescription::get(comphelper::getProcessComponentContext()); Reference xUICommandLabels; if (xNameAccess->getByName(sModuleIdentifier) >>= xUICommandLabels) xUICommandLabels->getByName(rsCommandName) >>= aProperties; @@ -502,9 +450,9 @@ Sequence 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& rxFrame) { - const Sequence aProperties (GetCommandProperties(rsCommandName)); + const Sequence aProperties (GetCommandProperties(rsCommandName, rxFrame)); for (sal_Int32 nIndex=0; nIndex 0) { - Reference xNameAccess = frame::theUICommandDescription::get(mxContext); + Reference xNameAccess = frame::theUICommandDescription::get(comphelper::getProcessComponentContext()); Reference xUICommandLabels; if (xNameAccess->getByName( rModuleName ) >>= xUICommandLabels ) xUICommandLabels->getByName(rCommandName) >>= aProperties; diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 32bd8b8..27c8107 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -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); diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 00b931e..bdc0c7b 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -510,9 +510,9 @@ void Menu::InsertItem(const OUString& rCommand, const css::uno::Reference::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, Event)) SetItemImageMirrorMode(it->mnId, mbImagesMirrored); - if (vcl::CommandInfoProvider::Instance().IsRotated(it->maCommandStr)) + if (vcl::CommandInfoProvider::IsRotated(it->maCommandStr, Event)) SetItemImageAngle(it->mnId, mnImagesRotationAngle); } } diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx index 037d228..e587825 100644 --- a/vcl/source/window/toolbox2.cxx +++ b/vcl/source/window/toolbox2.cxx @@ -432,8 +432,8 @@ void ToolBox::InsertItem( sal_uInt16 nItemId, const OUString& rText, ToolBoxItem void ToolBox::InsertItem(const OUString& rCommand, const css::uno::Reference& 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