1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "resultset.hxx"
21 #include <sal/log.hxx>
22 #include <stringconstants.hxx>
23 #include <apitools.hxx>
24 #include <com/sun/star/sdbc/ResultSetType.hpp>
25 #include <com/sun/star/sdbc/SQLException.hpp>
26 #include <cppuhelper/supportsservice.hxx>
27 #include <cppuhelper/queryinterface.hxx>
28 #include <cppuhelper/typeprovider.hxx>
29 #include <comphelper/types.hxx>
30 #include <tools/diagnose_ex.h>
31 #include "datacolumn.hxx"
32 #include <connectivity/dbexception.hxx>
33 #include <connectivity/dbtools.hxx>
36 using namespace ::com::sun::star::sdbc
;
37 using namespace ::com::sun::star::sdbcx
;
38 using namespace ::com::sun::star::beans
;
39 using namespace ::com::sun::star::uno
;
40 using namespace ::com::sun::star::lang
;
41 using namespace ::com::sun::star::container
;
42 using namespace ::cppu
;
43 using namespace ::osl
;
44 using namespace dbaccess
;
45 using namespace dbtools
;
48 OResultSet::OResultSet(const css::uno::Reference
< css::sdbc::XResultSet
>& _xResultSet
,
49 const css::uno::Reference
< css::uno::XInterface
>& _xStatement
,
51 :OResultSetBase(m_aMutex
)
52 ,OPropertySetHelper(OResultSetBase::rBHelper
)
53 ,m_xDelegatorResultSet(_xResultSet
)
54 ,m_aWarnings( Reference
< XWarningsSupplier
>( _xResultSet
, UNO_QUERY
) )
55 ,m_nResultSetConcurrency(0)
56 ,m_bIsBookmarkable(false)
58 m_pColumns
.reset( new OColumns(*this, m_aMutex
, _bCaseSensitive
, std::vector
< OUString
>(), nullptr,nullptr) );
62 m_aStatement
= _xStatement
;
63 m_xDelegatorResultSetUpdate
.set(m_xDelegatorResultSet
, css::uno::UNO_QUERY
);
64 m_xDelegatorRow
.set(m_xDelegatorResultSet
, css::uno::UNO_QUERY
);
65 m_xDelegatorRowUpdate
.set(m_xDelegatorResultSet
, css::uno::UNO_QUERY
);
67 Reference
< XPropertySet
> xSet(m_xDelegatorResultSet
, UNO_QUERY
);
68 sal_Int32
nResultSetType(0);
69 xSet
->getPropertyValue(PROPERTY_RESULTSETTYPE
) >>= nResultSetType
;
70 xSet
->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY
) >>= m_nResultSetConcurrency
;
73 if (ResultSetType::FORWARD_ONLY
!= nResultSetType
)
75 Reference
<XPropertySetInfo
> xInfo(xSet
->getPropertySetInfo());
76 if (xInfo
->hasPropertyByName(PROPERTY_ISBOOKMARKABLE
))
78 m_bIsBookmarkable
= ::comphelper::getBOOL(xSet
->getPropertyValue(PROPERTY_ISBOOKMARKABLE
));
79 OSL_ENSURE( !m_bIsBookmarkable
|| Reference
< XRowLocate
>(m_xDelegatorResultSet
, UNO_QUERY
).is(),
80 "OResultSet::OResultSet: aggregate is inconsistent in its bookmarkable attribute!" );
81 m_bIsBookmarkable
= m_bIsBookmarkable
&& Reference
< XRowLocate
>(m_xDelegatorResultSet
, UNO_QUERY
).is();
85 catch (const Exception
&)
90 OResultSet::~OResultSet()
92 m_pColumns
->acquire();
93 m_pColumns
->disposing();
96 // css::lang::XTypeProvider
97 Sequence
< Type
> OResultSet::getTypes()
99 OTypeCollection
aTypes(cppu::UnoType
<XPropertySet
>::get(),
100 OResultSetBase::getTypes());
102 return aTypes
.getTypes();
105 Sequence
< sal_Int8
> OResultSet::getImplementationId()
107 return css::uno::Sequence
<sal_Int8
>();
110 // css::uno::XInterface
111 Any
OResultSet::queryInterface( const Type
& rType
)
113 Any aIface
= OResultSetBase::queryInterface( rType
);
114 if (!aIface
.hasValue())
115 aIface
= ::cppu::queryInterface(
117 static_cast< XPropertySet
* >( this ));
122 void OResultSet::acquire() throw ()
124 OResultSetBase::acquire();
127 void OResultSet::release() throw ()
129 OResultSetBase::release();
134 void OResultSet::disposing()
136 OPropertySetHelper::disposing();
138 MutexGuard
aGuard(m_aMutex
);
141 m_pColumns
->disposing();
143 // close the pending result set
144 Reference
< XCloseable
> (m_xDelegatorResultSet
, UNO_QUERY_THROW
)->close();
146 m_xDelegatorResultSet
= nullptr;
147 m_xDelegatorRow
= nullptr;
148 m_xDelegatorRowUpdate
= nullptr;
150 m_aStatement
.clear();
154 void OResultSet::close()
157 MutexGuard
aGuard( m_aMutex
);
158 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
164 OUString
OResultSet::getImplementationName( )
166 return "com.sun.star.sdb.OResultSet";
169 sal_Bool
OResultSet::supportsService( const OUString
& _rServiceName
)
171 return cppu::supportsService(this, _rServiceName
);
174 Sequence
< OUString
> OResultSet::getSupportedServiceNames( )
176 return { SERVICE_SDBC_RESULTSET
, SERVICE_SDB_RESULTSET
};
179 // css::beans::XPropertySet
180 Reference
< XPropertySetInfo
> OResultSet::getPropertySetInfo()
182 return createPropertySetInfo( getInfoHelper() ) ;
185 // comphelper::OPropertyArrayUsageHelper
186 ::cppu::IPropertyArrayHelper
* OResultSet::createArrayHelper( ) const
188 BEGIN_PROPERTY_HELPER(6)
189 DECL_PROP1(CURSORNAME
, OUString
, READONLY
);
190 DECL_PROP0(FETCHDIRECTION
, sal_Int32
);
191 DECL_PROP0(FETCHSIZE
, sal_Int32
);
192 DECL_PROP1_BOOL(ISBOOKMARKABLE
, READONLY
);
193 DECL_PROP1(RESULTSETCONCURRENCY
, sal_Int32
, READONLY
);
194 DECL_PROP1(RESULTSETTYPE
, sal_Int32
, READONLY
);
195 END_PROPERTY_HELPER();
198 // cppu::OPropertySetHelper
199 ::cppu::IPropertyArrayHelper
& OResultSet::getInfoHelper()
201 return *getArrayHelper();
204 sal_Bool
OResultSet::convertFastPropertyValue(Any
& rConvertedValue
, Any
& rOldValue
, sal_Int32 nHandle
, const Any
& rValue
)
207 rConvertedValue
= rValue
;
208 getFastPropertyValue( rOldValue
, nHandle
);
212 void OResultSet::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const Any
& rValue
)
214 // set it for the driver result set
215 Reference
< XPropertySet
> xSet(m_xDelegatorResultSet
, UNO_QUERY
);
218 case PROPERTY_ID_FETCHDIRECTION
:
219 xSet
->setPropertyValue(PROPERTY_FETCHDIRECTION
, rValue
);
221 case PROPERTY_ID_FETCHSIZE
:
222 xSet
->setPropertyValue(PROPERTY_FETCHSIZE
, rValue
);
225 SAL_WARN("dbaccess", "unknown Property");
229 void OResultSet::getFastPropertyValue( Any
& rValue
, sal_Int32 nHandle
) const
233 case PROPERTY_ID_ISBOOKMARKABLE
:
235 rValue
<<= m_bIsBookmarkable
;
239 // get the property name
241 sal_Int16 nAttributes
;
242 const_cast<OResultSet
*>(this)->getInfoHelper().
243 fillPropertyMembersByHandle(&aPropName
, &nAttributes
, nHandle
);
244 OSL_ENSURE(!aPropName
.isEmpty(), "property not found?");
246 // now read the value
247 rValue
= Reference
< XPropertySet
>(m_xDelegatorResultSet
, UNO_QUERY_THROW
)->getPropertyValue(aPropName
);
253 Any
OResultSet::getWarnings()
255 MutexGuard
aGuard(m_aMutex
);
256 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
257 return m_aWarnings
.getWarnings();
260 void OResultSet::clearWarnings()
262 MutexGuard
aGuard(m_aMutex
);
263 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
264 m_aWarnings
.clearWarnings();
267 // css::sdbc::XResultSetMetaDataSupplier
268 Reference
< XResultSetMetaData
> OResultSet::getMetaData()
270 MutexGuard
aGuard(m_aMutex
);
271 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
273 return Reference
< XResultSetMetaDataSupplier
>(m_xDelegatorResultSet
, UNO_QUERY_THROW
)->getMetaData();
276 // css::sdbc::XColumnLocate
277 sal_Int32
OResultSet::findColumn(const OUString
& columnName
)
279 MutexGuard
aGuard(m_aMutex
);
280 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
282 return Reference
< XColumnLocate
>(m_xDelegatorResultSet
, UNO_QUERY_THROW
)->findColumn(columnName
);
287 Reference
< XDatabaseMetaData
> lcl_getDBMetaDataFromStatement_nothrow( const Reference
< XInterface
>& _rxStatement
)
289 Reference
< XDatabaseMetaData
> xDBMetaData
;
292 Reference
< XStatement
> xStatement( _rxStatement
, UNO_QUERY
);
293 Reference
< XPreparedStatement
> xPreparedStatement( _rxStatement
, UNO_QUERY
);
294 Reference
< XConnection
> xConn
;
295 if ( xStatement
.is() )
296 xConn
= xStatement
->getConnection();
297 else if ( xPreparedStatement
.is() )
298 xConn
= xPreparedStatement
->getConnection();
300 xDBMetaData
= xConn
->getMetaData();
302 catch( const Exception
& )
304 DBG_UNHANDLED_EXCEPTION("dbaccess");
310 // css::sdbcx::XColumnsSupplier
311 Reference
< css::container::XNameAccess
> OResultSet::getColumns()
313 MutexGuard
aGuard(m_aMutex
);
314 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
316 // do we have to populate the columns
317 if (!m_pColumns
->isInitialized())
320 Reference
< XResultSetMetaData
> xMetaData
= Reference
< XResultSetMetaDataSupplier
>(m_xDelegatorResultSet
, UNO_QUERY_THROW
)->getMetaData();
322 sal_Int32 nColCount
= 0;
323 // do we have columns
326 Reference
< XDatabaseMetaData
> xDBMetaData( lcl_getDBMetaDataFromStatement_nothrow( getStatement() ) );
327 nColCount
= xMetaData
->getColumnCount();
329 for ( sal_Int32 i
= 0; i
< nColCount
; ++i
)
331 // retrieve the name of the column
332 OUString sName
= xMetaData
->getColumnName(i
+ 1);
333 ODataColumn
* pColumn
= new ODataColumn(xMetaData
, m_xDelegatorRow
, m_xDelegatorRowUpdate
, i
+ 1, xDBMetaData
);
335 // don't silently assume that the name is unique - result set implementations
336 // are allowed to return duplicate names, but we are required to have
337 // unique column names
338 if ( m_pColumns
->hasByName( sName
) )
339 sName
= ::dbtools::createUniqueName( m_pColumns
.get(), sName
);
341 m_pColumns
->append( sName
, pColumn
);
344 catch ( const SQLException
& )
346 DBG_UNHANDLED_EXCEPTION("dbaccess");
348 m_pColumns
->setInitialized();
350 #if OSL_DEBUG_LEVEL > 0
351 // some sanity checks. Especially in case we auto-adjusted the column names above,
352 // this might be reasonable
355 const Reference
< XNameAccess
> xColNames( static_cast< XNameAccess
* >( m_pColumns
.get() ), UNO_SET_THROW
);
356 const Sequence
< OUString
> aNames( xColNames
->getElementNames() );
357 SAL_WARN_IF( aNames
.getLength() != nColCount
, "dbaccess",
358 "OResultSet::getColumns: invalid column count!" );
359 for ( auto const & name
: aNames
)
361 Reference
< XPropertySet
> xColProps( xColNames
->getByName( name
), UNO_QUERY_THROW
);
363 OSL_VERIFY( xColProps
->getPropertyValue( PROPERTY_NAME
) >>= sName
);
364 SAL_WARN_IF( sName
!= name
, "dbaccess", "OResultSet::getColumns: invalid column name!" );
368 catch( const Exception
& )
370 DBG_UNHANDLED_EXCEPTION("dbaccess");
374 return m_pColumns
.get();
378 sal_Bool
OResultSet::wasNull()
380 MutexGuard
aGuard(m_aMutex
);
381 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
383 return m_xDelegatorRow
->wasNull();
386 OUString
OResultSet::getString(sal_Int32 columnIndex
)
388 MutexGuard
aGuard(m_aMutex
);
389 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
391 return m_xDelegatorRow
->getString(columnIndex
);
394 sal_Bool
OResultSet::getBoolean(sal_Int32 columnIndex
)
396 MutexGuard
aGuard(m_aMutex
);
397 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
399 return m_xDelegatorRow
->getBoolean(columnIndex
);
402 sal_Int8
OResultSet::getByte(sal_Int32 columnIndex
)
404 MutexGuard
aGuard(m_aMutex
);
405 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
407 return m_xDelegatorRow
->getByte(columnIndex
);
410 sal_Int16
OResultSet::getShort(sal_Int32 columnIndex
)
412 MutexGuard
aGuard(m_aMutex
);
413 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
415 return m_xDelegatorRow
->getShort(columnIndex
);
418 sal_Int32
OResultSet::getInt(sal_Int32 columnIndex
)
420 MutexGuard
aGuard(m_aMutex
);
421 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
423 return m_xDelegatorRow
->getInt(columnIndex
);
426 sal_Int64
OResultSet::getLong(sal_Int32 columnIndex
)
428 MutexGuard
aGuard(m_aMutex
);
429 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
431 return m_xDelegatorRow
->getLong(columnIndex
);
434 float OResultSet::getFloat(sal_Int32 columnIndex
)
436 MutexGuard
aGuard(m_aMutex
);
437 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
439 return m_xDelegatorRow
->getFloat(columnIndex
);
442 double OResultSet::getDouble(sal_Int32 columnIndex
)
444 MutexGuard
aGuard(m_aMutex
);
445 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
447 return m_xDelegatorRow
->getDouble(columnIndex
);
450 Sequence
< sal_Int8
> OResultSet::getBytes(sal_Int32 columnIndex
)
452 MutexGuard
aGuard(m_aMutex
);
453 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
455 return m_xDelegatorRow
->getBytes(columnIndex
);
458 css::util::Date
OResultSet::getDate(sal_Int32 columnIndex
)
460 MutexGuard
aGuard(m_aMutex
);
461 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
463 return m_xDelegatorRow
->getDate(columnIndex
);
466 css::util::Time
OResultSet::getTime(sal_Int32 columnIndex
)
468 MutexGuard
aGuard(m_aMutex
);
469 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
471 return m_xDelegatorRow
->getTime(columnIndex
);
474 css::util::DateTime
OResultSet::getTimestamp(sal_Int32 columnIndex
)
476 MutexGuard
aGuard(m_aMutex
);
477 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
479 return m_xDelegatorRow
->getTimestamp(columnIndex
);
482 Reference
< css::io::XInputStream
> OResultSet::getBinaryStream(sal_Int32 columnIndex
)
484 MutexGuard
aGuard(m_aMutex
);
485 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
487 return m_xDelegatorRow
->getBinaryStream(columnIndex
);
490 Reference
< css::io::XInputStream
> OResultSet::getCharacterStream(sal_Int32 columnIndex
)
492 MutexGuard
aGuard(m_aMutex
);
493 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
495 return m_xDelegatorRow
->getCharacterStream(columnIndex
);
498 Any
OResultSet::getObject(sal_Int32 columnIndex
, const Reference
< css::container::XNameAccess
> & typeMap
)
500 MutexGuard
aGuard(m_aMutex
);
501 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
503 return m_xDelegatorRow
->getObject(columnIndex
, typeMap
);
506 Reference
< XRef
> OResultSet::getRef(sal_Int32 columnIndex
)
508 MutexGuard
aGuard(m_aMutex
);
509 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
511 return m_xDelegatorRow
->getRef(columnIndex
);
514 Reference
< XBlob
> OResultSet::getBlob(sal_Int32 columnIndex
)
516 MutexGuard
aGuard(m_aMutex
);
517 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
519 return m_xDelegatorRow
->getBlob(columnIndex
);
522 Reference
< XClob
> OResultSet::getClob(sal_Int32 columnIndex
)
524 MutexGuard
aGuard(m_aMutex
);
525 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
527 return m_xDelegatorRow
->getClob(columnIndex
);
530 Reference
< XArray
> OResultSet::getArray(sal_Int32 columnIndex
)
532 MutexGuard
aGuard(m_aMutex
);
533 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
535 return m_xDelegatorRow
->getArray(columnIndex
);
538 // css::sdbc::XRowUpdate
539 void OResultSet::updateNull(sal_Int32 columnIndex
)
541 MutexGuard
aGuard(m_aMutex
);
542 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
546 m_xDelegatorRowUpdate
->updateNull(columnIndex
);
549 void OResultSet::updateBoolean(sal_Int32 columnIndex
, sal_Bool x
)
551 MutexGuard
aGuard(m_aMutex
);
552 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
556 m_xDelegatorRowUpdate
->updateBoolean(columnIndex
, x
);
559 void OResultSet::updateByte(sal_Int32 columnIndex
, sal_Int8 x
)
561 MutexGuard
aGuard(m_aMutex
);
562 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
566 m_xDelegatorRowUpdate
->updateByte(columnIndex
, x
);
569 void OResultSet::updateShort(sal_Int32 columnIndex
, sal_Int16 x
)
571 MutexGuard
aGuard(m_aMutex
);
572 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
576 m_xDelegatorRowUpdate
->updateShort(columnIndex
, x
);
579 void OResultSet::updateInt(sal_Int32 columnIndex
, sal_Int32 x
)
581 MutexGuard
aGuard(m_aMutex
);
582 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
586 m_xDelegatorRowUpdate
->updateInt(columnIndex
, x
);
589 void OResultSet::updateLong(sal_Int32 columnIndex
, sal_Int64 x
)
591 MutexGuard
aGuard(m_aMutex
);
592 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
596 m_xDelegatorRowUpdate
->updateLong(columnIndex
, x
);
599 void OResultSet::updateFloat(sal_Int32 columnIndex
, float x
)
601 MutexGuard
aGuard(m_aMutex
);
602 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
606 m_xDelegatorRowUpdate
->updateFloat(columnIndex
, x
);
609 void OResultSet::updateDouble(sal_Int32 columnIndex
, double x
)
611 MutexGuard
aGuard(m_aMutex
);
612 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
616 m_xDelegatorRowUpdate
->updateDouble(columnIndex
, x
);
619 void OResultSet::updateString(sal_Int32 columnIndex
, const OUString
& x
)
621 MutexGuard
aGuard(m_aMutex
);
622 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
626 m_xDelegatorRowUpdate
->updateString(columnIndex
, x
);
629 void OResultSet::updateBytes(sal_Int32 columnIndex
, const Sequence
< sal_Int8
>& x
)
631 MutexGuard
aGuard(m_aMutex
);
632 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
636 m_xDelegatorRowUpdate
->updateBytes(columnIndex
, x
);
639 void OResultSet::updateDate(sal_Int32 columnIndex
, const css::util::Date
& x
)
641 MutexGuard
aGuard(m_aMutex
);
642 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
646 m_xDelegatorRowUpdate
->updateDate(columnIndex
, x
);
649 void OResultSet::updateTime(sal_Int32 columnIndex
, const css::util::Time
& x
)
651 MutexGuard
aGuard(m_aMutex
);
652 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
656 m_xDelegatorRowUpdate
->updateTime(columnIndex
, x
);
659 void OResultSet::updateTimestamp(sal_Int32 columnIndex
, const css::util::DateTime
& x
)
661 MutexGuard
aGuard(m_aMutex
);
662 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
666 m_xDelegatorRowUpdate
->updateTimestamp(columnIndex
, x
);
669 void OResultSet::updateBinaryStream(sal_Int32 columnIndex
, const Reference
< css::io::XInputStream
> & x
, sal_Int32 length
)
671 MutexGuard
aGuard(m_aMutex
);
672 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
676 m_xDelegatorRowUpdate
->updateBinaryStream(columnIndex
, x
, length
);
679 void OResultSet::updateCharacterStream(sal_Int32 columnIndex
, const Reference
< css::io::XInputStream
> & x
, sal_Int32 length
)
681 MutexGuard
aGuard(m_aMutex
);
682 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
686 m_xDelegatorRowUpdate
->updateCharacterStream(columnIndex
, x
, length
);
689 void OResultSet::updateNumericObject(sal_Int32 columnIndex
, const Any
& x
, sal_Int32 scale
)
691 MutexGuard
aGuard(m_aMutex
);
692 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
696 m_xDelegatorRowUpdate
->updateNumericObject(columnIndex
, x
, scale
);
699 void OResultSet::updateObject(sal_Int32 columnIndex
, const Any
& x
)
701 MutexGuard
aGuard(m_aMutex
);
702 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
706 m_xDelegatorRowUpdate
->updateObject(columnIndex
, x
);
709 // css::sdbc::XResultSet
710 sal_Bool
OResultSet::next()
712 MutexGuard
aGuard(m_aMutex
);
713 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
715 return m_xDelegatorResultSet
->next();
718 sal_Bool
OResultSet::isBeforeFirst()
720 MutexGuard
aGuard(m_aMutex
);
721 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
723 return m_xDelegatorResultSet
->isBeforeFirst();
726 sal_Bool
OResultSet::isAfterLast()
728 MutexGuard
aGuard(m_aMutex
);
729 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
731 return m_xDelegatorResultSet
->isAfterLast();
734 sal_Bool
OResultSet::isFirst()
736 MutexGuard
aGuard(m_aMutex
);
737 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
739 return m_xDelegatorResultSet
->isFirst();
742 sal_Bool
OResultSet::isLast()
744 MutexGuard
aGuard(m_aMutex
);
745 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
747 return m_xDelegatorResultSet
->isLast();
750 void OResultSet::beforeFirst()
752 MutexGuard
aGuard(m_aMutex
);
753 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
755 m_xDelegatorResultSet
->beforeFirst();
758 void OResultSet::afterLast()
760 MutexGuard
aGuard(m_aMutex
);
761 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
763 m_xDelegatorResultSet
->afterLast();
766 sal_Bool
OResultSet::first()
768 MutexGuard
aGuard(m_aMutex
);
769 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
771 return m_xDelegatorResultSet
->first();
774 sal_Bool
OResultSet::last()
776 MutexGuard
aGuard(m_aMutex
);
777 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
779 return m_xDelegatorResultSet
->last();
782 sal_Int32
OResultSet::getRow()
784 MutexGuard
aGuard(m_aMutex
);
785 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
787 return m_xDelegatorResultSet
->getRow();
790 sal_Bool
OResultSet::absolute(sal_Int32 row
)
792 MutexGuard
aGuard(m_aMutex
);
793 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
795 return m_xDelegatorResultSet
->absolute(row
);
798 sal_Bool
OResultSet::relative(sal_Int32 rows
)
800 MutexGuard
aGuard(m_aMutex
);
801 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
803 return m_xDelegatorResultSet
->relative(rows
);
806 sal_Bool
OResultSet::previous()
808 MutexGuard
aGuard(m_aMutex
);
809 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
811 return m_xDelegatorResultSet
->previous();
814 void OResultSet::refreshRow()
816 MutexGuard
aGuard(m_aMutex
);
817 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
819 m_xDelegatorResultSet
->refreshRow();
822 sal_Bool
OResultSet::rowUpdated()
824 MutexGuard
aGuard(m_aMutex
);
825 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
827 return m_xDelegatorResultSet
->rowUpdated();
830 sal_Bool
OResultSet::rowInserted()
832 MutexGuard
aGuard(m_aMutex
);
833 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
835 return m_xDelegatorResultSet
->rowInserted();
838 sal_Bool
OResultSet::rowDeleted()
840 MutexGuard
aGuard(m_aMutex
);
841 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
843 return m_xDelegatorResultSet
->rowDeleted();
846 Reference
< XInterface
> OResultSet::getStatement()
848 MutexGuard
aGuard(m_aMutex
);
849 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
854 // css::sdbcx::XRowLocate
855 Any
OResultSet::getBookmark()
857 MutexGuard
aGuard(m_aMutex
);
858 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
862 return Reference
< XRowLocate
>(m_xDelegatorResultSet
, UNO_QUERY_THROW
)->getBookmark();
865 sal_Bool
OResultSet::moveToBookmark(const Any
& bookmark
)
867 MutexGuard
aGuard(m_aMutex
);
868 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
872 return Reference
< XRowLocate
>(m_xDelegatorResultSet
, UNO_QUERY_THROW
)->moveToBookmark(bookmark
);
875 sal_Bool
OResultSet::moveRelativeToBookmark(const Any
& bookmark
, sal_Int32 rows
)
877 MutexGuard
aGuard(m_aMutex
);
878 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
882 return Reference
< XRowLocate
>(m_xDelegatorResultSet
, UNO_QUERY_THROW
)->moveRelativeToBookmark(bookmark
, rows
);
885 sal_Int32
OResultSet::compareBookmarks(const Any
& _first
, const Any
& _second
)
887 MutexGuard
aGuard(m_aMutex
);
888 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
892 return Reference
< XRowLocate
>(m_xDelegatorResultSet
, UNO_QUERY_THROW
)->compareBookmarks(_first
, _second
);
895 sal_Bool
OResultSet::hasOrderedBookmarks()
897 MutexGuard
aGuard(m_aMutex
);
898 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
902 return Reference
< XRowLocate
>(m_xDelegatorResultSet
, UNO_QUERY_THROW
)->hasOrderedBookmarks();
905 sal_Int32
OResultSet::hashBookmark(const Any
& bookmark
)
907 MutexGuard
aGuard(m_aMutex
);
908 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
912 return Reference
< XRowLocate
>(m_xDelegatorResultSet
, UNO_QUERY_THROW
)->hashBookmark(bookmark
);
915 // css::sdbc::XResultSetUpdate
916 void OResultSet::insertRow()
918 MutexGuard
aGuard(m_aMutex
);
919 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
923 m_xDelegatorResultSetUpdate
->insertRow();
926 void OResultSet::updateRow()
928 MutexGuard
aGuard(m_aMutex
);
929 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
933 m_xDelegatorResultSetUpdate
->updateRow();
936 void OResultSet::deleteRow()
938 MutexGuard
aGuard(m_aMutex
);
939 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
943 m_xDelegatorResultSetUpdate
->deleteRow();
946 void OResultSet::cancelRowUpdates()
948 MutexGuard
aGuard(m_aMutex
);
949 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
953 m_xDelegatorResultSetUpdate
->cancelRowUpdates();
956 void OResultSet::moveToInsertRow()
958 MutexGuard
aGuard(m_aMutex
);
959 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
963 m_xDelegatorResultSetUpdate
->moveToInsertRow();
966 void OResultSet::moveToCurrentRow()
968 MutexGuard
aGuard(m_aMutex
);
969 ::connectivity::checkDisposed(OResultSetBase::rBHelper
.bDisposed
);
973 m_xDelegatorResultSetUpdate
->moveToCurrentRow();
976 void OResultSet::checkReadOnly() const
978 if ( ( m_nResultSetConcurrency
== ResultSetConcurrency::READ_ONLY
)
979 || !m_xDelegatorResultSetUpdate
.is()
981 throwSQLException( "The result set is read-only.", StandardSQLState::GENERAL_ERROR
, *const_cast< OResultSet
* >( this ) );
984 void OResultSet::checkBookmarkable() const
986 if ( !m_bIsBookmarkable
)
987 throwSQLException( "The result set does not have bookmark support.", StandardSQLState::GENERAL_ERROR
, *const_cast< OResultSet
* >( this ) );
990 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */