Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef _UCBHELPER_PROPERTYVALUESET_HXX
21 : : #define _UCBHELPER_PROPERTYVALUESET_HXX
22 : :
23 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
24 : : #include <com/sun/star/lang/XTypeProvider.hpp>
25 : : #include <com/sun/star/sdbc/XColumnLocate.hpp>
26 : : #include <com/sun/star/sdbc/XRow.hpp>
27 : : #include <com/sun/star/beans/Property.hpp>
28 : : #include <cppuhelper/weak.hxx>
29 : :
30 : : #include "osl/mutex.hxx"
31 : : #include <ucbhelper/macros.hxx>
32 : : #include "ucbhelper/ucbhelperdllapi.h"
33 : :
34 : : namespace com { namespace sun { namespace star { namespace script {
35 : : class XTypeConverter;
36 : : } } } }
37 : :
38 : : namespace com { namespace sun { namespace star { namespace beans {
39 : : struct PropertyValue;
40 : : class XPropertySet;
41 : : } } } }
42 : :
43 : : namespace ucbhelper {
44 : :
45 : : class PropertyValues;
46 : :
47 : : //=========================================================================
48 : :
49 : : /**
50 : : * This class implements the interface XRow. After construction of a valueset
51 : : * the user can append properties ( incl. its values ) to the set. This class
52 : : * is useful when implementing the command "getPropertyValues", because the
53 : : * values to return can easyly appended to a valueset object. That object can
54 : : * directly be returned by the implementation of the command.
55 : : */
56 : : class UCBHELPER_DLLPUBLIC PropertyValueSet :
57 : : public cppu::OWeakObject,
58 : : public com::sun::star::lang::XTypeProvider,
59 : : public com::sun::star::sdbc::XRow,
60 : : public com::sun::star::sdbc::XColumnLocate
61 : : {
62 : : com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
63 : : m_xSMgr;
64 : : com::sun::star::uno::Reference< com::sun::star::script::XTypeConverter >
65 : : m_xTypeConverter;
66 : : osl::Mutex m_aMutex;
67 : : PropertyValues* m_pValues;
68 : : sal_Bool m_bWasNull;
69 : : sal_Bool m_bTriedToGetTypeConverter;
70 : :
71 : : private:
72 : : UCBHELPER_DLLPRIVATE const com::sun::star::uno::Reference<
73 : : com::sun::star::script::XTypeConverter >&
74 : : getTypeConverter();
75 : :
76 : : public:
77 : : PropertyValueSet(
78 : : const com::sun::star::uno::Reference<
79 : : com::sun::star::lang::XMultiServiceFactory >& rxSMgr );
80 : : virtual ~PropertyValueSet();
81 : :
82 : : // XInterface
83 : : XINTERFACE_DECL()
84 : :
85 : : // XTypeProvider
86 : : XTYPEPROVIDER_DECL()
87 : :
88 : : // XRow
89 : : virtual sal_Bool SAL_CALL
90 : : wasNull()
91 : : throw( ::com::sun::star::sdbc::SQLException,
92 : : ::com::sun::star::uno::RuntimeException );
93 : : virtual ::rtl::OUString SAL_CALL
94 : : getString( sal_Int32 columnIndex )
95 : : throw( ::com::sun::star::sdbc::SQLException,
96 : : ::com::sun::star::uno::RuntimeException );
97 : : virtual sal_Bool SAL_CALL
98 : : getBoolean( sal_Int32 columnIndex )
99 : : throw( ::com::sun::star::sdbc::SQLException,
100 : : ::com::sun::star::uno::RuntimeException );
101 : : virtual sal_Int8 SAL_CALL
102 : : getByte( sal_Int32 columnIndex )
103 : : throw( ::com::sun::star::sdbc::SQLException,
104 : : ::com::sun::star::uno::RuntimeException );
105 : : virtual sal_Int16 SAL_CALL
106 : : getShort( sal_Int32 columnIndex )
107 : : throw( ::com::sun::star::sdbc::SQLException,
108 : : ::com::sun::star::uno::RuntimeException );
109 : : virtual sal_Int32 SAL_CALL
110 : : getInt( sal_Int32 columnIndex )
111 : : throw( ::com::sun::star::sdbc::SQLException,
112 : : ::com::sun::star::uno::RuntimeException );
113 : : virtual sal_Int64 SAL_CALL
114 : : getLong( sal_Int32 columnIndex )
115 : : throw( ::com::sun::star::sdbc::SQLException,
116 : : ::com::sun::star::uno::RuntimeException );
117 : : virtual float SAL_CALL
118 : : getFloat( sal_Int32 columnIndex )
119 : : throw( ::com::sun::star::sdbc::SQLException,
120 : : ::com::sun::star::uno::RuntimeException );
121 : : virtual double SAL_CALL
122 : : getDouble( sal_Int32 columnIndex )
123 : : throw( ::com::sun::star::sdbc::SQLException,
124 : : ::com::sun::star::uno::RuntimeException );
125 : : virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
126 : : getBytes( sal_Int32 columnIndex )
127 : : throw( ::com::sun::star::sdbc::SQLException,
128 : : ::com::sun::star::uno::RuntimeException );
129 : : virtual ::com::sun::star::util::Date SAL_CALL
130 : : getDate( sal_Int32 columnIndex )
131 : : throw( ::com::sun::star::sdbc::SQLException,
132 : : ::com::sun::star::uno::RuntimeException );
133 : : virtual ::com::sun::star::util::Time SAL_CALL
134 : : getTime( sal_Int32 columnIndex )
135 : : throw( ::com::sun::star::sdbc::SQLException,
136 : : ::com::sun::star::uno::RuntimeException );
137 : : virtual ::com::sun::star::util::DateTime SAL_CALL
138 : : getTimestamp( sal_Int32 columnIndex )
139 : : throw( ::com::sun::star::sdbc::SQLException,
140 : : ::com::sun::star::uno::RuntimeException );
141 : : virtual ::com::sun::star::uno::Reference<
142 : : ::com::sun::star::io::XInputStream > SAL_CALL
143 : : getBinaryStream( sal_Int32 columnIndex )
144 : : throw( ::com::sun::star::sdbc::SQLException,
145 : : ::com::sun::star::uno::RuntimeException );
146 : : virtual ::com::sun::star::uno::Reference<
147 : : ::com::sun::star::io::XInputStream > SAL_CALL
148 : : getCharacterStream( sal_Int32 columnIndex )
149 : : throw( ::com::sun::star::sdbc::SQLException,
150 : : ::com::sun::star::uno::RuntimeException );
151 : : virtual ::com::sun::star::uno::Any SAL_CALL
152 : : getObject( sal_Int32 columnIndex,
153 : : const ::com::sun::star::uno::Reference<
154 : : ::com::sun::star::container::XNameAccess >& typeMap )
155 : : throw( ::com::sun::star::sdbc::SQLException,
156 : : ::com::sun::star::uno::RuntimeException );
157 : : virtual ::com::sun::star::uno::Reference<
158 : : ::com::sun::star::sdbc::XRef > SAL_CALL
159 : : getRef( sal_Int32 columnIndex )
160 : : throw( ::com::sun::star::sdbc::SQLException,
161 : : ::com::sun::star::uno::RuntimeException );
162 : : virtual ::com::sun::star::uno::Reference<
163 : : ::com::sun::star::sdbc::XBlob > SAL_CALL
164 : : getBlob( sal_Int32 columnIndex )
165 : : throw( ::com::sun::star::sdbc::SQLException,
166 : : ::com::sun::star::uno::RuntimeException );
167 : : virtual ::com::sun::star::uno::Reference<
168 : : ::com::sun::star::sdbc::XClob > SAL_CALL
169 : : getClob( sal_Int32 columnIndex )
170 : : throw( ::com::sun::star::sdbc::SQLException,
171 : : ::com::sun::star::uno::RuntimeException );
172 : : virtual ::com::sun::star::uno::Reference<
173 : : ::com::sun::star::sdbc::XArray > SAL_CALL
174 : : getArray( sal_Int32 columnIndex )
175 : : throw( ::com::sun::star::sdbc::SQLException,
176 : : ::com::sun::star::uno::RuntimeException );
177 : :
178 : : // XColumnLocate
179 : : virtual sal_Int32 SAL_CALL
180 : : findColumn( const ::rtl::OUString& columnName )
181 : : throw( ::com::sun::star::sdbc::SQLException,
182 : : ::com::sun::star::uno::RuntimeException );
183 : :
184 : : //////////////////////////////////////////////////////////////////////
185 : : // Non-interface methods
186 : : //////////////////////////////////////////////////////////////////////
187 : :
188 : : void appendString( const ::rtl::OUString& rPropName, const ::rtl::OUString& rValue );
189 : : void appendString( const sal_Char* pAsciiPropName, const ::rtl::OUString& rValue )
190 : : {
191 : : appendString( ::rtl::OUString::createFromAscii( pAsciiPropName ), rValue );
192 : : }
193 : 319 : void appendString( const ::com::sun::star::beans::Property& rProp, const ::rtl::OUString& rValue )
194 : : {
195 : 319 : appendString( rProp.Name, rValue );
196 : 319 : }
197 : :
198 : : void appendBoolean( const ::rtl::OUString& rPropName, sal_Bool bValue );
199 : : void appendBoolean( const sal_Char* pAsciiPropName, sal_Bool bValue )
200 : : {
201 : : appendBoolean( ::rtl::OUString::createFromAscii( pAsciiPropName ), bValue );
202 : : }
203 : 474 : void appendBoolean( const ::com::sun::star::beans::Property& rProp, sal_Bool bValue )
204 : : {
205 : 474 : appendBoolean( rProp.Name, bValue );
206 : 474 : }
207 : :
208 : : void appendLong( const ::rtl::OUString& rPropName, sal_Int64 nValue );
209 : : void appendLong( const sal_Char* pAsciiPropName, sal_Int64 nValue )
210 : : {
211 : : appendLong( ::rtl::OUString::createFromAscii( pAsciiPropName ), nValue );
212 : : }
213 : 8 : void appendLong( const ::com::sun::star::beans::Property& rProp, sal_Int64 nValue )
214 : : {
215 : 8 : appendLong( rProp.Name, nValue );
216 : 8 : }
217 : :
218 : : void appendTimestamp( const ::rtl::OUString& rPropName, const ::com::sun::star::util::DateTime& rValue );
219 : : void appendTimestamp( const sal_Char* pAsciiPropName, const ::com::sun::star::util::DateTime& rValue )
220 : : {
221 : : appendTimestamp( ::rtl::OUString::createFromAscii( pAsciiPropName ), rValue );
222 : : }
223 : 0 : void appendTimestamp( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::util::DateTime& rValue )
224 : : {
225 : 0 : appendTimestamp( rProp.Name, rValue );
226 : 0 : }
227 : :
228 : : void appendObject( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Any& rValue );
229 : : void appendObject( const sal_Char* pAsciiPropName, const ::com::sun::star::uno::Any& rValue )
230 : : {
231 : : appendObject( ::rtl::OUString::createFromAscii( pAsciiPropName ), rValue );
232 : : }
233 : 185 : void appendObject( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::uno::Any& rValue )
234 : : {
235 : 185 : appendObject( rProp.Name, rValue );
236 : 185 : }
237 : :
238 : : void appendVoid( const ::rtl::OUString& rPropName );
239 : : void appendVoid( const sal_Char* pAsciiPropName)
240 : : {
241 : : appendVoid( ::rtl::OUString::createFromAscii( pAsciiPropName ) );
242 : : }
243 : 20 : void appendVoid( const ::com::sun::star::beans::Property& rProp )
244 : : {
245 : 20 : appendVoid( rProp.Name );
246 : 20 : }
247 : :
248 : : /**
249 : : * This method tries to append all property values contained in a
250 : : * property set to the value set.
251 : : *
252 : : * @param rSet is a property set containing the property values.
253 : : */
254 : : void appendPropertySet( const ::com::sun::star::uno::Reference<
255 : : ::com::sun::star::beans::XPropertySet >& rSet );
256 : :
257 : : /** This method tries to append a single property value contained in a
258 : : * property set to the value set.
259 : : *
260 : : * @param rSet is a property set containing the property values.
261 : : * @param rProperty is the property for that the value shall be obtained
262 : : * from the given property set.
263 : : * @return False, if the property value cannot be obtained from the
264 : : * given property pet. True, otherwise.
265 : : */
266 : : sal_Bool appendPropertySetValue(
267 : : const ::com::sun::star::uno::Reference<
268 : : ::com::sun::star::beans::XPropertySet >& rSet,
269 : : const ::com::sun::star::beans::Property& rProperty );
270 : : };
271 : :
272 : : }
273 : :
274 : : #endif /* !_UCBHELPER_PROPERTYVALUESET_HXX */
275 : :
276 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|