diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2003-10-06 11:57:11 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2003-10-06 11:57:11 +0000 |
commit | 2b3dba53134469232a639f8b798f597fe5764a87 (patch) | |
tree | cfd2b11cf6b5353d4a80a8beaf34c457f24ed9ef /cppuhelper/source | |
parent | 5d149be765002e68ed7b9b302108b6c284aae018 (diff) |
INTEGRATION: CWS unopkg (1.10.14); FILE MERGED
2003/09/29 13:56:46 dbo 1.10.14.3: #112359#
2003/09/29 09:41:43 dbo 1.10.14.2: #112359# OPropertySetHelper( ..., bool ignore_exceptions_while_firing )
2003/09/26 09:24:27 dbo 1.10.14.1: #112359# catching DisposedExceptions
Diffstat (limited to 'cppuhelper/source')
-rw-r--r-- | cppuhelper/source/propshlp.cxx | 158 |
1 files changed, 129 insertions, 29 deletions
diff --git a/cppuhelper/source/propshlp.cxx b/cppuhelper/source/propshlp.cxx index 48c8d601fba6..bd7e4a47b551 100644 --- a/cppuhelper/source/propshlp.cxx +++ b/cppuhelper/source/propshlp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: propshlp.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: hr $ $Date: 2003-07-16 17:52:32 $ + * last change: $Author: vg $ $Date: 2003-10-06 12:57:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,17 +59,12 @@ * ************************************************************************/ - -#ifndef _CPPUHELPER_IMPLBASE1_HXX -#include <cppuhelper/implbase1.hxx> -#endif - -#include <osl/diagnose.h> - -#include <cppuhelper/weak.hxx> -#include <cppuhelper/propshlp.hxx> - -#include <com/sun/star/beans/PropertyAttribute.hpp> +#include "osl/diagnose.h" +#include "cppuhelper/implbase1.hxx" +#include "cppuhelper/weak.hxx" +#include "cppuhelper/propshlp.hxx" +#include "com/sun/star/beans/PropertyAttribute.hpp" +#include "com/sun/star/lang/DisposedException.hpp" using namespace osl; @@ -178,11 +173,21 @@ sal_Bool OPropertySetHelperInfo_Impl::hasPropertyByName( const OUString & Proper // class PropertySetHelper // ---------------------------------------------------- OPropertySetHelper::OPropertySetHelper( - OBroadcastHelper & rBHelper_ ) - SAL_THROW( () ) - : rBHelper( rBHelper_ ) - , aBoundLC( rBHelper_.rMutex ) - , aVetoableLC( rBHelper_.rMutex ) + OBroadcastHelper & rBHelper_ ) SAL_THROW( () ) + : rBHelper( rBHelper_ ), + aBoundLC( rBHelper_.rMutex ), + aVetoableLC( rBHelper_.rMutex ), + m_pReserved( 0 ) +{ +} + +OPropertySetHelper::OPropertySetHelper( + OBroadcastHelper & rBHelper_, bool bIgnoreRuntimeExceptionsWhileFiring ) + : rBHelper( rBHelper_ ), + aBoundLC( rBHelper_.rMutex ), + aVetoableLC( rBHelper_.rMutex ), + m_pReserved( reinterpret_cast< void * >( + bIgnoreRuntimeExceptionsWhileFiring ? 1 : 0 ) ) { } @@ -546,6 +551,9 @@ void OPropertySetHelper::fire } } + bool bIgnoreRuntimeExceptionsWhileFiring = + (m_pReserved == reinterpret_cast< void const * >(1)); + // fire the events for all changed properties for( i = 0; i < nChangesLen; i++ ) { @@ -562,10 +570,42 @@ void OPropertySetHelper::fire while( aIt.hasMoreElements() ) { XInterface * pL = aIt.next(); - if( bVetoable ) // fire change Events? - ((XVetoableChangeListener *)pL)->vetoableChange( pEvts[i] ); - else - ((XPropertyChangeListener *)pL)->propertyChange( pEvts[i] ); + try + { + try + { + if( bVetoable ) // fire change Events? + { + ((XVetoableChangeListener *)pL)->vetoableChange( + pEvts[i] ); + } + else + { + ((XPropertyChangeListener *)pL)->propertyChange( + pEvts[i] ); + } + } + catch (DisposedException & exc) + { + OSL_ENSURE( exc.Context.is(), + "DisposedException without Context!" ); + if (exc.Context == pL) + aIt.remove(); + else + throw; + } + } + catch (RuntimeException & exc) + { + OSL_TRACE( + OUStringToOString( + OUString( RTL_CONSTASCII_USTRINGPARAM( + "caught RuntimeException while " + "firing listeners: ") ) + + exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); + if (! bIgnoreRuntimeExceptionsWhileFiring) + throw; + } } } // broadcast to all listeners with "" property name @@ -587,10 +627,42 @@ void OPropertySetHelper::fire while( aIt.hasMoreElements() ) { XInterface * pL = aIt.next(); - if( bVetoable ) // fire change Events? - ((XVetoableChangeListener *)pL)->vetoableChange( pEvts[i] ); - else - ((XPropertyChangeListener *)pL)->propertyChange( pEvts[i] ); + try + { + try + { + if( bVetoable ) // fire change Events? + { + ((XVetoableChangeListener *)pL)->vetoableChange( + pEvts[i] ); + } + else + { + ((XPropertyChangeListener *)pL)->propertyChange( + pEvts[i] ); + } + } + catch (DisposedException & exc) + { + OSL_ENSURE( exc.Context.is(), + "DisposedException without Context!" ); + if (exc.Context == pL) + aIt.remove(); + else + throw; + } + } + catch (RuntimeException & exc) + { + OSL_TRACE( + OUStringToOString( + OUString( RTL_CONSTASCII_USTRINGPARAM( + "caught RuntimeException while " + "firing listeners: ") ) + + exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); + if (! bIgnoreRuntimeExceptionsWhileFiring) + throw; + } } } } @@ -610,9 +682,37 @@ void OPropertySetHelper::fire OInterfaceIteratorHelper aIt( *pCont ); while( aIt.hasMoreElements() ) { - XPropertiesChangeListener * pL = (XPropertiesChangeListener *)aIt.next(); - // fire the hole event sequence to the XPropertiesChangeListener's - pL->propertiesChange( aEvts ); + XPropertiesChangeListener * pL = + (XPropertiesChangeListener *)aIt.next(); + try + { + try + { + // fire the hole event sequence to the + // XPropertiesChangeListener's + pL->propertiesChange( aEvts ); + } + catch (DisposedException & exc) + { + OSL_ENSURE( exc.Context.is(), + "DisposedException without Context!" ); + if (exc.Context == pL) + aIt.remove(); + else + throw; + } + } + catch (RuntimeException & exc) + { + OSL_TRACE( + OUStringToOString( + OUString( RTL_CONSTASCII_USTRINGPARAM( + "caught RuntimeException while " + "firing listeners: ") ) + + exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); + if (! bIgnoreRuntimeExceptionsWhileFiring) + throw; + } } } } |