From 0c48c809f09e74e79c9f8dc4c22958147f591921 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 17 Nov 2015 11:08:46 +0100 Subject: tdf#95845 Use CommandInfoProvider to receive command properties Change-Id: I41f9a661b7a5b355e50910d7f58f0d9d55dc62a6 --- framework/source/uielement/toolbarmanager.cxx | 56 +-------------------------- include/vcl/commandinfoprovider.hxx | 4 ++ vcl/source/helper/commandinfoprovider.cxx | 19 +++++++++ 3 files changed, 24 insertions(+), 55 deletions(-) diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 76fa3319ba35..e4f29796d75e 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -773,62 +773,8 @@ void ToolBarManager::RemoveControllers() m_aControllerMap.clear(); } -uno::Sequence< beans::PropertyValue > ToolBarManager::GetPropsForCommand( const OUString& rCmdURL ) -{ - Sequence< PropertyValue > aPropSeq; - - // Retrieve properties for command - try - { - if ( !m_bModuleIdentified ) - { - Reference< XModuleManager2 > xModuleManager = ModuleManager::create( m_xContext ); - Reference< XInterface > xIfac( m_xFrame, UNO_QUERY ); - - m_bModuleIdentified = true; - m_aModuleIdentifier = xModuleManager->identify( xIfac ); - - if ( !m_aModuleIdentifier.isEmpty() ) - { - Reference< XNameAccess > xNameAccess = frame::theUICommandDescription::get( m_xContext ); - xNameAccess->getByName( m_aModuleIdentifier ) >>= m_xUICommandLabels; - } - } - - if ( m_xUICommandLabels.is() ) - { - if ( !rCmdURL.isEmpty() ) - m_xUICommandLabels->getByName( rCmdURL ) >>= aPropSeq; - } - } - catch (const Exception&) - { - } - - return aPropSeq; -} - -sal_Int32 ToolBarManager::RetrievePropertiesFromCommand( const OUString& aCmdURL ) -{ - sal_Int32 nProperties(0); - Sequence< PropertyValue > aPropSeq; - - // Retrieve popup menu labels - aPropSeq = GetPropsForCommand( aCmdURL ); - for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) - { - if ( aPropSeq[i].Name == "Properties" ) - { - aPropSeq[i].Value >>= nProperties; - break; - } - } - return nProperties; -} - void ToolBarManager::CreateControllers() { - Reference< XWindow > xToolbarWindow = VCLUnoHelper::GetInterface( m_pToolBar ); css::util::URL aURL; @@ -932,7 +878,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 = RetrievePropertiesFromCommand( aCommandURL ); + sal_Int32 nProps = vcl::CommandInfoProvider::Instance().GetPropertiesForCommand(aCommandURL, m_xFrame); if ( nProps & UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON ) m_pToolBar->SetItemBits( nId, m_pToolBar->GetItemBits( nId ) | ToolBoxItemBits::CHECKABLE ); } diff --git a/include/vcl/commandinfoprovider.hxx b/include/vcl/commandinfoprovider.hxx index 0dc69f8eed77..3d98296d1f3e 100644 --- a/include/vcl/commandinfoprovider.hxx +++ b/include/vcl/commandinfoprovider.hxx @@ -84,6 +84,10 @@ public: bool bLarge, const css::uno::Reference& rxFrame); + sal_Int32 GetPropertiesForCommand( + const OUString& rsCommandName, + const css::uno::Reference& rxFrame); + /** Do not call. Should be part of a local and hidden interface. */ void SetFrame (const css::uno::Reference& rxFrame); diff --git a/vcl/source/helper/commandinfoprovider.cxx b/vcl/source/helper/commandinfoprovider.cxx index 4eef99c1cb61..cb0378c7fd43 100644 --- a/vcl/source/helper/commandinfoprovider.cxx +++ b/vcl/source/helper/commandinfoprovider.cxx @@ -214,6 +214,25 @@ Image CommandInfoProvider::GetImageForCommand(const OUString& rsCommandName, boo return Image(); } +sal_Int32 CommandInfoProvider::GetPropertiesForCommand ( + const OUString& rsCommandName, + const Reference& rxFrame) +{ + SetFrame(rxFrame); + + const Sequence aProperties (GetCommandProperties(rsCommandName)); + for (sal_Int32 nIndex=0; nIndex>= nValue; + return nValue; + } + } + return 0; +} + void CommandInfoProvider::SetFrame (const Reference& rxFrame) { if (rxFrame != mxCachedDataFrame) -- cgit v1.2.3