fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / core / dataaccess / connection.hxx
blob0bb9de2322eeeeaad97b28f3380cc50f17a3e4b3
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 < ::com::sun::star::container::XChild
55 , ::com::sun::star::sdbcx::XTablesSupplier
56 , ::com::sun::star::sdbcx::XViewsSupplier
57 , ::com::sun::star::sdbc::XConnection
58 , ::com::sun::star::sdbc::XWarningsSupplier
59 , ::com::sun::star::sdb::XQueriesSupplier
60 , ::com::sun::star::sdb::XSQLQueryComposerFactory
61 , ::com::sun::star::sdb::XCommandPreparation
62 , ::com::sun::star::lang::XMultiServiceFactory
63 , ::com::sun::star::sdbcx::XUsersSupplier
64 , ::com::sun::star::sdbcx::XGroupsSupplier
65 , ::com::sun::star::sdb::tools::XConnectionTools
66 , ::com::sun::star::sdb::application::XTableUIProvider
67 > OConnection_Base;
69 class ODatabaseSource;
70 // OConnection
71 class OConnection :public ::comphelper::OBaseMutex
72 ,public OSubComponent
73 ,public ::connectivity::OConnectionWrapper
74 ,public OConnection_Base
75 ,public IRefreshListener
77 protected:
78 ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier >
79 m_xMasterTables; // just to avoid the recreation of the catalog
80 connectivity::OWeakRefArray m_aStatements;
81 ::com::sun::star::uno::Reference< ::com::sun::star::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 ::com::sun::star::uno::Sequence< OUString > m_aTableFilter;
87 ::com::sun::star::uno::Sequence< OUString > m_aTableTypeFilter;
88 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_aContext;
89 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xMasterConnection;
90 ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XConnectionTools > m_xConnectionTools;
91 ::com::sun::star::uno::Reference< ::com::sun::star::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, ::com::sun::star::uno::Reference< ::com::sun::star::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();
108 public:
109 OConnection(ODatabaseSource& _rDB
110 ,::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxMaster
111 ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB);
113 // com::sun::star::lang::XTypeProvider
114 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
117 // com::sun::star::uno::XInterface
118 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 virtual void SAL_CALL acquire() throw( ) SAL_OVERRIDE;
120 virtual void SAL_CALL release() throw( ) SAL_OVERRIDE;
122 // OComponentHelper
123 virtual void SAL_CALL disposing() SAL_OVERRIDE;
125 // ::com::sun::star::container::XChild
126 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
127 virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw(::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
129 // ::com::sun::star::sdbcx::XTablesSupplier
130 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
131 // ::com::sun::star::sdbcx::XViewsSupplier
132 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getViews( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
134 // ::com::sun::star::sdb::XQueriesSupplier
135 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getQueries( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
137 // ::com::sun::star::sdb::XSQLQueryComposerFactory
138 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLQueryComposer > SAL_CALL createQueryComposer( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
140 // ::com::sun::star::sdb::XCommandPreparation
141 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCommand( const OUString& command, sal_Int32 commandType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
143 // ::com::sun::star::sdbc::XWarningsSupplier
144 virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
145 virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
147 // ::com::sun::star::lang::XServiceInfo
148 virtual OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
149 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
150 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
152 // XConnection
153 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
154 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
155 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
156 virtual OUString SAL_CALL nativeSQL( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
157 virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
158 virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
159 virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
160 virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
161 virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
162 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
163 virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
164 virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
165 virtual void SAL_CALL setCatalog( const OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
166 virtual OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
167 virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
168 virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
169 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
170 virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
172 // ::com::sun::star::sdbc::XCloseable
173 virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
175 // XMultiServiceFactory
176 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
177 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
178 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
180 // XUsersSupplier
181 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getUsers( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
182 // XGroupsSupplier
183 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getGroups( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
185 // XConnectionTools
186 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XTableName > SAL_CALL createTableName( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
187 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XObjectNames > SAL_CALL getObjectNames( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
188 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XDataSourceMetaData > SAL_CALL getDataSourceMetaData( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
189 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getFieldsByCommandDescriptor( ::sal_Int32 commandType, const OUString& command, ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& keepFieldsAlive ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
190 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > SAL_CALL getComposer( ::sal_Int32 commandType, const OUString& command ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
192 // XTableUIProvider
193 virtual ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > SAL_CALL getTableIcon( const OUString& TableName, ::sal_Int32 ColorMode ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
194 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getTableEditor( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& DocumentUI, const OUString& TableName ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
196 // IRefreshListener
197 virtual void refresh(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rToBeRefreshed) SAL_OVERRIDE;
199 protected:
200 inline void checkDisposed() throw (::com::sun::star::lang::DisposedException)
202 if ( rBHelper.bDisposed || !m_xConnection.is() )
203 throw ::com::sun::star::lang::DisposedException();
206 ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > getMasterTables();
208 private:
209 /** checks whether or not there are naming conflicts between tables and queries
211 void impl_checkTableQueryNames_nothrow();
213 /** loads the XConnectionTools implementation which we forward the respective functionality to
215 @throws ::com::sun::star::uno::RuntimeException
216 if the implementation cannot be loaded
218 @postcond
219 m_xConnectionTools is nol <NULL/>
221 void impl_loadConnectionTools_throw();
223 /** reads the table filter and table type filter from the datasourfce
225 void impl_fillTableFilter();
228 } // namespace dbaccess
230 #endif // INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_CONNECTION_HXX
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */