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.hxx>
26 #include <com/sun/star/uno/Sequence.hxx>
27 #include <com/sun/star/lang/XTypeProvider.hpp>
28 #include <com/sun/star/sdbc/ColumnValue.hpp>
29 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
30 #include <cppuhelper/weak.hxx>
31 #include <ucbhelper/macros.hxx>
32 #include <ucbhelper/ucbhelperdllapi.h>
34 namespace com
{ namespace sun
{ namespace star
{
35 namespace lang
{ class XMultiServiceFactory
; }
36 namespace beans
{ struct Property
; }
39 namespace ucbhelper_impl
{
40 struct ResultSetMetaData_Impl
;
48 * This is a structure that holds additional meta data for one column
49 * of a resultset. The default values set in the constructor should be a
50 * good guess for many UCB use cases.
52 struct ResultSetColumnData
54 /** @see ResultSetMetaData::isCaseSensitive */
57 /** @see ResultSetMetaData::getColumnDisplaySize */
58 sal_Int32 columnDisplaySize
;
60 /** @see ResultSetMetaData::getColumnLabel */
63 /** @see ResultSetMetaData::getSchemaName */
66 /** @see ResultSetMetaData::getTableName */
69 /** @see ResultSetMetaData::getCatalogName */
72 /** @see ResultSetMetaData::getColumnTypeName */
73 OUString columnTypeName
;
75 /** @see ResultSetMetaData::getColumnServiceName */
76 OUString columnServiceName
;
78 inline ResultSetColumnData();
81 // Note: Never change the initial values! Implementations using this struct
82 // may heavily depend on the behaviour of the default constructor.
84 ResultSetColumnData::ResultSetColumnData()
85 : isCaseSensitive( true ),
86 columnDisplaySize( 16 )
92 * This is an implementation of the interface XResultSetMetaData. It can be
93 * used to implement the interface
94 * css::sdbc::XResultSetMetaDataSupplier, which is required for
95 * implementations of service com.sun.star.ucb.ContentResultSet.
97 class UCBHELPER_DLLPUBLIC ResultSetMetaData
:
98 public ::cppu::OWeakObject
,
99 public css::lang::XTypeProvider
,
100 public css::sdbc::XResultSetMetaData
103 std::unique_ptr
<ucbhelper_impl::ResultSetMetaData_Impl
> m_pImpl
;
106 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
107 css::uno::Sequence
< css::beans::Property
> m_aProps
;
112 * Constructor. ResultSet is readonly by default.
114 * @param rxSMgr is a Servive Manager.
115 * @param rProps is a sequence of properties (partially) describing the
116 * columns of a resultset.
119 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
120 const css::uno::Sequence
< css::beans::Property
>& rProps
);
125 * @param rxSMgr is a Servive Manager.
126 * @param rProps is a sequence of properties (partially) describing the
127 * columns of a resultset.
128 * @param rColumnData contains additional meta data for the columns of
129 * a resultset, which override the default values returned by the
130 * appropriate methods of this class. The length of rColumnData
131 * must be the same as length of rProps.
132 * rColumnData[ 0 ] corresponds to data in rProps[ 0 ],
133 * rColumnData[ 1 ] corresponds to data in rProps[ 1 ], ...
136 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
137 const css::uno::Sequence
< css::beans::Property
>& rProps
,
138 const std::vector
< ResultSetColumnData
>& rColumnData
);
143 virtual ~ResultSetMetaData() override
;
146 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
147 virtual void SAL_CALL
acquire()
149 virtual void SAL_CALL
release()
153 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
154 getImplementationId() override
;
155 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
158 // XResultSetMetaData
161 * Returns the number of columns of the resultset.
163 * @return the length of the property sequence.
165 virtual sal_Int32 SAL_CALL
166 getColumnCount() override
;
168 * Checks whether column is automatically numbered, which makes it
171 * @param column is the number of the column for that a value shall
172 * be returned. The first column is 1, the second is 2, ...
173 * @return true, if column is automatically numbered.
175 virtual sal_Bool SAL_CALL
176 isAutoIncrement( sal_Int32 column
) override
;
178 * Checks whether column is case sensitive.
180 * @param column is the number of the column for that a value shall
181 * be returned. The first column is 1, the second is 2, ...
182 * @return true, if column is case sensitive.
184 virtual sal_Bool SAL_CALL
185 isCaseSensitive( sal_Int32 column
) override
;
187 * Checks whether the value stored in column can be used in a
190 * @param column is the number of the column for that a value shall
191 * be returned. The first column is 1, the second is 2, ...
192 * @return true, if the column is searchable.
194 virtual sal_Bool SAL_CALL
195 isSearchable( sal_Int32 column
) override
;
197 * Checks whether column is a cash value.
199 * @param column is the number of the column for that a value shall
200 * be returned. The first column is 1, the second is 2, ...
201 * @return true, if the column is a cash value.
203 virtual sal_Bool SAL_CALL
204 isCurrency( sal_Int32 column
) override
;
206 * Checks whether a NULL can be stored in column.
208 * @see css::sdbc::ColumnValue
210 * @param column is the number of the column for that a value shall
211 * be returned. The first column is 1, the second is 2, ...
212 * @return css::sdbc::ColumnValue::NULLABLE, if a NULL
213 * can be stored in the column.
215 virtual sal_Int32 SAL_CALL
216 isNullable( sal_Int32 column
) override
;
218 * Checks whether the value stored in column is a signed number.
220 * @param column is the number of the column for that a value shall
221 * be returned. The first column is 1, the second is 2, ...
222 * @return true, if the value stored in column is a signed number.
224 virtual sal_Bool SAL_CALL
225 isSigned( sal_Int32 column
) override
;
227 * Gets the normal maximum width in characters for column.
229 * @param column is the number of the column for that a value shall
230 * be returned. The first column is 1, the second is 2, ...
231 * @return the normal maximum width in characters for column.
233 virtual sal_Int32 SAL_CALL
234 getColumnDisplaySize( sal_Int32 column
) override
;
236 * Gets the suggested column title for column, to be used in print-
239 * @param column is the number of the column for that a value shall
240 * be returned. The first column is 1, the second is 2, ...
241 * @return the column label.
243 virtual OUString SAL_CALL
244 getColumnLabel( sal_Int32 column
) override
;
246 * Gets the name of column.
248 * @param column is the number of the column for that a value shall
249 * be returned. The first column is 1, the second is 2, ...
250 * @return the name of the property that corresponds to column.
252 virtual OUString SAL_CALL
253 getColumnName( sal_Int32 column
) override
;
255 * Gets the schema name for the table from which column of this
256 * result set was derived.
257 * Because this feature is not widely supported, the return value
258 * for many DBMSs will be an empty string.
260 * @param column is the number of the column for that a value shall
261 * be returned. The first column is 1, the second is 2, ...
262 * @return the schema name of column or an empty string.
264 virtual OUString SAL_CALL
265 getSchemaName( sal_Int32 column
) override
;
267 * For number types, getprecision gets the number of decimal digits
269 * For character types, it gets the maximum length in characters for
271 * For binary types, it gets the maximum length in bytes for column.
273 * @param column is the number of the column for that a value shall
274 * be returned. The first column is 1, the second is 2, ...
275 * @return the precision for the column.
277 virtual sal_Int32 SAL_CALL
278 getPrecision( sal_Int32 column
) override
;
280 * Gets the number of digits to the right of the decimal point for
283 * @param column is the number of the column for that a value shall
284 * be returned. The first column is 1, the second is 2, ...
285 * @return the scale of the column.
287 virtual sal_Int32 SAL_CALL
288 getScale( sal_Int32 column
) override
;
290 * Gets the name of the table from which column of this result set
291 * was derived or "" if there is none (for example, for a join).
292 * Because this feature is not widely supported, the return value
293 * for many DBMSs will be an empty string.
295 * @param column is the number of the column for that a value shall
296 * be returned. The first column is 1, the second is 2, ...
297 * @return the table name for column or an empty string.
299 virtual OUString SAL_CALL
300 getTableName( sal_Int32 column
) override
;
301 virtual OUString SAL_CALL
303 * Gets the catalog name for the table from which column of this
304 * result set was derived.
305 * Because this feature is not widely supported, the return value
306 * for many DBMSs will be an empty string.
308 * @param column is the number of the column for that a value shall
309 * be returned. The first column is 1, the second is 2, ...
310 * @return the catalog name for column or an empty string.
312 getCatalogName( sal_Int32 column
) override
;
314 * Gets the JDBC type for the value stored in column. ... The STRUCT
315 * and DISTINCT type codes are always returned for structured and
316 * distinct types, regardless of whether the value will be mapped
317 * according to the standard mapping or be a custom mapping.
319 * @param column is the number of the column for that a value shall
320 * be returned. The first column is 1, the second is 2, ...
321 * @return the type of the property that corresponds to column - mapped
322 * from UNO-Type to SQL-Type.
324 virtual sal_Int32 SAL_CALL
325 getColumnType( sal_Int32 column
) override
;
327 * Gets the type name used by this particular data source for the
328 * values stored in column. If the type code for the type of value
329 * stored in column is STRUCT, DISTINCT or JAVA_OBJECT, this method
330 * returns a fully-qualified SQL type name.
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 the column type name.
336 virtual OUString SAL_CALL
337 getColumnTypeName( sal_Int32 column
) override
;
339 * Indicates whether a column is definitely not writable.
341 * @param column is the number of the column for that a value shall
342 * be returned. The first column is 1, the second is 2, ...
343 * @return true, if the column is definetely not writable.
345 virtual sal_Bool SAL_CALL
346 isReadOnly( sal_Int32 column
) override
;
348 * Indicates whether it is possible for a write on the column to succeed.
350 * @param column is the number of the column for that a value shall
351 * be returned. The first column is 1, the second is 2, ...
352 * @return true, if it is possible for a write to succeed.
354 virtual sal_Bool SAL_CALL
355 isWritable( sal_Int32 column
) override
;
357 * Indicates whether a write on the column will definitely succeed.
359 * @param column is the number of the column for that a value shall
360 * be returned. The first column is 1, the second is 2, ...
361 * @return true, if a write on the column will definetely succeed.
363 virtual sal_Bool SAL_CALL
364 isDefinitelyWritable( sal_Int32 column
) override
;
366 * Returns the fully-qualified name of the service whose instances
367 * are manufactured if the method
368 * css::sdbc::ResultSet::getObject is called to retrieve a
369 * value from the column.
371 * @param column is the number of the column for that a value shall
372 * be returned. The first column is 1, the second is 2, ...
373 * @return the service name for column or an empty string, if no service
376 virtual OUString SAL_CALL
377 getColumnServiceName( sal_Int32 column
) override
;
380 } // namespace ucbhelper
382 #endif /* ! INCLUDED_UCBHELPER_RESULTSETMETADATA_HXX */
384 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */