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/sdbc/XResultSetMetaData.hpp>
28 #include <cppuhelper/implbase.hxx>
29 #include <ucbhelper/ucbhelperdllapi.h>
31 namespace com::sun::star
{
32 namespace beans
{ struct Property
; }
33 namespace uno
{ class XComponentContext
; }
36 namespace ucbhelper_impl
{
37 struct ResultSetMetaData_Impl
;
45 * This is a structure that holds additional meta data for one column
46 * of a resultset. The default values set in the constructor should be a
47 * good guess for many UCB use cases.
49 struct ResultSetColumnData
51 /** @see ResultSetMetaData::isCaseSensitive */
54 inline ResultSetColumnData();
57 // Note: Never change the initial values! Implementations using this struct
58 // may heavily depend on the behaviour of the default constructor.
60 ResultSetColumnData::ResultSetColumnData()
61 : isCaseSensitive( true )
67 * This is an implementation of the interface XResultSetMetaData. It can be
68 * used to implement the interface
69 * css::sdbc::XResultSetMetaDataSupplier, which is required for
70 * implementations of service com.sun.star.ucb.ContentResultSet.
72 class ResultSetMetaData final
:
73 public cppu::WeakImplHelper
<css::sdbc::XResultSetMetaData
>
75 std::unique_ptr
<ucbhelper_impl::ResultSetMetaData_Impl
> m_pImpl
;
76 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
77 css::uno::Sequence
< css::beans::Property
> m_aProps
;
82 * Constructor. ResultSet is readonly by default.
84 * @param rxSMgr is a Service Manager.
85 * @param rProps is a sequence of properties (partially) describing the
86 * columns of a resultset.
88 UCBHELPER_DLLPUBLIC
ResultSetMetaData(
89 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
90 const css::uno::Sequence
< css::beans::Property
>& rProps
);
95 * @param rxSMgr is a Service Manager.
96 * @param rProps is a sequence of properties (partially) describing the
97 * columns of a resultset.
98 * @param rColumnData contains additional meta data for the columns of
99 * a resultset, which override the default values returned by the
100 * appropriate methods of this class. The length of rColumnData
101 * must be the same as length of rProps.
102 * rColumnData[ 0 ] corresponds to data in rProps[ 0 ],
103 * rColumnData[ 1 ] corresponds to data in rProps[ 1 ], ...
105 UCBHELPER_DLLPUBLIC
ResultSetMetaData(
106 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
107 const css::uno::Sequence
< css::beans::Property
>& rProps
,
108 std::vector
< ResultSetColumnData
>&& rColumnData
);
113 virtual ~ResultSetMetaData() override
;
115 // XResultSetMetaData
118 * Returns the number of columns of the resultset.
120 * @return the length of the property sequence.
122 virtual sal_Int32 SAL_CALL
123 getColumnCount() override
;
125 * Checks whether column is automatically numbered, which makes it
128 * @param column is the number of the column for that a value shall
129 * be returned. The first column is 1, the second is 2, ...
130 * @return true, if column is automatically numbered.
132 virtual sal_Bool SAL_CALL
133 isAutoIncrement( sal_Int32 column
) override
;
135 * Checks whether column is case sensitive.
137 * @param column is the number of the column for that a value shall
138 * be returned. The first column is 1, the second is 2, ...
139 * @return true, if column is case sensitive.
141 virtual sal_Bool SAL_CALL
142 isCaseSensitive( sal_Int32 column
) override
;
144 * Checks whether the value stored in column can be used in a
147 * @param column is the number of the column for that a value shall
148 * be returned. The first column is 1, the second is 2, ...
149 * @return true, if the column is searchable.
151 virtual sal_Bool SAL_CALL
152 isSearchable( sal_Int32 column
) override
;
154 * Checks whether column is a cash value.
156 * @param column is the number of the column for that a value shall
157 * be returned. The first column is 1, the second is 2, ...
158 * @return true, if the column is a cash value.
160 virtual sal_Bool SAL_CALL
161 isCurrency( sal_Int32 column
) override
;
163 * Checks whether a NULL can be stored in column.
165 * @see css::sdbc::ColumnValue
167 * @param column is the number of the column for that a value shall
168 * be returned. The first column is 1, the second is 2, ...
169 * @return css::sdbc::ColumnValue::NULLABLE, if a NULL
170 * can be stored in the column.
172 virtual sal_Int32 SAL_CALL
173 isNullable( sal_Int32 column
) override
;
175 * Checks whether the value stored in column is a signed number.
177 * @param column is the number of the column for that a value shall
178 * be returned. The first column is 1, the second is 2, ...
179 * @return true, if the value stored in column is a signed number.
181 virtual sal_Bool SAL_CALL
182 isSigned( sal_Int32 column
) override
;
184 * Gets the normal maximum width in characters for column.
186 * @param column is the number of the column for that a value shall
187 * be returned. The first column is 1, the second is 2, ...
188 * @return the normal maximum width in characters for column.
190 virtual sal_Int32 SAL_CALL
191 getColumnDisplaySize( sal_Int32 column
) override
;
193 * Gets the suggested column title for column, to be used in print-
196 * @param column is the number of the column for that a value shall
197 * be returned. The first column is 1, the second is 2, ...
198 * @return the column label.
200 virtual OUString SAL_CALL
201 getColumnLabel( sal_Int32 column
) override
;
203 * Gets the name of column.
205 * @param column is the number of the column for that a value shall
206 * be returned. The first column is 1, the second is 2, ...
207 * @return the name of the property that corresponds to column.
209 virtual OUString SAL_CALL
210 getColumnName( sal_Int32 column
) override
;
212 * Gets the schema name for the table from which column of this
213 * result set was derived.
214 * Because this feature is not widely supported, the return value
215 * for many DBMSs will be an empty string.
217 * @param column is the number of the column for that a value shall
218 * be returned. The first column is 1, the second is 2, ...
219 * @return the schema name of column or an empty string.
221 virtual OUString SAL_CALL
222 getSchemaName( sal_Int32 column
) override
;
224 * For number types, getprecision gets the number of decimal digits
226 * For character types, it gets the maximum length in characters for
228 * For binary types, it gets the maximum length in bytes for column.
230 * @param column is the number of the column for that a value shall
231 * be returned. The first column is 1, the second is 2, ...
232 * @return the precision for the column.
234 virtual sal_Int32 SAL_CALL
235 getPrecision( sal_Int32 column
) override
;
237 * Gets the number of digits to the right of the decimal point for
240 * @param column is the number of the column for that a value shall
241 * be returned. The first column is 1, the second is 2, ...
242 * @return the scale of the column.
244 virtual sal_Int32 SAL_CALL
245 getScale( sal_Int32 column
) override
;
247 * Gets the name of the table from which column of this result set
248 * was derived or "" if there is none (for example, for a join).
249 * Because this feature is not widely supported, the return value
250 * for many DBMSs will be an empty string.
252 * @param column is the number of the column for that a value shall
253 * be returned. The first column is 1, the second is 2, ...
254 * @return the table name for column or an empty string.
256 virtual OUString SAL_CALL
257 getTableName( sal_Int32 column
) override
;
258 virtual OUString SAL_CALL
260 * Gets the catalog name for the table from which column of this
261 * result set was derived.
262 * Because this feature is not widely supported, the return value
263 * for many DBMSs will be an empty string.
265 * @param column is the number of the column for that a value shall
266 * be returned. The first column is 1, the second is 2, ...
267 * @return the catalog name for column or an empty string.
269 getCatalogName( sal_Int32 column
) override
;
271 * Gets the JDBC type for the value stored in column. ... The STRUCT
272 * and DISTINCT type codes are always returned for structured and
273 * distinct types, regardless of whether the value will be mapped
274 * according to the standard mapping or be a custom mapping.
276 * @param column is the number of the column for that a value shall
277 * be returned. The first column is 1, the second is 2, ...
278 * @return the type of the property that corresponds to column - mapped
279 * from UNO-Type to SQL-Type.
281 virtual sal_Int32 SAL_CALL
282 getColumnType( sal_Int32 column
) override
;
284 * Gets the type name used by this particular data source for the
285 * values stored in column. If the type code for the type of value
286 * stored in column is STRUCT, DISTINCT or JAVA_OBJECT, this method
287 * returns a fully-qualified SQL type name.
289 * @param column is the number of the column for that a value shall
290 * be returned. The first column is 1, the second is 2, ...
291 * @return the column type name.
293 virtual OUString SAL_CALL
294 getColumnTypeName( sal_Int32 column
) override
;
296 * Indicates whether a column is definitely not writable.
298 * @param column is the number of the column for that a value shall
299 * be returned. The first column is 1, the second is 2, ...
300 * @return true, if the column is definitely not writable.
302 virtual sal_Bool SAL_CALL
303 isReadOnly( sal_Int32 column
) override
;
305 * Indicates whether it is possible for a write on the column to succeed.
307 * @param column is the number of the column for that a value shall
308 * be returned. The first column is 1, the second is 2, ...
309 * @return true, if it is possible for a write to succeed.
311 virtual sal_Bool SAL_CALL
312 isWritable( sal_Int32 column
) override
;
314 * Indicates whether a write on the column will definitely succeed.
316 * @param column is the number of the column for that a value shall
317 * be returned. The first column is 1, the second is 2, ...
318 * @return true, if a write on the column will definitely succeed.
320 virtual sal_Bool SAL_CALL
321 isDefinitelyWritable( sal_Int32 column
) override
;
323 * Returns the fully-qualified name of the service whose instances
324 * are manufactured if the method
325 * css::sdbc::ResultSet::getObject is called to retrieve a
326 * value from the column.
328 * @param column is the number of the column for that a value shall
329 * be returned. The first column is 1, the second is 2, ...
330 * @return the service name for column or an empty string, if no service
333 virtual OUString SAL_CALL
334 getColumnServiceName( sal_Int32 column
) override
;
337 } // namespace ucbhelper
339 #endif /* ! INCLUDED_UCBHELPER_RESULTSETMETADATA_HXX */
341 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */