26#include <core_resource.hxx>
29#include <com/sun/star/beans/PropertyAttribute.hpp>
30#include <com/sun/star/sdbcx/CompareBookmark.hpp>
31#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
32#include <com/sun/star/sdbc/ResultSetType.hpp>
52using namespace ::
cppu;
83 ,m_rBHelper(_rBHelper)
85 ,m_nLastColumnIndex(-1)
86 ,m_nDeletedPosition(-1)
87 ,m_nResultSetType( ResultSetType::FORWARD_ONLY )
88 ,m_nResultSetConcurrency( ResultSetConcurrency::READ_ONLY )
90 ,m_bIgnoreResult(false)
93 ,m_bIsInsertRow(false)
95 sal_Int32 nRBT = PropertyAttribute::READONLY | PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT;
136 rValue <<=
m_pCache->m_bRowCountFinal;
167 Sequence< Property > aProps;
169 return new ::cppu::OPropertyArrayHelper(aProps);
181 ::osl::MutexGuard aGuard( *
m_pMutex );
197 SAL_WARN(
"dbaccess",
"ORowSetBase::getValue: Illegal call here (we're before first or after last)!");
198 ::dbtools::throwSQLException(
DBA_RES( RID_STR_CURSOR_BEFORE_OR_AFTER ), StandardSQLState::INVALID_CURSOR_POSITION, *
m_pMySelf );
207 if ( !bValidCurrentRow )
213 OSL_ENSURE(!
m_aCurrentRow.
isNull(),
"ORowSetBase::getValue: we don't stand on a valid row! Row is null.");
218 if ( bValidCurrentRow )
220#if OSL_DEBUG_LEVEL > 0
221 ORowSetMatrix::const_iterator aCacheEnd;
222 ORowSetMatrix::iterator aCurrentRow;
227 ORowSetMatrix::const_iterator k =
aHelper.aIterator;
228 for (; k !=
m_pCache->getEnd(); ++k)
231 OSL_ENSURE( pTemp !=
reinterpret_cast<void*
>(0xfeeefeee),
"HALT!" );
233 OSL_ENSURE(!
m_aCurrentRow.
isNull() && m_aCurrentRow < m_pCache->getEnd() && aCacheIter !=
m_pCache->m_aCacheIterators.end(),
"Invalid iterator set for currentrow!");
239 SAL_WARN(
"dbaccess",
"ORowSetBase::getValue: Invalid size of vector!");
240 ::dbtools::throwSQLException(
DBA_RES( RID_STR_CURSOR_BEFORE_OR_AFTER ), StandardSQLState::INVALID_CURSOR_POSITION, *
m_pMySelf );
252 ::osl::MutexGuard aGuard( *
m_pMutex );
258 ::osl::MutexGuard aGuard( *
m_pMutex );
264 ::osl::MutexGuard aGuard( *
m_pMutex );
270 ::osl::MutexGuard aGuard( *
m_pMutex );
276 ::osl::MutexGuard aGuard( *
m_pMutex );
282 ::osl::MutexGuard aGuard( *
m_pMutex );
288 ::osl::MutexGuard aGuard( *
m_pMutex );
294 ::osl::MutexGuard aGuard( *
m_pMutex );
300 ::osl::MutexGuard aGuard( *
m_pMutex );
306 ::osl::MutexGuard aGuard( *
m_pMutex );
312 ::osl::MutexGuard aGuard( *
m_pMutex );
318 ::osl::MutexGuard aGuard( *
m_pMutex );
324 ::osl::MutexGuard aGuard( *
m_pMutex );
329 SAL_WARN(
"dbaccess",
"ORowSetBase::getBinaryStream: Illegal call here (we're before first or after last)!");
330 ::dbtools::throwSQLException(
DBA_RES( RID_STR_CURSOR_BEFORE_OR_AFTER ), StandardSQLState::INVALID_CURSOR_POSITION, *
m_pMySelf );
339 if ( !bValidCurrentRow )
344 OSL_ENSURE(!
m_aCurrentRow.
isNull(),
"ORowSetBase::getBinaryStream: we don't stand on a valid row! Row is null.");
349 if ( bValidCurrentRow )
356 return Reference< css::io::XInputStream >();
366 ::osl::MutexGuard aGuard( *
m_pMutex );
374 ::dbtools::throwFeatureNotImplementedSQLException(
"XRow::getRef", *
m_pMySelf );
390 ::dbtools::throwFeatureNotImplementedSQLException(
"XRow::getArray", *
m_pMySelf );
399 ::osl::MutexGuard aGuard( *
m_pMutex );
403 ::dbtools::throwSQLException(
DBA_RES( RID_STR_NO_BOOKMARK_BEFORE_OR_AFTER ), StandardSQLState::INVALID_CURSOR_POSITION, *
m_pMySelf );
406 ::dbtools::throwSQLException(
DBA_RES( RID_STR_NO_BOOKMARK_DELETED ), StandardSQLState::INVALID_CURSOR_POSITION, *
m_pMySelf );
408 OSL_ENSURE(
m_aBookmark.hasValue(),
"ORowSetBase::getBookmark: bookmark has no value!" );
414 SAL_INFO(
"dbaccess",
"ORowSetBase::moveToBookmark(Any) Clone = " <<
m_bClone);
415 OSL_ENSURE(bookmark.hasValue(),
"ORowSetBase::moveToBookmark bookmark has no value!");
416 ::osl::ResettableMutexGuard aGuard( *
m_pMutex );
420 if(bookmark.hasValue())
421 SAL_WARN(
"dbaccess",
"MoveToBookmark is not possible when we are only forward");
423 SAL_WARN(
"dbaccess",
"Bookmark is not valid");
440 bRet =
m_pCache->moveToBookmark(bookmark);
458 SAL_INFO(
"dbaccess",
"ORowSetBase::moveToBookmark(Any) = " << bRet <<
" Clone = " <<
m_bClone);
464 SAL_INFO(
"dbaccess",
"ORowSetBase::moveRelativeToBookmark(Any," << rows <<
") Clone = " <<
m_bClone);
467 ::osl::ResettableMutexGuard aGuard( *
m_pMutex );
482 bRet =
m_pCache->moveRelativeToBookmark(bookmark,rows);
501 SAL_INFO(
"dbaccess",
"ORowSetBase::moveRelativeToBookmark(Any," << rows <<
") = " << bRet <<
" Clone = " <<
m_bClone);
507 ::osl::MutexGuard aGuard( *
m_pMutex );
509 return m_pCache->compareBookmarks(_first,_second);
514 ::osl::MutexGuard aGuard( *
m_pMutex );
516 return m_pCache->hasOrderedBookmarks();
521 ::osl::MutexGuard aGuard( *
m_pMutex );
523 return m_pCache->hashBookmark(bookmark);
531 Reference< XResultSetMetaData > xMeta;
568 ::osl::ResettableMutexGuard aGuard( *
m_pMutex );
583 bool bAfterLast =
m_pCache->isAfterLast();
593 if (bAfterLast !=
m_pCache->isAfterLast())
599 if ( bRet || bAfterLast !=
m_pCache->isAfterLast() )
605 OSL_ENSURE(!
m_bBeforeFirst,
"BeforeFirst is true. I don't know why?");
611 OSL_ENSURE(
m_bAfterLast,
"AfterLast is false. I don't know why?");
621 SAL_INFO(
"dbaccess",
"ORowSetBase::next() = " << bRet <<
" Clone = " <<
m_bClone);
628 ::osl::MutexGuard aGuard( *
m_pMutex );
639 ::osl::MutexGuard aGuard( *
m_pMutex );
656 ::osl::MutexGuard aGuard( *
m_pMutex );
666 bool bIsFirst =
m_pCache->isFirst();
668 SAL_INFO(
"dbaccess",
"ORowSetBase::isFirst() = " << bIsFirst <<
" Clone = " <<
m_bClone);
681 ::osl::MutexGuard aGuard( *
m_pMutex );
698 SAL_INFO(
"dbaccess",
"ORowSetBase::isLast() = " << bIsLast <<
" Clone = " <<
m_bClone);
706 ::osl::ResettableMutexGuard aGuard( *
m_pMutex );
748 ::osl::ResettableMutexGuard aGuard( *
m_pMutex );
783 std::function<
bool(
ORowSetCache *)>
const & _aMovementFunctor)
787 ::osl::ResettableMutexGuard aGuard( *
m_pMutex );
801 bool bMoved = ( bWasNew || !_aCheckFunctor(
this) );
803 bRet = _aMovementFunctor(
m_pCache.get());
825 SAL_INFO(
"dbaccess",
"ORowSetBase::move() = " << bRet <<
" Clone = " <<
m_bClone);
834 return move(ioF_tmp,F_tmp);
842 return move(ioL_tmp,L_tmp);
848 ::osl::MutexGuard aGuard( *
m_pMutex );
876 SAL_INFO(
"dbaccess",
"ORowSetBase::absolute(" << row <<
") Clone = " <<
m_bClone);
878 ::osl::ResettableMutexGuard aGuard( *
m_pMutex );
881 bool bRet = ( row > 0 )
915 SAL_INFO(
"dbaccess",
"ORowSetBase::absolute(" << row <<
") = " << bRet <<
" Clone = " <<
m_bClone);
921 SAL_INFO(
"dbaccess",
"ORowSetBase::relative(" << rows <<
") Clone = " <<
m_bClone);
924 ::osl::ResettableMutexGuard aGuard( *
m_pMutex );
970 SAL_INFO(
"dbaccess",
"ORowSetBase::relative(" << rows <<
") = " << bRet <<
" Clone = " <<
m_bClone);
978 ::osl::ResettableMutexGuard aGuard( *
m_pMutex );
1009 SAL_WARN(
"dbaccess",
"ORowSetBase::previous: inconsistency!" );
1022 SAL_INFO(
"dbaccess",
"ORowSetBase::previous() = " << bRet <<
" Clone = " <<
m_bClone);
1035 OSL_ENSURE(
m_aBookmark.hasValue(),
"Bookmark has no value!");
1041 OSL_ENSURE(
m_aBookmark.hasValue(),
"Bookmark has no value!");
1046#if OSL_DEBUG_LEVEL > 0
1048 OSL_ENSURE(rRow.is() ,
"Invalid size of vector!");
1068 if ( _bMoved && _bDoNotify )
1089 ::osl::MutexGuard aGuard( *
m_pMutex );
1092 throwSQLException(
"The current row is deleted", StandardSQLState::INVALID_CURSOR_STATE, Reference< XRowSet >(
this ) );
1106 ::osl::MutexGuard aGuard( *
m_pMutex );
1117 ::osl::MutexGuard aGuard( *
m_pMutex );
1129 ::osl::MutexGuard aGuard( *
m_pMutex );
1142 ::osl::MutexGuard aGuard( *
m_pMutex );
1146 Reference< XWarningsSupplier > xWarnings(
m_pCache->m_xSet.get(), UNO_QUERY );
1147 if ( xWarnings.is() )
1148 return xWarnings->getWarnings();
1156 ::osl::MutexGuard aGuard( *
m_pMutex );
1160 Reference< XWarningsSupplier > xWarnings(
m_pCache->m_xSet.get(), UNO_QUERY );
1161 if ( xWarnings.is() )
1162 xWarnings->clearWarnings();
1171 SAL_INFO(
"dbaccess",
"ORowSetBase::firePropertyChange" );
1172 SAL_INFO(
"dbaccess",
"ORowSetBase::firePropertyChange() Clone = " <<
m_bClone);
1173 OSL_ENSURE(
m_pColumns,
"Columns can not be NULL here!");
1187 SAL_INFO(
"dbaccess",
"ORowSetBase::firePropertyChange() Clone = " <<
m_bClone);
1218 fire( &_nProperty, &aNew, &aOld, 1,
false );
1225 bool bSuccess =
false;
1249 OSL_ENSURE(
m_nDeletedPosition >= 1,
"ORowSetBase::positionCache: no bookmark, and no valid 'deleted position'!" );
1250 switch ( _ePrepareForDirection )
1279 OSL_ENSURE( bSuccess,
"ORowSetBase::positionCache: failed!" );
1293 SAL_INFO(
"dbaccess",
"ORowSetBase::movementFailed() Clone = " <<
m_bClone);
1300 SAL_INFO(
"dbaccess",
"ORowSetBase::movementFailed() Clone = " <<
m_bClone);
1305 OSL_ENSURE(
m_aOldRow.is(),
"RowSetRowHElper isn't valid!");
1307 if ( !_bWasNew &&
m_aOldRow->getRow().is() )
1323 ::osl::MutexGuard aGuard( *
m_pMutex );
1344 ::osl::MutexGuard aGuard( *
m_pMutex );
1355 sal_Int32 nRowCount(
m_pCache->m_nRowCount );
1363 :m_pRowSet( _pRowSet )
1365 ,m_bWasModified( false )
1368 OSL_ENSURE(
m_pRowSet,
"ORowSetNotifier::ORowSetNotifier: invalid row set. This will crash." );
1380 :m_pRowSet( _pRowSet )
1382 ,m_bWasModified( false )
1384 OSL_ENSURE(
m_pRowSet,
"ORowSetNotifier::ORowSetNotifier: invalid row set. This will crash." );
1385 aRow = std::move(i_aRow);
::cppu::IPropertyArrayHelper * getArrayHelper()
void registerPropertyNoMember(const OUString &_rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, const css::uno::Type &_rType, css::uno::Any const &_pInitialValue)
void describeProperties(css::uno::Sequence< css::beans::Property > &_rProps) const
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
std::vector< VectorVal > Vector
css::util::Time getTime() const
sal_Int32 getInt32() const
OUString getString() const
css::uno::Any makeAny() const
sal_Int16 getInt16() const
css::util::Date getDate() const
css::util::DateTime getDateTime() const
sal_Int64 getLong() const
css::uno::Sequence< sal_Int8 > getSequence() const
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
OEmptyCollection(::cppu::OWeakObject &_rParent,::osl::Mutex &_rMutex)
virtual void impl_refresh() override
virtual connectivity::sdbcx::ObjectType createObject(const OUString &_rName) override
virtual sal_Bool SAL_CALL absolute(sal_Int32 row) override
virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob(sal_Int32 columnIndex) override
ORowSetCacheIterator m_aCurrentRow
virtual OUString SAL_CALL getString(sal_Int32 columnIndex) override
virtual css::uno::Any SAL_CALL getWarnings() override
sal_Int32 m_nLastColumnIndex
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
const connectivity::ORowSetValue & getValue(sal_Int32 columnIndex)
virtual sal_Int32 SAL_CALL compareBookmarks(const css::uno::Any &first, const css::uno::Any &second) override
virtual css::util::Time SAL_CALL getTime(sal_Int32 columnIndex) override
TORowSetOldRowHelperRef m_aOldRow
virtual sal_Bool SAL_CALL rowDeleted() override
std::unique_ptr< ORowSetDataColumns > m_pColumns
std::unique_ptr< OEmptyCollection > m_pEmptyCollection
virtual sal_Bool SAL_CALL relative(sal_Int32 rows) override
virtual css::uno::Any SAL_CALL getObject(sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
::cppu::OBroadcastHelper & m_rBHelper
virtual void notifyAllListenersCursorMoved(::osl::ResettableMutexGuard &_rGuard)
virtual sal_Int32 SAL_CALL hashBookmark(const css::uno::Any &bookmark) override
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns() override
virtual void fireRowcount()
virtual sal_Bool SAL_CALL moveToBookmark(const css::uno::Any &bookmark) override
virtual sal_Int64 SAL_CALL getLong(sal_Int32 columnIndex) override
void checkPositioningAllowed()
virtual css::uno::Any SAL_CALL getBookmark() override
virtual bool isPropertyChangeNotificationEnabled() const
TDataColumns m_aDataColumns
virtual sal_Int32 SAL_CALL getInt(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL rowUpdated() override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes(sal_Int32 columnIndex) override
void fireProperty(sal_Int32 _nProperty, bool _bNew, bool _bOld)
virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL last() override
virtual bool isModified()=0
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream(sal_Int32 columnIndex) override
void onDeleteRow(const css::uno::Any &_rBookmark)
virtual sal_Bool SAL_CALL next() override
virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray(sal_Int32 columnIndex) override
virtual void SAL_CALL clearWarnings() override
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
virtual void SAL_CALL beforeFirst() override
virtual css::util::DateTime SAL_CALL getTimestamp(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef(sal_Int32 columnIndex) override
connectivity::ORowSetValue m_aEmptyValue
virtual sal_Bool SAL_CALL isAfterLast() override
bool isOnFirst()
same meaning as isFirst.
::cppu::OWeakObject * m_pMySelf
virtual void doCancelModification()=0
virtual sal_Bool SAL_CALL first() override
virtual sal_Bool SAL_CALL moveRelativeToBookmark(const css::uno::Any &bookmark, sal_Int32 rows) override
ORowSetRow getOldRow(bool _bWasNew)
::osl::Mutex m_aColumnsMutex
sal_Int32 impl_getRowCount() const
returns the current row count
css::uno::Any m_aBookmark
sal_Int32 m_nDeletedPosition
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
virtual bool isModification()=0
@ Current
denotes no cursor move at all, but move cache to current row (if it is not there already)
@ Forward
denotes a cursor move forward
@ CurrentRefresh
denotes no cursor move at all, but force the cache to move to current row (and refresh the row)
@ Backward
denotes a cursor move backwards
const connectivity::ORowSetValue & impl_getValue(sal_Int32 columnIndex)
virtual sal_Bool SAL_CALL isBeforeFirst() override
virtual bool notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard &_rGuard)
virtual float SAL_CALL getFloat(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL isFirst() override
virtual css::util::Date SAL_CALL getDate(sal_Int32 columnIndex) override
virtual sal_Int8 SAL_CALL getByte(sal_Int32 columnIndex) override
void onDeletedRow(const css::uno::Any &_rBookmark, sal_Int32 _nPos)
virtual sal_Int32 SAL_CALL findColumn(const OUString &columnName) override
virtual void SAL_CALL afterLast() override
void setCurrentRow(bool _bMoved, bool _bDoNotify, const ORowSetRow &_rOldValues, ::osl::ResettableMutexGuard &_rGuard)
virtual sal_Bool SAL_CALL rowInserted() override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream(sal_Int32 columnIndex) override
virtual void getPropertyDefaultByHandle(sal_Int32 _nHandle, css::uno::Any &_rDefault) const override
virtual sal_Bool SAL_CALL hasOrderedBookmarks() override
void positionCache(CursorMoveDirection _ePrepareForDirection)
positions the cache in preparation of a cursor move
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
bool isOnLast()
same meaning as isLast.
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
ORowSetBase(const css::uno::Reference< css::uno::XComponentContext > &_rContext, ::cppu::OBroadcastHelper &_rBHelper, ::osl::Mutex *_pMutex)
virtual void SAL_CALL disposing()
void firePropertyChange(const ORowSetRow &_rOldRow)
virtual sal_Bool SAL_CALL wasNull() override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement() override
virtual sal_Bool SAL_CALL isLast() override
virtual sal_Int32 SAL_CALL getRow() override
std::shared_ptr< ORowSetCache > m_pCache
bool SAL_CALL move(std::function< bool(ORowSetBase *)> const &_aCheckFunctor, std::function< bool(ORowSetCache *)> const &_aMovementFunctor)
move the cache the position defined by the member functor
sal_Int32 m_nResultSetType
virtual sal_Int16 SAL_CALL getShort(sal_Int32 columnIndex) override
std::vector< ORowSetDataColumn * > TDataColumns
virtual sal_Bool SAL_CALL getBoolean(sal_Int32 columnIndex) override
virtual ~ORowSetBase() override
virtual double SAL_CALL getDouble(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL previous() override
virtual void SAL_CALL refreshRow() override
const ORowSetCacheMap::iterator & getIter() const
eases the handling of the doCancelModification and notifyCancelInsert methods
ORowSetNotifier(ORowSetBase *m_pRowSet)
constructs the object, and cancels the insertion
void firePropertyChange()
notifies value change events and notifies IsModified
void fire()
notifies the insertion
ORowSetValueVector::Vector aRow
std::vector< sal_Int32 > aChangedColumns
std::vector< sal_Int32 > & getChangedColumns()
use this one to store the index of the changed column values
Reference< XComponentContext > m_aContext
#define TOOLS_WARN_EXCEPTION(area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
css::uno::Reference< css::beans::XPropertySet > ObjectType
connectivity::ORowVector< connectivity::ORowSetValue > ORowSetValueVector
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)
#define PROPERTY_ID_ISMODIFIED
#define PROPERTY_ID_ISROWCOUNTFINAL
#define PROPERTY_ID_ISNEW
#define PROPERTY_ID_ROWCOUNT
constexpr OUStringLiteral PROPERTY_ISROWCOUNTFINAL(u"IsRowCountFinal")
constexpr OUStringLiteral PROPERTY_ROWCOUNT(u"RowCount")