1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: datasource.hxx,v $
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>
37 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
38 #include <com/sun/star/lang/XServiceInfo.hpp>
40 #ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
41 #include <com/sun/star/sdbc/XDataSource.hpp>
43 #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_
44 #include <com/sun/star/container/XContainerListener.hpp>
46 #ifndef _COM_SUN_STAR_SDB_XBOOKMARKSSUPPLIER_HPP_
47 #include <com/sun/star/sdb/XBookmarksSupplier.hpp>
49 #ifndef _COM_SUN_STAR_SDB_XQUERYDEFINITIONSSUPPLIER_HPP_
50 #include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
52 #ifndef _COM_SUN_STAR_SDBC_XISOLATEDCONNECTION_HPP_
53 #include <com/sun/star/sdbc/XIsolatedConnection.hpp>
55 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
56 #include <com/sun/star/util/XNumberFormatter.hpp>
58 #ifndef _COM_SUN_STAR_DOCUMENT_XEVENTLISTENER_HPP_
59 #include <com/sun/star/document/XEventListener.hpp>
61 #ifndef _COM_SUN_STAR_UTIL_XFLUSHABLE_HPP_
62 #include <com/sun/star/util/XFlushable.hpp>
64 #ifndef _CPPUHELPER_PROPSHLP_HXX
65 #include <cppuhelper/propshlp.hxx>
67 #ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
68 #include <comphelper/proparrhlp.hxx>
70 #ifndef _CPPUHELPER_WEAKREF_HXX_
71 #include <cppuhelper/weakref.hxx>
73 #ifndef _CPPUHELPER_IMPLBASE11_HXX_
74 #include <cppuhelper/implbase11.hxx>
76 #ifndef _CPPUHELPER_IMPLBASE12_HXX_
77 #include <cppuhelper/implbase12.hxx>
79 #ifndef _COM_SUN_STAR_EMBED_XTRANSACTIONLISTENER_HPP_
80 #include <com/sun/star/embed/XTransactionListener.hpp>
82 #ifndef _DBASHARED_APITOOLS_HXX_
83 #include "apitools.hxx"
85 #ifndef _DBA_CORE_BOOKMARKCONTAINER_HXX_
86 #include "bookmarkcontainer.hxx"
89 #include <vos/ref.hxx>
92 #include <tools/string.hxx>
94 #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
95 #include <connectivity/CommonTools.hxx>
97 #ifndef _COMPHELPER_BROADCASTHELPER_HXX_
98 #include <comphelper/broadcasthelper.hxx>
100 #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
101 #include <com/sun/star/beans/PropertyAttribute.hpp>
103 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
104 #include <com/sun/star/beans/PropertyValue.hpp>
106 #ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_
107 #include <com/sun/star/sdb/XCompletedConnection.hpp>
109 #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
110 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
112 #ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_
113 #include <com/sun/star/embed/XStorage.hpp>
115 #ifndef DBA_CONTENTHELPER_HXX
116 #include "ContentHelper.hxx"
118 #ifndef _COM_SUN_STAR_DOCUMENT_XSTORAGEBASEDDOCUMENT_HPP_
119 #include <com/sun/star/document/XStorageBasedDocument.hpp>
121 #ifndef _COM_SUN_STAR_EMBED_ELEMENTMODES_HPP_
122 #include <com/sun/star/embed/ElementModes.hpp>
124 #ifndef _COM_SUN_STAR_UTIL_XREFRESHABLE_HPP_
125 #include <com/sun/star/util/XRefreshable.hpp>
127 #ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_
128 #include <com/sun/star/sdb/XDocumentDataSource.hpp>
130 #ifndef _DBA_COREDATAACCESS_MODELIMPL_HXX_
131 #include "ModelImpl.hxx"
134 //........................................................................
137 //........................................................................
139 class OSharedConnectionManager
;
140 class OChildCommitListen_Impl
;
142 //============================================================
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
;
171 OBookmarkContainer m_aBookmarks
;
172 ::cppu::OInterfaceContainerHelper m_aFlushListeners
;
175 virtual ~ODatabaseSource();
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.
192 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdb::XDocumentDataSource
>& _rxDocument
,
193 const ::rtl::OUString
& _rNewName
,
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
>&);
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
);
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
,
242 const ::com::sun::star::uno::Any
& rValue
)
243 throw (::com::sun::star::lang::IllegalArgumentException
);
244 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
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
);
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
);
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
);
281 // ModelDependentComponent overridables
282 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> getThis() const;
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
);
305 using ::cppu::OPropertySetHelper::getFastPropertyValue
;
308 //........................................................................
309 } // namespace dbaccess
310 //........................................................................
312 #endif // _DBA_COREDATAACCESS_DATALINK_HXX_