Tag: cws_src680_rowsetdel User: fs Date: 06/01/16 02:12:26 Modified: /dba/dbaccess/source/core/api/ RowSetCache.cxx, RowSetCache.hxx
Log: #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.80&r2=1.80.12.1 Delta lines: +47 -46 --------------------- --- RowSetCache.cxx 3 Jan 2006 16:13:57 -0000 1.80 +++ RowSetCache.cxx 16 Jan 2006 10:12:21 -0000 1.80.12.1 @@ -4,9 +4,9 @@ * * $RCSfile: RowSetCache.cxx,v $ * - * $Revision: 1.80 $ + * $Revision: 1.80.12.1 $ * - * last change: $Author: kz $ $Date: 2006/01/03 16:13:57 $ + * last change: $Author: fs $ $Date: 2006/01/16 10:12:21 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -142,7 +142,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) @@ -630,7 +629,7 @@ if ( m_pCacheSet->moveToBookmark(bookmark) ) { - m_bDeleted = m_bBeforeFirst = sal_False; + m_bBeforeFirst = sal_False; m_nPosition = m_pCacheSet->getRow(); checkPositionFlags(); @@ -758,6 +757,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) @@ -801,7 +801,7 @@ return m_nPosition == m_nRowCount; } // ------------------------------------------------------------------------- -void ORowSetCache::beforeFirst( ) +sal_Bool ORowSetCache::beforeFirst( ) { ::osl::MutexGuard aGuard( m_aRowCountMutex ); @@ -814,9 +814,10 @@ moveWindow(); m_aMatrixIter = m_pMatrix->end(); } + return sal_True; } // ------------------------------------------------------------------------- -void ORowSetCache::afterLast( ) +sal_Bool ORowSetCache::afterLast( ) { ::osl::MutexGuard aGuard( m_aRowCountMutex ); @@ -836,6 +837,7 @@ m_nPosition = 0; m_aMatrixIter = m_pMatrix->end(); } + return sal_True; } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos) @@ -1270,17 +1272,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; } @@ -1343,12 +1354,6 @@ return m_pCacheSet->rowInserted(); } // ------------------------------------------------------------------------- -sal_Bool ORowSetCache::rowDeleted( ) -{ - // return m_pCacheSet->rowDeleted(); - return m_bDeleted; -} -// ------------------------------------------------------------------------- Reference< XInterface > ORowSetCache::getStatement( ) { return m_pCacheSet->getStatement(); @@ -1450,7 +1455,7 @@ // refreshRow( ); } // ------------------------------------------------------------------------- -void ORowSetCache::deleteRow( ) +bool ORowSetCache::deleteRow( ) { ::osl::MutexGuard aGuard( m_aRowCountMutex ); @@ -1459,11 +1464,13 @@ // 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(); + ORowSetMatrix::iterator aPos = calcPosition(); (*aPos) = NULL; // (*m_pMatrix)[(m_nPosition - m_nStartPos)] = NULL; // set the deleted row to NULL @@ -1476,7 +1483,7 @@ m_aMatrixIter = m_pMatrix->end(); --m_nPosition; - } + return true; } // ------------------------------------------------------------------------- void ORowSetCache::cancelRowUpdates( ) @@ -1505,7 +1512,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()) @@ -1545,18 +1552,12 @@ const Any *pBegin = rows.getConstArray(); const Any *pEnd = pBegin + rows.getLength(); - sal_Int32 nOldPosition; for(;pBegin != pEnd;++pBegin,++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(*pBegin) && m_pCacheSet->moveToBookmark(*pBegin) ) - { - nOldPosition = m_nPosition; - deleteRow(); - *pRet = (nOldPosition != m_nPosition) ? 1 : 0; - nOldPosition = m_nPosition; - } + *pRet = deleteRow() ? 1 : 0; } return aRet; } File [changed]: RowSetCache.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/RowSetCache.hxx?r1=1.25&r2=1.25.76.1 Delta lines: +6 -8 ------------------- --- RowSetCache.hxx 8 Sep 2005 10:01:59 -0000 1.25 +++ RowSetCache.hxx 16 Jan 2006 10:12:23 -0000 1.25.76.1 @@ -4,9 +4,9 @@ * * $RCSfile: RowSetCache.hxx,v $ * - * $Revision: 1.25 $ + * $Revision: 1.25.76.1 $ * - * last change: $Author: rt $ $Date: 2005/09/08 10:01:59 $ + * last change: $Author: fs $ $Date: 2006/01/16 10:12:23 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -159,7 +159,6 @@ sal_Bool m_bBeforeFirst ; sal_Bool m_bAfterLast ; sal_Bool m_bInserted; - sal_Bool m_bDeleted ; sal_Bool m_bUpdated ; sal_Bool& m_bModified ; // points to the rowset member m_bModified sal_Bool& m_bNew ; // points to the rowset member m_bNew @@ -257,8 +256,8 @@ sal_Bool isAfterLast( ); sal_Bool isFirst( ); sal_Bool isLast( ); - void beforeFirst( ); - void afterLast( ); + sal_Bool beforeFirst( ); + sal_Bool afterLast( ); sal_Bool first( ); sal_Bool last( ); sal_Int32 getRow( ); @@ -268,7 +267,6 @@ void refreshRow( ); sal_Bool rowUpdated( ); sal_Bool rowInserted( ); - sal_Bool rowDeleted( ); ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getStatement( ); // ::com::sun::star::sdbc::XResultSetUpdate @@ -277,7 +275,7 @@ void updateRow(); void updateRow( ORowSetMatrix::iterator& _rUpdateRow ); - void deleteRow(); + bool deleteRow(); void cancelRowUpdates( ); void moveToInsertRow( ); void moveToCurrentRow( ); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
