From 4342408a8359e590f57b016baaf7d8dcfdebdbd4 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Thu, 6 May 2010 18:15:21 +0200 Subject: fwk142: #i104293 Use Commands.xcu files to mark commands which support a toggle state --- framework/source/uielement/toolbarmanager.cxx | 90 +++++++++++++++++---------- 1 file changed, 56 insertions(+), 34 deletions(-) (limited to 'framework/source/uielement/toolbarmanager.cxx') diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index d89b81c0f9b6..8171ff2e5419 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -112,6 +112,7 @@ using namespace ::com::sun::star::util; using namespace ::com::sun::star::container; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::ui; +using namespace ::com::sun::star; namespace framework { @@ -803,17 +804,18 @@ void ToolBarManager::RemoveControllers() m_aControllerMap.clear(); } -::rtl::OUString ToolBarManager::RetrieveLabelFromCommand( const ::rtl::OUString& aCmdURL ) +uno::Sequence< beans::PropertyValue > ToolBarManager::GetPropsForCommand( const ::rtl::OUString& rCmdURL ) { - ::rtl::OUString aLabel; + Sequence< PropertyValue > aPropSeq; - // Retrieve popup menu labels - if ( !m_bModuleIdentified ) + // Retrieve properties for command + try { - Reference< XModuleManager > xModuleManager( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW ); - Reference< XInterface > xIfac( m_xFrame, UNO_QUERY ); - try + if ( !m_bModuleIdentified ) { + Reference< XModuleManager > xModuleManager( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW ); + Reference< XInterface > xIfac( m_xFrame, UNO_QUERY ); + m_bModuleIdentified = sal_True; m_aModuleIdentifier = xModuleManager->identify( xIfac ); @@ -821,44 +823,57 @@ void ToolBarManager::RemoveControllers() { Reference< XNameAccess > xNameAccess( m_xServiceManager->createInstance( SERVICENAME_UICOMMANDDESCRIPTION ), UNO_QUERY ); if ( xNameAccess.is() ) - { xNameAccess->getByName( m_aModuleIdentifier ) >>= m_xUICommandLabels; - } } } - catch ( Exception& ) + + if ( m_xUICommandLabels.is() ) { + if ( rCmdURL.getLength() > 0 ) + m_xUICommandLabels->getByName( rCmdURL ) >>= aPropSeq; } } + catch ( Exception& ) + { + } - if ( m_xUICommandLabels.is() ) + return aPropSeq; +} + +::rtl::OUString ToolBarManager::RetrieveLabelFromCommand( const ::rtl::OUString& aCmdURL ) +{ + ::rtl::OUString aLabel; + Sequence< PropertyValue > aPropSeq; + + // Retrieve popup menu labels + aPropSeq = GetPropsForCommand( aCmdURL ); + for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) { - try + if ( aPropSeq[i].Name.equalsAscii( "Name" )) { - if ( aCmdURL.getLength() > 0 ) - { - rtl::OUString aStr; - Sequence< PropertyValue > aPropSeq; - if ( m_xUICommandLabels->getByName( aCmdURL ) >>= aPropSeq ) - { - for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) - { - if ( aPropSeq[i].Name.equalsAscii( "Name" )) - { - aPropSeq[i].Value >>= aStr; - break; - } - } - } - aLabel = aStr; - } + aPropSeq[i].Value >>= aLabel; + break; } - catch ( com::sun::star::uno::Exception& ) + } + return aLabel; +} + +sal_Int32 ToolBarManager::RetrievePropertiesFromCommand( const ::rtl::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.equalsAscii( "Properties" )) { + aPropSeq[i].Value >>= nProperties; + break; } } - - return aLabel; + return nProperties; } void ToolBarManager::CreateControllers() @@ -969,8 +984,15 @@ void ToolBarManager::CreateControllers() { MenuDescriptionMap::iterator it = m_aMenuMap.find( nId ); if ( it == m_aMenuMap.end() ) - xController = Reference< XStatusListener >( - new GenericToolbarController( m_xServiceManager, m_xFrame, m_pToolBar, nId, aCommandURL )); + { + xController = Reference< XStatusListener >( + new GenericToolbarController( m_xServiceManager, m_xFrame, m_pToolBar, nId, aCommandURL )); + + // Accessibility support: Set toggle button role for specific commands + sal_Int32 nProps = RetrievePropertiesFromCommand( aCommandURL ); + if ( nProps & UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON ) + m_pToolBar->SetItemBits( nId, m_pToolBar->GetItemBits( nId ) | TIB_CHECKABLE ); + } else xController = Reference< XStatusListener >( new MenuToolbarController( m_xServiceManager, m_xFrame, m_pToolBar, nId, aCommandURL, m_aModuleIdentifier, m_aMenuMap[ nId ] )); -- cgit From 13b8697f854e1f1dc5e8ab06eab04f90bf99d219 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Mon, 10 May 2010 11:12:15 +0200 Subject: fwk142: #i104468# Ensure that focus is set to a floating window created by a toolbar controller --- framework/source/uielement/toolbarmanager.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'framework/source/uielement/toolbarmanager.cxx') diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 8171ff2e5419..9b0ffa9ce993 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -1552,7 +1552,11 @@ IMPL_LINK( ToolBarManager, DropdownClick, ToolBox*, EMPTYARG ) Reference< XToolbarController > xController( pIter->second, UNO_QUERY ); if ( xController.is() ) - xController->createPopupWindow(); + { + Reference< XWindow > xWin = xController->createPopupWindow(); + if ( xWin.is() ) + xWin->setFocus(); + } } return 1; } -- cgit