LCOV - code coverage report
Current view: top level - dbaccess/source/core/api - RowSetBase.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 474 624 76.0 %
Date: 2014-04-11 Functions: 67 97 69.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "RowSetBase.hxx"
      21             : #include "CRowSetDataColumn.hxx"
      22             : #include <connectivity/sdbcx/VCollection.hxx>
      23             : #include "RowSetCache.hxx"
      24             : #include "dbastrings.hrc"
      25             : #include "core_resource.hrc"
      26             : #include <com/sun/star/lang/DisposedException.hpp>
      27             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      28             : #include <com/sun/star/sdbcx/CompareBookmark.hpp>
      29             : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
      30             : #include <com/sun/star/lang/Locale.hpp>
      31             : #include <com/sun/star/util/NumberFormat.hpp>
      32             : #include <comphelper/sequence.hxx>
      33             : #include <comphelper/seqstream.hxx>
      34             : #include <connectivity/dbexception.hxx>
      35             : #include <tools/debug.hxx>
      36             : 
      37             : using namespace dbaccess;
      38             : using namespace connectivity;
      39             : using namespace connectivity::sdbcx;
      40             : using namespace comphelper;
      41             : using namespace dbtools;
      42             : using namespace ::com::sun::star::uno;
      43             : using namespace ::com::sun::star::beans;
      44             : using namespace ::com::sun::star::sdbc;
      45             : using namespace ::com::sun::star::sdb;
      46             : using namespace ::com::sun::star::sdbcx;
      47             : using namespace ::com::sun::star::container;
      48             : using namespace ::com::sun::star::lang;
      49             : using namespace ::com::sun::star::util;
      50             : using namespace ::cppu;
      51             : using namespace ::osl;
      52             : 
      53             : namespace dbaccess
      54             : {
      55             : 
      56             : // OEmptyCollection
      57           0 : class OEmptyCollection : public sdbcx::OCollection
      58             : {
      59             : protected:
      60             :     virtual void impl_refresh() throw(RuntimeException) SAL_OVERRIDE;
      61             :     virtual connectivity::sdbcx::ObjectType createObject(const OUString& _rName) SAL_OVERRIDE;
      62             : public:
      63           0 :     OEmptyCollection(::cppu::OWeakObject& _rParent,::osl::Mutex& _rMutex) : OCollection(_rParent, true, _rMutex, ::std::vector< OUString>()){}
      64             : };
      65             : 
      66           0 : void OEmptyCollection::impl_refresh() throw(RuntimeException)
      67             : {
      68           0 : }
      69             : 
      70           0 : connectivity::sdbcx::ObjectType OEmptyCollection::createObject(const OUString& /*_rName*/)
      71             : {
      72           0 :     return connectivity::sdbcx::ObjectType();
      73             : }
      74             : 
      75             : // ORowSetBase
      76             : 
      77         178 : ORowSetBase::ORowSetBase( const Reference<XComponentContext>& _rContext, ::cppu::OBroadcastHelper& _rBHelper, ::osl::Mutex* _pMutex )
      78             :     :OPropertyStateContainer(_rBHelper)
      79             :     ,m_pMutex(_pMutex)
      80             :     ,m_pMySelf(NULL)
      81             :     ,m_pCache(NULL)
      82             :     ,m_pColumns(NULL)
      83             :     ,m_rBHelper(_rBHelper)
      84             :     ,m_pEmptyCollection( NULL )
      85             :     ,m_aContext( _rContext )
      86             :     ,m_aErrors( _rContext )
      87             :     ,m_nLastColumnIndex(-1)
      88             :     ,m_nDeletedPosition(-1)
      89             :     ,m_nResultSetType( ResultSetType::FORWARD_ONLY )
      90             :     ,m_nResultSetConcurrency( ResultSetConcurrency::READ_ONLY )
      91             :     ,m_bClone(sal_False)
      92             :     ,m_bIgnoreResult(sal_False)
      93             :     ,m_bBeforeFirst(sal_True) // changed from sal_False
      94             :     ,m_bAfterLast(sal_False)
      95         178 :     ,m_bIsInsertRow(sal_False)
      96             : {
      97             :     SAL_INFO("dbaccess", "ORowSetBase::ORowSetBase" );
      98             : 
      99         178 :     sal_Int32 nRBT  = PropertyAttribute::READONLY   | PropertyAttribute::BOUND      | PropertyAttribute::TRANSIENT;
     100             : 
     101         178 :     sal_Int32 nInitialRowCountValue = 0;
     102         178 :     sal_Bool bInitialRowCountFinalValue( sal_False );
     103         178 :     registerPropertyNoMember( PROPERTY_ROWCOUNT,        PROPERTY_ID_ROWCOUNT,        nRBT, ::getCppuType( &nInitialRowCountValue ), &nInitialRowCountValue );
     104         178 :     registerPropertyNoMember( PROPERTY_ISROWCOUNTFINAL, PROPERTY_ID_ISROWCOUNTFINAL, nRBT, ::getBooleanCppuType(),                  &bInitialRowCountFinalValue );
     105         178 : }
     106             : 
     107         350 : ORowSetBase::~ORowSetBase()
     108             : {
     109         175 :     if(m_pColumns)
     110             :     {
     111          17 :         TDataColumns().swap(m_aDataColumns);
     112          17 :         m_pColumns->acquire();
     113          17 :         m_pColumns->disposing();
     114          17 :         delete m_pColumns;
     115          17 :         m_pColumns = NULL;
     116             :     }
     117             : 
     118         175 :     if ( m_pEmptyCollection )
     119           0 :         delete m_pEmptyCollection;
     120             : 
     121         175 : }
     122             : 
     123             : // com::sun::star::lang::XTypeProvider
     124           2 : Sequence< Type > ORowSetBase::getTypes() throw (RuntimeException, std::exception)
     125             : {
     126           2 :     return ::comphelper::concatSequences(ORowSetBase_BASE::getTypes(),OPropertyStateContainer::getTypes());
     127             : }
     128             : 
     129             : // com::sun::star::uno::XInterface
     130        3225 : Any ORowSetBase::queryInterface( const Type & rType ) throw (RuntimeException, std::exception)
     131             : {
     132        3225 :     Any aRet = ORowSetBase_BASE::queryInterface(rType);
     133        3225 :     if(!aRet.hasValue())
     134        2470 :         aRet = OPropertyStateContainer::queryInterface(rType);
     135        3225 :     return aRet;
     136             : }
     137             : 
     138         602 : void SAL_CALL ORowSetBase::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
     139             : {
     140             :     //SAL_INFO("dbaccess", "ORowSetBase::getFastPropertyValue" );
     141         602 :     if(m_pCache)
     142             :     {
     143         358 :         switch(nHandle)
     144             :         {
     145             :         case PROPERTY_ID_ROWCOUNT:
     146          39 :             rValue <<= impl_getRowCount();
     147          39 :             break;
     148             :         case PROPERTY_ID_ISROWCOUNTFINAL:
     149           4 :             rValue.setValue(&m_pCache->m_bRowCountFinal,::getCppuBooleanType());
     150           4 :             break;
     151             :         default:
     152         315 :             OPropertyStateContainer::getFastPropertyValue(rValue,nHandle);
     153             :         };
     154             :     }
     155             :     else
     156         244 :         OPropertyStateContainer::getFastPropertyValue(rValue,nHandle);
     157         602 : }
     158             : 
     159             : // OComponentHelper
     160         177 : void SAL_CALL ORowSetBase::disposing(void)
     161             : {
     162             :     SAL_INFO("dbaccess", "ORowSetBase::disposing" );
     163         177 :     MutexGuard aGuard(*m_pMutex);
     164             : 
     165         177 :     if ( m_pColumns )
     166             :     {
     167          17 :         TDataColumns().swap(m_aDataColumns);
     168          17 :         m_pColumns->disposing();
     169             :     }
     170         177 :     if ( m_pCache )
     171             :     {
     172           2 :         m_pCache->deregisterOldRow(m_aOldRow);
     173           2 :         m_pCache->deleteIterator(this);
     174             :     }
     175         177 :     m_pCache = NULL;
     176         177 : }
     177             : 
     178             : // comphelper::OPropertyArrayUsageHelper
     179           0 : ::cppu::IPropertyArrayHelper* ORowSetBase::createArrayHelper( ) const
     180             : {
     181             :     SAL_INFO("dbaccess", "ORowSetBase::createArrayHelper" );
     182           0 :     Sequence< Property > aProps;
     183           0 :     describeProperties(aProps);
     184           0 :     return new ::cppu::OPropertyArrayHelper(aProps);
     185             : }
     186             : 
     187             : // cppu::OPropertySetHelper
     188           0 : ::cppu::IPropertyArrayHelper& SAL_CALL ORowSetBase::getInfoHelper()
     189             : {
     190             :     SAL_INFO("dbaccess", "ORowSetBase::getInfoHelper" );
     191           0 :     return *const_cast<ORowSetBase*>(this)->getArrayHelper();
     192             : }
     193             : 
     194             : // XRow
     195         557 : sal_Bool SAL_CALL ORowSetBase::wasNull(  ) throw(SQLException, RuntimeException, std::exception)
     196             : {
     197             :     SAL_INFO("dbaccess", "ORowSetBase::wasNull" );
     198         557 :     ::osl::MutexGuard aGuard( *m_pMutex );
     199         557 :     checkCache();
     200         557 :     return impl_wasNull();
     201             : }
     202             : 
     203         557 : sal_Bool ORowSetBase::impl_wasNull()
     204             : {
     205             :     SAL_INFO("dbaccess", "ORowSetBase::impl_wasNull" );
     206         557 :     return ((m_nLastColumnIndex != -1) && !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->is()) ? ((*m_aCurrentRow)->get())[m_nLastColumnIndex].isNull() : sal_True;
     207             : }
     208             : 
     209         896 : const ORowSetValue& ORowSetBase::getValue(sal_Int32 columnIndex)
     210             : {
     211             :     SAL_INFO("dbaccess", "ORowSetBase::getValue" );
     212         896 :     checkCache();
     213         896 :     return impl_getValue(columnIndex);
     214             : }
     215             : 
     216         896 : const ORowSetValue& ORowSetBase::impl_getValue(sal_Int32 columnIndex)
     217             : {
     218             :     SAL_INFO("dbaccess", "ORowSetBase::impl_getValue" );
     219         896 :     if ( m_bBeforeFirst || m_bAfterLast )
     220             :     {
     221             :         SAL_WARN("dbaccess", "ORowSetBase::getValue: Illegal call here (we're before first or after last)!");
     222           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_CURSOR_BEFORE_OR_AFTER ), SQL_INVALID_CURSOR_POSITION, *m_pMySelf );
     223             :     }
     224             : 
     225         896 :     if ( impl_rowDeleted() )
     226             :     {
     227           0 :         return m_aEmptyValue;
     228             :     }
     229             : 
     230         896 :     bool bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->is() );
     231         896 :     if ( !bValidCurrentRow )
     232             :     {
     233             :         // currentrow is null when the clone moves the window
     234           0 :         positionCache( MOVE_NONE_REFRESH_ONLY );
     235           0 :         m_aCurrentRow   = m_pCache->m_aMatrixIter;
     236           0 :         m_bIsInsertRow  = sal_False;
     237             :         OSL_ENSURE(!m_aCurrentRow.isNull(),"ORowSetBase::getValue: we don't stand on a valid row! Row is null.");
     238             : 
     239           0 :         bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->is() );
     240             :     }
     241             : 
     242         896 :     if ( bValidCurrentRow )
     243             :     {
     244             : #if OSL_DEBUG_LEVEL > 0
     245             :         ORowSetMatrix::iterator aCacheEnd;
     246             :         ORowSetMatrix::iterator aCurrentRow;
     247             :         aCacheEnd = m_pCache->getEnd();
     248             :         aCurrentRow = m_aCurrentRow;
     249             :         ORowSetCacheMap::iterator aCacheIter = m_aCurrentRow.getIter();
     250             :         ORowSetCacheIterator_Helper aHelper = aCacheIter->second;
     251             :         ORowSetMatrix::iterator k = aHelper.aIterator;
     252             :         for (; k != m_pCache->getEnd(); ++k)
     253             :         {
     254             :             ORowSetValueVector* pTemp = k->get();
     255             :             OSL_ENSURE( pTemp != (void*)0xfeeefeee,"HALT!" );
     256             :         }
     257             : #endif
     258             :         OSL_ENSURE(!m_aCurrentRow.isNull() && m_aCurrentRow < m_pCache->getEnd() && aCacheIter != m_pCache->m_aCacheIterators.end(),"Invalid iterator set for currentrow!");
     259             : #if OSL_DEBUG_LEVEL > 0
     260             :         ORowSetRow rRow = (*m_aCurrentRow);
     261             :         OSL_ENSURE(rRow.is() && static_cast<sal_uInt16>(columnIndex) < (rRow->get()).size(),"Invalid size of vector!");
     262             : #endif
     263         896 :         return ((*m_aCurrentRow)->get())[m_nLastColumnIndex = columnIndex];
     264             :     }
     265             : 
     266             :     // we should normally never reach this
     267           0 :     return m_aEmptyValue;
     268             : }
     269             : 
     270         140 : OUString SAL_CALL ORowSetBase::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     271             : {
     272             :     SAL_INFO("dbaccess", "ORowSetBase::getString" );
     273         140 :     ::osl::MutexGuard aGuard( *m_pMutex );
     274         140 :     return getValue(columnIndex);
     275             : }
     276             : 
     277           0 : sal_Bool SAL_CALL ORowSetBase::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     278             : {
     279             :     SAL_INFO("dbaccess", "ORowSetBase::getBoolean" );
     280           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     281           0 :     return getValue(columnIndex);
     282             : }
     283             : 
     284           0 : sal_Int8 SAL_CALL ORowSetBase::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     285             : {
     286             :     SAL_INFO("dbaccess", "ORowSetBase::getByte" );
     287           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     288           0 :     return getValue(columnIndex);
     289             : }
     290             : 
     291           0 : sal_Int16 SAL_CALL ORowSetBase::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     292             : {
     293             :     SAL_INFO("dbaccess", "ORowSetBase::getShort" );
     294           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     295           0 :     return getValue(columnIndex);
     296             : }
     297             : 
     298           0 : sal_Int32 SAL_CALL ORowSetBase::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     299             : {
     300             :     SAL_INFO("dbaccess", "ORowSetBase::getInt" );
     301           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     302           0 :     return getValue(columnIndex);
     303             : }
     304             : 
     305           0 : sal_Int64 SAL_CALL ORowSetBase::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     306             : {
     307             :     SAL_INFO("dbaccess", "ORowSetBase::getLong" );
     308           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     309           0 :     return getValue(columnIndex);
     310             : }
     311             : 
     312           0 : float SAL_CALL ORowSetBase::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     313             : {
     314             :     SAL_INFO("dbaccess", "ORowSetBase::getFloat" );
     315           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     316           0 :     return getValue(columnIndex);
     317             : }
     318             : 
     319           0 : double SAL_CALL ORowSetBase::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     320             : {
     321             :     SAL_INFO("dbaccess", "ORowSetBase::getDouble" );
     322           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     323           0 :     return getValue(columnIndex);
     324             : }
     325             : 
     326           0 : Sequence< sal_Int8 > SAL_CALL ORowSetBase::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     327             : {
     328             :     SAL_INFO("dbaccess", "ORowSetBase::getBytes" );
     329           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     330           0 :     return getValue(columnIndex);
     331             : }
     332             : 
     333           0 : ::com::sun::star::util::Date SAL_CALL ORowSetBase::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     334             : {
     335             :     SAL_INFO("dbaccess", "ORowSetBase::getDate" );
     336           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     337           0 :     return getValue(columnIndex);
     338             : }
     339             : 
     340           0 : ::com::sun::star::util::Time SAL_CALL ORowSetBase::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     341             : {
     342             :     SAL_INFO("dbaccess", "ORowSetBase::getTime" );
     343           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     344           0 :     return getValue(columnIndex);
     345             : }
     346             : 
     347           0 : ::com::sun::star::util::DateTime SAL_CALL ORowSetBase::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     348             : {
     349             :     SAL_INFO("dbaccess", "ORowSetBase::getTimestamp" );
     350           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     351           0 :     return getValue(columnIndex);
     352             : }
     353             : 
     354           0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSetBase::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     355             : {
     356             :     SAL_INFO("dbaccess", "ORowSetBase::getBinaryStream" );
     357           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     358           0 :     checkCache();
     359             : 
     360           0 :     if ( m_bBeforeFirst || m_bAfterLast )
     361             :     {
     362             :         SAL_WARN("dbaccess", "ORowSetBase::getBinaryStream: Illegal call here (we're before first or after last)!");
     363           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_CURSOR_BEFORE_OR_AFTER ), SQL_INVALID_CURSOR_POSITION, *m_pMySelf );
     364             :     }
     365             : 
     366           0 :     if ( impl_rowDeleted() )
     367             :     {
     368           0 :         return NULL;
     369             :     }
     370             : 
     371           0 :     bool bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->is() );
     372           0 :     if ( !bValidCurrentRow )
     373             :     {
     374           0 :         positionCache( MOVE_NONE_REFRESH_ONLY );
     375           0 :         m_aCurrentRow   = m_pCache->m_aMatrixIter;
     376           0 :         m_bIsInsertRow  = sal_False;
     377             :         OSL_ENSURE(!m_aCurrentRow.isNull(),"ORowSetBase::getBinaryStream: we don't stand on a valid row! Row is null.");
     378             : 
     379           0 :         bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->is() );
     380             :     }
     381             : 
     382           0 :     if ( bValidCurrentRow )
     383           0 :         return new ::comphelper::SequenceInputStream(((*m_aCurrentRow)->get())[m_nLastColumnIndex = columnIndex].getSequence());
     384             : 
     385             :     // we should normally never reach this
     386           0 :     return Reference< ::com::sun::star::io::XInputStream >();
     387             : }
     388             : 
     389           0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSetBase::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     390             : {
     391             :     SAL_INFO("dbaccess", "ORowSetBase::getCharacterStream" );
     392           0 :     return getBinaryStream(columnIndex);
     393             : }
     394             : 
     395           0 : Any SAL_CALL ORowSetBase::getObject( sal_Int32 columnIndex, const Reference< XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException, std::exception)
     396             : {
     397             :     SAL_INFO("dbaccess", "ORowSetBase::getObject" );
     398           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     399           0 :     checkCache();
     400             : 
     401           0 :     return getValue(columnIndex).makeAny();
     402             : }
     403             : 
     404           0 : Reference< XRef > SAL_CALL ORowSetBase::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     405             : {
     406             :     SAL_INFO("dbaccess", "ORowSetBase::getRef" );
     407           0 :     ::dbtools::throwFeatureNotImplementedException( "XRow::getRef", *m_pMySelf );
     408           0 :     return NULL;
     409             : }
     410             : 
     411           0 : Reference< XBlob > SAL_CALL ORowSetBase::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     412             : {
     413             :     SAL_INFO("dbaccess", "ORowSetBase::getBlob" );
     414           0 :     return Reference< XBlob >(getValue(columnIndex).makeAny(),UNO_QUERY);
     415             : }
     416             : 
     417           0 : Reference< XClob > SAL_CALL ORowSetBase::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     418             : {
     419             :     SAL_INFO("dbaccess", "ORowSetBase::getClob" );
     420           0 :     return Reference< XClob >(getValue(columnIndex).makeAny(),UNO_QUERY);
     421             : }
     422             : 
     423           0 : Reference< XArray > SAL_CALL ORowSetBase::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     424             : {
     425             :     SAL_INFO("dbaccess", "ORowSetBase::getArray" );
     426           0 :     ::dbtools::throwFeatureNotImplementedException( "XRow::getArray", *m_pMySelf );
     427           0 :     return NULL;
     428             : }
     429             : 
     430             : // ::com::sun::star::sdbcx::XRowLocate
     431          21 : Any SAL_CALL ORowSetBase::getBookmark(  ) throw(SQLException, RuntimeException, std::exception)
     432             : {
     433             :     SAL_INFO("dbaccess", "ORowSetBase::getBookmark" );
     434             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::getBookmark() Clone = " << m_bClone);
     435          21 :     ::connectivity::checkDisposed(m_rBHelper.bDisposed);
     436          21 :     ::osl::MutexGuard aGuard( *m_pMutex );
     437          21 :     checkCache();
     438             : 
     439          21 :     if ( m_bBeforeFirst || m_bAfterLast )
     440           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_BOOKMARK_BEFORE_OR_AFTER ), SQL_INVALID_CURSOR_POSITION, *m_pMySelf );
     441             : 
     442          21 :     if ( impl_rowDeleted() )
     443           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_BOOKMARK_DELETED ), SQL_INVALID_CURSOR_POSITION, *m_pMySelf );
     444             : 
     445             :     OSL_ENSURE( m_aBookmark.hasValue(), "ORowSetBase::getBookmark: bookmark has no value!" );
     446          21 :     return m_aBookmark;
     447             : }
     448             : 
     449           2 : sal_Bool SAL_CALL ORowSetBase::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException, std::exception)
     450             : {
     451             :     SAL_INFO("dbaccess", "ORowSetBase::moveToBookmark" );
     452             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::moveToBookmark(Any) Clone = " << m_bClone);
     453             :     OSL_ENSURE(bookmark.hasValue(),"ORowSetBase::moveToBookmark bookmark has no value!");
     454           2 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
     455             : 
     456           2 :     if(!bookmark.hasValue() || m_nResultSetType == ResultSetType::FORWARD_ONLY)
     457             :     {
     458           0 :         if(bookmark.hasValue())
     459             :             SAL_WARN("dbaccess", "MoveToBookmark is not possible when we are only forward");
     460             :         else
     461             :             SAL_WARN("dbaccess", "Bookmark is not valid");
     462           0 :         throwFunctionSequenceException(*m_pMySelf);
     463             :     }
     464             : 
     465           2 :     checkCache();
     466             : 
     467           2 :     sal_Bool bRet( notifyAllListenersCursorBeforeMove( aGuard ) );
     468           2 :     if ( bRet )
     469             :     {
     470             :         // check if we are inserting a row
     471           2 :         sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
     472             : 
     473           2 :         ORowSetNotifier aNotifier( this );
     474             :             // this will call cancelRowModification on the cache if necessary
     475             : 
     476           4 :         ORowSetRow aOldValues = getOldRow(bWasNew);
     477             : 
     478           2 :         bRet = m_pCache->moveToBookmark(bookmark);
     479           2 :         doCancelModification( );
     480           2 :         if(bRet)
     481             :         {
     482             :             // notification order
     483             :             // - column values
     484             :             // - cursorMoved
     485           2 :             setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
     486             :         }
     487             :         else
     488             :         {
     489           0 :             movementFailed();
     490             :         }
     491             : 
     492             :         // - IsModified
     493             :         // - IsNew
     494           4 :         aNotifier.fire( );
     495             :     }
     496             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::moveToBookmark(Any) = " << bRet << " Clone = " << m_bClone);
     497           2 :     return bRet;
     498             : }
     499             : 
     500           1 : sal_Bool SAL_CALL ORowSetBase::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException, std::exception)
     501             : {
     502             :     SAL_INFO("dbaccess", "ORowSetBase::moveRelativeToBookmark" );
     503             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::moveRelativeToBookmark(Any," << rows << ") Clone = " << m_bClone);
     504           1 :     ::connectivity::checkDisposed(m_rBHelper.bDisposed);
     505             : 
     506           1 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
     507             : 
     508           1 :     checkPositioningAllowed();
     509             : 
     510           1 :     sal_Bool bRet( notifyAllListenersCursorBeforeMove( aGuard ) );
     511           1 :     if ( bRet )
     512             :     {
     513             :         // check if we are inserting a row
     514           1 :         sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
     515             : 
     516           1 :         ORowSetNotifier aNotifier( this );
     517             :             // this will call cancelRowModification on the cache if necessary
     518             : 
     519           2 :         ORowSetRow aOldValues = getOldRow(bWasNew);
     520             : 
     521           1 :         bRet = m_pCache->moveRelativeToBookmark(bookmark,rows);
     522           1 :         doCancelModification( );
     523           1 :         if(bRet)
     524             :         {
     525             :             // notification order
     526             :             // - column values
     527             :             // - cursorMoved
     528           1 :             setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
     529             :         }
     530             :         else
     531           0 :             movementFailed();
     532             : 
     533             :         // - IsModified
     534             :         // - IsNew
     535           1 :         aNotifier.fire( );
     536             : 
     537             :         // RowCount/IsRowCountFinal
     538           2 :         fireRowcount();
     539             :     }
     540             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::moveRelativeToBookmark(Any," << rows << ") = " << bRet << " Clone = " << m_bClone);
     541           1 :     return bRet;
     542             : }
     543             : 
     544           5 : sal_Int32 SAL_CALL ORowSetBase::compareBookmarks( const Any& _first, const Any& _second ) throw(SQLException, RuntimeException, std::exception)
     545             : {
     546             :     SAL_INFO("dbaccess", "ORowSetBase::compareBookmarks" );
     547           5 :     ::osl::MutexGuard aGuard( *m_pMutex );
     548           5 :     checkCache();
     549           5 :     return m_pCache->compareBookmarks(_first,_second);
     550             : }
     551             : 
     552           1 : sal_Bool SAL_CALL ORowSetBase::hasOrderedBookmarks(  ) throw(SQLException, RuntimeException, std::exception)
     553             : {
     554             :     SAL_INFO("dbaccess", "ORowSetBase::hasOrderedBookmarks" );
     555           1 :     ::osl::MutexGuard aGuard( *m_pMutex );
     556           1 :     checkCache();
     557           1 :     return m_pCache->hasOrderedBookmarks();
     558             : }
     559             : 
     560           2 : sal_Int32 SAL_CALL ORowSetBase::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException, std::exception)
     561             : {
     562             :     SAL_INFO("dbaccess", "ORowSetBase::hashBookmark" );
     563           2 :     ::osl::MutexGuard aGuard( *m_pMutex );
     564           2 :     checkCache();
     565           2 :     return m_pCache->hashBookmark(bookmark);
     566             : }
     567             : 
     568             : // XResultSetMetaDataSupplier
     569         283 : Reference< XResultSetMetaData > SAL_CALL ORowSetBase::getMetaData(  ) throw(SQLException, RuntimeException, std::exception)
     570             : {
     571             :     SAL_INFO("dbaccess", "ORowSetBase::getMetaData" );
     572         283 :     ::connectivity::checkDisposed(m_rBHelper.bDisposed);
     573             : 
     574         283 :     Reference< XResultSetMetaData > xMeta;
     575         283 :     if(m_pCache)
     576         283 :         xMeta = m_pCache->getMetaData();
     577             : 
     578         283 :     return xMeta;
     579             : }
     580             : 
     581             : // XColumnLocate
     582           1 : sal_Int32 SAL_CALL ORowSetBase::findColumn( const OUString& columnName ) throw(SQLException, RuntimeException, std::exception)
     583             : {
     584             :     SAL_INFO("dbaccess", "ORowSetBase::findColumn" );
     585           1 :     ::connectivity::checkDisposed(m_rBHelper.bDisposed);
     586             : 
     587           1 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
     588             :     // it is possible to save some time here when we remember the names - position relation in a map
     589           1 :     return m_pColumns ? m_pColumns->findColumn(columnName) : sal_Int32(0);
     590             : }
     591             : 
     592             : // ::com::sun::star::sdbcx::XColumnsSupplier
     593         294 : Reference< XNameAccess > SAL_CALL ORowSetBase::getColumns(  ) throw(RuntimeException, std::exception)
     594             : {
     595             :     SAL_INFO("dbaccess", "ORowSetBase::getColumns" );
     596         294 :     ::connectivity::checkDisposed(m_rBHelper.bDisposed);
     597             : 
     598         294 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
     599         294 :     if(!m_pColumns)
     600             :     {
     601           0 :         if (!m_pEmptyCollection)
     602           0 :             m_pEmptyCollection = new OEmptyCollection(*m_pMySelf,m_aColumnsMutex);
     603           0 :         return m_pEmptyCollection;
     604             :     }
     605             : 
     606         294 :     return m_pColumns;
     607             : }
     608             : 
     609             : // XResultSet
     610          87 : sal_Bool SAL_CALL ORowSetBase::next(  ) throw(SQLException, RuntimeException, std::exception)
     611             : {
     612             :     SAL_INFO("dbaccess", "ORowSetBase::next" );
     613             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::next() Clone = " << m_bClone);
     614          87 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
     615          87 :     checkCache();
     616             : 
     617          87 :     sal_Bool bRet( notifyAllListenersCursorBeforeMove( aGuard ) );
     618          87 :     if ( bRet )
     619             :     {
     620             :         // check if we are inserting a row
     621          87 :         sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
     622             : 
     623          87 :         ORowSetNotifier aNotifier( this );
     624             :             // this will call cancelRowModification on the cache if necessary
     625             : 
     626         174 :         ORowSetRow aOldValues = getOldRow(bWasNew);
     627             : 
     628          87 :         positionCache( MOVE_FORWARD );
     629          87 :         sal_Bool bAfterLast = m_pCache->isAfterLast();
     630          87 :         bRet = m_pCache->next();
     631          87 :         doCancelModification( );
     632             : 
     633          87 :         if ( bRet || bAfterLast != m_pCache->isAfterLast() )
     634             :         {
     635             :             // notification order
     636             :             // - column values
     637             :             // - cursorMoved
     638          87 :             setCurrentRow( bRet, sal_True, aOldValues, aGuard );
     639             :             OSL_ENSURE(!m_bBeforeFirst,"BeforeFirst is true. I don't know why?");
     640             :         }
     641             :         else
     642             :         {
     643             :             // moved after the last row
     644           0 :             movementFailed();
     645             :             OSL_ENSURE(m_bAfterLast,"AfterLast is false. I don't know why?");
     646             :         }
     647             : 
     648             :         // - IsModified
     649             :         // - IsNew
     650          87 :         aNotifier.fire();
     651             : 
     652             :         // - RowCount/IsRowCountFinal
     653         174 :         fireRowcount();
     654             :     }
     655             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::next() = " << bRet << " Clone = " << m_bClone);
     656          87 :     return bRet;
     657             : }
     658             : 
     659         321 : sal_Bool SAL_CALL ORowSetBase::isBeforeFirst(  ) throw(SQLException, RuntimeException, std::exception)
     660             : {
     661             :     SAL_INFO("dbaccess", "ORowSetBase::isBeforeFirst" );
     662         321 :     ::connectivity::checkDisposed(m_rBHelper.bDisposed);
     663         321 :     ::osl::MutexGuard aGuard( *m_pMutex );
     664         321 :     checkCache();
     665             : 
     666             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::isBeforeFirst() = " << m_bBeforeFirst << " Clone = " << m_bClone);
     667             : 
     668         321 :     return m_bBeforeFirst;
     669             : }
     670             : 
     671         322 : sal_Bool SAL_CALL ORowSetBase::isAfterLast(  ) throw(SQLException, RuntimeException, std::exception)
     672             : {
     673             :     SAL_INFO("dbaccess", "ORowSetBase::isAfterLast" );
     674         322 :     ::connectivity::checkDisposed(m_rBHelper.bDisposed);
     675         322 :     ::osl::MutexGuard aGuard( *m_pMutex );
     676         322 :     checkCache();
     677             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::isAfterLast() = " << m_bAfterLast << " Clone = " << m_bClone);
     678             : 
     679         322 :     return m_bAfterLast;
     680             : }
     681             : 
     682          25 : sal_Bool ORowSetBase::isOnFirst()
     683             : {
     684             :     SAL_INFO("dbaccess", "ORowSetBase::isOnFirst" );
     685          25 :     return isFirst();
     686             : }
     687             : 
     688          26 : sal_Bool SAL_CALL ORowSetBase::isFirst(  ) throw(SQLException, RuntimeException, std::exception)
     689             : {
     690             :     SAL_INFO("dbaccess", "ORowSetBase::isFirst" );
     691             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::isFirst() Clone = " << m_bClone);
     692             : 
     693          26 :     ::connectivity::checkDisposed(m_rBHelper.bDisposed);
     694          26 :     ::osl::MutexGuard aGuard( *m_pMutex );
     695          26 :     checkCache();
     696             : 
     697          26 :     if ( m_bBeforeFirst || m_bAfterLast )
     698          15 :         return sal_False;
     699             : 
     700          11 :     if ( impl_rowDeleted() )
     701           0 :         return ( m_nDeletedPosition == 1 );
     702             : 
     703          11 :     sal_Bool bIsFirst = m_pCache->isFirst();
     704             : 
     705             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::isFirst() = " << bIsFirst << " Clone = " << m_bClone);
     706          11 :     return bIsFirst;
     707             : }
     708             : 
     709           2 : sal_Bool ORowSetBase::isOnLast()
     710             : {
     711             :     SAL_INFO("dbaccess", "ORowSetBase::isOnLast" );
     712           2 :     return isLast();
     713             : }
     714             : 
     715           3 : sal_Bool SAL_CALL ORowSetBase::isLast(  ) throw(SQLException, RuntimeException, std::exception)
     716             : {
     717             :     SAL_INFO("dbaccess", "ORowSetBase::isLast" );
     718             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::isLast() Clone = " << m_bClone);
     719           3 :     ::connectivity::checkDisposed(m_rBHelper.bDisposed);
     720           3 :     ::osl::MutexGuard aGuard( *m_pMutex );
     721           3 :     checkCache();
     722             : 
     723           3 :     if ( m_bBeforeFirst || m_bAfterLast )
     724           1 :         return sal_False;
     725             : 
     726           2 :     if ( impl_rowDeleted() )
     727             :     {
     728           0 :         if ( !m_pCache->m_bRowCountFinal )
     729           0 :             return sal_False;
     730             :         else
     731           0 :             return ( m_nDeletedPosition == impl_getRowCount() );
     732             :     }
     733             : 
     734           2 :     sal_Bool bIsLast = m_pCache->isLast();
     735             : 
     736             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::isLast() = " << bIsLast << " Clone = " << m_bClone);
     737           2 :     return bIsLast;
     738             : }
     739             : 
     740           9 : void SAL_CALL ORowSetBase::beforeFirst(  ) throw(SQLException, RuntimeException, std::exception)
     741             : {
     742             :     SAL_INFO("dbaccess", "ORowSetBase::beforeFirst" );
     743             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::beforeFirst() Clone = " << m_bClone);
     744           9 :     ::connectivity::checkDisposed(m_rBHelper.bDisposed);
     745           9 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
     746             : 
     747           9 :     checkPositioningAllowed();
     748             : 
     749             :     // check if we are inserting a row
     750           9 :     sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
     751             : 
     752           9 :     if((bWasNew || !m_bBeforeFirst) && notifyAllListenersCursorBeforeMove(aGuard) )
     753             :     {
     754           5 :         ORowSetNotifier aNotifier( this );
     755             :             // this will call cancelRowModification on the cache if necessary
     756             : 
     757           5 :         if ( !m_bBeforeFirst )
     758             :         {
     759           5 :             ORowSetRow aOldValues = getOldRow(bWasNew);
     760           5 :             m_pCache->beforeFirst();
     761           5 :             doCancelModification( );
     762             : 
     763             :             // notification order
     764             :             // - column values
     765             :             // - cursorMoved
     766           5 :             setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
     767             : 
     768             :             // - IsModified
     769             :             // - Isnew
     770           5 :             aNotifier.fire();
     771             : 
     772             :             // - RowCount/IsRowCountFinal
     773           5 :             fireRowcount();
     774             :         }
     775             : 
     776             :         // to be done _after_ the notifications!
     777           5 :         m_aOldRow->clearRow();
     778             :     }
     779           9 :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::beforeFirst() Clone = " << m_bClone);
     780           9 : }
     781             : 
     782           5 : void SAL_CALL ORowSetBase::afterLast(  ) throw(SQLException, RuntimeException, std::exception)
     783             : {
     784             :     SAL_INFO("dbaccess", "ORowSetBase::afterLast" );
     785             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::afterLast() Clone = " << m_bClone);
     786           5 :     ::connectivity::checkDisposed(m_rBHelper.bDisposed);
     787             : 
     788           5 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
     789           5 :     checkPositioningAllowed();
     790             : 
     791           5 :     sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
     792             : 
     793           5 :     if((bWasNew || !m_bAfterLast) && notifyAllListenersCursorBeforeMove(aGuard) )
     794             :     {
     795             :         // check if we are inserting a row
     796           5 :         ORowSetNotifier aNotifier( this );
     797             :             // this will call cancelRowModification on the cache if necessary
     798             : 
     799           5 :         if(!m_bAfterLast)
     800             :         {
     801           5 :             ORowSetRow aOldValues = getOldRow(bWasNew);
     802             : 
     803           5 :             m_pCache->afterLast();
     804           5 :             doCancelModification( );
     805             : 
     806             :             // notification order
     807             :             // - column values
     808             :             // - cursorMoved
     809           5 :             setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
     810             : 
     811             :             // - IsModified
     812             :             // - Isnew
     813           5 :             aNotifier.fire();
     814             : 
     815             :             // - RowCount/IsRowCountFinal
     816           5 :             fireRowcount();
     817           5 :         }
     818             :     }
     819           5 :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::afterLast() Clone = " << m_bClone);
     820           5 : }
     821             : 
     822          28 : sal_Bool SAL_CALL ORowSetBase::move(    ::std::mem_fun_t<sal_Bool,ORowSetBase>& _aCheckFunctor,
     823             :                                         ::std::mem_fun_t<sal_Bool,ORowSetCache>& _aMovementFunctor)
     824             : {
     825             :     SAL_INFO("dbaccess", "ORowSetBase::move" );
     826             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::move() Clone = " << m_bClone);
     827          28 :     ::connectivity::checkDisposed(m_rBHelper.bDisposed);
     828          28 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
     829          28 :     checkPositioningAllowed();
     830             : 
     831          27 :     sal_Bool bRet( notifyAllListenersCursorBeforeMove( aGuard ) );
     832          27 :     if( bRet )
     833             :     {
     834             :         // check if we are inserting a row
     835          27 :         sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
     836             : 
     837          27 :         ORowSetNotifier aNotifier( this );
     838             :             // this will call cancelRowModification on the cache if necessary
     839             : 
     840          54 :         ORowSetRow aOldValues = getOldRow(bWasNew);
     841             : 
     842          27 :         sal_Bool bMoved = ( bWasNew || !_aCheckFunctor(this) );
     843             : 
     844          27 :         bRet = _aMovementFunctor(m_pCache);
     845          27 :         doCancelModification( );
     846             : 
     847          27 :         if ( bRet )
     848             :         {
     849             :             // notification order
     850             :             // - column values
     851             :             // - cursorMoved
     852          25 :             setCurrentRow( bMoved, sal_True, aOldValues, aGuard );
     853             :         }
     854             :         else
     855             :         {   // first goes wrong so there is no row
     856           2 :             movementFailed();
     857             :         }
     858             : 
     859             :         // - IsModified
     860             :         // - IsNew
     861          27 :         aNotifier.fire();
     862             : 
     863             :         // - RowCount/IsRowCountFinal
     864          54 :         fireRowcount();
     865             :     }
     866             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::move() = " << bRet << " Clone = " << m_bClone);
     867          28 :     return bRet;
     868             : }
     869             : 
     870          26 : sal_Bool SAL_CALL ORowSetBase::first(  ) throw(SQLException, RuntimeException, std::exception)
     871             : {
     872             :     SAL_INFO("dbaccess", "ORowSetBase::first" );
     873             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::first() Clone = " << m_bClone);
     874          26 :     ::std::mem_fun_t<sal_Bool,ORowSetBase> ioF_tmp(&ORowSetBase::isOnFirst);
     875          26 :     ::std::mem_fun_t<sal_Bool,ORowSetCache> F_tmp(&ORowSetCache::first);
     876          26 :     return move(ioF_tmp,F_tmp);
     877             : }
     878             : 
     879           2 : sal_Bool SAL_CALL ORowSetBase::last(  ) throw(SQLException, RuntimeException, std::exception)
     880             : {
     881             :     SAL_INFO("dbaccess", "ORowSetBase::last" );
     882             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::last() Clone = " << m_bClone);
     883           2 :     ::std::mem_fun_t<sal_Bool,ORowSetBase> ioL_tmp(&ORowSetBase::isOnLast);
     884           2 :     ::std::mem_fun_t<sal_Bool,ORowSetCache> L_tmp(&ORowSetCache::last);
     885           2 :     return move(ioL_tmp,L_tmp);
     886             : }
     887             : 
     888          45 : sal_Int32 SAL_CALL ORowSetBase::getRow(  ) throw(SQLException, RuntimeException, std::exception)
     889             : {
     890             :     SAL_INFO("dbaccess", "ORowSetBase::getRow" );
     891             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::getRow() Clone = " << m_bClone);
     892          45 :     ::osl::MutexGuard aGuard( *m_pMutex );
     893             : 
     894          45 :     checkCache();
     895          45 :     return impl_getRow();
     896             : }
     897             : 
     898          45 : sal_Int32 ORowSetBase::impl_getRow()
     899             : {
     900             :     SAL_INFO("dbaccess", "ORowSetBase::impl_getRow" );
     901          45 :     sal_Int32  nPos = 0;
     902          45 :     if ( m_bBeforeFirst )
     903           0 :         nPos = 0;
     904          45 :     else if ( m_bAfterLast )
     905           0 :         nPos = impl_getRowCount() + 1;
     906          45 :     else if ( impl_rowDeleted() )
     907           0 :         nPos = m_nDeletedPosition;
     908          45 :     else if ( !m_bClone && m_pCache->m_bNew )
     909           0 :         nPos = 0;
     910             :     else
     911             :     {
     912         135 :         if  (   m_pCache->isAfterLast()
     913          45 :             ||  m_pCache->isBeforeFirst()
     914         225 :             ||  ( m_pCache->compareBookmarks( m_aBookmark, m_pCache->getBookmark() ) != CompareBookmark::EQUAL )
     915             :             )
     916             :         {
     917           0 :             positionCache( MOVE_NONE_REFRESH_ONLY );
     918             :         }
     919          45 :         nPos = m_pCache->getRow();
     920             :     }
     921             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::impl_getRow() = " << nPos << " Clone = " << m_bClone);
     922          45 :     return nPos;
     923             : }
     924             : 
     925           2 : sal_Bool SAL_CALL ORowSetBase::absolute( sal_Int32 row ) throw(SQLException, RuntimeException, std::exception)
     926             : {
     927             :     SAL_INFO("dbaccess", "ORowSetBase::absolute" );
     928             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::absolute(" << row << ") Clone = " << m_bClone);
     929           2 :     ::connectivity::checkDisposed(m_rBHelper.bDisposed);
     930           2 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
     931           2 :     checkPositioningAllowed();
     932             : 
     933           2 :     sal_Bool bRet = ( row > 0 )
     934           2 :                 &&  notifyAllListenersCursorBeforeMove( aGuard );
     935           2 :     if ( bRet )
     936             :     {
     937             :         // check if we are inserting a row
     938           2 :         sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
     939             : 
     940           2 :         ORowSetNotifier aNotifier( this );
     941             :             // this will call cancelRowModification on the cache if necessary
     942             : 
     943           4 :         ORowSetRow aOldValues = getOldRow(bWasNew);
     944             : 
     945           2 :         bRet = m_pCache->absolute(row);
     946           2 :         doCancelModification( );
     947             : 
     948           2 :         if(bRet)
     949             :         {
     950             :             // notification order
     951             :             // - column values
     952             :             // - cursorMoved
     953           2 :             setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
     954             :         }
     955             :         else
     956             :         { // absolute movement goes wrong we stand left or right side of the rows
     957           0 :             movementFailed();
     958             :         }
     959             : 
     960             :         // - IsModified
     961             :         // - IsNew
     962           2 :         aNotifier.fire();
     963             : 
     964             :         // - RowCount/IsRowCountFinal
     965           4 :         fireRowcount();
     966             :     }
     967             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::absolute(" << row << ") = " << bRet << " Clone = " << m_bClone);
     968           2 :     return bRet;
     969             : }
     970             : 
     971          16 : sal_Bool SAL_CALL ORowSetBase::relative( sal_Int32 rows ) throw(SQLException, RuntimeException, std::exception)
     972             : {
     973             :     SAL_INFO("dbaccess", "ORowSetBase::relative" );
     974             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::relative(" << rows << ") Clone = " << m_bClone);
     975          16 :     ::connectivity::checkDisposed(m_rBHelper.bDisposed);
     976             : 
     977          16 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
     978             : 
     979          16 :     if(!rows)
     980           0 :         return sal_True; // in this case do nothing
     981             : 
     982          16 :     checkPositioningAllowed();
     983             : 
     984             :     sal_Bool bRet =
     985          16 :             (  ( !m_bAfterLast || rows <= 0 )
     986          16 :             && ( !m_bBeforeFirst || rows >= 0 )
     987          32 :             && notifyAllListenersCursorBeforeMove( aGuard )
     988          16 :             );
     989             : 
     990          16 :     if ( bRet )
     991             :     {
     992             :         // check if we are inserting a row
     993          16 :         sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
     994             : 
     995          16 :         ORowSetNotifier aNotifier( this );
     996             :             // this will call cancelRowModification on the cache if necessary
     997             : 
     998          32 :         ORowSetRow aOldValues = getOldRow(bWasNew);
     999             : 
    1000          16 :         positionCache( rows > 0 ? MOVE_FORWARD : MOVE_BACKWARD );
    1001          16 :         bRet = m_pCache->relative(rows);
    1002          16 :         doCancelModification( );
    1003             : 
    1004          16 :         if(bRet)
    1005             :         {
    1006             :             // notification order
    1007             :             // - column values
    1008             :             // - cursorMoved
    1009          16 :             setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
    1010             :         }
    1011             :         else
    1012             :         {
    1013           0 :             movementFailed();
    1014             :         }
    1015             : 
    1016             :         // - IsModified
    1017             :         // - IsNew
    1018          16 :         aNotifier.fire();
    1019             : 
    1020             :         // - RowCount/IsRowCountFinal
    1021          32 :         fireRowcount();
    1022             :     }
    1023             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::relative(" << rows << ") = " << bRet << " Clone = " << m_bClone);
    1024          16 :     return bRet;
    1025             : }
    1026             : 
    1027           1 : sal_Bool SAL_CALL ORowSetBase::previous(  ) throw(SQLException, RuntimeException, std::exception)
    1028             : {
    1029             :     SAL_INFO("dbaccess", "ORowSetBase::previous" );
    1030             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::previous() Clone = " << m_bClone);
    1031           1 :     ::connectivity::checkDisposed(m_rBHelper.bDisposed);
    1032           1 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
    1033             : 
    1034           1 :     checkPositioningAllowed();
    1035             : 
    1036           1 :     sal_Bool bRet = !m_bBeforeFirst
    1037           1 :                 &&  notifyAllListenersCursorBeforeMove(aGuard);
    1038             : 
    1039           1 :     if ( bRet )
    1040             :     {
    1041             :         // check if we are inserting a row
    1042           1 :         sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
    1043             : 
    1044           1 :         ORowSetNotifier aNotifier( this );
    1045             :             // this will call cancelRowModification on the cache if necessary
    1046             : 
    1047           2 :         ORowSetRow aOldValues = getOldRow(bWasNew);
    1048             : 
    1049           1 :         positionCache( MOVE_BACKWARD );
    1050           1 :         bRet = m_pCache->previous();
    1051           1 :         doCancelModification( );
    1052             : 
    1053             :         // if m_bBeforeFirst is false and bRet is false than we stood on the first row
    1054           1 :         if(!m_bBeforeFirst || bRet)
    1055             :         {
    1056             :             // notification order
    1057             :             // - column values
    1058             :             // - cursorMoved
    1059           1 :             setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
    1060             :         }
    1061             :         else
    1062             :         {
    1063             :             SAL_WARN("dbaccess", "ORowSetBase::previous: inconsistency!" );
    1064             :                 // we should never reach this place, as we should not get into this whole branch if m_bBeforeFirst
    1065             :                 // was |true| from the beginning
    1066           0 :             movementFailed();
    1067             :         }
    1068             : 
    1069             :         // - IsModified
    1070             :         // - IsNew
    1071           1 :         aNotifier.fire();
    1072             : 
    1073             :         // - RowCount/IsRowCountFinal
    1074           2 :         fireRowcount();
    1075             :     }
    1076             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::previous() = " << bRet << " Clone = " << m_bClone);
    1077           1 :     return bRet;
    1078             : }
    1079             : 
    1080         145 : void ORowSetBase::setCurrentRow( sal_Bool _bMoved, sal_Bool _bDoNotify, const ORowSetRow& _rOldValues, ::osl::ResettableMutexGuard& _rGuard )
    1081             : {
    1082             :     SAL_INFO("dbaccess", "ORowSetBase::setCurrentRow" );
    1083             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::setCurrentRow() Clone = " << m_bClone);
    1084         145 :     m_bBeforeFirst  = m_pCache->isBeforeFirst();
    1085         145 :     m_bAfterLast    = m_pCache->isAfterLast();
    1086             : 
    1087         145 :     if(!(m_bBeforeFirst || m_bAfterLast))
    1088             :     {
    1089         130 :         m_aBookmark     = m_pCache->getBookmark();
    1090             :         OSL_ENSURE(m_aBookmark.hasValue(),"Bookmark has no value!");
    1091         130 :         m_aCurrentRow   = m_pCache->m_aMatrixIter;
    1092         130 :         m_bIsInsertRow  = sal_False;
    1093             :         OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is null!");
    1094         130 :         m_aCurrentRow.setBookmark(m_aBookmark);
    1095             :         OSL_ENSURE(!m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd(),"Position of matrix iterator isn't valid!");
    1096             :         OSL_ENSURE(m_aCurrentRow->is(),"Currentrow isn't valid");
    1097             :         OSL_ENSURE(m_aBookmark.hasValue(),"Bookmark has no value!");
    1098             : 
    1099         130 :         m_aCurrentRow   = m_pCache->m_aMatrixIter;
    1100         130 :         m_bIsInsertRow  = sal_False;
    1101             :         OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is nul after positionCache!");
    1102             : #if OSL_DEBUG_LEVEL > 0
    1103             :         ORowSetRow rRow = (*m_aCurrentRow);
    1104             :         OSL_ENSURE(rRow.is() ,"Invalid size of vector!");
    1105             : #endif
    1106             :         // the cache could repositioned so we need to adjust the cache
    1107         260 :         if ( _bMoved && m_aCurrentRow.isNull() )
    1108             :         {
    1109           0 :             positionCache( MOVE_NONE_REFRESH_ONLY );
    1110           0 :             m_aCurrentRow   = m_pCache->m_aMatrixIter;
    1111           0 :             m_bIsInsertRow  = sal_False;
    1112             :             OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is nul after positionCache!");
    1113             :         }
    1114             :     }
    1115             :     else
    1116             :     {
    1117          15 :         m_aOldRow->clearRow();
    1118          15 :         m_aCurrentRow   = m_pCache->getEnd();
    1119          15 :         m_aBookmark     = Any();
    1120          15 :         m_aCurrentRow.setBookmark(m_aBookmark);
    1121             :     }
    1122             : 
    1123             :     // notification order
    1124             :     // - column values
    1125         145 :     if ( _bDoNotify )
    1126         145 :         firePropertyChange(_rOldValues);
    1127             : 
    1128             :     // TODO: can this be done before the notifications?
    1129         145 :     if(!(m_bBeforeFirst || m_bAfterLast) && !m_aCurrentRow.isNull() && m_aCurrentRow->is() && m_aCurrentRow != m_pCache->getEnd())
    1130         130 :         m_aOldRow->setRow(new ORowSetValueVector( *(*m_aCurrentRow) ));
    1131             : 
    1132         145 :     if ( _bMoved && _bDoNotify )
    1133             :         // - cursorMoved
    1134         134 :         notifyAllListenersCursorMoved( _rGuard );
    1135             : 
    1136             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::setCurrentRow() Clone = " << m_bClone);
    1137         145 : }
    1138             : 
    1139          64 : void ORowSetBase::checkPositioningAllowed() throw( SQLException, RuntimeException )
    1140             : {
    1141             :     SAL_INFO("dbaccess", "ORowSetBase::checkPositioningAllowed" );
    1142          64 :     if(!m_pCache || m_nResultSetType == ResultSetType::FORWARD_ONLY)
    1143           2 :         throwFunctionSequenceException(*m_pMySelf);
    1144          63 : }
    1145             : 
    1146           1 : Reference< XInterface >  ORowSetBase::getStatement(void) throw( SQLException, RuntimeException, std::exception )
    1147             : {
    1148             :     SAL_INFO("dbaccess", "ORowSetBase::getStatement" );
    1149           1 :     return NULL;
    1150             : }
    1151             : 
    1152           1 : void SAL_CALL ORowSetBase::refreshRow(  ) throw(SQLException, RuntimeException, std::exception)
    1153             : {
    1154             :     SAL_INFO("dbaccess", "ORowSetBase::refreshRow" );
    1155           1 :     ::connectivity::checkDisposed(m_rBHelper.bDisposed);
    1156           1 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1157           1 :     checkCache();
    1158           1 :     if ( impl_rowDeleted() )
    1159           0 :         throwSQLException( "The current row is deleted", SQL_INVALID_CURSOR_STATE, Reference< XRowSet >( this ) );
    1160             : 
    1161           1 :     if(!(m_bBeforeFirst || m_bAfterLast))
    1162             :     {
    1163           1 :         sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
    1164           1 :         ORowSetRow aOldValues = getOldRow(bWasNew);
    1165           1 :         positionCache( MOVE_NONE_REFRESH_ONLY );
    1166           1 :         m_pCache->refreshRow();
    1167           1 :         firePropertyChange(aOldValues);
    1168           1 :     }
    1169           1 : }
    1170             : 
    1171           1 : sal_Bool SAL_CALL ORowSetBase::rowUpdated(  ) throw(SQLException, RuntimeException, std::exception)
    1172             : {
    1173             :     SAL_INFO("dbaccess", "ORowSetBase::rowUpdated" );
    1174           1 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1175           1 :     checkCache();
    1176             : 
    1177           1 :     if ( impl_rowDeleted() )
    1178           0 :         return sal_False;
    1179             : 
    1180           1 :     return m_pCache->rowUpdated();
    1181             : }
    1182             : 
    1183           1 : sal_Bool SAL_CALL ORowSetBase::rowInserted(  ) throw(SQLException, RuntimeException, std::exception)
    1184             : {
    1185             :     SAL_INFO("dbaccess", "ORowSetBase::rowInserted" );
    1186           1 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1187             : 
    1188           1 :     checkCache();
    1189             : 
    1190           1 :     if ( impl_rowDeleted() )
    1191           0 :         return sal_False;
    1192             : 
    1193           1 :     return m_pCache->rowInserted();
    1194             : }
    1195             : 
    1196         286 : sal_Bool SAL_CALL ORowSetBase::rowDeleted(  ) throw(SQLException, RuntimeException, std::exception)
    1197             : {
    1198             :     SAL_INFO("dbaccess", "ORowSetBase::rowDeleted" );
    1199         286 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1200         286 :     checkCache();
    1201         286 :     return impl_rowDeleted();
    1202             : }
    1203             : 
    1204        1368 : sal_Bool ORowSetBase::impl_rowDeleted(  )
    1205             : {
    1206        1368 :     return !m_aBookmark.hasValue() && !m_bBeforeFirst && !m_bAfterLast;
    1207             : }
    1208             : 
    1209             : // XWarningsSupplier
    1210           0 : Any SAL_CALL ORowSetBase::getWarnings(  ) throw(SQLException, RuntimeException, std::exception)
    1211             : {
    1212             :     SAL_INFO("dbaccess", "ORowSetBase::getWarnings" );
    1213           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1214             : 
    1215           0 :     if ( m_pCache )
    1216             :     {
    1217           0 :         Reference< XWarningsSupplier > xWarnings( m_pCache->m_xSet.get(), UNO_QUERY );
    1218           0 :         if ( xWarnings.is() )
    1219           0 :             return xWarnings->getWarnings();
    1220             :     }
    1221             : 
    1222           0 :     return Any();
    1223             : }
    1224             : 
    1225           0 : void SAL_CALL ORowSetBase::clearWarnings(  ) throw(SQLException, RuntimeException, std::exception)
    1226             : {
    1227             :     SAL_INFO("dbaccess", "ORowSetBase::clearWarnings" );
    1228           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1229             : 
    1230           0 :     if ( m_pCache )
    1231             :     {
    1232           0 :         Reference< XWarningsSupplier > xWarnings( m_pCache->m_xSet.get(), UNO_QUERY );
    1233           0 :         if ( xWarnings.is() )
    1234           0 :             xWarnings->clearWarnings();
    1235           0 :     }
    1236           0 : }
    1237             : 
    1238         151 : void ORowSetBase::firePropertyChange(const ORowSetRow& _rOldRow)
    1239             : {
    1240         151 :     if (!isPropertyChangeNotificationEnabled())
    1241         151 :         return;
    1242             : 
    1243             :     SAL_INFO("dbaccess", "ORowSetBase::firePropertyChange" );
    1244             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::firePropertyChange() Clone = " << m_bClone);
    1245             :     OSL_ENSURE(m_pColumns,"Columns can not be NULL here!");
    1246         151 :     sal_Int32 i=0;
    1247             :     try
    1248             :     {
    1249         151 :         TDataColumns::iterator aEnd = m_aDataColumns.end();
    1250        1922 :         for(TDataColumns::iterator aIter = m_aDataColumns.begin();aIter != aEnd;++aIter,++i)
    1251        1771 :             (*aIter)->fireValueChange(_rOldRow.is() ? (_rOldRow->get())[i+1] : ::connectivity::ORowSetValue());
    1252             :     }
    1253           0 :     catch (const Exception&)
    1254             :     {
    1255             :         SAL_WARN("dbaccess", "firePropertyChange: Exception");
    1256             :     }
    1257             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::firePropertyChange() Clone = " << m_bClone);
    1258             : }
    1259             : 
    1260           6 : void ORowSetBase::firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetValue& _rOldValue)
    1261             : {
    1262             :     OSL_ENSURE(_nPos < (sal_Int32)m_aDataColumns.size(),"nPos is invalid!");
    1263           6 :     m_aDataColumns[_nPos]->fireValueChange(_rOldValue);
    1264           6 : }
    1265             : 
    1266          16 : void ORowSetBase::fireRowcount()
    1267             : {
    1268             :     SAL_INFO("dbaccess", "ORowSetBase::fireRowcount" );
    1269          16 : }
    1270             : 
    1271          16 : sal_Bool ORowSetBase::notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard& /*_rGuard*/)
    1272             : {
    1273             :     SAL_INFO("dbaccess", "ORowSetBase::notifyAllListenersCursorBeforeMove" );
    1274          16 :     return sal_True;
    1275             : }
    1276             : 
    1277          16 : void ORowSetBase::notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& /*_rGuard*/)
    1278             : {
    1279             :     SAL_INFO("dbaccess", "ORowSetBase::notifyAllListenersCursorMoved" );
    1280          16 : }
    1281             : 
    1282           0 : void ORowSetBase::notifyAllListeners(::osl::ResettableMutexGuard& /*_rGuard*/)
    1283             : {
    1284             :     SAL_INFO("dbaccess", "ORowSetBase::notifyAllListeners" );
    1285           0 : }
    1286             : 
    1287          16 : sal_Bool ORowSetBase::isPropertyChangeNotificationEnabled() const
    1288             : {
    1289          16 :     return sal_True;
    1290             : }
    1291             : 
    1292          14 : void ORowSetBase::fireProperty( sal_Int32 _nProperty, sal_Bool _bNew, sal_Bool _bOld )
    1293             : {
    1294             :     SAL_INFO("dbaccess", "ORowSetBase::fireProperty" );
    1295          14 :     Any aNew = css::uno::makeAny( _bNew );
    1296          28 :     Any aOld = css::uno::makeAny( _bOld );
    1297          28 :     fire( &_nProperty, &aNew, &aOld, 1, sal_False );
    1298          14 : }
    1299             : 
    1300         109 : void ORowSetBase::positionCache( CursorMoveDirection _ePrepareForDirection )
    1301             : {
    1302             :     SAL_INFO("dbaccess", "ORowSetBase::positionCache" );
    1303             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::positionCache() Clone = " << m_bClone);
    1304             : 
    1305         109 :     sal_Bool bSuccess = sal_False;
    1306         109 :     if ( m_aBookmark.hasValue() )
    1307             :     {
    1308         404 :         if ( _ePrepareForDirection == MOVE_NONE_REFRESH_ONLY ||
    1309         396 :              m_pCache->compareBookmarks( m_aBookmark, m_pCache->getBookmark() ) != CompareBookmark::EQUAL )
    1310           4 :             bSuccess = m_pCache->moveToBookmark( m_aBookmark );
    1311             :         else
    1312          98 :             bSuccess = sal_True;
    1313             :     }
    1314             :     else
    1315             :     {
    1316           7 :         if ( m_bBeforeFirst )
    1317             :         {
    1318           6 :             bSuccess = m_pCache->beforeFirst();
    1319             :         }
    1320           1 :         else if ( m_bAfterLast )
    1321             :         {
    1322           0 :             bSuccess = m_pCache->afterLast();
    1323             :         }
    1324             :         else
    1325             :         {
    1326             :             OSL_ENSURE( m_nDeletedPosition >= 1, "ORowSetBase::positionCache: no bookmark, and no valid 'deleted position'!" );
    1327           1 :             switch ( _ePrepareForDirection )
    1328             :             {
    1329             :             case MOVE_FORWARD:
    1330           1 :                 if ( m_nDeletedPosition > 1 )
    1331           1 :                     bSuccess = m_pCache->absolute( m_nDeletedPosition - 1 );
    1332             :                 else
    1333             :                 {
    1334           0 :                     m_pCache->beforeFirst();
    1335           0 :                     bSuccess = sal_True;
    1336             :                 }
    1337           1 :                 break;
    1338             : 
    1339             :             case MOVE_BACKWARD:
    1340           0 :                 if ( m_pCache->m_bRowCountFinal && ( m_nDeletedPosition == impl_getRowCount() ) )
    1341             :                 {
    1342           0 :                     m_pCache->afterLast();
    1343           0 :                     bSuccess = sal_True;
    1344             :                 }
    1345             :                 else
    1346           0 :                     bSuccess = m_pCache->absolute( m_nDeletedPosition );
    1347           0 :                 break;
    1348             : 
    1349             :             case MOVE_NONE_REFRESH_ONLY:
    1350           0 :                 bSuccess = sal_False;   // will be asserted below
    1351           0 :                 break;
    1352             :             }
    1353             :         }
    1354             :     }
    1355             :     OSL_ENSURE( bSuccess, "ORowSetBase::positionCache: failed!" );
    1356             :     (void)bSuccess;
    1357             : 
    1358             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::positionCache() Clone = " << m_bClone);
    1359         109 : }
    1360             : 
    1361        3875 : void ORowSetBase::checkCache()
    1362             : {
    1363             :     SAL_INFO("dbaccess", "ORowSetBase::checkCache" );
    1364        3875 :     ::connectivity::checkDisposed(m_rBHelper.bDisposed);
    1365        3875 :     if(!m_pCache)
    1366           0 :         throwFunctionSequenceException(*m_pMySelf);
    1367        3875 : }
    1368             : 
    1369           2 : void ORowSetBase::movementFailed()
    1370             : {
    1371             :     SAL_INFO("dbaccess", "ORowSetBase::movementFailed" );
    1372             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::movementFailed() Clone = " << m_bClone);
    1373           2 :     m_aOldRow->clearRow();
    1374           2 :     m_aCurrentRow   = m_pCache->getEnd();
    1375           2 :     m_bBeforeFirst  = m_pCache->isBeforeFirst();
    1376           2 :     m_bAfterLast    = m_pCache->isAfterLast();
    1377           2 :     m_aBookmark     = Any();
    1378           2 :     m_aCurrentRow.setBookmark(m_aBookmark);
    1379             :     OSL_ENSURE(m_bBeforeFirst || m_bAfterLast,"BeforeFirst or AfterLast is wrong!");
    1380             :     SAL_INFO("dbaccess", "DBACCESS ORowSetBase::movementFailed() Clone = " << m_bClone);
    1381           2 : }
    1382             : 
    1383         147 : ORowSetRow ORowSetBase::getOldRow(sal_Bool _bWasNew)
    1384             : {
    1385             :     SAL_INFO("dbaccess", "ORowSetBase::getOldRow" );
    1386             :     OSL_ENSURE(m_aOldRow.is(),"RowSetRowHElper isn't valid!");
    1387         147 :     ORowSetRow aOldValues;
    1388         147 :     if ( !_bWasNew && m_aOldRow->getRow().is() )
    1389         117 :         aOldValues = new ORowSetValueVector( *(m_aOldRow->getRow()));    // remember the old values
    1390         147 :     return aOldValues;
    1391             : }
    1392             : 
    1393           0 : void ORowSetBase::getPropertyDefaultByHandle( sal_Int32 /*_nHandle*/, Any& _rDefault ) const
    1394             : {
    1395             :     SAL_INFO("dbaccess", "ORowSetBase::getPropertyDefaultByHandle" );
    1396           0 :     _rDefault.clear();
    1397           0 : }
    1398             : 
    1399           1 : void ORowSetBase::onDeleteRow( const Any& _rBookmark )
    1400             : {
    1401             :     SAL_INFO("dbaccess", "ORowSetBase::onDeleteRow" );
    1402           1 :     if ( rowDeleted() )
    1403             :         // not interested in
    1404           1 :         return;
    1405             : 
    1406           1 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1407             :     //OSL_ENSURE( m_aBookmark.hasValue(), "ORowSetBase::onDeleteRow: Bookmark isn't valid!" );
    1408           1 :     if ( compareBookmarks( _rBookmark, m_aBookmark ) == 0 )
    1409             :     {
    1410           1 :         positionCache( MOVE_NONE_REFRESH_ONLY );
    1411           1 :         m_nDeletedPosition = m_pCache->getRow();
    1412           1 :     }
    1413             : }
    1414             : 
    1415           1 : void ORowSetBase::onDeletedRow( const Any& _rBookmark, sal_Int32 _nPos )
    1416             : {
    1417             :     SAL_INFO("dbaccess", "ORowSetBase::onDeletedRow" );
    1418           1 :     if ( rowDeleted() )
    1419             :     {
    1420             :         // if we're a clone, and on a deleted row, and the main RowSet deleted another
    1421             :         // row (only the main RowSet can, clones can't), which is *before* our
    1422             :         // deleted position, then we have to adjust this position
    1423           0 :         if ( m_bClone && ( _nPos < m_nDeletedPosition ) )
    1424           0 :             --m_nDeletedPosition;
    1425           1 :         return;
    1426             :     }
    1427             : 
    1428           1 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1429           1 :     if ( compareBookmarks( _rBookmark, m_aBookmark ) == 0 )
    1430             :     {
    1431           1 :         m_aOldRow->clearRow();
    1432           1 :         m_aCurrentRow   = m_pCache->getEnd();
    1433           1 :         m_aBookmark     = Any();
    1434           1 :         m_aCurrentRow.setBookmark( m_aBookmark );
    1435           1 :     }
    1436             : }
    1437             : 
    1438         177 : sal_Int32 ORowSetBase::impl_getRowCount() const
    1439             : {
    1440             :     SAL_INFO("dbaccess", "ORowSetBase::impl_getRowCount" );
    1441         177 :     sal_Int32 nRowCount( m_pCache->m_nRowCount );
    1442         177 :     if ( const_cast< ORowSetBase* >( this )->rowDeleted() && !m_pCache->m_bNew )
    1443           2 :         ++nRowCount;
    1444         177 :     return nRowCount;
    1445             : }
    1446             : 
    1447          12 : struct ORowSetNotifierImpl
    1448             : {
    1449             :     ::std::vector<sal_Int32>    aChangedColumns;
    1450             :     ::std::vector<Any>          aChangedBookmarks;
    1451             :     ORowSetValueVector::Vector  aRow;
    1452             : 
    1453             : };
    1454             : 
    1455             : 
    1456         148 : ORowSetNotifier::ORowSetNotifier( ORowSetBase* _pRowSet )
    1457             :     :m_pRowSet( _pRowSet )
    1458             :     ,m_bWasNew( sal_False )
    1459         148 :     ,m_bWasModified( sal_False )
    1460             : #ifdef DBG_UTIL
    1461             :     ,m_bNotifyCalled( sal_False )
    1462             : #endif
    1463             : {
    1464             : 
    1465             :     OSL_ENSURE( m_pRowSet, "ORowSetNotifier::ORowSetNotifier: invalid row set. This wil crash." );
    1466             : 
    1467             :     // remember the "inserted" and "modified" state for later firing
    1468         148 :     m_bWasNew       = m_pRowSet->isNew( ORowSetBase::GrantNotifierAccess() );
    1469         148 :     m_bWasModified  = m_pRowSet->isModified( ORowSetBase::GrantNotifierAccess() );
    1470             : 
    1471             :     // if the row set is on the insert row, then we need to cancel this
    1472         148 :     if ( m_pRowSet->isModification( ORowSetBase::GrantNotifierAccess() ) )
    1473           0 :         m_pRowSet->doCancelModification( ORowSetBase::GrantNotifierAccess() );
    1474         148 : }
    1475             : 
    1476           6 : ORowSetNotifier::ORowSetNotifier( ORowSetBase* _pRowSet,const ORowSetValueVector::Vector& i_aRow )
    1477           6 :     :m_pImpl(new ORowSetNotifierImpl)
    1478             :     ,m_pRowSet( _pRowSet )
    1479             :     ,m_bWasNew( sal_False )
    1480          12 :     ,m_bWasModified( sal_False )
    1481             : #ifdef DBG_UTIL
    1482             :     ,m_bNotifyCalled( sal_False )
    1483             : #endif
    1484             : {
    1485             : 
    1486             :     OSL_ENSURE( m_pRowSet, "ORowSetNotifier::ORowSetNotifier: invalid row set. This wil crash." );
    1487           6 :     m_pImpl->aRow = i_aRow; // yes, create a copy to store the old values
    1488           6 : }
    1489             : 
    1490         154 : ORowSetNotifier::~ORowSetNotifier( )
    1491             : {
    1492             :     SAL_INFO("dbaccess", "ORowSetNotifier::~ORowSetNotifier" );
    1493         154 : }
    1494             : 
    1495         148 : void ORowSetNotifier::fire()
    1496             : {
    1497             :     // we're not interested in firing changes FALSE->TRUE, only TRUE->FALSE.
    1498             :     // (the former would be quite pathological, e.g. after a failed movement)
    1499             : 
    1500         443 :     if  (   m_bWasModified
    1501         297 :         &&  ( m_bWasModified != m_pRowSet->isModified( ORowSetBase::GrantNotifierAccess() ) )
    1502             :         )
    1503           1 :         m_pRowSet->fireProperty( PROPERTY_ID_ISMODIFIED, sal_False, sal_True, ORowSetBase::GrantNotifierAccess() );
    1504             : 
    1505         444 :     if  (   m_bWasNew
    1506         296 :         &&  ( m_bWasNew != m_pRowSet->isNew( ORowSetBase::GrantNotifierAccess() ) )
    1507             :         )
    1508           0 :         m_pRowSet->fireProperty( PROPERTY_ID_ISNEW, sal_False, sal_True, ORowSetBase::GrantNotifierAccess() );
    1509             : 
    1510             : #ifdef DBG_UTIL
    1511             :     m_bNotifyCalled = sal_True;
    1512             : #endif
    1513         148 : }
    1514             : 
    1515          12 : ::std::vector<sal_Int32>& ORowSetNotifier::getChangedColumns() const
    1516             : {
    1517             :     OSL_ENSURE(m_pImpl.get(),"Illegal CTor call, use the other one!");
    1518          12 :     return m_pImpl->aChangedColumns;
    1519             : }
    1520             : 
    1521           6 : void ORowSetNotifier::firePropertyChange()
    1522             : {
    1523             :     OSL_ENSURE(m_pImpl.get(),"Illegal CTor call, use the other one!");
    1524           6 :     if( m_pImpl.get() )
    1525             :     {
    1526           6 :         ::std::vector<sal_Int32>::iterator aIter = m_pImpl->aChangedColumns.begin();
    1527          12 :         for(;aIter != m_pImpl->aChangedColumns.end();++aIter)
    1528             :         {
    1529           6 :             m_pRowSet->firePropertyChange((*aIter)-1 ,m_pImpl->aRow[(*aIter)-1], ORowSetBase::GrantNotifierAccess());
    1530             :         }
    1531           6 :         if ( !m_pImpl->aChangedColumns.empty() )
    1532           6 :             m_pRowSet->fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False, ORowSetBase::GrantNotifierAccess());
    1533             :     }
    1534           6 : }
    1535             : 
    1536             : }   // namespace dbaccess
    1537             : 
    1538             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10