User: rt      
Date: 2006/07/26 00:46:15

Modified:
   dba/dbaccess/source/core/api/RowSetCache.cxx

Log:
 INTEGRATION: CWS dba204b (1.85.8); FILE MERGED
 2006/07/13 07:10:53 fs 1.85.8.2: RESYNC: (1.85-1.86); FILE MERGED
 2006/07/10 07:59:46 oj 1.85.8.1: #i64770# rotate end as well, and removed some 
warnings plus extra debug code

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.86&r2=1.87
Delta lines:  +15 -6
--------------------
--- RowSetCache.cxx     10 Jul 2006 15:03:49 -0000      1.86
+++ RowSetCache.cxx     26 Jul 2006 07:46:13 -0000      1.87
@@ -127,6 +127,8 @@
 using namespace ::cppu;
 using namespace ::osl;
 
+#define CHECK_MATRIX_POS(M) OSL_ENSURE(((M) >= 
static_cast<ORowSetMatrix::difference_type>(0)) && ((M) < 
static_cast<sal_Int32>(m_pMatrix->size())),"Position is invalid!")
+
 DBG_NAME(ORowSetCache)
 // -------------------------------------------------------------------------
 ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
@@ -416,7 +418,7 @@
                {
                        aCacheIterToChange[aCacheIter->first] = sal_False;
                        if ( !aCacheIter->second.pRowSet->isInsertRow() 
-                               && aCacheIter->second.aIterator != 
m_pMatrix->end() && !m_bModified )
+                               /*&& aCacheIter->second.aIterator != 
m_pMatrix->end()*/ && !m_bModified )
                        {
                                ptrdiff_t nDist = (aCacheIter->second.aIterator 
- m_pMatrix->begin());
                                aPositions.push_back(nDist);
@@ -425,6 +427,8 @@
                }
                sal_Int32 nKeyPos = (m_aMatrixIter - m_pMatrix->begin());
                m_pMatrix->resize(_nSize);
+
+        CHECK_MATRIX_POS(nKeyPos);
                m_aMatrixIter = m_pMatrix->begin() + nKeyPos;
                m_aMatrixEnd = m_pMatrix->end();
 
@@ -435,10 +439,13 @@
                                aPosChangeIter != aCacheIterToChange.end();
                                ++aPosChangeIter,++aCacheIter)
                {
-                       if(aPosChangeIter->second)
+                       if ( aPosChangeIter->second )
+            {
+                CHECK_MATRIX_POS(*aIter);
                                aCacheIter->second.aIterator = 
m_pMatrix->begin() + *aIter++;
                }
        }
+       }
        if(!m_nPosition)
        {
                sal_Int32 nNewSt = 1;
@@ -512,7 +519,6 @@
 // -------------------------------------------------------------------------
 sal_Bool ORowSetCache::moveRelativeToBookmark( const Any& bookmark, sal_Int32 
rows )
 {
-       
        sal_Bool bRet( moveToBookmark( bookmark ) );
        if ( bRet )
        {
@@ -824,6 +830,7 @@
 #if OSL_DEBUG_LEVEL > 0
                                                        ORowSetMatrix::iterator 
aOldPos = aCacheIter->second.aIterator;
 #endif
+                            CHECK_MATRIX_POS( ((aOldPos - m_pMatrix->begin()) 
+ nOffSet) );
                                                        
aCacheIter->second.aIterator += nOffSet;
 #if OSL_DEBUG_LEVEL > 0
                                                        ORowSetMatrix::iterator 
aCurrentPos = aCacheIter->second.aIterator;
@@ -908,7 +915,7 @@
                        // the rows from begin() to (begin + nNewStartPos - 
m_nStartPos) can be refilled with the new rows
                        // 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()!");
+            CHECK_MATRIX_POS(nNewStartPos - m_nStartPos - 1);
                        ORowSetMatrix::iterator aEnd  = m_pMatrix->begin() + 
(nNewStartPos - m_nStartPos - 1);
 
                        sal_Int32 nPos = m_nStartPos + m_nFetchSize + 1;
@@ -970,6 +977,7 @@
                                bCheck  = m_pCacheSet->absolute(m_nStartPos);
                                for(; !aIter->isValid() && bCheck;++aIter)
                                {
+                    OSL_ENSURE(aIter != m_pMatrix->end(),"Invalid iterator");
                     bCheck = m_pCacheSet->next();
                                        if ( bCheck ) // resultset stands on 
right position
                                        {
@@ -1336,7 +1344,7 @@
     return 
ORowSetCacheIterator(m_aCacheIterators.insert(m_aCacheIterators.begin(),ORowSetCacheMap::value_type(m_aCacheIterators.size()+1,aHelper)),this,_pRowSet);
 }
 // 
-----------------------------------------------------------------------------
-void ORowSetCache::rotateCacheIterator(sal_Int16 _nDist)
+void ORowSetCache::rotateCacheIterator(ORowSetMatrix::difference_type _nDist)
 {
        if(_nDist)
        {
@@ -1354,6 +1362,7 @@
                                }
                                else
                                {
+                    OSL_ENSURE((aCacheIter->second.aIterator - 
m_pMatrix->begin()) >= _nDist,"Invalid Dist value!");
                                        aCacheIter->second.aIterator -= _nDist;
                                        OSL_ENSURE(aCacheIter->second.aIterator 
>= m_pMatrix->begin()
                                                        && 
aCacheIter->second.aIterator < m_pMatrix->end(),"Iterator out of area!");
@@ -1474,7 +1483,7 @@
 ORowSetMatrix::iterator        ORowSetCache::calcPosition() const
 {
        sal_Int32 nValue = (m_nPosition - m_nStartPos) - 1;
-       OSL_ENSURE(nValue >= 0 && nValue < 
static_cast<sal_Int32>(m_pMatrix->size()),"Position is invalid!");
+    CHECK_MATRIX_POS(nValue);
        return ( nValue < 0 || nValue >= 
static_cast<sal_Int32>(m_pMatrix->size()) ) ? m_pMatrix->end() : 
(m_pMatrix->begin() + nValue);
 }
 // 
-----------------------------------------------------------------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to