1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
28*cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
29*cdf0e10cSrcweir #include <connectivity/paramwrapper.hxx>
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir /** === begin UNO includes === **/
32*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/lang/WrappedTargetException.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/sdb/XParametersSupplier.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
37*cdf0e10cSrcweir /** === end UNO includes === **/
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include <tools/diagnose_ex.h>
40*cdf0e10cSrcweir #include <comphelper/enumhelper.hxx>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #define PROPERTY_ID_VALUE   1000
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir //........................................................................
45*cdf0e10cSrcweir namespace dbtools
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir namespace param
48*cdf0e10cSrcweir {
49*cdf0e10cSrcweir //........................................................................
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir     /** === begin UNO using === **/
52*cdf0e10cSrcweir     using ::com::sun::star::uno::Reference;
53*cdf0e10cSrcweir     using ::com::sun::star::beans::XPropertySet;
54*cdf0e10cSrcweir     using ::com::sun::star::sdbc::XParameters;
55*cdf0e10cSrcweir     using ::com::sun::star::uno::Sequence;
56*cdf0e10cSrcweir     using ::com::sun::star::uno::Type;
57*cdf0e10cSrcweir     using ::com::sun::star::uno::RuntimeException;
58*cdf0e10cSrcweir     using ::com::sun::star::uno::XWeak;
59*cdf0e10cSrcweir     using ::com::sun::star::beans::XPropertySet;
60*cdf0e10cSrcweir     using ::com::sun::star::beans::XFastPropertySet;
61*cdf0e10cSrcweir     using ::com::sun::star::beans::XMultiPropertySet;
62*cdf0e10cSrcweir     using ::com::sun::star::beans::XPropertySetInfo;
63*cdf0e10cSrcweir     using ::com::sun::star::beans::Property;
64*cdf0e10cSrcweir     using ::com::sun::star::uno::Exception;
65*cdf0e10cSrcweir     using ::com::sun::star::uno::UNO_QUERY_THROW;
66*cdf0e10cSrcweir     using ::com::sun::star::uno::Any;
67*cdf0e10cSrcweir     using ::com::sun::star::lang::IllegalArgumentException;
68*cdf0e10cSrcweir     using ::com::sun::star::sdbc::SQLException;
69*cdf0e10cSrcweir     using ::com::sun::star::lang::WrappedTargetException;
70*cdf0e10cSrcweir     using ::com::sun::star::lang::IndexOutOfBoundsException;
71*cdf0e10cSrcweir     using ::com::sun::star::container::XEnumeration;
72*cdf0e10cSrcweir     using ::com::sun::star::sdb::XSingleSelectQueryAnalyzer;
73*cdf0e10cSrcweir     using ::com::sun::star::sdb::XParametersSupplier;
74*cdf0e10cSrcweir     using ::com::sun::star::lang::DisposedException;
75*cdf0e10cSrcweir     /** === end UNO using === **/
76*cdf0e10cSrcweir     namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
77*cdf0e10cSrcweir     namespace DataType = ::com::sun::star::sdbc::DataType;
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir     //====================================================================
80*cdf0e10cSrcweir     //= ParameterWrapper
81*cdf0e10cSrcweir     //====================================================================
82*cdf0e10cSrcweir     //--------------------------------------------------------------------
83*cdf0e10cSrcweir     ParameterWrapper::ParameterWrapper( const Reference< XPropertySet >& _rxColumn )
84*cdf0e10cSrcweir         :PropertyBase( m_aBHelper )
85*cdf0e10cSrcweir         ,m_xDelegator( _rxColumn )
86*cdf0e10cSrcweir     {
87*cdf0e10cSrcweir         if ( m_xDelegator.is() )
88*cdf0e10cSrcweir             m_xDelegatorPSI = m_xDelegator->getPropertySetInfo();
89*cdf0e10cSrcweir         if ( !m_xDelegatorPSI.is() )
90*cdf0e10cSrcweir             throw RuntimeException();
91*cdf0e10cSrcweir     }
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     //--------------------------------------------------------------------
94*cdf0e10cSrcweir     ParameterWrapper::ParameterWrapper( const Reference< XPropertySet >& _rxColumn,
95*cdf0e10cSrcweir             const Reference< XParameters >& _rxAllParameters, const ::std::vector< sal_Int32 >& _rIndexes )
96*cdf0e10cSrcweir         :PropertyBase( m_aBHelper )
97*cdf0e10cSrcweir         ,m_aIndexes( _rIndexes )
98*cdf0e10cSrcweir         ,m_xDelegator( _rxColumn )
99*cdf0e10cSrcweir         ,m_xValueDestination( _rxAllParameters )
100*cdf0e10cSrcweir     {
101*cdf0e10cSrcweir         if ( m_xDelegator.is() )
102*cdf0e10cSrcweir             m_xDelegatorPSI = m_xDelegator->getPropertySetInfo();
103*cdf0e10cSrcweir         if ( !m_xDelegatorPSI.is() )
104*cdf0e10cSrcweir             throw RuntimeException();
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir         OSL_ENSURE( !m_aIndexes.empty(), "ParameterWrapper::ParameterWrapper: sure about the indexes?" );
107*cdf0e10cSrcweir     }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     //--------------------------------------------------------------------
110*cdf0e10cSrcweir     ParameterWrapper::~ParameterWrapper()
111*cdf0e10cSrcweir     {
112*cdf0e10cSrcweir     }
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir     //--------------------------------------------------------------------
115*cdf0e10cSrcweir     IMPLEMENT_FORWARD_XINTERFACE2( ParameterWrapper, UnoBase, PropertyBase )
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir     //--------------------------------------------------------------------
118*cdf0e10cSrcweir     Sequence< Type > SAL_CALL ParameterWrapper::getTypes(   ) throw(RuntimeException)
119*cdf0e10cSrcweir     {
120*cdf0e10cSrcweir         Sequence< Type > aTypes( 4 );
121*cdf0e10cSrcweir         aTypes[ 1 ] = ::getCppuType( static_cast< Reference< XWeak >*             >( NULL ) );
122*cdf0e10cSrcweir         aTypes[ 1 ] = ::getCppuType( static_cast< Reference< XPropertySet >*      >( NULL ) );
123*cdf0e10cSrcweir         aTypes[ 2 ] = ::getCppuType( static_cast< Reference< XFastPropertySet >*  >( NULL ) );
124*cdf0e10cSrcweir         aTypes[ 3 ] = ::getCppuType( static_cast< Reference< XMultiPropertySet >* >( NULL ) );
125*cdf0e10cSrcweir         return aTypes;
126*cdf0e10cSrcweir     }
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     //--------------------------------------------------------------------
129*cdf0e10cSrcweir     IMPLEMENT_GET_IMPLEMENTATION_ID( ParameterWrapper )
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir     //--------------------------------------------------------------------
132*cdf0e10cSrcweir     ::rtl::OUString ParameterWrapper::impl_getPseudoAggregatePropertyName( sal_Int32 _nHandle ) const
133*cdf0e10cSrcweir     {
134*cdf0e10cSrcweir         Reference< XPropertySetInfo >  xInfo = const_cast<ParameterWrapper*>( this )->getPropertySetInfo();
135*cdf0e10cSrcweir         Sequence< Property > aProperties = xInfo->getProperties();
136*cdf0e10cSrcweir         const Property* pProperties = aProperties.getConstArray();
137*cdf0e10cSrcweir         for ( sal_Int32 i = 0; i < aProperties.getLength(); ++i, ++pProperties )
138*cdf0e10cSrcweir         {
139*cdf0e10cSrcweir             if ( pProperties->Handle == _nHandle )
140*cdf0e10cSrcweir                 return pProperties->Name;
141*cdf0e10cSrcweir         }
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir         OSL_ENSURE( sal_False, "ParameterWrapper::impl_getPseudoAggregatePropertyName: invalid argument!" );
144*cdf0e10cSrcweir         return ::rtl::OUString();
145*cdf0e10cSrcweir     }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir     //--------------------------------------------------------------------
148*cdf0e10cSrcweir     Reference< XPropertySetInfo > ParameterWrapper::getPropertySetInfo() throw( RuntimeException )
149*cdf0e10cSrcweir     {
150*cdf0e10cSrcweir         return createPropertySetInfo( getInfoHelper() );
151*cdf0e10cSrcweir     }
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir     //--------------------------------------------------------------------
154*cdf0e10cSrcweir     ::cppu::IPropertyArrayHelper& ParameterWrapper::getInfoHelper()
155*cdf0e10cSrcweir     {
156*cdf0e10cSrcweir         if ( !m_pInfoHelper.get() )
157*cdf0e10cSrcweir         {
158*cdf0e10cSrcweir             Sequence< Property > aProperties;
159*cdf0e10cSrcweir             try
160*cdf0e10cSrcweir             {
161*cdf0e10cSrcweir                 aProperties = m_xDelegatorPSI->getProperties();
162*cdf0e10cSrcweir                 sal_Int32 nProperties( aProperties.getLength() );
163*cdf0e10cSrcweir                 aProperties.realloc( nProperties + 1 );
164*cdf0e10cSrcweir                 aProperties[ nProperties ] = Property(
165*cdf0e10cSrcweir                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Value" ) ),
166*cdf0e10cSrcweir                     PROPERTY_ID_VALUE,
167*cdf0e10cSrcweir                     ::cppu::UnoType< Any >::get(),
168*cdf0e10cSrcweir                     PropertyAttribute::TRANSIENT | PropertyAttribute::MAYBEVOID
169*cdf0e10cSrcweir                 );
170*cdf0e10cSrcweir             }
171*cdf0e10cSrcweir             catch( const Exception& )
172*cdf0e10cSrcweir             {
173*cdf0e10cSrcweir                 DBG_UNHANDLED_EXCEPTION();
174*cdf0e10cSrcweir             }
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir             m_pInfoHelper.reset( new ::cppu::OPropertyArrayHelper( aProperties, false ) );
177*cdf0e10cSrcweir         }
178*cdf0e10cSrcweir         return *m_pInfoHelper;
179*cdf0e10cSrcweir     }
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir     //--------------------------------------------------------------------
182*cdf0e10cSrcweir     sal_Bool ParameterWrapper::convertFastPropertyValue(Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue) throw( IllegalArgumentException )
183*cdf0e10cSrcweir     {
184*cdf0e10cSrcweir         OSL_ENSURE( PROPERTY_ID_VALUE == nHandle, "ParameterWrapper::convertFastPropertyValue: the only non-readonly prop should be our PROPERTY_VALUE!" );
185*cdf0e10cSrcweir         (void)nHandle;
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir         // we're lazy here ...
188*cdf0e10cSrcweir         rOldValue = m_aValue.makeAny();
189*cdf0e10cSrcweir         rConvertedValue = rValue;
190*cdf0e10cSrcweir         return sal_True;    // assume "modified" ...
191*cdf0e10cSrcweir     }
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir     //--------------------------------------------------------------------
194*cdf0e10cSrcweir     void ParameterWrapper::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw( Exception )
195*cdf0e10cSrcweir     {
196*cdf0e10cSrcweir         if ( nHandle == PROPERTY_ID_VALUE )
197*cdf0e10cSrcweir         {
198*cdf0e10cSrcweir             try
199*cdf0e10cSrcweir             {
200*cdf0e10cSrcweir                 // TODO : aParamType & nScale can be obtained within the constructor ....
201*cdf0e10cSrcweir                 sal_Int32 nParamType = DataType::VARCHAR;
202*cdf0e10cSrcweir                 OSL_VERIFY( m_xDelegator->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Type" ) ) ) >>= nParamType );
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir                 sal_Int32 nScale = 0;
205*cdf0e10cSrcweir                 if ( m_xDelegatorPSI->hasPropertyByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Scale" ) ) ) )
206*cdf0e10cSrcweir                     OSL_VERIFY( m_xDelegator->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Scale" ) ) ) >>= nScale );
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir                 if ( m_xValueDestination.is() )
209*cdf0e10cSrcweir                 {
210*cdf0e10cSrcweir                     for ( ::std::vector< sal_Int32 >::iterator aIter = m_aIndexes.begin(); aIter != m_aIndexes.end(); ++aIter )
211*cdf0e10cSrcweir                     {
212*cdf0e10cSrcweir                         m_xValueDestination->setObjectWithInfo( *aIter + 1, rValue, nParamType, nScale );
213*cdf0e10cSrcweir                             // (the index of the parameters is one-based)
214*cdf0e10cSrcweir                     }
215*cdf0e10cSrcweir                 }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir                 m_aValue = rValue;
218*cdf0e10cSrcweir             }
219*cdf0e10cSrcweir             catch( SQLException& e )
220*cdf0e10cSrcweir             {
221*cdf0e10cSrcweir                 WrappedTargetException aExceptionWrapper;
222*cdf0e10cSrcweir                 aExceptionWrapper.Context = e.Context;
223*cdf0e10cSrcweir                 aExceptionWrapper.Message = e.Message;
224*cdf0e10cSrcweir                 aExceptionWrapper.TargetException <<= e;
225*cdf0e10cSrcweir                 throw WrappedTargetException( aExceptionWrapper );
226*cdf0e10cSrcweir             }
227*cdf0e10cSrcweir         }
228*cdf0e10cSrcweir         else
229*cdf0e10cSrcweir         {
230*cdf0e10cSrcweir             ::rtl::OUString aName = impl_getPseudoAggregatePropertyName( nHandle );
231*cdf0e10cSrcweir             m_xDelegator->setPropertyValue( aName, rValue );
232*cdf0e10cSrcweir         }
233*cdf0e10cSrcweir     }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir     //--------------------------------------------------------------------
236*cdf0e10cSrcweir     void ParameterWrapper::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
237*cdf0e10cSrcweir     {
238*cdf0e10cSrcweir         if ( nHandle == PROPERTY_ID_VALUE )
239*cdf0e10cSrcweir         {
240*cdf0e10cSrcweir             rValue = m_aValue.makeAny();
241*cdf0e10cSrcweir         }
242*cdf0e10cSrcweir         else
243*cdf0e10cSrcweir         {
244*cdf0e10cSrcweir             ::rtl::OUString aName = impl_getPseudoAggregatePropertyName( nHandle );
245*cdf0e10cSrcweir             rValue = m_xDelegator->getPropertyValue( aName );
246*cdf0e10cSrcweir         }
247*cdf0e10cSrcweir     }
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir     //--------------------------------------------------------------------
250*cdf0e10cSrcweir     void SAL_CALL ParameterWrapper::dispose()
251*cdf0e10cSrcweir     {
252*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir         m_aValue.setNull();
255*cdf0e10cSrcweir         m_aIndexes.resize(0);
256*cdf0e10cSrcweir         m_xDelegator.clear();
257*cdf0e10cSrcweir         m_xDelegatorPSI.clear();
258*cdf0e10cSrcweir         m_xValueDestination.clear();
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir         m_aBHelper.bDisposed = sal_True;
261*cdf0e10cSrcweir     }
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir     //====================================================================
264*cdf0e10cSrcweir     //= ParameterWrapperContainer
265*cdf0e10cSrcweir     //====================================================================
266*cdf0e10cSrcweir     //--------------------------------------------------------------------
267*cdf0e10cSrcweir     ParameterWrapperContainer::ParameterWrapperContainer()
268*cdf0e10cSrcweir         :ParameterWrapperContainer_Base( m_aMutex )
269*cdf0e10cSrcweir     {
270*cdf0e10cSrcweir     }
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir     //--------------------------------------------------------------------
273*cdf0e10cSrcweir     ParameterWrapperContainer::ParameterWrapperContainer( const Reference< XSingleSelectQueryAnalyzer >& _rxComposer )
274*cdf0e10cSrcweir         :ParameterWrapperContainer_Base( m_aMutex )
275*cdf0e10cSrcweir     {
276*cdf0e10cSrcweir         Reference< XParametersSupplier > xSuppParams( _rxComposer, UNO_QUERY_THROW );
277*cdf0e10cSrcweir         Reference< XIndexAccess > xParameters( xSuppParams->getParameters(), UNO_QUERY_THROW );
278*cdf0e10cSrcweir         sal_Int32 nParamCount( xParameters->getCount() );
279*cdf0e10cSrcweir         m_aParameters.reserve( nParamCount );
280*cdf0e10cSrcweir         for ( sal_Int32 i=0; i<nParamCount; ++i )
281*cdf0e10cSrcweir         {
282*cdf0e10cSrcweir             m_aParameters.push_back( new ParameterWrapper( Reference< XPropertySet >( xParameters->getByIndex( i ), UNO_QUERY_THROW ) ) );
283*cdf0e10cSrcweir         }
284*cdf0e10cSrcweir     }
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir     //--------------------------------------------------------------------
287*cdf0e10cSrcweir     ParameterWrapperContainer::~ParameterWrapperContainer()
288*cdf0e10cSrcweir     {
289*cdf0e10cSrcweir     }
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir     //--------------------------------------------------------------------
292*cdf0e10cSrcweir     Type SAL_CALL ParameterWrapperContainer::getElementType() throw( RuntimeException )
293*cdf0e10cSrcweir     {
294*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
295*cdf0e10cSrcweir         impl_checkDisposed_throw();
296*cdf0e10cSrcweir         return ::getCppuType( static_cast< Reference< XPropertySet >* >( NULL ) );
297*cdf0e10cSrcweir     }
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir     //--------------------------------------------------------------------
300*cdf0e10cSrcweir     sal_Bool SAL_CALL ParameterWrapperContainer::hasElements() throw( RuntimeException )
301*cdf0e10cSrcweir     {
302*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
303*cdf0e10cSrcweir         impl_checkDisposed_throw();
304*cdf0e10cSrcweir         return !m_aParameters.empty();
305*cdf0e10cSrcweir     }
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir     //--------------------------------------------------------------------
308*cdf0e10cSrcweir     sal_Int32 SAL_CALL ParameterWrapperContainer::getCount() throw( RuntimeException )
309*cdf0e10cSrcweir     {
310*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
311*cdf0e10cSrcweir         impl_checkDisposed_throw();
312*cdf0e10cSrcweir         return m_aParameters.size();
313*cdf0e10cSrcweir     }
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir     //--------------------------------------------------------------------
316*cdf0e10cSrcweir     Any SAL_CALL ParameterWrapperContainer::getByIndex( sal_Int32 _nIndex ) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
317*cdf0e10cSrcweir     {
318*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
319*cdf0e10cSrcweir         impl_checkDisposed_throw();
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir         if ( ( _nIndex < 0 ) || ( _nIndex >= (sal_Int32)m_aParameters.size() ) )
322*cdf0e10cSrcweir             throw IndexOutOfBoundsException();
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir         return makeAny( Reference< XPropertySet >( m_aParameters[ _nIndex ].get() ) );
325*cdf0e10cSrcweir     }
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir     //--------------------------------------------------------------------
328*cdf0e10cSrcweir     Reference< XEnumeration > ParameterWrapperContainer::createEnumeration() throw( RuntimeException )
329*cdf0e10cSrcweir     {
330*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
331*cdf0e10cSrcweir         impl_checkDisposed_throw();
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir         return new ::comphelper::OEnumerationByIndex( static_cast< XIndexAccess* >( this ) );
334*cdf0e10cSrcweir     }
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir     //--------------------------------------------------------------------
337*cdf0e10cSrcweir     void ParameterWrapperContainer::impl_checkDisposed_throw()
338*cdf0e10cSrcweir     {
339*cdf0e10cSrcweir         if ( rBHelper.bDisposed )
340*cdf0e10cSrcweir             throw DisposedException( ::rtl::OUString(), *this );
341*cdf0e10cSrcweir     }
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir     //--------------------------------------------------------------------
344*cdf0e10cSrcweir     void SAL_CALL ParameterWrapperContainer::disposing()
345*cdf0e10cSrcweir     {
346*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
347*cdf0e10cSrcweir         impl_checkDisposed_throw();
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir         for (   Parameters::const_iterator param = m_aParameters.begin();
350*cdf0e10cSrcweir                 param != m_aParameters.end();
351*cdf0e10cSrcweir                 ++param
352*cdf0e10cSrcweir             )
353*cdf0e10cSrcweir         {
354*cdf0e10cSrcweir             (*param)->dispose();
355*cdf0e10cSrcweir         }
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir         Parameters aEmpty;
358*cdf0e10cSrcweir         m_aParameters.swap( aEmpty );
359*cdf0e10cSrcweir     }
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir //........................................................................
362*cdf0e10cSrcweir } } // namespace dbtools::param
363*cdf0e10cSrcweir //........................................................................
364*cdf0e10cSrcweir 
365