update credits
[LibreOffice.git] / include / svx / dbtoolsclient.hxx
blobc1afd469050960c5694d55e7212d7d2756064045
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 SVX_DBTOOLSCLIENT_HXX
21 #define SVX_DBTOOLSCLIENT_HXX
23 #include <connectivity/virtualdbtools.hxx>
24 #include <osl/mutex.hxx>
25 #include <osl/module.h>
26 #include <tools/solar.h>
27 #include <unotools/sharedunocomponent.hxx>
28 #include "svx/svxdllapi.h"
30 //........................................................................
31 namespace svxform
33 //........................................................................
35 typedef ::utl::SharedUNOComponent< ::com::sun::star::sdbc::XConnection > SharedConnection;
37 //====================================================================
38 //= ODbtoolsClient
39 //====================================================================
40 /** base class for classes which want to use dbtools features with load-on-call
41 of the dbtools lib.
43 class SVX_DLLPUBLIC ODbtoolsClient
45 private:
46 static sal_Int32 s_nClients;
47 static oslModule s_hDbtoolsModule;
48 static ::connectivity::simple::createDataAccessToolsFactoryFunction
49 s_pFactoryCreationFunc;
51 mutable sal_Bool m_bCreateAlready;
53 private:
54 mutable ::rtl::Reference< ::connectivity::simple::IDataAccessToolsFactory > m_xDataAccessFactory;
56 protected:
57 ODbtoolsClient();
58 virtual ~ODbtoolsClient();
60 virtual bool ensureLoaded() const;
62 protected:
63 const ::rtl::Reference< ::connectivity::simple::IDataAccessToolsFactory >&
64 getFactory() const { return m_xDataAccessFactory; }
66 private:
67 static void registerClient();
68 static void revokeClient();
71 //====================================================================
72 //= OStaticDataAccessTools
73 //====================================================================
74 class SVX_DLLPUBLIC OStaticDataAccessTools : public ODbtoolsClient
76 protected:
77 mutable ::rtl::Reference< ::connectivity::simple::IDataAccessTools > m_xDataAccessTools;
79 protected:
80 virtual bool ensureLoaded() const;
82 public:
83 OStaticDataAccessTools();
85 const ::rtl::Reference< ::connectivity::simple::IDataAccessTools >& getDataAccessTools() const { return m_xDataAccessTools; }
87 // ------------------------------------------------
88 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> getNumberFormats(
89 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConn,
90 sal_Bool _bAllowDefault
91 ) const;
93 // ------------------------------------------------
94 sal_Int32 getDefaultNumberFormat(
95 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xColumn,
96 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatTypes >& _xTypes,
97 const ::com::sun::star::lang::Locale& _rLocale );
99 // ------------------------------------------------
100 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection_withFeedback(
101 const OUString& _rDataSourceName,
102 const OUString& _rUser,
103 const OUString& _rPwd,
104 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext
105 ) const SAL_THROW ( (::com::sun::star::sdbc::SQLException) );
107 // ------------------------------------------------
108 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> connectRowset(
109 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet,
110 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext,
111 sal_Bool _bSetAsActiveConnection
112 ) const SAL_THROW ( ( ::com::sun::star::sdbc::SQLException
113 , ::com::sun::star::lang::WrappedTargetException
114 , ::com::sun::star::uno::RuntimeException) );
116 // ------------------------------------------------
117 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getRowSetConnection(
118 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet)
119 const SAL_THROW ( (::com::sun::star::uno::RuntimeException) );
121 // ------------------------------------------------
122 void TransferFormComponentProperties(
123 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxOld,
124 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxNew,
125 const ::com::sun::star::lang::Locale& _rLocale
126 ) const;
128 // ------------------------------------------------
129 OUString quoteName(
130 const OUString& _rQuote,
131 const OUString& _rName
132 ) const;
134 // ------------------------------------------------
135 OUString composeTableNameForSelect(
136 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
137 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable
138 ) const;
140 // ------------------------------------------------
141 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > getDataSource(
142 const OUString& _rsRegisteredName,
143 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext
144 ) const;
146 // ------------------------------------------------
147 /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::INSERT
148 @param _rxCursorSet the property set
150 sal_Bool canInsert(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const;
152 // ------------------------------------------------
153 /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::UPDATE
154 @param _rxCursorSet the property set
156 sal_Bool canUpdate(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const;
158 // ------------------------------------------------
159 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
160 getFieldsByCommandDescriptor(
161 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
162 const sal_Int32 _nCommandType,
163 const OUString& _rCommand,
164 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxKeepFieldsAlive,
165 ::dbtools::SQLExceptionInfo* _pErrorInfo = NULL
166 ) SAL_THROW( ( ) );
168 // ------------------------------------------------
169 bool isEmbeddedInDatabase(
170 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent,
171 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxActualConnection
174 // ------------------------------------------------
175 bool isEmbeddedInDatabase(
176 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent
180 //====================================================================
181 //= DBToolsObjectFactory
182 //====================================================================
183 class SVX_DLLPUBLIC DBToolsObjectFactory : public ODbtoolsClient
185 public:
186 DBToolsObjectFactory();
187 ~DBToolsObjectFactory();
189 // ------------------------------------------------
190 ::std::auto_ptr< ::dbtools::FormattedColumnValue > createFormattedColumnValue(
191 const ::comphelper::ComponentContext& _rContext,
192 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& _rxRowSet,
193 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn
197 //........................................................................
198 } // namespace svxform
199 //........................................................................
201 #endif // SVX_DBTOOLSCLIENT_HXX
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */