xref: /aoo42x/main/dbaccess/source/core/api/RowSet.cxx (revision 96de5490)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_dbaccess.hxx"
26 
27 #include "RowSet.hxx"
28 #include "dbastrings.hrc"
29 #include "sdbcoretools.hxx"
30 #include "SingleSelectQueryComposer.hxx"
31 #include "module_dba.hxx"
32 #include "sdbcoretools.hxx"
33 #include "CRowSetColumn.hxx"
34 #include "CRowSetDataColumn.hxx"
35 #include "RowSetCache.hxx"
36 #include "core_resource.hrc"
37 #include "core_resource.hxx"
38 #include "tablecontainer.hxx"
39 
40 /** === begin UNO includes === **/
41 #include <com/sun/star/beans/PropertyAttribute.hpp>
42 #include <com/sun/star/container/XChild.hpp>
43 #include <com/sun/star/lang/DisposedException.hpp>
44 #include <com/sun/star/sdb/CommandType.hpp>
45 #include <com/sun/star/sdb/ErrorCondition.hpp>
46 #include <com/sun/star/sdb/RowChangeAction.hpp>
47 #include <com/sun/star/sdb/RowSetVetoException.hpp>
48 #include <com/sun/star/sdb/XCompletedConnection.hpp>
49 #include <com/sun/star/sdb/XParametersSupplier.hpp>
50 #include <com/sun/star/sdb/XQueriesSupplier.hpp>
51 #include <com/sun/star/sdbc/FetchDirection.hpp>
52 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
53 #include <com/sun/star/sdbc/XDataSource.hpp>
54 #include <com/sun/star/sdbc/XDriverAccess.hpp>
55 #include <com/sun/star/sdbcx/CompareBookmark.hpp>
56 #include <com/sun/star/sdbcx/Privilege.hpp>
57 #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
58 #include <com/sun/star/uno/XNamingService.hpp>
59 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
60 /** === end UNO includes === **/
61 
62 #include <comphelper/componentcontext.hxx>
63 #include <comphelper/extract.hxx>
64 #include <comphelper/interaction.hxx>
65 #include <comphelper/property.hxx>
66 #include <comphelper/seqstream.hxx>
67 #include <comphelper/sequence.hxx>
68 #include <comphelper/types.hxx>
69 #include <comphelper/uno3.hxx>
70 #include <connectivity/BlobHelper.hxx>
71 #include <connectivity/dbconversion.hxx>
72 #include <connectivity/dbexception.hxx>
73 #include <connectivity/dbtools.hxx>
74 #include <cppuhelper/exc_hlp.hxx>
75 #include <cppuhelper/interfacecontainer.h>
76 #include <cppuhelper/typeprovider.hxx>
77 #include <rtl/logfile.hxx>
78 #include <unotools/syslocale.hxx>
79 #include <tools/debug.hxx>
80 #include <tools/diagnose_ex.h>
81 #include <unotools/configmgr.hxx>
82 
83 using namespace utl;
84 using namespace dbaccess;
85 using namespace connectivity;
86 using namespace comphelper;
87 using namespace dbtools;
88 using namespace ::com::sun::star;
89 using namespace ::com::sun::star::uno;
90 using namespace ::com::sun::star::beans;
91 using namespace ::com::sun::star::sdbc;
92 using namespace ::com::sun::star::sdb;
93 using namespace ::com::sun::star::sdbcx;
94 using namespace ::com::sun::star::container;
95 using namespace ::com::sun::star::lang;
96 using namespace ::com::sun::star::task;
97 using namespace ::com::sun::star::util;
98 using namespace ::cppu;
99 using namespace ::osl;
100 
101 //--------------------------------------------------------------------------
102 extern "C" void SAL_CALL createRegistryInfo_ORowSet()
103 {
104 	static ::dba::OAutoRegistration< ORowSet > aAutoRegistration;
105 }
106 // -----------------------------------------------------------------------------
107 
108 #define NOTIFY_LISTERNERS_CHECK(_rListeners,T,method)							  \
109 	Sequence< Reference< XInterface > > aListenerSeq = _rListeners.getElements(); \
110 																				  \
111 	const Reference< XInterface >* pxIntBegin = aListenerSeq.getConstArray();	  \
112 	const Reference< XInterface >* pxInt = pxIntBegin + aListenerSeq.getLength(); \
113 																				  \
114 	_rGuard.clear();															  \
115 	sal_Bool bCheck = sal_True;													  \
116 	while( pxInt > pxIntBegin && bCheck )										  \
117 	{																			  \
118 		try																		  \
119 		{																		  \
120 			while( pxInt > pxIntBegin && bCheck )								  \
121 			{																	  \
122 				--pxInt;														  \
123 				bCheck = static_cast< T* >( pxInt->get() )->method(aEvt);		  \
124 			}																	  \
125 		}																		  \
126 		catch( RuntimeException& )												  \
127 		{																		  \
128 		}																		  \
129 	}																			  \
130 	_rGuard.reset();
131 
132 
133 //..................................................................
134 namespace dbaccess
135 {
136 //..................................................................
137 //--------------------------------------------------------------------------
138 Reference< XInterface > ORowSet_CreateInstance(const Reference< XMultiServiceFactory >& _rxFactory)
139 {
140 	return *(new ORowSet(_rxFactory));
141 }
142 //--------------------------------------------------------------------------
143 ORowSet::ORowSet( const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB )
144 	:ORowSet_BASE1(m_aMutex)
145 	,ORowSetBase( _rxORB, ORowSet_BASE1::rBHelper, &m_aMutex )
146     ,m_pParameters( NULL )
147     ,m_aRowsetListeners(*m_pMutex)
148 	,m_aApproveListeners(*m_pMutex)
149     ,m_aRowsChangeListener(*m_pMutex)
150 	,m_pTables(NULL)
151     ,m_nFetchDirection(FetchDirection::FORWARD)
152 	,m_nFetchSize(50)
153 	,m_nMaxFieldSize(0)
154 	,m_nMaxRows(0)
155 	,m_nQueryTimeOut(0)
156     ,m_nCommandType(CommandType::COMMAND)
157 	,m_nTransactionIsolation(0)
158 	,m_nPrivileges(0)
159     ,m_nInAppend(0)
160 	,m_bUseEscapeProcessing(sal_True)
161 	,m_bApplyFilter(sal_False)
162 	,m_bCommandFacetsDirty( sal_True )
163 	,m_bModified(sal_False)
164     ,m_bRebuildConnOnExecute(sal_False)
165 	,m_bIsBookmarable(sal_True)
166 	,m_bNew(sal_False)
167 	,m_bCanUpdateInsertedRows(sal_True)
168 	,m_bOwnConnection(sal_False)
169 {
170 	m_nResultSetType = ResultSetType::SCROLL_SENSITIVE;
171 	m_nResultSetConcurrency = ResultSetConcurrency::UPDATABLE;
172 	m_pMySelf = this;
173 	m_aActiveConnection <<= m_xActiveConnection;
174 
175 	sal_Int32 nRBT	= PropertyAttribute::READONLY	| PropertyAttribute::BOUND		| PropertyAttribute::TRANSIENT;
176 	sal_Int32 nRT	= PropertyAttribute::READONLY	| PropertyAttribute::TRANSIENT;
177 	sal_Int32 nBT	= PropertyAttribute::BOUND		| PropertyAttribute::TRANSIENT;
178 
179     m_aPrematureParamValues.get().resize( 0 );
180 
181 	// sdb.RowSet Properties
182 	registerMayBeVoidProperty(PROPERTY_ACTIVE_CONNECTION,PROPERTY_ID_ACTIVE_CONNECTION,	PropertyAttribute::MAYBEVOID|PropertyAttribute::TRANSIENT|PropertyAttribute::BOUND,	&m_aActiveConnection,	::getCppuType(reinterpret_cast< Reference< XConnection >* >(NULL)));
183 	registerProperty(PROPERTY_DATASOURCENAME,		PROPERTY_ID_DATASOURCENAME,			PropertyAttribute::BOUND,		&m_aDataSourceName,		::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
184 	registerProperty(PROPERTY_COMMAND,				PROPERTY_ID_COMMAND,				PropertyAttribute::BOUND,		&m_aCommand,			::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
185 	registerProperty(PROPERTY_COMMAND_TYPE,			PROPERTY_ID_COMMAND_TYPE,			PropertyAttribute::BOUND,		&m_nCommandType,		::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
186 	registerProperty(PROPERTY_ACTIVECOMMAND,		PROPERTY_ID_ACTIVECOMMAND,			nRBT,							&m_aActiveCommand,		::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
187 	registerProperty(PROPERTY_IGNORERESULT,			PROPERTY_ID_IGNORERESULT,			PropertyAttribute::BOUND,		&m_bIgnoreResult,		::getBooleanCppuType());
188 	registerProperty(PROPERTY_FILTER,				PROPERTY_ID_FILTER,					PropertyAttribute::BOUND,		&m_aFilter,				::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
189 	registerProperty(PROPERTY_HAVING_CLAUSE,		PROPERTY_ID_HAVING_CLAUSE,			PropertyAttribute::BOUND,		&m_aHavingClause,		::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
190 	registerProperty(PROPERTY_GROUP_BY,				PROPERTY_ID_GROUP_BY,				PropertyAttribute::BOUND,		&m_aGroupBy,			::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
191 	registerProperty(PROPERTY_APPLYFILTER,			PROPERTY_ID_APPLYFILTER,			PropertyAttribute::BOUND,		&m_bApplyFilter,		::getBooleanCppuType());
192 	registerProperty(PROPERTY_ORDER,				PROPERTY_ID_ORDER,					PropertyAttribute::BOUND,		&m_aOrder,				::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
193 	registerProperty(PROPERTY_PRIVILEGES,			PROPERTY_ID_PRIVILEGES,				nRT,							&m_nPrivileges,			::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
194 	registerProperty(PROPERTY_ISMODIFIED,			PROPERTY_ID_ISMODIFIED,				nBT,							&m_bModified,			::getBooleanCppuType());
195 	registerProperty(PROPERTY_ISNEW,				PROPERTY_ID_ISNEW,					nRBT,							&m_bNew,				::getBooleanCppuType());
196     registerProperty(PROPERTY_SINGLESELECTQUERYCOMPOSER,PROPERTY_ID_SINGLESELECTQUERYCOMPOSER,	nRT,	                &m_xComposer,	::getCppuType(reinterpret_cast< Reference< XSingleSelectQueryComposer >* >(NULL)));
197 
198 	// sdbcx.ResultSet Properties
199 	registerProperty(PROPERTY_ISBOOKMARKABLE,		PROPERTY_ID_ISBOOKMARKABLE,			nRT,							&m_bIsBookmarable,		::getBooleanCppuType());
200 	registerProperty(PROPERTY_CANUPDATEINSERTEDROWS,PROPERTY_ID_CANUPDATEINSERTEDROWS,	nRT,							&m_bCanUpdateInsertedRows,		::getBooleanCppuType());
201 	// sdbc.ResultSet Properties
202 	registerProperty(PROPERTY_RESULTSETCONCURRENCY,	PROPERTY_ID_RESULTSETCONCURRENCY,	PropertyAttribute::TRANSIENT,	&m_nResultSetConcurrency,::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
203 	registerProperty(PROPERTY_RESULTSETTYPE,		PROPERTY_ID_RESULTSETTYPE,			PropertyAttribute::TRANSIENT,	&m_nResultSetType,		::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
204 	registerProperty(PROPERTY_FETCHDIRECTION,		PROPERTY_ID_FETCHDIRECTION,			PropertyAttribute::TRANSIENT,	&m_nFetchDirection,		::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
205 	registerProperty(PROPERTY_FETCHSIZE,			PROPERTY_ID_FETCHSIZE,				PropertyAttribute::TRANSIENT,	&m_nFetchSize,			::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
206 
207 	// sdbc.RowSet Properties
208 	registerProperty(PROPERTY_URL,					PROPERTY_ID_URL,					0,								&m_aURL,				::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
209 	registerProperty(PROPERTY_TRANSACTIONISOLATION,	PROPERTY_ID_TRANSACTIONISOLATION,	PropertyAttribute::TRANSIENT,	&m_nTransactionIsolation,::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
210 	registerMayBeVoidProperty(PROPERTY_TYPEMAP,		PROPERTY_ID_TYPEMAP,				PropertyAttribute::MAYBEVOID|PropertyAttribute::TRANSIENT,	&m_aTypeMap,			::getCppuType(reinterpret_cast< Reference< XNameAccess >* >(NULL)));
211 	registerProperty(PROPERTY_ESCAPE_PROCESSING,PROPERTY_ID_ESCAPE_PROCESSING,	PropertyAttribute::BOUND,       &m_bUseEscapeProcessing,::getBooleanCppuType()	);
212 	registerProperty(PROPERTY_QUERYTIMEOUT,			PROPERTY_ID_QUERYTIMEOUT,			PropertyAttribute::TRANSIENT,	&m_nQueryTimeOut,		::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
213 	registerProperty(PROPERTY_MAXFIELDSIZE,			PROPERTY_ID_MAXFIELDSIZE,			PropertyAttribute::TRANSIENT,	&m_nMaxFieldSize,		::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
214 	registerProperty(PROPERTY_MAXROWS,				PROPERTY_ID_MAXROWS,				0,								&m_nMaxRows,			::getCppuType(reinterpret_cast< sal_Int32*>(NULL)) );
215 	registerProperty(PROPERTY_USER,					PROPERTY_ID_USER,					PropertyAttribute::TRANSIENT,	&m_aUser,				::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
216 	registerProperty(PROPERTY_PASSWORD,				PROPERTY_ID_PASSWORD,				PropertyAttribute::TRANSIENT,	&m_aPassword,			::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
217 
218 	registerProperty(PROPERTY_UPDATE_CATALOGNAME,	PROPERTY_ID_UPDATE_CATALOGNAME,		PropertyAttribute::BOUND,		&m_aUpdateCatalogName,	::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
219 	registerProperty(PROPERTY_UPDATE_SCHEMANAME,	PROPERTY_ID_UPDATE_SCHEMANAME,		PropertyAttribute::BOUND,		&m_aUpdateSchemaName,	::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
220 	registerProperty(PROPERTY_UPDATE_TABLENAME,		PROPERTY_ID_UPDATE_TABLENAME,		PropertyAttribute::BOUND,		&m_aUpdateTableName,	::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
221 }
222 
223 ORowSet::~ORowSet()
224 {
225 	if ( !m_rBHelper.bDisposed && !m_rBHelper.bInDispose )
226 	{
227 		OSL_ENSURE(0, "Please check who doesn't dispose this component!");
228 		osl_incrementInterlockedCount( &m_refCount );
229 		dispose();
230 	}
231 }
232 
233 // -----------------------------------------------------------------------------
234 void ORowSet::getPropertyDefaultByHandle( sal_Int32 _nHandle, Any& _rDefault ) const
235 {
236 	switch( _nHandle )
237 	{
238 		case PROPERTY_ID_COMMAND_TYPE:
239 			_rDefault <<= static_cast<sal_Int32>(CommandType::COMMAND);
240 			break;
241 		case PROPERTY_ID_IGNORERESULT:
242 			_rDefault <<= sal_False;
243 			break;
244 		case PROPERTY_ID_APPLYFILTER:
245 			_rDefault <<= sal_False;
246 			break;
247 		case PROPERTY_ID_ISMODIFIED:
248 			_rDefault <<= sal_False;
249 			break;
250 		case PROPERTY_ID_ISBOOKMARKABLE:
251 			_rDefault <<= sal_True;
252 			break;
253 		case PROPERTY_ID_CANUPDATEINSERTEDROWS:
254 			_rDefault <<= sal_True;
255 			break;
256 		case PROPERTY_ID_RESULTSETTYPE:
257 			_rDefault <<= ResultSetType::SCROLL_INSENSITIVE;
258 			break;
259 		case PROPERTY_ID_RESULTSETCONCURRENCY:
260 			_rDefault <<= ResultSetConcurrency::UPDATABLE;
261 			break;
262 		case PROPERTY_ID_FETCHDIRECTION:
263 			_rDefault <<= FetchDirection::FORWARD;
264 			break;
265 		case PROPERTY_ID_FETCHSIZE:
266 			_rDefault <<= static_cast<sal_Int32>(1);
267 			break;
268 		case PROPERTY_ID_ESCAPE_PROCESSING:
269 			_rDefault <<= sal_True;
270 			break;
271         case PROPERTY_ID_MAXROWS:
272             _rDefault <<= sal_Int32( 0 );
273             break;
274         case PROPERTY_ID_FILTER:
275         case PROPERTY_ID_HAVING_CLAUSE:
276         case PROPERTY_ID_GROUP_BY:
277         case PROPERTY_ID_ORDER:
278         case PROPERTY_ID_UPDATE_CATALOGNAME:
279         case PROPERTY_ID_UPDATE_SCHEMANAME:
280         case PROPERTY_ID_UPDATE_TABLENAME:
281             _rDefault <<= ::rtl::OUString();
282             break;
283 	}
284 }
285 // -------------------------------------------------------------------------
286 //	typedef ::comphelper::OPropertyArrayUsageHelper<ORowSet> ORowSet_Prop;
287 
288 void SAL_CALL ORowSet::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
289 {
290 	switch(nHandle)
291 	{
292 		case PROPERTY_ID_ISMODIFIED:
293 			m_bModified = cppu::any2bool(rValue);
294 			break;
295 		case PROPERTY_ID_FETCHDIRECTION:
296 			if( m_nResultSetType == ResultSetType::FORWARD_ONLY)
297 				throw Exception(); // else run through
298 		default:
299 			OPropertyStateContainer::setFastPropertyValue_NoBroadcast(nHandle,rValue);
300 	}
301 
302     if  (   ( nHandle == PROPERTY_ID_ACTIVE_CONNECTION )
303         ||  ( nHandle == PROPERTY_ID_DATASOURCENAME )
304         ||  ( nHandle == PROPERTY_ID_COMMAND )
305         ||  ( nHandle == PROPERTY_ID_COMMAND_TYPE )
306         ||  ( nHandle == PROPERTY_ID_IGNORERESULT )
307         ||  ( nHandle == PROPERTY_ID_FILTER )
308         ||  ( nHandle == PROPERTY_ID_HAVING_CLAUSE )
309         ||  ( nHandle == PROPERTY_ID_GROUP_BY )
310         ||  ( nHandle == PROPERTY_ID_APPLYFILTER )
311         ||  ( nHandle == PROPERTY_ID_ORDER )
312         ||  ( nHandle == PROPERTY_ID_URL )
313         ||  ( nHandle == PROPERTY_ID_USER )
314         )
315     {
316         m_bCommandFacetsDirty = sal_True;
317     }
318 
319 
320 	switch(nHandle)
321 	{
322 		case PROPERTY_ID_ACTIVE_CONNECTION:
323 			// the new connection
324 			{
325 				Reference< XConnection > xNewConnection(m_aActiveConnection,UNO_QUERY);
326 				setActiveConnection(xNewConnection, sal_False);
327 			}
328 
329 			m_bOwnConnection		= sal_False;
330 			m_bRebuildConnOnExecute = sal_False;
331 			break;
332 
333 		case PROPERTY_ID_DATASOURCENAME:
334 			if(!m_xStatement.is())
335 			{
336 				Reference< XConnection >  xNewConn;
337 				Any aNewConn;
338 				aNewConn <<= xNewConn;
339 				setFastPropertyValue(PROPERTY_ID_ACTIVE_CONNECTION, aNewConn);
340 			}
341 			else
342 				m_bRebuildConnOnExecute = sal_True;
343 			break;
344 		case PROPERTY_ID_FETCHSIZE:
345 			if(m_pCache)
346 			{
347 				m_pCache->setFetchSize(m_nFetchSize);
348 				fireRowcount();
349 			}
350 			break;
351 		case PROPERTY_ID_URL:
352 			// is the connection-to-be-built determined by the url (which is the case if m_aDataSourceName is empty) ?
353 			if (!m_aDataSourceName.getLength())
354 			{
355 				// are we active at the moment ?
356 				if (m_xStatement.is())
357 					// yes -> the next execute needs to rebuild our connection because of this new property
358 					m_bRebuildConnOnExecute = sal_True;
359 				else
360 				{	// no -> drop our active connection (if we have one) as it doesn't correspond to this new property value anymore
361 					Reference< XConnection >  xNewConn;
362 					Any aNewConn;
363 					aNewConn <<= xNewConn;
364 					setFastPropertyValue(PROPERTY_ID_ACTIVE_CONNECTION, aNewConn);
365 				}
366 			}
367 			m_bOwnConnection = sal_True;
368 			break;
369 		case PROPERTY_ID_TYPEMAP:
370 			::cppu::extractInterface(m_xTypeMap,m_aTypeMap);
371 			break;
372 		default:
373 			break;
374 	};
375 }
376 // -------------------------------------------------------------------------
377 void SAL_CALL ORowSet::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
378 {
379 	if(m_pCache)
380 	{
381 		switch(nHandle)
382 		{
383 		case PROPERTY_ID_ISMODIFIED:
384 			rValue.setValue(&m_bModified,::getCppuBooleanType());
385 			break;
386 		case PROPERTY_ID_ISNEW:
387 			rValue.setValue(&m_bNew,::getCppuBooleanType());
388 			break;
389 		case PROPERTY_ID_PRIVILEGES:
390 			rValue <<= m_pCache->m_nPrivileges;
391 			break;
392 		case PROPERTY_ID_ACTIVE_CONNECTION:
393 			rValue <<= m_xActiveConnection;
394 			break;
395 		case PROPERTY_ID_TYPEMAP:
396 			rValue <<= m_xTypeMap;
397 			break;
398 		default:
399 			ORowSetBase::getFastPropertyValue(rValue,nHandle);
400 		};
401 	}
402 	else
403 	{
404 		switch(nHandle)
405 		{
406 			case PROPERTY_ID_ACTIVE_CONNECTION:
407 				rValue <<= m_xActiveConnection;
408 				break;
409 			case PROPERTY_ID_TYPEMAP:
410 				rValue <<= m_xTypeMap;
411 				break;
412 			default:
413 				ORowSetBase::getFastPropertyValue(rValue,nHandle);
414 		}
415 	}
416 }
417 // -------------------------------------------------------------------------
418 // com::sun::star::XTypeProvider
419 Sequence< Type > SAL_CALL ORowSet::getTypes() throw (RuntimeException)
420 {
421 	OTypeCollection aTypes(::getCppuType( (const Reference< XPropertySet > *)0 ),
422 							::getCppuType( (const Reference< XFastPropertySet > *)0 ),
423 							::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
424 						   ::comphelper::concatSequences(ORowSet_BASE1::getTypes(),ORowSetBase::getTypes()));
425 	return aTypes.getTypes();
426 }
427 // -------------------------------------------------------------------------
428 Sequence< sal_Int8 > SAL_CALL ORowSet::getImplementationId() throw (RuntimeException)
429 {
430 	static OImplementationId * pId = 0;
431 	if (! pId)
432 	{
433 		MutexGuard aGuard( Mutex::getGlobalMutex() );
434 		if (! pId)
435 		{
436 			static OImplementationId aId;
437 			pId = &aId;
438 		}
439 	}
440 	return pId->getImplementationId();
441 }
442 // -------------------------------------------------------------------------
443 
444 // com::sun::star::XInterface
445 Any SAL_CALL ORowSet::queryInterface( const Type & rType ) throw (RuntimeException)
446 {
447 	return ORowSet_BASE1::queryInterface( rType);
448 }
449 // -------------------------------------------------------------------------
450 void SAL_CALL ORowSet::acquire() throw()
451 {
452 	ORowSet_BASE1::acquire();
453 }
454 // -------------------------------------------------------------------------
455 void SAL_CALL ORowSet::release() throw()
456 {
457 	ORowSet_BASE1::release();
458 }
459 // -------------------------------------------------------------------------
460 
461 // com::sun::star::XUnoTunnel
462 sal_Int64 SAL_CALL ORowSet::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException)
463 {
464 	if (rId.getLength() == 16 && 0 == rtl_compareMemory(getImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
465 		return reinterpret_cast<sal_Int64>(this);
466 
467 	return 0;
468 }
469 // -------------------------------------------------------------------------
470 // com::sun::star::XAggregation
471 Any SAL_CALL ORowSet::queryAggregation( const Type& rType ) throw(RuntimeException)
472 {
473 	Any aRet(ORowSetBase::queryInterface(rType));
474 	if (!aRet.hasValue())
475 		aRet = ORowSet_BASE1::queryAggregation(rType);
476 	return aRet;
477 }
478 //------------------------------------------------------------------------------
479 rtl::OUString ORowSet::getImplementationName_static(  ) throw(RuntimeException)
480 {
481 	return rtl::OUString::createFromAscii("com.sun.star.comp.dba.ORowSet");
482 }
483 // -------------------------------------------------------------------------
484 // ::com::sun::star::XServiceInfo
485 ::rtl::OUString SAL_CALL ORowSet::getImplementationName(  ) throw(RuntimeException)
486 {
487 	return getImplementationName_static();
488 }
489 // -------------------------------------------------------------------------
490 sal_Bool SAL_CALL ORowSet::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
491 {
492 	return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
493 }
494 //------------------------------------------------------------------------------
495 Sequence< ::rtl::OUString > ORowSet::getSupportedServiceNames_static(  ) throw (RuntimeException)
496 {
497 	Sequence< rtl::OUString > aSNS( 5 );
498 	aSNS[0] = SERVICE_SDBC_RESULTSET;
499 	aSNS[1] = SERVICE_SDBC_ROWSET;
500 	aSNS[2] = SERVICE_SDBCX_RESULTSET;
501 	aSNS[3] = SERVICE_SDB_RESULTSET;
502 	aSNS[4] = SERVICE_SDB_ROWSET;
503 	return aSNS;
504 }
505 // -------------------------------------------------------------------------
506 Sequence< ::rtl::OUString > SAL_CALL ORowSet::getSupportedServiceNames(  ) throw(RuntimeException)
507 {
508 	return getSupportedServiceNames_static();
509 }
510 //------------------------------------------------------------------------------
511 Reference< XInterface > ORowSet::Create(const Reference< XComponentContext >& _rxContext)
512 {
513     ::comphelper::ComponentContext aContext( _rxContext );
514 	return ORowSet_CreateInstance( aContext.getLegacyServiceFactory() );
515 }
516 // -------------------------------------------------------------------------
517 // OComponentHelper
518 void SAL_CALL ORowSet::disposing()
519 {
520 	OPropertyStateContainer::disposing();
521 
522 	MutexGuard aGuard(m_aMutex);
523 	EventObject aDisposeEvent;
524 	aDisposeEvent.Source = static_cast< XComponent* >(this);
525 	m_aRowsetListeners.disposeAndClear( aDisposeEvent );
526 	m_aApproveListeners.disposeAndClear( aDisposeEvent );
527     m_aRowsChangeListener.disposeAndClear( aDisposeEvent );
528 
529 	freeResources( true );
530 
531 	// remove myself as dispose listener
532 	Reference< XComponent >  xComponent(m_xActiveConnection, UNO_QUERY);
533 	if (xComponent.is())
534 	{
535 		Reference<XEventListener> xEvt;
536 		query_aggregation(this,xEvt);
537 		xComponent->removeEventListener(xEvt);
538 	}
539 
540 	m_aActiveConnection = Any(); // the any conatains a reference too
541 	if(m_bOwnConnection)
542 		::comphelper::disposeComponent(m_xActiveConnection);
543 	m_xActiveConnection = NULL;
544 
545 
546 	ORowSetBase::disposing();
547 }
548 // -------------------------------------------------------------------------
549 void ORowSet::freeResources( bool _bComplete )
550 {
551 	MutexGuard aGuard(m_aMutex);
552 
553 	// free all clones
554     connectivity::OWeakRefArray::iterator aEnd = m_aClones.end();
555 	for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); aEnd != i; i++)
556 	{
557 		Reference< XComponent > xComp(i->get(), UNO_QUERY);
558 		if (xComp.is())
559 			xComp->dispose();
560 	}
561 	m_aClones.clear();
562 
563     if ( _bComplete )
564 	{
565 		// the columns must be disposed before the querycomposer is disposed because
566 		// their owner can be the composer
567 		TDataColumns().swap(m_aDataColumns);// clear and resize capacity
568 		m_xColumns		= NULL;
569 		if ( m_pColumns )
570 			m_pColumns->disposing();
571 		// dispose the composer to avoid that everbody knows that the querycomposer is eol
572 		try { ::comphelper::disposeComponent( m_xComposer ); }
573 		catch(Exception&)
574 		{
575             DBG_UNHANDLED_EXCEPTION();
576 			m_xComposer = NULL;
577 		}
578 
579         // let our warnings container forget the reference to the (possibly disposed) old result set
580         m_aWarnings.setExternalWarnings( NULL );
581 
582 		DELETEZ(m_pCache);
583 
584         impl_resetTables_nothrow();
585 
586 		m_xStatement	= NULL;
587 		m_xTypeMap		= NULL;
588 
589 		m_aBookmark		= Any();
590 		m_bBeforeFirst	= sal_True;
591 		m_bAfterLast	= sal_False;
592 		m_bNew			= sal_False;
593 		m_bModified		= sal_False;
594 		m_bIsInsertRow	= sal_False;
595 		m_bLastKnownRowCountFinal = sal_False;
596         m_nLastKnownRowCount      = 0;
597 		if ( m_aOldRow.isValid() )
598 			m_aOldRow->clearRow();
599 
600         impl_disposeParametersContainer_nothrow();
601 
602         m_bCommandFacetsDirty = sal_True;
603 	}
604 }
605 
606 // -------------------------------------------------------------------------
607 void ORowSet::setActiveConnection( Reference< XConnection >& _rxNewConn, sal_Bool _bFireEvent )
608 {
609 	if (_rxNewConn.get() == m_xActiveConnection.get())
610 		// nothing to do
611 		return;
612 
613 	// remove the event listener for the old connection
614 	Reference< XComponent >  xComponent(m_xActiveConnection, UNO_QUERY);
615 	if (xComponent.is())
616 	{
617 		Reference<XEventListener> xListener;
618 		query_aggregation(this, xListener);
619 		xComponent->removeEventListener(xListener);
620 	}
621 
622 	// if we owned the connection, remember it for later disposing
623 	if(m_bOwnConnection)
624 		m_xOldConnection = m_xActiveConnection;
625 
626 	// for firing the PropertyChangeEvent
627 	sal_Int32 nHandle = PROPERTY_ID_ACTIVE_CONNECTION;
628 	Any aOldConnection; aOldConnection <<= m_xActiveConnection;
629 	Any aNewConnection; aNewConnection <<= _rxNewConn;
630 
631 	// set the new connection
632 	m_xActiveConnection = _rxNewConn;
633 	if (m_xActiveConnection.is())
634 		m_aActiveConnection <<= m_xActiveConnection;
635 	else
636 		m_aActiveConnection.clear();
637 
638 	// fire the event
639 	if (_bFireEvent)
640 		fire(&nHandle, &aNewConnection, &aOldConnection, 1, sal_False);
641 
642 	// register as event listener for the new connection
643 	xComponent.set(m_xActiveConnection,UNO_QUERY);
644 	if (xComponent.is())
645 	{
646 		Reference<XEventListener> xListener;
647 		query_aggregation(this, xListener);
648 		xComponent->addEventListener(xListener);
649 	}
650 }
651 
652 // -------------------------------------------------------------------------
653 // ::com::sun::star::XEventListener
654 void SAL_CALL ORowSet::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(RuntimeException)
655 {
656 	// close rowset because the connection is going to be deleted (someone told me :-)
657 	Reference<XConnection> xCon(Source.Source,UNO_QUERY);
658 	if(m_xActiveConnection == xCon)
659 	{
660 		close();
661 		{
662 			MutexGuard aGuard( m_aMutex );
663             Reference< XConnection > xXConnection;
664 			setActiveConnection( xXConnection );
665 		}
666 	}
667 }
668 // -------------------------------------------------------------------------
669 
670 // XCloseable
671 void SAL_CALL ORowSet::close(  ) throw(SQLException, RuntimeException)
672 {
673 	{
674 		MutexGuard aGuard( m_aMutex );
675 		::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
676 	}
677 	// additionals things to set
678 	freeResources( true );
679 }
680 // -------------------------------------------------------------------------
681 // comphelper::OPropertyArrayUsageHelper
682 ::cppu::IPropertyArrayHelper* ORowSet::createArrayHelper( ) const
683 {
684 	Sequence< Property > aProps;
685 	describeProperties(aProps);
686 	return new ::cppu::OPropertyArrayHelper(aProps);
687 }
688 // -------------------------------------------------------------------------
689 // cppu::OPropertySetHelper
690 ::cppu::IPropertyArrayHelper& SAL_CALL ORowSet::getInfoHelper()
691 {
692 	typedef ::comphelper::OPropertyArrayUsageHelper<ORowSet> ORowSet_PROP;
693 	return *ORowSet_PROP::getArrayHelper();
694 }
695 // -----------------------------------------------------------------------------
696 void ORowSet::updateValue(sal_Int32 columnIndex,const ORowSetValue& x)
697 {
698 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
699 
700 	::osl::MutexGuard aGuard( *m_pMutex );
701 	checkUpdateConditions(columnIndex);
702 	checkUpdateIterator();
703 
704     ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get());
705     ORowSetNotifier aNotify(this,rRow);
706     m_pCache->updateValue(columnIndex,x,rRow,aNotify.getChangedColumns());
707 	m_bModified = m_bModified || !aNotify.getChangedColumns().empty();
708     aNotify.firePropertyChange();
709 }
710 // -------------------------------------------------------------------------
711 // XRowUpdate
712 void SAL_CALL ORowSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
713 {
714 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
715 
716 	::osl::MutexGuard aGuard( *m_pMutex );
717 	checkUpdateConditions(columnIndex);
718 	checkUpdateIterator();
719 
720     ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get());
721     ORowSetNotifier aNotify(this,rRow);
722 	m_pCache->updateNull(columnIndex,rRow,aNotify.getChangedColumns());
723 	m_bModified = m_bModified || !aNotify.getChangedColumns().empty();
724     aNotify.firePropertyChange();
725 }
726 // -------------------------------------------------------------------------
727 void SAL_CALL ORowSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
728 {
729 	updateValue(columnIndex,x);
730 }
731 // -------------------------------------------------------------------------
732 void SAL_CALL ORowSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
733 {
734 	updateValue(columnIndex,x);
735 }
736 // -------------------------------------------------------------------------
737 void SAL_CALL ORowSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
738 {
739 	updateValue(columnIndex,x);
740 }
741 // -------------------------------------------------------------------------
742 void SAL_CALL ORowSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
743 {
744 	updateValue(columnIndex,x);
745 }
746 // -------------------------------------------------------------------------
747 void SAL_CALL ORowSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(SQLException, RuntimeException)
748 {
749 	updateValue(columnIndex,x);
750 }
751 // -------------------------------------------------------------------------
752 void SAL_CALL ORowSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException)
753 {
754 	updateValue(columnIndex,x);
755 }
756 // -------------------------------------------------------------------------
757 void SAL_CALL ORowSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException)
758 {
759 	updateValue(columnIndex,x);
760 }
761 // -------------------------------------------------------------------------
762 void SAL_CALL ORowSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
763 {
764 	updateValue(columnIndex,x);
765 }
766 // -------------------------------------------------------------------------
767 void SAL_CALL ORowSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
768 {
769 	updateValue(columnIndex,x);
770 }
771 // -------------------------------------------------------------------------
772 void SAL_CALL ORowSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException)
773 {
774 	updateValue(columnIndex,x);
775 }
776 // -------------------------------------------------------------------------
777 void SAL_CALL ORowSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException)
778 {
779 	updateValue(columnIndex,x);
780 }
781 // -------------------------------------------------------------------------
782 void SAL_CALL ORowSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException)
783 {
784 	updateValue(columnIndex,x);
785 }
786 // -------------------------------------------------------------------------
787 void SAL_CALL ORowSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
788 {
789 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
790 	::osl::MutexGuard aGuard( *m_pMutex );
791 	checkUpdateConditions(columnIndex);
792 	checkUpdateIterator();
793 
794 	//if(((*m_aCurrentRow)->get())[columnIndex].getTypeKind() == DataType::BLOB)
795 	//{
796  //       ::connectivity::ORowSetValue aOldValue = ((*m_aCurrentRow)->get())[columnIndex];
797 	//	m_pCache->updateBinaryStream(columnIndex,x,length);
798 	//	((*m_aCurrentRow)->get())[columnIndex] = makeAny(x);
799  //       ((*m_aCurrentRow)->get())[columnIndex].setTypeKind(DataType::BLOB);
800  //       firePropertyChange(columnIndex-1 ,aOldValue);
801 	//    fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False);
802 	//}
803 	//else
804 	{
805 		Sequence<sal_Int8> aSeq;
806 		if(x.is())
807 			x->readBytes(aSeq,length);
808 		updateValue(columnIndex,aSeq);
809 	}
810 }
811 // -------------------------------------------------------------------------
812 void SAL_CALL ORowSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
813 {
814 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
815 	::osl::MutexGuard aGuard( *m_pMutex );
816 	checkUpdateConditions(columnIndex);
817 	checkUpdateIterator();
818     ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get());
819     ORowSetNotifier aNotify(this,rRow);
820 	m_pCache->updateCharacterStream(columnIndex,x,length,rRow,aNotify.getChangedColumns());
821 	m_bModified = m_bModified || !aNotify.getChangedColumns().empty();
822     aNotify.firePropertyChange();
823 }
824 // -------------------------------------------------------------------------
825 void SAL_CALL ORowSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException)
826 {
827 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
828 	::osl::MutexGuard aGuard( *m_pMutex );
829 	checkUpdateConditions(columnIndex);
830 	checkUpdateIterator();
831 
832 	Any aNewValue = x;
833 
834 	if ( m_pColumns )
835 	{
836 		Reference<XPropertySet> xColumn(m_pColumns->getByIndex(columnIndex-1),UNO_QUERY);
837 		sal_Int32 nColType = 0;
838 		xColumn->getPropertyValue(PROPERTY_TYPE) >>= nColType;
839 		switch( nColType )
840 		{
841 			case DataType::DATE:
842 			case DataType::TIME:
843 			case DataType::TIMESTAMP:
844 			{
845 				double nValue = 0;
846 				if ( x >>= nValue )
847 				{
848 					if ( DataType::TIMESTAMP == nColType )
849 						aNewValue <<= dbtools::DBTypeConversion::toDateTime( nValue );
850 					else if ( DataType::DATE == nColType )
851 						aNewValue <<= dbtools::DBTypeConversion::toDate( nValue );
852 					else
853 						aNewValue <<= dbtools::DBTypeConversion::toTime( nValue );
854 				}
855 				break;
856 			}
857 		}
858 	}
859 
860 	if (!::dbtools::implUpdateObject(this, columnIndex, aNewValue))
861 	{	// there is no other updateXXX call which can handle the value in x
862         ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get());
863         ORowSetNotifier aNotify(this,rRow);
864 		m_pCache->updateObject(columnIndex,aNewValue,rRow,aNotify.getChangedColumns());
865 		m_bModified = m_bModified || !aNotify.getChangedColumns().empty();
866         aNotify.firePropertyChange();
867 	}
868 }
869 // -------------------------------------------------------------------------
870 void SAL_CALL ORowSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 scale ) throw(SQLException, RuntimeException)
871 {
872 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
873 	::osl::MutexGuard aGuard( *m_pMutex );
874 	checkUpdateConditions(columnIndex);
875 	checkUpdateIterator();
876     ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get());
877     ORowSetNotifier aNotify(this,rRow);
878 	m_pCache->updateNumericObject(columnIndex,x,scale,rRow,aNotify.getChangedColumns());
879 	m_bModified = m_bModified || !aNotify.getChangedColumns().empty();
880     aNotify.firePropertyChange();
881 }
882 // -------------------------------------------------------------------------
883 
884 // XResultSetUpdate
885 void SAL_CALL ORowSet::insertRow(  ) throw(SQLException, RuntimeException)
886 {
887 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
888 	// insertRow is not allowd when
889 	// standing not on the insert row nor
890 	// when the row isn't modified
891 	// or the concurency is read only
892 	::osl::ResettableMutexGuard aGuard( *m_pMutex );
893 
894 	if(!m_pCache || !m_bNew || !m_bModified || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
895 		throwFunctionSequenceException(*this);
896 
897 	// remember old value for fire
898 	sal_Bool bOld = m_bNew;
899 
900 	ORowSetRow aOldValues;
901 	if ( !m_aCurrentRow.isNull() )
902 		aOldValues = new ORowSetValueVector( m_aCurrentRow->getBody() );
903     Sequence<Any> aChangedBookmarks;
904 	RowsChangeEvent aEvt(*this,RowChangeAction::INSERT,1,aChangedBookmarks);
905 	notifyAllListenersRowBeforeChange(aGuard,aEvt);
906 
907     ::std::vector< Any > aBookmarks;
908 	sal_Bool bInserted = m_pCache->insertRow(aBookmarks);
909 
910     // make sure that our row is set to the new inserted row before clearing the insert flags in the cache
911     m_pCache->resetInsertRow(bInserted);
912 
913 	// notification order
914 	// - column values
915 	setCurrentRow( sal_False, sal_True, aOldValues, aGuard ); // we don't move here
916 
917     // read-only flag restored
918     impl_restoreDataColumnsWriteable_throw();
919 
920 	// - rowChanged
921 	notifyAllListenersRowChanged(aGuard,aEvt);
922 
923     if ( !aBookmarks.empty() )
924     {
925         RowsChangeEvent aUpEvt(*this,RowChangeAction::UPDATE,aBookmarks.size(),Sequence<Any>(&(*aBookmarks.begin()),aBookmarks.size()));
926         notifyAllListenersRowChanged(aGuard,aUpEvt);
927     }
928 
929 	// - IsModified
930 	if(!m_bModified)
931 		fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True);
932 	OSL_ENSURE( !m_bModified, "ORowSet::insertRow: just updated, but _still_ modified?" );
933 
934 	// - IsNew
935 	if(m_bNew != bOld)
936 		fireProperty(PROPERTY_ID_ISNEW,m_bNew,bOld);
937 
938 	// - RowCount/IsRowCountFinal
939 	fireRowcount();
940 }
941 // -------------------------------------------------------------------------
942 sal_Int32 SAL_CALL ORowSet::getRow(  ) throw(SQLException, RuntimeException)
943 {
944 	::osl::MutexGuard aGuard( *m_pMutex );
945 	checkCache();
946 
947 	// check if we are inserting a row
948 	return (m_pCache && isInsertRow()) ? 0 : ORowSetBase::getRow();
949 }
950 // -------------------------------------------------------------------------
951 void SAL_CALL ORowSet::updateRow(  ) throw(SQLException, RuntimeException)
952 {
953 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
954 	// not allowed when standing on insert row
955 	::osl::ResettableMutexGuard aGuard( *m_pMutex );
956 	if ( !m_pCache || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY || m_bNew || ((m_pCache->m_nPrivileges & Privilege::UPDATE ) != Privilege::UPDATE) )
957 		throwFunctionSequenceException(*this);
958 
959 
960 	if(m_bModified)
961 	{
962 		ORowSetRow aOldValues;
963 		if ( !m_aCurrentRow.isNull() )
964 			aOldValues = new ORowSetValueVector( m_aCurrentRow->getBody() );
965 
966         Sequence<Any> aChangedBookmarks;
967 		RowsChangeEvent aEvt(*this,RowChangeAction::UPDATE,1,aChangedBookmarks);
968 		notifyAllListenersRowBeforeChange(aGuard,aEvt);
969 
970         ::std::vector< Any > aBookmarks;
971         m_pCache->updateRow(m_aCurrentRow.operator ->(),aBookmarks);
972         if ( !aBookmarks.empty() )
973             aEvt.Bookmarks = Sequence<Any>(&(*aBookmarks.begin()),aBookmarks.size());
974         aEvt.Rows += aBookmarks.size();
975 		m_aBookmark		= m_pCache->getBookmark();
976 		m_aCurrentRow	= m_pCache->m_aMatrixIter;
977 		m_bIsInsertRow	= sal_False;
978         if ( m_pCache->m_aMatrixIter != m_pCache->getEnd() && (*m_pCache->m_aMatrixIter).isValid() )
979         {
980             if ( m_pCache->isResultSetChanged() )
981             {
982                 impl_rebuild_throw(aGuard);
983             }
984             else
985             {
986 		        m_aOldRow->setRow(new ORowSetValueVector(m_aCurrentRow->getBody()));
987 
988 		        // notification order
989 		        // - column values
990 		        ORowSetBase::firePropertyChange(aOldValues);
991             }
992             // - rowChanged
993 	        notifyAllListenersRowChanged(aGuard,aEvt);
994 
995 	        // - IsModified
996 	        if(!m_bModified)
997 		        fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True);
998 	        OSL_ENSURE( !m_bModified, "ORowSet::updateRow: just updated, but _still_ modified?" );
999 
1000             // - RowCount/IsRowCountFinal
1001 	        fireRowcount();
1002         }
1003         else if ( !m_bAfterLast ) // the update went rong
1004         {
1005             ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_UPDATE_FAILED ), SQL_INVALID_CURSOR_POSITION, *this );
1006         }
1007 	}
1008 }
1009 // -------------------------------------------------------------------------
1010 void SAL_CALL ORowSet::deleteRow(  ) throw(SQLException, RuntimeException)
1011 {
1012 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
1013 
1014 	::osl::ResettableMutexGuard aGuard( *m_pMutex );
1015     checkCache();
1016 
1017 	if ( m_bBeforeFirst || m_bAfterLast )
1018         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_DELETE_BEFORE_AFTER ), SQL_INVALID_CURSOR_POSITION, *this );
1019     if ( m_bNew )
1020         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_DELETE_INSERT_ROW ), SQL_INVALID_CURSOR_POSITION, *this );
1021     if  ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
1022         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_RESULT_IS_READONLY ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
1023     if ( ( m_pCache->m_nPrivileges & Privilege::DELETE ) != Privilege::DELETE )
1024         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_DELETE_PRIVILEGE ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
1025     if ( rowDeleted() )
1026         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
1027 
1028 	// this call position the cache indirect
1029     Any aBookmarkToDelete( m_aBookmark );
1030     positionCache( MOVE_NONE_REFRESH_ONLY );
1031     sal_Int32 nDeletePosition = m_pCache->getRow();
1032 
1033     notifyRowSetAndClonesRowDelete( aBookmarkToDelete );
1034 
1035 	ORowSetRow aOldValues;
1036 	if ( m_pCache->m_aMatrixIter != m_pCache->getEnd() && m_pCache->m_aMatrixIter->isValid() )
1037 		aOldValues = new ORowSetValueVector( m_pCache->m_aMatrixIter->getBody() );
1038 
1039     Sequence<Any> aChangedBookmarks;
1040 	RowsChangeEvent aEvt(*this,RowChangeAction::DELETE,1,aChangedBookmarks);
1041 	notifyAllListenersRowBeforeChange(aGuard,aEvt);
1042 
1043     m_pCache->deleteRow();
1044 	notifyRowSetAndClonesRowDeleted( aBookmarkToDelete, nDeletePosition );
1045 
1046 	ORowSetNotifier aNotifier( this );
1047 		// this will call cancelRowModification on the cache if necessary
1048 
1049 	// notification order
1050 	// - rowChanged
1051 	notifyAllListenersRowChanged(aGuard,aEvt);
1052 
1053 	// - IsModified
1054 	// - IsNew
1055 	aNotifier.fire( );
1056 
1057 	// - RowCount/IsRowCountFinal
1058 	fireRowcount();
1059 }
1060 
1061 // -------------------------------------------------------------------------
1062 void ORowSet::implCancelRowUpdates( sal_Bool _bNotifyModified ) SAL_THROW( ( SQLException, RuntimeException ) )
1063 {
1064 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
1065 
1066 	::osl::MutexGuard aGuard( *m_pMutex );
1067 	if ( m_bBeforeFirst || m_bAfterLast || rowDeleted() )
1068 		return; // nothing to do so return
1069 
1070     checkCache();
1071 	// cancelRowUpdates is not allowed when:
1072 	// - standing on the insert row
1073 	// - the concurrency is read only
1074     // - the current row is deleted
1075 	if ( m_bNew || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
1076 		throwFunctionSequenceException(*this);
1077 
1078 	positionCache( MOVE_NONE_REFRESH_ONLY );
1079 
1080 	ORowSetRow aOldValues;
1081 	if ( !m_bModified && _bNotifyModified && !m_aCurrentRow.isNull() )
1082 		aOldValues = new ORowSetValueVector( m_aCurrentRow->getBody() );
1083 
1084 	m_pCache->cancelRowUpdates();
1085 
1086 	m_aBookmark		= m_pCache->getBookmark();
1087 	m_aCurrentRow	= m_pCache->m_aMatrixIter;
1088 	m_bIsInsertRow	= sal_False;
1089 	m_aCurrentRow.setBookmark(m_aBookmark);
1090 
1091 	// notification order
1092 	// IsModified
1093 	if( !m_bModified && _bNotifyModified )
1094     {
1095         // - column values
1096 	    ORowSetBase::firePropertyChange(aOldValues);
1097 		fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True);
1098     }
1099 }
1100 
1101 // -------------------------------------------------------------------------
1102 void SAL_CALL ORowSet::cancelRowUpdates(  ) throw(SQLException, RuntimeException)
1103 {
1104 	implCancelRowUpdates( sal_True );
1105 }
1106 
1107 // -------------------------------------------------------------------------
1108 void SAL_CALL ORowSet::addRowSetListener( const Reference< XRowSetListener >& listener ) throw(RuntimeException)
1109 {
1110 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
1111 
1112 	::osl::MutexGuard aGuard( m_aColumnsMutex );
1113 	if(listener.is())
1114 		m_aRowsetListeners.addInterface(listener);
1115 }
1116 // -------------------------------------------------------------------------
1117 void SAL_CALL ORowSet::removeRowSetListener( const Reference< XRowSetListener >& listener ) throw(RuntimeException)
1118 {
1119 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
1120 
1121 	::osl::MutexGuard aGuard( m_aColumnsMutex );
1122 	if(listener.is())
1123 		m_aRowsetListeners.removeInterface(listener);
1124 }
1125 // -----------------------------------------------------------------------------
1126 void ORowSet::notifyAllListeners(::osl::ResettableMutexGuard& _rGuard)
1127 {
1128 	EventObject aEvt(*m_pMySelf);
1129 	_rGuard.clear();
1130     m_aRowsetListeners.notifyEach( &XRowSetListener::rowSetChanged, aEvt );
1131 	_rGuard.reset();
1132 }
1133 // -------------------------------------------------------------------------
1134 void ORowSet::notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& _rGuard)
1135 {
1136 	EventObject aEvt(*m_pMySelf);
1137 	_rGuard.clear();
1138     m_aRowsetListeners.notifyEach( &XRowSetListener::cursorMoved, aEvt );
1139 	_rGuard.reset();
1140 }
1141 // -------------------------------------------------------------------------
1142 void ORowSet::notifyAllListenersRowChanged(::osl::ResettableMutexGuard& _rGuard, const RowsChangeEvent& aEvt)
1143 {
1144 	_rGuard.clear();
1145     m_aRowsetListeners.notifyEach( &XRowSetListener::rowChanged, (EventObject)aEvt );
1146     m_aRowsChangeListener.notifyEach( &XRowsChangeListener::rowsChanged, aEvt );
1147 	_rGuard.reset();
1148 }
1149 // -------------------------------------------------------------------------
1150 sal_Bool ORowSet::notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard& _rGuard)
1151 {
1152 	EventObject aEvt(*m_pMySelf);
1153 	NOTIFY_LISTERNERS_CHECK(m_aApproveListeners,XRowSetApproveListener,approveCursorMove);
1154 	return bCheck;
1155 }
1156 // -------------------------------------------------------------------------
1157 void ORowSet::notifyAllListenersRowBeforeChange(::osl::ResettableMutexGuard& _rGuard,const RowChangeEvent &aEvt)
1158 {
1159 	NOTIFY_LISTERNERS_CHECK(m_aApproveListeners,XRowSetApproveListener,approveRowChange);
1160     if ( !bCheck )
1161         m_aErrors.raiseTypedException( sdb::ErrorCondition::ROW_SET_OPERATION_VETOED, *this, ::cppu::UnoType< RowSetVetoException >::get() );
1162 }
1163 // -------------------------------------------------------------------------
1164 void ORowSet::fireRowcount()
1165 {
1166     sal_Int32 nCurrentRowCount( impl_getRowCount() );
1167     sal_Bool bCurrentRowCountFinal( m_pCache->m_bRowCountFinal );
1168 
1169     if ( m_nLastKnownRowCount != nCurrentRowCount )
1170 	{
1171 		sal_Int32 nHandle = PROPERTY_ID_ROWCOUNT;
1172 		Any aNew,aOld;
1173 		aNew <<= nCurrentRowCount; aOld <<= m_nLastKnownRowCount;
1174 		fire(&nHandle,&aNew,&aOld,1,sal_False);
1175 		m_nLastKnownRowCount = nCurrentRowCount;
1176 	}
1177 	if ( !m_bLastKnownRowCountFinal && ( m_bLastKnownRowCountFinal != bCurrentRowCountFinal ) )
1178 	{
1179 		sal_Int32 nHandle = PROPERTY_ID_ISROWCOUNTFINAL;
1180 		Any aNew,aOld;
1181 		aNew <<= bCurrentRowCountFinal;
1182 		aOld <<= m_bLastKnownRowCountFinal;
1183 		fire(&nHandle,&aNew,&aOld,1,sal_False);
1184 		m_bLastKnownRowCountFinal = bCurrentRowCountFinal;
1185 	}
1186 }
1187 // -------------------------------------------------------------------------
1188 void SAL_CALL ORowSet::moveToInsertRow(  ) throw(SQLException, RuntimeException)
1189 {
1190 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
1191 
1192 	::osl::ResettableMutexGuard aGuard( *m_pMutex );
1193 	checkPositioningAllowed();
1194 	if ( ( m_pCache->m_nPrivileges & Privilege::INSERT ) != Privilege::INSERT )
1195         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_INSERT_PRIVILEGE ), SQL_GENERAL_ERROR, *this );
1196 
1197 	if ( notifyAllListenersCursorBeforeMove( aGuard ) )
1198 	{
1199 		// remember old value for fire
1200 		ORowSetRow aOldValues;
1201 		if ( rowDeleted() )
1202         {
1203 			positionCache( MOVE_FORWARD );
1204 		    m_pCache->next();
1205 			setCurrentRow( sal_True, sal_False, aOldValues, aGuard);
1206         }
1207         else
1208 			positionCache( MOVE_NONE_REFRESH_ONLY );
1209 
1210         // check before because the resultset could be empty
1211 		if  (   !m_bBeforeFirst
1212             &&  !m_bAfterLast
1213             &&  m_pCache->m_aMatrixIter != m_pCache->getEnd()
1214             &&  m_pCache->m_aMatrixIter->isValid()
1215             )
1216 			aOldValues = new ORowSetValueVector( m_pCache->m_aMatrixIter->getBody() );
1217 
1218 		const sal_Bool bNewState = m_bNew;
1219 		const sal_Bool bModState = m_bModified;
1220 
1221 		m_pCache->moveToInsertRow();
1222 		m_aCurrentRow = m_pCache->m_aInsertRow;
1223 		m_bIsInsertRow	= sal_True;
1224 
1225         // set read-only flag to false
1226         impl_setDataColumnsWriteable_throw();
1227 
1228 		// notification order
1229 		// - column values
1230 		ORowSetBase::firePropertyChange(aOldValues);
1231 
1232 		// - cursorMoved
1233 		notifyAllListenersCursorMoved(aGuard);
1234 
1235 		// - IsModified
1236 		if ( bModState != m_bModified )
1237 			fireProperty( PROPERTY_ID_ISMODIFIED, m_bModified, bModState );
1238 
1239 		// - IsNew
1240 		if ( bNewState != m_bNew )
1241 			fireProperty( PROPERTY_ID_ISNEW, m_bNew, bNewState );
1242 
1243         // - RowCount/IsRowCountFinal
1244 	    fireRowcount();
1245 	}
1246 }
1247 // -------------------------------------------------------------------------
1248 void ORowSet::impl_setDataColumnsWriteable_throw()
1249 {
1250     impl_restoreDataColumnsWriteable_throw();
1251     TDataColumns::iterator aIter = m_aDataColumns.begin();
1252     m_aReadOnlyDataColumns.resize(m_aDataColumns.size(),false);
1253     ::std::bit_vector::iterator aReadIter = m_aReadOnlyDataColumns.begin();
1254     for(;aIter != m_aDataColumns.end();++aIter,++aReadIter)
1255     {
1256         sal_Bool bReadOnly = sal_False;
1257         (*aIter)->getPropertyValue(PROPERTY_ISREADONLY) >>= bReadOnly;
1258         *aReadIter = bReadOnly;
1259 
1260         (*aIter)->setPropertyValue(PROPERTY_ISREADONLY,makeAny(sal_False));
1261     }
1262 }
1263 // -------------------------------------------------------------------------
1264 void ORowSet::impl_restoreDataColumnsWriteable_throw()
1265 {
1266     TDataColumns::iterator aIter = m_aDataColumns.begin();
1267     ::std::bit_vector::iterator aReadIter = m_aReadOnlyDataColumns.begin();
1268     for(;aReadIter != m_aReadOnlyDataColumns.end();++aIter,++aReadIter)
1269     {
1270         (*aIter)->setPropertyValue(PROPERTY_ISREADONLY,makeAny((sal_Bool)*aReadIter ));
1271     }
1272     m_aReadOnlyDataColumns.clear();
1273 }
1274 // -------------------------------------------------------------------------
1275 void SAL_CALL ORowSet::moveToCurrentRow(  ) throw(SQLException, RuntimeException)
1276 {
1277 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
1278 
1279 	::osl::ResettableMutexGuard aGuard( *m_pMutex );
1280 	checkPositioningAllowed();
1281 
1282     if ( !m_pCache->m_bNew && !m_bModified )
1283         // nothing to do if we're not on the insertion row, and not modified otherwise
1284         return;
1285 
1286     if ( rowDeleted() )
1287         // this would perhaps even justify a RuntimeException ....
1288         // if the current row is deleted, then no write access to this row should be possible. So,
1289         // m_bModified should be true. Also, as soon as somebody calls moveToInsertRow,
1290         // our current row should not be deleted anymore. So, we should not have survived the above
1291         // check "if ( !m_pCache->m_bNew && !m_bModified )"
1292         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
1293 
1294 	if ( notifyAllListenersCursorBeforeMove( aGuard ) )
1295 	{
1296         positionCache( MOVE_NONE_REFRESH_ONLY );
1297 
1298 		ORowSetNotifier aNotifier( this );
1299 
1300 		// notification order
1301 		// - cursorMoved
1302 		notifyAllListenersCursorMoved(aGuard);
1303 
1304 		// - IsModified
1305 		// - IsNew
1306 		aNotifier.fire();
1307 	}
1308 }
1309 // -------------------------------------------------------------------------
1310 // XRow
1311 sal_Bool SAL_CALL ORowSet::wasNull(  ) throw(SQLException, RuntimeException)
1312 {
1313 	::osl::MutexGuard aGuard( *m_pMutex );
1314 	checkCache();
1315 
1316 	return ( m_pCache && isInsertRow() ) ? ((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex].isNull() : ORowSetBase::wasNull();
1317 }
1318 // -----------------------------------------------------------------------------
1319 const ORowSetValue& ORowSet::getInsertValue(sal_Int32 columnIndex)
1320 {
1321 	checkCache();
1322 
1323 	if ( m_pCache && isInsertRow() )
1324 		return 	((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex = columnIndex];
1325 
1326 	return getValue(columnIndex);
1327 }
1328 // -------------------------------------------------------------------------
1329 ::rtl::OUString SAL_CALL ORowSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1330 {
1331 	::osl::MutexGuard aGuard( *m_pMutex );
1332 	return getInsertValue(columnIndex);
1333 }
1334 // -------------------------------------------------------------------------
1335 sal_Bool SAL_CALL ORowSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1336 {
1337 	::osl::MutexGuard aGuard( *m_pMutex );
1338 	return getInsertValue(columnIndex);
1339 }
1340 // -------------------------------------------------------------------------
1341 sal_Int8 SAL_CALL ORowSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1342 {
1343 	::osl::MutexGuard aGuard( *m_pMutex );
1344 	return getInsertValue(columnIndex);
1345 }
1346 // -------------------------------------------------------------------------
1347 sal_Int16 SAL_CALL ORowSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1348 {
1349 	::osl::MutexGuard aGuard( *m_pMutex );
1350 	return getInsertValue(columnIndex);
1351 }
1352 // -------------------------------------------------------------------------
1353 sal_Int32 SAL_CALL ORowSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1354 {
1355 	::osl::MutexGuard aGuard( *m_pMutex );
1356 	return getInsertValue(columnIndex);
1357 }
1358 // -------------------------------------------------------------------------
1359 sal_Int64 SAL_CALL ORowSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1360 {
1361 	::osl::MutexGuard aGuard( *m_pMutex );
1362 	return getInsertValue(columnIndex);
1363 }
1364 // -------------------------------------------------------------------------
1365 float SAL_CALL ORowSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1366 {
1367 	::osl::MutexGuard aGuard( *m_pMutex );
1368 	return getInsertValue(columnIndex);
1369 }
1370 // -------------------------------------------------------------------------
1371 double SAL_CALL ORowSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1372 {
1373 	::osl::MutexGuard aGuard( *m_pMutex );
1374 	return getInsertValue(columnIndex);
1375 }
1376 // -------------------------------------------------------------------------
1377 Sequence< sal_Int8 > SAL_CALL ORowSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1378 {
1379 	::osl::MutexGuard aGuard( *m_pMutex );
1380 	return getInsertValue(columnIndex);
1381 }
1382 // -------------------------------------------------------------------------
1383 ::com::sun::star::util::Date SAL_CALL ORowSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1384 {
1385 	::osl::MutexGuard aGuard( *m_pMutex );
1386 	return getInsertValue(columnIndex);
1387 }
1388 // -------------------------------------------------------------------------
1389 ::com::sun::star::util::Time SAL_CALL ORowSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1390 {
1391 	::osl::MutexGuard aGuard( *m_pMutex );
1392 	return getInsertValue(columnIndex);
1393 }
1394 // -------------------------------------------------------------------------
1395 ::com::sun::star::util::DateTime SAL_CALL ORowSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1396 {
1397 	::osl::MutexGuard aGuard( *m_pMutex );
1398 	return getInsertValue(columnIndex);
1399 }
1400 // -------------------------------------------------------------------------
1401 Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1402 {
1403 	::osl::MutexGuard aGuard( *m_pMutex );
1404 	if ( m_pCache && isInsertRow() )
1405 	{
1406 		checkCache();
1407 		return new ::comphelper::SequenceInputStream(((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex = columnIndex].getSequence());
1408 	}
1409 
1410 	return ORowSetBase::getBinaryStream(columnIndex);
1411 }
1412 // -------------------------------------------------------------------------
1413 Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1414 {
1415 	::osl::MutexGuard aGuard( *m_pMutex );
1416 	if(m_pCache && isInsertRow() )
1417 	{
1418 		checkCache();
1419 		return new ::comphelper::SequenceInputStream(((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex = columnIndex].getSequence());
1420 	}
1421 
1422 	return ORowSetBase::getCharacterStream(columnIndex);
1423 }
1424 // -------------------------------------------------------------------------
1425 Any SAL_CALL ORowSet::getObject( sal_Int32 columnIndex, const Reference< XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
1426 {
1427 	::osl::MutexGuard aGuard( *m_pMutex );
1428 	return getInsertValue(columnIndex).makeAny();
1429 }
1430 // -------------------------------------------------------------------------
1431 Reference< XRef > SAL_CALL ORowSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
1432 {
1433 	return Reference< XRef >();
1434 }
1435 // -------------------------------------------------------------------------
1436 Reference< XBlob > SAL_CALL ORowSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1437 {
1438     if ( m_pCache && isInsertRow() )
1439 	{
1440 		checkCache();
1441 		return new ::connectivity::BlobHelper(((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex = columnIndex].getSequence());
1442 	}
1443 	return ORowSetBase::getBlob(columnIndex);
1444 }
1445 // -------------------------------------------------------------------------
1446 Reference< XClob > SAL_CALL ORowSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1447 {
1448 	return Reference< XClob >(getInsertValue(columnIndex).makeAny(),UNO_QUERY);
1449 }
1450 // -------------------------------------------------------------------------
1451 Reference< XArray > SAL_CALL ORowSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
1452 {
1453 	return Reference< XArray >();
1454 }
1455 // -------------------------------------------------------------------------
1456 void SAL_CALL ORowSet::executeWithCompletion( const Reference< XInteractionHandler >& _rxHandler ) throw(SQLException, RuntimeException)
1457 {
1458 	if (!_rxHandler.is())
1459 		execute();
1460 
1461 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
1462 
1463 	// tell everybody that we will change the result set
1464 	approveExecution();
1465 
1466 	ResettableMutexGuard aGuard( m_aMutex );
1467 
1468 	try
1469 	{
1470         freeResources( m_bCommandFacetsDirty );
1471 
1472 		// calc the connection to be used
1473 		if (m_xActiveConnection.is() && m_bRebuildConnOnExecute)
1474         {
1475 			// there was a setProperty(ActiveConnection), but a setProperty(DataSource) _after_ that, too
1476             Reference< XConnection > xXConnection;
1477             setActiveConnection( xXConnection );
1478         }
1479 		calcConnection( _rxHandler );
1480 		m_bRebuildConnOnExecute = sal_False;
1481 
1482         Reference< XSingleSelectQueryComposer > xComposer = getCurrentSettingsComposer( this, m_aContext.getLegacyServiceFactory() );
1483         Reference<XParametersSupplier>  xParameters(xComposer, UNO_QUERY);
1484 
1485 	    Reference<XIndexAccess>  xParamsAsIndicies = xParameters.is() ? xParameters->getParameters() : Reference<XIndexAccess>();
1486 	    const sal_Int32 nParamCount = xParamsAsIndicies.is() ? xParamsAsIndicies->getCount() : 0;
1487         if ( m_aParametersSet.size() < (size_t)nParamCount )
1488 		    m_aParametersSet.resize( nParamCount ,false);
1489 
1490 		::dbtools::askForParameters( xComposer, this, m_xActiveConnection, _rxHandler,m_aParametersSet );
1491 	}
1492 	// ensure that only the allowed exceptions leave this block
1493 	catch(SQLException&)
1494 	{
1495 		throw;
1496 	}
1497 	catch(RuntimeException&)
1498 	{
1499 		throw;
1500 	}
1501 	catch(Exception&)
1502 	{
1503 		DBG_ERROR("ORowSet::executeWithCompletion: caught an unexpected exception type while filling in the parameters!");
1504 	}
1505 
1506 	// we're done with the parameters, now for the real execution
1507 
1508 	//  do the real execute
1509 	execute_NoApprove_NoNewConn(aGuard);
1510 }
1511 
1512 // -------------------------------------------------------------------------
1513 Reference< XIndexAccess > SAL_CALL ORowSet::getParameters(  ) throw (RuntimeException)
1514 {
1515 	::osl::MutexGuard aGuard( *m_pMutex );
1516 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
1517 
1518     if ( m_bCommandFacetsDirty )
1519         // need to rebuild the parameters, since some property which contributes to the
1520         // complete command, and thus the parameters, changed
1521         impl_disposeParametersContainer_nothrow();
1522 
1523     if ( !m_pParameters.get() && m_aCommand.getLength() )
1524     {
1525         try
1526         {
1527             ::rtl::OUString sNotInterestedIn;
1528             impl_initComposer_throw( sNotInterestedIn );
1529         }
1530         catch( const Exception& )
1531         {
1532         	// silence it
1533         }
1534     }
1535 
1536     return m_pParameters.get();
1537 }
1538 
1539 // -------------------------------------------------------------------------
1540 void ORowSet::approveExecution() throw (RowSetVetoException, RuntimeException)
1541 {
1542 	::osl::MutexGuard aGuard( m_aColumnsMutex );
1543 	EventObject aEvt(*this);
1544 
1545     OInterfaceIteratorHelper aApproveIter( m_aApproveListeners );
1546 	while ( aApproveIter.hasMoreElements() )
1547 	{
1548         Reference< XRowSetApproveListener > xListener( static_cast< XRowSetApproveListener* >( aApproveIter.next() ) );
1549         try
1550         {
1551             if ( xListener.is() && !xListener->approveRowSetChange( aEvt ) )
1552 			    throw RowSetVetoException();
1553         }
1554         catch ( const DisposedException& e )
1555         {
1556             if ( e.Context == xListener )
1557                 aApproveIter.remove();
1558         }
1559         catch ( const RuntimeException& ) { throw; }
1560         catch ( const RowSetVetoException& ) { throw; }
1561         catch ( const Exception& )
1562         {
1563         	DBG_UNHANDLED_EXCEPTION();
1564         }
1565 	}
1566 }
1567 // -------------------------------------------------------------------------
1568 // XRowSet
1569 // -------------------------------------------------------------------------
1570 void SAL_CALL ORowSet::execute(  ) throw(SQLException, RuntimeException)
1571 {
1572 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
1573 
1574 	// tell everybody that we will change the result set
1575 	approveExecution();
1576 
1577 	ResettableMutexGuard aGuard( m_aMutex );
1578 	freeResources( m_bCommandFacetsDirty );
1579 
1580 	// calc the connection to be used
1581 	if (m_xActiveConnection.is() && m_bRebuildConnOnExecute) {
1582 		// there was a setProperty(ActiveConnection), but a setProperty(DataSource) _after_ that, too
1583         Reference< XConnection> xXConnection;
1584 		setActiveConnection( xXConnection );
1585     }
1586 
1587 	calcConnection(NULL);
1588 	m_bRebuildConnOnExecute = sal_False;
1589 
1590 	// do the real execute
1591 	execute_NoApprove_NoNewConn(aGuard);
1592 }
1593 
1594 //------------------------------------------------------------------------------
1595 void ORowSet::setStatementResultSetType( const Reference< XPropertySet >& _rxStatement, sal_Int32 _nDesiredResultSetType, sal_Int32 _nDesiredResultSetConcurrency )
1596 {
1597     OSL_ENSURE( _rxStatement.is(), "ORowSet::setStatementResultSetType: invalid statement - this will crash!" );
1598 
1599     sal_Int32 nResultSetType( _nDesiredResultSetType );
1600     sal_Int32 nResultSetConcurrency( _nDesiredResultSetConcurrency );
1601 
1602     // there *might* be a data source setting which tells use to be more defensive with those settings
1603     // #i15113# / 2005-02-10 / frank.schoenheit@sun.com
1604     sal_Bool bRespectDriverRST = sal_False;
1605     Any aSetting;
1606     if ( getDataSourceSetting( ::dbaccess::getDataSource( m_xActiveConnection ), "RespectDriverResultSetType", aSetting ) )
1607     {
1608         OSL_VERIFY( aSetting >>= bRespectDriverRST );
1609     }
1610 
1611     if ( bRespectDriverRST )
1612     {
1613         // try type/concurrency settings with decreasing usefullness, and rely on what the connection claims
1614         // to support
1615         Reference< XDatabaseMetaData > xMeta( m_xActiveConnection->getMetaData() );
1616 
1617         sal_Int32 nCharacteristics[5][2] =
1618         {   { ResultSetType::SCROLL_SENSITIVE, ResultSetConcurrency::UPDATABLE },
1619             { ResultSetType::SCROLL_INSENSITIVE, ResultSetConcurrency::UPDATABLE },
1620             { ResultSetType::SCROLL_SENSITIVE, ResultSetConcurrency::READ_ONLY },
1621             { ResultSetType::SCROLL_INSENSITIVE, ResultSetConcurrency::READ_ONLY },
1622             { ResultSetType::FORWARD_ONLY, ResultSetConcurrency::READ_ONLY }
1623         };
1624         sal_Int32 i=0;
1625         if ( m_xActiveConnection->getMetaData()->isReadOnly() )
1626             i = 2; // if the database is read-only we only should use read-only concurrency
1627 
1628         for ( ; i<5; ++i )
1629         {
1630 			nResultSetType = nCharacteristics[i][0];
1631 			nResultSetConcurrency = nCharacteristics[i][1];
1632 
1633             // don't try type/concurrency pairs which are more featured than what our caller requested
1634             if ( nResultSetType > _nDesiredResultSetType )
1635                 continue;
1636             if ( nResultSetConcurrency > _nDesiredResultSetConcurrency )
1637                 continue;
1638 
1639             if ( xMeta.is() && xMeta->supportsResultSetConcurrency( nResultSetType, nResultSetConcurrency ) )
1640                 break;
1641         }
1642     }
1643 
1644 	_rxStatement->setPropertyValue( PROPERTY_RESULTSETTYPE, makeAny( nResultSetType ) );
1645     _rxStatement->setPropertyValue( PROPERTY_RESULTSETCONCURRENCY, makeAny( nResultSetConcurrency ) );
1646 }
1647 
1648 // -----------------------------------------------------------------------------
1649 Reference< XResultSet > ORowSet::impl_prepareAndExecute_throw()
1650 {
1651     ::rtl::OUString sCommandToExecute;
1652     sal_Bool bUseEscapeProcessing = impl_initComposer_throw( sCommandToExecute );
1653 
1654     Reference< XResultSet> xResultSet;
1655     try
1656     {
1657         m_xStatement = m_xActiveConnection->prepareStatement( sCommandToExecute );
1658         if ( !m_xStatement.is() )
1659 		{
1660             ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INTERNAL_ERROR ), SQL_GENERAL_ERROR, *this );
1661 		}
1662 
1663 		Reference< XPropertySet > xStatementProps( m_xStatement, UNO_QUERY_THROW );
1664         // set the result set type and concurrency
1665         try
1666 		{
1667             xStatementProps->setPropertyValue( PROPERTY_USEBOOKMARKS, makeAny( sal_True ) );
1668             xStatementProps->setPropertyValue( PROPERTY_MAXROWS, makeAny( m_nMaxRows ) );
1669 
1670             setStatementResultSetType( xStatementProps, m_nResultSetType, m_nResultSetConcurrency );
1671 		}
1672 		catch ( const Exception& )
1673 		{
1674 			// this exception doesn't matter here because when we catch an exception
1675 			// then the driver doesn't support this feature
1676 		}
1677         m_aParameterValueForCache.get().resize(1);
1678 		Reference< XParameters > xParam( m_xStatement, UNO_QUERY_THROW );
1679         size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues.get().size() );
1680         for ( size_t i=1; i<=nParamCount; ++i )
1681         {
1682             ORowSetValue& rParamValue( getParameterStorage( (sal_Int32)i ) );
1683             ::dbtools::setObjectWithInfo( xParam, i, rParamValue.makeAny(), rParamValue.getTypeKind() );
1684             m_aParameterValueForCache.get().push_back(rParamValue);
1685         }
1686 
1687 		xResultSet = m_xStatement->executeQuery();
1688     }
1689     catch( const SQLException& )
1690     {
1691         SQLExceptionInfo aError( ::cppu::getCaughtException() );
1692         OSL_ENSURE( aError.isValid(), "ORowSet::impl_prepareAndExecute_throw: caught an SQLException which we cannot analyze!" );
1693 
1694         // append information about what we were actually going to execute
1695         try
1696         {
1697             String sQuery = bUseEscapeProcessing && m_xComposer.is() ? m_xComposer->getQuery() : m_aActiveCommand;
1698             String sInfo( DBA_RES_PARAM( RID_STR_COMMAND_LEADING_TO_ERROR, "$command$", sQuery ) );
1699             aError.append( SQLExceptionInfo::SQL_CONTEXT, sInfo );
1700         }
1701         catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
1702 
1703         // propagate
1704         aError.doThrow();
1705     }
1706 
1707     return xResultSet;
1708 }
1709 
1710 // -----------------------------------------------------------------------------
1711 void ORowSet::impl_initializeColumnSettings_nothrow( const Reference< XPropertySet >& _rxTemplateColumn, const Reference< XPropertySet >& _rxRowSetColumn )
1712 {
1713     OSL_ENSURE( _rxTemplateColumn.is() && _rxRowSetColumn.is(),
1714         "ORowSet::impl_initializeColumnSettings_nothrow: this will crash!" );
1715 
1716     bool bHaveAnyColumnSetting = false;
1717 	try
1718 	{
1719         Reference< XPropertySetInfo > xInfo( _rxTemplateColumn->getPropertySetInfo(), UNO_QUERY_THROW );
1720 
1721         // a number of properties is plain copied
1722         const ::rtl::OUString aPropertyNames[] = {
1723             PROPERTY_ALIGN, PROPERTY_RELATIVEPOSITION, PROPERTY_WIDTH, PROPERTY_HIDDEN, PROPERTY_CONTROLMODEL,
1724             PROPERTY_HELPTEXT, PROPERTY_CONTROLDEFAULT
1725         };
1726         for ( size_t i=0; i<sizeof( aPropertyNames ) / sizeof( aPropertyNames[0] ); ++i )
1727         {
1728 			if ( xInfo->hasPropertyByName( aPropertyNames[i] ) )
1729             {
1730 				_rxRowSetColumn->setPropertyValue( aPropertyNames[i], _rxTemplateColumn->getPropertyValue( aPropertyNames[i] ) );
1731                 bHaveAnyColumnSetting = true;
1732             }
1733         }
1734 
1735         // the format key is slightly more complex
1736 		sal_Int32 nFormatKey = 0;
1737 		if( xInfo->hasPropertyByName( PROPERTY_NUMBERFORMAT ) )
1738         {
1739 			_rxTemplateColumn->getPropertyValue( PROPERTY_NUMBERFORMAT ) >>= nFormatKey;
1740             bHaveAnyColumnSetting = true;
1741         }
1742 		if ( !nFormatKey && m_xNumberFormatTypes.is() )
1743 			nFormatKey = ::dbtools::getDefaultNumberFormat( _rxTemplateColumn, m_xNumberFormatTypes, SvtSysLocale().GetLocaleData().getLocale() );
1744 		_rxRowSetColumn->setPropertyValue( PROPERTY_NUMBERFORMAT, makeAny( nFormatKey ) );
1745 	}
1746 	catch(Exception&)
1747 	{
1748         DBG_UNHANDLED_EXCEPTION();
1749         return;
1750 	}
1751 
1752     if ( bHaveAnyColumnSetting )
1753         return;
1754 
1755     // the template column could not provide *any* setting. Okay, probably it's a parser column, which
1756     // does not offer those. However, perhaps the template column referes to a table column, which we
1757     // can use as new template column
1758     try
1759     {
1760         Reference< XPropertySetInfo > xInfo( _rxTemplateColumn->getPropertySetInfo(), UNO_QUERY_THROW );
1761         if ( !xInfo->hasPropertyByName( PROPERTY_TABLENAME ) )
1762             // no chance
1763             return;
1764 
1765         ::rtl::OUString sTableName;
1766         OSL_VERIFY( _rxTemplateColumn->getPropertyValue( PROPERTY_TABLENAME ) >>= sTableName );
1767 
1768         Reference< XNameAccess > xTables( impl_getTables_throw(), UNO_QUERY_THROW );
1769         if ( !xTables->hasByName( sTableName ) )
1770             // no chance
1771             return;
1772 
1773         Reference< XColumnsSupplier > xTableColSup( xTables->getByName( sTableName ), UNO_QUERY_THROW );
1774         Reference< XNameAccess > xTableCols( xTableColSup->getColumns(), UNO_QUERY_THROW );
1775 
1776         ::rtl::OUString sTableColumnName;
1777 
1778         // get the "Name" or (preferred) "RealName" property of the column
1779         ::rtl::OUString sNamePropertyName( PROPERTY_NAME );
1780         if ( xInfo->hasPropertyByName( PROPERTY_REALNAME ) )
1781             sNamePropertyName = PROPERTY_REALNAME;
1782         OSL_VERIFY( _rxTemplateColumn->getPropertyValue( sNamePropertyName ) >>= sTableColumnName );
1783 
1784         if ( !xTableCols->hasByName( sTableColumnName ) )
1785             return;
1786 
1787         Reference< XPropertySet > xTableColumn( xTableCols->getByName( sTableColumnName ), UNO_QUERY_THROW );
1788         impl_initializeColumnSettings_nothrow( xTableColumn, _rxRowSetColumn );
1789     }
1790     catch( const Exception& )
1791     {
1792     	DBG_UNHANDLED_EXCEPTION();
1793     }
1794 }
1795 
1796 // -----------------------------------------------------------------------------
1797 void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotification)
1798 {
1799 	RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "frank.schoenheit@sun.com", "ORowSet::execute_NoApprove_NoNewConn" );
1800 
1801 	// now we can dispose our old connection
1802 	::comphelper::disposeComponent(m_xOldConnection);
1803 	m_xOldConnection = NULL;
1804 
1805 	// do we need a new statement
1806 	if ( m_bCommandFacetsDirty )
1807 	{
1808 		m_xStatement	= NULL;
1809 		m_xComposer		= NULL;
1810 
1811         Reference< XResultSet > xResultSet( impl_prepareAndExecute_throw() );
1812 
1813         // let our warnings container forget the reference to the (possibly disposed) old result set
1814         m_aWarnings.setExternalWarnings( NULL );
1815         // clear all current warnings
1816         m_aWarnings.clearWarnings();
1817         // let the warnings container know about the new "external warnings"
1818         m_aWarnings.setExternalWarnings( Reference< XWarningsSupplier >( xResultSet, UNO_QUERY ) );
1819 
1820 		::rtl::OUString aComposedUpdateTableName;
1821 		if ( m_aUpdateTableName.getLength() )
1822 			aComposedUpdateTableName = composeTableName( m_xActiveConnection->getMetaData(), m_aUpdateCatalogName, m_aUpdateSchemaName, m_aUpdateTableName, sal_False, ::dbtools::eInDataManipulation );
1823 
1824         {
1825             RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "frank.schoenheit@sun.com", "ORowSet::execute_NoApprove_NoNewConn: creating cache" );
1826             m_pCache = new ORowSetCache( xResultSet, m_xComposer.get(), m_aContext, aComposedUpdateTableName, m_bModified, m_bNew,m_aParameterValueForCache,m_aFilter,m_nMaxRows );
1827             if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
1828             {
1829                 m_nPrivileges = Privilege::SELECT;
1830                 m_pCache->m_nPrivileges = Privilege::SELECT;
1831             }
1832             m_pCache->setFetchSize(m_nFetchSize);
1833             m_aCurrentRow	= m_pCache->createIterator(this);
1834 			m_bIsInsertRow	= sal_False;
1835             m_aOldRow       = m_pCache->registerOldRow();
1836         }
1837 
1838 		// get the locale
1839 		//	ConfigManager*	pConfigMgr = ConfigManager::GetConfigManager();
1840 		Locale aLocale = SvtSysLocale().GetLocaleData().getLocale();
1841 		//	pConfigMgr->GetDirectConfigProperty(ConfigManager::LOCALE) >>= aLocale;
1842 
1843 		// get the numberformatTypes
1844 		OSL_ENSURE(m_xActiveConnection.is(),"No ActiveConnection");
1845 		Reference< XNumberFormatTypes> xNumberFormatTypes;
1846 		Reference< XNumberFormatsSupplier> xNumberFormat = ::dbtools::getNumberFormats(m_xActiveConnection);
1847 		if ( xNumberFormat.is() )
1848 			m_xNumberFormatTypes.set(xNumberFormat->getNumberFormats(),UNO_QUERY);
1849 
1850 		::vos::ORef< ::connectivity::OSQLColumns> aColumns = new ::connectivity::OSQLColumns();
1851 		::std::vector< ::rtl::OUString> aNames;
1852 		::rtl::OUString aDescription;
1853 		sal_Int32 nFormatKey = 0;
1854 
1855         const ::std::map<sal_Int32,sal_Int32>& rKeyColumns = m_pCache->getKeyColumns();
1856 		if(!m_xColumns.is())
1857 		{
1858             RTL_LOGFILE_CONTEXT_AUTHOR( aColumnCreateLog, "dbaccess", "frank.schoenheit@sun.com", "ORowSet::execute_NoApprove_NoNewConn::creating columns" );
1859 			// use the meta data
1860 			Reference<XResultSetMetaDataSupplier> xMetaSup(m_xStatement,UNO_QUERY);
1861 			try
1862 			{
1863 				Reference<XResultSetMetaData> xMetaData = xMetaSup->getMetaData();
1864 				if ( xMetaData.is() )
1865 				{
1866 					sal_Int32 nCount = xMetaData->getColumnCount();
1867 					m_aDataColumns.reserve(nCount+1);
1868 					aColumns->get().reserve(nCount+1);
1869 					DECLARE_STL_USTRINGACCESS_MAP(int,StringMap);
1870 					StringMap aColumnMap;
1871 					for (sal_Int32 i = 0 ; i < nCount; ++i)
1872 					{
1873 						// retrieve the name of the column
1874 						::rtl::OUString sName = xMetaData->getColumnName(i + 1);
1875 						// check for duplicate entries
1876 						if(aColumnMap.find(sName) != aColumnMap.end())
1877 						{
1878 							::rtl::OUString sAlias(sName);
1879 							sal_Int32 searchIndex=1;
1880 							while(aColumnMap.find(sAlias) != aColumnMap.end())
1881 							{
1882                                 (sAlias = sName) += ::rtl::OUString::valueOf(searchIndex++);
1883 							}
1884 							sName = sAlias;
1885 						}
1886 						ORowSetDataColumn* pColumn = new ORowSetDataColumn(	getMetaData(),
1887 																			this,
1888 																			this,
1889 																			i+1,
1890                                                                             m_xActiveConnection->getMetaData(),
1891 																			aDescription,
1892                                                                             ::rtl::OUString(),
1893 																			m_aCurrentRow);
1894 						aColumnMap.insert(StringMap::value_type(sName,0));
1895 						aColumns->get().push_back(pColumn);
1896 						pColumn->setName(sName);
1897 						aNames.push_back(sName);
1898 						m_aDataColumns.push_back(pColumn);
1899 
1900                         pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,makeAny(rKeyColumns.find(i+1) != rKeyColumns.end()));
1901 
1902 						try
1903 						{
1904 							nFormatKey = 0;
1905 							if(m_xNumberFormatTypes.is())
1906 								nFormatKey = ::dbtools::getDefaultNumberFormat(pColumn,m_xNumberFormatTypes,aLocale);
1907 
1908 
1909 							pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey));
1910 							pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,makeAny(sal_Int32(i+1)));
1911 							pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,makeAny(sal_Int32(227)));
1912 							pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,makeAny((sal_Int32)0));
1913 							pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HIDDEN,::cppu::bool2any(sal_False));
1914 						}
1915 						catch(Exception&)
1916 						{
1917 						}
1918 					}
1919 				}
1920 			}
1921 			catch (SQLException&)
1922 			{
1923 			}
1924 		}
1925 		else
1926 		{
1927 			// create the rowset columns
1928 			Reference< XResultSetMetaData > xMeta( getMetaData(), UNO_QUERY_THROW );
1929 			sal_Int32 nCount = xMeta->getColumnCount();
1930 			m_aDataColumns.reserve(nCount+1);
1931 			aColumns->get().reserve(nCount+1);
1932 			::std::set< Reference< XPropertySet > > aAllColumns;
1933 
1934 			for(sal_Int32 i=1; i <= nCount ;++i)
1935 			{
1936 				::rtl::OUString sName = xMeta->getColumnName(i);
1937                 ::rtl::OUString sColumnLabel = xMeta->getColumnLabel(i);
1938 
1939                 // retrieve the column number |i|
1940 				Reference<XPropertySet> xColumn;
1941                 {
1942 				    sal_Bool bReFetchName = sal_False;
1943                     if (m_xColumns->hasByName(sColumnLabel))
1944 					    m_xColumns->getByName(sColumnLabel) >>= xColumn;
1945 				    if (!xColumn.is() && m_xColumns->hasByName(sName))
1946 					    m_xColumns->getByName(sName) >>= xColumn;
1947 
1948 				    // check if column already in the list we need another
1949 				    if ( aAllColumns.find( xColumn ) != aAllColumns.end() )
1950 				    {
1951 					    xColumn = NULL;
1952 					    bReFetchName = sal_True;
1953                         sColumnLabel = ::rtl::OUString();
1954 				    }
1955 				    if(!xColumn.is())
1956 				    {
1957 					    // no column found so we could look at the position i
1958                         //bReFetchName = sal_True;
1959                         //sColumnLabel = ::rtl::OUString();
1960 					    Reference<XIndexAccess> xIndexAccess(m_xColumns,UNO_QUERY);
1961 					    if(xIndexAccess.is() && i <= xIndexAccess->getCount())
1962 					    {
1963 						    xIndexAccess->getByIndex(i-1) >>= xColumn;
1964 					    }
1965 					    else
1966 					    {
1967 						    Sequence< ::rtl::OUString> aSeq = m_xColumns->getElementNames();
1968 						    if( i <= aSeq.getLength())
1969                             {
1970 							    m_xColumns->getByName(aSeq.getConstArray()[i-1]) >>= xColumn;
1971                             }
1972 					    }
1973 				    }
1974 				    if(bReFetchName && xColumn.is())
1975 					    xColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
1976 				    aAllColumns.insert( xColumn );
1977                 }
1978 
1979                 // create a RowSetDataColumn
1980                 {
1981 				    Reference<XPropertySetInfo> xInfo = xColumn.is() ? xColumn->getPropertySetInfo() : Reference<XPropertySetInfo>();
1982 				    if(xInfo.is() && xInfo->hasPropertyByName(PROPERTY_DESCRIPTION))
1983 					    aDescription = comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION));
1984 
1985                     ::rtl::OUString sParseLabel;
1986                     if ( xColumn.is() )
1987                     {
1988                         xColumn->getPropertyValue(PROPERTY_LABEL) >>= sParseLabel;
1989                     }
1990 				    ORowSetDataColumn* pColumn = new ORowSetDataColumn(	getMetaData(),
1991 																	    this,
1992 																	    this,
1993 																	    i,
1994                                                                         m_xActiveConnection->getMetaData(),
1995 																	    aDescription,
1996                                                                         sParseLabel,
1997 																	    m_aCurrentRow);
1998 				    aColumns->get().push_back(pColumn);
1999 
2000                     pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,makeAny(rKeyColumns.find(i) != rKeyColumns.end()));
2001 
2002 				    if(!sColumnLabel.getLength())
2003 				    {
2004 					    if(xColumn.is())
2005 						    xColumn->getPropertyValue(PROPERTY_NAME) >>= sColumnLabel;
2006 					    else
2007 						    sColumnLabel = DBACORE_RESSTRING( RID_STR_EXPRESSION1 );
2008 				    }
2009 				    pColumn->setName(sColumnLabel);
2010 				    aNames.push_back(sColumnLabel);
2011 				    m_aDataColumns.push_back(pColumn);
2012 
2013                     if ( xColumn.is() )
2014                         impl_initializeColumnSettings_nothrow( xColumn, pColumn );
2015                 }
2016 			}
2017 		}
2018 		// now create the columns we need
2019 		if(m_pColumns)
2020 			m_pColumns->assign(aColumns,aNames);
2021 		else
2022 		{
2023 			Reference<XDatabaseMetaData> xMeta = m_xActiveConnection->getMetaData();
2024 			m_pColumns = new ORowSetDataColumns(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(),
2025 												aColumns,*this,m_aColumnsMutex,aNames);
2026 		}
2027 	}
2028 	checkCache();
2029 	// notify the rowset listeners
2030 	notifyAllListeners(_rClearForNotification);
2031 }
2032 // -------------------------------------------------------------------------
2033 // XRowSetApproveBroadcaster
2034 void SAL_CALL ORowSet::addRowSetApproveListener( const Reference< XRowSetApproveListener >& listener ) throw(RuntimeException)
2035 {
2036 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
2037 
2038 	::osl::MutexGuard aGuard( m_aColumnsMutex );
2039 
2040 	m_aApproveListeners.addInterface(listener);
2041 }
2042 // -------------------------------------------------------------------------
2043 void SAL_CALL ORowSet::removeRowSetApproveListener( const Reference< XRowSetApproveListener >& listener ) throw(RuntimeException)
2044 {
2045 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
2046 
2047 	::osl::MutexGuard aGuard( m_aColumnsMutex );
2048 
2049 	m_aApproveListeners.removeInterface(listener);
2050 }
2051 // XRowsChangeBroadcaster
2052 void SAL_CALL ORowSet::addRowsChangeListener( const Reference< XRowsChangeListener >& listener ) throw(RuntimeException)
2053 {
2054 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
2055 
2056 	::osl::MutexGuard aGuard( m_aColumnsMutex );
2057 
2058 	m_aRowsChangeListener.addInterface(listener);
2059 }
2060 // -------------------------------------------------------------------------
2061 void SAL_CALL ORowSet::removeRowsChangeListener( const Reference< XRowsChangeListener >& listener ) throw(RuntimeException)
2062 {
2063 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
2064 
2065 	::osl::MutexGuard aGuard( m_aColumnsMutex );
2066 
2067 	m_aRowsChangeListener.removeInterface(listener);
2068 }
2069 // -------------------------------------------------------------------------
2070 
2071 // XResultSetAccess
2072 Reference< XResultSet > SAL_CALL ORowSet::createResultSet(  ) throw(SQLException, RuntimeException)
2073 {
2074 	::osl::MutexGuard aGuard( m_aColumnsMutex );
2075 
2076 	if(m_xStatement.is())
2077 	{
2078 		ORowSetClone* pClone = new ORowSetClone( m_aContext, *this, m_pMutex );
2079 		Reference< XResultSet > xRet(pClone);
2080 		m_aClones.push_back(WeakReferenceHelper(xRet));
2081 		return xRet;
2082 	}
2083 	return Reference< XResultSet >();
2084 }
2085 // -------------------------------------------------------------------------
2086 
2087 // ::com::sun::star::util::XCancellable
2088 void SAL_CALL ORowSet::cancel(  ) throw(RuntimeException)
2089 {
2090 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
2091 }
2092 // -------------------------------------------------------------------------
2093 
2094 // ::com::sun::star::sdbcx::XDeleteRows
2095 Sequence< sal_Int32 > SAL_CALL ORowSet::deleteRows( const Sequence< Any >& rows ) throw(SQLException, RuntimeException)
2096 {
2097 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
2098 
2099 	if(!m_pCache || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
2100 		throwFunctionSequenceException(*this);
2101 
2102 	::osl::ResettableMutexGuard aGuard( *m_pMutex );
2103 
2104     Sequence<Any> aChangedBookmarks;
2105 	RowsChangeEvent aEvt(*this,RowChangeAction::DELETE,rows.getLength(),aChangedBookmarks);
2106 	// notify the rowset listeners
2107 	notifyAllListenersRowBeforeChange(aGuard,aEvt);
2108 
2109     Sequence< sal_Int32 > aResults( rows.getLength() );
2110     const Any* row = rows.getConstArray();
2111     const Any* rowEnd = rows.getConstArray() + rows.getLength();
2112     sal_Int32* result = aResults.getArray();
2113     for ( ; row != rowEnd; ++row, ++result )
2114     {
2115         *result = 0;
2116         if ( !m_pCache->moveToBookmark( *row ) )
2117             continue;
2118         sal_Int32 nDeletePosition = m_pCache->getRow();
2119 
2120         // first notify the clones so that they can save their position
2121 		notifyRowSetAndClonesRowDelete( *row );
2122 
2123         // now delete the row
2124         if ( !m_pCache->deleteRow() )
2125             continue;
2126         *result = 1;
2127         // now notify that we have deleted
2128 		notifyRowSetAndClonesRowDeleted( *row, nDeletePosition );
2129     }
2130 	aEvt.Rows = aResults.getLength();
2131 
2132 	// we have to check if we stand on the insert row and if so we have to reset it
2133 	ORowSetNotifier aNotifier( this );
2134 		// this will call cancelRowModification on the cache if necessary
2135 	// notification order
2136 	// - rowChanged
2137 	notifyAllListenersRowChanged(aGuard,aEvt);
2138 
2139 	// - IsModified
2140 	// - IsNew
2141 	aNotifier.fire();
2142 
2143 	// - RowCount/IsRowCountFinal
2144 	fireRowcount();
2145 
2146     return aResults;
2147 }
2148 // -----------------------------------------------------------------------------
2149 void ORowSet::notifyRowSetAndClonesRowDelete( const Any& _rBookmark )
2150 {
2151     // notify ourself
2152     onDeleteRow( _rBookmark );
2153     // notify the clones
2154     connectivity::OWeakRefArray::iterator aEnd = m_aClones.end();
2155 	for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); aEnd != i; i++)
2156 	{
2157 		Reference< XUnoTunnel > xTunnel(i->get(),UNO_QUERY);
2158 		if(xTunnel.is())
2159 		{
2160 			ORowSetClone* pClone = reinterpret_cast<ORowSetClone*>(xTunnel->getSomething(ORowSetClone::getUnoTunnelImplementationId()));
2161 			if(pClone)
2162 				pClone->onDeleteRow( _rBookmark );
2163 		}
2164 	}
2165 }
2166 //------------------------------------------------------------------------------
2167 void ORowSet::notifyRowSetAndClonesRowDeleted( const Any& _rBookmark, sal_Int32 _nPos )
2168 {
2169     // notify ourself
2170     onDeletedRow( _rBookmark, _nPos );
2171     // notify the clones
2172     connectivity::OWeakRefArray::iterator aEnd = m_aClones.end();
2173 	for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); aEnd != i; i++)
2174 	{
2175 		Reference< XUnoTunnel > xTunnel(i->get(),UNO_QUERY);
2176 		if(xTunnel.is())
2177 		{
2178 			ORowSetClone* pClone = reinterpret_cast<ORowSetClone*>(xTunnel->getSomething(ORowSetClone::getUnoTunnelImplementationId()));
2179 			if(pClone)
2180 				pClone->onDeletedRow( _rBookmark, _nPos );
2181 		}
2182 	}
2183 }
2184 //------------------------------------------------------------------------------
2185 Reference< XConnection >  ORowSet::calcConnection(const Reference< XInteractionHandler >& _rxHandler) throw( SQLException, RuntimeException )
2186 {
2187 	MutexGuard aGuard(m_aMutex);
2188 	if (!m_xActiveConnection.is())
2189 	{
2190 		Reference< XConnection > xNewConn;
2191 		if ( m_aDataSourceName.getLength() )
2192 		{
2193             Reference< XNameAccess > xDatabaseContext(
2194                 m_aContext.createComponent( (::rtl::OUString)SERVICE_SDB_DATABASECONTEXT ),
2195                 UNO_QUERY_THROW );
2196             try
2197             {
2198                 Reference< XDataSource > xDataSource( xDatabaseContext->getByName( m_aDataSourceName ), UNO_QUERY_THROW );
2199 
2200                 // try connecting with the interaction handler
2201                 Reference< XCompletedConnection > xComplConn( xDataSource, UNO_QUERY );
2202                 if ( _rxHandler.is() && xComplConn.is() )
2203                 {
2204                     xNewConn = xComplConn->connectWithCompletion( _rxHandler );
2205                 }
2206                 else
2207                 {
2208                     xNewConn = xDataSource->getConnection( m_aUser, m_aPassword );
2209                 }
2210             }
2211             catch ( const SQLException& e )
2212             {
2213                 throw;
2214             }
2215             catch ( const Exception& e )
2216             {
2217                 Any aError = ::cppu::getCaughtException();
2218                 ::rtl::OUString sMessage = ResourceManager::loadString( RID_NO_SUCH_DATA_SOURCE,
2219                     "$name$", m_aDataSourceName, "$error$", extractExceptionMessage( m_aContext, aError ) );
2220                 ::dbtools::throwGenericSQLException( sMessage, *this );
2221             }
2222         }
2223 		setActiveConnection(xNewConn);
2224 		m_bOwnConnection = sal_True;
2225 	}
2226 	return m_xActiveConnection;
2227 }
2228 //------------------------------------------------------------------------------
2229 Reference< XNameAccess > ORowSet::impl_getTables_throw()
2230 {
2231     Reference< XNameAccess > xTables;
2232 
2233 	Reference< XTablesSupplier >  xTablesAccess( m_xActiveConnection, UNO_QUERY );
2234 	if ( xTablesAccess.is() )
2235 	{
2236 		xTables.set( xTablesAccess->getTables(), UNO_QUERY_THROW );
2237 	}
2238 	else if ( m_pTables )
2239     {
2240         xTables = m_pTables;
2241     }
2242     else
2243 	{
2244 		if ( !m_xActiveConnection.is() )
2245             throw SQLException(DBA_RES(RID_STR_CONNECTION_INVALID),*this,SQLSTATE_GENERAL,1000,Any() );
2246 
2247         sal_Bool bCase = sal_True;
2248 		try
2249 		{
2250 			Reference<XDatabaseMetaData> xMeta = m_xActiveConnection->getMetaData();
2251 			bCase = xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers();
2252 		}
2253 		catch(SQLException&)
2254 		{
2255             DBG_UNHANDLED_EXCEPTION();
2256 		}
2257 
2258         m_pTables = new OTableContainer(*this,m_aMutex,m_xActiveConnection,bCase,NULL,NULL,NULL,m_nInAppend);
2259 		xTables = m_pTables;
2260 		Sequence< ::rtl::OUString> aTableFilter(1);
2261 		aTableFilter[0] = ::rtl::OUString::createFromAscii("%");
2262 		m_pTables->construct(aTableFilter,Sequence< ::rtl::OUString>());
2263 	}
2264 
2265     return xTables;
2266 }
2267 
2268 //------------------------------------------------------------------------------
2269 void ORowSet::impl_resetTables_nothrow()
2270 {
2271     if ( !m_pTables )
2272         return;
2273 
2274     try
2275     {
2276 		m_pTables->dispose();
2277     }
2278     catch( const Exception& )
2279     {
2280     	DBG_UNHANDLED_EXCEPTION();
2281     }
2282 
2283     DELETEZ( m_pTables );
2284 }
2285 
2286 //------------------------------------------------------------------------------
2287 sal_Bool ORowSet::impl_initComposer_throw( ::rtl::OUString& _out_rCommandToExecute )
2288 {
2289 	sal_Bool bUseEscapeProcessing = impl_buildActiveCommand_throw( );
2290     _out_rCommandToExecute = m_aActiveCommand;
2291     if ( !bUseEscapeProcessing )
2292         return bUseEscapeProcessing;
2293 
2294 	Reference< XMultiServiceFactory > xFactory( m_xActiveConnection, UNO_QUERY );
2295     if ( xFactory.is() )
2296     {
2297 	    try
2298 	    {
2299             ::comphelper::disposeComponent( m_xComposer );
2300 		    m_xComposer.set( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW );
2301 	    }
2302 	    catch (const Exception& ) { m_xComposer = NULL; }
2303     }
2304 	if ( !m_xComposer.is() )
2305 		m_xComposer = new OSingleSelectQueryComposer( impl_getTables_throw(), m_xActiveConnection, m_aContext );
2306 
2307 	m_xComposer->setCommand( m_aCommand,m_nCommandType );
2308     m_aActiveCommand = m_xComposer->getQuery();
2309 
2310     m_xComposer->setFilter( m_bApplyFilter ? m_aFilter : ::rtl::OUString() );
2311     m_xComposer->setHavingClause( m_bApplyFilter ? m_aHavingClause : ::rtl::OUString() );
2312 
2313     if ( m_bIgnoreResult )
2314     {   // append a "0=1" filter
2315         // don't simply overwrite an existent filter, this would lead to problems if this existent
2316         // filter contains paramters (since a keyset may add parameters itself)
2317         // 2003-12-12 - #23418# - fs@openoffice.org
2318         m_xComposer->setElementaryQuery( m_xComposer->getQuery( ) );
2319         m_xComposer->setFilter( ::rtl::OUString::createFromAscii( "0 = 1" ) );
2320     }
2321 
2322 	m_xComposer->setOrder( m_aOrder );
2323 	m_xComposer->setGroup( m_aGroupBy );
2324 
2325     if ( !m_xColumns.is() )
2326     {
2327 	    Reference< XColumnsSupplier > xCols( m_xComposer, UNO_QUERY_THROW );
2328 	    m_xColumns = xCols->getColumns();
2329     }
2330 
2331     impl_initParametersContainer_nothrow();
2332 
2333     _out_rCommandToExecute = m_xComposer->getQueryWithSubstitution();
2334 
2335     return bUseEscapeProcessing;
2336 }
2337 
2338 //------------------------------------------------------------------------------
2339 sal_Bool ORowSet::impl_buildActiveCommand_throw()
2340 {
2341 	// create the sql command
2342 	// from a table name or get the command out of a query (not a view)
2343 	// the last use the command as it is
2344 	sal_Bool bDoEscapeProcessing = m_bUseEscapeProcessing;
2345 
2346     m_aActiveCommand = ::rtl::OUString();
2347     ::rtl::OUString sCommand;
2348 
2349 	if ( !m_aCommand.getLength() )
2350         return bDoEscapeProcessing;
2351 
2352 	switch (m_nCommandType)
2353 	{
2354 		case CommandType::TABLE:
2355 		{
2356             impl_resetTables_nothrow();
2357             if ( bDoEscapeProcessing )
2358             {
2359                 Reference< XNameAccess > xTables( impl_getTables_throw() );
2360                 if ( xTables->hasByName(m_aCommand) )
2361 			    {
2362 /*
2363 				    Reference< XPropertySet > xTable;
2364 				    try
2365 				    {
2366                         xTables->getByName( m_aCommand ) >>= xTable;
2367 				    }
2368 				    catch(const WrappedTargetException& e)
2369 				    {
2370 					    SQLException e2;
2371 					    if ( e.TargetException >>= e2 )
2372 						    throw e2;
2373 				    }
2374 				    catch(Exception&)
2375 				    {
2376                         DBG_UNHANDLED_EXCEPTION();
2377 				    }
2378 
2379 				    Reference<XColumnsSupplier> xSup(xTable,UNO_QUERY);
2380 				    if ( xSup.is() )
2381 					    m_xColumns = xSup->getColumns();
2382 
2383 				    sCommand = rtl::OUString::createFromAscii("SELECT * FROM ");
2384 				    ::rtl::OUString sCatalog, sSchema, sTable;
2385 				    ::dbtools::qualifiedNameComponents( m_xActiveConnection->getMetaData(), m_aCommand, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation );
2386 				    sCommand += ::dbtools::composeTableNameForSelect( m_xActiveConnection, sCatalog, sSchema, sTable );
2387 */
2388 			    }
2389 			    else
2390 			    {
2391                     String sMessage( DBACORE_RESSTRING( RID_STR_TABLE_DOES_NOT_EXIST ) );
2392                     sMessage.SearchAndReplaceAscii( "$table$", m_aCommand );
2393                     throwGenericSQLException(sMessage,*this);
2394 			    }
2395             }
2396             else
2397             {
2398                 sCommand = rtl::OUString::createFromAscii("SELECT * FROM ");
2399 			    ::rtl::OUString sCatalog, sSchema, sTable;
2400 			    ::dbtools::qualifiedNameComponents( m_xActiveConnection->getMetaData(), m_aCommand, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation );
2401 			    sCommand += ::dbtools::composeTableNameForSelect( m_xActiveConnection, sCatalog, sSchema, sTable );
2402             }
2403 		}
2404         break;
2405 
2406 		case CommandType::QUERY:
2407 		{
2408 			Reference< XQueriesSupplier >  xQueriesAccess(m_xActiveConnection, UNO_QUERY);
2409 			if (xQueriesAccess.is())
2410 			{
2411 				Reference< ::com::sun::star::container::XNameAccess >  xQueries(xQueriesAccess->getQueries());
2412 				if (xQueries->hasByName(m_aCommand))
2413 				{
2414 					Reference< XPropertySet > xQuery(xQueries->getByName(m_aCommand),UNO_QUERY);
2415 					OSL_ENSURE(xQuery.is(),"ORowSet::impl_buildActiveCommand_throw: Query is NULL!");
2416 					if ( xQuery.is() )
2417 					{
2418 						xQuery->getPropertyValue(PROPERTY_COMMAND) >>= sCommand;
2419                         xQuery->getPropertyValue(PROPERTY_ESCAPE_PROCESSING) >>= bDoEscapeProcessing;
2420                         if ( bDoEscapeProcessing != m_bUseEscapeProcessing )
2421                         {
2422                             sal_Bool bOldValue = m_bUseEscapeProcessing;
2423                             m_bUseEscapeProcessing = bDoEscapeProcessing;
2424                             fireProperty(PROPERTY_ID_ESCAPE_PROCESSING,bOldValue,bDoEscapeProcessing);
2425                         }
2426 
2427 						::rtl::OUString aCatalog,aSchema,aTable;
2428 						xQuery->getPropertyValue(PROPERTY_UPDATE_CATALOGNAME)	>>= aCatalog;
2429 						xQuery->getPropertyValue(PROPERTY_UPDATE_SCHEMANAME)	>>= aSchema;
2430 						xQuery->getPropertyValue(PROPERTY_UPDATE_TABLENAME)		>>= aTable;
2431 						if(aTable.getLength())
2432 							m_aUpdateTableName = composeTableName( m_xActiveConnection->getMetaData(), aCatalog, aSchema, aTable, sal_False, ::dbtools::eInDataManipulation );
2433 /*
2434 						Reference<XColumnsSupplier> xSup(xQuery,UNO_QUERY);
2435 						if(xSup.is())
2436 							m_xColumns = xSup->getColumns();
2437 */
2438 					}
2439 				}
2440 				else
2441 				{
2442                     String sMessage( DBACORE_RESSTRING( RID_STR_QUERY_DOES_NOT_EXIST ) );
2443                     sMessage.SearchAndReplaceAscii( "$table$", m_aCommand );
2444                     throwGenericSQLException(sMessage,*this);
2445 				}
2446 			}
2447 			else
2448 				throw SQLException(DBA_RES(RID_STR_NO_XQUERIESSUPPLIER),*this,::rtl::OUString(),0,Any());
2449 		}
2450         break;
2451 
2452         default:
2453 			sCommand = m_aCommand;
2454             break;
2455 	}
2456 
2457     m_aActiveCommand = sCommand;
2458 
2459     if ( !m_aActiveCommand.getLength() && !bDoEscapeProcessing )
2460         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_SQL_COMMAND ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
2461 
2462     return bDoEscapeProcessing;
2463 }
2464 
2465 //------------------------------------------------------------------------------
2466 void ORowSet::impl_initParametersContainer_nothrow()
2467 {
2468     OSL_PRECOND( !m_pParameters.is(), "ORowSet::impl_initParametersContainer_nothrow: already initialized the parameters!" );
2469 
2470     m_pParameters = new param::ParameterWrapperContainer( m_xComposer.get() );
2471     // copy the premature parameters into the final ones
2472     size_t nParamCount( ::std::min( m_pParameters->size(), m_aPrematureParamValues.get().size() ) );
2473     for ( size_t i=0; i<nParamCount; ++i )
2474     {
2475         (*m_pParameters)[i] = m_aPrematureParamValues.get()[i];
2476     }
2477 }
2478 
2479 //------------------------------------------------------------------------------
2480 void ORowSet::impl_disposeParametersContainer_nothrow()
2481 {
2482     if ( !m_pParameters.is() )
2483         return;
2484 
2485     // copy the actual values to our "premature" ones, to preserve them for later use
2486     size_t nParamCount( m_pParameters->size() );
2487     m_aPrematureParamValues.get().resize( nParamCount );
2488     for ( size_t i=0; i<nParamCount; ++i )
2489     {
2490         m_aPrematureParamValues.get()[i] = (*m_pParameters)[i];
2491     }
2492 
2493     m_pParameters->dispose();
2494     m_pParameters = NULL;
2495 }
2496 
2497 // -----------------------------------------------------------------------------
2498 ORowSetValue& ORowSet::getParameterStorage(sal_Int32 parameterIndex)
2499 {
2500 	::connectivity::checkDisposed( ORowSet_BASE1::rBHelper.bDisposed );
2501 	if ( parameterIndex < 1 )
2502 		throwInvalidIndexException( *this );
2503 
2504     if ( m_aParametersSet.size() < (size_t)parameterIndex )
2505 		m_aParametersSet.resize( parameterIndex ,false);
2506     m_aParametersSet[parameterIndex - 1] = true;
2507 
2508     if ( m_aParametersSet.size() < (size_t)parameterIndex )
2509 		m_aParametersSet.resize( parameterIndex ,false);
2510     m_aParametersSet[parameterIndex - 1] = true;
2511 
2512     if ( m_pParameters.is() )
2513     {
2514 		if ( m_bCommandFacetsDirty )
2515         // need to rebuild the parameters, since some property which contributes to the
2516         // complete command, and thus the parameters, changed
2517 			impl_disposeParametersContainer_nothrow();
2518 		if ( m_pParameters.is() )
2519 		{
2520 			if ( (size_t)parameterIndex > m_pParameters->size() )
2521 				throwInvalidIndexException( *this );
2522 			return (*m_pParameters)[ parameterIndex - 1 ];
2523 		}
2524     }
2525 
2526     if ( m_aPrematureParamValues.get().size() < (size_t)parameterIndex )
2527 		m_aPrematureParamValues.get().resize( parameterIndex );
2528     return m_aPrematureParamValues.get()[ parameterIndex - 1 ];
2529 }
2530 // -------------------------------------------------------------------------
2531 // XParameters
2532 void SAL_CALL ORowSet::setNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/ ) throw(SQLException, RuntimeException)
2533 {
2534 	::osl::MutexGuard aGuard( m_aColumnsMutex );
2535 
2536     getParameterStorage( parameterIndex ).setNull();
2537 }
2538 // -------------------------------------------------------------------------
2539 void SAL_CALL ORowSet::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException)
2540 {
2541     setNull( parameterIndex, sqlType );
2542 }
2543 // -----------------------------------------------------------------------------
2544 void ORowSet::setParameter(sal_Int32 parameterIndex, const ORowSetValue& x)
2545 {
2546 	::osl::MutexGuard aGuard( m_aColumnsMutex );
2547 
2548     getParameterStorage( parameterIndex ) = x;
2549 }
2550 
2551 // -------------------------------------------------------------------------
2552 void SAL_CALL ORowSet::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException)
2553 {
2554 	setParameter(parameterIndex,x);
2555 }
2556 // -------------------------------------------------------------------------
2557 void SAL_CALL ORowSet::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
2558 {
2559 	setParameter(parameterIndex,x);
2560 }
2561 // -------------------------------------------------------------------------
2562 void SAL_CALL ORowSet::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
2563 {
2564 	setParameter(parameterIndex,x);
2565 }
2566 // -------------------------------------------------------------------------
2567 void SAL_CALL ORowSet::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
2568 {
2569 	setParameter(parameterIndex,x);
2570 }
2571 // -------------------------------------------------------------------------
2572 void SAL_CALL ORowSet::setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(SQLException, RuntimeException)
2573 {
2574 	setParameter(parameterIndex,x);
2575 }
2576 // -------------------------------------------------------------------------
2577 void SAL_CALL ORowSet::setFloat( sal_Int32 parameterIndex, float x ) throw(SQLException, RuntimeException)
2578 {
2579 	setParameter(parameterIndex,x);
2580 }
2581 // -------------------------------------------------------------------------
2582 void SAL_CALL ORowSet::setDouble( sal_Int32 parameterIndex, double x ) throw(SQLException, RuntimeException)
2583 {
2584 	setParameter(parameterIndex,x);
2585 }
2586 // -------------------------------------------------------------------------
2587 void SAL_CALL ORowSet::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
2588 {
2589 	setParameter(parameterIndex,x);
2590 }
2591 // -------------------------------------------------------------------------
2592 void SAL_CALL ORowSet::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
2593 {
2594 	setParameter(parameterIndex,x);
2595 }
2596 // -------------------------------------------------------------------------
2597 void SAL_CALL ORowSet::setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException)
2598 {
2599 	setParameter(parameterIndex,x);
2600 }
2601 // -------------------------------------------------------------------------
2602 void SAL_CALL ORowSet::setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException)
2603 {
2604 	setParameter(parameterIndex,x);
2605 }
2606 // -------------------------------------------------------------------------
2607 void SAL_CALL ORowSet::setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException)
2608 {
2609 	setParameter(parameterIndex,x);
2610 }
2611 // -------------------------------------------------------------------------
2612 void SAL_CALL ORowSet::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
2613 {
2614 	::osl::MutexGuard aGuard( m_aColumnsMutex );
2615     ORowSetValue& rParamValue( getParameterStorage( parameterIndex ) );
2616 
2617     try
2618 	{
2619 		Sequence <sal_Int8> aData;
2620 		x->readBytes(aData, length);
2621 		rParamValue = aData;
2622 		x->closeInput();
2623 	}
2624 	catch( Exception& )
2625 	{
2626 		throw SQLException();
2627 	}
2628 }
2629 // -------------------------------------------------------------------------
2630 void SAL_CALL ORowSet::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
2631 {
2632 	::osl::MutexGuard aGuard( m_aColumnsMutex );
2633 	ORowSetValue& rParamValue( getParameterStorage( parameterIndex ) );
2634 	try
2635 	{
2636 		Sequence <sal_Int8> aData;
2637 		rtl::OUString aDataStr;
2638 		// the data is given as character data and the length defines the character length
2639 		sal_Int32 nSize = x->readBytes(aData, length * sizeof(sal_Unicode));
2640 		if (nSize / sizeof(sal_Unicode))
2641 			aDataStr = rtl::OUString((sal_Unicode*)aData.getConstArray(), nSize / sizeof(sal_Unicode));
2642 		rParamValue = aDataStr;
2643 		rParamValue.setTypeKind( DataType::LONGVARCHAR );
2644 		x->closeInput();
2645 	}
2646 	catch( Exception& )
2647 	{
2648 		throw SQLException();
2649 	}
2650 }
2651 // -------------------------------------------------------------------------
2652 void SAL_CALL ORowSet::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException)
2653 {
2654 	if ( !::dbtools::implSetObject( this, parameterIndex, x ) )
2655 	{	// there is no other setXXX call which can handle the value in x
2656 		throw SQLException();
2657 	}
2658 }
2659 // -------------------------------------------------------------------------
2660 void SAL_CALL ORowSet::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException)
2661 {
2662 	::osl::MutexGuard aGuard( m_aColumnsMutex );
2663 	ORowSetValue& rParamValue( getParameterStorage( parameterIndex ) );
2664 	setObject( parameterIndex, x );
2665 	rParamValue.setTypeKind( targetSqlType );
2666 }
2667 // -------------------------------------------------------------------------
2668 void SAL_CALL ORowSet::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ ) throw(SQLException, RuntimeException)
2669 {
2670     ::dbtools::throwFeatureNotImplementedException( "XParameters::setRef", *this );
2671 }
2672 // -------------------------------------------------------------------------
2673 void SAL_CALL ORowSet::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException)
2674 {
2675     ::dbtools::throwFeatureNotImplementedException( "XParameters::setBlob", *this );
2676 }
2677 // -------------------------------------------------------------------------
2678 void SAL_CALL ORowSet::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException)
2679 {
2680     ::dbtools::throwFeatureNotImplementedException( "XParameters::setClob", *this );
2681 }
2682 // -------------------------------------------------------------------------
2683 void SAL_CALL ORowSet::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ ) throw(SQLException, RuntimeException)
2684 {
2685     ::dbtools::throwFeatureNotImplementedException( "XParameters::setArray", *this );
2686 }
2687 // -------------------------------------------------------------------------
2688 void SAL_CALL ORowSet::clearParameters(  ) throw(SQLException, RuntimeException)
2689 {
2690 	::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
2691 
2692 	::osl::MutexGuard aGuard( m_aColumnsMutex );
2693 
2694     size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues.get().size() );
2695     for ( size_t i=1; i<=nParamCount; ++i )
2696         getParameterStorage( (sal_Int32)i ).setNull();
2697     m_aParametersSet.clear();
2698 }
2699 
2700 // -------------------------------------------------------------------------
2701 Any SAL_CALL ORowSet::getWarnings(  ) throw (SQLException, RuntimeException)
2702 {
2703     return m_aWarnings.getWarnings();
2704 }
2705 
2706 // -------------------------------------------------------------------------
2707 void SAL_CALL ORowSet::clearWarnings(  ) throw (SQLException, RuntimeException)
2708 {
2709     m_aWarnings.clearWarnings();
2710 }
2711 // -----------------------------------------------------------------------------
2712 void ORowSet::doCancelModification( )
2713 {
2714 	//OSL_ENSURE( isModification(), "ORowSet::doCancelModification: invalid call (no cache!)!" );
2715 	if ( isModification() )
2716     {
2717         // read-only flag restored
2718         impl_restoreDataColumnsWriteable_throw();
2719 		m_pCache->cancelRowModification();
2720     }
2721     m_bModified = sal_False;
2722 	m_bIsInsertRow = sal_False;
2723 }
2724 
2725 // -----------------------------------------------------------------------------
2726 sal_Bool ORowSet::isModification( )
2727 {
2728 	return isNew();
2729 }
2730 
2731 // -----------------------------------------------------------------------------
2732 sal_Bool ORowSet::isModified( )
2733 {
2734 	return m_bModified;
2735 }
2736 
2737 // -----------------------------------------------------------------------------
2738 sal_Bool ORowSet::isNew( )
2739 {
2740 	return m_bNew;
2741 }
2742 
2743 // -----------------------------------------------------------------------------
2744 void ORowSet::checkUpdateIterator()
2745 {
2746 	if(!m_bIsInsertRow)
2747 	{
2748 		m_pCache->setUpdateIterator(m_aCurrentRow);
2749 		m_aCurrentRow = m_pCache->m_aInsertRow;
2750 		m_bIsInsertRow = sal_True;
2751 	}
2752 }
2753 // -----------------------------------------------------------------------------
2754 void ORowSet::checkUpdateConditions(sal_Int32 columnIndex)
2755 {
2756     checkCache();
2757     if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
2758         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_RESULT_IS_READONLY ), SQL_GENERAL_ERROR, *this );
2759 
2760     if ( rowDeleted() )
2761         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_INVALID_CURSOR_POSITION, *this );
2762 
2763     if ( m_aCurrentRow.isNull() )
2764         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INVALID_CURSOR_STATE ), SQL_INVALID_CURSOR_STATE, *this );
2765 
2766     if ( columnIndex <= 0 || sal_Int32((*m_aCurrentRow)->get().size()) <= columnIndex )
2767         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INVALID_INDEX ), SQL_INVALID_DESCRIPTOR_INDEX, *this );
2768 }
2769 // -----------------------------------------------------------------------------
2770 void SAL_CALL ORowSet::refreshRow(  ) throw(SQLException, RuntimeException)
2771 {
2772 
2773 	ORowSetNotifier aNotifier( this );
2774 		// this will call cancelRowModification on the cache if necessary
2775 
2776 	// notification order:
2777 	if ( m_bModified && m_pCache )
2778 		implCancelRowUpdates( sal_False ); // do _not_ notify the IsModify - will do this ourself below
2779 
2780     // - column values
2781 	ORowSetBase::refreshRow();
2782 
2783 	// - IsModified
2784 	// - IsNew
2785 	aNotifier.fire( );
2786 }
2787 // -----------------------------------------------------------------------------
2788 void ORowSet::impl_rebuild_throw(::osl::ResettableMutexGuard& _rGuard)
2789 {
2790     Reference< XResultSet > xResultSet( m_xStatement->executeQuery() );
2791     m_aWarnings.setExternalWarnings( Reference< XWarningsSupplier >( xResultSet, UNO_QUERY ) );
2792     m_pCache->reset(xResultSet);
2793     notifyAllListeners(_rGuard);
2794 }
2795 // ***********************************************************
2796 //  ORowSetClone
2797 // ***********************************************************
2798 DBG_NAME(ORowSetClone);
2799 //--------------------------------------------------------------------------
2800 ORowSetClone::ORowSetClone( const ::comphelper::ComponentContext& _rContext, ORowSet& rParent, ::osl::Mutex* _pMutex )
2801 		     :OSubComponent(m_aMutex, rParent)
2802 		     ,ORowSetBase( _rContext, OComponentHelper::rBHelper, _pMutex )
2803 			 ,m_pParent(&rParent)
2804 			 ,m_nFetchDirection(rParent.m_nFetchDirection)
2805 			 ,m_nFetchSize(rParent.m_nFetchSize)
2806 			 ,m_bIsBookmarable(sal_True)
2807 {
2808 	DBG_CTOR(ORowSetClone, NULL);
2809 
2810 	m_nResultSetType		= rParent.m_nResultSetType;
2811 	m_nResultSetConcurrency = ResultSetConcurrency::READ_ONLY;
2812 	m_pMySelf				= this;
2813 	m_bClone				= sal_True;
2814 	m_bBeforeFirst			= rParent.m_bBeforeFirst;
2815 	m_bAfterLast			= rParent.m_bAfterLast;
2816 	m_pCache				= rParent.m_pCache;
2817 	m_aBookmark				= rParent.m_aBookmark;
2818 	m_aCurrentRow			= m_pCache->createIterator(this);
2819 	m_xNumberFormatTypes	= rParent.m_xNumberFormatTypes;
2820 
2821 	m_aOldRow = m_pCache->registerOldRow();
2822 
2823 	::vos::ORef< ::connectivity::OSQLColumns> aColumns = new ::connectivity::OSQLColumns();
2824 	::std::vector< ::rtl::OUString> aNames;
2825 
2826 	::rtl::OUString aDescription;
2827 	//	ConfigManager*	pConfigMgr = ConfigManager::GetConfigManager();
2828 	//	Locale aLocale;
2829 	//	pConfigMgr->GetDirectConfigProperty(ConfigManager::LOCALE) >>= aLocale;
2830 	Locale aLocale = SvtSysLocale().GetLocaleData().getLocale();
2831 
2832     if ( rParent.m_pColumns )
2833     {
2834 	    Sequence< ::rtl::OUString> aSeq = rParent.m_pColumns->getElementNames();
2835 	    const ::rtl::OUString* pIter	= aSeq.getConstArray();
2836 	    const ::rtl::OUString* pEnd		= pIter + aSeq.getLength();
2837 	    aColumns->get().reserve(aSeq.getLength()+1);
2838 	    for(sal_Int32 i=1;pIter != pEnd ;++pIter,++i)
2839 	    {
2840 		    Reference<XPropertySet> xColumn;
2841 		    rParent.m_pColumns->getByName(*pIter) >>= xColumn;
2842 		    if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_DESCRIPTION))
2843 			    aDescription = comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION));
2844 
2845             ::rtl::OUString sParseLabel;
2846             xColumn->getPropertyValue(PROPERTY_LABEL) >>= sParseLabel;
2847 		    ORowSetColumn* pColumn = new ORowSetColumn(	rParent.getMetaData(),
2848 															    this,
2849 															    i,
2850                                                                 rParent.m_xActiveConnection->getMetaData(),
2851 															    aDescription,
2852                                                                 sParseLabel,
2853 															    m_aCurrentRow);
2854 		    aColumns->get().push_back(pColumn);
2855 		    pColumn->setName(*pIter);
2856 		    aNames.push_back(*pIter);
2857 		    m_aDataColumns.push_back(pColumn);
2858 
2859 		    pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,xColumn->getPropertyValue(PROPERTY_ALIGN));
2860 		    sal_Int32 nFormatKey = 0;
2861 			xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT) >>= nFormatKey;
2862 		    if(!nFormatKey && xColumn.is() && m_xNumberFormatTypes.is())
2863 			    nFormatKey = ::dbtools::getDefaultNumberFormat(xColumn,m_xNumberFormatTypes,aLocale);
2864 		    pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey));
2865 		    pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,xColumn->getPropertyValue(PROPERTY_RELATIVEPOSITION));
2866 		    pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,xColumn->getPropertyValue(PROPERTY_WIDTH));
2867 		    pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HIDDEN,xColumn->getPropertyValue(PROPERTY_HIDDEN));
2868 		    pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_CONTROLMODEL,xColumn->getPropertyValue(PROPERTY_CONTROLMODEL));
2869 		    pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HELPTEXT,xColumn->getPropertyValue(PROPERTY_HELPTEXT));
2870 		    pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_CONTROLDEFAULT,xColumn->getPropertyValue(PROPERTY_CONTROLDEFAULT));
2871 
2872 	    } // for(sal_Int32 i=1;pIter != pEnd ;++pIter,++i)
2873     }
2874 	Reference<XDatabaseMetaData> xMeta = rParent.m_xActiveConnection->getMetaData();
2875 	m_pColumns = new ORowSetDataColumns(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(),
2876 										aColumns,*this,m_aMutex,aNames);
2877 
2878 	sal_Int32 nRT	= PropertyAttribute::READONLY	| PropertyAttribute::TRANSIENT;
2879 
2880 	// sdb.RowSet Properties
2881 	//	registerProperty(PROPERTY_CURSORNAME,		PROPERTY_ID_CURSORNAME,			PropertyAttribute::READONLY,		&m_aDataSourceName,		::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
2882     registerMayBeVoidProperty(PROPERTY_ACTIVE_CONNECTION,PROPERTY_ID_ACTIVE_CONNECTION,	PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY,	&rParent.m_aActiveConnection,	::getCppuType(reinterpret_cast< Reference< XConnection >* >(NULL)));
2883 	registerProperty(PROPERTY_RESULTSETCONCURRENCY,	PROPERTY_ID_RESULTSETCONCURRENCY,	PropertyAttribute::READONLY,	&m_nResultSetConcurrency,::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
2884 	registerProperty(PROPERTY_RESULTSETTYPE,		PROPERTY_ID_RESULTSETTYPE,			PropertyAttribute::READONLY,	&m_nResultSetType,		::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
2885 	registerProperty(PROPERTY_FETCHDIRECTION,		PROPERTY_ID_FETCHDIRECTION,			PropertyAttribute::TRANSIENT,	&m_nFetchDirection,		::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
2886 	registerProperty(PROPERTY_FETCHSIZE,			PROPERTY_ID_FETCHSIZE,				PropertyAttribute::TRANSIENT,	&m_nFetchSize,			::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
2887 	registerProperty(PROPERTY_ISBOOKMARKABLE,		PROPERTY_ID_ISBOOKMARKABLE,			nRT,							&m_bIsBookmarable,		::getBooleanCppuType());
2888 }
2889 
2890 //--------------------------------------------------------------------------
2891 ORowSetClone::~ORowSetClone()
2892 {
2893 	DBG_DTOR(ORowSetClone, NULL);
2894 }
2895 // com::sun::star::XTypeProvider
2896 //--------------------------------------------------------------------------
2897 Sequence< Type > ORowSetClone::getTypes() throw (RuntimeException)
2898 {
2899 	return ::comphelper::concatSequences(OSubComponent::getTypes(),ORowSetBase::getTypes());
2900 }
2901 // com::sun::star::XInterface
2902 //--------------------------------------------------------------------------
2903 Any ORowSetClone::queryInterface( const Type & rType ) throw (RuntimeException)
2904 {
2905 	Any aRet = ORowSetBase::queryInterface(rType);
2906 	if(!aRet.hasValue())
2907 		aRet = OSubComponent::queryInterface(rType);
2908 	return aRet;
2909 }
2910 //------------------------------------------------------------------------------
2911 void ORowSetClone::acquire() throw()
2912 {
2913 	OSubComponent::acquire();
2914 }
2915 
2916 //------------------------------------------------------------------------------
2917 void ORowSetClone::release() throw()
2918 {
2919 	OSubComponent::release();
2920 }
2921 
2922 // XServiceInfo
2923 //------------------------------------------------------------------------------
2924 rtl::OUString ORowSetClone::getImplementationName(  ) throw(RuntimeException)
2925 {
2926 	return rtl::OUString::createFromAscii("com.sun.star.sdb.ORowSetClone");
2927 }
2928 
2929 //------------------------------------------------------------------------------
2930 sal_Bool ORowSetClone::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
2931 {
2932 	return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
2933 }
2934 
2935 //------------------------------------------------------------------------------
2936 Sequence< ::rtl::OUString > ORowSetClone::getSupportedServiceNames(  ) throw (RuntimeException)
2937 {
2938 	Sequence< ::rtl::OUString > aSNS( 2 );
2939 	aSNS[0] = SERVICE_SDBC_RESULTSET;
2940 	aSNS[1] = SERVICE_SDB_RESULTSET;
2941 	return aSNS;
2942 }
2943 
2944 // OComponentHelper
2945 //------------------------------------------------------------------------------
2946 void ORowSetClone::disposing()
2947 {
2948 	MutexGuard aGuard( m_aMutex );
2949 	ORowSetBase::disposing();
2950 
2951 	m_pParent	= NULL;
2952 	m_pMutex	= &m_aMutex; // this must be done here because someone could hold a ref to us and try to do something
2953 	OSubComponent::disposing();
2954 }
2955 
2956 // XCloseable
2957 //------------------------------------------------------------------------------
2958 void ORowSetClone::close(void) throw( SQLException, RuntimeException )
2959 {
2960 	{
2961 		MutexGuard aGuard( m_aMutex );
2962 		if (OComponentHelper::rBHelper.bDisposed)
2963 			throw DisposedException();
2964 	}
2965 	dispose();
2966 }
2967 // -------------------------------------------------------------------------
2968 
2969 // comphelper::OPropertyArrayUsageHelper
2970 ::cppu::IPropertyArrayHelper* ORowSetClone::createArrayHelper( ) const
2971 {
2972 	Sequence< Property > aProps;
2973 	describeProperties(aProps);
2974 	return new ::cppu::OPropertyArrayHelper(aProps);
2975 }
2976 // -------------------------------------------------------------------------
2977 
2978 // cppu::OPropertySetHelper
2979 ::cppu::IPropertyArrayHelper& SAL_CALL ORowSetClone::getInfoHelper()
2980 {
2981 	typedef ::comphelper::OPropertyArrayUsageHelper<ORowSetClone> ORowSetClone_PROP;
2982 	return *ORowSetClone_PROP::getArrayHelper();
2983 }
2984 // -------------------------------------------------------------------------
2985 //--------------------------------------------------------------------------
2986 Sequence< sal_Int8 > ORowSetClone::getUnoTunnelImplementationId()
2987 {
2988 	static ::cppu::OImplementationId * pId = 0;
2989 	if (! pId)
2990 	{
2991 		::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
2992 		if (! pId)
2993 		{
2994 			static ::cppu::OImplementationId aId;
2995 			pId = &aId;
2996 		}
2997 	}
2998 	return pId->getImplementationId();
2999 }
3000 // -----------------------------------------------------------------------------
3001 // com::sun::star::XUnoTunnel
3002 sal_Int64 SAL_CALL ORowSetClone::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException)
3003 {
3004 	if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
3005 		return reinterpret_cast<sal_Int64>(this);
3006 
3007 	return 0;
3008 }
3009 // -----------------------------------------------------------------------------
3010 void SAL_CALL ORowSetClone::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
3011 {
3012     if ( nHandle == PROPERTY_ID_FETCHSIZE )
3013     {
3014 		if ( m_pParent )
3015 			m_pParent->setFastPropertyValue_NoBroadcast( nHandle, rValue );
3016     }
3017 
3018     OPropertyStateContainer::setFastPropertyValue_NoBroadcast(nHandle,rValue);
3019 }
3020 
3021 // -----------------------------------------------------------------------------
3022 void ORowSetClone::doCancelModification( )
3023 {
3024 	//OSL_ENSURE( sal_False, "ORowSetClone::doCancelModification: invalid call!" );
3025 }
3026 
3027 // -----------------------------------------------------------------------------
3028 sal_Bool ORowSetClone::isModification( )
3029 {
3030 	return sal_False;
3031 }
3032 
3033 // -----------------------------------------------------------------------------
3034 sal_Bool ORowSetClone::isModified( )
3035 {
3036 	return sal_False;
3037 }
3038 
3039 // -----------------------------------------------------------------------------
3040 sal_Bool ORowSetClone::isNew( )
3041 {
3042 	return sal_False;
3043 }
3044 
3045 // -------------------------------------------------------------------------
3046 void SAL_CALL ORowSetClone::execute(  ) throw(SQLException, RuntimeException)
3047 {
3048     throwFunctionNotSupportedException( "RowSetClone::XRowSet::execute", *this );
3049 }
3050 
3051 // -------------------------------------------------------------------------
3052 void SAL_CALL ORowSetClone::addRowSetListener( const Reference< XRowSetListener >& ) throw(RuntimeException)
3053 {
3054     throwFunctionNotSupportedException( "RowSetClone::XRowSet", *this );
3055 }
3056 
3057 // -------------------------------------------------------------------------
3058 void SAL_CALL ORowSetClone::removeRowSetListener( const Reference< XRowSetListener >& ) throw(RuntimeException)
3059 {
3060     throwFunctionNotSupportedException( "RowSetClone::XRowSet", *this );
3061 }
3062 
3063 } // dbaccess
3064