User: hr Date: 06/01/25 07:10:45 Modified: /dba/dbaccess/source/core/api/ RowSetCache.cxx
Log: INTEGRATION: CWS rowsetdel (1.80.12); FILE MERGED 2006/01/25 14:46:53 fs 1.80.12.9: #i10000# clearModified was duplicate 2006/01/25 14:44:20 fs 1.80.12.8: manual RESYNC to HEAD 2006/01/25 12:59:11 fs 1.80.12.7: RESYNC: (1.80-1.81); FILE MERGED 2006/01/20 09:01:23 fs 1.80.12.6: #i55731# deleteRows now implemented in the RowSet itself 2006/01/19 09:04:08 fs 1.80.12.5: merging the changes from CWS stlusagefix01, to ensure there are no interdependencies 2006/01/19 07:12:27 fs 1.80.12.4: #i55731# removed some unused code from the cache 2006/01/18 13:59:17 fs 1.80.12.3: #i55731# moveToInsertRow must also fire a RowCountChange - might happen in case the current row is deleted 2006/01/16 10:16:01 fs 1.80.12.2: #i10000# 2006/01/16 10:12:21 fs 1.80.12.1: #i55731# fixed the handling for deleting rows. In particular, remove m_bDeleted, since this is an attribute of the RowSet/Clone now, not the cache File Changes: Directory: /dba/dbaccess/source/core/api/ ========================================= File [changed]: RowSetCache.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/RowSetCache.cxx?r1=1.82&r2=1.83 Delta lines: +54 -77 --------------------- --- RowSetCache.cxx 25 Jan 2006 13:43:29 -0000 1.82 +++ RowSetCache.cxx 25 Jan 2006 15:10:43 -0000 1.83 @@ -145,7 +145,6 @@ ,m_bAfterLast( sal_False ) ,m_bRowCountFinal(sal_False) ,m_bInserted(sal_False) - ,m_bDeleted(sal_False) ,m_bUpdated(sal_False) ,m_xMetaData(Reference< XResultSetMetaDataSupplier >(_xRs,UNO_QUERY)->getMetaData()) ,m_xServiceFactory(_xServiceFactory) @@ -415,7 +414,7 @@ for(;aCacheIter != m_aCacheIterators.end();++aCacheIter) { aCacheIterToChange[aCacheIter->first] = sal_False; - if ( !aCacheIter->second.pRowSet->isInsertRow(ORowSetBase::GrantNotifierAccess()) + if ( !aCacheIter->second.pRowSet->isInsertRow() && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bInserted && !m_bModified ) { sal_Int16 nDist = (aCacheIter->second.aIterator - m_pMatrix->begin()); @@ -482,12 +481,9 @@ // ------------------------------------------------------------------------- sal_Bool ORowSetCache::moveToBookmark( const Any& bookmark ) { -// if(m_bInserted) -// m_bInserted = sal_False; - if ( m_pCacheSet->moveToBookmark(bookmark) ) { - m_bDeleted = m_bBeforeFirst = sal_False; + m_bBeforeFirst = sal_False; m_nPosition = m_pCacheSet->getRow(); checkPositionFlags(); @@ -611,6 +607,7 @@ { m_bBeforeFirst = sal_False; ++m_nPosition; + // after we increment the position we have to check if we are already after the last row checkPositionFlags(); if(!m_bAfterLast) @@ -654,7 +651,7 @@ return m_nPosition == m_nRowCount; } // ------------------------------------------------------------------------- -void ORowSetCache::beforeFirst( ) +sal_Bool ORowSetCache::beforeFirst( ) { ::osl::MutexGuard aGuard( m_aRowCountMutex ); @@ -667,9 +664,10 @@ moveWindow(); m_aMatrixIter = m_pMatrix->end(); } + return sal_True; } // ------------------------------------------------------------------------- -void ORowSetCache::afterLast( ) +sal_Bool ORowSetCache::afterLast( ) { ::osl::MutexGuard aGuard( m_aRowCountMutex ); @@ -689,6 +687,7 @@ m_nPosition = 0; m_aMatrixIter = m_pMatrix->end(); } + return sal_True; } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos) @@ -813,7 +812,7 @@ ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin(); for(;aCacheIter != m_aCacheIterators.end();++aCacheIter) { - if ( !aCacheIter->second.pRowSet->isInsertRow(ORowSetBase::GrantNotifierAccess()) + if ( !aCacheIter->second.pRowSet->isInsertRow() && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bInserted && !m_bModified ) { sal_Int16 nDist = (aCacheIter->second.aIterator - m_pMatrix->begin()); @@ -1122,17 +1121,26 @@ sal_Bool bErg = sal_True; if(rows) { - if(m_bBeforeFirst || (m_bRowCountFinal && m_bAfterLast)) - throw SQLException(DBACORE_RESSTRING(RID_STR_NO_RELATIVE),NULL,SQLSTATE_GENERAL,1000,Any() ); + sal_Int32 nNewPosition = m_nPosition + rows; - if(m_nPosition + rows) - { - bErg = absolute(m_nPosition + rows); + if ( m_bBeforeFirst && rows > 0 ) + nNewPosition = rows; + else if ( m_bRowCountFinal && m_bAfterLast && rows < 0 ) + nNewPosition = m_nRowCount + 1 + rows; + else + if ( m_bBeforeFirst || ( m_bRowCountFinal && m_bAfterLast ) ) + throw SQLException( DBACORE_RESSTRING( RID_STR_NO_RELATIVE ), NULL, SQLSTATE_GENERAL, 1000, Any() ); + if ( nNewPosition ) + { + bErg = absolute( nNewPosition ); bErg = bErg && !isAfterLast() && !isBeforeFirst(); } else - bErg = !(m_bBeforeFirst = sal_True); + { + m_bBeforeFirst = sal_True; + bErg = sal_False; + } } return bErg; } @@ -1195,12 +1203,6 @@ return m_pCacheSet->rowInserted(); } // ------------------------------------------------------------------------- -sal_Bool ORowSetCache::rowDeleted( ) -{ - // return m_pCacheSet->rowDeleted(); - return m_bDeleted; -} -// ------------------------------------------------------------------------- // XResultSetUpdate sal_Bool ORowSetCache::insertRow( ) { @@ -1243,7 +1245,7 @@ ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end(); for(;aCacheIter != aCacheEnd;++aCacheIter) { - if ( aCacheIter->second.pRowSet->isInsertRow(ORowSetBase::GrantNotifierAccess()) && aCacheIter->second.aIterator == m_aInsertRow ) + if ( aCacheIter->second.pRowSet->isInsertRow() && aCacheIter->second.aIterator == m_aInsertRow ) aCacheIter->second.aIterator = m_pMatrix->end(); } // for(;aCacheIter != aCacheEnd;++aCacheIter) resetInsertRow(sal_False); @@ -1274,7 +1276,7 @@ // refreshRow( ); } // ------------------------------------------------------------------------- -void ORowSetCache::deleteRow( ) +bool ORowSetCache::deleteRow( ) { ::osl::MutexGuard aGuard( m_aRowCountMutex ); @@ -1283,8 +1285,9 @@ // m_pCacheSet->absolute(m_nPosition); m_pCacheSet->deleteRow(*m_aMatrixIter,m_aUpdateTable); - if(m_bDeleted = m_pCacheSet->rowDeleted()) - { + if ( !m_pCacheSet->rowDeleted() ) + return false; + --m_nRowCount; OSL_ENSURE(((m_nPosition - m_nStartPos) - 1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!"); ORowSetMatrix::iterator aPos = calcPosition(); @@ -1300,12 +1303,7 @@ m_aMatrixIter = m_pMatrix->end(); --m_nPosition; - } -} -// ----------------------------------------------------------------------------- -void ORowSetCache::clearModified( ) -{ - m_bModified = sal_False; + return true; } // ------------------------------------------------------------------------- void ORowSetCache::cancelRowUpdates( ) @@ -1334,7 +1332,7 @@ m_bNew = sal_True; m_bInserted = sal_True; - m_bUpdated = m_bDeleted = m_bAfterLast = sal_False; + m_bUpdated = m_bAfterLast = sal_False; m_aInsertRow = m_pInsertMatrix->begin(); if(!m_aInsertRow->isValid()) @@ -1360,32 +1358,6 @@ // m_bInserted = sal_False; // } } -// ------------------------------------------------------------------------- -// ::com::sun::star::sdbcx::XDeleteRows -Sequence< sal_Int32 > ORowSetCache::deleteRows( const Sequence< Any >& rows ) -{ - // TODO impl. a better version which is faster than tis one - - ::osl::MutexGuard aGuard( m_aRowCountMutex ); - - Sequence< sal_Int32 > aRet(rows.getLength()); - sal_Int32 *pRet = aRet.getArray(); - - const Any *pIter = rows.getConstArray(); - const Any *pEnd = pIter + rows.getLength(); - - for(;pIter != pEnd;++pIter,++pRet) - { - // first we have to position our own and then we have to position our CacheSet again, - // it could be repositioned in the moveToBookmark call - if ( moveToBookmark(*pIter) && m_pCacheSet->moveToBookmark(*pIter) ) - { - deleteRow(); - *pRet = (m_bDeleted) ? 1 : 0; - } - } - return aRet; -} // ------------------------------------------------------------------------- ORowSetCacheIterator ORowSetCache::createIterator(ORowSetBase* _pRowSet) @@ -1404,7 +1376,7 @@ ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin(); for(;aCacheIter != m_aCacheIterators.end();++aCacheIter) { - if ( !aCacheIter->second.pRowSet->isInsertRow(ORowSetBase::GrantNotifierAccess()) + if ( !aCacheIter->second.pRowSet->isInsertRow() && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bInserted && !m_bModified ) { sal_Int16 nDist = (aCacheIter->second.aIterator - m_pMatrix->begin()); @@ -1421,6 +1393,11 @@ } } } +} +// ----------------------------------------------------------------------------- +void ORowSetCache::clearModified( ) +{ + m_bModified = sal_False; } // ------------------------------------------------------------------------- void ORowSetCache::setUpdateIterator(const ORowSetMatrix::iterator& _rOriginalRow) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
