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 INCLUDED_CONNECTIVITY_VIRTUALDBTOOLS_HXX
21 : #define INCLUDED_CONNECTIVITY_VIRTUALDBTOOLS_HXX
22 :
23 : #include <rtl/ref.hxx>
24 : #include <rtl/ustring.hxx>
25 : #include <com/sun/star/uno/Reference.hxx>
26 : #include <com/sun/star/util/Date.hpp>
27 : #include <com/sun/star/sdbc/SQLException.hpp>
28 : #include <com/sun/star/uno/Sequence.hxx>
29 :
30 : #include <vector>
31 : #include <memory>
32 : #include <connectivity/dbtoolsdllapi.hxx>
33 :
34 :
35 : //= forward declarations
36 :
37 : namespace com {
38 : namespace sun {
39 : namespace star {
40 : namespace util {
41 : class XNumberFormatter;
42 : class XNumberFormatTypes;
43 : class XNumberFormatsSupplier;
44 : }
45 : namespace beans {
46 : class XPropertySet;
47 : }
48 : namespace lang {
49 : class XMultiServiceFactory;
50 : class XComponent;
51 : class WrappedTargetException;
52 : struct Locale;
53 : }
54 : namespace sdbc {
55 : class XDatabaseMetaData;
56 : class XConnection;
57 : class XRowSet;
58 : class XDataSource;
59 : }
60 : namespace sdb {
61 : class XColumn;
62 : class SQLContext;
63 : }
64 : namespace uno {
65 : class XComponentContext;
66 : }
67 : namespace container {
68 : class XNameAccess;
69 : }
70 : }
71 : }
72 : }
73 :
74 : namespace dbtools {
75 : class SQLExceptionInfo;
76 : class FormattedColumnValue;
77 : }
78 :
79 :
80 : //= entry into this library
81 :
82 : /** this is the entry point for the load-on-call usage of the DBTOOLS
83 : library.
84 : <p>When you need one of the simple objects in this library, load the lib
85 : and call this method. The returned pointer is a pointer to an IDataAccessToolsFactory
86 : instance, which is acquired <em>once</em>.</p>
87 : @return
88 : a pointer to an object implementing the IDataAccessToolsFactory interface,
89 : aquired exactly <em>once</em>.
90 : */
91 : extern "C" OOO_DLLPUBLIC_DBTOOLS void* SAL_CALL createDataAccessToolsFactory();
92 :
93 :
94 : //=
95 :
96 :
97 : namespace connectivity
98 : {
99 :
100 :
101 : class IParseContext;
102 :
103 : namespace simple
104 : {
105 :
106 :
107 : typedef void* (SAL_CALL * createDataAccessToolsFactoryFunction)( );
108 :
109 :
110 : //= IDataAccessTools
111 :
112 0 : class OOO_DLLPUBLIC_DBTOOLS IDataAccessTools : public ::rtl::IReference
113 : {
114 : public:
115 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection_withFeedback(
116 : const OUString& _rDataSourceName,
117 : const OUString& _rUser,
118 : const OUString& _rPwd,
119 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext
120 : ) const SAL_THROW ( (::com::sun::star::sdbc::SQLException) ) = 0;
121 :
122 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> connectRowset(
123 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet,
124 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext,
125 : sal_Bool _bSetAsActiveConnection
126 : ) const SAL_THROW ( ( ::com::sun::star::sdbc::SQLException
127 : , ::com::sun::star::lang::WrappedTargetException
128 : , ::com::sun::star::uno::RuntimeException ) ) = 0;
129 :
130 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getRowSetConnection(
131 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet)
132 : const SAL_THROW ( (::com::sun::star::uno::RuntimeException) ) = 0;
133 :
134 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> getNumberFormats(
135 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConn,
136 : sal_Bool _bAllowDefault
137 : ) const = 0;
138 :
139 : virtual sal_Int32 getDefaultNumberFormat(
140 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn,
141 : const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatTypes >& _rxTypes,
142 : const ::com::sun::star::lang::Locale& _rLocale
143 : ) const = 0;
144 :
145 : virtual void TransferFormComponentProperties(
146 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxOld,
147 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxNew,
148 : const ::com::sun::star::lang::Locale& _rLocale
149 : ) const = 0;
150 :
151 : virtual OUString quoteName(
152 : const OUString& _rQuote,
153 : const OUString& _rName
154 : ) const = 0;
155 :
156 : virtual OUString composeTableNameForSelect(
157 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
158 : const OUString& _rCatalog,
159 : const OUString& _rSchema,
160 : const OUString& _rName
161 : ) const = 0;
162 :
163 : virtual OUString composeTableNameForSelect(
164 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
165 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable
166 : ) const = 0;
167 :
168 : virtual ::com::sun::star::sdb::SQLContext prependContextInfo(
169 : ::com::sun::star::sdbc::SQLException& _rException,
170 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext,
171 : const OUString& _rContextDescription,
172 : const OUString& _rContextDetails
173 : ) const = 0;
174 :
175 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > getDataSource(
176 : const OUString& _rsRegisteredName,
177 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext
178 : ) const = 0;
179 :
180 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
181 : getFieldsByCommandDescriptor(
182 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
183 : const sal_Int32 _nCommandType,
184 : const OUString& _rCommand,
185 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxKeepFieldsAlive,
186 : ::dbtools::SQLExceptionInfo* _pErrorInfo = NULL
187 : ) SAL_THROW( ( ) ) = 0;
188 :
189 : virtual ::com::sun::star::uno::Sequence< OUString >
190 : getFieldNamesByCommandDescriptor(
191 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
192 : const sal_Int32 _nCommandType,
193 : const OUString& _rCommand,
194 : ::dbtools::SQLExceptionInfo* _pErrorInfo = NULL
195 : ) SAL_THROW( ( ) ) = 0;
196 :
197 : /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::INSERT
198 : @param _rxCursorSet the property set
199 : */
200 : virtual bool canInsert(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const = 0;
201 :
202 : /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::UPDATE
203 : @param _rxCursorSet the property set
204 : */
205 : virtual bool canUpdate(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const = 0;
206 :
207 : /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::DELETE
208 : @param _rxCursorSet the property set
209 : */
210 : virtual bool canDelete(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const = 0;
211 :
212 : /** determines whether the given component is part of a document which is an embedded database
213 : document (such as a form)
214 : */
215 : virtual bool isEmbeddedInDatabase(
216 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent,
217 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxActualConnection
218 : ) = 0;
219 :
220 : protected:
221 0 : ~IDataAccessTools() {}
222 : };
223 :
224 :
225 : //= IDataAccessCharSet
226 :
227 : /** simple wrapper for the OCharsetMap
228 : */
229 0 : class OOO_DLLPUBLIC_DBTOOLS IDataAccessCharSet :
230 : public ::rtl::IReference
231 : {
232 : // to be extended if necessary ....
233 : public:
234 : /** enumerates all supported char sets
235 : @return the number of charsets supported
236 : */
237 : virtual sal_Int32 getSupportedTextEncodings(
238 : ::std::vector< rtl_TextEncoding >& /* [out] */ _rEncs
239 : ) const = 0;
240 :
241 : protected:
242 0 : ~IDataAccessCharSet() {}
243 : };
244 :
245 :
246 : //= IDataAccessTypeConversion
247 :
248 0 : class OOO_DLLPUBLIC_DBTOOLS IDataAccessTypeConversion :
249 : public ::rtl::IReference
250 : {
251 : public:
252 : virtual ::com::sun::star::util::Date getStandardDate() const = 0;
253 :
254 : virtual double getValue(
255 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn>& _rxVariant,
256 : const ::com::sun::star::util::Date& rNullDate ) const = 0;
257 :
258 : virtual OUString getFormattedValue(
259 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxColumn,
260 : const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
261 : const ::com::sun::star::util::Date& _rNullDate,
262 : sal_Int32 _nKey,
263 : sal_Int16 _nKeyType) const = 0;
264 :
265 : virtual OUString getFormattedValue(
266 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxColumn,
267 : const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter>& _rxFormatter,
268 : const ::com::sun::star::lang::Locale& _rLocale,
269 : const ::com::sun::star::util::Date& _rNullDate
270 : ) const = 0;
271 :
272 : protected:
273 0 : ~IDataAccessTypeConversion() {}
274 : };
275 :
276 :
277 : //= ISQLParseNode
278 :
279 : /** a simple version of the OSQLParseNode, with all methods beeing virtual
280 : */
281 0 : class OOO_DLLPUBLIC_DBTOOLS ISQLParseNode : public ::rtl::IReference
282 : {
283 : public:
284 : virtual void parseNodeToStr(OUString& _rString,
285 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
286 : const IParseContext* _pContext
287 : ) const = 0;
288 :
289 : virtual void parseNodeToPredicateStr(OUString& _rString,
290 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
291 : const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
292 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField,
293 : const OUString &_sPredicateTableAlias,
294 : const ::com::sun::star::lang::Locale& _rIntl,
295 : const sal_Char _cDecSeparator,
296 : const IParseContext* _pContext
297 : ) const = 0;
298 :
299 : protected:
300 0 : ~ISQLParseNode() {}
301 : };
302 :
303 :
304 : //= ISQLParser
305 :
306 : /** a simple version of the OSQLParser, with all methods beeing virtual
307 : */
308 0 : class OOO_DLLPUBLIC_DBTOOLS ISQLParser : public ::rtl::IReference
309 : {
310 : public:
311 : virtual ::rtl::Reference< ISQLParseNode > predicateTree(
312 : OUString& rErrorMessage,
313 : const OUString& rStatement,
314 : const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
315 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField
316 : ) const = 0;
317 :
318 : virtual const IParseContext& getContext() const = 0;
319 :
320 : protected:
321 0 : ~ISQLParser() {}
322 : };
323 :
324 :
325 : //= IDataAccessToolsFactory
326 :
327 : /** the main factory for runtime-loadable tools in the DBTOOLS library
328 : */
329 0 : class OOO_DLLPUBLIC_DBTOOLS IDataAccessToolsFactory :
330 : public ::rtl::IReference
331 : {
332 : public:
333 : /// creates a simple version of the class OSQLParser
334 : virtual ::rtl::Reference< ISQLParser > createSQLParser(
335 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
336 : const IParseContext* _pContext
337 : ) const = 0;
338 :
339 : /// creates a helper for charset related functionality (OCharsetMap)
340 : virtual ::rtl::Reference< IDataAccessCharSet > createCharsetHelper( ) const = 0;
341 :
342 : /// creates a simple version of the DBTypeConversion helper
343 : virtual ::rtl::Reference< IDataAccessTypeConversion > getTypeConversionHelper() = 0;
344 :
345 : /// creates a helper which can be used to access the static methods in dbtools.hxx
346 : virtual ::rtl::Reference< IDataAccessTools > getDataAccessTools() = 0;
347 :
348 : virtual ::std::auto_ptr< ::dbtools::FormattedColumnValue > createFormattedColumnValue(
349 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
350 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& _rxRowSet,
351 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn
352 : ) = 0;
353 :
354 : protected:
355 0 : ~IDataAccessToolsFactory() {}
356 : };
357 :
358 :
359 : } // namespace simple
360 :
361 :
362 :
363 : } // namespace connectivity
364 :
365 :
366 : #endif // INCLUDED_CONNECTIVITY_VIRTUALDBTOOLS_HXX
367 :
368 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|