Tag: cws_src680_oj14 User: fs Date: 2007-06-06 06:03:22+0000 Log: #i78077# allow for disposals, to release all references
File Changes: Directory: /dba/connectivity/source/commontools/ ================================================ File [changed]: paramwrapper.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/commontools/paramwrapper.cxx?r1=1.1.2.4&r2=1.1.2.5 Delta lines: +64 -7 -------------------- --- paramwrapper.cxx 2007-06-05 09:11:57+0000 1.1.2.4 +++ paramwrapper.cxx 2007-06-06 06:03:20+0000 1.1.2.5 @@ -4,9 +4,9 @@ * * $RCSfile: paramwrapper.cxx,v $ * - * $Revision: 1.1.2.4 $ + * $Revision: 1.1.2.5 $ * - * last change: $Author: oj $ $Date: 2007/06/05 09:11:57 $ + * last change: $Author: fs $ $Date: 2007/06/06 06:03:20 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -50,6 +50,9 @@ #ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_ #include <com/sun/star/sdb/XParametersSupplier.hpp> #endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif /** === end UNO includes === **/ #include <tools/diagnose_ex.h> @@ -87,6 +90,7 @@ using ::com::sun::star::container::XEnumeration; using ::com::sun::star::sdb::XSingleSelectQueryAnalyzer; using ::com::sun::star::sdb::XParametersSupplier; + using ::com::sun::star::lang::DisposedException; /** === end UNO using === **/ namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; namespace DataType = ::com::sun::star::sdbc::DataType; @@ -96,7 +100,7 @@ //==================================================================== //-------------------------------------------------------------------- ParameterWrapper::ParameterWrapper( const Reference< XPropertySet >& _rxColumn ) - :OPropertySetHelper( m_aBHelper ) + :PropertyBase( m_aBHelper ) ,m_xDelegator( _rxColumn ) { if ( m_xDelegator.is() ) @@ -108,7 +112,7 @@ //-------------------------------------------------------------------- ParameterWrapper::ParameterWrapper( const Reference< XPropertySet >& _rxColumn, const Reference< XParameters >& _rxAllParameters, const ::std::vector< sal_Int32 >& _rIndexes ) - :OPropertySetHelper( m_aBHelper ) + :PropertyBase( m_aBHelper ) ,m_aIndexes( _rIndexes ) ,m_xDelegator( _rxColumn ) ,m_xValueDestination( _rxAllParameters ) @@ -127,13 +131,13 @@ } //-------------------------------------------------------------------- - IMPLEMENT_FORWARD_XINTERFACE2( ParameterWrapper, OWeakObject, OPropertySetHelper ) + IMPLEMENT_FORWARD_XINTERFACE2( ParameterWrapper, UnoBase, PropertyBase ) //-------------------------------------------------------------------- Sequence< Type > SAL_CALL ParameterWrapper::getTypes( ) throw(RuntimeException) { Sequence< Type > aTypes( 4 ); - aTypes[ 0 ] = ::getCppuType( static_cast< Reference< XWeak >* >( NULL ) ); + aTypes[ 1 ] = ::getCppuType( static_cast< Reference< XWeak >* >( NULL ) ); aTypes[ 1 ] = ::getCppuType( static_cast< Reference< XPropertySet >* >( NULL ) ); aTypes[ 2 ] = ::getCppuType( static_cast< Reference< XFastPropertySet >* >( NULL ) ); aTypes[ 3 ] = ::getCppuType( static_cast< Reference< XMultiPropertySet >* >( NULL ) ); @@ -261,16 +265,32 @@ } } + //-------------------------------------------------------------------- + void SAL_CALL ParameterWrapper::dispose() + { + ::osl::MutexGuard aGuard( m_aMutex ); + + m_aValue.setNull(); + m_aIndexes.resize(0); + m_xDelegator.clear(); + m_xDelegatorPSI.clear(); + m_xValueDestination.clear(); + + m_aBHelper.bDisposed = sal_True; + } + //==================================================================== //= ParameterWrapperContainer //==================================================================== //-------------------------------------------------------------------- ParameterWrapperContainer::ParameterWrapperContainer() + :ParameterWrapperContainer_Base( m_aMutex ) { } //-------------------------------------------------------------------- ParameterWrapperContainer::ParameterWrapperContainer( const Reference< XSingleSelectQueryAnalyzer >& _rxComposer ) + :ParameterWrapperContainer_Base( m_aMutex ) { Reference< XParametersSupplier > xSuppParams( _rxComposer, UNO_QUERY_THROW ); Reference< XIndexAccess > xParameters( xSuppParams->getParameters(), UNO_QUERY_THROW ); @@ -283,26 +303,40 @@ } //-------------------------------------------------------------------- + ParameterWrapperContainer::~ParameterWrapperContainer() + { + } + + //-------------------------------------------------------------------- Type SAL_CALL ParameterWrapperContainer::getElementType() throw( RuntimeException ) { + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); return ::getCppuType( static_cast< Reference< XPropertySet >* >( NULL ) ); } //-------------------------------------------------------------------- sal_Bool SAL_CALL ParameterWrapperContainer::hasElements() throw( RuntimeException ) { + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); return !m_aParameters.empty(); } //-------------------------------------------------------------------- sal_Int32 SAL_CALL ParameterWrapperContainer::getCount() throw( RuntimeException ) { + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); return m_aParameters.size(); } //-------------------------------------------------------------------- Any SAL_CALL ParameterWrapperContainer::getByIndex( sal_Int32 _nIndex ) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException ) { + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + if ( ( _nIndex < 0 ) || ( _nIndex >= (sal_Int32)m_aParameters.size() ) ) throw IndexOutOfBoundsException(); @@ -312,12 +346,35 @@ //-------------------------------------------------------------------- Reference< XEnumeration > ParameterWrapperContainer::createEnumeration() throw( RuntimeException ) { + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + return new ::comphelper::OEnumerationByIndex( static_cast< XIndexAccess* >( this ) ); } //-------------------------------------------------------------------- - ParameterWrapperContainer::~ParameterWrapperContainer() + void ParameterWrapperContainer::impl_checkDisposed_throw() { + if ( rBHelper.bDisposed ) + throw DisposedException( ::rtl::OUString(), *this ); + } + + //-------------------------------------------------------------------- + void SAL_CALL ParameterWrapperContainer::disposing() + { + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + for ( Parameters::const_iterator param = m_aParameters.begin(); + param != m_aParameters.end(); + ++param + ) + { + (*param)->dispose(); + } + + Parameters aEmpty; + m_aParameters.swap( aEmpty ); } //........................................................................ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
