LibreOffice Module dbaccess (master) 1
datasource.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
20#pragma once
21
22#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
23#include <com/sun/star/lang/XServiceInfo.hpp>
24#include <com/sun/star/sdbc/XDataSource.hpp>
25#include <com/sun/star/container/XContainerListener.hpp>
26#include <com/sun/star/sdb/XBookmarksSupplier.hpp>
27#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
28#include <com/sun/star/sdbc/XIsolatedConnection.hpp>
29#include <com/sun/star/util/XNumberFormatter.hpp>
30#include <com/sun/star/document/XEventListener.hpp>
31#include <com/sun/star/util/XFlushable.hpp>
37#include <com/sun/star/embed/XTransactionListener.hpp>
38#include <apitools.hxx>
39#include <bookmarkcontainer.hxx>
40#include <rtl/ref.hxx>
42#include <com/sun/star/beans/PropertyAttribute.hpp>
43#include <com/sun/star/beans/PropertyValue.hpp>
44#include <com/sun/star/sdb/XCompletedConnection.hpp>
45#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
46#include <com/sun/star/embed/XStorage.hpp>
47#include <ContentHelper.hxx>
48#include <com/sun/star/document/XStorageBasedDocument.hpp>
49#include <com/sun/star/embed/ElementModes.hpp>
50#include <com/sun/star/util/XRefreshable.hpp>
51#include <com/sun/star/sdb/XDocumentDataSource.hpp>
52#include <ModelImpl.hxx>
53
54namespace dbaccess
55{
56
57class OSharedConnectionManager;
58
59// ODatabaseSource
60typedef ::cppu::WeakComponentImplHelper< css::lang::XServiceInfo
61 , css::sdbc::XDataSource
62 , css::sdb::XBookmarksSupplier
63 , css::sdb::XQueryDefinitionsSupplier
64 , css::sdb::XCompletedConnection
65 , css::container::XContainerListener
66 , css::sdbc::XIsolatedConnection
67 , css::sdbcx::XTablesSupplier
68 , css::util::XFlushable
69 , css::util::XFlushListener
70 , css::sdb::XDocumentDataSource
71 , css::lang::XInitialization
73
74class ODatabaseSource :public ModelDependentComponent // must be first
77 ,public ::comphelper::OPropertyArrayUsageHelper < ODatabaseSource >
78{
79 friend class ODatabaseContext;
80 friend class OConnection;
82
83private:
84 using ODatabaseSource_Base::rBHelper;
85 // note: this thing uses the ref-count of "this", see OBookmarkContainer::acquire!
88
89private:
90 virtual ~ODatabaseSource() override;
91
92public:
93 explicit ODatabaseSource( const ::rtl::Reference< ODatabaseModelImpl >& _pImpl );
94
95 struct DBContextAccess { friend class ODatabaseContext; private: DBContextAccess() { } };
96
106 static void setName(
107 const css::uno::Reference< css::sdb::XDocumentDataSource >& _rxDocument,
108 const OUString& _rNewName,
110 );
111
112 // XContainerListener
113 virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override;
114 virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override;
115 virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override;
116 // css::sdbcx::XTablesSupplier
117 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTables( ) override;
118
119// css::lang::XTypeProvider
120 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
121 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
122
123// css::uno::XInterface
124 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
125 virtual void SAL_CALL acquire() noexcept override;
126 virtual void SAL_CALL release() noexcept override;
127
128// css::lang::XServiceInfo
129 virtual OUString SAL_CALL getImplementationName( ) override;
130 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
131 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
132
133// OComponentHelper
134 virtual void SAL_CALL disposing() override;
135
136// css::beans::XPropertySet
137 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
138 // XEventListener
139 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
140
141// comphelper::OPropertyArrayUsageHelper
142 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
143
144// cppu::OPropertySetHelper
145 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
146
147 virtual sal_Bool SAL_CALL convertFastPropertyValue(
148 css::uno::Any & rConvertedValue,
149 css::uno::Any & rOldValue,
150 sal_Int32 nHandle,
151 const css::uno::Any& rValue ) override;
152 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
153 sal_Int32 nHandle,
154 const css::uno::Any& rValue
155 ) override;
156 virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const override;
157
158// css::sdb::XCompletedConnection
159 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL connectWithCompletion( const css::uno::Reference< css::task::XInteractionHandler >& handler ) override;
160
161// css::sdbc::XDataSource
162 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( const OUString& user, const OUString& password ) override;
163 virtual void SAL_CALL setLoginTimeout( sal_Int32 seconds ) override;
164 virtual sal_Int32 SAL_CALL getLoginTimeout( ) override;
165
166//::css::sdb::XBookmarksSupplier
167 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getBookmarks( ) override;
168
169//::css::sdb::XQueryDefinitionsSupplier
170 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getQueryDefinitions( ) override;
171
172// css::sdbc::XIsolatedConnection
173 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getIsolatedConnection( const OUString& user, const OUString& password ) override;
174 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getIsolatedConnectionWithCompletion( const css::uno::Reference< css::task::XInteractionHandler >& handler ) override;
175
176// XFlushable
177 virtual void SAL_CALL flush( ) override;
178 virtual void SAL_CALL addFlushListener( const css::uno::Reference< css::util::XFlushListener >& l ) override;
179 virtual void SAL_CALL removeFlushListener( const css::uno::Reference< css::util::XFlushListener >& l ) override;
180
181 // XFlushListener
182 virtual void SAL_CALL flushed( const css::lang::EventObject& rEvent ) override;
183
184 // XDocumentDataSource
185 virtual css::uno::Reference< css::sdb::XOfficeDatabaseDocument > SAL_CALL getDatabaseDocument() override;
186
187 // XInitialization
188 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
189
190protected:
191 // ModelDependentComponent overridables
192 virtual css::uno::Reference< css::uno::XInterface > getThis() const override;
193
194private:
195// helper
199 css::uno::Reference< css::sdbc::XConnection > buildLowLevelConnection(
200 const OUString& _rUid, const OUString& _rPwd
201 );
202
203 css::uno::Reference< css::sdbc::XConnection > buildIsolatedConnection(
204 const OUString& user, const OUString& password
205 );
206
209 css::uno::Reference< css::sdbc::XConnection > getConnection( const OUString& user, const OUString& password , bool _bIsolated);
212 css::uno::Reference< css::sdbc::XConnection > connectWithCompletion( const css::uno::Reference< css::task::XInteractionHandler >& handler , bool _bIsolated);
213
214protected:
216};
217
218} // namespace dbaccess
219
220/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
a small base class for UNO components whose functionality depends on an ODatabaseModelImpl
Definition: ModelImpl.hxx:452
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: datasource.cxx:560
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTables() override
virtual css::uno::Reference< css::sdb::XOfficeDatabaseDocument > SAL_CALL getDatabaseDocument() override
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getIsolatedConnection(const OUString &user, const OUString &password) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: datasource.cxx:507
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: datasource.cxx:525
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getIsolatedConnectionWithCompletion(const css::uno::Reference< css::task::XInteractionHandler > &handler) override
virtual void SAL_CALL addFlushListener(const css::uno::Reference< css::util::XFlushListener > &l) override
virtual OUString SAL_CALL getImplementationName() override
Definition: datasource.cxx:550
virtual void SAL_CALL disposing() override
Definition: datasource.cxx:566
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
Definition: datasource.cxx:826
css::uno::Reference< css::sdbc::XConnection > buildLowLevelConnection(const OUString &_rUid, const OUString &_rPwd)
open a connection for the current settings.
Definition: datasource.cxx:598
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
Definition: datasource.cxx:964
virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent &Event) override
virtual void SAL_CALL elementInserted(const css::container::ContainerEvent &Event) override
virtual void SAL_CALL flushed(const css::lang::EventObject &rEvent) override
virtual void SAL_CALL acquire() noexcept override
Definition: datasource.cxx:533
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getBookmarks() override
virtual void SAL_CALL removeFlushListener(const css::uno::Reference< css::util::XFlushListener > &l) override
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
Definition: datasource.cxx:797
virtual sal_Int32 SAL_CALL getLoginTimeout() override
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getQueryDefinitions() override
virtual void SAL_CALL release() noexcept override
Definition: datasource.cxx:538
ODatabaseSource(const ::rtl::Reference< ODatabaseModelImpl > &_pImpl)
Definition: datasource.cxx:476
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection(const OUString &user, const OUString &password) override
::comphelper::OInterfaceContainerHelper3< css::util::XFlushListener > m_aFlushListeners
Definition: datasource.hxx:87
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL connectWithCompletion(const css::uno::Reference< css::task::XInteractionHandler > &handler) override
virtual css::uno::Reference< css::uno::XInterface > getThis() const override
returns the component itself
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
Definition: datasource.cxx:821
virtual ~ODatabaseSource() override
Definition: datasource.cxx:487
OBookmarkContainer m_Bookmarks
Definition: datasource.hxx:86
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: datasource.cxx:519
virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent &Event) override
virtual void SAL_CALL flush() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: datasource.cxx:555
virtual void SAL_CALL setLoginTimeout(sal_Int32 seconds) override
css::uno::Reference< css::sdbc::XConnection > buildIsolatedConnection(const OUString &user, const OUString &password)
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: datasource.cxx:791
static void setName(const css::uno::Reference< css::sdb::XDocumentDataSource > &_rxDocument, const OUString &_rNewName, DBContextAccess)
sets a new name for the data source
Definition: datasource.cxx:497
Sequence< PropertyValue > aArguments
Definition: intercept.cxx:88
::cppu::WeakComponentImplHelper< css::lang::XServiceInfo, css::sdbc::XDataSource, css::sdb::XBookmarksSupplier, css::sdb::XQueryDefinitionsSupplier, css::sdb::XCompletedConnection, css::container::XContainerListener, css::sdbc::XIsolatedConnection, css::sdbcx::XTablesSupplier, css::util::XFlushable, css::util::XFlushListener, css::sdb::XDocumentDataSource, css::lang::XInitialization > ODatabaseSource_Base
Definition: datasource.hxx:57
unsigned char sal_Bool