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_SVX_DBTOOLSCLIENT_HXX
21 #define INCLUDED_SVX_DBTOOLSCLIENT_HXX
23 #include <connectivity/virtualdbtools.hxx>
24 #include <osl/mutex.hxx>
25 #include <osl/module.h>
26 #include <svx/svxdllapi.h>
27 #include <tools/solar.h>
28 #include <unotools/sharedunocomponent.hxx>
32 typedef ::utl::SharedUNOComponent
< ::com::sun::star::sdbc::XConnection
> SharedConnection
;
34 /** base class for classes which want to use dbtools features with load-on-call
37 class SVX_DLLPUBLIC ODbtoolsClient
40 static sal_Int32 s_nClients
;
41 static oslModule s_hDbtoolsModule
;
42 static ::connectivity::simple::createDataAccessToolsFactoryFunction
43 s_pFactoryCreationFunc
;
45 mutable bool m_bCreateAlready
;
48 mutable ::rtl::Reference
< ::connectivity::simple::IDataAccessToolsFactory
> m_xDataAccessFactory
;
52 virtual ~ODbtoolsClient();
54 virtual bool ensureLoaded() const;
57 const ::rtl::Reference
< ::connectivity::simple::IDataAccessToolsFactory
>&
58 getFactory() const { return m_xDataAccessFactory
; }
61 static void registerClient();
62 static void revokeClient();
65 class SVX_DLLPUBLIC OStaticDataAccessTools
: public ODbtoolsClient
68 mutable ::rtl::Reference
< ::connectivity::simple::IDataAccessTools
> m_xDataAccessTools
;
71 virtual bool ensureLoaded() const SAL_OVERRIDE
;
74 OStaticDataAccessTools();
76 const ::rtl::Reference
< ::connectivity::simple::IDataAccessTools
>& getDataAccessTools() const { return m_xDataAccessTools
; }
78 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormatsSupplier
> getNumberFormats(
79 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConn
,
83 sal_Int32
getDefaultNumberFormat(
84 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _xColumn
,
85 const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormatTypes
>& _xTypes
,
86 const ::com::sun::star::lang::Locale
& _rLocale
);
88 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
> getConnection_withFeedback(
89 const OUString
& _rDataSourceName
,
90 const OUString
& _rUser
,
91 const OUString
& _rPwd
,
92 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxContext
93 ) const SAL_THROW ( (::com::sun::star::sdbc::SQLException
) );
95 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
> connectRowset(
96 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRowSet
>& _rxRowSet
,
97 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxContext
,
98 bool _bSetAsActiveConnection
99 ) const SAL_THROW ( ( ::com::sun::star::sdbc::SQLException
100 , ::com::sun::star::lang::WrappedTargetException
101 , ::com::sun::star::uno::RuntimeException
) );
103 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
> getRowSetConnection(
104 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRowSet
>& _rxRowSet
)
105 const SAL_THROW ( (::com::sun::star::uno::RuntimeException
) );
107 void TransferFormComponentProperties(
108 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxOld
,
109 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxNew
,
110 const ::com::sun::star::lang::Locale
& _rLocale
114 const OUString
& _rQuote
,
115 const OUString
& _rName
118 OUString
composeTableNameForSelect(
119 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
,
120 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _xTable
123 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDataSource
> getDataSource(
124 const OUString
& _rsRegisteredName
,
125 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxContext
128 /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::INSERT
129 @param _rxCursorSet the property set
131 bool canInsert(const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxCursorSet
) const;
133 /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::UPDATE
134 @param _rxCursorSet the property set
136 bool canUpdate(const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxCursorSet
) const;
138 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>
139 getFieldsByCommandDescriptor(
140 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
,
141 const sal_Int32 _nCommandType
,
142 const OUString
& _rCommand
,
143 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
>& _rxKeepFieldsAlive
,
144 ::dbtools::SQLExceptionInfo
* _pErrorInfo
= NULL
147 bool isEmbeddedInDatabase(
148 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxComponent
,
149 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxActualConnection
152 bool isEmbeddedInDatabase(
153 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxComponent
157 class SVX_DLLPUBLIC DBToolsObjectFactory
: public ODbtoolsClient
160 DBToolsObjectFactory();
161 virtual ~DBToolsObjectFactory();
163 ::std::auto_ptr
< ::dbtools::FormattedColumnValue
> createFormattedColumnValue(
164 const css::uno::Reference
<css::uno::XComponentContext
>& _rContext
,
165 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRowSet
>& _rxRowSet
,
166 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxColumn
170 } // namespace svxform
173 #endif // INCLUDED_SVX_DBTOOLSCLIENT_HXX
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */