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 CONNECTIVITY_VIRTUAL_DBTOOLS_HXX
21 #define CONNECTIVITY_VIRTUAL_DBTOOLS_HXX
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>
32 #include "connectivity/dbtoolsdllapi.hxx"
34 //========================================================================
35 //= forward declarations
36 //========================================================================
41 class XNumberFormatter
;
42 class XNumberFormatTypes
;
43 class XNumberFormatsSupplier
;
49 class XMultiServiceFactory
;
51 class WrappedTargetException
;
55 class XDatabaseMetaData
;
65 class XComponentContext
;
75 class SQLExceptionInfo
;
76 class FormattedColumnValue
;
79 namespace comphelper
{
80 class ComponentContext
;
83 //========================================================================
84 //= entry into this library
85 //========================================================================
86 /** this is the entry point for the load-on-call usage of the DBTOOLS
88 <p>When you need one of the simple objects in this library, load the lib
89 and call this method. The returned pointer is a pointer to an IDataAccessToolsFactory
90 instance, which is acquired <em>once</em>.</p>
92 a pointer to an object implementing the IDataAccessToolsFactory interface,
93 aquired exactly <em>once</em>.
95 extern "C" OOO_DLLPUBLIC_DBTOOLS
void* SAL_CALL
createDataAccessToolsFactory();
97 //========================================================================
99 //========================================================================
100 //........................................................................
101 namespace connectivity
103 //........................................................................
106 //....................................................................
109 //....................................................................
111 typedef void* (SAL_CALL
* createDataAccessToolsFactoryFunction
)( );
113 //================================================================
115 //================================================================
116 class OOO_DLLPUBLIC_DBTOOLS IDataAccessTools
: public ::rtl::IReference
119 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
> getConnection_withFeedback(
120 const OUString
& _rDataSourceName
,
121 const OUString
& _rUser
,
122 const OUString
& _rPwd
,
123 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxContext
124 ) const SAL_THROW ( (::com::sun::star::sdbc::SQLException
) ) = 0;
126 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
> connectRowset(
127 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRowSet
>& _rxRowSet
,
128 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxContext
,
129 sal_Bool _bSetAsActiveConnection
130 ) const SAL_THROW ( ( ::com::sun::star::sdbc::SQLException
131 , ::com::sun::star::lang::WrappedTargetException
132 , ::com::sun::star::uno::RuntimeException
) ) = 0;
134 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
> getRowSetConnection(
135 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRowSet
>& _rxRowSet
)
136 const SAL_THROW ( (::com::sun::star::uno::RuntimeException
) ) = 0;
138 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormatsSupplier
> getNumberFormats(
139 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConn
,
140 sal_Bool _bAllowDefault
143 virtual sal_Int32
getDefaultNumberFormat(
144 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxColumn
,
145 const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormatTypes
>& _rxTypes
,
146 const ::com::sun::star::lang::Locale
& _rLocale
149 virtual void TransferFormComponentProperties(
150 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxOld
,
151 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxNew
,
152 const ::com::sun::star::lang::Locale
& _rLocale
155 virtual OUString
quoteName(
156 const OUString
& _rQuote
,
157 const OUString
& _rName
160 virtual OUString
composeTableNameForSelect(
161 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
,
162 const OUString
& _rCatalog
,
163 const OUString
& _rSchema
,
164 const OUString
& _rName
167 virtual OUString
composeTableNameForSelect(
168 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
,
169 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _xTable
172 virtual ::com::sun::star::sdb::SQLContext
prependContextInfo(
173 ::com::sun::star::sdbc::SQLException
& _rException
,
174 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxContext
,
175 const OUString
& _rContextDescription
,
176 const OUString
& _rContextDetails
179 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDataSource
> getDataSource(
180 const OUString
& _rsRegisteredName
,
181 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxContext
184 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>
185 getFieldsByCommandDescriptor(
186 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
,
187 const sal_Int32 _nCommandType
,
188 const OUString
& _rCommand
,
189 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
>& _rxKeepFieldsAlive
,
190 ::dbtools::SQLExceptionInfo
* _pErrorInfo
= NULL
191 ) SAL_THROW( ( ) ) = 0;
193 virtual ::com::sun::star::uno::Sequence
< OUString
>
194 getFieldNamesByCommandDescriptor(
195 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
,
196 const sal_Int32 _nCommandType
,
197 const OUString
& _rCommand
,
198 ::dbtools::SQLExceptionInfo
* _pErrorInfo
= NULL
199 ) SAL_THROW( ( ) ) = 0;
201 /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::INSERT
202 @param _rxCursorSet the property set
204 virtual sal_Bool
canInsert(const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxCursorSet
) const = 0;
206 /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::UPDATE
207 @param _rxCursorSet the property set
209 virtual sal_Bool
canUpdate(const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxCursorSet
) const = 0;
211 /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::DELETE
212 @param _rxCursorSet the property set
214 virtual sal_Bool
canDelete(const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxCursorSet
) const = 0;
216 /** determines whether the given component is part of a document which is an embedded database
217 document (such as a form)
219 virtual bool isEmbeddedInDatabase(
220 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxComponent
,
221 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxActualConnection
225 ~IDataAccessTools() {}
228 //================================================================
229 //= IDataAccessCharSet
230 //================================================================
231 /** simple wrapper for the <type>OCharsetMap</type>
233 class OOO_DLLPUBLIC_DBTOOLS IDataAccessCharSet
:
234 public ::rtl::IReference
236 // to be extended if necessary ....
238 /** enumerates all supported char sets
239 @return the number of charsets supported
241 virtual sal_Int32
getSupportedTextEncodings(
242 ::std::vector
< rtl_TextEncoding
>& /* [out] */ _rEncs
246 ~IDataAccessCharSet() {}
249 //================================================================
250 //= IDataAccessTypeConversion
251 //================================================================
252 class OOO_DLLPUBLIC_DBTOOLS IDataAccessTypeConversion
:
253 public ::rtl::IReference
256 virtual ::com::sun::star::util::Date
getStandardDate() const = 0;
258 virtual double getValue(
259 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdb::XColumn
>& _rxVariant
,
260 const ::com::sun::star::util::Date
& rNullDate
) const = 0;
262 virtual OUString
getFormattedValue(
263 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdb::XColumn
>& _rxColumn
,
264 const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormatter
>& _rxFormatter
,
265 const ::com::sun::star::util::Date
& _rNullDate
,
267 sal_Int16 _nKeyType
) const = 0;
269 virtual OUString
getFormattedValue(
270 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxColumn
,
271 const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormatter
>& _rxFormatter
,
272 const ::com::sun::star::lang::Locale
& _rLocale
,
273 const ::com::sun::star::util::Date
& _rNullDate
277 ~IDataAccessTypeConversion() {}
280 //================================================================
282 //================================================================
283 /** a simple version of the OSQLParseNode, with all methods beeing virtual
285 class OOO_DLLPUBLIC_DBTOOLS ISQLParseNode
: public ::rtl::IReference
288 virtual void parseNodeToStr(OUString
& _rString
,
289 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
,
290 const IParseContext
* _pContext
293 virtual void parseNodeToPredicateStr(OUString
& _rString
,
294 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
,
295 const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormatter
>& _rxFormatter
,
296 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxField
,
297 const OUString
&_sPredicateTableAlias
,
298 const ::com::sun::star::lang::Locale
& _rIntl
,
299 const sal_Char _cDecSeparator
,
300 const IParseContext
* _pContext
307 //================================================================
309 //================================================================
310 /** a simple version of the OSQLParser, with all methods beeing virtual
312 class OOO_DLLPUBLIC_DBTOOLS ISQLParser
: public ::rtl::IReference
315 virtual ::rtl::Reference
< ISQLParseNode
> predicateTree(
316 OUString
& rErrorMessage
,
317 const OUString
& rStatement
,
318 const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormatter
>& _rxFormatter
,
319 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxField
322 virtual const IParseContext
& getContext() const = 0;
328 //================================================================
329 //= IDataAccessToolsFactory
330 //================================================================
331 /** the main factory for runtime-loadable tools in the DBTOOLS library
333 class OOO_DLLPUBLIC_DBTOOLS IDataAccessToolsFactory
:
334 public ::rtl::IReference
337 /// creates a simple version of the class OSQLParser
338 virtual ::rtl::Reference
< ISQLParser
> createSQLParser(
339 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& rxContext
,
340 const IParseContext
* _pContext
343 /// creates a helper for charset related functionality (<type>OCharsetMap</type>)
344 virtual ::rtl::Reference
< IDataAccessCharSet
> createCharsetHelper( ) const = 0;
346 /// creates a simple version of the DBTypeConversion helper
347 virtual ::rtl::Reference
< IDataAccessTypeConversion
> getTypeConversionHelper() = 0;
349 /// creates a helper which can be used to access the static methods in dbtools.hxx
350 virtual ::rtl::Reference
< IDataAccessTools
> getDataAccessTools() = 0;
352 virtual ::std::auto_ptr
< ::dbtools::FormattedColumnValue
> createFormattedColumnValue(
353 const ::comphelper::ComponentContext
& _rContext
,
354 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRowSet
>& _rxRowSet
,
355 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxColumn
359 ~IDataAccessToolsFactory() {}
362 //....................................................................
363 } // namespace simple
364 //....................................................................
366 //........................................................................
367 } // namespace connectivity
368 //........................................................................
370 #endif // CONNECTIVITY_VIRTUAL_DBTOOLS_HXX
372 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */