1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_RESULTSETMETADATA_HXX
21 #define INCLUDED_UCBHELPER_RESULTSETMETADATA_HXX
25 #include <com/sun/star/uno/Reference.h>
26 #include <com/sun/star/uno/Sequence.h>
27 #include <com/sun/star/lang/XTypeProvider.hpp>
28 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
29 #include <cppuhelper/weak.hxx>
30 #include <ucbhelper/ucbhelperdllapi.h>
32 namespace com
{ namespace sun
{ namespace star
{
33 namespace beans
{ struct Property
; }
34 namespace uno
{ class XComponentContext
; }
37 namespace ucbhelper_impl
{
38 struct ResultSetMetaData_Impl
;
46 * This is a structure that holds additional meta data for one column
47 * of a resultset. The default values set in the constructor should be a
48 * good guess for many UCB use cases.
50 struct ResultSetColumnData
52 /** @see ResultSetMetaData::isCaseSensitive */
55 inline ResultSetColumnData();
58 // Note: Never change the initial values! Implementations using this struct
59 // may heavily depend on the behaviour of the default constructor.
61 ResultSetColumnData::ResultSetColumnData()
62 : isCaseSensitive( true )
68 * This is an implementation of the interface XResultSetMetaData. It can be
69 * used to implement the interface
70 * css::sdbc::XResultSetMetaDataSupplier, which is required for
71 * implementations of service com.sun.star.ucb.ContentResultSet.
73 class UCBHELPER_DLLPUBLIC ResultSetMetaData final
:
74 public ::cppu::OWeakObject
,
75 public css::lang::XTypeProvider
,
76 public css::sdbc::XResultSetMetaData
78 std::unique_ptr
<ucbhelper_impl::ResultSetMetaData_Impl
> m_pImpl
;
79 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
80 css::uno::Sequence
< css::beans::Property
> m_aProps
;
85 * Constructor. ResultSet is readonly by default.
87 * @param rxSMgr is a Servive Manager.
88 * @param rProps is a sequence of properties (partially) describing the
89 * columns of a resultset.
92 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
93 const css::uno::Sequence
< css::beans::Property
>& rProps
);
98 * @param rxSMgr is a Servive Manager.
99 * @param rProps is a sequence of properties (partially) describing the
100 * columns of a resultset.
101 * @param rColumnData contains additional meta data for the columns of
102 * a resultset, which override the default values returned by the
103 * appropriate methods of this class. The length of rColumnData
104 * must be the same as length of rProps.
105 * rColumnData[ 0 ] corresponds to data in rProps[ 0 ],
106 * rColumnData[ 1 ] corresponds to data in rProps[ 1 ], ...
109 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
110 const css::uno::Sequence
< css::beans::Property
>& rProps
,
111 const std::vector
< ResultSetColumnData
>& rColumnData
);
116 virtual ~ResultSetMetaData() override
;
119 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
120 virtual void SAL_CALL
acquire()
122 virtual void SAL_CALL
release()
126 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
127 getImplementationId() override
;
128 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
131 // XResultSetMetaData
134 * Returns the number of columns of the resultset.
136 * @return the length of the property sequence.
138 virtual sal_Int32 SAL_CALL
139 getColumnCount() override
;
141 * Checks whether column is automatically numbered, which makes it
144 * @param column is the number of the column for that a value shall
145 * be returned. The first column is 1, the second is 2, ...
146 * @return true, if column is automatically numbered.
148 virtual sal_Bool SAL_CALL
149 isAutoIncrement( sal_Int32 column
) override
;
151 * Checks whether column is case sensitive.
153 * @param column is the number of the column for that a value shall
154 * be returned. The first column is 1, the second is 2, ...
155 * @return true, if column is case sensitive.
157 virtual sal_Bool SAL_CALL
158 isCaseSensitive( sal_Int32 column
) override
;
160 * Checks whether the value stored in column can be used in a
163 * @param column is the number of the column for that a value shall
164 * be returned. The first column is 1, the second is 2, ...
165 * @return true, if the column is searchable.
167 virtual sal_Bool SAL_CALL
168 isSearchable( sal_Int32 column
) override
;
170 * Checks whether column is a cash value.
172 * @param column is the number of the column for that a value shall
173 * be returned. The first column is 1, the second is 2, ...
174 * @return true, if the column is a cash value.
176 virtual sal_Bool SAL_CALL
177 isCurrency( sal_Int32 column
) override
;
179 * Checks whether a NULL can be stored in column.
181 * @see css::sdbc::ColumnValue
183 * @param column is the number of the column for that a value shall
184 * be returned. The first column is 1, the second is 2, ...
185 * @return css::sdbc::ColumnValue::NULLABLE, if a NULL
186 * can be stored in the column.
188 virtual sal_Int32 SAL_CALL
189 isNullable( sal_Int32 column
) override
;
191 * Checks whether the value stored in column is a signed number.
193 * @param column is the number of the column for that a value shall
194 * be returned. The first column is 1, the second is 2, ...
195 * @return true, if the value stored in column is a signed number.
197 virtual sal_Bool SAL_CALL
198 isSigned( sal_Int32 column
) override
;
200 * Gets the normal maximum width in characters for column.
202 * @param column is the number of the column for that a value shall
203 * be returned. The first column is 1, the second is 2, ...
204 * @return the normal maximum width in characters for column.
206 virtual sal_Int32 SAL_CALL
207 getColumnDisplaySize( sal_Int32 column
) override
;
209 * Gets the suggested column title for column, to be used in print-
212 * @param column is the number of the column for that a value shall
213 * be returned. The first column is 1, the second is 2, ...
214 * @return the column label.
216 virtual OUString SAL_CALL
217 getColumnLabel( sal_Int32 column
) override
;
219 * Gets the name of column.
221 * @param column is the number of the column for that a value shall
222 * be returned. The first column is 1, the second is 2, ...
223 * @return the name of the property that corresponds to column.
225 virtual OUString SAL_CALL
226 getColumnName( sal_Int32 column
) override
;
228 * Gets the schema name for the table from which column of this
229 * result set was derived.
230 * Because this feature is not widely supported, the return value
231 * for many DBMSs will be an empty string.
233 * @param column is the number of the column for that a value shall
234 * be returned. The first column is 1, the second is 2, ...
235 * @return the schema name of column or an empty string.
237 virtual OUString SAL_CALL
238 getSchemaName( sal_Int32 column
) override
;
240 * For number types, getprecision gets the number of decimal digits
242 * For character types, it gets the maximum length in characters for
244 * For binary types, it gets the maximum length in bytes for column.
246 * @param column is the number of the column for that a value shall
247 * be returned. The first column is 1, the second is 2, ...
248 * @return the precision for the column.
250 virtual sal_Int32 SAL_CALL
251 getPrecision( sal_Int32 column
) override
;
253 * Gets the number of digits to the right of the decimal point for
256 * @param column is the number of the column for that a value shall
257 * be returned. The first column is 1, the second is 2, ...
258 * @return the scale of the column.
260 virtual sal_Int32 SAL_CALL
261 getScale( sal_Int32 column
) override
;
263 * Gets the name of the table from which column of this result set
264 * was derived or "" if there is none (for example, for a join).
265 * Because this feature is not widely supported, the return value
266 * for many DBMSs will be an empty string.
268 * @param column is the number of the column for that a value shall
269 * be returned. The first column is 1, the second is 2, ...
270 * @return the table name for column or an empty string.
272 virtual OUString SAL_CALL
273 getTableName( sal_Int32 column
) override
;
274 virtual OUString SAL_CALL
276 * Gets the catalog name for the table from which column of this
277 * result set was derived.
278 * Because this feature is not widely supported, the return value
279 * for many DBMSs will be an empty string.
281 * @param column is the number of the column for that a value shall
282 * be returned. The first column is 1, the second is 2, ...
283 * @return the catalog name for column or an empty string.
285 getCatalogName( sal_Int32 column
) override
;
287 * Gets the JDBC type for the value stored in column. ... The STRUCT
288 * and DISTINCT type codes are always returned for structured and
289 * distinct types, regardless of whether the value will be mapped
290 * according to the standard mapping or be a custom mapping.
292 * @param column is the number of the column for that a value shall
293 * be returned. The first column is 1, the second is 2, ...
294 * @return the type of the property that corresponds to column - mapped
295 * from UNO-Type to SQL-Type.
297 virtual sal_Int32 SAL_CALL
298 getColumnType( sal_Int32 column
) override
;
300 * Gets the type name used by this particular data source for the
301 * values stored in column. If the type code for the type of value
302 * stored in column is STRUCT, DISTINCT or JAVA_OBJECT, this method
303 * returns a fully-qualified SQL type name.
305 * @param column is the number of the column for that a value shall
306 * be returned. The first column is 1, the second is 2, ...
307 * @return the column type name.
309 virtual OUString SAL_CALL
310 getColumnTypeName( sal_Int32 column
) override
;
312 * Indicates whether a column is definitely not writable.
314 * @param column is the number of the column for that a value shall
315 * be returned. The first column is 1, the second is 2, ...
316 * @return true, if the column is definetely not writable.
318 virtual sal_Bool SAL_CALL
319 isReadOnly( sal_Int32 column
) override
;
321 * Indicates whether it is possible for a write on the column to succeed.
323 * @param column is the number of the column for that a value shall
324 * be returned. The first column is 1, the second is 2, ...
325 * @return true, if it is possible for a write to succeed.
327 virtual sal_Bool SAL_CALL
328 isWritable( sal_Int32 column
) override
;
330 * Indicates whether a write on the column will definitely succeed.
332 * @param column is the number of the column for that a value shall
333 * be returned. The first column is 1, the second is 2, ...
334 * @return true, if a write on the column will definetely succeed.
336 virtual sal_Bool SAL_CALL
337 isDefinitelyWritable( sal_Int32 column
) override
;
339 * Returns the fully-qualified name of the service whose instances
340 * are manufactured if the method
341 * css::sdbc::ResultSet::getObject is called to retrieve a
342 * value from the column.
344 * @param column is the number of the column for that a value shall
345 * be returned. The first column is 1, the second is 2, ...
346 * @return the service name for column or an empty string, if no service
349 virtual OUString SAL_CALL
350 getColumnServiceName( sal_Int32 column
) override
;
353 } // namespace ucbhelper
355 #endif /* ! INCLUDED_UCBHELPER_RESULTSETMETADATA_HXX */
357 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */