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 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_ucbhelper.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir /**************************************************************************
32*cdf0e10cSrcweir 								TODO
33*cdf0e10cSrcweir  **************************************************************************
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir  *************************************************************************/
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #ifndef __VECTOR__
38*cdf0e10cSrcweir #include <vector>
39*cdf0e10cSrcweir #endif
40*cdf0e10cSrcweir #include <com/sun/star/beans/Property.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyAccess.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/script/XTypeConverter.hpp>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #include "osl/diagnose.h"
47*cdf0e10cSrcweir #include "osl/mutex.hxx"
48*cdf0e10cSrcweir #include <ucbhelper/propertyvalueset.hxx>
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir using namespace com::sun::star::beans;
51*cdf0e10cSrcweir using namespace com::sun::star::container;
52*cdf0e10cSrcweir using namespace com::sun::star::io;
53*cdf0e10cSrcweir using namespace com::sun::star::lang;
54*cdf0e10cSrcweir using namespace com::sun::star::script;
55*cdf0e10cSrcweir using namespace com::sun::star::sdbc;
56*cdf0e10cSrcweir using namespace com::sun::star::uno;
57*cdf0e10cSrcweir using namespace com::sun::star::util;
58*cdf0e10cSrcweir using namespace rtl;
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir namespace ucbhelper_impl
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir //=========================================================================
64*cdf0e10cSrcweir //
65*cdf0e10cSrcweir // PropertyValue.
66*cdf0e10cSrcweir //
67*cdf0e10cSrcweir //=========================================================================
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir const sal_uInt32 NO_VALUE_SET 				= 0x00000000;
70*cdf0e10cSrcweir const sal_uInt32 STRING_VALUE_SET 		 	= 0x00000001;
71*cdf0e10cSrcweir const sal_uInt32 BOOLEAN_VALUE_SET 		 	= 0x00000002;
72*cdf0e10cSrcweir const sal_uInt32 BYTE_VALUE_SET 			= 0x00000004;
73*cdf0e10cSrcweir const sal_uInt32 SHORT_VALUE_SET 			= 0x00000008;
74*cdf0e10cSrcweir const sal_uInt32 INT_VALUE_SET 			 	= 0x00000010;
75*cdf0e10cSrcweir const sal_uInt32 LONG_VALUE_SET 			= 0x00000020;
76*cdf0e10cSrcweir const sal_uInt32 FLOAT_VALUE_SET 			= 0x00000040;
77*cdf0e10cSrcweir const sal_uInt32 DOUBLE_VALUE_SET 		 	= 0x00000080;
78*cdf0e10cSrcweir const sal_uInt32 BYTES_VALUE_SET 			= 0x00000100;
79*cdf0e10cSrcweir const sal_uInt32 DATE_VALUE_SET 			= 0x00000200;
80*cdf0e10cSrcweir const sal_uInt32 TIME_VALUE_SET 			= 0x00000400;
81*cdf0e10cSrcweir const sal_uInt32 TIMESTAMP_VALUE_SET 		= 0x00000800;
82*cdf0e10cSrcweir const sal_uInt32 BINARYSTREAM_VALUE_SET 	= 0x00001000;
83*cdf0e10cSrcweir const sal_uInt32 CHARACTERSTREAM_VALUE_SET 	= 0x00002000;
84*cdf0e10cSrcweir const sal_uInt32 REF_VALUE_SET 			 	= 0x00004000;
85*cdf0e10cSrcweir const sal_uInt32 BLOB_VALUE_SET 			= 0x00008000;
86*cdf0e10cSrcweir const sal_uInt32 CLOB_VALUE_SET 			= 0x00010000;
87*cdf0e10cSrcweir const sal_uInt32 ARRAY_VALUE_SET 			= 0x00020000;
88*cdf0e10cSrcweir const sal_uInt32 OBJECT_VALUE_SET 		 	= 0x00040000;
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir struct PropertyValue
91*cdf0e10cSrcweir {
92*cdf0e10cSrcweir     ::rtl::OUString
93*cdf0e10cSrcweir                 sPropertyName;
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 	sal_uInt32	nPropsSet;
96*cdf0e10cSrcweir 	sal_uInt32  nOrigValue;
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 	OUString	aString;	// getString
99*cdf0e10cSrcweir 	sal_Bool 	bBoolean;	// getBoolean
100*cdf0e10cSrcweir 	sal_Int8	nByte;		// getByte
101*cdf0e10cSrcweir 	sal_Int16	nShort;		// getShort
102*cdf0e10cSrcweir 	sal_Int32 	nInt;		// getInt
103*cdf0e10cSrcweir 	sal_Int64 	nLong;		// getLong
104*cdf0e10cSrcweir 	float		nFloat;		// getFloat
105*cdf0e10cSrcweir 	double		nDouble;	// getDouble
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir 	Sequence< sal_Int8 > 		aBytes; 			// getBytes
108*cdf0e10cSrcweir 	Date                		aDate;				// getDate
109*cdf0e10cSrcweir 	Time                		aTime;				// getTime
110*cdf0e10cSrcweir 	DateTime            		aTimestamp;			// getTimestamp
111*cdf0e10cSrcweir 	Reference< XInputStream >	xBinaryStream;		// getBinaryStream
112*cdf0e10cSrcweir 	Reference< XInputStream >	xCharacterStream;	// getCharacterStream
113*cdf0e10cSrcweir 	Reference< XRef >			xRef;				// getRef
114*cdf0e10cSrcweir 	Reference< XBlob >			xBlob;				// getBlob
115*cdf0e10cSrcweir 	Reference< XClob >			xClob;				// getClob
116*cdf0e10cSrcweir 	Reference< XArray >			xArray;				// getArray
117*cdf0e10cSrcweir 	Any							aObject;			// getObject
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir 	inline PropertyValue()
120*cdf0e10cSrcweir         : nPropsSet( NO_VALUE_SET ), nOrigValue( NO_VALUE_SET ),
121*cdf0e10cSrcweir           bBoolean(false),
122*cdf0e10cSrcweir           nByte(0),
123*cdf0e10cSrcweir           nShort(0),
124*cdf0e10cSrcweir           nInt(0),
125*cdf0e10cSrcweir           nLong(0),
126*cdf0e10cSrcweir           nFloat(0.0),
127*cdf0e10cSrcweir           nDouble(0.0)
128*cdf0e10cSrcweir         {}
129*cdf0e10cSrcweir };
130*cdf0e10cSrcweir } // namespace ucbhelper_impl
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir using namespace ucbhelper_impl;
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir namespace ucbhelper
135*cdf0e10cSrcweir {
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir //=========================================================================
138*cdf0e10cSrcweir //
139*cdf0e10cSrcweir // class PropertyValues.
140*cdf0e10cSrcweir //
141*cdf0e10cSrcweir //=========================================================================
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir typedef std::vector< ucbhelper_impl::PropertyValue > PropertyValuesVector;
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir class PropertyValues : public PropertyValuesVector {};
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir } // namespace ucbhelper
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir //=========================================================================
150*cdf0e10cSrcweir //
151*cdf0e10cSrcweir // Welcome to the macro hell...
152*cdf0e10cSrcweir //
153*cdf0e10cSrcweir //=========================================================================
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir #define GETVALUE_IMPL_TYPE( _type_, _type_name_, _member_name_, _cppu_type_ ) \
156*cdf0e10cSrcweir 																			  \
157*cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );                                       \
158*cdf0e10cSrcweir 																			  \
159*cdf0e10cSrcweir 	_type_ aValue = _type_();	/* default ctor	*/							  \
160*cdf0e10cSrcweir 																			  \
161*cdf0e10cSrcweir 	m_bWasNull = sal_True;                                					  \
162*cdf0e10cSrcweir 																			  \
163*cdf0e10cSrcweir 	if ( ( columnIndex < 1 )												  \
164*cdf0e10cSrcweir 	     || ( columnIndex > sal_Int32( m_pValues->size() ) ) )         		  \
165*cdf0e10cSrcweir 	{                                                                         \
166*cdf0e10cSrcweir 		OSL_ENSURE( sal_False, "PropertyValueSet - index out of range!" );    \
167*cdf0e10cSrcweir 	}                                                                         \
168*cdf0e10cSrcweir 	else                                                                      \
169*cdf0e10cSrcweir 	{                                                                         \
170*cdf0e10cSrcweir 		ucbhelper_impl::PropertyValue& rValue                                 \
171*cdf0e10cSrcweir             = (*m_pValues)[ columnIndex - 1 ];                                \
172*cdf0e10cSrcweir 																			  \
173*cdf0e10cSrcweir 		if ( rValue.nOrigValue != NO_VALUE_SET )							  \
174*cdf0e10cSrcweir 		{                                                                     \
175*cdf0e10cSrcweir 			if ( rValue.nPropsSet & _type_name_ )							  \
176*cdf0e10cSrcweir 			{                                                                 \
177*cdf0e10cSrcweir 				/* Values is present natively... */							  \
178*cdf0e10cSrcweir 				aValue = rValue._member_name_;                                \
179*cdf0e10cSrcweir 				m_bWasNull = sal_False;                   					  \
180*cdf0e10cSrcweir 			}                                                                 \
181*cdf0e10cSrcweir 			else                                                              \
182*cdf0e10cSrcweir 			{                                                                 \
183*cdf0e10cSrcweir 				if ( !(rValue.nPropsSet & OBJECT_VALUE_SET) )                 \
184*cdf0e10cSrcweir 				{                                                             \
185*cdf0e10cSrcweir 					/* Value is not (yet) available as Any. Create it. */     \
186*cdf0e10cSrcweir 					getObject( columnIndex, Reference< XNameAccess >() );     \
187*cdf0e10cSrcweir 				}                                                             \
188*cdf0e10cSrcweir 																			  \
189*cdf0e10cSrcweir 				if ( rValue.nPropsSet & OBJECT_VALUE_SET )                    \
190*cdf0e10cSrcweir 				{															  \
191*cdf0e10cSrcweir 					/* Value is available as Any. */                          \
192*cdf0e10cSrcweir 																			  \
193*cdf0e10cSrcweir 					if ( rValue.aObject.hasValue() )						  \
194*cdf0e10cSrcweir 					{                                                         \
195*cdf0e10cSrcweir 						/* Try to convert into native value. */               \
196*cdf0e10cSrcweir 						if ( rValue.aObject >>= aValue )                      \
197*cdf0e10cSrcweir 						{                                                     \
198*cdf0e10cSrcweir 							rValue._member_name_ = aValue;					  \
199*cdf0e10cSrcweir 							rValue.nPropsSet |= _type_name_;				  \
200*cdf0e10cSrcweir 							m_bWasNull = sal_False;           				  \
201*cdf0e10cSrcweir 						}                                                     \
202*cdf0e10cSrcweir 						else                                                  \
203*cdf0e10cSrcweir 						{                                                     \
204*cdf0e10cSrcweir 							/* Last chance. Try type converter service... */  \
205*cdf0e10cSrcweir 																			  \
206*cdf0e10cSrcweir 							Reference< XTypeConverter > xConverter            \
207*cdf0e10cSrcweir 													= getTypeConverter(); 	  \
208*cdf0e10cSrcweir 							if ( xConverter.is() )                            \
209*cdf0e10cSrcweir 							{                                                 \
210*cdf0e10cSrcweir 								try                                           \
211*cdf0e10cSrcweir 								{                                             \
212*cdf0e10cSrcweir 									Any aConvAny = xConverter->convertTo(     \
213*cdf0e10cSrcweir 													 		rValue.aObject,	  \
214*cdf0e10cSrcweir 															_cppu_type_ );	  \
215*cdf0e10cSrcweir 																			  \
216*cdf0e10cSrcweir 									if ( aConvAny >>= aValue )                \
217*cdf0e10cSrcweir 									{                           			  \
218*cdf0e10cSrcweir 										rValue._member_name_ = aValue;		  \
219*cdf0e10cSrcweir 										rValue.nPropsSet |= _type_name_;      \
220*cdf0e10cSrcweir 										m_bWasNull = sal_False;   			  \
221*cdf0e10cSrcweir 									}                                         \
222*cdf0e10cSrcweir 								}                                             \
223*cdf0e10cSrcweir 								catch ( IllegalArgumentException )            \
224*cdf0e10cSrcweir 								{                                             \
225*cdf0e10cSrcweir 								}                                             \
226*cdf0e10cSrcweir 								catch ( CannotConvertException )              \
227*cdf0e10cSrcweir 								{                                             \
228*cdf0e10cSrcweir 								}                                             \
229*cdf0e10cSrcweir 							}                                                 \
230*cdf0e10cSrcweir 						}                                                     \
231*cdf0e10cSrcweir 					}                                                         \
232*cdf0e10cSrcweir 				}                                                             \
233*cdf0e10cSrcweir 			}                                                                 \
234*cdf0e10cSrcweir 		}																	  \
235*cdf0e10cSrcweir 	}                                                                         \
236*cdf0e10cSrcweir 	return aValue;
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir #define GETVALUE_IMPL( _type_, _type_name_, _member_name_ )					  \
239*cdf0e10cSrcweir 	GETVALUE_IMPL_TYPE( _type_,												  \
240*cdf0e10cSrcweir 						_type_name_,										  \
241*cdf0e10cSrcweir 						_member_name_,                                        \
242*cdf0e10cSrcweir 						getCppuType( static_cast< const _type_ * >( 0 ) ) )
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir #define SETVALUE_IMPL( _prop_name_, _type_name_, _member_name_, _value_ ) 	  \
245*cdf0e10cSrcweir 																			  \
246*cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );				                          \
247*cdf0e10cSrcweir 																			  \
248*cdf0e10cSrcweir 	ucbhelper_impl::PropertyValue aNewValue;                                  \
249*cdf0e10cSrcweir 	aNewValue.sPropertyName = _prop_name_;                                    \
250*cdf0e10cSrcweir 	aNewValue.nPropsSet  	= _type_name_;                                    \
251*cdf0e10cSrcweir 	aNewValue.nOrigValue 	= _type_name_;                                    \
252*cdf0e10cSrcweir 	aNewValue._member_name_ = _value_;                                        \
253*cdf0e10cSrcweir 																			  \
254*cdf0e10cSrcweir 	m_pValues->push_back( aNewValue );
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir namespace ucbhelper {
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir //=========================================================================
259*cdf0e10cSrcweir //=========================================================================
260*cdf0e10cSrcweir //
261*cdf0e10cSrcweir // PropertyValueSet Implementation.
262*cdf0e10cSrcweir //
263*cdf0e10cSrcweir //=========================================================================
264*cdf0e10cSrcweir //=========================================================================
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir #define PROPERTYVALUESET_INIT() 			\
267*cdf0e10cSrcweir   m_xSMgr( rxSMgr ),						\
268*cdf0e10cSrcweir   m_pValues( new PropertyValues ),			\
269*cdf0e10cSrcweir   m_bWasNull( sal_False ),      			\
270*cdf0e10cSrcweir   m_bTriedToGetTypeConverter( sal_False )
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir //=========================================================================
273*cdf0e10cSrcweir PropertyValueSet::PropertyValueSet(
274*cdf0e10cSrcweir 					const Reference< XMultiServiceFactory >& rxSMgr )
275*cdf0e10cSrcweir : PROPERTYVALUESET_INIT()
276*cdf0e10cSrcweir {
277*cdf0e10cSrcweir }
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir //=========================================================================
280*cdf0e10cSrcweir PropertyValueSet::PropertyValueSet(
281*cdf0e10cSrcweir 			const Reference< XMultiServiceFactory >& rxSMgr,
282*cdf0e10cSrcweir 			const Sequence< com::sun::star::beans::PropertyValue >& rValues )
283*cdf0e10cSrcweir : PROPERTYVALUESET_INIT()
284*cdf0e10cSrcweir {
285*cdf0e10cSrcweir 	sal_Int32 nCount = rValues.getLength();
286*cdf0e10cSrcweir 	if ( nCount )
287*cdf0e10cSrcweir 	{
288*cdf0e10cSrcweir 		const com::sun::star::beans::PropertyValue* pValues
289*cdf0e10cSrcweir 			= rValues.getConstArray();
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir 		for ( sal_Int32 n = 0; n < nCount; ++n )
292*cdf0e10cSrcweir 		{
293*cdf0e10cSrcweir 			const com::sun::star::beans::PropertyValue& rValue = pValues[ n ];
294*cdf0e10cSrcweir 			appendObject( Property( rValue.Name,
295*cdf0e10cSrcweir 					  				rValue.Handle,
296*cdf0e10cSrcweir 					  				rValue.Value.getValueType(),
297*cdf0e10cSrcweir 					  				0 ),
298*cdf0e10cSrcweir 						  rValue.Value );
299*cdf0e10cSrcweir 		}
300*cdf0e10cSrcweir 	}
301*cdf0e10cSrcweir }
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir //=========================================================================
304*cdf0e10cSrcweir // virtual
305*cdf0e10cSrcweir PropertyValueSet::~PropertyValueSet()
306*cdf0e10cSrcweir {
307*cdf0e10cSrcweir 	delete m_pValues;
308*cdf0e10cSrcweir }
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir //=========================================================================
311*cdf0e10cSrcweir //
312*cdf0e10cSrcweir // XInterface methods.
313*cdf0e10cSrcweir //
314*cdf0e10cSrcweir //=========================================================================
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir XINTERFACE_IMPL_3( PropertyValueSet,
317*cdf0e10cSrcweir 				   XTypeProvider,
318*cdf0e10cSrcweir 				   XRow,
319*cdf0e10cSrcweir 				   XColumnLocate );
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir //=========================================================================
322*cdf0e10cSrcweir //
323*cdf0e10cSrcweir // XTypeProvider methods.
324*cdf0e10cSrcweir //
325*cdf0e10cSrcweir //=========================================================================
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir XTYPEPROVIDER_IMPL_3( PropertyValueSet,
328*cdf0e10cSrcweir 					  XTypeProvider,
329*cdf0e10cSrcweir 				   	  XRow,
330*cdf0e10cSrcweir 					  XColumnLocate );
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir //=========================================================================
333*cdf0e10cSrcweir //
334*cdf0e10cSrcweir // XRow methods.
335*cdf0e10cSrcweir //
336*cdf0e10cSrcweir //=========================================================================
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir // virtual
339*cdf0e10cSrcweir sal_Bool SAL_CALL PropertyValueSet::wasNull()
340*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
341*cdf0e10cSrcweir {
342*cdf0e10cSrcweir 	// This method can not be implemented correctly!!! Imagine different
343*cdf0e10cSrcweir 	// threads doing a getXYZ - wasNull calling sequence on the same
344*cdf0e10cSrcweir 	// implementation object...
345*cdf0e10cSrcweir 	return m_bWasNull;
346*cdf0e10cSrcweir }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir //=========================================================================
349*cdf0e10cSrcweir // virtual
350*cdf0e10cSrcweir OUString SAL_CALL PropertyValueSet::getString( sal_Int32 columnIndex )
351*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
352*cdf0e10cSrcweir {
353*cdf0e10cSrcweir 	GETVALUE_IMPL( OUString, STRING_VALUE_SET, aString );
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir //=========================================================================
357*cdf0e10cSrcweir // virtual
358*cdf0e10cSrcweir sal_Bool SAL_CALL PropertyValueSet::getBoolean( sal_Int32 columnIndex )
359*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
360*cdf0e10cSrcweir {
361*cdf0e10cSrcweir 	GETVALUE_IMPL_TYPE(
362*cdf0e10cSrcweir 			sal_Bool, BOOLEAN_VALUE_SET, bBoolean, getCppuBooleanType() );
363*cdf0e10cSrcweir }
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir //=========================================================================
366*cdf0e10cSrcweir // virtual
367*cdf0e10cSrcweir sal_Int8 SAL_CALL PropertyValueSet::getByte( sal_Int32 columnIndex )
368*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
369*cdf0e10cSrcweir {
370*cdf0e10cSrcweir 	GETVALUE_IMPL( sal_Int8, BYTE_VALUE_SET, nByte );
371*cdf0e10cSrcweir }
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir //=========================================================================
374*cdf0e10cSrcweir // virtual
375*cdf0e10cSrcweir sal_Int16 SAL_CALL PropertyValueSet::getShort( sal_Int32 columnIndex )
376*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
377*cdf0e10cSrcweir {
378*cdf0e10cSrcweir 	GETVALUE_IMPL( sal_Int16, SHORT_VALUE_SET, nShort );
379*cdf0e10cSrcweir }
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir //=========================================================================
382*cdf0e10cSrcweir // virtual
383*cdf0e10cSrcweir sal_Int32 SAL_CALL PropertyValueSet::getInt( sal_Int32 columnIndex )
384*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
385*cdf0e10cSrcweir {
386*cdf0e10cSrcweir 	GETVALUE_IMPL( sal_Int32, INT_VALUE_SET, nInt );
387*cdf0e10cSrcweir }
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir //=========================================================================
390*cdf0e10cSrcweir // virtual
391*cdf0e10cSrcweir sal_Int64 SAL_CALL PropertyValueSet::getLong( sal_Int32 columnIndex )
392*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
393*cdf0e10cSrcweir {
394*cdf0e10cSrcweir 	GETVALUE_IMPL( sal_Int64, LONG_VALUE_SET, nLong );
395*cdf0e10cSrcweir }
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir //=========================================================================
398*cdf0e10cSrcweir // virtual
399*cdf0e10cSrcweir float SAL_CALL PropertyValueSet::getFloat( sal_Int32 columnIndex )
400*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
401*cdf0e10cSrcweir {
402*cdf0e10cSrcweir 	GETVALUE_IMPL( float, FLOAT_VALUE_SET, nFloat );
403*cdf0e10cSrcweir }
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir //=========================================================================
406*cdf0e10cSrcweir // virtual
407*cdf0e10cSrcweir double SAL_CALL PropertyValueSet::getDouble( sal_Int32 columnIndex )
408*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
409*cdf0e10cSrcweir {
410*cdf0e10cSrcweir 	GETVALUE_IMPL( double, DOUBLE_VALUE_SET, nDouble );
411*cdf0e10cSrcweir }
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir //=========================================================================
414*cdf0e10cSrcweir // virtual
415*cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL
416*cdf0e10cSrcweir PropertyValueSet::getBytes( sal_Int32 columnIndex )
417*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
418*cdf0e10cSrcweir {
419*cdf0e10cSrcweir 	GETVALUE_IMPL( Sequence< sal_Int8 >, BYTES_VALUE_SET, aBytes );
420*cdf0e10cSrcweir }
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir //=========================================================================
423*cdf0e10cSrcweir // virtual
424*cdf0e10cSrcweir Date SAL_CALL PropertyValueSet::getDate( sal_Int32 columnIndex )
425*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
426*cdf0e10cSrcweir {
427*cdf0e10cSrcweir 	GETVALUE_IMPL( Date, DATE_VALUE_SET, aDate );
428*cdf0e10cSrcweir }
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir //=========================================================================
431*cdf0e10cSrcweir // virtual
432*cdf0e10cSrcweir Time SAL_CALL PropertyValueSet::getTime( sal_Int32 columnIndex )
433*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
434*cdf0e10cSrcweir {
435*cdf0e10cSrcweir 	GETVALUE_IMPL( Time, TIME_VALUE_SET, aTime );
436*cdf0e10cSrcweir }
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir //=========================================================================
439*cdf0e10cSrcweir // virtual
440*cdf0e10cSrcweir DateTime SAL_CALL PropertyValueSet::getTimestamp( sal_Int32 columnIndex )
441*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
442*cdf0e10cSrcweir {
443*cdf0e10cSrcweir 	GETVALUE_IMPL( DateTime, TIMESTAMP_VALUE_SET, aTimestamp );
444*cdf0e10cSrcweir }
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir //=========================================================================
447*cdf0e10cSrcweir // virtual
448*cdf0e10cSrcweir Reference< XInputStream > SAL_CALL
449*cdf0e10cSrcweir PropertyValueSet::getBinaryStream( sal_Int32 columnIndex )
450*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
451*cdf0e10cSrcweir {
452*cdf0e10cSrcweir 	GETVALUE_IMPL(
453*cdf0e10cSrcweir 		Reference< XInputStream >, BINARYSTREAM_VALUE_SET, xBinaryStream );
454*cdf0e10cSrcweir }
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir //=========================================================================
457*cdf0e10cSrcweir // virtual
458*cdf0e10cSrcweir Reference< XInputStream > SAL_CALL
459*cdf0e10cSrcweir PropertyValueSet::getCharacterStream( sal_Int32 columnIndex )
460*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
461*cdf0e10cSrcweir {
462*cdf0e10cSrcweir 	GETVALUE_IMPL(
463*cdf0e10cSrcweir 		Reference< XInputStream >, CHARACTERSTREAM_VALUE_SET, xCharacterStream );
464*cdf0e10cSrcweir }
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir //=========================================================================
467*cdf0e10cSrcweir // virtual
468*cdf0e10cSrcweir Any SAL_CALL PropertyValueSet::getObject(
469*cdf0e10cSrcweir 									sal_Int32 columnIndex,
470*cdf0e10cSrcweir 	   				 			 	const Reference< XNameAccess >& )
471*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
472*cdf0e10cSrcweir {
473*cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
474*cdf0e10cSrcweir 
475*cdf0e10cSrcweir 	Any aValue;
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir 	m_bWasNull = sal_True;
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir 	if ( ( columnIndex < 1 )
480*cdf0e10cSrcweir 	     || ( columnIndex > sal_Int32( m_pValues->size() ) ) )
481*cdf0e10cSrcweir 	{
482*cdf0e10cSrcweir 		OSL_ENSURE( sal_False, "PropertyValueSet - index out of range!" );
483*cdf0e10cSrcweir 	}
484*cdf0e10cSrcweir 	else
485*cdf0e10cSrcweir 	{
486*cdf0e10cSrcweir 		ucbhelper_impl::PropertyValue& rValue
487*cdf0e10cSrcweir             = (*m_pValues)[ columnIndex - 1 ];
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir 		if ( rValue.nPropsSet & OBJECT_VALUE_SET )
490*cdf0e10cSrcweir 		{
491*cdf0e10cSrcweir 			// Values is present natively...
492*cdf0e10cSrcweir 			aValue = rValue.aObject;
493*cdf0e10cSrcweir 			m_bWasNull = sal_False;
494*cdf0e10cSrcweir 		}
495*cdf0e10cSrcweir 		else
496*cdf0e10cSrcweir 		{
497*cdf0e10cSrcweir 			// Make Any from original value.
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir 			switch ( rValue.nOrigValue )
500*cdf0e10cSrcweir 			{
501*cdf0e10cSrcweir 				case NO_VALUE_SET:
502*cdf0e10cSrcweir 					break;
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir 				case STRING_VALUE_SET:
505*cdf0e10cSrcweir 					aValue <<= rValue.aString;
506*cdf0e10cSrcweir 					break;
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir 				case BOOLEAN_VALUE_SET:
509*cdf0e10cSrcweir 					aValue <<= rValue.bBoolean;
510*cdf0e10cSrcweir 					break;
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir 				case BYTE_VALUE_SET:
513*cdf0e10cSrcweir 					aValue <<= rValue.nByte;
514*cdf0e10cSrcweir 					break;
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir 				case SHORT_VALUE_SET:
517*cdf0e10cSrcweir 					aValue <<= rValue.nShort;
518*cdf0e10cSrcweir 					break;
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir 				case INT_VALUE_SET:
521*cdf0e10cSrcweir 					aValue <<= rValue.nInt;
522*cdf0e10cSrcweir 					break;
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir 				case LONG_VALUE_SET:
525*cdf0e10cSrcweir 					aValue <<= rValue.nLong;
526*cdf0e10cSrcweir 					break;
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir 				case FLOAT_VALUE_SET:
529*cdf0e10cSrcweir 					aValue <<= rValue.nFloat;
530*cdf0e10cSrcweir 					break;
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir 				case DOUBLE_VALUE_SET:
533*cdf0e10cSrcweir 					aValue <<= rValue.nDouble;
534*cdf0e10cSrcweir 					break;
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir 				case BYTES_VALUE_SET:
537*cdf0e10cSrcweir 					aValue <<= rValue.aBytes;
538*cdf0e10cSrcweir 					break;
539*cdf0e10cSrcweir 
540*cdf0e10cSrcweir 				case DATE_VALUE_SET:
541*cdf0e10cSrcweir 					aValue <<= rValue.aDate;
542*cdf0e10cSrcweir 					break;
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir 				case TIME_VALUE_SET:
545*cdf0e10cSrcweir 					aValue <<= rValue.aTime;
546*cdf0e10cSrcweir 					break;
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir 				case TIMESTAMP_VALUE_SET:
549*cdf0e10cSrcweir 					aValue <<= rValue.aTimestamp;
550*cdf0e10cSrcweir 					break;
551*cdf0e10cSrcweir 
552*cdf0e10cSrcweir 				case BINARYSTREAM_VALUE_SET:
553*cdf0e10cSrcweir 					aValue <<= rValue.xBinaryStream;
554*cdf0e10cSrcweir 					break;
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir 				case CHARACTERSTREAM_VALUE_SET:
557*cdf0e10cSrcweir 					aValue <<= rValue.xCharacterStream;
558*cdf0e10cSrcweir 					break;
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir 				case REF_VALUE_SET:
561*cdf0e10cSrcweir 					aValue <<= rValue.xRef;
562*cdf0e10cSrcweir 					break;
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir 				case BLOB_VALUE_SET:
565*cdf0e10cSrcweir 					aValue <<= rValue.xBlob;
566*cdf0e10cSrcweir 					break;
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir 				case CLOB_VALUE_SET:
569*cdf0e10cSrcweir 					aValue <<= rValue.xClob;
570*cdf0e10cSrcweir 					break;
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir 				case ARRAY_VALUE_SET:
573*cdf0e10cSrcweir 					aValue <<= rValue.xArray;
574*cdf0e10cSrcweir 					break;
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir 				case OBJECT_VALUE_SET:
577*cdf0e10cSrcweir 					// Fall-through is intended!
578*cdf0e10cSrcweir 				default:
579*cdf0e10cSrcweir 					OSL_ENSURE( sal_False,
580*cdf0e10cSrcweir 								"PropertyValueSet::getObject - "
581*cdf0e10cSrcweir 								"Wrong original type" );
582*cdf0e10cSrcweir 					break;
583*cdf0e10cSrcweir 			}
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir 			if ( aValue.hasValue() )
586*cdf0e10cSrcweir 			{
587*cdf0e10cSrcweir 				rValue.aObject = aValue;
588*cdf0e10cSrcweir 				rValue.nPropsSet |= OBJECT_VALUE_SET;
589*cdf0e10cSrcweir 				m_bWasNull = sal_False;
590*cdf0e10cSrcweir 			}
591*cdf0e10cSrcweir 		}
592*cdf0e10cSrcweir  	}
593*cdf0e10cSrcweir 
594*cdf0e10cSrcweir 	return aValue;
595*cdf0e10cSrcweir }
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir //=========================================================================
598*cdf0e10cSrcweir // virtual
599*cdf0e10cSrcweir Reference< XRef > SAL_CALL PropertyValueSet::getRef( sal_Int32 columnIndex )
600*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
601*cdf0e10cSrcweir {
602*cdf0e10cSrcweir 	GETVALUE_IMPL( Reference< XRef >, REF_VALUE_SET, xRef );
603*cdf0e10cSrcweir }
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir //=========================================================================
606*cdf0e10cSrcweir // virtual
607*cdf0e10cSrcweir Reference< XBlob > SAL_CALL PropertyValueSet::getBlob( sal_Int32 columnIndex )
608*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
609*cdf0e10cSrcweir {
610*cdf0e10cSrcweir 	GETVALUE_IMPL( Reference< XBlob >, BLOB_VALUE_SET, xBlob );
611*cdf0e10cSrcweir }
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir //=========================================================================
614*cdf0e10cSrcweir // virtual
615*cdf0e10cSrcweir Reference< XClob > SAL_CALL PropertyValueSet::getClob( sal_Int32 columnIndex )
616*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
617*cdf0e10cSrcweir {
618*cdf0e10cSrcweir 	GETVALUE_IMPL( Reference< XClob >, CLOB_VALUE_SET, xClob );
619*cdf0e10cSrcweir }
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir //=========================================================================
622*cdf0e10cSrcweir // virtual
623*cdf0e10cSrcweir Reference< XArray > SAL_CALL PropertyValueSet::getArray( sal_Int32 columnIndex )
624*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
625*cdf0e10cSrcweir {
626*cdf0e10cSrcweir 	GETVALUE_IMPL( Reference< XArray >, ARRAY_VALUE_SET, xArray );
627*cdf0e10cSrcweir }
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir //=========================================================================
630*cdf0e10cSrcweir //
631*cdf0e10cSrcweir // XColumnLocate methods.
632*cdf0e10cSrcweir //
633*cdf0e10cSrcweir //=========================================================================
634*cdf0e10cSrcweir 
635*cdf0e10cSrcweir // virtual
636*cdf0e10cSrcweir sal_Int32 SAL_CALL PropertyValueSet::findColumn( const OUString& columnName )
637*cdf0e10cSrcweir 	throw( SQLException, RuntimeException )
638*cdf0e10cSrcweir {
639*cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir 	if ( columnName.getLength() )
642*cdf0e10cSrcweir 	{
643*cdf0e10cSrcweir 		sal_Int32 nCount = m_pValues->size();
644*cdf0e10cSrcweir 		for ( sal_Int32 n = 0; n < nCount; ++n )
645*cdf0e10cSrcweir 		{
646*cdf0e10cSrcweir 			if ( (*m_pValues)[ n ].sPropertyName.equals( columnName ) )
647*cdf0e10cSrcweir 				return sal_Int32( n + 1 ); // Index is 1-based.
648*cdf0e10cSrcweir 		}
649*cdf0e10cSrcweir 	}
650*cdf0e10cSrcweir 	return 0;
651*cdf0e10cSrcweir }
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir //=========================================================================
654*cdf0e10cSrcweir //
655*cdf0e10cSrcweir // Non-interface methods.
656*cdf0e10cSrcweir //
657*cdf0e10cSrcweir //=========================================================================
658*cdf0e10cSrcweir 
659*cdf0e10cSrcweir const Reference< XTypeConverter >& PropertyValueSet::getTypeConverter()
660*cdf0e10cSrcweir {
661*cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
662*cdf0e10cSrcweir 
663*cdf0e10cSrcweir 	if ( !m_bTriedToGetTypeConverter && !m_xTypeConverter.is() )
664*cdf0e10cSrcweir 	{
665*cdf0e10cSrcweir 		m_bTriedToGetTypeConverter = sal_True;
666*cdf0e10cSrcweir 		m_xTypeConverter = Reference< XTypeConverter >(
667*cdf0e10cSrcweir 								m_xSMgr->createInstance(
668*cdf0e10cSrcweir 									OUString::createFromAscii(
669*cdf0e10cSrcweir 										"com.sun.star.script.Converter" ) ),
670*cdf0e10cSrcweir 								UNO_QUERY );
671*cdf0e10cSrcweir 
672*cdf0e10cSrcweir 		OSL_ENSURE( m_xTypeConverter.is(),
673*cdf0e10cSrcweir 					"PropertyValueSet::getTypeConverter() - "
674*cdf0e10cSrcweir 					"Service 'com.sun.star.script.Converter' n/a!" );
675*cdf0e10cSrcweir 	}
676*cdf0e10cSrcweir 	return m_xTypeConverter;
677*cdf0e10cSrcweir }
678*cdf0e10cSrcweir 
679*cdf0e10cSrcweir //=========================================================================
680*cdf0e10cSrcweir sal_Int32 PropertyValueSet::getLength() const
681*cdf0e10cSrcweir {
682*cdf0e10cSrcweir 	return m_pValues->size();
683*cdf0e10cSrcweir }
684*cdf0e10cSrcweir 
685*cdf0e10cSrcweir //=========================================================================
686*cdf0e10cSrcweir void PropertyValueSet::appendString( const ::rtl::OUString& rPropName,
687*cdf0e10cSrcweir 									 const OUString& rValue )
688*cdf0e10cSrcweir {
689*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, STRING_VALUE_SET, aString, rValue );
690*cdf0e10cSrcweir }
691*cdf0e10cSrcweir 
692*cdf0e10cSrcweir //=========================================================================
693*cdf0e10cSrcweir void PropertyValueSet::appendBoolean( const ::rtl::OUString& rPropName,
694*cdf0e10cSrcweir 									  sal_Bool bValue )
695*cdf0e10cSrcweir {
696*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, BOOLEAN_VALUE_SET, bBoolean, bValue );
697*cdf0e10cSrcweir }
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir //=========================================================================
700*cdf0e10cSrcweir void PropertyValueSet::appendByte( const ::rtl::OUString& rPropName,
701*cdf0e10cSrcweir 								   sal_Int8 nValue )
702*cdf0e10cSrcweir {
703*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, BYTE_VALUE_SET, nByte, nValue );
704*cdf0e10cSrcweir }
705*cdf0e10cSrcweir 
706*cdf0e10cSrcweir //=========================================================================
707*cdf0e10cSrcweir void PropertyValueSet::appendShort( const ::rtl::OUString& rPropName,
708*cdf0e10cSrcweir 									sal_Int16 nValue )
709*cdf0e10cSrcweir {
710*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, SHORT_VALUE_SET, nShort, nValue );
711*cdf0e10cSrcweir }
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir //=========================================================================
714*cdf0e10cSrcweir void PropertyValueSet::appendInt( const ::rtl::OUString& rPropName,
715*cdf0e10cSrcweir 								  sal_Int32 nValue )
716*cdf0e10cSrcweir {
717*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, INT_VALUE_SET, nInt, nValue );
718*cdf0e10cSrcweir }
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir //=========================================================================
721*cdf0e10cSrcweir void PropertyValueSet::appendLong( const ::rtl::OUString& rPropName,
722*cdf0e10cSrcweir 								   sal_Int64 nValue )
723*cdf0e10cSrcweir {
724*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, LONG_VALUE_SET, nLong, nValue );
725*cdf0e10cSrcweir }
726*cdf0e10cSrcweir 
727*cdf0e10cSrcweir //=========================================================================
728*cdf0e10cSrcweir void PropertyValueSet::appendFloat( const ::rtl::OUString& rPropName,
729*cdf0e10cSrcweir 									float nValue )
730*cdf0e10cSrcweir {
731*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, FLOAT_VALUE_SET, nFloat, nValue );
732*cdf0e10cSrcweir }
733*cdf0e10cSrcweir 
734*cdf0e10cSrcweir //=========================================================================
735*cdf0e10cSrcweir void PropertyValueSet::appendDouble( const ::rtl::OUString& rPropName,
736*cdf0e10cSrcweir 									 double nValue )
737*cdf0e10cSrcweir {
738*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, DOUBLE_VALUE_SET, nDouble, nValue );
739*cdf0e10cSrcweir }
740*cdf0e10cSrcweir 
741*cdf0e10cSrcweir //=========================================================================
742*cdf0e10cSrcweir void PropertyValueSet::appendBytes( const ::rtl::OUString& rPropName,
743*cdf0e10cSrcweir 									const Sequence< sal_Int8 >& rValue )
744*cdf0e10cSrcweir {
745*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, BYTES_VALUE_SET, aBytes, rValue );
746*cdf0e10cSrcweir }
747*cdf0e10cSrcweir 
748*cdf0e10cSrcweir //=========================================================================
749*cdf0e10cSrcweir void PropertyValueSet::appendDate( const ::rtl::OUString& rPropName,
750*cdf0e10cSrcweir 								   const Date& rValue )
751*cdf0e10cSrcweir {
752*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, DATE_VALUE_SET, aDate, rValue );
753*cdf0e10cSrcweir }
754*cdf0e10cSrcweir 
755*cdf0e10cSrcweir //=========================================================================
756*cdf0e10cSrcweir void PropertyValueSet::appendTime( const ::rtl::OUString& rPropName,
757*cdf0e10cSrcweir 								   const Time& rValue )
758*cdf0e10cSrcweir {
759*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, TIME_VALUE_SET, aTime, rValue );
760*cdf0e10cSrcweir }
761*cdf0e10cSrcweir 
762*cdf0e10cSrcweir //=========================================================================
763*cdf0e10cSrcweir void PropertyValueSet::appendTimestamp( const ::rtl::OUString& rPropName,
764*cdf0e10cSrcweir 										const DateTime& rValue )
765*cdf0e10cSrcweir {
766*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, TIMESTAMP_VALUE_SET, aTimestamp, rValue );
767*cdf0e10cSrcweir }
768*cdf0e10cSrcweir 
769*cdf0e10cSrcweir //=========================================================================
770*cdf0e10cSrcweir void PropertyValueSet::appendBinaryStream(
771*cdf0e10cSrcweir 								const ::rtl::OUString& rPropName,
772*cdf0e10cSrcweir 								const Reference< XInputStream >& rValue )
773*cdf0e10cSrcweir {
774*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, BINARYSTREAM_VALUE_SET, xBinaryStream, rValue );
775*cdf0e10cSrcweir }
776*cdf0e10cSrcweir 
777*cdf0e10cSrcweir //=========================================================================
778*cdf0e10cSrcweir void PropertyValueSet::appendCharacterStream(
779*cdf0e10cSrcweir 								const ::rtl::OUString& rPropName,
780*cdf0e10cSrcweir 								const Reference< XInputStream >& rValue )
781*cdf0e10cSrcweir {
782*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, CHARACTERSTREAM_VALUE_SET, xCharacterStream, rValue );
783*cdf0e10cSrcweir }
784*cdf0e10cSrcweir 
785*cdf0e10cSrcweir //=========================================================================
786*cdf0e10cSrcweir void PropertyValueSet::appendObject( const ::rtl::OUString& rPropName,
787*cdf0e10cSrcweir 									 const Any& rValue )
788*cdf0e10cSrcweir {
789*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, OBJECT_VALUE_SET, aObject, rValue );
790*cdf0e10cSrcweir }
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir //=========================================================================
793*cdf0e10cSrcweir void PropertyValueSet::appendRef( const ::rtl::OUString& rPropName,
794*cdf0e10cSrcweir 								  const Reference< XRef >& rValue )
795*cdf0e10cSrcweir {
796*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, REF_VALUE_SET, xRef, rValue );
797*cdf0e10cSrcweir }
798*cdf0e10cSrcweir 
799*cdf0e10cSrcweir //=========================================================================
800*cdf0e10cSrcweir void PropertyValueSet::appendBlob( const ::rtl::OUString& rPropName,
801*cdf0e10cSrcweir 								   const Reference< XBlob >& rValue )
802*cdf0e10cSrcweir {
803*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, BLOB_VALUE_SET, xBlob, rValue );
804*cdf0e10cSrcweir }
805*cdf0e10cSrcweir 
806*cdf0e10cSrcweir //=========================================================================
807*cdf0e10cSrcweir void PropertyValueSet::appendClob( const ::rtl::OUString& rPropName,
808*cdf0e10cSrcweir 								   const Reference< XClob >& rValue )
809*cdf0e10cSrcweir {
810*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, CLOB_VALUE_SET, xClob, rValue );
811*cdf0e10cSrcweir }
812*cdf0e10cSrcweir 
813*cdf0e10cSrcweir //=========================================================================
814*cdf0e10cSrcweir void PropertyValueSet::appendArray( const ::rtl::OUString& rPropName,
815*cdf0e10cSrcweir 									const Reference< XArray >& rValue )
816*cdf0e10cSrcweir {
817*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, ARRAY_VALUE_SET, xArray, rValue );
818*cdf0e10cSrcweir }
819*cdf0e10cSrcweir 
820*cdf0e10cSrcweir //=========================================================================
821*cdf0e10cSrcweir void PropertyValueSet::appendVoid( const ::rtl::OUString& rPropName )
822*cdf0e10cSrcweir {
823*cdf0e10cSrcweir 	SETVALUE_IMPL( rPropName, NO_VALUE_SET, aObject, Any() );
824*cdf0e10cSrcweir }
825*cdf0e10cSrcweir 
826*cdf0e10cSrcweir //=========================================================================
827*cdf0e10cSrcweir void PropertyValueSet::appendPropertySet(
828*cdf0e10cSrcweir 								const Reference< XPropertySet >& rxSet )
829*cdf0e10cSrcweir {
830*cdf0e10cSrcweir 	if ( rxSet.is() )
831*cdf0e10cSrcweir 	{
832*cdf0e10cSrcweir 		Reference< XPropertySetInfo > xInfo = rxSet->getPropertySetInfo();
833*cdf0e10cSrcweir 		if ( xInfo.is() )
834*cdf0e10cSrcweir 		{
835*cdf0e10cSrcweir     		Sequence< Property > aProps 	 = xInfo->getProperties();
836*cdf0e10cSrcweir 			const Property* 	 pProps 	 = aProps.getConstArray();
837*cdf0e10cSrcweir 			sal_Int32 			 nPropsCount = aProps.getLength();
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir 			Reference< XPropertyAccess > xPropertyAccess( rxSet, UNO_QUERY );
840*cdf0e10cSrcweir 			if ( xPropertyAccess.is() )
841*cdf0e10cSrcweir 			{
842*cdf0e10cSrcweir 				// Efficient: Get all prop values with one ( remote) call.
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir 	    		Sequence< ::com::sun::star::beans::PropertyValue > aPropValues
845*cdf0e10cSrcweir 					= xPropertyAccess->getPropertyValues();
846*cdf0e10cSrcweir 
847*cdf0e10cSrcweir 				const ::com::sun::star::beans::PropertyValue* pPropValues
848*cdf0e10cSrcweir 				  	= aPropValues.getConstArray();
849*cdf0e10cSrcweir 
850*cdf0e10cSrcweir 				sal_Int32 nValuesCount = aPropValues.getLength();
851*cdf0e10cSrcweir 				for ( sal_Int32 n = 0; n < nValuesCount; ++n )
852*cdf0e10cSrcweir 				{
853*cdf0e10cSrcweir 					const ::com::sun::star::beans::PropertyValue& rPropValue
854*cdf0e10cSrcweir 						= pPropValues[ n ];
855*cdf0e10cSrcweir 
856*cdf0e10cSrcweir 					// Find info for current property value.
857*cdf0e10cSrcweir 					for ( sal_Int32 m = 0; m < nPropsCount; ++m )
858*cdf0e10cSrcweir 					{
859*cdf0e10cSrcweir 						const Property& rProp = pProps[ m ];
860*cdf0e10cSrcweir 						if ( rProp.Name == rPropValue.Name )
861*cdf0e10cSrcweir 						{
862*cdf0e10cSrcweir 							// Found!
863*cdf0e10cSrcweir 							appendObject( rProp, rPropValue.Value );
864*cdf0e10cSrcweir 							break;
865*cdf0e10cSrcweir 						}
866*cdf0e10cSrcweir 					}
867*cdf0e10cSrcweir 				}
868*cdf0e10cSrcweir 			}
869*cdf0e10cSrcweir 			else
870*cdf0e10cSrcweir 			{
871*cdf0e10cSrcweir 				// Get every single prop value with one ( remote) call.
872*cdf0e10cSrcweir 
873*cdf0e10cSrcweir 				for ( sal_Int32 n = 0; n < nPropsCount; ++n )
874*cdf0e10cSrcweir 				{
875*cdf0e10cSrcweir 					const Property& rProp = pProps[ n ];
876*cdf0e10cSrcweir 
877*cdf0e10cSrcweir 					try
878*cdf0e10cSrcweir 					{
879*cdf0e10cSrcweir 						Any aValue = rxSet->getPropertyValue( rProp.Name );
880*cdf0e10cSrcweir 
881*cdf0e10cSrcweir 						if ( aValue.hasValue() )
882*cdf0e10cSrcweir 							appendObject( rProp, aValue );
883*cdf0e10cSrcweir 					}
884*cdf0e10cSrcweir 					catch ( UnknownPropertyException )
885*cdf0e10cSrcweir 					{
886*cdf0e10cSrcweir 					}
887*cdf0e10cSrcweir 			   		catch ( WrappedTargetException )
888*cdf0e10cSrcweir 					{
889*cdf0e10cSrcweir 					}
890*cdf0e10cSrcweir 				}
891*cdf0e10cSrcweir 			}
892*cdf0e10cSrcweir 		}
893*cdf0e10cSrcweir 	}
894*cdf0e10cSrcweir }
895*cdf0e10cSrcweir 
896*cdf0e10cSrcweir //=========================================================================
897*cdf0e10cSrcweir sal_Bool PropertyValueSet::appendPropertySetValue(
898*cdf0e10cSrcweir 								const Reference< XPropertySet >& rxSet,
899*cdf0e10cSrcweir 								const Property& rProperty )
900*cdf0e10cSrcweir {
901*cdf0e10cSrcweir 	if ( rxSet.is() )
902*cdf0e10cSrcweir 	{
903*cdf0e10cSrcweir 		try
904*cdf0e10cSrcweir 		{
905*cdf0e10cSrcweir 			Any aValue = rxSet->getPropertyValue( rProperty.Name );
906*cdf0e10cSrcweir 			if ( aValue.hasValue() )
907*cdf0e10cSrcweir 			{
908*cdf0e10cSrcweir 				appendObject( rProperty, aValue );
909*cdf0e10cSrcweir 				return sal_True;
910*cdf0e10cSrcweir 			}
911*cdf0e10cSrcweir 		}
912*cdf0e10cSrcweir 		catch ( UnknownPropertyException )
913*cdf0e10cSrcweir 		{
914*cdf0e10cSrcweir 		}
915*cdf0e10cSrcweir 		catch ( WrappedTargetException )
916*cdf0e10cSrcweir 		{
917*cdf0e10cSrcweir 		}
918*cdf0e10cSrcweir 	}
919*cdf0e10cSrcweir 
920*cdf0e10cSrcweir 	// Error.
921*cdf0e10cSrcweir 	return sal_False;
922*cdf0e10cSrcweir }
923*cdf0e10cSrcweir 
924*cdf0e10cSrcweir } // namespace ucbhelper
925