Tag: cws_src680_oj14 User: oj Date: 06/03/20 05:45:22 Modified: /dba/dbaccess/source/core/api/ RowSetCache.cxx
Log: RESYNC: (1.79-1.84); FILE MERGED 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.78.4.1&r2=1.78.4.2 Delta lines: +111 -340 ----------------------- --- RowSetCache.cxx 3 Jan 2006 08:07:46 -0000 1.78.4.1 +++ RowSetCache.cxx 20 Mar 2006 13:45:19 -0000 1.78.4.2 @@ -90,6 +90,9 @@ #ifndef DBACCESS_CORE_API_CROWSETCOLUMN_HXX #include "CRowSetColumn.hxx" #endif +#ifndef DBACCESS_CORE_API_ROWSETBASE_HXX +#include "RowSetBase.hxx" +#endif #ifndef _DBHELPER_DBEXCEPTION_HXX_ #include <connectivity/dbexception.hxx> #endif @@ -139,10 +142,8 @@ ,m_nPosition(0) ,m_nRowCount(0) ,m_bBeforeFirst(sal_True) - ,m_bAfterLast(sal_True) + ,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) @@ -303,18 +304,18 @@ sal_Bool bNoInsert = sal_False; Sequence< ::rtl::OUString> aNames(xColumns->getElementNames()); - const ::rtl::OUString* pBegin = aNames.getConstArray(); - const ::rtl::OUString* pEnd = pBegin + aNames.getLength(); - for(;pBegin != pEnd;++pBegin) + const ::rtl::OUString* pIter = aNames.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aNames.getLength(); + for(;pIter != pEnd;++pIter) { Reference<XPropertySet> xColumn; - ::cppu::extractInterface(xColumn,xColumns->getByName(*pBegin)); + ::cppu::extractInterface(xColumn,xColumns->getByName(*pIter)); OSL_ENSURE(xColumn.is(),"Column in table is null!"); if(xColumn.is()) { sal_Int32 nNullable = 0; xColumn->getPropertyValue(PROPERTY_ISNULLABLE) >>= nNullable; - if(nNullable == ColumnValue::NO_NULLS && aColumnNames.find(*pBegin) == aColumnNames.end()) + if(nNullable == ColumnValue::NO_NULLS && aColumnNames.find(*pIter) == aColumnNames.end()) { // we found a column where null is not allowed so we can't insert new values bNoInsert = sal_True; break; // one column is enough @@ -389,6 +390,7 @@ // ------------------------------------------------------------------------- void ORowSetCache::setMaxRowSize(sal_Int32 _nSize) { + if(_nSize == m_nFetchSize) return; @@ -412,9 +414,8 @@ for(;aCacheIter != m_aCacheIterators.end();++aCacheIter) { aCacheIterToChange[aCacheIter->first] = sal_False; - if ( aCacheIter->second.aIterator == m_pMatrix->end() ) - continue; - if(aCacheIter->second.aIterator != m_aInsertRow && !m_bInserted && !m_bModified) + if ( !aCacheIter->second.pRowSet->isInsertRow() + && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bModified ) { sal_Int16 nDist = (aCacheIter->second.aIterator - m_pMatrix->begin()); aPositions.push_back(nDist); @@ -453,154 +454,10 @@ return m_xMetaData; } // ------------------------------------------------------------------------- -// XRow -sal_Bool ORowSetCache::wasNull( ) -{ - if(m_bAfterLast) - throwFunctionSequenceException(m_xSet.get()); - - OSL_ENSURE(m_aMatrixIter != m_pMatrix->end(),"Iterator is equal end()"); - - return (*(*m_aMatrixIter))[m_nLastColumnIndex].isNull(); -} -// ----------------------------------------------------------------------------- -ORowSetValue ORowSetCache::getValue(sal_Int32 columnIndex) -{ - if(m_bAfterLast) - throwFunctionSequenceException(m_xSet.get()); - - OSL_ENSURE(m_aMatrixIter != m_pMatrix->end(),"Iterator is equal end()"); - - m_nLastColumnIndex = columnIndex; - return (*(*m_aMatrixIter))[m_nLastColumnIndex]; -} -// ------------------------------------------------------------------------- -::rtl::OUString ORowSetCache::getString( sal_Int32 columnIndex ) -{ - return getValue(columnIndex); -} -// ------------------------------------------------------------------------- -sal_Bool ORowSetCache::getBoolean( sal_Int32 columnIndex ) -{ - return getValue(columnIndex); -} -// ------------------------------------------------------------------------- -sal_Int8 ORowSetCache::getByte( sal_Int32 columnIndex ) -{ - return getValue(columnIndex); -} -// ------------------------------------------------------------------------- -sal_Int16 ORowSetCache::getShort( sal_Int32 columnIndex ) -{ - return getValue(columnIndex); -} -// ------------------------------------------------------------------------- -sal_Int32 ORowSetCache::getInt( sal_Int32 columnIndex ) -{ - return getValue(columnIndex); -} -// ------------------------------------------------------------------------- -sal_Int64 ORowSetCache::getLong( sal_Int32 columnIndex ) -{ - return getValue(columnIndex); -} -// ------------------------------------------------------------------------- -float ORowSetCache::getFloat( sal_Int32 columnIndex ) -{ - return getValue(columnIndex); -} -// ------------------------------------------------------------------------- -double ORowSetCache::getDouble( sal_Int32 columnIndex ) -{ - return getValue(columnIndex); -} -// ------------------------------------------------------------------------- -Sequence< sal_Int8 > ORowSetCache::getBytes( sal_Int32 columnIndex ) -{ - return getValue(columnIndex); -} -// ------------------------------------------------------------------------- -::com::sun::star::util::Date ORowSetCache::getDate( sal_Int32 columnIndex ) -{ - return getValue(columnIndex); -} -// ------------------------------------------------------------------------- -::com::sun::star::util::Time ORowSetCache::getTime( sal_Int32 columnIndex ) -{ - return getValue(columnIndex); -} -// ------------------------------------------------------------------------- -::com::sun::star::util::DateTime ORowSetCache::getTimestamp( sal_Int32 columnIndex ) -{ - return getValue(columnIndex); -} -// ------------------------------------------------------------------------- -Reference< ::com::sun::star::io::XInputStream > ORowSetCache::getBinaryStream( sal_Int32 columnIndex ) -{ - if(m_bAfterLast) - throwFunctionSequenceException(m_xSet.get()); - - OSL_ENSURE(m_aMatrixIter != m_pMatrix->end(),"Iterator is equal end()"); - - m_nLastColumnIndex = columnIndex; - return new ::comphelper::SequenceInputStream((*(*m_aMatrixIter))[m_nLastColumnIndex].getSequence()); -} -// ------------------------------------------------------------------------- -Reference< ::com::sun::star::io::XInputStream > ORowSetCache::getCharacterStream( sal_Int32 columnIndex ) -{ - if(m_bAfterLast) - throwFunctionSequenceException(m_xSet.get()); - - OSL_ENSURE(m_aMatrixIter != m_pMatrix->end(),"Iterator is equal end()"); - - m_nLastColumnIndex = columnIndex; - return new ::comphelper::SequenceInputStream((*(*m_aMatrixIter))[m_nLastColumnIndex].getSequence()); -} -// ------------------------------------------------------------------------- -Any ORowSetCache::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) -{ - if(m_bAfterLast) - throwFunctionSequenceException(m_xSet.get()); - - return Any(); -} -// ------------------------------------------------------------------------- -Reference< XRef > ORowSetCache::getRef( sal_Int32 columnIndex ) -{ - if(m_bAfterLast) - throwFunctionSequenceException(m_xSet.get()); - - return Reference< XRef >(); -} -// ------------------------------------------------------------------------- -Reference< XBlob > ORowSetCache::getBlob( sal_Int32 columnIndex ) -{ - if(m_bAfterLast) - throwFunctionSequenceException(m_xSet.get()); - - return Reference< XBlob >(); -} -// ------------------------------------------------------------------------- -Reference< XClob > ORowSetCache::getClob( sal_Int32 columnIndex ) -{ - if(m_bAfterLast) - throwFunctionSequenceException(m_xSet.get()); - - return Reference< XClob >(); -} -// ------------------------------------------------------------------------- -Reference< XArray > ORowSetCache::getArray( sal_Int32 columnIndex ) -{ - if(m_bAfterLast) - throwFunctionSequenceException(m_xSet.get()); - - return Reference< XArray >(); -} -// ------------------------------------------------------------------------- - // ::com::sun::star::sdbcx::XRowLocate Any ORowSetCache::getBookmark( ) { + if(m_bAfterLast) throwFunctionSequenceException(m_xSet.get()); @@ -625,12 +482,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(); @@ -658,6 +512,7 @@ // ------------------------------------------------------------------------- sal_Bool ORowSetCache::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) { + sal_Bool bRet; if(bRet = moveToBookmark(bookmark)) { @@ -678,36 +533,33 @@ // ------------------------------------------------------------------------- sal_Bool ORowSetCache::hasOrderedBookmarks( ) { + return m_pCacheSet->hasOrderedBookmarks(); } // ------------------------------------------------------------------------- sal_Int32 ORowSetCache::hashBookmark( const Any& bookmark ) { + return m_pCacheSet->hashBookmark(bookmark); } // ------------------------------------------------------------------------- // XRowUpdate -void ORowSetCache::updateNull( sal_Int32 columnIndex ) -{ - updateValue(columnIndex,ORowSetValue()); -} // ----------------------------------------------------------------------------- void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x) { checkUpdateConditions(columnIndex); - ::osl::MutexGuard aGuard( m_aColumnsMutex ); + (*(*m_aInsertRow))[columnIndex].setBound(sal_True); (*(*m_aInsertRow))[columnIndex] = x; (*(*m_aInsertRow))[columnIndex].setModified(); - m_bModified = sal_True; } // ------------------------------------------------------------------------- void ORowSetCache::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) { checkUpdateConditions(columnIndex); - ::osl::MutexGuard aGuard( m_aColumnsMutex ); + Sequence<sal_Int8> aSeq; if(x.is()) x->readSomeBytes(aSeq,length); @@ -718,7 +570,7 @@ { checkUpdateConditions(columnIndex); - ::osl::MutexGuard aGuard( m_aColumnsMutex ); + Sequence<sal_Int8> aSeq; if(x.is()) x->readSomeBytes(aSeq,length); @@ -730,34 +582,32 @@ { checkUpdateConditions(columnIndex); - ::osl::MutexGuard aGuard( m_aColumnsMutex ); + (*(*m_aInsertRow))[columnIndex].setBound(sal_True); (*(*m_aInsertRow))[columnIndex] = x; (*(*m_aInsertRow))[columnIndex].setModified(); - m_bModified = sal_True; } // ------------------------------------------------------------------------- void ORowSetCache::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 scale ) { checkUpdateConditions(columnIndex); - ::osl::MutexGuard aGuard( m_aColumnsMutex ); + (*(*m_aInsertRow))[columnIndex].setBound(sal_True); (*(*m_aInsertRow))[columnIndex] = x; (*(*m_aInsertRow))[columnIndex].setModified(); - m_bModified = sal_True; - } // ------------------------------------------------------------------------- // XResultSet sal_Bool ORowSetCache::next( ) { - ::osl::MutexGuard aGuard( m_aRowCountMutex ); + if(!isAfterLast()) { 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) @@ -776,34 +626,32 @@ sal_Bool ORowSetCache::isBeforeFirst( ) { // return !m_nPosition; - ::osl::MutexGuard aGuard( m_aRowCountMutex ); + return m_bBeforeFirst; } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::isAfterLast( ) { - // return m_pCacheSet->isAfterLast(); - // return m_bRowCountFinal ? m_bAfterLast : m_pCacheSet->isAfterLast(); - ::osl::MutexGuard aGuard( m_aRowCountMutex ); + return m_bAfterLast; } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::isFirst( ) { - ::osl::MutexGuard aGuard( m_aRowCountMutex ); + return m_nPosition == 1; // ask resultset for } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::isLast( ) { // return m_bRowCountFinal ? (m_nPosition==m_nRowCount) : m_pCacheSet->isLast(); - ::osl::MutexGuard aGuard( m_aRowCountMutex ); + return m_nPosition == m_nRowCount; } // ------------------------------------------------------------------------- -void ORowSetCache::beforeFirst( ) +sal_Bool ORowSetCache::beforeFirst( ) { - ::osl::MutexGuard aGuard( m_aRowCountMutex ); + if(!m_bBeforeFirst) { @@ -814,11 +662,12 @@ moveWindow(); m_aMatrixIter = m_pMatrix->end(); } + return sal_True; } // ------------------------------------------------------------------------- -void ORowSetCache::afterLast( ) +sal_Bool ORowSetCache::afterLast( ) { - ::osl::MutexGuard aGuard( m_aRowCountMutex ); + if(!m_bAfterLast) { @@ -836,6 +685,7 @@ m_nPosition = 0; m_aMatrixIter = m_pMatrix->end(); } + return sal_True; } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos) @@ -909,6 +759,7 @@ // ------------------------------------------------------------------------- sal_Bool ORowSetCache::moveWindow() { + sal_Bool bRet = sal_True; sal_Int32 nDiff = (sal_Int32)(m_nFetchSize*0.5 -0.5); @@ -934,15 +785,15 @@ bCheck = m_pCacheSet->first(); // aEnd = m_pMatrix->begin() + (sal_Int32)(m_nFetchSize*0.5); OSL_ENSURE((nNewEndPos - m_nStartPos - nNewStartPos) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!"); - aEnd = m_pMatrix->begin() + nNewEndPos - m_nStartPos - nNewStartPos; + aEnd = m_pMatrix->begin() + (nNewEndPos - m_nStartPos - nNewStartPos); aIter = aEnd; m_nStartPos = 0; } else { OSL_ENSURE((nNewEndPos - m_nStartPos -1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!"); - aEnd = m_pMatrix->begin() + (nNewEndPos - m_nStartPos)-1; - aIter = m_pMatrix->begin() + (nNewEndPos - m_nStartPos)-1; + aEnd = m_pMatrix->begin() + ((nNewEndPos - m_nStartPos)-1); + aIter = m_pMatrix->begin() + ((nNewEndPos - m_nStartPos)-1); bCheck = m_pCacheSet->absolute(nNewStartPos); m_nStartPos = nNewStartPos -1; } @@ -960,9 +811,8 @@ ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin(); for(;aCacheIter != m_aCacheIterators.end();++aCacheIter) { - if ( aCacheIter->second.aIterator != m_pMatrix->end() - && aCacheIter->second.aIterator != m_aInsertRow - && !m_bInserted && !m_bModified ) + if ( !aCacheIter->second.pRowSet->isInsertRow() + && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bModified ) { sal_Int16 nDist = (aCacheIter->second.aIterator - m_pMatrix->begin()); if ( nDist >= nNewDist ) @@ -996,6 +846,8 @@ { m_nStartPos = 0; + rotateCacheIterator(static_cast<sal_Int16>(m_nFetchSize+1)); // static_cast<sal_Int16>(m_nFetchSize+1) + m_pCacheSet->beforeFirst(); sal_Bool bCheck; @@ -1010,7 +862,6 @@ } else *aIter = NULL; - } } else @@ -1053,7 +904,7 @@ // the rows behind this can be reused ORowSetMatrix::iterator aIter = m_pMatrix->begin(); OSL_ENSURE((nNewStartPos - m_nStartPos - 1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!"); - ORowSetMatrix::iterator aEnd = m_pMatrix->begin() + nNewStartPos - m_nStartPos - 1; + ORowSetMatrix::iterator aEnd = m_pMatrix->begin() + (nNewStartPos - m_nStartPos - 1); sal_Int32 nPos = m_nStartPos + m_nFetchSize + 1; sal_Bool bCheck = m_pCacheSet->absolute(nPos); @@ -1135,8 +986,6 @@ // ------------------------------------------------------------------------- sal_Bool ORowSetCache::first( ) { - ::osl::MutexGuard aGuard( m_aRowCountMutex ); - // first move to the first row // then check if the cache window is at the begining // when not postionize the window and fill it with data @@ -1154,7 +1003,7 @@ m_bRowCountFinal = m_bBeforeFirst = m_bAfterLast = sal_True; m_nRowCount = m_nPosition = 0; - OSL_ENSURE(m_bBeforeFirst || (m_bNew && m_bInserted),"ORowSetCache::first return false and BeforeFirst isn't true"); + OSL_ENSURE(m_bBeforeFirst || m_bNew,"ORowSetCache::first return false and BeforeFirst isn't true"); m_aMatrixIter = m_pMatrix->end(); } return bRet; @@ -1162,8 +1011,6 @@ // ------------------------------------------------------------------------- sal_Bool ORowSetCache::last( ) { - ::osl::MutexGuard aGuard( m_aRowCountMutex ); - sal_Bool bRet = m_pCacheSet->last(); if(bRet) { @@ -1203,15 +1050,11 @@ // ------------------------------------------------------------------------- sal_Int32 ORowSetCache::getRow( ) { - ::osl::MutexGuard aGuard( m_aRowCountMutex ); - return (isBeforeFirst() || isAfterLast()) ? 0 : m_nPosition; } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::absolute( sal_Int32 row ) { - ::osl::MutexGuard aGuard( m_aRowCountMutex ); - if(!row ) throw SQLException(DBACORE_RESSTRING(RID_STR_NO_ABS_ZERO),NULL,SQLSTATE_GENERAL,1000,Any() ); @@ -1265,30 +1108,34 @@ // ------------------------------------------------------------------------- sal_Bool ORowSetCache::relative( sal_Int32 rows ) { - ::osl::MutexGuard aGuard( m_aRowCountMutex ); - 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) + 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(m_nPosition + rows); - + bErg = absolute( nNewPosition ); bErg = bErg && !isAfterLast() && !isBeforeFirst(); } else - bErg = !(m_bBeforeFirst = sal_True); + { + m_bBeforeFirst = sal_True; + bErg = sal_False; + } } return bErg; } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::previous( ) { - ::osl::MutexGuard aGuard( m_aRowCountMutex ); - sal_Bool bRet = sal_False; if(!isBeforeFirst()) { @@ -1320,14 +1167,12 @@ // ------------------------------------------------------------------------- void ORowSetCache::refreshRow( ) { - ::osl::MutexGuard aGuard( m_aRowCountMutex ); - if(isAfterLast()) throw SQLException(DBACORE_RESSTRING(RID_STR_NO_REFESH_AFTERLAST),NULL,SQLSTATE_GENERAL,1000,Any() ); OSL_ENSURE(m_aMatrixIter != m_pMatrix->end(),"refreshRow() called for invalid row!"); m_pCacheSet->refreshRow(); m_pCacheSet->fillValueRow(*m_aMatrixIter,m_nPosition); - if ( m_bInserted ) + if ( m_bNew ) { cancelRowModification(); } @@ -1343,24 +1188,10 @@ return m_pCacheSet->rowInserted(); } // ------------------------------------------------------------------------- -sal_Bool ORowSetCache::rowDeleted( ) -{ - // return m_pCacheSet->rowDeleted(); - return m_bDeleted; -} -// ------------------------------------------------------------------------- -Reference< XInterface > ORowSetCache::getStatement( ) -{ - return m_pCacheSet->getStatement(); -} -// ------------------------------------------------------------------------- - // XResultSetUpdate sal_Bool ORowSetCache::insertRow( ) { - ::osl::MutexGuard aGuard( m_aRowCountMutex ); - - if ( !m_bInserted || !m_aInsertRow->isValid() ) + if ( !m_bNew || !m_aInsertRow->isValid() ) throw SQLException(DBACORE_RESSTRING(RID_STR_NO_MOVETOINSERTROW_CALLED),NULL,SQLSTATE_GENERAL,1000,Any() ); sal_Bool bRet; @@ -1387,48 +1218,23 @@ clearInsertRow(); m_bNew = sal_False; m_bModified = sal_False; - m_bInserted = sal_False; } // ------------------------------------------------------------------------- void ORowSetCache::cancelRowModification() { - resetInsertRow(sal_False); - // clear the insertrow references -> implies that the current row of the rowset changes as well ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin(); - for(;aCacheIter != m_aCacheIterators.end();++aCacheIter) + ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end(); + for(;aCacheIter != aCacheEnd;++aCacheIter) { - if ( aCacheIter->second.aIterator != m_pMatrix->end() ) - { - ORowSetMatrix::iterator aOldIter = aCacheIter->second.aIterator; - if(aOldIter == m_aInsertRow) + if ( aCacheIter->second.pRowSet->isInsertRow() && aCacheIter->second.aIterator == m_aInsertRow ) aCacheIter->second.aIterator = m_pMatrix->end(); - } - } -} -// ------------------------------------------------------------------------- -/* -void ORowSetCache::updateRow( ) -{ - ::osl::MutexGuard aGuard( m_aRowCountMutex ); - - if(isAfterLast() || isBeforeFirst()) - throw SQLException(DBACORE_RESSTRING(RID_STR_NO_UPDATEROW),NULL,SQLSTATE_GENERAL,1000,Any() ); - - m_pCacheSet->updateRow(*m_aInsertRow,*m_aMatrixIter,m_aUpdateTable); - - clearInsertRow(); - - // we don't need to repositioning here refresh will do it for us - m_bModified = sal_False; - refreshRow( ); + } // for(;aCacheIter != aCacheEnd;++aCacheIter) + resetInsertRow(sal_False); } -*/ // ------------------------------------------------------------------------- void ORowSetCache::updateRow( ORowSetMatrix::iterator& _rUpdateRow ) { - ::osl::MutexGuard aGuard( m_aRowCountMutex ); - if(isAfterLast() || isBeforeFirst()) throw SQLException(DBACORE_RESSTRING(RID_STR_NO_UPDATEROW),NULL,SQLSTATE_GENERAL,1000,Any() ); @@ -1450,17 +1256,16 @@ // refreshRow( ); } // ------------------------------------------------------------------------- -void ORowSetCache::deleteRow( ) +bool ORowSetCache::deleteRow( ) { - ::osl::MutexGuard aGuard( m_aRowCountMutex ); - if(isAfterLast() || isBeforeFirst()) throw SQLException(DBACORE_RESSTRING(RID_STR_NO_DELETEROW),NULL,SQLSTATE_GENERAL,1000,Any() ); // 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(); @@ -1468,7 +1273,7 @@ // (*m_pMatrix)[(m_nPosition - m_nStartPos)] = NULL; // set the deleted row to NULL - for(++aPos;aPos->isValid() && aPos != m_pMatrix->end();++aPos) + for(++aPos;aPos != m_pMatrix->end() && aPos->isValid();++aPos) { *(aPos-1) = *aPos; (*aPos) = NULL; @@ -1476,14 +1281,12 @@ m_aMatrixIter = m_pMatrix->end(); --m_nPosition; - } + return true; } // ------------------------------------------------------------------------- void ORowSetCache::cancelRowUpdates( ) { - ::osl::MutexGuard aGuard( m_aRowCountMutex ); - - m_bNew = m_bInserted = m_bModified = sal_False; + m_bNew = m_bModified = sal_False; if(!m_nPosition) { OSL_ENSURE(0,"cancelRowUpdates:Invalid positions pos == 0"); @@ -1501,11 +1304,8 @@ // ------------------------------------------------------------------------- void ORowSetCache::moveToInsertRow( ) { - ::osl::MutexGuard aGuard( m_aRowCountMutex ); - 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()) @@ -1521,52 +1321,13 @@ } } // ------------------------------------------------------------------------- -void ORowSetCache::moveToCurrentRow( ) -{ - ::osl::MutexGuard aGuard( m_aRowCountMutex ); - -// if(m_bInserted) -// { -// m_pCacheSet->moveToCurrentRow(); -// m_bInserted = sal_False; -// } -} -// ------------------------------------------------------------------------- -// ::com::sun::star::sdbcx::XDeleteRows -Sequence< sal_Int32 > ORowSetCache::deleteRows( const Sequence< Any >& rows ) +ORowSetCacheIterator ORowSetCache::createIterator(ORowSetBase* _pRowSet) { - // 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 *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; - } - } - return aRet; -} - -// ------------------------------------------------------------------------- -ORowSetCacheIterator ORowSetCache::createIterator() -{ ORowSetCacheIterator_Helper aHelper; aHelper.aIterator = m_pMatrix->end(); - return ORowSetCacheIterator(m_aCacheIterators.insert(m_aCacheIterators.begin(),ORowSetCacheMap::value_type(m_aCacheIterators.size()+1,aHelper)),this); + aHelper.pRowSet = _pRowSet; + return ORowSetCacheIterator(m_aCacheIterators.insert(m_aCacheIterators.begin(),ORowSetCacheMap::value_type(m_aCacheIterators.size()+1,aHelper)),this,_pRowSet); } // ----------------------------------------------------------------------------- void ORowSetCache::rotateCacheIterator(sal_Int16 _nDist) @@ -1577,7 +1338,8 @@ ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin(); for(;aCacheIter != m_aCacheIterators.end();++aCacheIter) { - if ( aCacheIter->second.aIterator != m_pMatrix->end() && aCacheIter->second.aIterator != m_aInsertRow && !m_bInserted && !m_bModified) + if ( !aCacheIter->second.pRowSet->isInsertRow() + && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bModified ) { sal_Int16 nDist = (aCacheIter->second.aIterator - m_pMatrix->begin()); if(nDist < _nDist) @@ -1594,6 +1356,11 @@ } } } +// ----------------------------------------------------------------------------- +void ORowSetCache::clearModified( ) +{ + m_bModified = sal_False; +} // ------------------------------------------------------------------------- void ORowSetCache::setUpdateIterator(const ORowSetMatrix::iterator& _rOriginalRow) { @@ -1685,12 +1452,16 @@ void ORowSetCache::clearInsertRow() { // we don't unbound the bookmark column + if ( m_aInsertRow != m_pInsertMatrix->end() && m_aInsertRow->isValid() ) + { ORowSetValueVector::iterator aIter = (*m_aInsertRow)->begin()+1; - for(;aIter != (*m_aInsertRow)->end();++aIter) + ORowSetValueVector::iterator aEnd = (*m_aInsertRow)->end(); + for(;aIter != aEnd;++aIter) { aIter->setBound(sal_False); aIter->setModified(sal_False); aIter->setNull(); + } // for(;aIter != (*m_aInsertRow)->end();++aIter) } } // ----------------------------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
