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_connectivity.hxx"
26 #include "ado/AResultSet.hxx"
27 #include "ado/AResultSetMetaData.hxx"
28 #include <com/sun/star/sdbc/DataType.hpp>
29 #include <com/sun/star/sdbc/KeyRule.hpp>
30 #include <com/sun/star/sdbc/IndexType.hpp>
31 #include <comphelper/property.hxx>
32 #include <com/sun/star/lang/DisposedException.hpp>
33 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
34 #include <com/sun/star/sdbc/ResultSetType.hpp>
35 #include <com/sun/star/sdbc/FetchDirection.hpp>
36 #include <cppuhelper/typeprovider.hxx>
37 #include <comphelper/sequence.hxx>
38 #include <com/sun/star/beans/PropertyAttribute.hpp>
39 #include <comphelper/seqstream.hxx>
40 #include "connectivity/dbexception.hxx"
41 #include "connectivity/dbtools.hxx"
42 #include <comphelper/types.hxx>
43 
44 using namespace ::comphelper;
45 
46 
47 #include <oledb.h>
48 
49 #define CHECK_RETURN(x)													\
50 	if(!SUCCEEDED(x))																\
51 		ADOS::ThrowException(*m_pStmt->m_pConnection->getConnection(),*this);
52 
53 using namespace connectivity::ado;
54 using namespace com::sun::star::uno;
55 using namespace com::sun::star::lang;
56 using namespace com::sun::star::beans;
57 using namespace com::sun::star::sdbc;
58 
59 //------------------------------------------------------------------------------
60 //	IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.AResultSet","com.sun.star.sdbc.ResultSet");
getImplementationName()61 ::rtl::OUString SAL_CALL OResultSet::getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException)	\
62 {
63 	return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ado.ResultSet");
64 }
65 // -------------------------------------------------------------------------
getSupportedServiceNames()66 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OResultSet::getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException)
67 {
68 	::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(2);
69 	aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet");
70 	aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet");
71 	return aSupported;
72 }
73 // -------------------------------------------------------------------------
supportsService(const::rtl::OUString & _rServiceName)74 sal_Bool SAL_CALL OResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw(::com::sun::star::uno::RuntimeException)
75 {
76 	Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
77 	const ::rtl::OUString* pSupported = aSupported.getConstArray();
78 	const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
79 	for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
80 		;
81 
82 	return pSupported != pEnd;
83 }
84 // -------------------------------------------------------------------------
OResultSet(ADORecordset * _pRecordSet,OStatement_Base * pStmt)85 OResultSet::OResultSet(ADORecordset* _pRecordSet,OStatement_Base* pStmt) :	OResultSet_BASE(m_aMutex)
86 						,OPropertySetHelper(OResultSet_BASE::rBHelper)
87 						,m_xStatement(*pStmt)
88 						,m_pStmt(pStmt)
89 						,m_nRowPos(0)
90 						,m_xMetaData(NULL)
91 						,m_pRecordSet(_pRecordSet)
92 						,m_bEOF(sal_False)
93 {
94 }
95 // -------------------------------------------------------------------------
OResultSet(ADORecordset * _pRecordSet)96 OResultSet::OResultSet(ADORecordset* _pRecordSet) :	OResultSet_BASE(m_aMutex)
97 						,OPropertySetHelper(OResultSet_BASE::rBHelper)
98 						,m_xStatement(NULL)
99 						,m_xMetaData(NULL)
100 						,m_pRecordSet(_pRecordSet)
101 						,m_bEOF(sal_False)
102 {
103 }
104 // -----------------------------------------------------------------------------
construct()105 void OResultSet::construct()
106 {
107 	osl_incrementInterlockedCount( &m_refCount );
108 	if (!m_pRecordSet)
109 	{
110 		OSL_ENSURE( sal_False, "OResultSet::construct: no RecordSet!" );
111 		Reference< XInterface > xInt( *this );
112 		osl_decrementInterlockedCount( &m_refCount );
113 		::dbtools::throwFunctionSequenceException( xInt );
114 	}
115 	m_pRecordSet->AddRef();
116 	VARIANT_BOOL bIsAtBOF;
117 	CHECK_RETURN(m_pRecordSet->get_BOF(&bIsAtBOF))
118 	m_bOnFirstAfterOpen = bIsAtBOF != VARIANT_TRUE;
119 	osl_decrementInterlockedCount( &m_refCount );
120 }
121 // -------------------------------------------------------------------------
~OResultSet()122 OResultSet::~OResultSet()
123 {
124 	if(m_pRecordSet)
125 		m_pRecordSet->Release();
126 }
127 // -------------------------------------------------------------------------
disposing(void)128 void OResultSet::disposing(void)
129 {
130 	OPropertySetHelper::disposing();
131 
132 	::osl::MutexGuard aGuard(m_aMutex);
133 	if(m_pRecordSet)
134 		m_pRecordSet->Close();
135 m_xStatement.clear();
136 m_xMetaData.clear();
137 }
138 // -------------------------------------------------------------------------
queryInterface(const Type & rType)139 Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
140 {
141 	Any aRet = OPropertySetHelper::queryInterface(rType);
142 	return aRet.hasValue() ? aRet : OResultSet_BASE::queryInterface(rType);
143 }
144 // -------------------------------------------------------------------------
getTypes()145 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OResultSet::getTypes(  ) throw(::com::sun::star::uno::RuntimeException)
146 {
147 	::cppu::OTypeCollection aTypes(	::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
148 									::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
149 									::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
150 
151 	return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes());
152 }
153 
154 // -------------------------------------------------------------------------
155 
findColumn(const::rtl::OUString & columnName)156 sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
157 {
158 	::osl::MutexGuard aGuard( m_aMutex );
159 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
160 
161 
162 	Reference< XResultSetMetaData > xMeta = getMetaData();
163 	sal_Int32 nLen = xMeta->getColumnCount();
164 	sal_Int32 i = 1;
165 	for(;i<=nLen;++i)
166 		if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
167 			columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
168 			break;
169 	return i;
170 }
171 #define BLOCK_SIZE 256
172 // -------------------------------------------------------------------------
getBinaryStream(sal_Int32 columnIndex)173 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
174 {
175 	::osl::MutexGuard aGuard( m_aMutex );
176 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
177 
178 	WpADOField aField = ADOS::getField(m_pRecordSet,columnIndex);
179 
180 	if((aField.GetAttributes() & adFldLong) == adFldLong)
181 	{
182 		//Copy the data only up to the Actual Size of Field.
183 		sal_Int32 nSize = aField.GetActualSize();
184 		Sequence<sal_Int8> aData(nSize);
185 		long index = 0;
186 		while(index < nSize)
187 		{
188 			m_aValue = aField.GetChunk(BLOCK_SIZE);
189 			if(m_aValue.isNull())
190 				break;
191 			UCHAR chData;
192 			for(long index2 = 0;index2 < BLOCK_SIZE;++index2)
193 			{
194 				HRESULT hr = ::SafeArrayGetElement(m_aValue.parray,&index2,&chData);
195 				if(SUCCEEDED(hr))
196 				{
197 					//Take BYTE by BYTE and advance Memory Location
198 					aData.getArray()[index++] = chData;
199 				}
200 				else
201 					break;
202 			}
203 		}
204 
205 		return new ::comphelper::SequenceInputStream(aData);
206 	}
207 	// else we ask for a bytesequence
208 	aField.get_Value(m_aValue);
209 
210 	return m_aValue.isNull() ? NULL : new ::comphelper::SequenceInputStream(m_aValue);
211 }
212 // -------------------------------------------------------------------------
getCharacterStream(sal_Int32)213 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
214 {
215     ::dbtools::throwFeatureNotImplementedException( "XRow::getCharacterStream", *this );
216 	return NULL;
217 }
218 // -----------------------------------------------------------------------------
getValue(sal_Int32 columnIndex)219 OLEVariant OResultSet::getValue(sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
220 {
221 	::osl::MutexGuard aGuard( m_aMutex );
222 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
223 
224 	WpADOField aField = ADOS::getField(m_pRecordSet,columnIndex);
225 	aField.get_Value(m_aValue);
226 	return m_aValue;
227 }
228 // -------------------------------------------------------------------------
getBoolean(sal_Int32 columnIndex)229 sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
230 {
231 	return getValue(columnIndex);
232 }
233 // -------------------------------------------------------------------------
234 
getByte(sal_Int32 columnIndex)235 sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
236 {
237 	return getValue(columnIndex);
238 }
239 // -------------------------------------------------------------------------
240 
getBytes(sal_Int32 columnIndex)241 Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
242 {
243 	return getValue(columnIndex);
244 }
245 // -------------------------------------------------------------------------
246 
getDate(sal_Int32 columnIndex)247 ::com::sun::star::util::Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
248 {
249 	return getValue(columnIndex);
250 }
251 // -------------------------------------------------------------------------
252 
getDouble(sal_Int32 columnIndex)253 double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
254 {
255 	return getValue(columnIndex);
256 }
257 // -------------------------------------------------------------------------
258 
getFloat(sal_Int32 columnIndex)259 float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
260 {
261 	return getValue(columnIndex);
262 }
263 // -------------------------------------------------------------------------
264 
getInt(sal_Int32 columnIndex)265 sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
266 {
267 	return getValue(columnIndex);
268 }
269 // -------------------------------------------------------------------------
270 
getRow()271 sal_Int32 SAL_CALL OResultSet::getRow(  ) throw(SQLException, RuntimeException)
272 {
273 	::osl::MutexGuard aGuard( m_aMutex );
274 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
275 
276 
277 	PositionEnum aPos;
278 	m_pRecordSet->get_AbsolutePosition(&aPos);
279 	return  (aPos > 0) ? aPos : m_nRowPos;
280 	// return the rowcount from driver if the driver doesn't support this return our count
281 }
282 // -------------------------------------------------------------------------
283 
getLong(sal_Int32)284 sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
285 {
286     ::dbtools::throwFeatureNotImplementedException( "XRow::getLong", *this );
287 	return sal_Int64(0);
288 }
289 // -------------------------------------------------------------------------
290 
getMetaData()291 Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData(  ) throw(SQLException, RuntimeException)
292 {
293 	::osl::MutexGuard aGuard( m_aMutex );
294 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
295 
296 
297 	if(!m_xMetaData.is())
298 		m_xMetaData = new OResultSetMetaData(m_pRecordSet);
299 	return m_xMetaData;
300 }
301 // -------------------------------------------------------------------------
getArray(sal_Int32)302 Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
303 {
304     ::dbtools::throwFeatureNotImplementedException( "XRow::getArray", *this );
305 	return NULL;
306 }
307 
308 // -------------------------------------------------------------------------
309 
getClob(sal_Int32)310 Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
311 {
312     ::dbtools::throwFeatureNotImplementedException( "XRow::getClob", *this );
313 	return NULL;
314 }
315 // -------------------------------------------------------------------------
getBlob(sal_Int32)316 Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
317 {
318     ::dbtools::throwFeatureNotImplementedException( "XRow::getBlob", *this );
319 	return NULL;
320 }
321 // -------------------------------------------------------------------------
322 
getRef(sal_Int32)323 Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
324 {
325     ::dbtools::throwFeatureNotImplementedException( "XRow::getRef", *this );
326 	return NULL;
327 }
328 // -------------------------------------------------------------------------
329 
getObject(sal_Int32 columnIndex,const Reference<::com::sun::star::container::XNameAccess> &)330 Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
331 {
332     return getValue(columnIndex).makeAny();
333 }
334 // -------------------------------------------------------------------------
335 
getShort(sal_Int32 columnIndex)336 sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
337 {
338 	return getValue(columnIndex);
339 }
340 // -------------------------------------------------------------------------
341 
getString(sal_Int32 columnIndex)342 ::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
343 {
344 	return getValue(columnIndex);
345 }
346 
347 // -------------------------------------------------------------------------
348 
349 
getTime(sal_Int32 columnIndex)350 ::com::sun::star::util::Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
351 {
352 	return getValue(columnIndex);
353 }
354 // -------------------------------------------------------------------------
355 
356 
getTimestamp(sal_Int32 columnIndex)357 ::com::sun::star::util::DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
358 {
359 	return getValue(columnIndex);
360 }
361 // -------------------------------------------------------------------------
362 
isAfterLast()363 sal_Bool SAL_CALL OResultSet::isAfterLast(  ) throw(SQLException, RuntimeException)
364 {
365 	::osl::MutexGuard aGuard( m_aMutex );
366 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
367 
368 
369 	VARIANT_BOOL bIsAtEOF;
370 	CHECK_RETURN(m_pRecordSet->get_EOF(&bIsAtEOF))
371 	return bIsAtEOF == VARIANT_TRUE;
372 }
373 // -------------------------------------------------------------------------
isFirst()374 sal_Bool SAL_CALL OResultSet::isFirst(  ) throw(SQLException, RuntimeException)
375 {
376 	::osl::MutexGuard aGuard( m_aMutex );
377 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
378 
379 
380 	return m_nRowPos == 1;
381 }
382 // -------------------------------------------------------------------------
isLast()383 sal_Bool SAL_CALL OResultSet::isLast(  ) throw(SQLException, RuntimeException)
384 {
385 	::osl::MutexGuard aGuard( m_aMutex );
386 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
387 
388 
389 	return sal_True;
390 }
391 // -------------------------------------------------------------------------
beforeFirst()392 void SAL_CALL OResultSet::beforeFirst(  ) throw(SQLException, RuntimeException)
393 {
394 	::osl::MutexGuard aGuard( m_aMutex );
395 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
396 
397 
398 	if(first())
399 		m_bOnFirstAfterOpen = !previous();
400 }
401 // -------------------------------------------------------------------------
afterLast()402 void SAL_CALL OResultSet::afterLast(  ) throw(SQLException, RuntimeException)
403 {
404 	::osl::MutexGuard aGuard( m_aMutex );
405 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
406 
407 
408 	if(last())
409 		next();
410 	m_bEOF = sal_True;
411 }
412 // -------------------------------------------------------------------------
413 
close()414 void SAL_CALL OResultSet::close(  ) throw(SQLException, RuntimeException)
415 {
416 	{
417 		::osl::MutexGuard aGuard( m_aMutex );
418 		checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
419 
420 	}
421 	dispose();
422 }
423 // -------------------------------------------------------------------------
424 
first()425 sal_Bool SAL_CALL OResultSet::first(  ) throw(SQLException, RuntimeException)
426 {
427 	::osl::MutexGuard aGuard( m_aMutex );
428 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
429 
430 
431 	if(SUCCEEDED(m_pRecordSet->MoveFirst()))
432 	{
433 		m_nRowPos = 1;
434 		m_bOnFirstAfterOpen = sal_False;
435 		return sal_True;
436 	}
437 	return sal_False;
438 }
439 // -------------------------------------------------------------------------
440 
last()441 sal_Bool SAL_CALL OResultSet::last(  ) throw(SQLException, RuntimeException)
442 {
443 	::osl::MutexGuard aGuard( m_aMutex );
444 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
445 
446 
447 	sal_Bool bRet = SUCCEEDED(m_pRecordSet->MoveLast());
448 	if(bRet)
449 	{
450 		m_pRecordSet->get_RecordCount(&m_nRowPos);
451 		m_bOnFirstAfterOpen = sal_False;
452 	}
453 	return bRet;
454 }
455 // -------------------------------------------------------------------------
absolute(sal_Int32 row)456 sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
457 {
458 	::osl::MutexGuard aGuard( m_aMutex );
459 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
460 
461 
462 	if(!row)				 // absolute with zero not allowed
463 		::dbtools::throwFunctionSequenceException(*this);
464 
465 	sal_Bool bCheck = sal_True;
466 	if(row < 0)
467 	{
468         bCheck = SUCCEEDED(m_pRecordSet->MoveLast());
469 		if ( bCheck )
470 		{
471 			while(++row < 0 && bCheck)
472 				bCheck = SUCCEEDED(m_pRecordSet->MovePrevious());
473 		}
474 	}
475 	else
476 	{
477 		first();
478 		OLEVariant aEmpty;
479 		aEmpty.setNoArg();
480 		bCheck = SUCCEEDED(m_pRecordSet->Move(row-1,aEmpty)); // move to row -1 because we stand already on the first
481 		if(bCheck)
482 			m_nRowPos = row;
483 	}
484 	if(bCheck)
485 		m_bOnFirstAfterOpen = sal_False;
486 	return bCheck;
487 }
488 // -------------------------------------------------------------------------
relative(sal_Int32 row)489 sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
490 {
491 	::osl::MutexGuard aGuard( m_aMutex );
492 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
493 
494 
495 	OLEVariant aEmpty;
496 	aEmpty.setNoArg();
497 	sal_Int32 nNewPos = row;
498 	if ( m_bOnFirstAfterOpen && nNewPos > 0 )
499 		--nNewPos;
500 	sal_Bool bRet = SUCCEEDED(m_pRecordSet->Move(row,aEmpty));
501 	if(bRet)
502 	{
503 		m_nRowPos += row;
504 		m_bOnFirstAfterOpen = sal_False;
505 	}
506 	return bRet;
507 }
508 // -------------------------------------------------------------------------
previous()509 sal_Bool SAL_CALL OResultSet::previous(  ) throw(SQLException, RuntimeException)
510 {
511 	::osl::MutexGuard aGuard( m_aMutex );
512 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
513 
514 	sal_Bool bRet = SUCCEEDED(m_pRecordSet->MovePrevious());
515 	if(bRet)
516 	{
517 		--m_nRowPos;
518 		m_bOnFirstAfterOpen = sal_False;
519 	}
520 	return bRet;
521 }
522 // -------------------------------------------------------------------------
getStatement()523 Reference< XInterface > SAL_CALL OResultSet::getStatement(  ) throw(SQLException, RuntimeException)
524 {
525 	::osl::MutexGuard aGuard( m_aMutex );
526 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
527 	return m_xStatement;
528 }
529 // -------------------------------------------------------------------------
530 
rowDeleted()531 sal_Bool SAL_CALL OResultSet::rowDeleted(  ) throw(SQLException, RuntimeException)
532 {
533 	::osl::MutexGuard aGuard( m_aMutex );
534 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
535 
536 
537 	RecordStatusEnum eRec;
538 	m_pRecordSet->get_Status((sal_Int32*)&eRec);
539 	sal_Bool  bRet = (eRec & adRecDeleted) == adRecDeleted;
540 	if(bRet)
541 		--m_nRowPos;
542 	return bRet;
543 }
544 // -------------------------------------------------------------------------
rowInserted()545 sal_Bool SAL_CALL OResultSet::rowInserted(  ) throw(SQLException, RuntimeException)
546 {	::osl::MutexGuard aGuard( m_aMutex );
547 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
548 
549 
550 	RecordStatusEnum eRec;
551 	m_pRecordSet->get_Status((sal_Int32*)&eRec);
552 	sal_Bool  bRet = (eRec & adRecNew) == adRecNew;
553 	if(bRet)
554 		++m_nRowPos;
555 	return bRet;
556 }
557 // -------------------------------------------------------------------------
rowUpdated()558 sal_Bool SAL_CALL OResultSet::rowUpdated(  ) throw(SQLException, RuntimeException)
559 {
560 	::osl::MutexGuard aGuard( m_aMutex );
561 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
562 
563 
564 	RecordStatusEnum eRec;
565 	m_pRecordSet->get_Status((sal_Int32*)&eRec);
566 	return (eRec & adRecModified) == adRecModified;
567 }
568 // -------------------------------------------------------------------------
569 
isBeforeFirst()570 sal_Bool SAL_CALL OResultSet::isBeforeFirst(  ) throw(SQLException, RuntimeException)
571 {
572 	::osl::MutexGuard aGuard( m_aMutex );
573 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
574 
575 
576 	OSL_ENSURE(!m_nRowPos,"OResultSet::isBeforeFirst: Error in setting m_nRowPos!");
577 	VARIANT_BOOL bIsAtBOF = VARIANT_TRUE;
578 	if(!m_bOnFirstAfterOpen)
579 	{
580 		OSL_ENSURE(!m_nRowPos,"OResultSet::isBeforeFirst: Error in setting m_nRowPos!");
581 		m_pRecordSet->get_BOF(&bIsAtBOF);
582 	}
583 	return bIsAtBOF == VARIANT_TRUE;
584 }
585 // -------------------------------------------------------------------------
586 
next()587 sal_Bool SAL_CALL OResultSet::next(  ) throw(SQLException, RuntimeException)
588 {
589 	::osl::MutexGuard aGuard( m_aMutex );
590 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
591 
592 
593 	sal_Bool bRet = sal_True;
594 	if(m_bOnFirstAfterOpen)
595 	{
596 		m_bOnFirstAfterOpen = sal_False;
597 		++m_nRowPos;
598 	}
599 	else
600 	{
601 		bRet = SUCCEEDED(m_pRecordSet->MoveNext());
602 
603 		if(bRet)
604 		{
605 			VARIANT_BOOL bIsAtEOF;
606 			CHECK_RETURN(m_pRecordSet->get_EOF(&bIsAtEOF))
607 			bRet = bIsAtEOF != VARIANT_TRUE;
608 			++m_nRowPos;
609 		}
610 		else
611 			ADOS::ThrowException(*m_pStmt->m_pConnection->getConnection(),*this);
612 	}
613 
614 	return bRet;
615 }
616 // -------------------------------------------------------------------------
617 
wasNull()618 sal_Bool SAL_CALL OResultSet::wasNull(  ) throw(SQLException, RuntimeException)
619 {
620 	::osl::MutexGuard aGuard( m_aMutex );
621 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
622 
623 
624 	return m_aValue.isNull();
625 }
626 // -------------------------------------------------------------------------
627 
cancel()628 void SAL_CALL OResultSet::cancel(  ) throw(RuntimeException)
629 {
630 	::osl::MutexGuard aGuard( m_aMutex );
631 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
632 
633 
634 	m_pRecordSet->Cancel();
635 }
636 // -------------------------------------------------------------------------
clearWarnings()637 void SAL_CALL OResultSet::clearWarnings(  ) throw(SQLException, RuntimeException)
638 {
639 }
640 // -------------------------------------------------------------------------
getWarnings()641 Any SAL_CALL OResultSet::getWarnings(  ) throw(SQLException, RuntimeException)
642 {
643 	return Any();
644 }
645 // -------------------------------------------------------------------------
insertRow()646 void SAL_CALL OResultSet::insertRow(  ) throw(SQLException, RuntimeException)
647 {
648 	::osl::MutexGuard aGuard( m_aMutex );
649 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
650 
651 
652 	OLEVariant aEmpty;
653 	aEmpty.setNoArg();
654 	m_pRecordSet->AddNew(aEmpty,aEmpty);
655 }
656 // -------------------------------------------------------------------------
updateRow()657 void SAL_CALL OResultSet::updateRow(  ) throw(SQLException, RuntimeException)
658 {
659 	::osl::MutexGuard aGuard( m_aMutex );
660 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
661 
662 
663 	OLEVariant aEmpty;
664 	aEmpty.setNoArg();
665 	m_pRecordSet->Update(aEmpty,aEmpty);
666 }
667 // -------------------------------------------------------------------------
deleteRow()668 void SAL_CALL OResultSet::deleteRow(  ) throw(SQLException, RuntimeException)
669 {
670 	::osl::MutexGuard aGuard( m_aMutex );
671 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
672 
673 
674 	m_pRecordSet->Delete(adAffectCurrent);
675 	m_pRecordSet->UpdateBatch(adAffectCurrent);
676 }
677 // -------------------------------------------------------------------------
678 
cancelRowUpdates()679 void SAL_CALL OResultSet::cancelRowUpdates(  ) throw(SQLException, RuntimeException)
680 {
681 	::osl::MutexGuard aGuard( m_aMutex );
682 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
683 
684 
685 	m_pRecordSet->CancelUpdate();
686 }
687 // -------------------------------------------------------------------------
688 
moveToInsertRow()689 void SAL_CALL OResultSet::moveToInsertRow(  ) throw(SQLException, RuntimeException)
690 {
691  //   ::osl::MutexGuard aGuard( m_aMutex );
692 	//checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
693  //   if ( getResultSetConcurrency() == ResultSetConcurrency::READ_ONLY )
694  //       throw SQLException();
695 }
696 // -------------------------------------------------------------------------
697 
moveToCurrentRow()698 void SAL_CALL OResultSet::moveToCurrentRow(  ) throw(SQLException, RuntimeException)
699 {
700 }
701 // -----------------------------------------------------------------------------
updateValue(sal_Int32 columnIndex,const OLEVariant & x)702 void OResultSet::updateValue(sal_Int32 columnIndex,const OLEVariant& x)
703 {
704 	::osl::MutexGuard aGuard( m_aMutex );
705 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
706 
707 	WpADOField aField = ADOS::getField(m_pRecordSet,columnIndex);
708 	aField.PutValue(x);
709 }
710 // -------------------------------------------------------------------------
updateNull(sal_Int32 columnIndex)711 void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
712 {
713 	OLEVariant x;
714 	x.setNull();
715 	updateValue(columnIndex,x);
716 }
717 // -------------------------------------------------------------------------
718 
updateBoolean(sal_Int32 columnIndex,sal_Bool x)719 void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
720 {
721 	updateValue(columnIndex,x);
722 }
723 // -------------------------------------------------------------------------
updateByte(sal_Int32 columnIndex,sal_Int8 x)724 void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
725 {
726 	updateValue(columnIndex,x);
727 }
728 // -------------------------------------------------------------------------
729 
updateShort(sal_Int32 columnIndex,sal_Int16 x)730 void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
731 {
732 	updateValue(columnIndex,x);
733 }
734 // -------------------------------------------------------------------------
updateInt(sal_Int32 columnIndex,sal_Int32 x)735 void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
736 {
737 	updateValue(columnIndex,x);
738 }
739 // -------------------------------------------------------------------------
updateLong(sal_Int32 columnIndex,sal_Int64 x)740 void SAL_CALL OResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(SQLException, RuntimeException)
741 {
742 	updateValue(columnIndex,x);
743 }
744 // -----------------------------------------------------------------------
updateFloat(sal_Int32 columnIndex,float x)745 void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException)
746 {
747 	updateValue(columnIndex,x);
748 }
749 // -------------------------------------------------------------------------
750 
updateDouble(sal_Int32 columnIndex,double x)751 void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException)
752 {
753 	updateValue(columnIndex,x);
754 }
755 // -------------------------------------------------------------------------
updateString(sal_Int32 columnIndex,const::rtl::OUString & x)756 void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
757 {
758 	updateValue(columnIndex,x);
759 }
760 // -------------------------------------------------------------------------
updateBytes(sal_Int32 columnIndex,const Sequence<sal_Int8> & x)761 void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
762 {
763 	updateValue(columnIndex,x);
764 }
765 // -------------------------------------------------------------------------
updateDate(sal_Int32 columnIndex,const::com::sun::star::util::Date & x)766 void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException)
767 {
768 	updateValue(columnIndex,x);
769 }
770 // -------------------------------------------------------------------------
771 
updateTime(sal_Int32 columnIndex,const::com::sun::star::util::Time & x)772 void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException)
773 {
774 	updateValue(columnIndex,x);
775 }
776 // -------------------------------------------------------------------------
777 
updateTimestamp(sal_Int32 columnIndex,const::com::sun::star::util::DateTime & x)778 void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException)
779 {
780 	updateValue(columnIndex,x);
781 }
782 // -------------------------------------------------------------------------
783 
updateBinaryStream(sal_Int32 columnIndex,const Reference<::com::sun::star::io::XInputStream> & x,sal_Int32 length)784 void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
785 {
786     if(!x.is())
787 		::dbtools::throwFunctionSequenceException(*this);
788 
789 	Sequence<sal_Int8> aSeq;
790 	x->readBytes(aSeq,length);
791 	updateBytes(columnIndex,aSeq);
792 }
793 // -------------------------------------------------------------------------
updateCharacterStream(sal_Int32 columnIndex,const Reference<::com::sun::star::io::XInputStream> & x,sal_Int32 length)794 void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
795 {
796     if(!x.is())
797 		::dbtools::throwFunctionSequenceException(*this);
798 
799 	Sequence<sal_Int8> aSeq;
800 	x->readBytes(aSeq,length);
801 	updateBytes(columnIndex,aSeq);
802 }
803 // -------------------------------------------------------------------------
refreshRow()804 void SAL_CALL OResultSet::refreshRow(  ) throw(SQLException, RuntimeException)
805 {
806 	::osl::MutexGuard aGuard( m_aMutex );
807 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
808 
809 
810 	m_pRecordSet->Resync(adAffectCurrent,adResyncAllValues);
811 }
812 // -------------------------------------------------------------------------
updateObject(sal_Int32 columnIndex,const Any & x)813 void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException)
814 {
815 	if (!::dbtools::implUpdateObject(this, columnIndex, x))
816 		throw SQLException();
817 }
818 // -------------------------------------------------------------------------
819 
updateNumericObject(sal_Int32 columnIndex,const Any & x,sal_Int32)820 void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException)
821 {
822 	if (!::dbtools::implUpdateObject(this, columnIndex, x))
823 		throw SQLException();
824 }
825 //------------------------------------------------------------------------------
826 // XRowLocate
getBookmark()827 Any SAL_CALL OResultSet::getBookmark(  ) throw(SQLException, RuntimeException)
828 {
829 	::osl::MutexGuard aGuard( m_aMutex );
830 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
831 
832 	if(m_nRowPos < (sal_Int32)m_aBookmarks.size()) // this bookmark was already fetched
833 		return makeAny(sal_Int32(m_nRowPos-1));
834 
835 	OLEVariant aVar;
836 	m_pRecordSet->get_Bookmark(&aVar);
837 	m_aBookmarks.push_back(aVar);
838 	return makeAny((sal_Int32)(m_aBookmarks.size()-1));
839 
840 }
841 //------------------------------------------------------------------------------
moveToBookmark(const Any & bookmark)842 sal_Bool SAL_CALL OResultSet::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
843 {
844 	::osl::MutexGuard aGuard( m_aMutex );
845 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
846 
847 
848 	sal_Int32 nPos;
849 	bookmark >>= nPos;
850 	OSL_ENSURE(nPos >= 0 && nPos < (sal_Int32)m_aBookmarks.size(),"Invalid Index for vector");
851 	if(nPos < 0 || nPos >= (sal_Int32)m_aBookmarks.size())
852 		::dbtools::throwFunctionSequenceException(*this);
853 
854 	return SUCCEEDED(m_pRecordSet->Move(0,m_aBookmarks[nPos]));
855 }
856 //------------------------------------------------------------------------------
moveRelativeToBookmark(const Any & bookmark,sal_Int32 rows)857 sal_Bool SAL_CALL OResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException)
858 {
859 	::osl::MutexGuard aGuard( m_aMutex );
860 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
861 
862 
863 	sal_Int32 nPos;
864 	bookmark >>= nPos;
865 	nPos += rows;
866 	OSL_ENSURE(nPos >= 0 && nPos < (sal_Int32)m_aBookmarks.size(),"Invalid Index for vector");
867 	if(nPos < 0 || nPos >= (sal_Int32)m_aBookmarks.size())
868 		::dbtools::throwFunctionSequenceException(*this);
869 	return SUCCEEDED(m_pRecordSet->Move(rows,m_aBookmarks[nPos]));
870 }
871 //------------------------------------------------------------------------------
compareBookmarks(const Any & first,const Any & second)872 sal_Int32 SAL_CALL OResultSet::compareBookmarks( const Any& first, const Any& second ) throw(SQLException, RuntimeException)
873 {
874 	::osl::MutexGuard aGuard( m_aMutex );
875 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
876 
877 	sal_Int32 nPos1;
878 	first >>= nPos1;
879 	sal_Int32 nPos2;
880 	second >>= nPos2;
881 	if(nPos1 == nPos2)	// they should be equal
882 		return sal_True;
883 
884 	OSL_ENSURE((nPos1 >= 0 && nPos1 < (sal_Int32)m_aBookmarks.size()) || (nPos1 >= 0 && nPos2 < (sal_Int32)m_aBookmarks.size()),"Invalid Index for vector");
885 
886 	CompareEnum eNum;
887 	m_pRecordSet->CompareBookmarks(m_aBookmarks[nPos1],m_aBookmarks[nPos2],&eNum);
888 	return ((sal_Int32)eNum) +1;
889 }
890 //------------------------------------------------------------------------------
hasOrderedBookmarks()891 sal_Bool SAL_CALL OResultSet::hasOrderedBookmarks(  ) throw(SQLException, RuntimeException)
892 {
893 	::osl::MutexGuard aGuard( m_aMutex );
894 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
895 
896 
897 	ADOProperties* pProps = NULL;
898 	m_pRecordSet->get_Properties(&pProps);
899 	WpADOProperties aProps;
900 	aProps.setWithOutAddRef(pProps);
901 	ADOS::ThrowException(*((OConnection*)m_pStmt->getConnection().get())->getConnection(),*this);
902 	OSL_ENSURE(aProps.IsValid(),"There are no properties at the connection");
903 
904 	WpADOProperty aProp(aProps.GetItem(::rtl::OUString::createFromAscii("Bookmarks Ordered")));
905 	OLEVariant aVar;
906 	if(aProp.IsValid())
907 		aVar = aProp.GetValue();
908 	else
909 		ADOS::ThrowException(*((OConnection*)m_pStmt->getConnection().get())->getConnection(),*this);
910 
911 	sal_Bool bValue(sal_False);
912 	if(!aVar.isNull() && !aVar.isEmpty())
913 		bValue = aVar;
914 	return bValue;
915 }
916 //------------------------------------------------------------------------------
hashBookmark(const Any & bookmark)917 sal_Int32 SAL_CALL OResultSet::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
918 {
919 	::osl::MutexGuard aGuard( m_aMutex );
920 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
921 
922 
923 	sal_Int32 nPos;
924 	bookmark >>= nPos;
925 	return nPos;
926 }
927 //------------------------------------------------------------------------------
928 // XDeleteRows
deleteRows(const Sequence<Any> & rows)929 Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const Sequence< Any >& rows ) throw(SQLException, RuntimeException)
930 {
931 	::osl::MutexGuard aGuard( m_aMutex );
932 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
933 
934 
935 	OLEVariant aVar;
936 	sal_Int32 nPos;
937 
938 	// Create SafeArray Bounds and initialize the array
939 	SAFEARRAYBOUND rgsabound[1];
940 	rgsabound[0].lLbound   = 0;
941 	rgsabound[0].cElements = rows.getLength();
942 	SAFEARRAY *psa         = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
943 
944 	const Any* pBegin = rows.getConstArray();
945 	const Any* pEnd = pBegin + rows.getLength();
946 	for(sal_Int32 i=0;pBegin != pEnd ;++pBegin,++i)
947 	{
948 		*pBegin >>= nPos;
949 		SafeArrayPutElement(psa,&i,&m_aBookmarks[nPos]);
950 	}
951 
952 	// Initialize and fill the SafeArray
953 	OLEVariant vsa;
954 	vsa.setArray(psa,VT_VARIANT);
955 
956 	m_pRecordSet->put_Filter(vsa);
957 	m_pRecordSet->Delete(adAffectGroup);
958 	m_pRecordSet->UpdateBatch(adAffectGroup);
959 
960 	Sequence< sal_Int32 > aSeq(rows.getLength());
961 	if(first())
962 	{
963 		sal_Int32* pSeq = aSeq.getArray();
964 		sal_Int32 i=0;
965 		do
966 		{
967 			OSL_ENSURE(i<aSeq.getLength(),"Index greater than length of sequence");
968 			m_pRecordSet->get_Status(&pSeq[i]);
969 			if(pSeq[i++] == adRecDeleted)
970 				--m_nRowPos;
971 		}
972 		while(next());
973 	}
974 	return aSeq;
975 }
976 //------------------------------------------------------------------------------
getResultSetConcurrency() const977 sal_Int32 OResultSet::getResultSetConcurrency() const
978 	throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
979 {
980 	sal_Int32 nValue=ResultSetConcurrency::READ_ONLY;
981 	LockTypeEnum eRet;
982 	if(!SUCCEEDED(m_pRecordSet->get_LockType(&eRet)))
983 	{
984 		switch(eRet)
985 		{
986 			case adLockReadOnly:
987 				nValue = ResultSetConcurrency::READ_ONLY;
988 				break;
989 			default:
990 				nValue = ResultSetConcurrency::UPDATABLE;
991 				break;
992 		}
993 	}
994 	return nValue;
995 }
996 //------------------------------------------------------------------------------
getResultSetType() const997 sal_Int32 OResultSet::getResultSetType() const
998 	throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
999 {
1000 	sal_Int32 nValue=0;
1001 	CursorTypeEnum eRet;
1002 	if(!SUCCEEDED(m_pRecordSet->get_CursorType(&eRet)))
1003 	{
1004 		switch(eRet)
1005 		{
1006 			case adOpenUnspecified:
1007 			case adOpenForwardOnly:
1008 				nValue = ResultSetType::FORWARD_ONLY;
1009 				break;
1010 			case adOpenStatic:
1011 			case adOpenKeyset:
1012 				nValue = ResultSetType::SCROLL_INSENSITIVE;
1013 				break;
1014 			case adOpenDynamic:
1015 				nValue = ResultSetType::SCROLL_SENSITIVE;
1016 				break;
1017 		}
1018 	}
1019 	return nValue;
1020 }
1021 //------------------------------------------------------------------------------
getFetchDirection() const1022 sal_Int32 OResultSet::getFetchDirection() const
1023 	throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
1024 {
1025 	return FetchDirection::FORWARD;
1026 }
1027 //------------------------------------------------------------------------------
getFetchSize() const1028 sal_Int32 OResultSet::getFetchSize() const
1029 	throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
1030 {
1031 	sal_Int32 nValue=-1;
1032 	m_pRecordSet->get_CacheSize(&nValue);
1033 	return nValue;
1034 }
1035 //------------------------------------------------------------------------------
getCursorName() const1036 ::rtl::OUString OResultSet::getCursorName() const
1037 	throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
1038 {
1039 	return ::rtl::OUString();
1040 }
1041 
1042 //------------------------------------------------------------------------------
setFetchDirection(sal_Int32)1043 void OResultSet::setFetchDirection(sal_Int32 /*_par0*/)
1044 	throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
1045 {
1046     ::dbtools::throwFeatureNotImplementedException( "ResultSet::FetchDirection", *this );
1047 }
1048 //------------------------------------------------------------------------------
setFetchSize(sal_Int32 _par0)1049 void OResultSet::setFetchSize(sal_Int32 _par0)
1050 	throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
1051 {
1052 	m_pRecordSet->put_CacheSize(_par0);
1053 }
1054 // -------------------------------------------------------------------------
createArrayHelper() const1055 ::cppu::IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
1056 {
1057 	Sequence< com::sun::star::beans::Property > aProps(5);
1058 	com::sun::star::beans::Property* pProperties = aProps.getArray();
1059 	sal_Int32 nPos = 0;
1060 
1061 	//	DECL_PROP1IMPL(CURSORNAME,			::rtl::OUString) PropertyAttribute::READONLY);
1062 	DECL_PROP0(FETCHDIRECTION,			sal_Int32);
1063 	DECL_PROP0(FETCHSIZE,				sal_Int32);
1064 	DECL_BOOL_PROP1IMPL(ISBOOKMARKABLE) PropertyAttribute::READONLY);
1065 	DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY);
1066 	DECL_PROP1IMPL(RESULTSETTYPE,		sal_Int32) PropertyAttribute::READONLY);
1067 
1068 	return new ::cppu::OPropertyArrayHelper(aProps);
1069 }
1070 // -------------------------------------------------------------------------
getInfoHelper()1071 ::cppu::IPropertyArrayHelper & OResultSet::getInfoHelper()
1072 {
1073 	return *const_cast<OResultSet*>(this)->getArrayHelper();
1074 }
1075 // -------------------------------------------------------------------------
convertFastPropertyValue(Any & rConvertedValue,Any & rOldValue,sal_Int32 nHandle,const Any & rValue)1076 sal_Bool OResultSet::convertFastPropertyValue(
1077 							Any & rConvertedValue,
1078 							Any & rOldValue,
1079 							sal_Int32 nHandle,
1080 							const Any& rValue )
1081 								throw (::com::sun::star::lang::IllegalArgumentException)
1082 {
1083 	switch(nHandle)
1084 	{
1085 		case PROPERTY_ID_ISBOOKMARKABLE:
1086 		case PROPERTY_ID_CURSORNAME:
1087 		case PROPERTY_ID_RESULTSETCONCURRENCY:
1088 		case PROPERTY_ID_RESULTSETTYPE:
1089 			throw ::com::sun::star::lang::IllegalArgumentException();
1090 			break;
1091 		case PROPERTY_ID_FETCHDIRECTION:
1092 			return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
1093 		case PROPERTY_ID_FETCHSIZE:
1094 			return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
1095 		default:
1096 			;
1097 	}
1098 	return sal_False;
1099 }
1100 // -------------------------------------------------------------------------
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any & rValue)1101 void OResultSet::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception)
1102 {
1103 	switch(nHandle)
1104 	{
1105 		case PROPERTY_ID_ISBOOKMARKABLE:
1106 		case PROPERTY_ID_CURSORNAME:
1107 		case PROPERTY_ID_RESULTSETCONCURRENCY:
1108 		case PROPERTY_ID_RESULTSETTYPE:
1109 			throw Exception();
1110 			break;
1111 		case PROPERTY_ID_FETCHDIRECTION:
1112 			setFetchDirection(getINT32(rValue));
1113 			break;
1114 		case PROPERTY_ID_FETCHSIZE:
1115 			setFetchSize(getINT32(rValue));
1116 			break;
1117 		default:
1118 			;
1119 	}
1120 }
1121 // -------------------------------------------------------------------------
getFastPropertyValue(Any & rValue,sal_Int32 nHandle) const1122 void OResultSet::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
1123 {
1124 	switch(nHandle)
1125 	{
1126 		case PROPERTY_ID_ISBOOKMARKABLE:
1127 			{
1128 				VARIANT_BOOL bBool;
1129 				m_pRecordSet->Supports(adBookmark,&bBool);
1130 				sal_Bool bRet = bBool == VARIANT_TRUE;
1131 				rValue.setValue(&bRet, ::getCppuBooleanType() );
1132 			}
1133 			break;
1134 		case PROPERTY_ID_CURSORNAME:
1135 			rValue <<= getCursorName();
1136 			break;
1137 		case PROPERTY_ID_RESULTSETCONCURRENCY:
1138 			rValue <<= getResultSetConcurrency();
1139 			break;
1140 		case PROPERTY_ID_RESULTSETTYPE:
1141 			rValue <<= getResultSetType();
1142 			break;
1143 		case PROPERTY_ID_FETCHDIRECTION:
1144 			rValue <<= getFetchDirection();
1145 			break;
1146 		case PROPERTY_ID_FETCHSIZE:
1147 			rValue <<= getFetchSize();
1148 			break;
1149 	}
1150 }
1151 // -----------------------------------------------------------------------------
acquire()1152 void SAL_CALL OResultSet::acquire() throw()
1153 {
1154 	OResultSet_BASE::acquire();
1155 }
1156 // -----------------------------------------------------------------------------
release()1157 void SAL_CALL OResultSet::release() throw()
1158 {
1159 	OResultSet_BASE::release();
1160 }
1161 // -----------------------------------------------------------------------------
getPropertySetInfo()1162 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException)
1163 {
1164 	return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
1165 }
1166 // -----------------------------------------------------------------------------
1167 
1168 
1169 
1170