diff options
-rw-r--r-- | framework/source/uielement/toolbarmanager.cxx | 56 | ||||
-rw-r--r-- | include/vcl/commandinfoprovider.hxx | 4 | ||||
-rw-r--r-- | 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<css::frame::XFrame>& rxFrame); + sal_Int32 GetPropertiesForCommand( + const OUString& rsCommandName, + const css::uno::Reference<css::frame::XFrame>& rxFrame); + /** Do not call. Should be part of a local and hidden interface. */ void SetFrame (const css::uno::Reference<css::frame::XFrame>& 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<frame::XFrame>& rxFrame) +{ + SetFrame(rxFrame); + + const Sequence<beans::PropertyValue> aProperties (GetCommandProperties(rsCommandName)); + for (sal_Int32 nIndex=0; nIndex<aProperties.getLength(); ++nIndex) + { + if (aProperties[nIndex].Name == "Properties") + { + sal_Int32 nValue; + aProperties[nIndex].Value >>= nValue; + return nValue; + } + } + return 0; +} + void CommandInfoProvider::SetFrame (const Reference<frame::XFrame>& rxFrame) { if (rxFrame != mxCachedDataFrame) |