Tag: cws_src680_dba202f
User: fs      
Date: 06/01/26 22:54:05

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

Log:
 RESYNC: (1.80-1.83); 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.80.8.1&r2=1.80.8.2
Delta lines:  +55 -76
---------------------
--- RowSetCache.cxx     20 Jan 2006 14:51:46 -0000      1.80.8.1
+++ RowSetCache.cxx     27 Jan 2006 06:54:02 -0000      1.80.8.2
@@ -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)
@@ -306,18 +305,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
@@ -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)
@@ -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(  )
 {
@@ -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,7 +1303,7 @@
                m_aMatrixIter = m_pMatrix->end();
 
                --m_nPosition;
-       }
+    return true;
 }
 // 
-----------------------------------------------------------------------------
 void ORowSetCache::clearModified(  )
@@ -1334,7 +1337,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,35 +1363,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 *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(ORowSetBase* _pRowSet)
@@ -1424,6 +1398,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]

Reply via email to