Update ooo320-m1
[ooovba.git] / dbaccess / source / core / dataaccess / datasource.hxx
blob7ba295f0413be41e77737aed7c090559a102fd12
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: datasource.hxx,v $
10 * $Revision: 1.44 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _DBA_COREDATAACCESS_DATASOURCE_HXX_
32 #define _DBA_COREDATAACCESS_DATASOURCE_HXX_
34 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
35 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
36 #endif
37 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
38 #include <com/sun/star/lang/XServiceInfo.hpp>
39 #endif
40 #ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
41 #include <com/sun/star/sdbc/XDataSource.hpp>
42 #endif
43 #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_
44 #include <com/sun/star/container/XContainerListener.hpp>
45 #endif
46 #ifndef _COM_SUN_STAR_SDB_XBOOKMARKSSUPPLIER_HPP_
47 #include <com/sun/star/sdb/XBookmarksSupplier.hpp>
48 #endif
49 #ifndef _COM_SUN_STAR_SDB_XQUERYDEFINITIONSSUPPLIER_HPP_
50 #include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
51 #endif
52 #ifndef _COM_SUN_STAR_SDBC_XISOLATEDCONNECTION_HPP_
53 #include <com/sun/star/sdbc/XIsolatedConnection.hpp>
54 #endif
55 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
56 #include <com/sun/star/util/XNumberFormatter.hpp>
57 #endif
58 #ifndef _COM_SUN_STAR_DOCUMENT_XEVENTLISTENER_HPP_
59 #include <com/sun/star/document/XEventListener.hpp>
60 #endif
61 #ifndef _COM_SUN_STAR_UTIL_XFLUSHABLE_HPP_
62 #include <com/sun/star/util/XFlushable.hpp>
63 #endif
64 #ifndef _CPPUHELPER_PROPSHLP_HXX
65 #include <cppuhelper/propshlp.hxx>
66 #endif
67 #ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
68 #include <comphelper/proparrhlp.hxx>
69 #endif
70 #ifndef _CPPUHELPER_WEAKREF_HXX_
71 #include <cppuhelper/weakref.hxx>
72 #endif
73 #ifndef _CPPUHELPER_IMPLBASE11_HXX_
74 #include <cppuhelper/implbase11.hxx>
75 #endif
76 #ifndef _CPPUHELPER_IMPLBASE12_HXX_
77 #include <cppuhelper/implbase12.hxx>
78 #endif
79 #ifndef _COM_SUN_STAR_EMBED_XTRANSACTIONLISTENER_HPP_
80 #include <com/sun/star/embed/XTransactionListener.hpp>
81 #endif
82 #ifndef _DBASHARED_APITOOLS_HXX_
83 #include "apitools.hxx"
84 #endif
85 #ifndef _DBA_CORE_BOOKMARKCONTAINER_HXX_
86 #include "bookmarkcontainer.hxx"
87 #endif
88 #ifndef _VOS_REF_HXX_
89 #include <vos/ref.hxx>
90 #endif
91 #ifndef _STRING_HXX
92 #include <tools/string.hxx>
93 #endif
94 #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
95 #include <connectivity/CommonTools.hxx>
96 #endif
97 #ifndef _COMPHELPER_BROADCASTHELPER_HXX_
98 #include <comphelper/broadcasthelper.hxx>
99 #endif
100 #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
101 #include <com/sun/star/beans/PropertyAttribute.hpp>
102 #endif
103 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
104 #include <com/sun/star/beans/PropertyValue.hpp>
105 #endif
106 #ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_
107 #include <com/sun/star/sdb/XCompletedConnection.hpp>
108 #endif
109 #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
110 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
111 #endif
112 #ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_
113 #include <com/sun/star/embed/XStorage.hpp>
114 #endif
115 #ifndef DBA_CONTENTHELPER_HXX
116 #include "ContentHelper.hxx"
117 #endif
118 #ifndef _COM_SUN_STAR_DOCUMENT_XSTORAGEBASEDDOCUMENT_HPP_
119 #include <com/sun/star/document/XStorageBasedDocument.hpp>
120 #endif
121 #ifndef _COM_SUN_STAR_EMBED_ELEMENTMODES_HPP_
122 #include <com/sun/star/embed/ElementModes.hpp>
123 #endif
124 #ifndef _COM_SUN_STAR_UTIL_XREFRESHABLE_HPP_
125 #include <com/sun/star/util/XRefreshable.hpp>
126 #endif
127 #ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_
128 #include <com/sun/star/sdb/XDocumentDataSource.hpp>
129 #endif
130 #ifndef _DBA_COREDATAACCESS_MODELIMPL_HXX_
131 #include "ModelImpl.hxx"
132 #endif
134 //........................................................................
135 namespace dbaccess
137 //........................................................................
139 class OSharedConnectionManager;
140 class OChildCommitListen_Impl;
142 //============================================================
143 //= ODatabaseSource
144 //============================================================
145 typedef ::cppu::ImplHelper11 < ::com::sun::star::lang::XServiceInfo
146 , ::com::sun::star::sdbc::XDataSource
147 , ::com::sun::star::sdb::XBookmarksSupplier
148 , ::com::sun::star::sdb::XQueryDefinitionsSupplier
149 , ::com::sun::star::sdb::XCompletedConnection
150 , ::com::sun::star::container::XContainerListener
151 , ::com::sun::star::sdbc::XIsolatedConnection
152 , ::com::sun::star::sdbcx::XTablesSupplier
153 , ::com::sun::star::util::XFlushable
154 , ::com::sun::star::util::XFlushListener
155 , ::com::sun::star::sdb::XDocumentDataSource
156 > ODatabaseSource_Base;
159 class ODatabaseSource :public ModelDependentComponent // must be first
160 ,public OSubComponent
161 ,public ::cppu::OPropertySetHelper
162 ,public ::comphelper::OPropertyArrayUsageHelper < ODatabaseSource >
163 ,public ODatabaseSource_Base
165 friend class ODatabaseContext;
166 friend class OConnection;
167 friend class OSharedConnectionManager;
169 private:
171 OBookmarkContainer m_aBookmarks;
172 ::cppu::OInterfaceContainerHelper m_aFlushListeners;
174 private:
175 virtual ~ODatabaseSource();
177 public:
178 ODatabaseSource( const ::rtl::Reference< ODatabaseModelImpl >& _pImpl );
180 struct DBContextAccess { friend class ODatabaseContext; private: DBContextAccess() { } };
182 /** sets a new name for the data source
184 The name of a data source (our m_sName member) is the registration name, *if* the
185 data source actually *is* registered at the database context.
187 Normally, this name is passed at time of creation of the ODatabaseModelImpl instance,
188 but if a newly creaed data source is registered, then it must be possible to propagate
189 the new trgistration name.
191 static void setName(
192 const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDocumentDataSource >& _rxDocument,
193 const ::rtl::OUString& _rNewName,
194 DBContextAccess
197 // XContainerListener
198 virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
199 virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
200 virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
201 // ::com::sun::star::sdbcx::XTablesSupplier
202 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables( ) throw(::com::sun::star::uno::RuntimeException);
204 // com::sun::star::lang::XTypeProvider
205 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
206 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
208 // com::sun::star::uno::XInterface
209 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException);
210 virtual void SAL_CALL acquire() throw( );
211 virtual void SAL_CALL release() throw( );
213 // ::com::sun::star::lang::XServiceInfo
214 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
215 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
216 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
218 // ::com::sun::star::lang::XServiceInfo - static methods
219 static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException );
220 static ::rtl::OUString getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException );
221 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
222 SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
224 // OComponentHelper
225 virtual void SAL_CALL disposing(void);
227 // com::sun::star::beans::XPropertySet
228 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
229 // XEventListener
230 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
232 // comphelper::OPropertyArrayUsageHelper
233 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
235 // cppu::OPropertySetHelper
236 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
238 virtual sal_Bool SAL_CALL convertFastPropertyValue(
239 ::com::sun::star::uno::Any & rConvertedValue,
240 ::com::sun::star::uno::Any & rOldValue,
241 sal_Int32 nHandle,
242 const ::com::sun::star::uno::Any& rValue )
243 throw (::com::sun::star::lang::IllegalArgumentException);
244 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
245 sal_Int32 nHandle,
246 const ::com::sun::star::uno::Any& rValue
248 throw (::com::sun::star::uno::Exception);
249 virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
251 // ::com::sun::star::sdb::XCompletedConnection
252 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connectWithCompletion( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& handler ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
254 // ::com::sun::star::sdbc::XDataSource
255 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( const ::rtl::OUString& user, const ::rtl::OUString& password ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
256 virtual void SAL_CALL setLoginTimeout( sal_Int32 seconds ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
257 virtual sal_Int32 SAL_CALL getLoginTimeout( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
259 // :: com::sun::star::sdb::XBookmarksSupplier
260 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getBookmarks( ) throw (::com::sun::star::uno::RuntimeException);
262 // :: com::sun::star::sdb::XQueryDefinitionsSupplier
263 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getQueryDefinitions( ) throw(::com::sun::star::uno::RuntimeException);
265 // ::com::sun::star::sdbc::XIsolatedConnection
266 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getIsolatedConnection( const ::rtl::OUString& user, const ::rtl::OUString& password ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
267 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getIsolatedConnectionWithCompletion( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& handler ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
269 // XFlushable
270 virtual void SAL_CALL flush( ) throw (::com::sun::star::uno::RuntimeException);
271 virtual void SAL_CALL addFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw (::com::sun::star::uno::RuntimeException);
272 virtual void SAL_CALL removeFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw (::com::sun::star::uno::RuntimeException);
274 // XFlushListener
275 virtual void SAL_CALL flushed( const ::com::sun::star::lang::EventObject& rEvent ) throw (::com::sun::star::uno::RuntimeException);
277 // XDocumentDataSource
278 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XOfficeDatabaseDocument > SAL_CALL getDatabaseDocument() throw (::com::sun::star::uno::RuntimeException);
280 protected:
281 // ModelDependentComponent overridables
282 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getThis() const;
284 private:
285 // helper
286 /** open a connection for the current settings. this is the simple connection we get from the driver
287 manager, so it can be used as a master for a "high level" sdb connection.
289 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > buildLowLevelConnection(
290 const ::rtl::OUString& _rUid, const ::rtl::OUString& _rPwd
293 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > buildIsolatedConnection(
294 const rtl::OUString& user, const rtl::OUString& password
297 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( const ::rtl::OUString& user, const ::rtl::OUString& password , sal_Bool _bIsolated) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
298 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connectWithCompletion( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& handler , sal_Bool _bIsolated) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
300 void clearConnections();
302 void impl_insertJavaDriverClassPath_nothrow(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rDriverInfo);
304 protected:
305 using ::cppu::OPropertySetHelper::getFastPropertyValue;
308 //........................................................................
309 } // namespace dbaccess
310 //........................................................................
312 #endif // _DBA_COREDATAACCESS_DATALINK_HXX_