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