User: hr Date: 06/01/25 05:43:32 Modified: /dba/dbaccess/source/core/api/ RowSetCache.cxx
Log: INTEGRATION: CWS stlusagefix01 (1.80.10); FILE MERGED 2006/01/17 09:00:17 oj 1.80.10.3: #i60480# stl usage corrected 2006/01/17 06:55:27 oj 1.80.10.2: #i60480# stl calc corrected 2006/01/16 13:47:16 oj 1.80.10.1: #i60480# fix stl usage 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.81&r2=1.82 Delta lines: +37 -202 ---------------------- --- RowSetCache.cxx 16 Jan 2006 15:27:42 -0000 1.81 +++ RowSetCache.cxx 25 Jan 2006 13:43:29 -0000 1.82 @@ -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 @@ -412,9 +415,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(ORowSetBase::GrantNotifierAccess()) + && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bInserted && !m_bModified ) { sal_Int16 nDist = (aCacheIter->second.aIterator - m_pMatrix->begin()); aPositions.push_back(nDist); @@ -453,151 +455,6 @@ 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( ) { @@ -687,10 +544,6 @@ } // ------------------------------------------------------------------------- // XRowUpdate -void ORowSetCache::updateNull( sal_Int32 columnIndex ) -{ - updateValue(columnIndex,ORowSetValue()); -} // ----------------------------------------------------------------------------- void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x) { @@ -934,15 +787,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 +813,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(ORowSetBase::GrantNotifierAccess()) + && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bInserted && !m_bModified ) { sal_Int16 nDist = (aCacheIter->second.aIterator - m_pMatrix->begin()); if ( nDist >= nNewDist ) @@ -1053,7 +905,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); @@ -1349,12 +1201,6 @@ return m_bDeleted; } // ------------------------------------------------------------------------- -Reference< XInterface > ORowSetCache::getStatement( ) -{ - return m_pCacheSet->getStatement(); -} -// ------------------------------------------------------------------------- - // XResultSetUpdate sal_Bool ORowSetCache::insertRow( ) { @@ -1392,38 +1238,16 @@ // ------------------------------------------------------------------------- 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) - { - if ( aCacheIter->second.aIterator != m_pMatrix->end() ) + ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end(); + for(;aCacheIter != aCacheEnd;++aCacheIter) { - ORowSetMatrix::iterator aOldIter = aCacheIter->second.aIterator; - if(aOldIter == m_aInsertRow) + if ( aCacheIter->second.pRowSet->isInsertRow(ORowSetBase::GrantNotifierAccess()) && 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 ) { @@ -1468,7 +1292,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; @@ -1478,6 +1302,11 @@ --m_nPosition; } } +// ----------------------------------------------------------------------------- +void ORowSetCache::clearModified( ) +{ + m_bModified = sal_False; +} // ------------------------------------------------------------------------- void ORowSetCache::cancelRowUpdates( ) { @@ -1559,11 +1388,12 @@ } // ------------------------------------------------------------------------- -ORowSetCacheIterator ORowSetCache::createIterator() +ORowSetCacheIterator ORowSetCache::createIterator(ORowSetBase* _pRowSet) { 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) @@ -1574,7 +1404,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(ORowSetBase::GrantNotifierAccess()) + && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bInserted && !m_bModified ) { sal_Int16 nDist = (aCacheIter->second.aIterator - m_pMatrix->begin()); if(nDist < _nDist) @@ -1682,12 +1513,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]
