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
This commit is contained in:
Vladimir Glazounov
2003-10-06 11:57:11 +00:00
parent 5d149be765
commit 2b3dba5313

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: propshlp.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -59,17 +59,12 @@
* *
************************************************************************/ ************************************************************************/
#include "osl/diagnose.h"
#ifndef _CPPUHELPER_IMPLBASE1_HXX #include "cppuhelper/implbase1.hxx"
#include <cppuhelper/implbase1.hxx> #include "cppuhelper/weak.hxx"
#endif #include "cppuhelper/propshlp.hxx"
#include "com/sun/star/beans/PropertyAttribute.hpp"
#include <osl/diagnose.h> #include "com/sun/star/lang/DisposedException.hpp"
#include <cppuhelper/weak.hxx>
#include <cppuhelper/propshlp.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
using namespace osl; using namespace osl;
@@ -178,11 +173,21 @@ sal_Bool OPropertySetHelperInfo_Impl::hasPropertyByName( const OUString & Proper
// class PropertySetHelper // class PropertySetHelper
// ---------------------------------------------------- // ----------------------------------------------------
OPropertySetHelper::OPropertySetHelper( OPropertySetHelper::OPropertySetHelper(
OBroadcastHelper & rBHelper_ ) OBroadcastHelper & rBHelper_ ) SAL_THROW( () )
SAL_THROW( () ) : rBHelper( rBHelper_ ),
: rBHelper( rBHelper_ ) aBoundLC( rBHelper_.rMutex ),
, aBoundLC( rBHelper_.rMutex ) aVetoableLC( 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 // fire the events for all changed properties
for( i = 0; i < nChangesLen; i++ ) for( i = 0; i < nChangesLen; i++ )
{ {
@@ -562,10 +570,42 @@ void OPropertySetHelper::fire
while( aIt.hasMoreElements() ) while( aIt.hasMoreElements() )
{ {
XInterface * pL = aIt.next(); XInterface * pL = aIt.next();
try
{
try
{
if( bVetoable ) // fire change Events? if( bVetoable ) // fire change Events?
((XVetoableChangeListener *)pL)->vetoableChange( pEvts[i] ); {
((XVetoableChangeListener *)pL)->vetoableChange(
pEvts[i] );
}
else else
((XPropertyChangeListener *)pL)->propertyChange( pEvts[i] ); {
((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 // broadcast to all listeners with "" property name
@@ -587,10 +627,42 @@ void OPropertySetHelper::fire
while( aIt.hasMoreElements() ) while( aIt.hasMoreElements() )
{ {
XInterface * pL = aIt.next(); XInterface * pL = aIt.next();
try
{
try
{
if( bVetoable ) // fire change Events? if( bVetoable ) // fire change Events?
((XVetoableChangeListener *)pL)->vetoableChange( pEvts[i] ); {
((XVetoableChangeListener *)pL)->vetoableChange(
pEvts[i] );
}
else else
((XPropertyChangeListener *)pL)->propertyChange( pEvts[i] ); {
((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,10 +682,38 @@ void OPropertySetHelper::fire
OInterfaceIteratorHelper aIt( *pCont ); OInterfaceIteratorHelper aIt( *pCont );
while( aIt.hasMoreElements() ) while( aIt.hasMoreElements() )
{ {
XPropertiesChangeListener * pL = (XPropertiesChangeListener *)aIt.next(); XPropertiesChangeListener * pL =
// fire the hole event sequence to the XPropertiesChangeListener's (XPropertiesChangeListener *)aIt.next();
try
{
try
{
// fire the hole event sequence to the
// XPropertiesChangeListener's
pL->propertiesChange( aEvts ); 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;
}
}
} }
} }
} }