Tag: cws_src680_rowsetdel
User: fs      
Date: 06/01/20 01:02:54

Modified:
 /dba/dbaccess/source/core/api/
  RowSet.cxx, RowSet.hxx, RowSetBase.cxx, RowSetBase.hxx

Log:
 #i55731# deletion of rows even more refined

File Changes:

Directory: /dba/dbaccess/source/core/api/
=========================================

File [changed]: RowSet.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/RowSet.cxx?r1=1.139.16.4&r2=1.139.16.5
Delta lines:  +37 -31
---------------------
--- RowSet.cxx  19 Jan 2006 09:04:06 -0000      1.139.16.4
+++ RowSet.cxx  20 Jan 2006 09:02:48 -0000      1.139.16.5
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: RowSet.cxx,v $
  *
- *  $Revision: 1.139.16.4 $
+ *  $Revision: 1.139.16.5 $
  *
- *  last change: $Author: fs $ $Date: 2006/01/19 09:04:06 $
+ *  last change: $Author: fs $ $Date: 2006/01/20 09:02:48 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -1111,9 +1111,11 @@
 
        // this call position the cache indirect
     Any aBookmarkToDelete( m_aBookmark );
-       notifyRowSetAndClonesRowDelete( aBookmarkToDelete );
 
        positionCache( MOVE_NONE_REFRESH_ONLY );
+    sal_Int32 nDeletePosition = m_pCache->getRow();
+
+    notifyRowSetAndClonesRowDelete( aBookmarkToDelete, nDeletePosition );
 
        ORowSetRow aOldValues;
        if ( m_pCache->m_aMatrixIter != m_pCache->getEnd() && 
m_pCache->m_aMatrixIter->isValid() )
@@ -1123,7 +1125,7 @@
        notifyAllListenersRowBeforeChange(aGuard,aEvt);
 
     m_pCache->deleteRow();
-       notifyRowSetAndClonesRowDeleted( aBookmarkToDelete );
+       notifyRowSetAndClonesRowDeleted( aBookmarkToDelete, nDeletePosition );
 
        ORowSetNotifier aNotifier( this );
                // this will call cancelRowModification on the cache if 
necessary
@@ -1965,30 +1967,34 @@
 
        ::osl::ResettableMutexGuard aGuard( *m_pMutex );
 
-       Sequence< sal_Int32 > aRet;
        RowChangeEvent aEvt(*this,RowChangeAction::DELETE,rows.getLength());
        // notify the rowset listeners
        notifyAllListenersRowBeforeChange(aGuard,aEvt);
 
+    Sequence< sal_Int32 > aResults( rows.getLength() );
+    const Any* row = rows.getConstArray();
+    const Any* rowEnd = rows.getConstArray() + rows.getLength();
+    sal_Int32* result = aResults.getArray();
+    for ( ; row != rowEnd; ++row, ++result )
+    {
+        *result = 0;
+        if ( !m_pCache->moveToBookmark( *row ) )
+            continue;
+        sal_Int32 nDeletePosition = m_pCache->getRow();
+
     // first notify the clones so that they can save their position
-       const Any* pBegin = rows.getConstArray();
-       const Any* pEnd   = pBegin + rows.getLength();
-       for(;pBegin != pEnd;++pBegin)
-               notifyRowSetAndClonesRowDelete(*pBegin);
+               notifyRowSetAndClonesRowDelete( *row, nDeletePosition );
 
-    // now delete the rows
-       aRet = m_pCache->deleteRows(rows);
+        // now delete the row
+        if ( !m_pCache->deleteRow() )
+            continue;
+        *result = 1;
 
        // now notify that we have deleted
-       pBegin = rows.getConstArray();
-
-       const sal_Int32* pRetBegin      = aRet.getConstArray();
-       OSL_ENSURE(aRet.getLength() == rows.getLength(),"ORowSet::deleteRows: 
The length of the rows and return status is not equal!");
-       for (;pBegin != pEnd;++pBegin)
-               if ( *pRetBegin )
-                       notifyRowSetAndClonesRowDeleted( *pBegin );
+               notifyRowSetAndClonesRowDeleted( *row, nDeletePosition );
+    }
 
-       aEvt.Rows = aRet.getLength();
+       aEvt.Rows = aResults.getLength();
 
        // we have to check if we stand on the insert row and if so we have to 
reset it
        ORowSetNotifier aNotifier( this );
@@ -2005,13 +2011,13 @@
        // - RowCount/IsRowCountFinal
        fireRowcount();
 
-    return aRet;
+    return aResults;
 }
 // 
-----------------------------------------------------------------------------
-void ORowSet::notifyRowSetAndClonesRowDelete(const Any& _rBookmark)
+void ORowSet::notifyRowSetAndClonesRowDelete( const Any& _rBookmark, sal_Int32 
_nPos )
 {
     // notify ourself
-    onDeleteRow(_rBookmark);
+    onDeleteRow( _rBookmark, _nPos );
     // notify the clones
        for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); 
m_aClones.end() != i; i++)
        {
@@ -2020,15 +2026,15 @@
                {
                        ORowSetClone* pClone = 
reinterpret_cast<ORowSetClone*>(xTunnel->getSomething(ORowSetClone::getUnoTunnelImplementationId()));
                        if(pClone)
-                               pClone->onDeleteRow(_rBookmark);
+                               pClone->onDeleteRow( _rBookmark, _nPos );
                }
        }
 }
 
//------------------------------------------------------------------------------
-void ORowSet::notifyRowSetAndClonesRowDeleted( const Any& _rBookmark )
+void ORowSet::notifyRowSetAndClonesRowDeleted( const Any& _rBookmark, 
sal_Int32 _nPos )
 {
     // notify ourself
-    onDeletedRow(_rBookmark);
+    onDeletedRow( _rBookmark, _nPos );
     // notify the clones
        for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); 
m_aClones.end() != i; i++)
        {
@@ -2037,7 +2043,7 @@
                {
                        ORowSetClone* pClone = 
reinterpret_cast<ORowSetClone*>(xTunnel->getSomething(ORowSetClone::getUnoTunnelImplementationId()));
                        if(pClone)
-                               pClone->onDeletedRow(_rBookmark);
+                               pClone->onDeletedRow( _rBookmark, _nPos );
                }
        }
 }

File [changed]: RowSet.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/RowSet.hxx?r1=1.41.74.1&r2=1.41.74.2
Delta lines:  +4 -4
-------------------
--- RowSet.hxx  16 Jan 2006 10:12:37 -0000      1.41.74.1
+++ RowSet.hxx  20 Jan 2006 09:02:49 -0000      1.41.74.2
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: RowSet.hxx,v $
  *
- *  $Revision: 1.41.74.1 $
+ *  $Revision: 1.41.74.2 $
  *
- *  last change: $Author: fs $ $Date: 2006/01/16 10:12:37 $
+ *  last change: $Author: fs $ $Date: 2006/01/20 09:02:49 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -183,10 +183,10 @@
                void firePropertyChange(sal_Int32 _nPos,const 
::connectivity::ORowSetValue& _rNewValue);
 
         /// informs the clones (and ourself) that we are going to delete a 
record with a given bookmark
-               void notifyRowSetAndClonesRowDelete(const 
::com::sun::star::uno::Any& _rBookmark);
+               void notifyRowSetAndClonesRowDelete( const 
::com::sun::star::uno::Any& _rBookmark, sal_Int32 _nPos );
 
         /// inform the clones (and ourself) that we have deleted a record with 
a given bookmark
-               void notifyRowSetAndClonesRowDeleted(const 
::com::sun::star::uno::Any& _rBookmark);
+               void notifyRowSetAndClonesRowDeleted( const 
::com::sun::star::uno::Any& _rBookmark, sal_Int32 _nPos );
 
         void checkUpdateIterator();
                const connectivity::ORowSetValue& getInsertValue(sal_Int32 
columnIndex);

File [changed]: RowSetBase.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/RowSetBase.cxx?r1=1.80.12.6&r2=1.80.12.7
Delta lines:  +20 -14
---------------------
--- RowSetBase.cxx      19 Jan 2006 09:04:07 -0000      1.80.12.6
+++ RowSetBase.cxx      20 Jan 2006 09:02:50 -0000      1.80.12.7
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: RowSetBase.cxx,v $
  *
- *  $Revision: 1.80.12.6 $
+ *  $Revision: 1.80.12.7 $
  *
- *  last change: $Author: fs $ $Date: 2006/01/19 09:04:07 $
+ *  last change: $Author: fs $ $Date: 2006/01/20 09:02:50 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -1303,29 +1303,35 @@
        return Any();
 }
 // 
-----------------------------------------------------------------------------
-void ORowSetBase::onDeleteRow(const Any& _rBookmark)
+void ORowSetBase::onDeleteRow( const Any& _rBookmark, sal_Int32 _nPos )
 {
     if ( rowDeleted() )
-        // nothing to do. The row at which we're currently positioned is 
already deleted, so
-        // we're not interested in if another one also gets deleted
+        // not interested in
         return;
 
-       if ( compareBookmarks( _rBookmark, m_aBookmark ) == 0 )
-       {
-           OSL_ENSURE( m_aBookmark.hasValue(), "ORowSetBase::onDeleteRow: 
Bookmark isn't valid!" );
                ::osl::MutexGuard aGuard( *m_pMutex );
-        positionCache( MOVE_NONE_REFRESH_ONLY );
-               m_nDeletedPosition = m_pCache->getRow();
-       }
+       OSL_ENSURE( m_aBookmark.hasValue(), "ORowSetBase::onDeleteRow: Bookmark 
isn't valid!" );
+       if ( compareBookmarks( _rBookmark, m_aBookmark ) == 0 )
+               m_nDeletedPosition = _nPos;
 }
 // 
-----------------------------------------------------------------------------
-void ORowSetBase::onDeletedRow(const Any& _rBookmark)
+void ORowSetBase::onDeletedRow( const Any& _rBookmark, sal_Int32 _nPos )
 {
     if ( rowDeleted() )
-        // nothing to do. The row at which we're currently positioned is 
already deleted, so
-        // we're not interested in if another one also has been deleted
+    {
+        // if we're a clone, and on a deleted row, and the main RowSet deleted 
another
+        // row (only the main RowSet can, clones can't), which is *before* our
+        // deleted position, then we have to adjust this position
+        if ( m_bClone )
+        {
+            DBG_ASSERT( _nPos != m_nDeletedPosition, 
"ORowSetBase::onDeletedRow: deleted the same row again?" );
+            if ( _nPos < m_nDeletedPosition )
+                --m_nDeletedPosition;
+        }
         return;
+    }
 
+       ::osl::MutexGuard aGuard( *m_pMutex );
        if ( compareBookmarks( _rBookmark, m_aBookmark ) == 0 )
        {
                m_aOldRow->clearRow();

File [changed]: RowSetBase.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/RowSetBase.hxx?r1=1.32.74.2&r2=1.32.74.3
Delta lines:  +4 -4
-------------------
--- RowSetBase.hxx      19 Jan 2006 09:04:07 -0000      1.32.74.2
+++ RowSetBase.hxx      20 Jan 2006 09:02:51 -0000      1.32.74.3
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: RowSetBase.hxx,v $
  *
- *  $Revision: 1.32.74.2 $
+ *  $Revision: 1.32.74.3 $
  *
- *  last change: $Author: fs $ $Date: 2006/01/19 09:04:07 $
+ *  last change: $Author: fs $ $Date: 2006/01/20 09:02:51 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -351,9 +351,9 @@
                virtual void SAL_CALL removeRowSetListener( const 
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSetListener >& 
listener ) throw(::com::sun::star::uno::RuntimeException) = 0;
 
                // is called when the rowset is going to delete this bookmark 
_rBookmark
-               void onDeleteRow(const ::com::sun::star::uno::Any& _rBookmark);
+               void onDeleteRow( const ::com::sun::star::uno::Any& _rBookmark, 
sal_Int32 _nPos );
                // is called when the rowset has deleted this bookmark 
_rBookmark
-               void onDeletedRow(const ::com::sun::star::uno::Any& _rBookmark);
+               void onDeletedRow( const ::com::sun::star::uno::Any& 
_rBookmark, sal_Int32 _nPos );
 
                // ==========================================================
                // granular access control




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

Reply via email to