Tag: cws_src680_oj14
User: oj      
Date: 06/03/20 05:44:07

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

Log:
 RESYNC: (1.139-1.142); FILE MERGED

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.137.4.2&r2=1.137.4.3
Delta lines:  +251 -253
-----------------------
--- RowSet.cxx  3 Jan 2006 13:11:58 -0000       1.137.4.2
+++ RowSet.cxx  20 Mar 2006 13:44:04 -0000      1.137.4.3
@@ -134,9 +134,6 @@
 #ifndef _DBHELPER_DBEXCEPTION_HXX_
 #include <connectivity/dbexception.hxx>
 #endif
-#ifndef _CONNECTIVITY_DBTOOLS_HXX_
-#include <connectivity/dbtools.hxx>
-#endif
 #ifndef DBACCESS_CORE_API_SINGLESELECTQUERYCOMPOSER_HXX
 #include "SingleSelectQueryComposer.hxx"
 #endif
@@ -272,19 +269,12 @@
        ,m_nMaxFieldSize(0)
        ,m_nTransactionIsolation(0)
        ,m_nPrivileges(0)
-       ,m_nAsyncUpdateRowCount(0)
        ,m_nMaxRows(0)
        ,m_nQueryTimeOut(0)
        ,m_bUseEscapeProcessing(sal_True)
        ,m_bApplyFilter(sal_False)
-       ,m_bInserted(sal_False)
-       ,m_bDeleted(sal_False)
-       ,m_bUpdated(sal_False)
        ,m_bCreateStatement(sal_True)
-       ,m_bCanceled(sal_False)
-       ,m_bRowObsolete(sal_False)
        ,m_bModified(sal_False)
-       ,m_bOwnsResultRow(sal_False)
        ,m_bRebuildConnOnExecute(sal_False)
        ,m_bNew(sal_False)
        ,m_bIsBookmarable(sal_True)
@@ -713,10 +703,10 @@
                m_aBookmark             = Any();
                m_bBeforeFirst  = sal_True;
                m_bAfterLast    = sal_False;
-               m_bRowCountFinal= sal_False;
                m_bNew                  = sal_False;
                m_bModified             = sal_False;
-               m_nRowCount             = 0;
+               m_bLastKnownRowCountFinal = sal_False;
+        m_nLastKnownRowCount      = 0;
                if ( m_aOldRow.isValid() )
                        m_aOldRow->clearRow();
        }
@@ -1015,6 +1005,7 @@
        // when the row isn't modified
        // or the concurency is read only
        ::osl::ResettableMutexGuard aGuard( *m_pMutex );
+    
        if(!m_pCache || !m_bNew || !m_bModified || m_nResultSetConcurrency == 
ResultSetConcurrency::READ_ONLY)
                throwFunctionSequenceException(*this);
 
@@ -1027,17 +1018,16 @@
                if ( !m_aCurrentRow.isNull() )
                        aOldValues = new ORowSetValueVector( 
m_aCurrentRow->getBody() );
                RowChangeEvent aEvt(*this,RowChangeAction::INSERT,1);
-               if(notifyAllListenersRowBeforeChange(aGuard,aEvt))
-               {
-                       ::osl::MutexGuard aCacheGuard( *m_pMutex);
+               notifyAllListenersRowBeforeChange(aGuard,aEvt);
+
                        sal_Bool bInserted = m_pCache->insertRow();
 
+        // make sure that our row is set to the new inserted row before 
clearing the insert flags in the cache
+        m_pCache->resetInsertRow(bInserted);
+
                        // notification order
                        // - column values
-                       setCurrentRow(sal_False,aOldValues,aGuard); // we don't 
move here
-
-                       // make sure that our row is set to the new inserted 
row before clearing the inser flags in the cache
-                       m_pCache->resetInsertRow(bInserted);
+               setCurrentRow( sal_False, sal_True, aOldValues, aGuard ); // we 
don't move here
 
                        // - rowChanged
                        notifyAllListenersRowChanged(aGuard,aEvt);
@@ -1054,18 +1044,15 @@
                        // - RowCount/IsRowCountFinal
                        fireRowcount();
                }
-        else
-            throwRowSetVetoException( *this, "The insertion of the record has 
been vetoed." );
-       }
 }
 // -------------------------------------------------------------------------
 sal_Int32 SAL_CALL ORowSet::getRow(  ) throw(SQLException, RuntimeException)
 {
-       ::osl::MutexGuard aGuard( m_aRowCountMutex );
+       ::osl::MutexGuard aGuard( *m_pMutex );
        checkCache();
 
        // check if we are inserting a row
-       return (m_pCache && ( m_pCache->m_bInserted || m_bModified )) ? 0 : 
ORowSetBase::getRow();
+       return (m_pCache && ( m_pCache->m_bNew || m_bModified )) ? 0 : 
ORowSetBase::getRow();
 }
 // -------------------------------------------------------------------------
 void SAL_CALL ORowSet::updateRow(  ) throw(SQLException, RuntimeException)
@@ -1076,6 +1063,7 @@
        if ( !m_pCache || m_nResultSetConcurrency == 
ResultSetConcurrency::READ_ONLY || m_bNew || ((m_pCache->m_nPrivileges & 
Privilege::UPDATE ) != Privilege::UPDATE) )
                throwFunctionSequenceException(*this);
 
+
        if(m_bModified)
        {
                ORowSetRow aOldValues;
@@ -1083,8 +1071,8 @@
                        aOldValues = new ORowSetValueVector( 
m_aCurrentRow->getBody() );
 
                RowChangeEvent aEvt(*this,RowChangeAction::UPDATE,1);
-               if(notifyAllListenersRowBeforeChange(aGuard,aEvt))
-               {
+               notifyAllListenersRowBeforeChange(aGuard,aEvt);
+
                        m_pCache->updateRow(m_aCurrentRow.operator ->());
                        m_aBookmark             = m_pCache->getBookmark();
                        m_aCurrentRow   = m_pCache->m_aMatrixIter;
@@ -1102,9 +1090,6 @@
                                
fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True);
                        OSL_ENSURE( !m_bModified, "ORowSet::updateRow: just 
updated, but _still_ modified?" );
                }
-        else
-            throwRowSetVetoException( *this, "The update of the record has 
been vetoed." );
-       }
 }
 // -------------------------------------------------------------------------
 void SAL_CALL ORowSet::deleteRow(  ) throw(SQLException, RuntimeException)
@@ -1112,33 +1097,35 @@
        ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
 
        ::osl::ResettableMutexGuard aGuard( *m_pMutex );
-       // deleteRow is not allowed when:
-       // stands before the first row
-       // after the last row
-       // stands on the insert row
-       // the concurrency is read only
-       if(!m_pCache || m_bBeforeFirst || m_bAfterLast || m_bNew || 
m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY || 
((m_pCache->m_nPrivileges & Privilege::DELETE ) != Privilege::DELETE))
-               throwFunctionSequenceException(*this);
+    checkCache();
+
+       if ( m_bBeforeFirst || m_bAfterLast )
+        throwSQLException( "Cannot delete the before-first or after-last 
row.", SQL_INVALID_CURSOR_POSITION, *this );
+    if ( m_bNew )
+        throwSQLException( "Cannot delete the insert-row.", 
SQL_INVALID_CURSOR_POSITION, *this );
+    if  ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
+        throwSQLException( "Result set is read only.", 
SQL_FUNCTION_SEQUENCE_ERROR, *this );
+    if ( ( m_pCache->m_nPrivileges & Privilege::DELETE ) != Privilege::DELETE )
+        throwSQLException( "DELETE privilege not available.", 
SQL_FUNCTION_SEQUENCE_ERROR, *this );
+    if ( rowDeleted() )
+        throwSQLException( "Current row already deleted.", 
SQL_FUNCTION_SEQUENCE_ERROR, *this );
 
        // this call position the cache indirect
-       notifyClonesRowDelete(m_aBookmark);
+    Any aBookmarkToDelete( m_aBookmark );
+    positionCache( MOVE_NONE_REFRESH_ONLY );
+    sal_Int32 nDeletePosition = m_pCache->getRow();
 
-       positionCache();
+    notifyRowSetAndClonesRowDelete( aBookmarkToDelete );
 
        ORowSetRow aOldValues;
        if ( m_pCache->m_aMatrixIter != m_pCache->getEnd() && 
m_pCache->m_aMatrixIter->isValid() )
                aOldValues = new ORowSetValueVector( 
m_pCache->m_aMatrixIter->getBody() );
 
        RowChangeEvent aEvt(*this,RowChangeAction::DELETE,1);
-       if(notifyAllListenersRowBeforeChange(aGuard,aEvt))
-       {
-               m_nPosition = m_pCache->getRow();
-               m_pCache->deleteRow();
-               notifyClonesRowDeleted(m_aBookmark);
+       notifyAllListenersRowBeforeChange(aGuard,aEvt);
 
-               m_aBookmark             = Any();
-               m_aCurrentRow   = m_pCache->getEnd();
-               m_aCurrentRow.setBookmark(Any());
+    m_pCache->deleteRow();
+       notifyRowSetAndClonesRowDeleted( aBookmarkToDelete, nDeletePosition );
 
                ORowSetNotifier aNotifier( this );
                        // this will call cancelRowModification on the cache if 
necessary
@@ -1153,9 +1140,6 @@
 
                // - RowCount/IsRowCountFinal
                fireRowcount();
-       }
-    else
-        throwRowSetVetoException( *this, "The deletion of the row has been 
vetoed." );
 }
 
 // -------------------------------------------------------------------------
@@ -1164,23 +1148,25 @@
        ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
 
        ::osl::MutexGuard aGuard( *m_pMutex );
-       if(m_bBeforeFirst || m_bAfterLast)
+       if ( m_bBeforeFirst || m_bAfterLast || rowDeleted() )
                return; // nothing to do so return
 
+    checkCache();
        // cancelRowUpdates is not allowed when:
-       // standing on the insert row
-       // the concurrency is read only
-       if(!m_pCache || m_bNew || m_nResultSetConcurrency == 
ResultSetConcurrency::READ_ONLY)
+       // - standing on the insert row
+       // - the concurrency is read only
+    // - the current row is deleted
+       if ( m_bNew || m_nResultSetConcurrency == 
ResultSetConcurrency::READ_ONLY )
                throwFunctionSequenceException(*this);
 
-       positionCache();
-
-       m_pCache->cancelRowUpdates();
+       positionCache( MOVE_NONE_REFRESH_ONLY );
 
        ORowSetRow aOldValues;
        if ( !m_aCurrentRow.isNull() )
                aOldValues = new ORowSetValueVector( m_aCurrentRow->getBody() );
 
+       m_pCache->cancelRowUpdates();
+
        m_aBookmark             = m_pCache->getBookmark();
        m_aCurrentRow   = m_pCache->m_aMatrixIter;
        m_aCurrentRow.setBookmark(m_aBookmark);
@@ -1221,18 +1207,24 @@
 void ORowSet::notifyAllListeners(::osl::ResettableMutexGuard& _rGuard)
 {
        EventObject aEvt(*m_pMySelf);
-       NOTIFY_LISTERNERS(m_aRowsetListeners,XRowSetListener,rowSetChanged);
+       _rGuard.clear();
+    m_aRowsetListeners.notifyEach( &XRowSetListener::rowSetChanged, aEvt );
+       _rGuard.reset();
 }
 // -------------------------------------------------------------------------
 void ORowSet::notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& 
_rGuard)
 {
        EventObject aEvt(*m_pMySelf);
-       NOTIFY_LISTERNERS(m_aRowsetListeners,XRowSetListener,cursorMoved);
+       _rGuard.clear();
+    m_aRowsetListeners.notifyEach( &XRowSetListener::cursorMoved, aEvt );
+       _rGuard.reset();
 }
 // -------------------------------------------------------------------------
-void ORowSet::notifyAllListenersRowChanged(::osl::ResettableMutexGuard& 
_rGuard,const RowChangeEvent &aEvt)
+void ORowSet::notifyAllListenersRowChanged(::osl::ResettableMutexGuard& 
_rGuard, const EventObject& aEvt)
 {
-       NOTIFY_LISTERNERS(m_aRowsetListeners,XRowSetListener,rowChanged);
+       _rGuard.clear();
+    m_aRowsetListeners.notifyEach( &XRowSetListener::rowChanged, aEvt );
+       _rGuard.reset();
 }
 // -------------------------------------------------------------------------
 sal_Bool 
ORowSet::notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard& 
_rGuard)
@@ -1242,30 +1234,34 @@
        return bCheck;
 }
 // -------------------------------------------------------------------------
-sal_Bool 
ORowSet::notifyAllListenersRowBeforeChange(::osl::ResettableMutexGuard& 
_rGuard,const RowChangeEvent &aEvt)
+void ORowSet::notifyAllListenersRowBeforeChange(::osl::ResettableMutexGuard& 
_rGuard,const RowChangeEvent &aEvt)
 {
        
NOTIFY_LISTERNERS_CHECK(m_aApproveListeners,XRowSetApproveListener,approveRowChange);
-       return bCheck;
+    if ( !bCheck )
+        throwRowSetVetoException( *this, "The record operation has been 
vetoed." );
 }
 // -------------------------------------------------------------------------
 void ORowSet::fireRowcount()
 {
-       if(m_nRowCount != m_pCache->m_nRowCount)
+    sal_Int32 nCurrentRowCount( impl_getRowCount() );
+    sal_Bool bCurrentRowCountFinal( m_pCache->m_bRowCountFinal );
+
+    if ( m_nLastKnownRowCount != nCurrentRowCount )
        {
                sal_Int32 nHandle = PROPERTY_ID_ROWCOUNT;
                Any aNew,aOld;
-               aNew <<= m_pCache->m_nRowCount;aOld <<= m_nRowCount;
+               aNew <<= nCurrentRowCount; aOld <<= m_nLastKnownRowCount;
                fire(&nHandle,&aNew,&aOld,1,sal_False);
-               m_nRowCount = m_pCache->m_nRowCount;
+               m_nLastKnownRowCount = nCurrentRowCount;
        }
-       if(!m_bRowCountFinal && m_bRowCountFinal != m_pCache->m_bRowCountFinal)
+       if ( !m_bLastKnownRowCountFinal && ( m_bLastKnownRowCountFinal != 
bCurrentRowCountFinal ) )
        {
                sal_Int32 nHandle = PROPERTY_ID_ISROWCOUNTFINAL;
                Any aNew,aOld;
-               aNew <<= bool2any(m_pCache->m_bRowCountFinal);
-               aOld <<= bool2any(m_bRowCountFinal);
+               aNew <<= bool2any( bCurrentRowCountFinal );
+               aOld <<= bool2any( m_bLastKnownRowCountFinal );
                fire(&nHandle,&aNew,&aOld,1,sal_False);
-               m_bRowCountFinal = m_pCache->m_bRowCountFinal;
+               m_bLastKnownRowCountFinal = bCurrentRowCountFinal;
        }
 }
 // -------------------------------------------------------------------------
@@ -1275,19 +1271,28 @@
 
        ::osl::ResettableMutexGuard aGuard( *m_pMutex );
        checkPositioningAllowed();
-       if ((m_pCache->m_nPrivileges & Privilege::INSERT ) != Privilege::INSERT)
-               throwFunctionSequenceException(*this);
+       if ( ( m_pCache->m_nPrivileges & Privilege::INSERT ) != 
Privilege::INSERT )
+        throwSQLException( "No insert privileges", SQL_GENERAL_ERROR, *this );
 
-
-       if(notifyAllListenersCursorBeforeMove(aGuard))
+       if ( notifyAllListenersCursorBeforeMove( aGuard ) )
        {
                // remember old value for fire
-               // check before because the resultset could be empty
-               if(m_aBookmark.hasValue())
-                       positionCache();
-
                ORowSetRow aOldValues;
-               if ( !m_bBeforeFirst && !m_bAfterLast && 
m_pCache->m_aMatrixIter != m_pCache->getEnd() && 
m_pCache->m_aMatrixIter->isValid() )
+               if ( rowDeleted() )
+        {
+                       positionCache( MOVE_FORWARD );
+                   m_pCache->next();
+                       setCurrentRow( sal_True, sal_False, aOldValues, aGuard);
+        }
+        else
+                       positionCache( MOVE_NONE_REFRESH_ONLY );
+
+        // check before because the resultset could be empty
+               if  (   !m_bBeforeFirst
+            &&  !m_bAfterLast
+            &&  m_pCache->m_aMatrixIter != m_pCache->getEnd()
+            &&  m_pCache->m_aMatrixIter->isValid()
+            )
                        aOldValues = new ORowSetValueVector( 
m_pCache->m_aMatrixIter->getBody() );
 
                const sal_Bool bNewState = m_bNew;
@@ -1310,6 +1315,9 @@
                // - IsNew
                if ( bNewState != m_bNew )
                        fireProperty( PROPERTY_ID_ISNEW, m_bNew, bNewState );
+
+        // - RowCount/IsRowCountFinal
+           fireRowcount();
        }
 }
 // -------------------------------------------------------------------------
@@ -1318,18 +1326,25 @@
        ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
 
        ::osl::ResettableMutexGuard aGuard( *m_pMutex );
-
        checkPositioningAllowed();
 
-       if(m_pCache && ( m_pCache->m_bInserted || m_bModified ))
-       {
-               if(notifyAllListenersCursorBeforeMove(aGuard))
+    if ( !m_pCache->m_bNew && !m_bModified )
+        // nothing to do if we're not on the insertion row, and not modified 
otherwise
+        return;
+
+    if ( rowDeleted() )
+        // this would perhaps even justify a RuntimeException ....
+        // if the current row is deleted, then no write access to this row 
should be possible. So,
+        // m_bModified should be true. Also, as soon as somebody calls 
moveToInsertRow,
+        // our current row should not be deleted anymore. So, we should not 
have survived the above
+        // check "if ( !m_pCache->m_bInserted && !m_bModified )"
+        throwSQLException( "The current row is deleted.", 
SQL_FUNCTION_SEQUENCE_ERROR, *this );
+
+       if ( notifyAllListenersCursorBeforeMove( aGuard ) )
                {
-                       positionCache();
-                       m_pCache->moveToCurrentRow();
+        positionCache( MOVE_NONE_REFRESH_ONLY );
 
                        ORowSetNotifier aNotifier( this );
-                               // this will call cancelRowModification on the 
cache if necessary
 
                        // notification order
                        // - cursorMoved
@@ -1339,7 +1354,6 @@
                        // - IsNew
                        aNotifier.fire();
                }
-       }
 }
 // -------------------------------------------------------------------------
 // XRow
@@ -1348,85 +1362,95 @@
        ::osl::MutexGuard aGuard( *m_pMutex );
        checkCache();
 
-       return ( m_pCache && ( m_pCache->m_bInserted || m_bModified ) ) ? 
(*(*m_pCache->m_aInsertRow))[m_nLastColumnIndex].isNull() : 
ORowSetBase::wasNull();
+       return ( m_pCache && isInsertRow() ) ? 
(*(*m_pCache->m_aInsertRow))[m_nLastColumnIndex].isNull() : 
ORowSetBase::wasNull();
 }
 // 
-----------------------------------------------------------------------------
 const ORowSetValue& ORowSet::getInsertValue(sal_Int32 columnIndex)
 {
-       ::osl::MutexGuard aGuard( *m_pMutex );
        checkCache();
 
-       if ( m_pCache && ( m_pCache->m_bInserted || m_bModified) )
+       if ( m_pCache && isInsertRow() )
                return  (*(*m_pCache->m_aInsertRow))[m_nLastColumnIndex = 
columnIndex];
 
-       OSL_ENSURE(m_aCurrentRow != m_pCache->m_aInsertRow,"Current row stand 
on the insert row but all flags are wrong!");
        return getValue(columnIndex);
 }
 // -------------------------------------------------------------------------
 ::rtl::OUString SAL_CALL ORowSet::getString( sal_Int32 columnIndex ) 
throw(SQLException, RuntimeException)
 {
+       ::osl::MutexGuard aGuard( *m_pMutex );
        return getInsertValue(columnIndex);
 }
 // -------------------------------------------------------------------------
 sal_Bool SAL_CALL ORowSet::getBoolean( sal_Int32 columnIndex ) 
throw(SQLException, RuntimeException)
 {
+       ::osl::MutexGuard aGuard( *m_pMutex );
        return getInsertValue(columnIndex);
 }
 // -------------------------------------------------------------------------
 sal_Int8 SAL_CALL ORowSet::getByte( sal_Int32 columnIndex ) 
throw(SQLException, RuntimeException)
 {
+       ::osl::MutexGuard aGuard( *m_pMutex );
        return getInsertValue(columnIndex);
 }
 // -------------------------------------------------------------------------
 sal_Int16 SAL_CALL ORowSet::getShort( sal_Int32 columnIndex ) 
throw(SQLException, RuntimeException)
 {
+       ::osl::MutexGuard aGuard( *m_pMutex );
        return getInsertValue(columnIndex);
 }
 // -------------------------------------------------------------------------
 sal_Int32 SAL_CALL ORowSet::getInt( sal_Int32 columnIndex ) 
throw(SQLException, RuntimeException)
 {
+       ::osl::MutexGuard aGuard( *m_pMutex );
        return getInsertValue(columnIndex);
 }
 // -------------------------------------------------------------------------
 sal_Int64 SAL_CALL ORowSet::getLong( sal_Int32 columnIndex ) 
throw(SQLException, RuntimeException)
 {
+       ::osl::MutexGuard aGuard( *m_pMutex );
        return getInsertValue(columnIndex);
 }
 // -------------------------------------------------------------------------
 float SAL_CALL ORowSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, 
RuntimeException)
 {
+       ::osl::MutexGuard aGuard( *m_pMutex );
        return getInsertValue(columnIndex);
 }
 // -------------------------------------------------------------------------
 double SAL_CALL ORowSet::getDouble( sal_Int32 columnIndex ) 
throw(SQLException, RuntimeException)
 {
+       ::osl::MutexGuard aGuard( *m_pMutex );
        return getInsertValue(columnIndex);
 }
 // -------------------------------------------------------------------------
 Sequence< sal_Int8 > SAL_CALL ORowSet::getBytes( sal_Int32 columnIndex ) 
throw(SQLException, RuntimeException)
 {
+       ::osl::MutexGuard aGuard( *m_pMutex );
        return getInsertValue(columnIndex);
 }
 // -------------------------------------------------------------------------
 ::com::sun::star::util::Date SAL_CALL ORowSet::getDate( sal_Int32 columnIndex 
) throw(SQLException, RuntimeException)
 {
+       ::osl::MutexGuard aGuard( *m_pMutex );
        return getInsertValue(columnIndex);
 }
 // -------------------------------------------------------------------------
 ::com::sun::star::util::Time SAL_CALL ORowSet::getTime( sal_Int32 columnIndex 
) throw(SQLException, RuntimeException)
 {
+       ::osl::MutexGuard aGuard( *m_pMutex );
        return getInsertValue(columnIndex);
 }
 // -------------------------------------------------------------------------
 ::com::sun::star::util::DateTime SAL_CALL ORowSet::getTimestamp( sal_Int32 
columnIndex ) throw(SQLException, RuntimeException)
 {
+       ::osl::MutexGuard aGuard( *m_pMutex );
        return getInsertValue(columnIndex);
 }
 // -------------------------------------------------------------------------
 Reference< ::com::sun::star::io::XInputStream > SAL_CALL 
ORowSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, 
RuntimeException)
 {
        ::osl::MutexGuard aGuard( *m_pMutex );
-       if(m_pCache && ( m_pCache->m_bInserted || m_bModified ))
+       if ( m_pCache && isInsertRow() )
        {
                checkCache();
                return new 
::comphelper::SequenceInputStream((*(*m_pCache->m_aInsertRow))[m_nLastColumnIndex
 = columnIndex].getSequence());
@@ -1438,7 +1462,7 @@
 Reference< ::com::sun::star::io::XInputStream > SAL_CALL 
ORowSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, 
RuntimeException)
 {
        ::osl::MutexGuard aGuard( *m_pMutex );
-       if(m_pCache && ( m_pCache->m_bInserted || m_bModified ))
+       if(m_pCache && isInsertRow() )
        {
                checkCache();
                return new 
::comphelper::SequenceInputStream((*(*m_pCache->m_aInsertRow))[m_nLastColumnIndex
 = columnIndex].getSequence());
@@ -1449,41 +1473,26 @@
 // -------------------------------------------------------------------------
 Any SAL_CALL ORowSet::getObject( sal_Int32 columnIndex, const Reference< 
XNameAccess >& typeMap ) throw(SQLException, RuntimeException)
 {
-       ::osl::MutexGuard aGuard( *m_pMutex );
-       checkCache();
-
        return Any();
 }
 // -------------------------------------------------------------------------
 Reference< XRef > SAL_CALL ORowSet::getRef( sal_Int32 columnIndex ) 
throw(SQLException, RuntimeException)
 {
-       ::osl::MutexGuard aGuard( *m_pMutex );
-       checkCache();
-
        return Reference< XRef >();
 }
 // -------------------------------------------------------------------------
 Reference< XBlob > SAL_CALL ORowSet::getBlob( sal_Int32 columnIndex ) 
throw(SQLException, RuntimeException)
 {
-       ::osl::MutexGuard aGuard( *m_pMutex );
-       checkCache();
-
        return Reference< XBlob >();
 }
 // -------------------------------------------------------------------------
 Reference< XClob > SAL_CALL ORowSet::getClob( sal_Int32 columnIndex ) 
throw(SQLException, RuntimeException)
 {
-       ::osl::MutexGuard aGuard( *m_pMutex );
-       checkCache();
-
        return Reference< XClob >();
 }
 // -------------------------------------------------------------------------
 Reference< XArray > SAL_CALL ORowSet::getArray( sal_Int32 columnIndex ) 
throw(SQLException, RuntimeException)
 {
-       ::osl::MutexGuard aGuard( *m_pMutex );
-       checkCache();
-
        return Reference< XArray >();
 }
 // -------------------------------------------------------------------------
@@ -1692,7 +1701,7 @@
                                                m_pCache->m_nPrivileges = 
Privilege::SELECT;
                                        }
                                        m_pCache->setMaxRowSize(m_nFetchSize);
-                                       m_aCurrentRow   = 
m_pCache->createIterator();
+                                       m_aCurrentRow   = 
m_pCache->createIterator(this);
                                        m_aOldRow = m_pCache->registerOldRow();
                                        // now we can clear the parameter row
                                        m_aParameterRow.clear();
@@ -1749,8 +1758,7 @@
                                                                                
                                                                                
                i+1,
                                                                                
         m_xActiveConnection->getMetaData(),
                                                                                
                                                                                
                aDescription,
-                                                                               
                                                                                
                m_aCurrentRow,
-                                                                               
                                                                                
                m_pCache->getEnd());
+                                                                               
                                                                                
                m_aCurrentRow);
                                                                        
aColumnMap.insert(StringMap::value_type(sName,0));
                                                                        
aColumns->push_back(pColumn);
                                                                        
pColumn->setName(sName);
@@ -1835,8 +1843,7 @@
                                                                                
                                                                                
        i,
                                                                                
     m_xActiveConnection->getMetaData(),
                                                                                
                                                                                
        aDescription,
-                                                                               
                                                                                
        m_aCurrentRow,
-                                                                               
                                                                                
        m_pCache->getEnd());
+                                                                               
                                                                                
        m_aCurrentRow);
                                                                
aColumns->push_back(pColumn);
                                                                
if(!sName.getLength())
                                                                {
@@ -1901,7 +1908,6 @@
                }
        }
        checkCache();
-       _rClearForNotification.clear();
        // notify the rowset listeners
        notifyAllListeners(_rClearForNotification);
 }
@@ -1959,53 +1965,36 @@
 
        ::osl::ResettableMutexGuard aGuard( *m_pMutex );
 
-       Sequence< sal_Int32 > aRet;
        RowChangeEvent aEvt(*this,RowChangeAction::DELETE,rows.getLength());
        // notify the rowset listeners
-       if(notifyAllListenersRowBeforeChange(aGuard,aEvt))
+       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)
-               {
-                       notifyClonesRowDelete(*pBegin);
-                       if(compareBookmarks( m_aBookmark,*pBegin) == 0)
-                       {
-                               positionCache();
-                               m_nPosition = m_pCache->getRow();
-                       }
-               }
-               // now delete the rows
-               aRet = m_pCache->deleteRows(rows);
+               notifyRowSetAndClonesRowDelete( *row );
 
+        // 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();
-               const sal_Int32* pRetEnd        = pRetBegin + aRet.getLength();
-               OSL_ENSURE(aRet.getLength() == 
rows.getLength(),"ORowSet::deleteRows: The length of the rows and returnstatus 
is not equal!");
-               for(;pBegin != pEnd;++pBegin)
-               {
-                       if(*pRetBegin)
-                       {
-                               notifyClonesRowDeleted(*pBegin);
-                               if(compareBookmarks( m_aBookmark,*pBegin) == 0)
-                               {
-                                       m_aOldRow->clearRow();
-                                       m_aCurrentRow   = m_pCache->getEnd();
-                                       m_aBookmark             = Any();
-                                       m_aCurrentRow.setBookmark(m_aBookmark);
-                               }
+               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 );
                        // this will call cancelRowModification on the cache if 
necessary
-
                // notification order
                // - rowChanged
                notifyAllListenersRowChanged(aGuard,aEvt);
@@ -2016,14 +2005,15 @@
 
                // - RowCount/IsRowCountFinal
                fireRowcount();
-       }
-    else
-        throwRowSetVetoException( *this, "The deletion of the records has been 
vetoed." );
-       return aRet;
+
+    return aResults;
 }
 // 
-----------------------------------------------------------------------------
-void ORowSet::notifyClonesRowDelete(const Any& _rBookmark)
+void ORowSet::notifyRowSetAndClonesRowDelete( const Any& _rBookmark )
 {
+    // notify ourself
+    onDeleteRow( _rBookmark );
+    // notify the clones
        for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); 
m_aClones.end() != i; i++)
        {
                Reference< XUnoTunnel > xTunnel(i->get(),UNO_QUERY);
@@ -2031,13 +2021,16 @@
                {
                        ORowSetClone* pClone = 
reinterpret_cast<ORowSetClone*>(xTunnel->getSomething(ORowSetClone::getUnoTunnelImplementationId()));
                        if(pClone)
-                               pClone->rowDelete(_rBookmark);
+                               pClone->onDeleteRow( _rBookmark );
                }
        }
 }
 
//------------------------------------------------------------------------------
-void ORowSet::notifyClonesRowDeleted(const Any& _rBookmark)
+void ORowSet::notifyRowSetAndClonesRowDeleted( const Any& _rBookmark, 
sal_Int32 _nPos )
 {
+    // notify ourself
+    onDeletedRow( _rBookmark, _nPos );
+    // notify the clones
        for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); 
m_aClones.end() != i; i++)
        {
                Reference< XUnoTunnel > xTunnel(i->get(),UNO_QUERY);
@@ -2045,7 +2038,7 @@
                {
                        ORowSetClone* pClone = 
reinterpret_cast<ORowSetClone*>(xTunnel->getSomething(ORowSetClone::getUnoTunnelImplementationId()));
                        if(pClone)
-                               pClone->rowDeleted(_rBookmark);
+                               pClone->onDeletedRow( _rBookmark, _nPos );
                }
        }
 }
@@ -2473,7 +2466,7 @@
 // 
-----------------------------------------------------------------------------
 sal_Bool ORowSet::isModification( )
 {
-       return m_pCache && m_pCache->m_bInserted;
+       return m_pCache && m_pCache->m_bNew;
 }
 
 // 
-----------------------------------------------------------------------------
@@ -2495,17 +2488,28 @@
        {
                m_pCache->setUpdateIterator(m_aCurrentRow);
                m_aCurrentRow = m_pCache->m_aInsertRow;
-       }
+               m_bModified = sal_True;
+       } // if(!m_bModified && !m_bNew)
+       else if ( m_bNew ) // here we are modifing a value
+               m_bModified = sal_True;
 }
 // 
-----------------------------------------------------------------------------
 void ORowSet::checkUpdateConditions(sal_Int32 columnIndex)
 {
-       if(!m_pCache || columnIndex <= 0 || m_aCurrentRow.isNull() || 
m_aCurrentRow == m_pCache->getEnd() || m_nResultSetConcurrency == 
ResultSetConcurrency::READ_ONLY)
-               throwFunctionSequenceException(*this);
+    checkCache();
+    if ( columnIndex <= 0 )
+        throwSQLException( "Invalid column index", 
SQL_INVALID_DESCRIPTOR_INDEX, *this );
+    if ( rowDeleted() )
+        throwSQLException( "Current row is deleted", 
SQL_INVALID_CURSOR_POSITION, *this );
+       if ( m_aCurrentRow.isNull() )
+        throwSQLException( "Invalid cursor state", SQL_INVALID_CURSOR_STATE, 
*this );
+    if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
+        throwSQLException( "Result set is not writeable", SQL_GENERAL_ERROR, 
*this );
 }
 // 
-----------------------------------------------------------------------------
 void SAL_CALL ORowSet::refreshRow(  ) throw(SQLException, RuntimeException)
 {
+    
        ORowSetNotifier aNotifier( this );
                // this will call cancelRowModification on the cache if 
necessary
 
@@ -2530,8 +2534,6 @@
                     ,ORowSetBase(OComponentHelper::rBHelper,_pMutex)
                         ,m_nFetchDirection(rParent.m_nFetchDirection)
                         ,m_nFetchSize(rParent.m_nFetchSize)
-                        ,m_bDeleted(rParent.m_bDeleted)
-                        ,m_bRowObsolete(rParent.m_bRowObsolete)
                         ,m_bIsBookmarable(sal_True)
                         ,m_pParent(&rParent)
 {
@@ -2545,7 +2547,7 @@
        m_bAfterLast                    = rParent.m_bAfterLast;
        m_pCache                                = rParent.m_pCache;
        m_aBookmark                             = rParent.m_aBookmark;
-       m_aCurrentRow                   = m_pCache->createIterator();
+       m_aCurrentRow                   = m_pCache->createIterator(this);
        m_xNumberFormatTypes    = rParent.m_xNumberFormatTypes;
 
        m_aOldRow = m_pCache->registerOldRow();
@@ -2575,8 +2577,7 @@
                                                                                
                                        i,
                                                             
rParent.m_xActiveConnection->getMetaData(),
                                                                                
                                        aDescription,
-                                                                               
                                        m_aCurrentRow,
-                                                                               
                                        m_pCache->getEnd());
+                                                                               
                                        m_aCurrentRow);
                aColumns->push_back(pColumn);
                pColumn->setName(*pBegin);
                aNames.push_back(*pBegin);
@@ -2731,27 +2732,6 @@
        return 0;
 }
 // 
-----------------------------------------------------------------------------
-void ORowSetClone::rowDelete(const ::com::sun::star::uno::Any& _rBookmark)
-{
-       if(compareBookmarks(_rBookmark,m_aBookmark) == 0)
-       {
-               OSL_ENSURE(m_aBookmark.hasValue(),"ORowSetClone::rowDelete: 
Bookmark isn't valid!");
-               ::osl::MutexGuard aGuard( *m_pMutex );
-               m_pCache->moveToBookmark(m_aBookmark);
-               m_nPosition = m_pCache->getRow();
-       }
-}
-// 
-----------------------------------------------------------------------------
-void ORowSetClone::rowDeleted(const ::com::sun::star::uno::Any& _rBookmark)
-{
-       if(compareBookmarks(_rBookmark,m_aBookmark) == 0)
-       {
-               m_aBookmark             = Any();
-               m_aCurrentRow   = m_pCache->getEnd();
-               m_aCurrentRow.setBookmark(Any());
-       }
-}
-// 
-----------------------------------------------------------------------------
 void SAL_CALL ORowSetClone::setFastPropertyValue_NoBroadcast(sal_Int32 
nHandle,const Any& rValue) throw (Exception)
 {
        switch(nHandle)
@@ -2788,6 +2768,24 @@
 sal_Bool ORowSetClone::isNew( )
 {
        return sal_False;
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSetClone::execute(  ) throw(SQLException, RuntimeException)
+{
+    throwFunctionNotSupportedException( "RowSetClone::XRowSet::execute", *this 
);
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSetClone::addRowSetListener( const Reference< 
XRowSetListener >& listener ) throw(RuntimeException)
+{
+    throwFunctionNotSupportedException( "RowSetClone::XRowSet", *this );
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL ORowSetClone::removeRowSetListener( const Reference< 
XRowSetListener >& listener ) throw(RuntimeException)
+{
+    throwFunctionNotSupportedException( "RowSetClone::XRowSet", *this );
 }
 
 } // dbaccess




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

Reply via email to