Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <resultset.hxx>
21 : #include "dbastrings.hrc"
22 : #include "apitools.hxx"
23 : #include <com/sun/star/lang/DisposedException.hpp>
24 : #include <com/sun/star/sdbc/ResultSetType.hpp>
25 : #include <cppuhelper/supportsservice.hxx>
26 : #include <cppuhelper/queryinterface.hxx>
27 : #include <cppuhelper/typeprovider.hxx>
28 : #include <comphelper/property.hxx>
29 : #include <comphelper/sequence.hxx>
30 : #include <comphelper/types.hxx>
31 : #include <tools/debug.hxx>
32 : #include <tools/diagnose_ex.h>
33 : #include <datacolumn.hxx>
34 : #include <com/sun/star/beans/PropertyAttribute.hpp>
35 : #include <connectivity/dbexception.hxx>
36 : #include <connectivity/dbtools.hxx>
37 : #include <cppuhelper/exc_hlp.hxx>
38 : #include <osl/thread.h>
39 :
40 :
41 : using namespace ::com::sun::star::sdbc;
42 : using namespace ::com::sun::star::sdbcx;
43 : using namespace ::com::sun::star::beans;
44 : using namespace ::com::sun::star::uno;
45 : using namespace ::com::sun::star::lang;
46 : using namespace ::com::sun::star::container;
47 : using namespace ::cppu;
48 : using namespace ::osl;
49 : using namespace dbaccess;
50 : using namespace dbtools;
51 :
52 :
53 13519 : OResultSet::OResultSet(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& _xResultSet,
54 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xStatement,
55 : bool _bCaseSensitive)
56 : :OResultSetBase(m_aMutex)
57 : ,OPropertySetHelper(OResultSetBase::rBHelper)
58 : ,m_xDelegatorResultSet(_xResultSet)
59 : ,m_aWarnings( Reference< XWarningsSupplier >( _xResultSet, UNO_QUERY ) )
60 : ,m_nResultSetType(0)
61 : ,m_nResultSetConcurrency(0)
62 13519 : ,m_bIsBookmarkable(false)
63 : {
64 13519 : m_pColumns = new OColumns(*this, m_aMutex, _bCaseSensitive, ::std::vector< OUString>(), NULL,NULL);
65 :
66 : try
67 : {
68 13519 : m_aStatement = _xStatement;
69 13519 : m_xDelegatorResultSetUpdate.set(m_xDelegatorResultSet, css::uno::UNO_QUERY);
70 13519 : m_xDelegatorRow.set(m_xDelegatorResultSet, css::uno::UNO_QUERY);
71 13519 : m_xDelegatorRowUpdate.set(m_xDelegatorResultSet, css::uno::UNO_QUERY);
72 :
73 13519 : Reference< XPropertySet > xSet(m_xDelegatorResultSet, UNO_QUERY);
74 13519 : xSet->getPropertyValue(PROPERTY_RESULTSETTYPE) >>= m_nResultSetType;
75 13519 : xSet->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY) >>= m_nResultSetConcurrency;
76 :
77 : // test for Bookmarks
78 13519 : if (ResultSetType::FORWARD_ONLY != m_nResultSetType)
79 : {
80 38 : Reference <XPropertySetInfo > xInfo(xSet->getPropertySetInfo());
81 38 : if (xInfo->hasPropertyByName(PROPERTY_ISBOOKMARKABLE))
82 : {
83 29 : m_bIsBookmarkable = ::comphelper::getBOOL(xSet->getPropertyValue(PROPERTY_ISBOOKMARKABLE));
84 : OSL_ENSURE( !m_bIsBookmarkable || Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY).is(),
85 : "OResultSet::OResultSet: aggregate is inconsistent in it's bookmarkable attribute!" );
86 29 : m_bIsBookmarkable = m_bIsBookmarkable && Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY).is();
87 38 : }
88 13519 : }
89 : }
90 0 : catch (const Exception&)
91 : {
92 : }
93 13519 : }
94 :
95 40557 : OResultSet::~OResultSet()
96 : {
97 13519 : m_pColumns->acquire();
98 13519 : m_pColumns->disposing();
99 13519 : delete m_pColumns;
100 :
101 27038 : }
102 :
103 : // com::sun::star::lang::XTypeProvider
104 6 : Sequence< Type > OResultSet::getTypes() throw (RuntimeException, std::exception)
105 : {
106 6 : OTypeCollection aTypes(cppu::UnoType<XPropertySet>::get(),
107 12 : OResultSetBase::getTypes());
108 :
109 6 : return aTypes.getTypes();
110 : }
111 :
112 0 : Sequence< sal_Int8 > OResultSet::getImplementationId() throw (RuntimeException, std::exception)
113 : {
114 0 : return css::uno::Sequence<sal_Int8>();
115 : }
116 :
117 : // com::sun::star::uno::XInterface
118 55102 : Any OResultSet::queryInterface( const Type & rType ) throw (RuntimeException, std::exception)
119 : {
120 55102 : Any aIface = OResultSetBase::queryInterface( rType );
121 55102 : if (!aIface.hasValue())
122 27430 : aIface = ::cppu::queryInterface(
123 : rType,
124 13715 : static_cast< XPropertySet * >( this ));
125 :
126 55102 : return aIface;
127 : }
128 :
129 258529 : void OResultSet::acquire() throw ()
130 : {
131 258529 : OResultSetBase::acquire();
132 258529 : }
133 :
134 245010 : void OResultSet::release() throw ()
135 : {
136 245010 : OResultSetBase::release();
137 245010 : }
138 :
139 :
140 : // OResultSetBase
141 13519 : void OResultSet::disposing()
142 : {
143 13519 : OPropertySetHelper::disposing();
144 :
145 13519 : MutexGuard aGuard(m_aMutex);
146 :
147 : // free the columns
148 13519 : m_pColumns->disposing();
149 :
150 : // close the pending result set
151 13519 : Reference< XCloseable > (m_xDelegatorResultSet, UNO_QUERY)->close();
152 :
153 13519 : m_xDelegatorResultSet = NULL;
154 13519 : m_xDelegatorRow = NULL;
155 13519 : m_xDelegatorRowUpdate = NULL;
156 :
157 13519 : m_aStatement.clear();
158 13519 : }
159 :
160 : // XCloseable
161 0 : void OResultSet::close() throw( SQLException, RuntimeException, std::exception )
162 : {
163 : {
164 0 : MutexGuard aGuard( m_aMutex );
165 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
166 : }
167 0 : dispose();
168 0 : }
169 :
170 : // XServiceInfo
171 0 : OUString OResultSet::getImplementationName( ) throw(RuntimeException, std::exception)
172 : {
173 0 : return OUString("com.sun.star.sdb.OResultSet");
174 : }
175 :
176 0 : sal_Bool OResultSet::supportsService( const OUString& _rServiceName ) throw (RuntimeException, std::exception)
177 : {
178 0 : return cppu::supportsService(this, _rServiceName);
179 : }
180 :
181 0 : Sequence< OUString > OResultSet::getSupportedServiceNames( ) throw (RuntimeException, std::exception)
182 : {
183 0 : Sequence< OUString > aSNS( 2 );
184 0 : aSNS[0] = SERVICE_SDBC_RESULTSET;
185 0 : aSNS[1] = SERVICE_SDB_RESULTSET;
186 0 : return aSNS;
187 : }
188 :
189 : // com::sun::star::beans::XPropertySet
190 40 : Reference< XPropertySetInfo > OResultSet::getPropertySetInfo() throw (RuntimeException, std::exception)
191 : {
192 40 : return createPropertySetInfo( getInfoHelper() ) ;
193 : }
194 :
195 : // comphelper::OPropertyArrayUsageHelper
196 29 : ::cppu::IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
197 : {
198 29 : BEGIN_PROPERTY_HELPER(6)
199 29 : DECL_PROP1(CURSORNAME, OUString, READONLY);
200 29 : DECL_PROP0(FETCHDIRECTION, sal_Int32);
201 29 : DECL_PROP0(FETCHSIZE, sal_Int32);
202 29 : DECL_PROP1_BOOL(ISBOOKMARKABLE, READONLY);
203 29 : DECL_PROP1(RESULTSETCONCURRENCY, sal_Int32, READONLY);
204 29 : DECL_PROP1(RESULTSETTYPE, sal_Int32, READONLY);
205 29 : END_PROPERTY_HELPER();
206 : }
207 :
208 : // cppu::OPropertySetHelper
209 189 : ::cppu::IPropertyArrayHelper& OResultSet::getInfoHelper()
210 : {
211 189 : return *getArrayHelper();
212 : }
213 :
214 0 : sal_Bool OResultSet::convertFastPropertyValue(Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw( IllegalArgumentException )
215 : {
216 : // be lazy ...
217 0 : rConvertedValue = rValue;
218 0 : getFastPropertyValue( rOldValue, nHandle );
219 0 : return sal_True;
220 : }
221 :
222 0 : void OResultSet::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception, std::exception)
223 : {
224 : // set it for the driver result set
225 0 : Reference< XPropertySet > xSet(m_xDelegatorResultSet, UNO_QUERY);
226 0 : switch (nHandle)
227 : {
228 : case PROPERTY_ID_FETCHDIRECTION:
229 0 : xSet->setPropertyValue(PROPERTY_FETCHDIRECTION, rValue);
230 0 : break;
231 : case PROPERTY_ID_FETCHSIZE:
232 0 : xSet->setPropertyValue(PROPERTY_FETCHSIZE, rValue);
233 0 : break;
234 : default:
235 : SAL_WARN("dbaccess", "unknown Property");
236 0 : }
237 0 : }
238 :
239 62 : void OResultSet::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
240 : {
241 62 : switch (nHandle)
242 : {
243 : case PROPERTY_ID_ISBOOKMARKABLE:
244 : {
245 37 : sal_Bool bVal = m_bIsBookmarkable;
246 37 : rValue.setValue(&bVal, cppu::UnoType<bool>::get());
247 37 : } break;
248 : default:
249 : {
250 : // get the property name
251 25 : OUString aPropName;
252 : sal_Int16 nAttributes;
253 25 : const_cast<OResultSet*>(this)->getInfoHelper().
254 25 : fillPropertyMembersByHandle(&aPropName, &nAttributes, nHandle);
255 : OSL_ENSURE(!aPropName.isEmpty(), "property not found?");
256 :
257 : // now read the value
258 25 : rValue = Reference< XPropertySet >(m_xDelegatorResultSet, UNO_QUERY)->getPropertyValue(aPropName);
259 : }
260 : }
261 62 : }
262 :
263 : // XWarningsSupplier
264 1 : Any OResultSet::getWarnings() throw( SQLException, RuntimeException, std::exception )
265 : {
266 1 : MutexGuard aGuard(m_aMutex);
267 1 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
268 1 : return m_aWarnings.getWarnings();
269 : }
270 :
271 0 : void OResultSet::clearWarnings() throw( SQLException, RuntimeException, std::exception )
272 : {
273 0 : MutexGuard aGuard(m_aMutex);
274 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
275 0 : m_aWarnings.clearWarnings();
276 0 : }
277 :
278 : // ::com::sun::star::sdbc::XResultSetMetaDataSupplier
279 79 : Reference< XResultSetMetaData > OResultSet::getMetaData() throw( SQLException, RuntimeException, std::exception )
280 : {
281 79 : MutexGuard aGuard(m_aMutex);
282 79 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
283 :
284 79 : return Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData();
285 : }
286 :
287 : // ::com::sun::star::sdbc::XColumnLocate
288 3 : sal_Int32 OResultSet::findColumn(const OUString& columnName) throw( SQLException, RuntimeException, std::exception )
289 : {
290 3 : MutexGuard aGuard(m_aMutex);
291 3 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
292 :
293 3 : return Reference< XColumnLocate >(m_xDelegatorResultSet, UNO_QUERY)->findColumn(columnName);
294 : }
295 :
296 : namespace
297 : {
298 0 : static Reference< XDatabaseMetaData > lcl_getDBMetaDataFromStatement_nothrow( const Reference< XInterface >& _rxStatement )
299 : {
300 0 : Reference< XDatabaseMetaData > xDBMetaData;
301 : try
302 : {
303 0 : Reference< XStatement > xStatement( _rxStatement, UNO_QUERY );
304 0 : Reference< XPreparedStatement > xPreparedStatement( _rxStatement, UNO_QUERY );
305 0 : Reference< XConnection > xConn;
306 0 : if ( xStatement.is() )
307 0 : xConn = xStatement->getConnection();
308 0 : else if ( xPreparedStatement.is() )
309 0 : xConn = xPreparedStatement->getConnection();
310 0 : if ( xConn.is() )
311 0 : xDBMetaData = xConn->getMetaData();
312 : }
313 0 : catch( const Exception& )
314 : {
315 : DBG_UNHANDLED_EXCEPTION();
316 : }
317 0 : return xDBMetaData;
318 : }
319 : }
320 :
321 : // ::com::sun::star::sdbcx::XColumnsSupplier
322 0 : Reference< ::com::sun::star::container::XNameAccess > OResultSet::getColumns() throw( RuntimeException, std::exception )
323 : {
324 0 : MutexGuard aGuard(m_aMutex);
325 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
326 :
327 : // do we have to populate the columns
328 0 : if (!m_pColumns->isInitialized())
329 : {
330 : // get the metadata
331 0 : Reference< XResultSetMetaData > xMetaData = Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData();
332 :
333 0 : sal_Int32 nColCount = 0;
334 : // do we have columns
335 : try
336 : {
337 0 : Reference< XDatabaseMetaData > xDBMetaData( lcl_getDBMetaDataFromStatement_nothrow( getStatement() ) );
338 0 : nColCount = xMetaData->getColumnCount();
339 :
340 0 : for ( sal_Int32 i = 0; i < nColCount; ++i)
341 : {
342 : // retrieve the name of the column
343 0 : OUString sName = xMetaData->getColumnName(i + 1);
344 0 : ODataColumn* pColumn = new ODataColumn(xMetaData, m_xDelegatorRow, m_xDelegatorRowUpdate, i + 1, xDBMetaData);
345 :
346 : // don't silently assume that the name is unique - result set implementations
347 : // are allowed to return duplicate names, but we are required to have
348 : // unique column names
349 0 : if ( m_pColumns->hasByName( sName ) )
350 0 : sName = ::dbtools::createUniqueName( m_pColumns, sName );
351 :
352 0 : m_pColumns->append( sName, pColumn );
353 0 : }
354 : }
355 0 : catch ( const SQLException& )
356 : {
357 : DBG_UNHANDLED_EXCEPTION();
358 : }
359 0 : m_pColumns->setInitialized();
360 :
361 : #if OSL_DEBUG_LEVEL > 0
362 : // some sanity checks. Especially in case we auto-adjusted the column names above,
363 : // this might be reasonable
364 : try
365 : {
366 : const Reference< XNameAccess > xColNames( static_cast< XNameAccess* >( m_pColumns ), UNO_SET_THROW );
367 : const Sequence< OUString > aNames( xColNames->getElementNames() );
368 : SAL_WARN_IF( aNames.getLength() != nColCount, "dbaccess",
369 : "OResultSet::getColumns: invalid column count!" );
370 : for ( const OUString* pName = aNames.getConstArray();
371 : pName != aNames.getConstArray() + aNames.getLength();
372 : ++pName
373 : )
374 : {
375 : Reference< XPropertySet > xColProps( xColNames->getByName( *pName ), UNO_QUERY_THROW );
376 : OUString sName;
377 : OSL_VERIFY( xColProps->getPropertyValue( PROPERTY_NAME ) >>= sName );
378 : SAL_WARN_IF( sName != *pName, "dbaccess", "OResultSet::getColumns: invalid column name!" );
379 : }
380 :
381 : }
382 : catch( const Exception& )
383 : {
384 : DBG_UNHANDLED_EXCEPTION();
385 : }
386 : #endif
387 : }
388 0 : return m_pColumns;
389 : }
390 :
391 : // ::com::sun::star::sdbc::XRow
392 31760 : sal_Bool OResultSet::wasNull() throw( SQLException, RuntimeException, std::exception )
393 : {
394 31760 : MutexGuard aGuard(m_aMutex);
395 31760 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
396 :
397 31760 : return m_xDelegatorRow->wasNull();
398 : }
399 :
400 17449 : OUString OResultSet::getString(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
401 : {
402 17449 : MutexGuard aGuard(m_aMutex);
403 17449 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
404 :
405 17449 : return m_xDelegatorRow->getString(columnIndex);
406 : }
407 :
408 28 : sal_Bool OResultSet::getBoolean(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
409 : {
410 28 : MutexGuard aGuard(m_aMutex);
411 28 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
412 :
413 28 : return m_xDelegatorRow->getBoolean(columnIndex);
414 : }
415 :
416 0 : sal_Int8 OResultSet::getByte(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
417 : {
418 0 : MutexGuard aGuard(m_aMutex);
419 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
420 :
421 0 : return m_xDelegatorRow->getByte(columnIndex);
422 : }
423 :
424 0 : sal_Int16 OResultSet::getShort(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
425 : {
426 0 : MutexGuard aGuard(m_aMutex);
427 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
428 :
429 0 : return m_xDelegatorRow->getShort(columnIndex);
430 : }
431 :
432 14197 : sal_Int32 OResultSet::getInt(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
433 : {
434 14197 : MutexGuard aGuard(m_aMutex);
435 14197 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
436 :
437 14197 : return m_xDelegatorRow->getInt(columnIndex);
438 : }
439 :
440 0 : sal_Int64 OResultSet::getLong(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
441 : {
442 0 : MutexGuard aGuard(m_aMutex);
443 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
444 :
445 0 : return m_xDelegatorRow->getLong(columnIndex);
446 : }
447 :
448 0 : float OResultSet::getFloat(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
449 : {
450 0 : MutexGuard aGuard(m_aMutex);
451 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
452 :
453 0 : return m_xDelegatorRow->getFloat(columnIndex);
454 : }
455 :
456 0 : double OResultSet::getDouble(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
457 : {
458 0 : MutexGuard aGuard(m_aMutex);
459 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
460 :
461 0 : return m_xDelegatorRow->getDouble(columnIndex);
462 : }
463 :
464 0 : Sequence< sal_Int8 > OResultSet::getBytes(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
465 : {
466 0 : MutexGuard aGuard(m_aMutex);
467 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
468 :
469 0 : return m_xDelegatorRow->getBytes(columnIndex);
470 : }
471 :
472 92 : ::com::sun::star::util::Date OResultSet::getDate(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
473 : {
474 92 : MutexGuard aGuard(m_aMutex);
475 92 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
476 :
477 92 : return m_xDelegatorRow->getDate(columnIndex);
478 : }
479 :
480 0 : ::com::sun::star::util::Time OResultSet::getTime(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
481 : {
482 0 : MutexGuard aGuard(m_aMutex);
483 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
484 :
485 0 : return m_xDelegatorRow->getTime(columnIndex);
486 : }
487 :
488 0 : ::com::sun::star::util::DateTime OResultSet::getTimestamp(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
489 : {
490 0 : MutexGuard aGuard(m_aMutex);
491 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
492 :
493 0 : return m_xDelegatorRow->getTimestamp(columnIndex);
494 : }
495 :
496 0 : Reference< ::com::sun::star::io::XInputStream > OResultSet::getBinaryStream(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
497 : {
498 0 : MutexGuard aGuard(m_aMutex);
499 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
500 :
501 0 : return m_xDelegatorRow->getBinaryStream(columnIndex);
502 : }
503 :
504 0 : Reference< ::com::sun::star::io::XInputStream > OResultSet::getCharacterStream(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
505 : {
506 0 : MutexGuard aGuard(m_aMutex);
507 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
508 :
509 0 : return m_xDelegatorRow->getCharacterStream(columnIndex);
510 : }
511 :
512 0 : Any OResultSet::getObject(sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess > & typeMap) throw( SQLException, RuntimeException, std::exception )
513 : {
514 0 : MutexGuard aGuard(m_aMutex);
515 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
516 :
517 0 : return m_xDelegatorRow->getObject(columnIndex, typeMap);
518 : }
519 :
520 0 : Reference< XRef > OResultSet::getRef(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
521 : {
522 0 : MutexGuard aGuard(m_aMutex);
523 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
524 :
525 0 : return m_xDelegatorRow->getRef(columnIndex);
526 : }
527 :
528 0 : Reference< XBlob > OResultSet::getBlob(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
529 : {
530 0 : MutexGuard aGuard(m_aMutex);
531 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
532 :
533 0 : return m_xDelegatorRow->getBlob(columnIndex);
534 : }
535 :
536 0 : Reference< XClob > OResultSet::getClob(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
537 : {
538 0 : MutexGuard aGuard(m_aMutex);
539 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
540 :
541 0 : return m_xDelegatorRow->getClob(columnIndex);
542 : }
543 :
544 0 : Reference< XArray > OResultSet::getArray(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
545 : {
546 0 : MutexGuard aGuard(m_aMutex);
547 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
548 :
549 0 : return m_xDelegatorRow->getArray(columnIndex);
550 : }
551 :
552 : // ::com::sun::star::sdbc::XRowUpdate
553 0 : void OResultSet::updateNull(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
554 : {
555 0 : MutexGuard aGuard(m_aMutex);
556 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
557 :
558 0 : checkReadOnly();
559 :
560 0 : m_xDelegatorRowUpdate->updateNull(columnIndex);
561 0 : }
562 :
563 0 : void OResultSet::updateBoolean(sal_Int32 columnIndex, sal_Bool x) throw( SQLException, RuntimeException, std::exception )
564 : {
565 0 : MutexGuard aGuard(m_aMutex);
566 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
567 :
568 0 : checkReadOnly();
569 :
570 0 : m_xDelegatorRowUpdate->updateBoolean(columnIndex, x);
571 0 : }
572 :
573 0 : void OResultSet::updateByte(sal_Int32 columnIndex, sal_Int8 x) throw( SQLException, RuntimeException, std::exception )
574 : {
575 0 : MutexGuard aGuard(m_aMutex);
576 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
577 :
578 0 : checkReadOnly();
579 :
580 0 : m_xDelegatorRowUpdate->updateByte(columnIndex, x);
581 0 : }
582 :
583 0 : void OResultSet::updateShort(sal_Int32 columnIndex, sal_Int16 x) throw( SQLException, RuntimeException, std::exception )
584 : {
585 0 : MutexGuard aGuard(m_aMutex);
586 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
587 :
588 0 : checkReadOnly();
589 :
590 0 : m_xDelegatorRowUpdate->updateShort(columnIndex, x);
591 0 : }
592 :
593 0 : void OResultSet::updateInt(sal_Int32 columnIndex, sal_Int32 x) throw( SQLException, RuntimeException, std::exception )
594 : {
595 0 : MutexGuard aGuard(m_aMutex);
596 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
597 :
598 0 : checkReadOnly();
599 :
600 0 : m_xDelegatorRowUpdate->updateInt(columnIndex, x);
601 0 : }
602 :
603 0 : void OResultSet::updateLong(sal_Int32 columnIndex, sal_Int64 x) throw( SQLException, RuntimeException, std::exception )
604 : {
605 0 : MutexGuard aGuard(m_aMutex);
606 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
607 :
608 0 : checkReadOnly();
609 :
610 0 : m_xDelegatorRowUpdate->updateLong(columnIndex, x);
611 0 : }
612 :
613 0 : void OResultSet::updateFloat(sal_Int32 columnIndex, float x) throw( SQLException, RuntimeException, std::exception )
614 : {
615 0 : MutexGuard aGuard(m_aMutex);
616 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
617 :
618 0 : checkReadOnly();
619 :
620 0 : m_xDelegatorRowUpdate->updateFloat(columnIndex, x);
621 0 : }
622 :
623 0 : void OResultSet::updateDouble(sal_Int32 columnIndex, double x) throw( SQLException, RuntimeException, std::exception )
624 : {
625 0 : MutexGuard aGuard(m_aMutex);
626 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
627 :
628 0 : checkReadOnly();
629 :
630 0 : m_xDelegatorRowUpdate->updateDouble(columnIndex, x);
631 0 : }
632 :
633 5 : void OResultSet::updateString(sal_Int32 columnIndex, const OUString& x) throw( SQLException, RuntimeException, std::exception )
634 : {
635 5 : MutexGuard aGuard(m_aMutex);
636 5 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
637 :
638 5 : checkReadOnly();
639 :
640 5 : m_xDelegatorRowUpdate->updateString(columnIndex, x);
641 5 : }
642 :
643 0 : void OResultSet::updateBytes(sal_Int32 columnIndex, const Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException, std::exception )
644 : {
645 0 : MutexGuard aGuard(m_aMutex);
646 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
647 :
648 0 : checkReadOnly();
649 :
650 0 : m_xDelegatorRowUpdate->updateBytes(columnIndex, x);
651 0 : }
652 :
653 0 : void OResultSet::updateDate(sal_Int32 columnIndex, const ::com::sun::star::util::Date& x) throw( SQLException, RuntimeException, std::exception )
654 : {
655 0 : MutexGuard aGuard(m_aMutex);
656 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
657 :
658 0 : checkReadOnly();
659 :
660 0 : m_xDelegatorRowUpdate->updateDate(columnIndex, x);
661 0 : }
662 :
663 0 : void OResultSet::updateTime(sal_Int32 columnIndex, const ::com::sun::star::util::Time& x) throw( SQLException, RuntimeException, std::exception )
664 : {
665 0 : MutexGuard aGuard(m_aMutex);
666 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
667 :
668 0 : checkReadOnly();
669 :
670 0 : m_xDelegatorRowUpdate->updateTime(columnIndex, x);
671 0 : }
672 :
673 0 : void OResultSet::updateTimestamp(sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x) throw( SQLException, RuntimeException, std::exception )
674 : {
675 0 : MutexGuard aGuard(m_aMutex);
676 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
677 :
678 0 : checkReadOnly();
679 :
680 0 : m_xDelegatorRowUpdate->updateTimestamp(columnIndex, x);
681 0 : }
682 :
683 0 : void OResultSet::updateBinaryStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException, std::exception )
684 : {
685 0 : MutexGuard aGuard(m_aMutex);
686 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
687 :
688 0 : checkReadOnly();
689 :
690 0 : m_xDelegatorRowUpdate->updateBinaryStream(columnIndex, x, length);
691 0 : }
692 :
693 0 : void OResultSet::updateCharacterStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException, std::exception )
694 : {
695 0 : MutexGuard aGuard(m_aMutex);
696 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
697 :
698 0 : checkReadOnly();
699 :
700 0 : m_xDelegatorRowUpdate->updateCharacterStream(columnIndex, x, length);
701 0 : }
702 :
703 0 : void OResultSet::updateNumericObject(sal_Int32 columnIndex, const Any& x, sal_Int32 scale) throw( SQLException, RuntimeException, std::exception )
704 : {
705 0 : MutexGuard aGuard(m_aMutex);
706 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
707 :
708 0 : checkReadOnly();
709 :
710 0 : m_xDelegatorRowUpdate->updateNumericObject(columnIndex, x, scale);
711 0 : }
712 :
713 0 : void OResultSet::updateObject(sal_Int32 columnIndex, const Any& x) throw( SQLException, RuntimeException, std::exception )
714 : {
715 0 : MutexGuard aGuard(m_aMutex);
716 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
717 :
718 0 : checkReadOnly();
719 :
720 0 : m_xDelegatorRowUpdate->updateObject(columnIndex, x);
721 0 : }
722 :
723 : // ::com::sun::star::sdbc::XResultSet
724 14246 : sal_Bool OResultSet::next() throw( SQLException, RuntimeException, std::exception )
725 : {
726 14246 : MutexGuard aGuard(m_aMutex);
727 14246 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
728 :
729 14246 : return m_xDelegatorResultSet->next();
730 : }
731 :
732 0 : sal_Bool OResultSet::isBeforeFirst() throw( SQLException, RuntimeException, std::exception )
733 : {
734 0 : MutexGuard aGuard(m_aMutex);
735 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
736 :
737 0 : return m_xDelegatorResultSet->isBeforeFirst();
738 : }
739 :
740 0 : sal_Bool OResultSet::isAfterLast() throw( SQLException, RuntimeException, std::exception )
741 : {
742 0 : MutexGuard aGuard(m_aMutex);
743 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
744 :
745 0 : return m_xDelegatorResultSet->isAfterLast();
746 : }
747 :
748 0 : sal_Bool OResultSet::isFirst() throw( SQLException, RuntimeException, std::exception )
749 : {
750 0 : MutexGuard aGuard(m_aMutex);
751 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
752 :
753 0 : return m_xDelegatorResultSet->isFirst();
754 : }
755 :
756 0 : sal_Bool OResultSet::isLast() throw( SQLException, RuntimeException, std::exception )
757 : {
758 0 : MutexGuard aGuard(m_aMutex);
759 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
760 :
761 0 : return m_xDelegatorResultSet->isLast();
762 : }
763 :
764 51 : void OResultSet::beforeFirst() throw( SQLException, RuntimeException, std::exception )
765 : {
766 51 : MutexGuard aGuard(m_aMutex);
767 51 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
768 :
769 51 : m_xDelegatorResultSet->beforeFirst();
770 51 : }
771 :
772 5 : void OResultSet::afterLast() throw( SQLException, RuntimeException, std::exception )
773 : {
774 5 : MutexGuard aGuard(m_aMutex);
775 5 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
776 :
777 5 : m_xDelegatorResultSet->afterLast();
778 5 : }
779 :
780 35 : sal_Bool OResultSet::first() throw( SQLException, RuntimeException, std::exception )
781 : {
782 35 : MutexGuard aGuard(m_aMutex);
783 35 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
784 :
785 35 : return m_xDelegatorResultSet->first();
786 : }
787 :
788 4 : sal_Bool OResultSet::last() throw( SQLException, RuntimeException, std::exception )
789 : {
790 4 : MutexGuard aGuard(m_aMutex);
791 4 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
792 :
793 4 : return m_xDelegatorResultSet->last();
794 : }
795 :
796 40 : sal_Int32 OResultSet::getRow() throw( SQLException, RuntimeException, std::exception )
797 : {
798 40 : MutexGuard aGuard(m_aMutex);
799 40 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
800 :
801 40 : return m_xDelegatorResultSet->getRow();
802 : }
803 :
804 82 : sal_Bool OResultSet::absolute(sal_Int32 row) throw( SQLException, RuntimeException, std::exception )
805 : {
806 82 : MutexGuard aGuard(m_aMutex);
807 82 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
808 :
809 82 : return m_xDelegatorResultSet->absolute(row);
810 : }
811 :
812 0 : sal_Bool OResultSet::relative(sal_Int32 rows) throw( SQLException, RuntimeException, std::exception )
813 : {
814 0 : MutexGuard aGuard(m_aMutex);
815 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
816 :
817 0 : return m_xDelegatorResultSet->relative(rows);
818 : }
819 :
820 29 : sal_Bool OResultSet::previous() throw( SQLException, RuntimeException, std::exception )
821 : {
822 29 : MutexGuard aGuard(m_aMutex);
823 29 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
824 :
825 29 : return m_xDelegatorResultSet->previous();
826 : }
827 :
828 1 : void OResultSet::refreshRow() throw( SQLException, RuntimeException, std::exception )
829 : {
830 1 : MutexGuard aGuard(m_aMutex);
831 1 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
832 :
833 1 : m_xDelegatorResultSet->refreshRow();
834 1 : }
835 :
836 1 : sal_Bool OResultSet::rowUpdated() throw( SQLException, RuntimeException, std::exception )
837 : {
838 1 : MutexGuard aGuard(m_aMutex);
839 1 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
840 :
841 1 : return m_xDelegatorResultSet->rowUpdated();
842 : }
843 :
844 2 : sal_Bool OResultSet::rowInserted() throw( SQLException, RuntimeException, std::exception )
845 : {
846 2 : MutexGuard aGuard(m_aMutex);
847 2 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
848 :
849 2 : return m_xDelegatorResultSet->rowInserted();
850 : }
851 :
852 1 : sal_Bool OResultSet::rowDeleted() throw( SQLException, RuntimeException, std::exception )
853 : {
854 1 : MutexGuard aGuard(m_aMutex);
855 1 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
856 :
857 1 : return m_xDelegatorResultSet->rowDeleted();
858 : }
859 :
860 110 : Reference< XInterface > OResultSet::getStatement() throw( SQLException, RuntimeException, std::exception )
861 : {
862 110 : MutexGuard aGuard(m_aMutex);
863 110 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
864 :
865 110 : return m_aStatement;
866 : }
867 :
868 : // ::com::sun::star::sdbcx::XRowLocate
869 239 : Any OResultSet::getBookmark() throw( SQLException, RuntimeException, std::exception )
870 : {
871 239 : MutexGuard aGuard(m_aMutex);
872 239 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
873 :
874 239 : checkBookmarkable();
875 :
876 239 : return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->getBookmark();
877 : }
878 :
879 12 : sal_Bool OResultSet::moveToBookmark(const Any& bookmark) throw( SQLException, RuntimeException, std::exception )
880 : {
881 12 : MutexGuard aGuard(m_aMutex);
882 12 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
883 :
884 12 : checkBookmarkable();
885 :
886 12 : return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveToBookmark(bookmark);
887 : }
888 :
889 0 : sal_Bool OResultSet::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( SQLException, RuntimeException, std::exception )
890 : {
891 0 : MutexGuard aGuard(m_aMutex);
892 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
893 :
894 0 : checkBookmarkable();
895 :
896 0 : return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveRelativeToBookmark(bookmark, rows);
897 : }
898 :
899 536 : sal_Int32 OResultSet::compareBookmarks(const Any& _first, const Any& _second) throw( SQLException, RuntimeException, std::exception )
900 : {
901 536 : MutexGuard aGuard(m_aMutex);
902 536 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
903 :
904 536 : checkBookmarkable();
905 :
906 536 : return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->compareBookmarks(_first, _second);
907 : }
908 :
909 1 : sal_Bool OResultSet::hasOrderedBookmarks() throw( SQLException, RuntimeException, std::exception )
910 : {
911 1 : MutexGuard aGuard(m_aMutex);
912 1 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
913 :
914 1 : checkBookmarkable();
915 :
916 1 : return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hasOrderedBookmarks();
917 : }
918 :
919 2 : sal_Int32 OResultSet::hashBookmark(const Any& bookmark) throw( SQLException, RuntimeException, std::exception )
920 : {
921 2 : MutexGuard aGuard(m_aMutex);
922 2 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
923 :
924 2 : checkBookmarkable();
925 :
926 2 : return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hashBookmark(bookmark);
927 : }
928 :
929 : // ::com::sun::star::sdbc::XResultSetUpdate
930 1 : void OResultSet::insertRow() throw( SQLException, RuntimeException, std::exception )
931 : {
932 1 : MutexGuard aGuard(m_aMutex);
933 1 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
934 :
935 1 : checkReadOnly();
936 :
937 1 : m_xDelegatorResultSetUpdate->insertRow();
938 1 : }
939 :
940 4 : void OResultSet::updateRow() throw( SQLException, RuntimeException, std::exception )
941 : {
942 4 : MutexGuard aGuard(m_aMutex);
943 4 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
944 :
945 4 : checkReadOnly();
946 :
947 4 : m_xDelegatorResultSetUpdate->updateRow();
948 4 : }
949 :
950 1 : void OResultSet::deleteRow() throw( SQLException, RuntimeException, std::exception )
951 : {
952 1 : MutexGuard aGuard(m_aMutex);
953 1 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
954 :
955 1 : checkReadOnly();
956 :
957 1 : m_xDelegatorResultSetUpdate->deleteRow();
958 1 : }
959 :
960 20 : void OResultSet::cancelRowUpdates() throw( SQLException, RuntimeException, std::exception )
961 : {
962 20 : MutexGuard aGuard(m_aMutex);
963 20 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
964 :
965 20 : checkReadOnly();
966 :
967 20 : m_xDelegatorResultSetUpdate->cancelRowUpdates();
968 20 : }
969 :
970 29 : void OResultSet::moveToInsertRow() throw( SQLException, RuntimeException, std::exception )
971 : {
972 29 : MutexGuard aGuard(m_aMutex);
973 29 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
974 :
975 29 : checkReadOnly();
976 :
977 29 : m_xDelegatorResultSetUpdate->moveToInsertRow();
978 21 : }
979 :
980 0 : void OResultSet::moveToCurrentRow() throw( SQLException, RuntimeException, std::exception )
981 : {
982 0 : MutexGuard aGuard(m_aMutex);
983 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
984 :
985 0 : checkReadOnly();
986 :
987 0 : m_xDelegatorResultSetUpdate->moveToCurrentRow();
988 0 : }
989 :
990 60 : void OResultSet::checkReadOnly() const
991 : {
992 120 : if ( ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
993 60 : || !m_xDelegatorResultSetUpdate.is()
994 : )
995 16 : throwSQLException( "The result set is read-only.", SQL_GENERAL_ERROR, *const_cast< OResultSet* >( this ) );
996 52 : }
997 :
998 790 : void OResultSet::checkBookmarkable() const
999 : {
1000 790 : if ( !m_bIsBookmarkable )
1001 0 : throwSQLException( "The result set does not have bookmark support.", SQL_GENERAL_ERROR, *const_cast< OResultSet* >( this ) );
1002 790 : }
1003 :
1004 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|