Branch libreoffice-5-0-4
[LibreOffice.git] / include / ucbhelper / propertyvalueset.hxx
blobc55737379f476dec35a884f467ef8347b59fd840
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_UCBHELPER_PROPERTYVALUESET_HXX
21 #define INCLUDED_UCBHELPER_PROPERTYVALUESET_HXX
23 #include <com/sun/star/lang/XTypeProvider.hpp>
24 #include <com/sun/star/sdbc/XColumnLocate.hpp>
25 #include <com/sun/star/sdbc/XRow.hpp>
26 #include <com/sun/star/beans/Property.hpp>
27 #include <cppuhelper/weak.hxx>
29 #include <osl/mutex.hxx>
30 #include <ucbhelper/macros.hxx>
31 #include <ucbhelper/ucbhelperdllapi.h>
33 namespace com { namespace sun { namespace star { namespace script {
34 class XTypeConverter;
35 } } } }
37 namespace com { namespace sun { namespace star { namespace beans {
38 struct PropertyValue;
39 class XPropertySet;
40 } } } }
42 namespace ucbhelper {
44 class PropertyValues;
48 /**
49 * This class implements the interface XRow. After construction of a valueset
50 * the user can append properties ( incl. its values ) to the set. This class
51 * is useful when implementing the command "getPropertyValues", because the
52 * values to return can easily appended to a valueset object. That object can
53 * directly be returned by the implementation of the command.
55 class UCBHELPER_DLLPUBLIC PropertyValueSet :
56 public cppu::OWeakObject,
57 public com::sun::star::lang::XTypeProvider,
58 public com::sun::star::sdbc::XRow,
59 public com::sun::star::sdbc::XColumnLocate
61 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
62 m_xContext;
63 com::sun::star::uno::Reference< com::sun::star::script::XTypeConverter >
64 m_xTypeConverter;
65 osl::Mutex m_aMutex;
66 PropertyValues* m_pValues;
67 bool m_bWasNull;
68 bool m_bTriedToGetTypeConverter;
70 private:
71 UCBHELPER_DLLPRIVATE const com::sun::star::uno::Reference<
72 com::sun::star::script::XTypeConverter >&
73 getTypeConverter();
75 public:
76 PropertyValueSet(
77 const com::sun::star::uno::Reference<
78 com::sun::star::uno::XComponentContext >& rxContext );
79 virtual ~PropertyValueSet();
81 // XInterface
82 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType )
83 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
84 virtual void SAL_CALL acquire()
85 throw() SAL_OVERRIDE;
86 virtual void SAL_CALL release()
87 throw() SAL_OVERRIDE;
89 // XTypeProvider
90 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
91 getImplementationId()
92 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
93 virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL
94 getTypes()
95 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
97 // XRow
98 virtual sal_Bool SAL_CALL
99 wasNull()
100 throw( ::com::sun::star::sdbc::SQLException,
101 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
102 virtual OUString SAL_CALL
103 getString( sal_Int32 columnIndex )
104 throw( ::com::sun::star::sdbc::SQLException,
105 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
106 virtual sal_Bool SAL_CALL
107 getBoolean( sal_Int32 columnIndex )
108 throw( ::com::sun::star::sdbc::SQLException,
109 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
110 virtual sal_Int8 SAL_CALL
111 getByte( sal_Int32 columnIndex )
112 throw( ::com::sun::star::sdbc::SQLException,
113 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
114 virtual sal_Int16 SAL_CALL
115 getShort( sal_Int32 columnIndex )
116 throw( ::com::sun::star::sdbc::SQLException,
117 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
118 virtual sal_Int32 SAL_CALL
119 getInt( sal_Int32 columnIndex )
120 throw( ::com::sun::star::sdbc::SQLException,
121 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
122 virtual sal_Int64 SAL_CALL
123 getLong( sal_Int32 columnIndex )
124 throw( ::com::sun::star::sdbc::SQLException,
125 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
126 virtual float SAL_CALL
127 getFloat( sal_Int32 columnIndex )
128 throw( ::com::sun::star::sdbc::SQLException,
129 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
130 virtual double SAL_CALL
131 getDouble( sal_Int32 columnIndex )
132 throw( ::com::sun::star::sdbc::SQLException,
133 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
134 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
135 getBytes( sal_Int32 columnIndex )
136 throw( ::com::sun::star::sdbc::SQLException,
137 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
138 virtual ::com::sun::star::util::Date SAL_CALL
139 getDate( sal_Int32 columnIndex )
140 throw( ::com::sun::star::sdbc::SQLException,
141 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
142 virtual ::com::sun::star::util::Time SAL_CALL
143 getTime( sal_Int32 columnIndex )
144 throw( ::com::sun::star::sdbc::SQLException,
145 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
146 virtual ::com::sun::star::util::DateTime SAL_CALL
147 getTimestamp( sal_Int32 columnIndex )
148 throw( ::com::sun::star::sdbc::SQLException,
149 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
150 virtual ::com::sun::star::uno::Reference<
151 ::com::sun::star::io::XInputStream > SAL_CALL
152 getBinaryStream( sal_Int32 columnIndex )
153 throw( ::com::sun::star::sdbc::SQLException,
154 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
155 virtual ::com::sun::star::uno::Reference<
156 ::com::sun::star::io::XInputStream > SAL_CALL
157 getCharacterStream( sal_Int32 columnIndex )
158 throw( ::com::sun::star::sdbc::SQLException,
159 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
160 virtual ::com::sun::star::uno::Any SAL_CALL
161 getObject( sal_Int32 columnIndex,
162 const ::com::sun::star::uno::Reference<
163 ::com::sun::star::container::XNameAccess >& typeMap )
164 throw( ::com::sun::star::sdbc::SQLException,
165 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
166 virtual ::com::sun::star::uno::Reference<
167 ::com::sun::star::sdbc::XRef > SAL_CALL
168 getRef( sal_Int32 columnIndex )
169 throw( ::com::sun::star::sdbc::SQLException,
170 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
171 virtual ::com::sun::star::uno::Reference<
172 ::com::sun::star::sdbc::XBlob > SAL_CALL
173 getBlob( sal_Int32 columnIndex )
174 throw( ::com::sun::star::sdbc::SQLException,
175 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
176 virtual ::com::sun::star::uno::Reference<
177 ::com::sun::star::sdbc::XClob > SAL_CALL
178 getClob( sal_Int32 columnIndex )
179 throw( ::com::sun::star::sdbc::SQLException,
180 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
181 virtual ::com::sun::star::uno::Reference<
182 ::com::sun::star::sdbc::XArray > SAL_CALL
183 getArray( sal_Int32 columnIndex )
184 throw( ::com::sun::star::sdbc::SQLException,
185 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
187 // XColumnLocate
188 virtual sal_Int32 SAL_CALL
189 findColumn( const OUString& columnName )
190 throw( ::com::sun::star::sdbc::SQLException,
191 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
194 // Non-interface methods
197 void appendString( const OUString& rPropName, const OUString& rValue );
198 void appendString( const sal_Char* pAsciiPropName, const OUString& rValue )
200 appendString( OUString::createFromAscii( pAsciiPropName ), rValue );
202 void appendString( const ::com::sun::star::beans::Property& rProp, const OUString& rValue )
204 appendString( rProp.Name, rValue );
207 void appendBoolean( const OUString& rPropName, bool bValue );
208 void appendBoolean( const sal_Char* pAsciiPropName, bool bValue )
210 appendBoolean( OUString::createFromAscii( pAsciiPropName ), bValue );
212 void appendBoolean( const ::com::sun::star::beans::Property& rProp, bool bValue )
214 appendBoolean( rProp.Name, bValue );
217 void appendLong( const OUString& rPropName, sal_Int64 nValue );
218 void appendLong( const sal_Char* pAsciiPropName, sal_Int64 nValue )
220 appendLong( OUString::createFromAscii( pAsciiPropName ), nValue );
222 void appendLong( const ::com::sun::star::beans::Property& rProp, sal_Int64 nValue )
224 appendLong( rProp.Name, nValue );
227 void appendTimestamp( const OUString& rPropName, const ::com::sun::star::util::DateTime& rValue );
228 void appendTimestamp( const sal_Char* pAsciiPropName, const ::com::sun::star::util::DateTime& rValue )
230 appendTimestamp( OUString::createFromAscii( pAsciiPropName ), rValue );
232 void appendTimestamp( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::util::DateTime& rValue )
234 appendTimestamp( rProp.Name, rValue );
237 void appendObject( const OUString& rPropName, const ::com::sun::star::uno::Any& rValue );
238 void appendObject( const sal_Char* pAsciiPropName, const ::com::sun::star::uno::Any& rValue )
240 appendObject( OUString::createFromAscii( pAsciiPropName ), rValue );
242 void appendObject( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::uno::Any& rValue )
244 appendObject( rProp.Name, rValue );
247 void appendVoid( const OUString& rPropName );
248 void appendVoid( const sal_Char* pAsciiPropName)
250 appendVoid( OUString::createFromAscii( pAsciiPropName ) );
252 void appendVoid( const ::com::sun::star::beans::Property& rProp )
254 appendVoid( rProp.Name );
258 * This method tries to append all property values contained in a
259 * property set to the value set.
261 * @param rSet is a property set containing the property values.
263 void appendPropertySet( const ::com::sun::star::uno::Reference<
264 ::com::sun::star::beans::XPropertySet >& rSet );
266 /** This method tries to append a single property value contained in a
267 * property set to the value set.
269 * @param rSet is a property set containing the property values.
270 * @param rProperty is the property for that the value shall be obtained
271 * from the given property set.
272 * @return False, if the property value cannot be obtained from the
273 * given property pet. True, otherwise.
275 bool appendPropertySetValue(
276 const ::com::sun::star::uno::Reference<
277 ::com::sun::star::beans::XPropertySet >& rSet,
278 const ::com::sun::star::beans::Property& rProperty );
283 #endif /* ! INCLUDED_UCBHELPER_PROPERTYVALUESET_HXX */
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */