diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2004-08-02 16:43:51 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2004-08-02 16:43:51 +0000 |
commit | c5a0438f67e0e9990a21a6604b7db410c8fe2123 (patch) | |
tree | d3a5ebaa49f862299c0c9fc58fdd8ab3ba392840 /embeddedobj | |
parent | 8980b4f25e1a09db7efde842dada41a5b5653448 (diff) |
INTEGRATION: CWS insight01 (1.5.4); FILE MERGED
2004/06/10 11:27:59 oj 1.5.4.1: embedded obj changes
Diffstat (limited to 'embeddedobj')
-rw-r--r-- | embeddedobj/source/commonembedding/embedobj.cxx | 149 |
1 files changed, 92 insertions, 57 deletions
diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx index 5d2de469a38b..962279919819 100644 --- a/embeddedobj/source/commonembedding/embedobj.cxx +++ b/embeddedobj/source/commonembedding/embedobj.cxx @@ -2,9 +2,9 @@ * * $RCSfile: embedobj.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: hr $ $Date: 2004-05-10 17:51:00 $ + * last change: $Author: hr $ $Date: 2004-08-02 17:43:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -104,6 +104,29 @@ using namespace ::com::sun::star; +#define NOTIFY_LISTERNERS(_rListeners,T,T1,T2,method) \ + uno::Sequence< uno::Reference< uno::XInterface > > aListenerSeq = _rListeners.getElements(); \ + \ + const uno::Reference< uno::XInterface >* pxIntBegin = aListenerSeq.getConstArray(); \ + const uno::Reference< uno::XInterface >* pxInt = pxIntBegin + aListenerSeq.getLength(); \ + \ + _rGuard.clear(); \ + while( pxInt > pxIntBegin ) \ + { \ + try \ + { \ + while( pxInt > pxIntBegin ) \ + { \ + --pxInt; \ + static_cast< T* >( pxInt->get() )->method(aEvt,T1,T2); \ + } \ + } \ + catch( uno::RuntimeException& ) \ + { \ + } \ + } + + //---------------------------------------------- sal_Int32 OCommonEmbeddedObject::ConvertVerbToState_Impl( sal_Int32 nVerb ) { @@ -115,7 +138,7 @@ sal_Int32 OCommonEmbeddedObject::ConvertVerbToState_Impl( sal_Int32 nVerb ) } //---------------------------------------------- -void OCommonEmbeddedObject::StateChangeNotification_Impl( sal_Bool bBeforeChange, sal_Int32 nOldState, sal_Int32 nNewState ) +void OCommonEmbeddedObject::StateChangeNotification_Impl( sal_Bool bBeforeChange, sal_Int32 nOldState, sal_Int32 nNewState ,::osl::ResettableMutexGuard& _rGuard) { if ( m_pInterfaceContainer ) { @@ -123,34 +146,42 @@ void OCommonEmbeddedObject::StateChangeNotification_Impl( sal_Bool bBeforeChange ::getCppuType( ( const uno::Reference< embed::XStateChangeListener >*) NULL ) ); if ( pContainer != NULL ) { - lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) ); - ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); - - while (pIterator.hasMoreElements()) + lang::EventObject aEvt( static_cast< ::cppu::OWeakObject* >( this ) ); + if ( bBeforeChange ) { - if ( bBeforeChange ) - { - try - { - ((embed::XStateChangeListener*)pIterator.next())->changingState( aSource, nOldState, nNewState ); - } - catch( uno::Exception& ) - { - // even if the listener complains ignore it for now - } - } - else - { - try - { - ((embed::XStateChangeListener*)pIterator.next())->stateChanged( aSource, nOldState, nNewState ); - } - catch( uno::Exception& ) - { - // if anything happened it is problem of listener, ignore it - } - } + NOTIFY_LISTERNERS((*pContainer),embed::XStateChangeListener, nOldState, nNewState,changingState); + } + else + { + NOTIFY_LISTERNERS((*pContainer),embed::XStateChangeListener, nOldState, nNewState,stateChanged); } +// ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); + + // while (pIterator.hasMoreElements()) +// { +// if ( bBeforeChange ) +// { +// try +// { +// ((embed::XStateChangeListener*)pIterator.next())->changingState( aSource, nOldState, nNewState ); +// } +// catch( uno::Exception& ) +// { +// // even if the listener complains ignore it for now +// } +// } +// else +// { +// try +// { +// ((embed::XStateChangeListener*)pIterator.next())->stateChanged( aSource, nOldState, nNewState ); +// } +// catch( uno::Exception& ) +// { +// // if anything happened it is problem of listener, ignore it +// } +// } +// } } } } @@ -301,43 +332,47 @@ void SAL_CALL OCommonEmbeddedObject::changeState( sal_Int32 nNewState ) uno::Exception, uno::RuntimeException ) { - ::osl::MutexGuard aGuard( m_aMutex ); - if ( m_bDisposed ) - throw lang::DisposedException(); // TODO + uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ), uno::UNO_QUERY); + { + ::osl::ResettableMutexGuard aGuard( m_aMutex ); + if ( m_bDisposed ) + throw lang::DisposedException(); // TODO - if ( m_nObjectState == -1 ) - throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), - uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) ); + if ( m_nObjectState == -1 ) + throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), + uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) ); - // in case the object is already in requested state - if ( m_nObjectState == nNewState ) - return; + // in case the object is already in requested state + if ( m_nObjectState == nNewState ) + return; - sal_Int32 nOldState = m_nObjectState; + sal_Int32 nOldState = m_nObjectState; - // retrieve sequence of states that should be passed to reach desired state - uno::Sequence< sal_Int32 > aIntermediateStates = GetIntermediateStatesSequence_Impl( nNewState ); + // retrieve sequence of states that should be passed to reach desired state + uno::Sequence< sal_Int32 > aIntermediateStates = GetIntermediateStatesSequence_Impl( nNewState ); - // notify listeners that the object is going to change the state - StateChangeNotification_Impl( sal_True, nOldState, nNewState ); + // notify listeners that the object is going to change the state + StateChangeNotification_Impl( sal_True, nOldState, nNewState,aGuard ); + aGuard.reset(); - try { - for ( sal_Int32 nInd = 0; nInd < aIntermediateStates.getLength(); nInd++ ) - SwitchStateTo_Impl( aIntermediateStates[nInd] ); + try { + for ( sal_Int32 nInd = 0; nInd < aIntermediateStates.getLength(); nInd++ ) + SwitchStateTo_Impl( aIntermediateStates[nInd] ); - SwitchStateTo_Impl( nNewState ); - } - catch( uno::Exception& ) - { - if ( nOldState != m_nObjectState ) - // notify listeners that the object has changed the state - StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState ); + SwitchStateTo_Impl( nNewState ); + } + catch( uno::Exception& ) + { + if ( nOldState != m_nObjectState ) + // notify listeners that the object has changed the state + StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState ,aGuard); - throw; - } + throw; + } - // notify listeners that the object has changed the state - StateChangeNotification_Impl( sal_False, nOldState, nNewState ); + // notify listeners that the object has changed the state + StateChangeNotification_Impl( sal_False, nOldState, nNewState,aGuard ); + } } //---------------------------------------------- |