Tag: cws_src680_dba201b User: fs Date: 05/07/21 05:00:30 Modified: /dba/connectivity/inc/connectivity/ dbtools.hxx
Log: #i52255# +ensureRowSetConnection File Changes: Directory: /dba/connectivity/inc/connectivity/ ============================================== File [changed]: dbtools.hxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/inc/connectivity/dbtools.hxx?r1=1.27&r2=1.27.58.1 Delta lines: +44 -6 -------------------- --- dbtools.hxx 17 Feb 2005 10:13:53 -0000 1.27 +++ dbtools.hxx 21 Jul 2005 12:00:27 -0000 1.27.58.1 @@ -2,9 +2,9 @@ * * $RCSfile: dbtools.hxx,v $ * - * $Revision: 1.27 $ + * $Revision: 1.27.58.1 $ * - * last change: $Author: vg $ $Date: 2005/02/17 10:13:53 $ + * last change: $Author: fs $ $Date: 2005/07/21 12:00:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,6 +74,9 @@ #ifndef _COMPHELPER_STLTYPES_HXX_ #include <comphelper/stl_types.hxx> #endif +#ifndef UNOTOOLS_INC_SHAREDUNOCOMPONENT_HXX +#include <unotools/sharedunocomponent.hxx> +#endif namespace com { namespace sun { namespace star { @@ -121,6 +124,8 @@ //......................................................................... namespace dbtools { + typedef ::utl::SharedUNOComponent< ::com::sun::star::sdbc::XConnection > SharedConnection; + enum EComposeRule { eInTableDefinitions, @@ -159,6 +164,8 @@ <nl> <li>If the rowset already has an ActiveConnection (means a non-<NULL/> value vor this property), this one is used.</li> + <li>If row set is part of a database form document (see ->isEmbeddedInDatabase), + a connection for the respective database is used.</li> <li>If in the parent hierarchy of the row set, there is an object supporting the XConnection interface, this one is returned.</li> <li>If the DataSourceName property of the row set is not empty, a connection for this @@ -177,9 +184,9 @@ If <TRUE/>, the calculated connection is set as ActiveConnection property on the rowset. If the connection was newly created by the method, and this parameter is <TRUE/>, then - the ownership of the conneciton is delivered to a temporary object, which observes the + the ownership of the connection is delivered to a temporary object, which observes the row set: As soon as a connection-relevant property of the row set changes, or as soon - as if somebody else sets another ActiveConnection at the row set, the original + as somebody else sets another ActiveConnection at the row set, the original connection (the one which this function calculated) is disposed and discarded. At this very moment, also the temporary observer object dies. This way, it is ensured that there's no resource leak from an un-owned connection object. @@ -188,6 +195,37 @@ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet, const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory, sal_Bool _bSetAsActiveConnection + ) SAL_THROW ( ( ::com::sun::star::sdbc::SQLException + , ::com::sun::star::lang::WrappedTargetException + , ::com::sun::star::uno::RuntimeException ) ); + + /** ensures that a row set has a valid ActiveConnection, if possible + + This function does nearly the same as ->connectRowset. In fact, it is to be preferred over + ->connectRowset, if possible. + + There are a few differences: + <ul><li>If a connection could be determined for the given RowSet, it is always + set as ActiveConnection.</li> + <li>Definition of the ownership of the created connection allows for more scenarios: + <ul><li>If the connection was not newly created, the returned ->SharedConnection + instance will not have the ownership, since in this case it's assumed + that there already is an instance which has the ownership.</li> + <li>If the connection was newly created, and ->_bUseAutoConnectionDisposer + is <TRUE/>, then the returned SharedConnection instance will <em>not</em> + be the owner of the connection. Instead, the ownership will be delivered + to a temporary object as described for connectRowset.</li> + <li>If the connection was newly created, and ->_bUseAutoConnectionDisposer + is <FALSE/>, then the returned SharedConnection instance will have the + ownership of the XConnection.</li> + </ul> + </li> + </ul> + */ + SharedConnection ensureRowSetConnection( + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory, + bool _bUseAutoConnectionDisposer ) SAL_THROW ( ( ::com::sun::star::sdbc::SQLException , ::com::sun::star::lang::WrappedTargetException , ::com::sun::star::uno::RuntimeException ) ); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
