build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / dbaccess / source / core / dataaccess / connection.hxx
blobd1258f211467d63423ef4d745b0b724b0d7b9284
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 .
19 #ifndef INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_CONNECTION_HXX
20 #define INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_CONNECTION_HXX
22 #include <sal/config.h>
24 #include <map>
26 #include "apitools.hxx"
27 #include "querycontainer.hxx"
28 #include "tablecontainer.hxx"
29 #include "viewcontainer.hxx"
30 #include "RefreshListener.hxx"
32 #include <com/sun/star/container/XChild.hpp>
33 #include <com/sun/star/lang/DisposedException.hpp>
34 #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
35 #include <com/sun/star/sdb/XCommandPreparation.hpp>
36 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
37 #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
38 #include <com/sun/star/sdbcx/XUsersSupplier.hpp>
39 #include <com/sun/star/sdbcx/XGroupsSupplier.hpp>
40 #include <com/sun/star/sdb/XQueriesSupplier.hpp>
41 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
42 #include <com/sun/star/sdb/tools/XConnectionTools.hpp>
43 #include <com/sun/star/sdb/application/XTableUIProvider.hpp>
45 #include <cppuhelper/implbase13.hxx>
46 #include <comphelper/stl_types.hxx>
47 #include <connectivity/ConnectionWrapper.hxx>
48 #include <connectivity/CommonTools.hxx>
49 #include <connectivity/warningscontainer.hxx>
51 namespace dbaccess
54 typedef cppu::ImplHelper13 < css::container::XChild
55 , css::sdbcx::XTablesSupplier
56 , css::sdbcx::XViewsSupplier
57 , css::sdbc::XConnection
58 , css::sdbc::XWarningsSupplier
59 , css::sdb::XQueriesSupplier
60 , css::sdb::XSQLQueryComposerFactory
61 , css::sdb::XCommandPreparation
62 , css::lang::XMultiServiceFactory
63 , css::sdbcx::XUsersSupplier
64 , css::sdbcx::XGroupsSupplier
65 , css::sdb::tools::XConnectionTools
66 , css::sdb::application::XTableUIProvider
67 > OConnection_Base;
69 class ODatabaseSource;
70 // OConnection
71 class OConnection :public ::cppu::BaseMutex
72 ,public OSubComponent
73 ,public ::connectivity::OConnectionWrapper
74 ,public OConnection_Base
75 ,public IRefreshListener
77 protected:
78 css::uno::Reference< css::sdbcx::XTablesSupplier >
79 m_xMasterTables; // just to avoid the recreation of the catalog
80 connectivity::OWeakRefArray m_aStatements;
81 css::uno::Reference< css::container::XNameAccess >
82 m_xQueries;
83 connectivity::OWeakRefArray m_aComposers;
85 // the filter as set on the parent data link at construction of the connection
86 css::uno::Sequence< OUString > m_aTableFilter;
87 css::uno::Sequence< OUString > m_aTableTypeFilter;
88 css::uno::Reference< css::uno::XComponentContext > m_aContext;
89 css::uno::Reference< css::sdbc::XConnection > m_xMasterConnection;
90 css::uno::Reference< css::sdb::tools::XConnectionTools > m_xConnectionTools;
91 css::uno::Reference< css::sdb::application::XTableUIProvider > m_xTableUIProvider;
93 // defines the helper services for example to query the command of a view
94 // @ see com.sun.star.sdb.tools.XViewAccess
95 typedef std::map< OUString, css::uno::Reference< css::uno::XInterface> > TSupportServices;
96 TSupportServices m_aSupportServices;
98 OTableContainer* m_pTables;
99 OViewContainer* m_pViews;
100 ::dbtools::WarningsContainer m_aWarnings;
101 oslInterlockedCount m_nInAppend;
102 bool m_bSupportsViews; // true when the getTableTypes return "VIEW" as type
103 bool m_bSupportsUsers;
104 bool m_bSupportsGroups;
106 protected:
107 virtual ~OConnection() override;
108 public:
109 OConnection(ODatabaseSource& _rDB
110 ,css::uno::Reference< css::sdbc::XConnection >& _rxMaster
111 ,const css::uno::Reference< css::uno::XComponentContext >& _rxORB);
113 // css::lang::XTypeProvider
114 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() throw (css::uno::RuntimeException, std::exception) override;
115 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (css::uno::RuntimeException, std::exception) override;
117 // css::uno::XInterface
118 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) throw (css::uno::RuntimeException, std::exception) override;
119 virtual void SAL_CALL acquire() throw( ) override;
120 virtual void SAL_CALL release() throw( ) override;
122 // OComponentHelper
123 virtual void SAL_CALL disposing() override;
125 // css::container::XChild
126 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) throw(css::uno::RuntimeException, std::exception) override;
127 virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) throw(css::lang::NoSupportException, css::uno::RuntimeException, std::exception) override;
129 // css::sdbcx::XTablesSupplier
130 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTables( ) throw(css::uno::RuntimeException, std::exception) override;
131 // css::sdbcx::XViewsSupplier
132 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getViews( ) throw(css::uno::RuntimeException, std::exception) override;
134 // css::sdb::XQueriesSupplier
135 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getQueries( ) throw(css::uno::RuntimeException, std::exception) override;
137 // css::sdb::XSQLQueryComposerFactory
138 virtual css::uno::Reference< css::sdb::XSQLQueryComposer > SAL_CALL createQueryComposer( ) throw(css::uno::RuntimeException, std::exception) override;
140 // css::sdb::XCommandPreparation
141 virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCommand( const OUString& command, sal_Int32 commandType ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
143 // css::sdbc::XWarningsSupplier
144 virtual css::uno::Any SAL_CALL getWarnings( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
145 virtual void SAL_CALL clearWarnings( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
147 // css::lang::XServiceInfo
148 virtual OUString SAL_CALL getImplementationName( ) throw(css::uno::RuntimeException, std::exception) override;
149 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(css::uno::RuntimeException, std::exception) override;
150 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(css::uno::RuntimeException, std::exception) override;
152 // XConnection
153 virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
154 virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const OUString& sql ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
155 virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall( const OUString& sql ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
156 virtual OUString SAL_CALL nativeSQL( const OUString& sql ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
157 virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
158 virtual sal_Bool SAL_CALL getAutoCommit( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
159 virtual void SAL_CALL commit( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
160 virtual void SAL_CALL rollback( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
161 virtual sal_Bool SAL_CALL isClosed( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
162 virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
163 virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
164 virtual sal_Bool SAL_CALL isReadOnly( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
165 virtual void SAL_CALL setCatalog( const OUString& catalog ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
166 virtual OUString SAL_CALL getCatalog( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
167 virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
168 virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
169 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTypeMap( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
170 virtual void SAL_CALL setTypeMap( const css::uno::Reference< css::container::XNameAccess >& typeMap ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
172 // css::sdbc::XCloseable
173 virtual void SAL_CALL close( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
175 // XMultiServiceFactory
176 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) throw (css::uno::Exception, css::uno::RuntimeException, std::exception) override;
177 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments ) throw (css::uno::Exception, css::uno::RuntimeException, std::exception) override;
178 virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames( ) throw (css::uno::RuntimeException, std::exception) override;
180 // XUsersSupplier
181 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getUsers( ) throw(css::uno::RuntimeException, std::exception) override;
182 // XGroupsSupplier
183 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getGroups( ) throw(css::uno::RuntimeException, std::exception) override;
185 // XConnectionTools
186 virtual css::uno::Reference< css::sdb::tools::XTableName > SAL_CALL createTableName( ) throw (css::uno::RuntimeException, std::exception) override;
187 virtual css::uno::Reference< css::sdb::tools::XObjectNames > SAL_CALL getObjectNames( ) throw (css::uno::RuntimeException, std::exception) override;
188 virtual css::uno::Reference< css::sdb::tools::XDataSourceMetaData > SAL_CALL getDataSourceMetaData( ) throw (css::uno::RuntimeException, std::exception) override;
189 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getFieldsByCommandDescriptor( ::sal_Int32 commandType, const OUString& command, css::uno::Reference< css::lang::XComponent >& keepFieldsAlive ) throw (css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
190 virtual css::uno::Reference< css::sdb::XSingleSelectQueryComposer > SAL_CALL getComposer( ::sal_Int32 commandType, const OUString& command ) throw (css::uno::RuntimeException, std::exception) override;
192 // XTableUIProvider
193 virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getTableIcon( const OUString& TableName, ::sal_Int32 ColorMode ) throw (css::uno::RuntimeException, std::exception) override;
194 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getTableEditor( const css::uno::Reference< css::sdb::application::XDatabaseDocumentUI >& DocumentUI, const OUString& TableName ) throw (css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
196 // IRefreshListener
197 virtual void refresh(const css::uno::Reference< css::container::XNameAccess >& _rToBeRefreshed) override;
199 protected:
200 /// @throws css::lang::DisposedException
201 inline void checkDisposed() throw (css::lang::DisposedException)
203 if ( rBHelper.bDisposed || !m_xConnection.is() )
204 throw css::lang::DisposedException();
207 css::uno::Reference< css::sdbcx::XTablesSupplier > const & getMasterTables();
209 private:
210 /** checks whether or not there are naming conflicts between tables and queries
212 void impl_checkTableQueryNames_nothrow();
214 /** loads the XConnectionTools implementation which we forward the respective functionality to
216 @throws css::uno::RuntimeException
217 if the implementation cannot be loaded
219 @postcond
220 m_xConnectionTools is nol <NULL/>
222 void impl_loadConnectionTools_throw();
224 /** reads the table filter and table type filter from the datasource
226 void impl_fillTableFilter();
229 } // namespace dbaccess
231 #endif // INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_CONNECTION_HXX
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */