diff options
author | Oliver Bolte <obo@openoffice.org> | 2004-08-11 16:22:37 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2004-08-11 16:22:37 +0000 |
commit | a2bbbc5130b8042e72fd3f593da04b1ff1c73d1e (patch) | |
tree | 00f2d91b3d94c0182bfc6511c36e03bc104f4cce /framework | |
parent | 0ffabd6da8ae6bdd9205b8ebc850e9d2fbf09138 (diff) |
INTEGRATION: CWS docking3 (1.2.26); FILE MERGED
2004/07/22 07:38:07 cd 1.2.26.1: #i31831# Generic toolbar controller must execute dispatch asynchronously to keep toolbar responsive
Diffstat (limited to 'framework')
-rw-r--r-- | framework/source/uielement/generictoolbarcontroller.cxx | 73 |
1 files changed, 71 insertions, 2 deletions
diff --git a/framework/source/uielement/generictoolbarcontroller.cxx b/framework/source/uielement/generictoolbarcontroller.cxx index 5655ca7ca754..755b07856619 100644 --- a/framework/source/uielement/generictoolbarcontroller.cxx +++ b/framework/source/uielement/generictoolbarcontroller.cxx @@ -2,9 +2,9 @@ * * $RCSfile: generictoolbarcontroller.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: obo $ $Date: 2004-07-06 17:00:58 $ + * last change: $Author: obo $ $Date: 2004-08-11 17:22:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -120,6 +120,13 @@ using namespace ::com::sun::star::util; namespace framework { +struct ExecuteInfo +{ + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch; + ::com::sun::star::util::URL aTargetURL; + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs; +}; + GenericToolbarController::GenericToolbarController( const Reference< XMultiServiceFactory >& rServiceManager, const Reference< XFrame >& rFrame, ToolBar* pToolbar, @@ -146,6 +153,52 @@ throw ( RuntimeException ) m_nID = 0; } +void SAL_CALL GenericToolbarController::execute( sal_Int16 KeyModifier ) +throw ( RuntimeException ) +{ + Reference< XDispatch > xDispatch; + Reference< XURLTransformer > xURLTransformer; + OUString aCommandURL; + + { + vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); + + if ( m_bDisposed ) + throw DisposedException(); + + if ( m_bInitialized && + m_xFrame.is() && + m_xServiceManager.is() && + m_aCommandURL.getLength() ) + { + xURLTransformer = Reference< XURLTransformer >( m_xServiceManager->createInstance( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), + UNO_QUERY ); + + aCommandURL = m_aCommandURL; + URLToDispatchMap::iterator pIter = m_aListenerMap.find( m_aCommandURL ); + if ( pIter != m_aListenerMap.end() ) + xDispatch = pIter->second; + } + } + + if ( xDispatch.is() && xURLTransformer.is() ) + { + com::sun::star::util::URL aTargetURL; + Sequence<PropertyValue> aArgs; + + aTargetURL.Complete = aCommandURL; + xURLTransformer->parseStrict( aTargetURL ); + + // Execute dispatch asynchronously + ExecuteInfo* pExecuteInfo = new ExecuteInfo; + pExecuteInfo->xDispatch = xDispatch; + pExecuteInfo->aTargetURL = aTargetURL; + pExecuteInfo->aArgs = aArgs; + Application::PostUserEvent( STATIC_LINK(0, GenericToolbarController , ExecuteHdl_Impl), pExecuteInfo ); + } +} + void GenericToolbarController::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException ) { @@ -190,4 +243,20 @@ throw ( RuntimeException ) } } +IMPL_STATIC_LINK( GenericToolbarController, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo ) +{ + try + { + // Asynchronous execution as this can lead to our own destruction! + // Framework can recycle our current frame and the layout manager disposes all user interface + // elements if a component gets detached from its frame! + pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs ); + } + catch ( Exception& ) + { + } + delete pExecuteInfo; + return 0; +} + } // namespace |