LibreOffice Module dbaccess (master) 1
connection.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#pragma once
20
21#include <sal/config.h>
22
23#include <atomic>
24#include <cstddef>
25#include <map>
26
27#include <apitools.hxx>
28#include <querycontainer.hxx>
29#include <tablecontainer.hxx>
30#include <viewcontainer.hxx>
31#include <RefreshListener.hxx>
32
33#include <com/sun/star/container/XChild.hpp>
34#include <com/sun/star/lang/DisposedException.hpp>
35#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
36#include <com/sun/star/sdb/XCommandPreparation.hpp>
37#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
38#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
39#include <com/sun/star/sdbcx/XUsersSupplier.hpp>
40#include <com/sun/star/sdbcx/XGroupsSupplier.hpp>
41#include <com/sun/star/sdb/XQueriesSupplier.hpp>
42#include <com/sun/star/lang/XMultiServiceFactory.hpp>
43#include <com/sun/star/sdb/tools/XConnectionTools.hpp>
44#include <com/sun/star/sdb/application/XTableUIProvider.hpp>
45#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
46
51
52namespace dbaccess
53{
54
55typedef cppu::ImplHelper13 < css::container::XChild
56 , css::sdbcx::XTablesSupplier
57 , css::sdbcx::XViewsSupplier
58 , css::sdbc::XConnection
59 , css::sdbc::XWarningsSupplier
60 , css::sdb::XQueriesSupplier
61 , css::sdb::XSQLQueryComposerFactory
62 , css::sdb::XCommandPreparation
63 , css::lang::XMultiServiceFactory
64 , css::sdbcx::XUsersSupplier
65 , css::sdbcx::XGroupsSupplier
66 , css::sdb::tools::XConnectionTools
67 , css::sdb::application::XTableUIProvider
69
70class ODatabaseSource;
71// OConnection
72class OConnection final :public ::cppu::BaseMutex
73 ,public OSubComponent
75 ,public OConnection_Base
76 ,public IRefreshListener
77{
78 css::uno::Reference< css::sdbcx::XTablesSupplier >
79 m_xMasterTables; // just to avoid the recreation of the catalog
81 css::uno::Reference< css::container::XNameAccess >
84
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;
92
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;
97
98 std::unique_ptr<OTableContainer> m_pTables;
99 std::unique_ptr<OViewContainer> m_pViews;
101 std::atomic<std::size_t> m_nInAppend;
102 bool m_bSupportsViews; // true when the getTableTypes return "VIEW" as type
105
106 virtual ~OConnection() override;
107public:
109 ,css::uno::Reference< css::sdbc::XConnection > const & _rxMaster
110 ,const css::uno::Reference< css::uno::XComponentContext >& _rxORB);
111
112// css::lang::XTypeProvider
113 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
114 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
115
116// css::uno::XInterface
117 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
118 virtual void SAL_CALL acquire() noexcept override;
119 virtual void SAL_CALL release() noexcept override;
120
121// OComponentHelper
122 virtual void SAL_CALL disposing() override;
123
124// css::container::XChild
125 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override;
126 virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override;
127
128// css::sdbcx::XTablesSupplier
129 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTables( ) override;
130// css::sdbcx::XViewsSupplier
131 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getViews( ) override;
132
133// css::sdb::XQueriesSupplier
134 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getQueries( ) override;
135
136// css::sdb::XSQLQueryComposerFactory
137 virtual css::uno::Reference< css::sdb::XSQLQueryComposer > SAL_CALL createQueryComposer( ) override;
138
139// css::sdb::XCommandPreparation
140 virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCommand( const OUString& command, sal_Int32 commandType ) override;
141
142// css::sdbc::XWarningsSupplier
143 virtual css::uno::Any SAL_CALL getWarnings( ) override;
144 virtual void SAL_CALL clearWarnings( ) override;
145
146// css::lang::XServiceInfo
147 virtual OUString SAL_CALL getImplementationName( ) override;
148 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
149 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
150
151// XConnection
152 virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement( ) override;
153 virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const OUString& sql ) override;
154 virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall( const OUString& sql ) override;
155 virtual OUString SAL_CALL nativeSQL( const OUString& sql ) override;
156 virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) override;
157 virtual sal_Bool SAL_CALL getAutoCommit( ) override;
158 virtual void SAL_CALL commit( ) override;
159 virtual void SAL_CALL rollback( ) override;
160 virtual sal_Bool SAL_CALL isClosed( ) override;
161 virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) override;
162 virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) override;
163 virtual sal_Bool SAL_CALL isReadOnly( ) override;
164 virtual void SAL_CALL setCatalog( const OUString& catalog ) override;
165 virtual OUString SAL_CALL getCatalog( ) override;
166 virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) override;
167 virtual sal_Int32 SAL_CALL getTransactionIsolation( ) override;
168 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTypeMap( ) override;
169 virtual void SAL_CALL setTypeMap( const css::uno::Reference< css::container::XNameAccess >& typeMap ) override;
170
171// css::sdbc::XCloseable
172 virtual void SAL_CALL close( ) override;
173
174 // XMultiServiceFactory
175 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) override;
176 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments ) override;
177 virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames( ) override;
178
179 // XUsersSupplier
180 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getUsers( ) override;
181 // XGroupsSupplier
182 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getGroups( ) override;
183
184 // XConnectionTools
185 virtual css::uno::Reference< css::sdb::tools::XTableName > SAL_CALL createTableName( ) override;
186 virtual css::uno::Reference< css::sdb::tools::XObjectNames > SAL_CALL getObjectNames( ) override;
187 virtual css::uno::Reference< css::sdb::tools::XDataSourceMetaData > SAL_CALL getDataSourceMetaData( ) override;
188 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getFieldsByCommandDescriptor( ::sal_Int32 commandType, const OUString& command, css::uno::Reference< css::lang::XComponent >& keepFieldsAlive ) override;
189 virtual css::uno::Reference< css::sdb::XSingleSelectQueryComposer > SAL_CALL getComposer( ::sal_Int32 commandType, const OUString& command ) override;
190
191 // XTableUIProvider
192 virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getTableIcon( const OUString& TableName, ::sal_Int32 ColorMode ) override;
193 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getTableEditor( const css::uno::Reference< css::sdb::application::XDatabaseDocumentUI >& DocumentUI, const OUString& TableName ) override;
194
195 // IRefreshListener
196 virtual void refresh(const css::uno::Reference< css::container::XNameAccess >& _rToBeRefreshed) override;
197
198private:
201 {
202 if ( rBHelper.bDisposed || !m_xConnection.is() )
203 throw css::lang::DisposedException();
204 }
205
206 css::uno::Reference< css::sdbcx::XTablesSupplier > const & getMasterTables();
207
211
221
225};
226
227} // namespace dbaccess
228
229/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::sdbc::XConnection > m_xConnection
virtual css::uno::Reference< css::sdb::tools::XDataSourceMetaData > SAL_CALL getDataSourceMetaData() override
Definition: connection.cxx:716
virtual void SAL_CALL setParent(const css::uno::Reference< css::uno::XInterface > &Parent) override
Definition: connection.cxx:492
virtual void SAL_CALL close() override
Definition: connection.cxx:97
virtual void SAL_CALL release() noexcept override
Definition: connection.cxx:436
virtual void SAL_CALL disposing() override
Definition: connection.cxx:443
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(const OUString &aServiceSpecifier) override
Definition: connection.cxx:617
virtual void SAL_CALL setReadOnly(sal_Bool readOnly) override
Definition: connection.cxx:198
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getUsers() override
Definition: connection.cxx:675
css::uno::Reference< css::sdbcx::XTablesSupplier > const & getMasterTables()
Definition: connection.cxx:656
virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall(const OUString &sql) override
Definition: connection.cxx:141
void impl_loadConnectionTools_throw()
loads the XConnectionTools implementation which we forward the respective functionality to
Definition: connection.cxx:693
virtual css::uno::Reference< css::sdb::tools::XTableName > SAL_CALL createTableName() override
Definition: connection.cxx:698
OConnection(ODatabaseSource &_rDB, css::uno::Reference< css::sdbc::XConnection > const &_rxMaster, const css::uno::Reference< css::uno::XComponentContext > &_rxORB)
virtual void SAL_CALL setAutoCommit(sal_Bool autoCommit) override
Definition: connection.cxx:163
virtual css::uno::Reference< css::sdb::XSingleSelectQueryComposer > SAL_CALL getComposer(::sal_Int32 commandType, const OUString &command) override
Definition: connection.cxx:734
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getFieldsByCommandDescriptor(::sal_Int32 commandType, const OUString &command, css::uno::Reference< css::lang::XComponent > &keepFieldsAlive) override
Definition: connection.cxx:725
::dbtools::WarningsContainer m_aWarnings
Definition: connection.hxx:100
virtual void SAL_CALL setCatalog(const OUString &catalog) override
Definition: connection.cxx:212
void impl_checkTableQueryNames_nothrow()
checks whether or not there are naming conflicts between tables and queries
Definition: connection.cxx:743
virtual sal_Int32 SAL_CALL getTransactionIsolation() override
Definition: connection.cxx:233
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: connection.cxx:412
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTypeMap() override
Definition: connection.cxx:240
virtual css::uno::Reference< css::sdb::XSQLQueryComposer > SAL_CALL createQueryComposer() override
Definition: connection.cxx:498
virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData() override
Definition: connection.cxx:191
css::uno::Reference< css::container::XNameAccess > m_xQueries
Definition: connection.hxx:82
virtual void SAL_CALL commit() override
Definition: connection.cxx:177
css::uno::Reference< css::sdbc::XConnection > m_xMasterConnection
Definition: connection.hxx:89
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getViews() override
Definition: connection.cxx:566
css::uno::Sequence< OUString > m_aTableTypeFilter
Definition: connection.hxx:87
connectivity::OWeakRefArray m_aComposers
Definition: connection.hxx:83
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: connection.cxx:77
virtual void SAL_CALL rollback() override
Definition: connection.cxx:184
virtual ~OConnection() override
Definition: connection.cxx:350
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override
Definition: connection.cxx:485
virtual void refresh(const css::uno::Reference< css::container::XNameAccess > &_rToBeRefreshed) override
Definition: connection.cxx:519
css::uno::Reference< css::sdb::tools::XConnectionTools > m_xConnectionTools
Definition: connection.hxx:90
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: connection.cxx:82
virtual void SAL_CALL setTypeMap(const css::uno::Reference< css::container::XNameAccess > &typeMap) override
virtual void SAL_CALL clearWarnings() override
Definition: connection.cxx:362
css::uno::Reference< css::sdb::application::XTableUIProvider > m_xTableUIProvider
Definition: connection.hxx:91
std::unique_ptr< OTableContainer > m_pTables
Definition: connection.hxx:98
virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getTableIcon(const OUString &TableName, ::sal_Int32 ColorMode) override
Definition: connection.cxx:774
virtual css::uno::Reference< css::sdb::tools::XObjectNames > SAL_CALL getObjectNames() override
Definition: connection.cxx:707
virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCommand(const OUString &command, sal_Int32 commandType) override
Definition: connection.cxx:586
virtual OUString SAL_CALL getCatalog() override
Definition: connection.cxx:219
virtual sal_Bool SAL_CALL getAutoCommit() override
Definition: connection.cxx:170
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getGroups() override
Definition: connection.cxx:685
TSupportServices m_aSupportServices
Definition: connection.hxx:96
std::map< OUString, css::uno::Reference< css::uno::XInterface > > TSupportServices
Definition: connection.hxx:95
void impl_fillTableFilter()
reads the table filter and table type filter from the datasource
Definition: connection.cxx:509
css::uno::Reference< css::uno::XComponentContext > m_aContext
Definition: connection.hxx:88
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: connection.cxx:406
virtual sal_Bool SAL_CALL isReadOnly() override
Definition: connection.cxx:205
virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement() override
Definition: connection.cxx:110
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: connection.cxx:388
virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement(const OUString &sql) override
Definition: connection.cxx:125
virtual void SAL_CALL acquire() noexcept override
Definition: connection.cxx:430
connectivity::OWeakRefArray m_aStatements
Definition: connection.hxx:80
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTables() override
Definition: connection.cxx:556
std::atomic< std::size_t > m_nInAppend
Definition: connection.hxx:101
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getTableEditor(const css::uno::Reference< css::sdb::application::XDatabaseDocumentUI > &DocumentUI, const OUString &TableName) override
Definition: connection.cxx:790
virtual OUString SAL_CALL getImplementationName() override
Definition: connection.cxx:72
virtual OUString SAL_CALL nativeSQL(const OUString &sql) override
Definition: connection.cxx:156
virtual sal_Bool SAL_CALL isClosed() override
Definition: connection.cxx:103
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: connection.cxx:650
std::unique_ptr< OViewContainer > m_pViews
Definition: connection.hxx:99
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments(const OUString &ServiceSpecifier, const css::uno::Sequence< css::uno::Any > &Arguments) override
Definition: connection.cxx:645
virtual css::uno::Any SAL_CALL getWarnings() override
Definition: connection.cxx:355
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getQueries() override
Definition: connection.cxx:577
css::uno::Reference< css::sdbcx::XTablesSupplier > m_xMasterTables
Definition: connection.hxx:79
virtual void SAL_CALL setTransactionIsolation(sal_Int32 level) override
Definition: connection.cxx:226
css::uno::Sequence< OUString > m_aTableFilter
Definition: connection.hxx:86
std::vector< css::uno::WeakReferenceHelper > OWeakRefArray
cppu::ImplHelper13< css::container::XChild, css::sdbcx::XTablesSupplier, css::sdbcx::XViewsSupplier, css::sdbc::XConnection, css::sdbc::XWarningsSupplier, css::sdb::XQueriesSupplier, css::sdb::XSQLQueryComposerFactory, css::sdb::XCommandPreparation, css::lang::XMultiServiceFactory, css::sdbcx::XUsersSupplier, css::sdbcx::XGroupsSupplier, css::sdb::tools::XConnectionTools, css::sdb::application::XTableUIProvider > OConnection_Base
Definition: connection.hxx:68
unsigned char sal_Bool