LCOV - code coverage report
Current view: top level - connectivity/source/drivers/mork - MResultSet.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 298 785 38.0 %
Date: 2014-11-03 Functions: 35 118 29.7 %
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 <com/sun/star/sdbc/DataType.hpp>
      21             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      22             : #include <comphelper/property.hxx>
      23             : #include <comphelper/sequence.hxx>
      24             : #include <cppuhelper/typeprovider.hxx>
      25             : #include <cppuhelper/supportsservice.hxx>
      26             : #include <comphelper/extract.hxx>
      27             : #include <com/sun/star/lang/DisposedException.hpp>
      28             : #include <com/sun/star/sdbc/ResultSetType.hpp>
      29             : #include <com/sun/star/sdbc/FetchDirection.hpp>
      30             : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
      31             : #include <comphelper/types.hxx>
      32             : #include <connectivity/dbexception.hxx>
      33             : #include <connectivity/dbtools.hxx>
      34             : 
      35             : #include <TSortIndex.hxx>
      36             : #include <rtl/string.hxx>
      37             : #include <vector>
      38             : #include <algorithm>
      39             : #include "MResultSet.hxx"
      40             : #include "MResultSetMetaData.hxx"
      41             : #include "FDatabaseMetaDataResultSet.hxx"
      42             : 
      43             : #include "resource/mork_res.hrc"
      44             : #include "resource/common_res.hrc"
      45             : 
      46             : #if OSL_DEBUG_LEVEL > 0
      47             : # define OUtoCStr( x ) ( OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
      48             : #else /* OSL_DEBUG_LEVEL */
      49             : # define OUtoCStr( x ) ("dummy")
      50             : #endif /* OSL_DEBUG_LEVEL */
      51             : 
      52             : using namespace ::comphelper;
      53             : using namespace connectivity;
      54             : using namespace connectivity::mork;
      55             : using namespace ::cppu;
      56             : using namespace com::sun::star::uno;
      57             : using namespace com::sun::star::lang;
      58             : using namespace com::sun::star::beans;
      59             : using namespace com::sun::star::sdbc;
      60             : using namespace com::sun::star::container;
      61             : using namespace com::sun::star::io;
      62             : using namespace com::sun::star::util;
      63             : 
      64             : 
      65             : //  IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.OResultSet","com.sun.star.sdbc.ResultSet");
      66           0 : OUString SAL_CALL OResultSet::getImplementationName(  ) throw ( RuntimeException, std::exception)    \
      67             : {
      68           0 :     return OUString("com.sun.star.sdbcx.mork.ResultSet");
      69             : }
      70             : 
      71           0 :  Sequence< OUString > SAL_CALL OResultSet::getSupportedServiceNames(  ) throw( RuntimeException, std::exception)
      72             : {
      73           0 :     ::com::sun::star::uno::Sequence< OUString > aSupported(2);
      74           0 :     aSupported[0] = "com.sun.star.sdbc.ResultSet";
      75           0 :     aSupported[1] = "com.sun.star.sdbcx.ResultSet";
      76           0 :     return aSupported;
      77             : }
      78             : 
      79           0 : sal_Bool SAL_CALL OResultSet::supportsService( const OUString& _rServiceName ) throw( RuntimeException, std::exception)
      80             : {
      81           0 :     return cppu::supportsService(this, _rServiceName);
      82             : }
      83             : 
      84             : 
      85           4 : OResultSet::OResultSet(OCommonStatement* pStmt, const ::boost::shared_ptr< connectivity::OSQLParseTreeIterator >& _pSQLIterator )
      86             :     : OResultSet_BASE(m_aMutex)
      87             :     ,OPropertySetHelper(OResultSet_BASE::rBHelper)
      88             :     ,m_pStatement(pStmt)
      89             :     ,m_xStatement(*pStmt)
      90             :     ,m_xMetaData(NULL)
      91             :     ,m_nRowPos(0)
      92             :     ,m_nOldRowPos(0)
      93             :     ,m_bWasNull(false)
      94             :     ,m_nFetchSize(0)
      95             :     ,m_nResultSetType(ResultSetType::SCROLL_INSENSITIVE)
      96             :     ,m_nFetchDirection(FetchDirection::FORWARD)
      97             :     ,m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE)
      98             :     ,m_pSQLIterator( _pSQLIterator )
      99           4 :     ,m_pParseTree( _pSQLIterator->getParseTree() )
     100           4 :     ,m_aQueryHelper(pStmt->getOwnConnection()->getColumnAlias())
     101             :     ,m_pTable(NULL)
     102             :     ,m_CurrentRowCount(0)
     103             :     ,m_nParamIndex(0)
     104             :     ,m_bIsAlwaysFalseQuery(false)
     105             :     ,m_pKeySet(NULL)
     106             :     ,m_nNewRow(0)
     107             :     ,m_nUpdatedRow(0)
     108             :     ,m_RowStates(0)
     109          12 :     ,m_bIsReadOnly(-1)
     110             : {
     111             :     //m_aQuery.setMaxNrOfReturns(pStmt->getOwnConnection()->getMaxResultRecords());
     112           4 : }
     113             : 
     114           8 : OResultSet::~OResultSet()
     115             : {
     116           8 : }
     117             : 
     118             : 
     119           4 : void OResultSet::disposing(void)
     120             : {
     121           4 :     OPropertySetHelper::disposing();
     122             : 
     123           4 :     ::osl::MutexGuard aGuard(m_aMutex);
     124             : 
     125           4 :     m_xStatement.clear();
     126           4 :     m_xMetaData.clear();
     127           4 :     m_pParseTree    = NULL;
     128           4 :     m_xColumns = NULL;
     129           4 :     m_xParamColumns = NULL;
     130           4 :     m_pKeySet       = NULL;
     131           4 :     if(m_pTable)
     132             :     {
     133           4 :         m_pTable->release();
     134           4 :         m_pTable = NULL;
     135           4 :     }
     136           4 : }
     137             : 
     138          20 : Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
     139             : {
     140          20 :     Any aRet = OPropertySetHelper::queryInterface(rType);
     141          20 :     if(!aRet.hasValue())
     142          16 :         aRet = OResultSet_BASE::queryInterface(rType);
     143          20 :     return aRet;
     144             : }
     145             : 
     146           0 :  Sequence<  Type > SAL_CALL OResultSet::getTypes(  ) throw( RuntimeException, std::exception)
     147             : {
     148           0 :     OTypeCollection aTypes( cppu::UnoType<com::sun::star::beans::XMultiPropertySet>::get(),
     149           0 :                                                 cppu::UnoType<com::sun::star::beans::XFastPropertySet>::get(),
     150           0 :                                                 cppu::UnoType<com::sun::star::beans::XPropertySet>::get());
     151             : 
     152           0 :     return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes());
     153             : }
     154             : 
     155          28 : void OResultSet::methodEntry()
     156             : {
     157          28 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     158          28 :     if ( !m_pTable )
     159             :     {
     160             :         OSL_FAIL( "OResultSet::methodEntry: looks like we're disposed, but how is this possible?" );
     161           0 :         throw DisposedException( OUString(), *this );
     162             :     }
     163          28 : }
     164             : 
     165             : 
     166           0 : sal_Int32 SAL_CALL OResultSet::findColumn( const OUString& columnName ) throw(SQLException, RuntimeException, std::exception)
     167             : {
     168           0 :     ResultSetEntryGuard aGuard( *this );
     169             : 
     170             :     // find the first column with the name columnName
     171           0 :     Reference< XResultSetMetaData > xMeta = getMetaData();
     172           0 :     sal_Int32 nLen = xMeta->getColumnCount();
     173           0 :     sal_Int32 i = 1;
     174           0 :     for(;i<=nLen;++i)
     175             :     {
     176           0 :         if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
     177           0 :                 columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
     178           0 :             return i;
     179             :     }
     180             : 
     181           0 :     ::dbtools::throwInvalidColumnException( columnName, *this );
     182             :     assert(false);
     183           0 :     return 0; // Never reached
     184             : }
     185             : 
     186           0 : Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     187             : {
     188           0 :     return NULL;
     189             : }
     190             : 
     191           0 : Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     192             : {
     193           0 :     return NULL;
     194             : }
     195             : 
     196             : 
     197           0 : sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     198             : {
     199           0 :     ResultSetEntryGuard aGuard( *this );
     200           0 :     m_bWasNull = true;
     201           0 :     return sal_False;
     202             : }
     203             : 
     204             : 
     205           0 : sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     206             : {
     207           0 :     ResultSetEntryGuard aGuard( *this );
     208           0 :     return 0;
     209             : }
     210             : 
     211             : 
     212           0 : Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     213             : {
     214           0 :     ResultSetEntryGuard aGuard( *this );
     215           0 :     return Sequence< sal_Int8 >();
     216             : }
     217             : 
     218             : 
     219           0 : Date SAL_CALL OResultSet::getDate( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     220             : {
     221           0 :     ResultSetEntryGuard aGuard( *this );
     222           0 :     return Date();
     223             : }
     224             : 
     225             : 
     226           0 : double SAL_CALL OResultSet::getDouble( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     227             : {
     228           0 :     ResultSetEntryGuard aGuard( *this );
     229           0 :     return 0.0;
     230             : }
     231             : 
     232             : 
     233           0 : float SAL_CALL OResultSet::getFloat( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     234             : {
     235           0 :     ResultSetEntryGuard aGuard( *this );
     236           0 :     return 0;
     237             : }
     238             : 
     239             : 
     240           0 : sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     241             : {
     242           0 :     ResultSetEntryGuard aGuard( *this );
     243           0 :     return 0;
     244             : }
     245             : 
     246             : 
     247           0 : sal_Int32 SAL_CALL OResultSet::getRow(  ) throw(SQLException, RuntimeException, std::exception)
     248             : {
     249           0 :     ResultSetEntryGuard aGuard( *this );
     250             : 
     251             :     OSL_TRACE("In/Out: OResultSet::getRow, return = %u", m_nRowPos );
     252           0 :     return m_nRowPos;
     253             : }
     254             : 
     255             : 
     256           0 : sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     257             : {
     258           0 :     ResultSetEntryGuard aGuard( *this );
     259           0 :     return sal_Int64();
     260             : }
     261             : 
     262             : 
     263           0 : Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData(  ) throw(SQLException, RuntimeException, std::exception)
     264             : {
     265           0 :     ResultSetEntryGuard aGuard( *this );
     266             : 
     267           0 :     if(!m_xMetaData.is())
     268           0 :         m_xMetaData = new OResultSetMetaData(
     269           0 :         m_pSQLIterator->getSelectColumns(), m_pSQLIterator->getTables().begin()->first ,m_pTable,determineReadOnly());
     270           0 :     return m_xMetaData;
     271             : }
     272             : 
     273           0 : Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     274             : {
     275           0 :     return NULL;
     276             : }
     277             : 
     278             : 
     279             : 
     280           0 : Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     281             : {
     282           0 :     return NULL;
     283             : }
     284             : 
     285           0 : Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     286             : {
     287           0 :     return NULL;
     288             : }
     289             : 
     290             : 
     291           0 : Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     292             : {
     293           0 :     return NULL;
     294             : }
     295             : 
     296             : 
     297           0 : Any SAL_CALL OResultSet::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException, std::exception)
     298             : {
     299           0 :     return Any();
     300             : }
     301             : 
     302             : 
     303           0 : sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     304             : {
     305           0 :     return 0;
     306             : }
     307             : 
     308             : 
     309           8 : void OResultSet::checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException)
     310             : {
     311           8 :     if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->get().size())
     312           0 :         ::dbtools::throwInvalidIndexException(*this);
     313           8 : }
     314             : 
     315          12 : sal_uInt32 OResultSet::currentRowCount()
     316             : {
     317          12 :     if ( m_bIsAlwaysFalseQuery )
     318           0 :         return 0;
     319             :     //return 0;//m_aQuery.getRealRowCount() - deletedCount();
     320             :     // new implementation
     321          12 :     return m_aQueryHelper.getResultCount();
     322             : }
     323             : 
     324             : 
     325             : 
     326          10 : bool OResultSet::fetchCurrentRow( ) throw(SQLException, RuntimeException)
     327             : {
     328             :     OSL_TRACE("fetchCurrentRow, m_nRowPos = %u", m_nRowPos );
     329          10 :     return fetchRow(getCurrentCardNumber());
     330             : }
     331             : 
     332             : 
     333           0 : bool OResultSet::pushCard(sal_uInt32 /*cardNumber*/) throw(SQLException, RuntimeException)
     334             : {
     335           0 :     return true;
     336             : /*
     337             :     if (cardNumber == 0)
     338             :         return sal_True;
     339             :     // Check whether we are storing the updated row
     340             :     if ( (m_aRow->get())[0].isNull() || (sal_Int32)(m_aRow->get())[0] != (sal_Int32)cardNumber )
     341             :         return sal_False;
     342             : 
     343             :     sal_Int32 nCount = m_aColumnNames.getLength();
     344             :     m_aQuery.setRowStates(cardNumber,m_RowStates);
     345             :     for( sal_Int32 i = 1; i <= nCount; i++ )
     346             :     {
     347             :         if ( (m_aRow->get())[i].isBound() )
     348             :         {
     349             : 
     350             :             // Everything in the addressbook is a string!
     351             : 
     352             :             if ( !m_aQuery.setRowValue( (m_aRow->get())[i], cardNumber, m_aColumnNames[i-1], DataType::VARCHAR ))
     353             :             {
     354             :                 m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this );
     355             :             }
     356             :         }
     357             :     }
     358             :     return sal_True;
     359             : */
     360             : }
     361             : 
     362          38 : bool OResultSet::fetchRow(sal_Int32 cardNumber,bool bForceReload) throw(SQLException, RuntimeException)
     363             : {
     364             :     OSL_TRACE("fetchRow, cardNumber = %u", cardNumber );
     365          38 :     if (!bForceReload)
     366             :     {
     367             :         // Check whether we've already fetched the row...
     368          38 :         if ( !(m_aRow->get())[0].isNull() && (sal_Int32)(m_aRow->get())[0] == (sal_Int32)cardNumber )
     369          10 :             return true;
     370             :         //Check whether the old row has been changed
     371          28 :         if (cardNumber == m_nUpdatedRow)
     372             :         {
     373             :             //write back the changes first
     374           0 :             if (!pushCard(cardNumber))  //error write back the changes
     375           0 :                 throw SQLException();
     376             :         }
     377             :     }
     378             : //    else
     379             : //        m_aQuery.resyncRow(cardNumber);
     380             : 
     381          28 :     if ( validRow( cardNumber ) == false )
     382           0 :         return false;
     383             : 
     384          28 :     (m_aRow->get())[0] = (sal_Int32)cardNumber;
     385          28 :     sal_Int32 nCount = m_aColumnNames.getLength();
     386             :     //m_RowStates = m_aQuery.getRowStates(cardNumber);
     387        1064 :     for( sal_Int32 i = 1; i <= nCount; i++ )
     388             :     {
     389        1036 :         if ( (m_aRow->get())[i].isBound() )
     390             :         {
     391             : 
     392             :             // Everything in the addressbook is a string!
     393             : 
     394          28 :             if ( !m_aQueryHelper.getRowValue( (m_aRow->get())[i], cardNumber, m_aColumnNames[i-1], DataType::VARCHAR ))
     395             :             {
     396           0 :                 m_pStatement->getOwnConnection()->throwSQLException( m_aQueryHelper.getError(), *this );
     397             :             }
     398             :         }
     399             :     }
     400          28 :     return true;
     401             : 
     402             : }
     403             : 
     404             : 
     405          28 : const ORowSetValue& OResultSet::getValue(sal_Int32 cardNumber, sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     406             : {
     407          28 :     if ( fetchRow( cardNumber ) == false )
     408             :     {
     409             :         OSL_FAIL("fetchRow() returned False" );
     410           0 :         m_bWasNull = true;
     411           0 :         return *ODatabaseMetaDataResultSet::getEmptyValue();
     412             :     }
     413             : 
     414          28 :     m_bWasNull = (m_aRow->get())[columnIndex].isNull();
     415          28 :     return (m_aRow->get())[columnIndex];
     416             : 
     417             : }
     418             : 
     419             : 
     420             : 
     421           8 : OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     422             : {
     423           8 :     ResultSetEntryGuard aGuard( *this );
     424             : 
     425             :     OSL_ENSURE(m_xColumns.is(), "Need the Columns!!");
     426             :     OSL_ENSURE(columnIndex <= (sal_Int32)m_xColumns->get().size(), "Trying to access invalid columns number");
     427           8 :     checkIndex( columnIndex );
     428             : 
     429             :     // If this query was sorted then we should have a valid KeySet, so use it
     430           8 :     return getValue(getCurrentCardNumber(), mapColumn( columnIndex ) );
     431             : 
     432             : }
     433             : 
     434             : 
     435           0 : Time SAL_CALL OResultSet::getTime( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     436             : {
     437           0 :     ResultSetEntryGuard aGuard( *this );
     438           0 :     return Time();
     439             : }
     440             : 
     441             : 
     442             : 
     443           0 : DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     444             : {
     445           0 :     ResultSetEntryGuard aGuard( *this );
     446           0 :     return DateTime();
     447             : }
     448             : 
     449             : 
     450           0 : sal_Bool SAL_CALL OResultSet::isBeforeFirst(  ) throw(SQLException, RuntimeException, std::exception)
     451             : {
     452           0 :     ResultSetEntryGuard aGuard( *this );
     453             : 
     454             :     // here you have to implement your movements
     455             :     // return true means there is no data
     456             :     OSL_TRACE("In/Out: OResultSet::isBeforeFirst" );
     457           0 :     return( m_nRowPos < 1 );
     458             : }
     459             : 
     460           0 : sal_Bool SAL_CALL OResultSet::isAfterLast(  ) throw(SQLException, RuntimeException, std::exception)
     461             : {
     462             :     SAL_WARN("connectivity.mork", "OResultSet::isAfterLast() NOT IMPLEMENTED!");
     463           0 :     ResultSetEntryGuard aGuard( *this );
     464             : 
     465             :     OSL_TRACE("In/Out: OResultSet::isAfterLast" );
     466             : //    return sal_True;
     467           0 :     return m_nRowPos > currentRowCount() && m_aQueryHelper.queryComplete();
     468             : }
     469             : 
     470           0 : sal_Bool SAL_CALL OResultSet::isFirst(  ) throw(SQLException, RuntimeException, std::exception)
     471             : {
     472           0 :     ResultSetEntryGuard aGuard( *this );
     473             : 
     474             :     OSL_TRACE("In/Out: OResultSet::isFirst" );
     475           0 :     return m_nRowPos == 1;
     476             : }
     477             : 
     478           0 : sal_Bool SAL_CALL OResultSet::isLast(  ) throw(SQLException, RuntimeException, std::exception)
     479             : {
     480             :     SAL_WARN("connectivity.mork", "OResultSet::isLast() NOT IMPLEMENTED!");
     481           0 :     ResultSetEntryGuard aGuard( *this );
     482             : 
     483             :     OSL_TRACE("In/Out: OResultSet::isLast" );
     484             : //    return sal_True;
     485           0 :     return m_nRowPos == currentRowCount() && m_aQueryHelper.queryComplete();
     486             : }
     487             : 
     488           2 : void SAL_CALL OResultSet::beforeFirst(  ) throw(SQLException, RuntimeException, std::exception)
     489             : {
     490           2 :     ResultSetEntryGuard aGuard( *this );
     491             : 
     492             :     // move before the first row so that isBeforeFirst returns false
     493             :     OSL_TRACE("In/Out: OResultSet::beforeFirst" );
     494           2 :     if ( first() )
     495           2 :         previous();
     496           2 : }
     497             : 
     498           0 : void SAL_CALL OResultSet::afterLast(  ) throw(SQLException, RuntimeException, std::exception)
     499             : {
     500           0 :     ResultSetEntryGuard aGuard( *this );
     501             :     OSL_TRACE("In/Out: OResultSet::afterLast" );
     502             : 
     503           0 :     if(last())
     504           0 :         next();
     505           0 : }
     506             : 
     507             : 
     508           4 : void SAL_CALL OResultSet::close() throw(SQLException, RuntimeException, std::exception)
     509             : {
     510             :     OSL_TRACE("In/Out: OResultSet::close" );
     511           4 :     dispose();
     512           4 : }
     513             : 
     514             : 
     515           6 : sal_Bool SAL_CALL OResultSet::first(  ) throw(SQLException, RuntimeException, std::exception)
     516             : {
     517             :     OSL_TRACE("In/Out: OResultSet::first" );
     518           6 :     return seekRow( FIRST_POS );
     519             : }
     520             : 
     521             : 
     522           2 : sal_Bool SAL_CALL OResultSet::last(  ) throw(SQLException, RuntimeException, std::exception)
     523             : {
     524             :     OSL_TRACE("In/Out: OResultSet::last" );
     525           2 :     return seekRow( LAST_POS );
     526             : }
     527             : 
     528           0 : sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException, std::exception)
     529             : {
     530             :     OSL_TRACE("In/Out: OResultSet::absolute" );
     531           0 :     return seekRow( ABSOLUTE_POS, row );
     532             : }
     533             : 
     534           0 : sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException, std::exception)
     535             : {
     536             :     OSL_TRACE("In/Out: OResultSet::relative" );
     537           0 :     return seekRow( RELATIVE_POS, row );
     538             : }
     539             : 
     540           2 : sal_Bool SAL_CALL OResultSet::previous(  ) throw(SQLException, RuntimeException, std::exception)
     541             : {
     542           2 :     ResultSetEntryGuard aGuard( *this );
     543             :     OSL_TRACE("In/Out: OResultSet::previous" );
     544           2 :     return seekRow( PRIOR_POS );
     545             : }
     546             : 
     547           0 : Reference< XInterface > SAL_CALL OResultSet::getStatement(  ) throw(SQLException, RuntimeException, std::exception)
     548             : {
     549           0 :     ResultSetEntryGuard aGuard( *this );
     550             : 
     551             :     OSL_TRACE("In/Out: OResultSet::getStatement" );
     552           0 :     return m_xStatement;
     553             : }
     554             : 
     555             : 
     556           0 : sal_Bool SAL_CALL OResultSet::rowDeleted(  ) throw(SQLException, RuntimeException, std::exception)
     557             : {
     558             :     SAL_WARN("connectivity.mork", "OResultSet::rowDeleted() NOT IMPLEMENTED!");
     559           0 :     ResultSetEntryGuard aGuard( *this );
     560             :     OSL_TRACE("In/Out: OResultSet::rowDeleted, m_RowStates=%u",m_RowStates );
     561           0 :     return sal_True;//return ((m_RowStates & RowStates_Deleted) == RowStates_Deleted) ;
     562             : }
     563             : 
     564           0 : sal_Bool SAL_CALL OResultSet::rowInserted(  ) throw(SQLException, RuntimeException, std::exception)
     565             : {
     566             :     SAL_WARN("connectivity.mork", "OResultSet::rowInserted() NOT IMPLEMENTED!");
     567           0 :     ResultSetEntryGuard aGuard( *this );
     568             :     OSL_TRACE("In/Out: OResultSet::rowInserted,m_RowStates=%u",m_RowStates );
     569           0 :     return sal_True;//return ((m_RowStates & RowStates_Inserted) == RowStates_Inserted);
     570             : }
     571             : 
     572           0 : sal_Bool SAL_CALL OResultSet::rowUpdated(  ) throw(SQLException, RuntimeException, std::exception)
     573             : {
     574             :     SAL_WARN("connectivity.mork", "OResultSet::rowUpdated() NOT IMPLEMENTED!");
     575           0 :     ResultSetEntryGuard aGuard( *this );
     576             :     OSL_TRACE("In/Out: OResultSet::rowUpdated,m_RowStates=%u",m_RowStates );
     577           0 :     return sal_True;// return ((m_RowStates & RowStates_Updated) == RowStates_Updated) ;
     578             : }
     579             : 
     580             : 
     581           2 : sal_Bool SAL_CALL OResultSet::next(  ) throw(SQLException, RuntimeException, std::exception)
     582             : {
     583           2 :     return seekRow( NEXT_POS );
     584             : }
     585             : 
     586             : 
     587           0 : sal_Bool SAL_CALL OResultSet::wasNull(  ) throw(SQLException, RuntimeException, std::exception)
     588             : {
     589           0 :     ResultSetEntryGuard aGuard( *this );
     590             : 
     591           0 :     return m_bWasNull;
     592             : }
     593             : 
     594             : 
     595           0 : void SAL_CALL OResultSet::cancel(  ) throw(RuntimeException, std::exception)
     596             : {
     597           0 :     ResultSetEntryGuard aGuard( *this );
     598           0 :     OSL_TRACE("In/Out: OResultSet::cancel" );
     599             : 
     600           0 : }
     601             : 
     602           0 : void SAL_CALL OResultSet::clearWarnings(  ) throw(SQLException, RuntimeException, std::exception)
     603             : {
     604             :     OSL_TRACE("In/Out: OResultSet::clearWarnings" );
     605           0 : }
     606             : 
     607           0 : Any SAL_CALL OResultSet::getWarnings(  ) throw(SQLException, RuntimeException, std::exception)
     608             : {
     609             :     OSL_TRACE("In/Out: OResultSet::getWarnings" );
     610           0 :     return Any();
     611             : }
     612             : 
     613           0 : void SAL_CALL OResultSet::refreshRow(  ) throw(SQLException, RuntimeException, std::exception)
     614             : {
     615             :     OSL_TRACE("In/Out: OResultSet::refreshRow" );
     616           0 :     if (fetchRow(getCurrentCardNumber(),true)) {
     617             :         //force fetch current row will cause we lose all change to the current row
     618           0 :         m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_REFRESH_ROW, *this );
     619             :     }
     620           0 : }
     621             : 
     622           0 : IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
     623             : {
     624           0 :     Sequence< Property > aProps(5);
     625           0 :     Property* pProperties = aProps.getArray();
     626           0 :     sal_Int32 nPos = 0;
     627           0 :     pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION),
     628           0 :         PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0);
     629             : 
     630           0 :     pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE),
     631           0 :         PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0);
     632             : 
     633           0 :     pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE),
     634           0 :         PROPERTY_ID_ISBOOKMARKABLE, ::getBooleanCppuType(), PropertyAttribute::READONLY);
     635             : 
     636           0 :     pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY),
     637           0 :         PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::READONLY);
     638             : 
     639           0 :     pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE),
     640           0 :         PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::READONLY);
     641             : 
     642           0 :     return new OPropertyArrayHelper(aProps);
     643             : }
     644             : 
     645           0 : IPropertyArrayHelper & OResultSet::getInfoHelper()
     646             : {
     647           0 :     return *const_cast<OResultSet*>(this)->getArrayHelper();
     648             : }
     649             : 
     650           0 : sal_Bool OResultSet::convertFastPropertyValue(
     651             :                             Any & /*rConvertedValue*/,
     652             :                             Any & /*rOldValue*/,
     653             :                             sal_Int32 nHandle,
     654             :                             const Any& /*rValue*/ )
     655             :                                 throw (::com::sun::star::lang::IllegalArgumentException)
     656             : {
     657             :     OSL_FAIL( "OResultSet::convertFastPropertyValue: not implemented!" );
     658           0 :     switch(nHandle)
     659             :     {
     660             :         case PROPERTY_ID_ISBOOKMARKABLE:
     661             :         case PROPERTY_ID_RESULTSETCONCURRENCY:
     662             :         case PROPERTY_ID_RESULTSETTYPE:
     663           0 :             throw ::com::sun::star::lang::IllegalArgumentException();
     664             :         case PROPERTY_ID_FETCHDIRECTION:
     665             :         case PROPERTY_ID_FETCHSIZE:
     666             :         default:
     667             :             ;
     668             :     }
     669           0 :     return sal_False;
     670             : }
     671             : 
     672           0 : void OResultSet::setFastPropertyValue_NoBroadcast(
     673             :                                 sal_Int32 nHandle,
     674             :                                 const Any& /*rValue*/
     675             :                                                  )
     676             :                                                  throw (Exception, std::exception)
     677             : {
     678             :     OSL_FAIL( "OResultSet::setFastPropertyValue_NoBroadcast: not implemented!" );
     679           0 :     switch(nHandle)
     680             :     {
     681             :         case PROPERTY_ID_ISBOOKMARKABLE:
     682             :         case PROPERTY_ID_RESULTSETCONCURRENCY:
     683             :         case PROPERTY_ID_RESULTSETTYPE:
     684           0 :             throw Exception();
     685             :         case PROPERTY_ID_FETCHDIRECTION:
     686           0 :             break;
     687             :         case PROPERTY_ID_FETCHSIZE:
     688           0 :             break;
     689             :         default:
     690             :             ;
     691             :     }
     692           0 : }
     693             : 
     694           0 : void OResultSet::getFastPropertyValue(
     695             :                                 Any& rValue,
     696             :                                 sal_Int32 nHandle
     697             :                                      ) const
     698             : {
     699           0 :     switch(nHandle)
     700             :     {
     701             :         case PROPERTY_ID_RESULTSETCONCURRENCY:
     702           0 :             rValue <<= (sal_Int32)m_nResultSetConcurrency;
     703           0 :             break;
     704             :         case PROPERTY_ID_RESULTSETTYPE:
     705           0 :             rValue <<= m_nResultSetType;
     706           0 :             break;
     707             :         case PROPERTY_ID_FETCHDIRECTION:
     708           0 :             rValue <<= m_nFetchDirection;
     709           0 :             break;
     710             :         case PROPERTY_ID_FETCHSIZE:
     711           0 :             rValue <<= m_nFetchSize;
     712           0 :             break;
     713             :         case PROPERTY_ID_ISBOOKMARKABLE:
     714           0 :             const_cast< OResultSet* >( this )->determineReadOnly();
     715           0 :             rValue <<= !m_bIsReadOnly;
     716           0 :          break;
     717             :     }
     718           0 : }
     719             : 
     720          72 : void SAL_CALL OResultSet::acquire() throw()
     721             : {
     722          72 :     OResultSet_BASE::acquire();
     723          72 : }
     724             : 
     725          72 : void SAL_CALL OResultSet::release() throw()
     726             : {
     727          72 :     OResultSet_BASE::release();
     728          72 : }
     729             : 
     730           0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     731             : {
     732           0 :     return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
     733             : }
     734             : 
     735             : 
     736           0 : void OResultSet::parseParameter( const OSQLParseNode* pNode, OUString& rMatchString )
     737             : {
     738             :     OSL_ENSURE(pNode->count() > 0,"Error parsing parameter in Parse Tree");
     739           0 :     OSQLParseNode *pMark = pNode->getChild(0);
     740             : 
     741             :     // Initialize to empty string
     742           0 :     rMatchString = "";
     743             : 
     744           0 :     OUString aParameterName;
     745           0 :     if (SQL_ISPUNCTUATION(pMark,"?")) {
     746           0 :         aParameterName = "?";
     747             :     }
     748           0 :     else if (SQL_ISPUNCTUATION(pMark,":")) {
     749           0 :         aParameterName = pNode->getChild(1)->getTokenValue();
     750             :     }
     751             :     // XXX - Now we know name, what's value????
     752           0 :     m_nParamIndex ++;
     753             :     OSL_TRACE("Parameter name [%d]: %s", m_nParamIndex,OUtoCStr(aParameterName) );
     754             : 
     755           0 :     if ( m_aParameterRow.is() ) {
     756             :         OSL_ENSURE( m_nParamIndex < (sal_Int32)m_aParameterRow->get().size() + 1, "More parameters than values found" );
     757           0 :         rMatchString = (m_aParameterRow->get())[(sal_uInt16)m_nParamIndex];
     758             : #if OSL_DEBUG_LEVEL > 0
     759             :         OSL_TRACE("Prop Value       : %s", OUtoCStr( rMatchString ) );
     760             : #endif
     761           0 :     }
     762             : #if OSL_DEBUG_LEVEL > 0
     763             :     else {
     764             :         OSL_TRACE("Prop Value       : Invalid ParameterRow!" );
     765             :     }
     766             : #endif
     767           0 : }
     768             : 
     769             : #define WILDCARD "%"
     770             : #define ALT_WILDCARD "*"
     771             : static const sal_Unicode MATCHCHAR = '_';
     772             : 
     773           4 : void OResultSet::analyseWhereClause( const OSQLParseNode*                 parseTree,
     774             :                                      MQueryExpression                     &queryExpression)
     775             : {
     776           4 :     OUString         columnName;
     777           4 :     MQueryOp::cond_type     op( MQueryOp::Is );
     778           8 :     OUString         matchString;
     779             : 
     780           4 :     if ( parseTree == NULL )
     781           4 :         return;
     782             : 
     783           4 :     if ( m_pSQLIterator->getParseTree() != NULL ) {
     784           4 :         ::rtl::Reference<OSQLColumns> xColumns = m_pSQLIterator->getParameters();
     785           4 :         if(xColumns.is())
     786             :         {
     787           8 :             OUString aColName, aParameterValue;
     788           4 :             OSQLColumns::Vector::iterator aIter = xColumns->get().begin();
     789           4 :             sal_Int32 i = 1;
     790           4 :             for(;aIter != xColumns->get().end();++aIter)
     791             :             {
     792           0 :                 (*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName;
     793             :                 OSL_TRACE("Prop Column Name : %s", OUtoCStr( aColName ) );
     794           0 :                 if ( m_aParameterRow.is() ) {
     795           0 :                     aParameterValue = (m_aParameterRow->get())[(sal_uInt16)i];
     796             : #if OSL_DEBUG_LEVEL > 0
     797             :                     OSL_TRACE("Prop Value       : %s", OUtoCStr( aParameterValue ) );
     798             : #endif
     799             :                 }
     800             : #if OSL_DEBUG_LEVEL > 0
     801             :                 else {
     802             :                     OSL_TRACE("Prop Value       : Invalid ParameterRow!" );
     803             :                 }
     804             : #endif
     805           0 :                 i++;
     806           4 :             }
     807           4 :         }
     808             : 
     809             :     }
     810             : 
     811           4 :     if ( SQL_ISRULE(parseTree,where_clause) )
     812             :     {
     813             :         OSL_TRACE("analyseSQL : Got WHERE clause");
     814             :         // Reset Parameter Counter
     815           2 :         resetParameters();
     816           2 :         analyseWhereClause( parseTree->getChild( 1 ), queryExpression );
     817             :     }
     818           4 :     else if ( parseTree->count() == 3 &&                         // Handle ()'s
     819           2 :         SQL_ISPUNCTUATION(parseTree->getChild(0),"(") &&
     820           0 :         SQL_ISPUNCTUATION(parseTree->getChild(2),")"))
     821             :     {
     822             : 
     823             :         OSL_TRACE("analyseSQL : Got Punctuation ()");
     824           0 :         MQueryExpression *subExpression = new MQueryExpression();
     825           0 :         analyseWhereClause( parseTree->getChild( 1 ), *subExpression );
     826           0 :         queryExpression.addExpression( subExpression );
     827             :     }
     828           6 :     else if ((SQL_ISRULE(parseTree,search_condition) || (SQL_ISRULE(parseTree,boolean_term)))
     829           2 :              && parseTree->count() == 3)                   // Handle AND/OR
     830             :     {
     831             : 
     832             :         OSL_TRACE("analyseSQL : Got AND/OR clause");
     833             : 
     834             :         // TODO - Need to take care or AND, for now match is always OR
     835           0 :         analyseWhereClause( parseTree->getChild( 0 ), queryExpression );
     836           0 :         analyseWhereClause( parseTree->getChild( 2 ), queryExpression );
     837             : 
     838           0 :         if (SQL_ISTOKEN(parseTree->getChild(1),OR)) {         // OR-Operator
     839           0 :             queryExpression.setExpressionCondition( MQueryExpression::OR );
     840             :         }
     841           0 :         else if (SQL_ISTOKEN(parseTree->getChild(1),AND)) {  // AND-Operator
     842           0 :             queryExpression.setExpressionCondition( MQueryExpression::AND );
     843             :         }
     844             :         else {
     845             :             OSL_FAIL("analyseSQL: Error in Parse Tree");
     846             :         }
     847             :     }
     848           2 :     else if (SQL_ISRULE(parseTree,comparison_predicate))
     849             :     {
     850             :         OSL_ENSURE(parseTree->count() == 3, "Error parsing COMPARE predicate");
     851           0 :         if (!(SQL_ISRULE(parseTree->getChild(0),column_ref) ||
     852           0 :           parseTree->getChild(2)->getNodeType() == SQL_NODE_STRING ||
     853           0 :           parseTree->getChild(2)->getNodeType() == SQL_NODE_INTNUM ||
     854           0 :           parseTree->getChild(2)->getNodeType() == SQL_NODE_APPROXNUM ||
     855           0 :           SQL_ISTOKEN(parseTree->getChild(2),TRUE) ||
     856           0 :           SQL_ISTOKEN(parseTree->getChild(2),FALSE) ||
     857           0 :           SQL_ISRULE(parseTree->getChild(2),parameter) ||
     858             :           // odbc date
     859           0 :           (SQL_ISRULE(parseTree->getChild(2),set_fct_spec) && SQL_ISPUNCTUATION(parseTree->getChild(2)->getChild(0),"{"))))
     860             :         {
     861           0 :             m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this );
     862             :         }
     863             : 
     864           0 :         OSQLParseNode *pPrec = parseTree->getChild(1);
     865           0 :         if (pPrec->getNodeType() == SQL_NODE_EQUAL)
     866           0 :             op = MQueryOp::Is;
     867           0 :         else if (pPrec->getNodeType() == SQL_NODE_NOTEQUAL)
     868           0 :             op = MQueryOp::IsNot;
     869             : 
     870           0 :         OUString sTableRange;
     871           0 :         if(SQL_ISRULE(parseTree->getChild(0),column_ref))
     872           0 :             m_pSQLIterator->getColumnRange(parseTree->getChild(0),columnName,sTableRange);
     873           0 :         else if(parseTree->getChild(0)->isToken())
     874           0 :             columnName = parseTree->getChild(0)->getTokenValue();
     875             : 
     876           0 :         if ( SQL_ISRULE(parseTree->getChild(2),parameter) ) {
     877           0 :             parseParameter( parseTree->getChild(2), matchString );
     878             :         }
     879             :         else {
     880           0 :             matchString = parseTree->getChild(2)->getTokenValue();
     881             :         }
     882             : 
     883           0 :         if ( columnName.equalsAscii("0") && op == MQueryOp::Is &&
     884           0 :              matchString.equalsAscii("1") ) {
     885             :             OSL_TRACE("Query always evaluates to FALSE");
     886           0 :             m_bIsAlwaysFalseQuery = true;
     887             :         }
     888           0 :         queryExpression.addExpression( new MQueryExpressionString( columnName, op, matchString ));
     889             :     }
     890           2 :     else if (SQL_ISRULE(parseTree,like_predicate))
     891             :     {
     892             :         OSL_ENSURE(parseTree->count() == 2, "Error parsing LIKE predicate");
     893             : 
     894             :         OSL_TRACE("analyseSQL : Got LIKE rule");
     895             : 
     896           2 :         if ( !(SQL_ISRULE(parseTree->getChild(0), column_ref)) )
     897             :         {
     898           0 :             m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_LIKE_COLUMN, *this );
     899             :         }
     900             : 
     901             : 
     902             :         OSQLParseNode *pColumn;
     903             :         OSQLParseNode *pAtom;
     904             :         OSQLParseNode *pOptEscape;
     905           2 :         const OSQLParseNode* pPart2 = parseTree->getChild(1);
     906           2 :         pColumn     = parseTree->getChild(0);                        // Match Item
     907           2 :         pAtom       = pPart2->getChild(static_cast<sal_uInt32>(pPart2->count()-2));     // Match String
     908           2 :         pOptEscape  = pPart2->getChild(static_cast<sal_uInt32>(pPart2->count()-1));     // Opt Escape Rule
     909             :         (void)pOptEscape;
     910           2 :         const bool bNot = SQL_ISTOKEN(pPart2->getChild(0), NOT);
     911             : 
     912           4 :         if (!(pAtom->getNodeType() == SQL_NODE_STRING ||
     913           0 :               pAtom->getNodeType() == SQL_NODE_NAME ||
     914           0 :               SQL_ISRULE(pAtom,parameter) ||
     915           0 :               ( pAtom->getChild(0) && pAtom->getChild(0)->getNodeType() == SQL_NODE_NAME ) ||
     916           0 :               ( pAtom->getChild(0) && pAtom->getChild(0)->getNodeType() == SQL_NODE_STRING )
     917           2 :               ) )
     918             :         {
     919             :             OSL_TRACE("analyseSQL : pAtom->count() = %zu", pAtom->count() );
     920             : 
     921           0 :             m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_LIKE_STRING, *this );
     922             :         }
     923             : 
     924           2 :         OUString sTableRange;
     925           2 :         if(SQL_ISRULE(pColumn,column_ref))
     926           2 :             m_pSQLIterator->getColumnRange(pColumn,columnName,sTableRange);
     927             : 
     928             :         OSL_TRACE("ColumnName = %s", OUtoCStr( columnName ) );
     929             : 
     930           2 :         if ( SQL_ISRULE(pAtom,parameter) ) {
     931           0 :             parseParameter( pAtom, matchString );
     932             :             // Replace all '*' with '%' : UI Usually does this but not with
     933             :             // Parameters for some reason.
     934           0 :             matchString = matchString.replaceAll( ALT_WILDCARD, WILDCARD );
     935             :         }
     936             :         else
     937             :         {
     938           2 :             matchString = pAtom->getTokenValue();
     939             :         }
     940             : 
     941             :         // Determine where '%' character is...
     942             : 
     943           2 :         if ( matchString == WILDCARD )
     944             :         {
     945             :             // String containing only a '%' and nothing else
     946           0 :             op = MQueryOp::Exists;
     947             :             // Will be ignored for Exists case, but clear anyway.
     948           0 :             matchString = "";
     949             :         }
     950           2 :         else if ( matchString.indexOf ( WILDCARD ) == -1 &&
     951           0 :              matchString.indexOf ( MATCHCHAR ) == -1 )
     952             :         {
     953             :             // Simple string , eg. "to match"
     954           0 :             if ( bNot )
     955           0 :                 op = MQueryOp::DoesNotContain;
     956             :             else
     957           0 :                 op = MQueryOp::Contains;
     958             :         }
     959           4 :         else if (  matchString.startsWith( WILDCARD )
     960           2 :                    && matchString.endsWith( WILDCARD )
     961           0 :                    && matchString.indexOf ( WILDCARD, 1 ) == matchString.lastIndexOf ( WILDCARD )
     962           2 :                    && matchString.indexOf( MATCHCHAR ) == -1
     963             :                  )
     964             :         {
     965             :             // Relatively simple "%string%" - ie, contains...
     966             :             // Cut '%'  from front and rear
     967           0 :             matchString = matchString.replaceAt( 0, 1, OUString() );
     968           0 :             matchString = matchString.replaceAt( matchString.getLength() -1 , 1, OUString() );
     969             : 
     970           0 :             if (bNot)
     971           0 :                 op = MQueryOp::DoesNotContain;
     972             :             else
     973           0 :                 op = MQueryOp::Contains;
     974             :         }
     975           2 :         else if ( bNot )
     976             :         {
     977             :             // We currently can't handle a 'NOT LIKE' when there are '%' or
     978             :             // '_' dispersed throughout
     979           0 :             m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_NOT_LIKE_TOO_COMPLEX, *this );
     980             :         }
     981             :         else
     982             :         {
     983           4 :             if ( (matchString.indexOf ( WILDCARD ) == matchString.lastIndexOf ( WILDCARD ))
     984           2 :                   && matchString.indexOf( MATCHCHAR ) == -1
     985             :                 )
     986             :             {
     987             :                 // One occurrence of '%' - no '_' matches...
     988           2 :                 if ( matchString.startsWith( WILDCARD ) )
     989             :                 {
     990           2 :                     op = MQueryOp::EndsWith;
     991           2 :                     matchString = matchString.replaceAt( 0, 1, OUString());
     992             :                 }
     993           0 :                 else if ( matchString.indexOf ( WILDCARD ) == matchString.getLength() -1 )
     994             :                 {
     995           0 :                     op = MQueryOp::BeginsWith;
     996           0 :                     matchString = matchString.replaceAt( matchString.getLength() -1 , 1, OUString() );
     997             :                 }
     998             :                 else
     999             :                 {
    1000           0 :                     sal_Int32 pos = matchString.indexOf ( WILDCARD );
    1001           0 :                     matchString = matchString.replaceAt( pos, 1, ".*" );
    1002           0 :                     op = MQueryOp::RegExp;
    1003             :                 }
    1004             : 
    1005             :             }
    1006             :             else
    1007             :             {
    1008             :                 // Most Complex, need to use an RE
    1009             :                 sal_Int32 pos;
    1010           0 :                 while ( (pos = matchString.indexOf ( WILDCARD )) != -1 )
    1011             :                 {
    1012           0 :                     matchString = matchString.replaceAt( pos, 1, OUString(".*") );
    1013             :                 }
    1014             : 
    1015           0 :                 while ( (pos = matchString.indexOf( MATCHCHAR )) != -1 )
    1016             :                 {
    1017           0 :                     matchString = matchString.replaceAt( pos, 1, OUString(".") );
    1018             :                 }
    1019             : 
    1020           0 :                 op = MQueryOp::RegExp;
    1021             :             }
    1022             :         }
    1023             : 
    1024           2 :         queryExpression.addExpression( new MQueryExpressionString( columnName, op, matchString ));
    1025             :     }
    1026           0 :     else if (SQL_ISRULE(parseTree,test_for_null))
    1027             :     {
    1028             :         OSL_ENSURE(parseTree->count() == 2,"Error in ParseTree");
    1029           0 :         const OSQLParseNode* pPart2 = parseTree->getChild(1);
    1030             :         OSL_ENSURE(SQL_ISTOKEN(pPart2->getChild(0),IS),"Error in ParseTree");
    1031             : 
    1032           0 :         if (!SQL_ISRULE(parseTree->getChild(0),column_ref))
    1033             :         {
    1034           0 :             m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_IS_NULL_COLUMN, *this );
    1035             :         }
    1036             : 
    1037           0 :         if (SQL_ISTOKEN(pPart2->getChild(1),NOT))
    1038             :         {
    1039           0 :             op = MQueryOp::Exists;
    1040             :         }
    1041             :         else
    1042             :         {
    1043           0 :             op = MQueryOp::DoesNotExist;
    1044             :         }
    1045             : 
    1046           0 :         OUString sTableRange;
    1047           0 :         m_pSQLIterator->getColumnRange(parseTree->getChild(0),columnName,sTableRange);
    1048             : 
    1049           0 :         queryExpression.addExpression( new MQueryExpressionString( columnName, op ));
    1050             :     }
    1051             :     else
    1052             :     {
    1053             :         OSL_TRACE( "Unexpected statement!!!" );
    1054             : 
    1055           0 :         m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this );
    1056           4 :     }
    1057             : }
    1058             : 
    1059             : 
    1060             : 
    1061           4 : void OResultSet::fillRowData()
    1062             :     throw (css::sdbc::SQLException, css::uno::RuntimeException)
    1063             : {
    1064             :     OSL_ENSURE( m_pStatement, "Require a statement" );
    1065             : 
    1066           4 :     MQueryExpression queryExpression;
    1067             : 
    1068           4 :     OConnection* xConnection = static_cast<OConnection*>(m_pStatement->getConnection().get());
    1069           4 :     m_xColumns = m_pSQLIterator->getSelectColumns();
    1070             : 
    1071             :     OSL_ENSURE(m_xColumns.is(), "Need the Columns!!");
    1072             : 
    1073           4 :     OSQLColumns::Vector::const_iterator aIter = m_xColumns->get().begin();
    1074           8 :     const OUString sProprtyName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME);
    1075           8 :     OUString sName;
    1076           4 :     m_aAttributeStrings.clear();
    1077           4 :     m_aAttributeStrings.reserve(m_xColumns->get().size());
    1078           8 :     for (sal_Int32 i = 1; aIter != m_xColumns->get().end();++aIter, i++)
    1079             :     {
    1080           4 :         (*aIter)->getPropertyValue(sProprtyName) >>= sName;
    1081             : #if OSL_DEBUG_LEVEL > 0
    1082             :         OSL_TRACE("Query Columns : (%d) %s", i, OUtoCStr(sName) );
    1083             : #endif
    1084           4 :         m_aAttributeStrings.push_back( sName );
    1085             :     }
    1086             : 
    1087             :     // Generate Match Conditions for Query
    1088           4 :     const OSQLParseNode*  pParseTree = m_pSQLIterator->getWhereTree();
    1089             : 
    1090           4 :     m_bIsAlwaysFalseQuery = false;
    1091           4 :     if ( pParseTree != NULL )
    1092             :     {
    1093             :         // Extract required info
    1094             : 
    1095             :         OSL_TRACE("\tHave a Where Clause");
    1096             : 
    1097           2 :         analyseWhereClause( pParseTree, queryExpression );
    1098             :     }
    1099             :     // If the query is a 0=1 then set Row count to 0 and return
    1100           4 :     if ( m_bIsAlwaysFalseQuery )
    1101             :     {
    1102           0 :         m_bIsReadOnly = 1;
    1103           4 :         return;
    1104             :     }
    1105             : 
    1106           8 :     OUString aStr(  m_pTable->getName() );
    1107           4 :     m_aQueryHelper.setAddressbook( aStr );
    1108             : 
    1109           4 :     sal_Int32 rv = m_aQueryHelper.executeQuery(xConnection, queryExpression);
    1110           4 :     if ( rv == -1 ) {
    1111           0 :         m_pStatement->getOwnConnection()->throwSQLException( STR_ERR_EXECUTING_QUERY, *this );
    1112             :     }
    1113             : 
    1114           4 :     if (m_aQueryHelper.hadError())
    1115             :     {
    1116           0 :         m_pStatement->getOwnConnection()->throwSQLException( m_aQueryHelper.getError(), *this );
    1117             :     }
    1118             : 
    1119             :     //determine whether the address book is readonly
    1120           8 :     determineReadOnly();
    1121             : 
    1122             : #if OSL_DEBUG_LEVEL > 0
    1123             :     OSL_TRACE( "executeQuery returned %d", rv );
    1124             : 
    1125             :     OSL_TRACE( "\tOUT OResultSet::fillRowData()" );
    1126             : #endif
    1127             : }
    1128             : 
    1129             : 
    1130           0 : static bool matchRow( OValueRow& row1, OValueRow& row2 )
    1131             : {
    1132           0 :     OValueVector::Vector::iterator row1Iter = row1->get().begin();
    1133           0 :     OValueVector::Vector::iterator row2Iter = row2->get().begin();
    1134           0 :     for ( ++row1Iter,++row2Iter; // the first column is the bookmark column
    1135           0 :           row1Iter != row1->get().end(); ++row1Iter,++row2Iter)
    1136             :     {
    1137           0 :         if ( row1Iter->isBound())
    1138             :         {
    1139             :             // Compare values, if at anytime there's a mismatch return false
    1140           0 :             if ( !( (*row1Iter) == (*row2Iter) ) )
    1141           0 :                 return false;
    1142             :         }
    1143             :     }
    1144             : 
    1145             :     // If we get to here the rows match
    1146           0 :     return true;
    1147             : }
    1148             : 
    1149           0 : sal_Int32 OResultSet::getRowForCardNumber(sal_Int32 nCardNum)
    1150             : {
    1151             :     OSL_TRACE("In/Out: OResultSet::getRowForCardNumber, nCardNum = %u", nCardNum );
    1152             : 
    1153           0 :     if ( m_pKeySet.is() )
    1154             :     {
    1155             :         sal_Int32  nPos;
    1156           0 :         for(nPos=0;nPos < (sal_Int32)m_pKeySet->get().size();nPos++)
    1157             :         {
    1158           0 :             if (nCardNum == (m_pKeySet->get())[nPos])
    1159             :             {
    1160             :                 OSL_TRACE("In/Out: OResultSet::getRowForCardNumber, return = %u", nPos+1 );
    1161           0 :                 return nPos+1;
    1162             :             }
    1163             :         }
    1164             :     }
    1165             : 
    1166           0 :     m_pStatement->getOwnConnection()->throwSQLException( STR_INVALID_BOOKMARK, *this );
    1167             : 
    1168           0 :     return 0;
    1169             : }
    1170             : 
    1171             : 
    1172           4 : void SAL_CALL OResultSet::executeQuery() throw( ::com::sun::star::sdbc::SQLException,
    1173             :                                                 ::com::sun::star::uno::RuntimeException)
    1174             : {
    1175           4 :     ResultSetEntryGuard aGuard( *this );
    1176             : 
    1177             :     OSL_ENSURE( m_pTable, "Need a Table object");
    1178           4 :     if(!m_pTable)
    1179             :     {
    1180           0 :         const OSQLTables& xTabs = m_pSQLIterator->getTables();
    1181           0 :         if ((xTabs.begin() == xTabs.end()) || !xTabs.begin()->second.is())
    1182           0 :             m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this );
    1183             : 
    1184           0 :         m_pTable = static_cast< OTable* > ((xTabs.begin()->second).get());
    1185             : 
    1186             :     }
    1187             : 
    1188           4 :     m_nRowPos = 0;
    1189             : 
    1190           4 :     fillRowData();
    1191             : 
    1192             :     OSL_ENSURE(m_xColumns.is(), "Need the Columns!!");
    1193             : 
    1194           4 :     switch( m_pSQLIterator->getStatementType() )
    1195             :     {
    1196             :         case SQL_STATEMENT_SELECT:
    1197             :         {
    1198           4 :             if(m_bIsAlwaysFalseQuery) {
    1199           0 :                 break;
    1200             :             }
    1201           4 :             else if(isCount())
    1202             :             {
    1203           0 :                 m_pStatement->getOwnConnection()->throwSQLException( STR_NO_COUNT_SUPPORT, *this );
    1204             :             }
    1205             :             else
    1206             :             {
    1207           4 :                 bool bDistinct = false;
    1208           4 :                 OSQLParseNode *pDistinct = m_pParseTree->getChild(1);
    1209           4 :                 if (pDistinct && pDistinct->getTokenID() == SQL_TOKEN_DISTINCT)
    1210             :                 {
    1211           0 :                     if(!IsSorted())
    1212             :                     {
    1213           0 :                         m_aOrderbyColumnNumber.push_back(m_aColMapping[1]);
    1214           0 :                         m_aOrderbyAscending.push_back(SQL_DESC);
    1215             :                     }
    1216           0 :                     bDistinct = true;
    1217             :                 }
    1218             : 
    1219           4 :                 OSortIndex::TKeyTypeVector eKeyType(m_aOrderbyColumnNumber.size());
    1220           4 :                 ::std::vector<sal_Int32>::iterator aOrderByIter = m_aOrderbyColumnNumber.begin();
    1221           6 :                 for ( ::std::vector<sal_Int16>::size_type i = 0; aOrderByIter != m_aOrderbyColumnNumber.end(); ++aOrderByIter,++i)
    1222             :                 {
    1223             :                     OSL_ENSURE((sal_Int32)m_aRow->get().size() > *aOrderByIter,"Invalid Index");
    1224           2 :                     switch ((m_aRow->get().begin()+*aOrderByIter)->getTypeKind())
    1225             :                     {
    1226             :                     case DataType::CHAR:
    1227             :                         case DataType::VARCHAR:
    1228           2 :                             eKeyType[i] = SQL_ORDERBYKEY_STRING;
    1229           2 :                             break;
    1230             : 
    1231             :                         case DataType::OTHER:
    1232             :                         case DataType::TINYINT:
    1233             :                         case DataType::SMALLINT:
    1234             :                         case DataType::INTEGER:
    1235             :                         case DataType::DECIMAL:
    1236             :                         case DataType::NUMERIC:
    1237             :                         case DataType::REAL:
    1238             :                         case DataType::DOUBLE:
    1239             :                         case DataType::DATE:
    1240             :                         case DataType::TIME:
    1241             :                         case DataType::TIMESTAMP:
    1242             :                         case DataType::BIT:
    1243           0 :                             eKeyType[i] = SQL_ORDERBYKEY_DOUBLE;
    1244           0 :                             break;
    1245             : 
    1246             :                     // Other types aren't implemented (so they are always FALSE)
    1247             :                         default:
    1248           0 :                             eKeyType[i] = SQL_ORDERBYKEY_NONE;
    1249             :                             OSL_FAIL("MResultSet::executeQuery: Order By Data Type not implemented");
    1250           0 :                             break;
    1251             :                     }
    1252             :                 }
    1253             : 
    1254           4 :                 if (IsSorted())
    1255             :                 {
    1256             :                     // Implement Sorting
    1257             : 
    1258             :                     // So that we can sort we need to wait until the executed
    1259             :                     // query to the mozilla addressbooks has returned all
    1260             :                     // values.
    1261             : 
    1262             :                     OSL_TRACE("Query is to be sorted");
    1263             : 
    1264             :                     OSL_ENSURE( m_aQueryHelper.queryComplete(), "Query not complete!!");
    1265             : 
    1266           2 :                     OSortIndex aSortIndex(eKeyType,m_aOrderbyAscending);
    1267             : 
    1268             :                     OSL_TRACE("OrderbyColumnNumber->size() = %zu",m_aOrderbyColumnNumber.size());
    1269             : #if OSL_DEBUG_LEVEL > 0
    1270             :                     for ( ::std::vector<sal_Int32>::size_type i = 0; i < m_aColMapping.size(); i++ )
    1271             :                         OSL_TRACE("Mapped: %d -> %d", i, m_aColMapping[i] );
    1272             : #endif
    1273          22 :                     for ( sal_Int32 nRow = 1; nRow <= m_aQueryHelper.getResultCount(); nRow++ ) {
    1274             : 
    1275          20 :                         OKeyValue* pKeyValue = OKeyValue::createKeyValue((nRow));
    1276             : 
    1277          20 :                         ::std::vector<sal_Int32>::iterator aIter = m_aOrderbyColumnNumber.begin();
    1278          40 :                         for (;aIter != m_aOrderbyColumnNumber.end(); ++aIter)
    1279             :                         {
    1280          20 :                             const ORowSetValue& value = getValue(nRow, *aIter);
    1281             : 
    1282             :                             OSL_TRACE( "Adding Value: (%d,%d) : %s", nRow, *aIter,OUtoCStr( value ));
    1283             : 
    1284          20 :                             pKeyValue->pushKey(new ORowSetValueDecorator(value));
    1285             :                         }
    1286             : 
    1287          20 :                         aSortIndex.AddKeyValue( pKeyValue );
    1288             :                     }
    1289             : 
    1290           2 :                     m_pKeySet = aSortIndex.CreateKeySet();
    1291           2 :                     m_CurrentRowCount = static_cast<sal_Int32>(m_pKeySet->get().size());
    1292             : #if OSL_DEBUG_LEVEL > 0
    1293             :                     for( OKeySet::Vector::size_type i = 0; i < m_pKeySet->get().size(); i++ )
    1294             :                         OSL_TRACE("Sorted: %d -> %d", i, (m_pKeySet->get())[i] );
    1295             : #endif
    1296             : 
    1297           2 :                     beforeFirst(); // Go back to start
    1298             :                 }
    1299             :                 else  //we always need m_pKeySet now
    1300           2 :                     m_pKeySet = new OKeySet();
    1301             : 
    1302             :                 // Handle the DISTINCT case
    1303           4 :                 if ( bDistinct && m_pKeySet.is() )
    1304             :                 {
    1305           0 :                     OValueRow aSearchRow = new OValueVector( m_aRow->get().size() );
    1306             : 
    1307           0 :                     for( OKeySet::Vector::size_type i = 0; i < m_pKeySet->get().size(); i++ )
    1308             :                     {
    1309           0 :                         fetchRow( (m_pKeySet->get())[i] );        // Fills m_aRow
    1310           0 :                         if ( matchRow( m_aRow, aSearchRow ) )
    1311             :                         {
    1312           0 :                             (m_pKeySet->get())[i] = 0;   // Marker for later to be removed
    1313             :                         }
    1314             :                         else
    1315             :                         {
    1316             :                             // They don't match, so it's not a duplicate.
    1317             :                             // Use the current Row as the next one to match against
    1318           0 :                             *aSearchRow = *m_aRow;
    1319             :                         }
    1320             :                     }
    1321             :                     // Now remove any keys marked with a 0
    1322           0 :                     m_pKeySet->get().erase(::std::remove_if(m_pKeySet->get().begin(),m_pKeySet->get().end()
    1323           0 :                                     ,::std::bind2nd(::std::equal_to<sal_Int32>(),0))
    1324           0 :                                      ,m_pKeySet->get().end());
    1325             : 
    1326           4 :                 }
    1327             :             }
    1328           4 :         }   break;
    1329             : 
    1330             :         case SQL_STATEMENT_UPDATE:
    1331             :         case SQL_STATEMENT_DELETE:
    1332             :         case SQL_STATEMENT_INSERT:
    1333           0 :             break;
    1334             :         default:
    1335           0 :             m_pStatement->getOwnConnection()->throwSQLException( STR_STMT_TYPE_NOT_SUPPORTED, *this );
    1336           0 :             break;
    1337           4 :     }
    1338           4 : }
    1339             : 
    1340             : 
    1341             : 
    1342             : 
    1343           8 : void OResultSet::setBoundedColumns(const OValueRow& _rRow,
    1344             :                                    const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns,
    1345             :                                    const Reference<XIndexAccess>& _xNames,
    1346             :                                    bool _bSetColumnMapping,
    1347             :                                    const Reference<XDatabaseMetaData>& _xMetaData,
    1348             :                                    ::std::vector<sal_Int32>& _rColMapping)
    1349             : {
    1350           8 :     ::comphelper::UStringMixEqual aCase(_xMetaData->supportsMixedCaseQuotedIdentifiers());
    1351             : 
    1352           8 :     Reference<XPropertySet> xTableColumn;
    1353          16 :     OUString sTableColumnName, sSelectColumnRealName;
    1354             : 
    1355          16 :     const OUString sName     = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME);
    1356          16 :     const OUString sRealName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME);
    1357             : 
    1358          16 :     ::std::vector< OUString> aColumnNames;
    1359           8 :     aColumnNames.reserve(_rxColumns->get().size());
    1360           8 :     OValueVector::Vector::iterator aRowIter = _rRow->get().begin()+1;
    1361         912 :     for (sal_Int32 i=0; // the first column is the bookmark column
    1362         608 :          aRowIter != _rRow->get().end();
    1363             :             ++i, ++aRowIter
    1364             :         )
    1365             :     {
    1366             :         try
    1367             :         {
    1368             :             // get the table column and its name
    1369         296 :             _xNames->getByIndex(i) >>= xTableColumn;
    1370             :             OSL_ENSURE(xTableColumn.is(), "OResultSet::setBoundedColumns: invalid table column!");
    1371         296 :             if (xTableColumn.is())
    1372         296 :                 xTableColumn->getPropertyValue(sName) >>= sTableColumnName;
    1373             :             else
    1374           0 :                 sTableColumnName = "";
    1375             : 
    1376             :             // look if we have such a select column
    1377             :             // TODO: would like to have a O(log n) search here ...
    1378         296 :             sal_Int32 nColumnPos = 0;
    1379        1332 :             for (   OSQLColumns::Vector::iterator aIter = _rxColumns->get().begin();
    1380         888 :                     aIter != _rxColumns->get().end();
    1381             :                     ++aIter,++nColumnPos
    1382             :                 )
    1383             :             {
    1384         148 :                 if ( nColumnPos < (sal_Int32)aColumnNames.size() )
    1385         144 :                     sSelectColumnRealName = aColumnNames[nColumnPos];
    1386             :                 else
    1387             :                 {
    1388           4 :                     if((*aIter)->getPropertySetInfo()->hasPropertyByName(sRealName))
    1389           4 :                         (*aIter)->getPropertyValue(sRealName) >>= sSelectColumnRealName;
    1390             :                     else
    1391           0 :                         (*aIter)->getPropertyValue(sName) >>= sSelectColumnRealName;
    1392           4 :                     aColumnNames.push_back(sSelectColumnRealName);
    1393             :                 }
    1394             : 
    1395         148 :                 if (aCase(sTableColumnName, sSelectColumnRealName))
    1396             :                 {
    1397           4 :                     if(_bSetColumnMapping)
    1398             :                     {
    1399           4 :                         sal_Int32 nSelectColumnPos = static_cast<sal_Int32>(aIter - _rxColumns->get().begin() + 1);
    1400             :                             // the getXXX methods are 1-based ...
    1401           4 :                         sal_Int32 nTableColumnPos = i + 1;
    1402             :                             // get first table column is the bookmark column
    1403             : 
    1404             : #if OSL_DEBUG_LEVEL > 0
    1405             :                         OSL_TRACE("Set Col Mapping: %d -> %d", nSelectColumnPos, nTableColumnPos );
    1406             : #endif
    1407           4 :                         _rColMapping[nSelectColumnPos] = nTableColumnPos;
    1408             :                     }
    1409             : 
    1410           4 :                     aRowIter->setBound(true);
    1411           4 :                     aRowIter->setTypeKind(DataType::VARCHAR);
    1412             :                 }
    1413             :             }
    1414             :         }
    1415           0 :         catch (Exception&)
    1416             :         {
    1417             :             OSL_FAIL("OResultSet::setBoundedColumns: caught an Exception!");
    1418             :         }
    1419           8 :     }
    1420           8 : }
    1421             : 
    1422             : 
    1423             : 
    1424           4 : bool OResultSet::isCount() const
    1425             : {
    1426           4 :     return (m_pParseTree &&
    1427           8 :             m_pParseTree->count() > 2                                                       &&
    1428          12 :             SQL_ISRULE(m_pParseTree->getChild(2),scalar_exp_commalist)                      &&
    1429          12 :             SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0),derived_column)               &&
    1430          12 :             SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0)->getChild(0),general_set_fct) &&
    1431           0 :             m_pParseTree->getChild(2)->getChild(0)->getChild(0)->count() == 4
    1432           4 :             );
    1433             : }
    1434             : 
    1435             : 
    1436             : 
    1437             : // Check for valid row in m_aQuery
    1438             : 
    1439          28 : bool OResultSet::validRow( sal_uInt32 nRow)
    1440             : {
    1441          28 :     sal_Int32  nNumberOfRecords = m_aQueryHelper.getResultCount();
    1442             : 
    1443          56 :     while ( nRow > (sal_uInt32)nNumberOfRecords && !m_aQueryHelper.queryComplete() ) {
    1444             : #if OSL_DEBUG_LEVEL > 0
    1445             :             OSL_TRACE("validRow: waiting...");
    1446             : #endif
    1447           0 :             if (m_aQueryHelper.checkRowAvailable( nRow ) == false)
    1448             :             {
    1449             :                 OSL_TRACE("validRow(%u): return False", nRow);
    1450           0 :                 return false;
    1451             :             }
    1452             : 
    1453           0 :             if ( m_aQueryHelper.hadError() )
    1454             :             {
    1455           0 :                 m_pStatement->getOwnConnection()->throwSQLException( m_aQueryHelper.getError(), *this );
    1456             :             }
    1457             : 
    1458           0 :             nNumberOfRecords = m_aQueryHelper.getResultCount();
    1459             :     }
    1460             : 
    1461          56 :     if (( nRow == 0 ) ||
    1462          28 :         ( nRow > (sal_uInt32)nNumberOfRecords && m_aQueryHelper.queryComplete()) ){
    1463             :         OSL_TRACE("validRow(%u): return False", nRow);
    1464           0 :         return false;
    1465             :     }
    1466             : #if OSL_DEBUG_LEVEL > 0
    1467             :     OSL_TRACE("validRow(%u): return True", nRow);
    1468             : #endif
    1469             : 
    1470          28 :     return true;
    1471             : }
    1472          10 : bool OResultSet::fillKeySet(sal_Int32 nMaxCardNumber)
    1473             : {
    1474          10 :     impl_ensureKeySet();
    1475          10 :     if (m_CurrentRowCount < nMaxCardNumber)
    1476             :     {
    1477             :         sal_Int32   nKeyValue;
    1478           2 :         if ( (sal_Int32)m_pKeySet->get().capacity() < nMaxCardNumber )
    1479           2 :             m_pKeySet->get().reserve(nMaxCardNumber + 20 );
    1480             : 
    1481           4 :         for (nKeyValue = m_CurrentRowCount+1; nKeyValue  <= nMaxCardNumber; nKeyValue ++)
    1482           2 :             m_pKeySet->get().push_back( nKeyValue );
    1483           2 :         m_CurrentRowCount = nMaxCardNumber;
    1484             :     }
    1485          10 :     return true;
    1486             : }
    1487             : 
    1488           4 : sal_Int32 OResultSet::deletedCount()
    1489             : {
    1490           4 :     impl_ensureKeySet();
    1491           4 :     return m_CurrentRowCount - static_cast<sal_Int32>(m_pKeySet->get().size());
    1492             : 
    1493             : }
    1494             : 
    1495          12 : bool OResultSet::seekRow( eRowPosition pos, sal_Int32 nOffset )
    1496             : {
    1497          12 :     ResultSetEntryGuard aGuard( *this );
    1498          12 :     if ( !m_pKeySet.is() )
    1499           0 :         m_pStatement->getOwnConnection()->throwSQLException( STR_ILLEGAL_MOVEMENT, *this );
    1500             : 
    1501          12 :     sal_Int32  nNumberOfRecords = m_aQueryHelper.getResultCount();
    1502          12 :     sal_Int32  nRetrievedRows = currentRowCount();
    1503          12 :     sal_Int32  nCurPos = m_nRowPos;
    1504             : 
    1505             :     OSL_TRACE("seekRow: nCurPos = %d", nCurPos );
    1506          12 :     switch( pos ) {
    1507             :         case NEXT_POS:
    1508             :             OSL_TRACE("seekRow: NEXT");
    1509           2 :             nCurPos++;
    1510           2 :             break;
    1511             :         case PRIOR_POS:
    1512             :             OSL_TRACE("seekRow: PRIOR");
    1513           2 :             if ( nCurPos > 0 )
    1514           2 :                 nCurPos--;
    1515           2 :             break;
    1516             : 
    1517             :         case FIRST_POS:
    1518             :             OSL_TRACE("seekRow: FIRST");
    1519           6 :             nCurPos = 1;
    1520           6 :             break;
    1521             : 
    1522             :         case LAST_POS:
    1523             :             OSL_TRACE("seekRow: LAST");
    1524           2 :             nCurPos = nRetrievedRows;
    1525           2 :             break;
    1526             :         case ABSOLUTE_POS:
    1527             :             OSL_TRACE("seekRow: ABSOLUTE : %d", nOffset);
    1528           0 :             nCurPos = nOffset;
    1529           0 :             break;
    1530             :         case RELATIVE_POS:
    1531             :             OSL_TRACE("seekRow: RELATIVE : %d", nOffset);
    1532           0 :             nCurPos += sal_uInt32( nOffset );
    1533           0 :             break;
    1534             :     }
    1535             : 
    1536          12 :     if ( nCurPos <= 0 ) {
    1537           2 :         m_nRowPos = 0;
    1538             :         OSL_TRACE("seekRow: return False, m_nRowPos = %u", m_nRowPos );
    1539           2 :         return false;
    1540             :     }
    1541          10 :     sal_Int32 nCurCard = nCurPos;
    1542          10 :     if ( nCurPos < (sal_Int32)m_pKeySet->get().size() ) //The requested row is exist in m_pKeySet, so we just use it
    1543             :     {
    1544           6 :         nCurCard = (m_pKeySet->get())[nCurPos-1];
    1545             :     }
    1546             :     else    //The requested row has not been retrieved until now. We should get the right card for it.
    1547           4 :         nCurCard = nCurPos + deletedCount();
    1548             : 
    1549          10 :     if ( nCurCard > nNumberOfRecords) {
    1550           0 :         fillKeySet(nNumberOfRecords);
    1551           0 :         m_nRowPos = static_cast<sal_uInt32>(m_pKeySet->get().size() + 1);
    1552             :         OSL_TRACE("seekRow: return False, m_nRowPos = %u", m_nRowPos );
    1553           0 :         return false;
    1554             :     }
    1555             :     //Insert new retrieved items for later use
    1556          10 :     fillKeySet(nNumberOfRecords);
    1557          10 :     m_nRowPos = (sal_uInt32)nCurPos;
    1558             :     OSL_TRACE("seekRow: return True, m_nRowPos = %u", m_nRowPos );
    1559          10 :     fetchCurrentRow();
    1560          10 :     return true;
    1561             : }
    1562             : 
    1563           4 : void OResultSet::setColumnMapping(const ::std::vector<sal_Int32>& _aColumnMapping)
    1564             : {
    1565           4 :     m_aColMapping = _aColumnMapping;
    1566             : #if OSL_DEBUG_LEVEL > 0
    1567             :     for ( sal_uInt32 i = 0; i < m_aColMapping.size(); i++ )
    1568             :         OSL_TRACE("Set Mapped: %d -> %d", i, m_aColMapping[i] );
    1569             : #endif
    1570           4 : }
    1571             : 
    1572             : 
    1573           0 : ::com::sun::star::uno::Any OResultSet::getBookmark(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
    1574             : {
    1575             :     OSL_TRACE("getBookmark, m_nRowPos = %u", m_nRowPos );
    1576           0 :     ResultSetEntryGuard aGuard( *this );
    1577           0 :     if ( fetchCurrentRow() == false ) {
    1578           0 :         m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this );
    1579             :     }
    1580             : 
    1581             :     OSL_ENSURE((!m_aRow->isDeleted()),"getBookmark called for deleted row");
    1582           0 :     return makeAny((sal_Int32)(m_aRow->get())[0]);
    1583             : }
    1584           0 : sal_Bool  OResultSet::moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
    1585             : {
    1586           0 :     ResultSetEntryGuard aGuard( *this );
    1587             :     OSL_TRACE("moveToBookmark, bookmark = %u", comphelper::getINT32(bookmark) );
    1588           0 :     sal_Int32 nCardNum = comphelper::getINT32(bookmark);
    1589           0 :     m_nRowPos = getRowForCardNumber(nCardNum);
    1590           0 :     fetchCurrentRow();
    1591           0 :     return sal_True;
    1592             : }
    1593           0 : sal_Bool  OResultSet::moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
    1594             : {
    1595           0 :     ResultSetEntryGuard aGuard( *this );
    1596             :     OSL_TRACE("moveRelativeToBookmark, bookmark = %u rows= %u", comphelper::getINT32(bookmark),rows );
    1597           0 :     sal_Int32 nCardNum = comphelper::getINT32(bookmark);
    1598           0 :     m_nRowPos = getRowForCardNumber(nCardNum);
    1599           0 :     return seekRow(RELATIVE_POS,rows );
    1600             : }
    1601           0 : sal_Int32 OResultSet::compareBookmarks( const ::com::sun::star::uno::Any& lhs, const ::com::sun::star::uno::Any& rhs ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
    1602             : {
    1603           0 :     ResultSetEntryGuard aGuard( *this );
    1604             :     OSL_TRACE("compareBookmarks, m_nRowPos = %u", m_nRowPos );
    1605           0 :         sal_Int32 nFirst=0;
    1606           0 :         sal_Int32 nSecond=0;
    1607           0 :         sal_Int32 nResult=0;
    1608             : 
    1609           0 :         if ( !( lhs >>= nFirst ) || !( rhs >>= nSecond ) ) {
    1610           0 :             m_pStatement->getOwnConnection()->throwSQLException( STR_INVALID_BOOKMARK, *this );
    1611             :         }
    1612             : 
    1613           0 :     if(nFirst < nSecond)
    1614           0 :          nResult = -1;
    1615           0 :     else if(nFirst > nSecond)
    1616           0 :          nResult = 1;
    1617             :     else
    1618           0 :          nResult = 0;
    1619             : 
    1620           0 :     return  nResult;
    1621             : }
    1622           0 : sal_Bool OResultSet::hasOrderedBookmarks(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
    1623             : {
    1624           0 :     ResultSetEntryGuard aGuard( *this );
    1625             :     OSL_TRACE("hasOrderedBookmarks, m_nRowPos = %u", m_nRowPos );
    1626           0 :     return sal_True;
    1627             : }
    1628           0 : sal_Int32 OResultSet::hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
    1629             : {
    1630           0 :     ResultSetEntryGuard aGuard( *this );
    1631             :     OSL_TRACE("hashBookmark, m_nRowPos = %u", m_nRowPos );
    1632           0 :     return  comphelper::getINT32(bookmark);
    1633             : }
    1634             : 
    1635          18 : sal_Int32 OResultSet::getCurrentCardNumber()
    1636             : {
    1637          18 :     if ( ( m_nRowPos == 0 ) || !m_pKeySet.is() )
    1638           0 :         return 0;
    1639          18 :     if (m_pKeySet->get().size() < m_nRowPos)
    1640           0 :         return 0;
    1641          18 :     return (m_pKeySet->get())[m_nRowPos-1];
    1642             : }
    1643           0 : void OResultSet::checkPendingUpdate() throw(SQLException, RuntimeException)
    1644             : {
    1645             :     OSL_FAIL( "OResultSet::checkPendingUpdate() not implemented" );
    1646             : /*
    1647             :     OSL_TRACE("checkPendingUpdate, m_nRowPos = %u", m_nRowPos );
    1648             :     const sal_Int32 nCurrentRow = getCurrentCardNumber();
    1649             : 
    1650             :     if ((m_nNewRow && nCurrentRow != m_nNewRow)
    1651             :         || ( m_nUpdatedRow && m_nUpdatedRow != nCurrentRow))
    1652             :     {
    1653             :         const OUString sError( m_pStatement->getOwnConnection()->getResources().getResourceStringWithSubstitution(
    1654             :                 STR_COMMIT_ROW,
    1655             :                 "$position$", OUString::valueOf(nCurrentRow)
    1656             :              ) );
    1657             :         ::dbtools::throwGenericSQLException(sError,*this);
    1658             :     }
    1659             : */
    1660             : 
    1661           0 : }
    1662           0 : void OResultSet::updateValue(sal_Int32 columnIndex ,const ORowSetValue& x) throw(SQLException, RuntimeException)
    1663             : {
    1664             :     OSL_TRACE("updateValue, m_nRowPos = %u", m_nRowPos );
    1665           0 :     ResultSetEntryGuard aGuard( *this );
    1666           0 :     if ( fetchCurrentRow() == false ) {
    1667           0 :         m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this );
    1668             :     }
    1669             : 
    1670           0 :     checkPendingUpdate();
    1671             : 
    1672           0 :     checkIndex(columnIndex );
    1673           0 :     columnIndex = mapColumn(columnIndex);
    1674             : 
    1675           0 :     (m_aRow->get())[columnIndex].setBound(true);
    1676           0 :     (m_aRow->get())[columnIndex] = x;
    1677           0 :     m_nUpdatedRow = getCurrentCardNumber();
    1678             : //    m_RowStates = m_RowStates | RowStates_Updated;
    1679           0 : }
    1680             : 
    1681             : 
    1682           0 : void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1683             : {
    1684             :     OSL_TRACE("updateNull, m_nRowPos = %u", m_nRowPos );
    1685           0 :     ResultSetEntryGuard aGuard( *this );
    1686           0 :     if ( fetchCurrentRow() == false )
    1687           0 :         m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this );
    1688             : 
    1689           0 :     checkPendingUpdate();
    1690           0 :     checkIndex(columnIndex );
    1691           0 :     columnIndex = mapColumn(columnIndex);
    1692             : 
    1693           0 :     (m_aRow->get())[columnIndex].setBound(true);
    1694           0 :     (m_aRow->get())[columnIndex].setNull();
    1695           0 :     m_nUpdatedRow = getCurrentCardNumber();
    1696             : //    m_RowStates = m_RowStates | RowStates_Updated;
    1697           0 : }
    1698             : 
    1699             : 
    1700           0 : void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException, std::exception)
    1701             : {
    1702           0 :     updateValue(columnIndex, static_cast<bool>(x));
    1703           0 : }
    1704             : 
    1705           0 : void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException, std::exception)
    1706             : {
    1707           0 :     updateValue(columnIndex,x);
    1708           0 : }
    1709             : 
    1710             : 
    1711           0 : void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException, std::exception)
    1712             : {
    1713           0 :     updateValue(columnIndex,x);
    1714           0 : }
    1715             : 
    1716           0 : void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException, std::exception)
    1717             : {
    1718           0 :     updateValue(columnIndex,x);
    1719           0 : }
    1720             : 
    1721           0 : void SAL_CALL OResultSet::updateLong( sal_Int32 /*columnIndex*/, sal_Int64 /*x*/ ) throw(SQLException, RuntimeException, std::exception)
    1722             : {
    1723           0 :     ::dbtools::throwFeatureNotImplementedSQLException( "XRowUpdate::updateLong", *this );
    1724           0 : }
    1725             : 
    1726           0 : void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException, std::exception)
    1727             : {
    1728           0 :     updateValue(columnIndex,x);
    1729           0 : }
    1730             : 
    1731             : 
    1732           0 : void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException, std::exception)
    1733             : {
    1734           0 :     updateValue(columnIndex,x);
    1735           0 : }
    1736             : 
    1737           0 : void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const OUString& x ) throw(SQLException, RuntimeException, std::exception)
    1738             : {
    1739           0 :     updateValue(columnIndex,x);
    1740           0 : }
    1741             : 
    1742           0 : void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException, std::exception)
    1743             : {
    1744           0 :     updateValue(columnIndex,x);
    1745           0 : }
    1746             : 
    1747           0 : void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException, std::exception)
    1748             : {
    1749           0 :     updateValue(columnIndex,x);
    1750           0 : }
    1751             : 
    1752             : 
    1753           0 : void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException, std::exception)
    1754             : {
    1755           0 :     updateValue(columnIndex,x);
    1756           0 : }
    1757             : 
    1758             : 
    1759           0 : void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException, std::exception)
    1760             : {
    1761           0 :     updateValue(columnIndex,x);
    1762           0 : }
    1763             : 
    1764             : 
    1765           0 : void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException, std::exception)
    1766             : {
    1767           0 :     ResultSetEntryGuard aGuard( *this );
    1768             : 
    1769           0 :     if(!x.is())
    1770           0 :         ::dbtools::throwFunctionSequenceException(*this);
    1771             : 
    1772           0 :     Sequence<sal_Int8> aSeq;
    1773           0 :     x->readBytes(aSeq,length);
    1774           0 :     updateValue(columnIndex,aSeq);
    1775           0 : }
    1776             : 
    1777           0 : void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException, std::exception)
    1778             : {
    1779           0 :     updateBinaryStream(columnIndex,x,length);
    1780           0 : }
    1781             : 
    1782           0 : void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException, std::exception)
    1783             : {
    1784           0 :     if (!::dbtools::implUpdateObject(this, columnIndex, x))
    1785             :     {
    1786           0 :         const OUString sError( m_pStatement->getOwnConnection()->getResources().getResourceStringWithSubstitution(
    1787             :                 STR_COLUMN_NOT_UPDATEABLE,
    1788             :                 "$position$", OUString::number(columnIndex)
    1789           0 :              ) );
    1790           0 :         ::dbtools::throwGenericSQLException(sError,*this);
    1791             :     } // if (!::dbtools::implUpdateObject(this, columnIndex, x))
    1792           0 :  }
    1793             : 
    1794             : 
    1795           0 : void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException, std::exception)
    1796             : {
    1797           0 :     if (!::dbtools::implUpdateObject(this, columnIndex, x))
    1798             :     {
    1799           0 :         const OUString sError( m_pStatement->getOwnConnection()->getResources().getResourceStringWithSubstitution(
    1800             :                 STR_COLUMN_NOT_UPDATEABLE,
    1801             :                 "$position$", OUString::number(columnIndex)
    1802           0 :              ) );
    1803           0 :         ::dbtools::throwGenericSQLException(sError,*this);
    1804             :     }
    1805           0 : }
    1806             : 
    1807             : // XResultSetUpdate
    1808             : 
    1809           0 : void SAL_CALL OResultSet::insertRow(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
    1810             : {
    1811           0 :     ResultSetEntryGuard aGuard( *this );
    1812             :     OSL_TRACE("insertRow in, m_nRowPos = %u", m_nRowPos );
    1813             : //    m_RowStates = RowStates_Inserted;
    1814           0 :     updateRow();
    1815           0 :     m_nOldRowPos = 0;
    1816           0 :     m_nNewRow = 0;
    1817             :     //m_aQueryHelper.setRowStates(getCurrentCardNumber(),m_RowStates);
    1818           0 :     OSL_TRACE("insertRow out, m_nRowPos = %u", m_nRowPos );
    1819           0 : }
    1820             : 
    1821           0 : void SAL_CALL OResultSet::updateRow(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
    1822             : {
    1823             :     OSL_FAIL( "OResultSet::updateRow(  ) not implemented" );
    1824           0 : }
    1825             : 
    1826           0 : void SAL_CALL OResultSet::deleteRow(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
    1827             : {
    1828             :     OSL_FAIL( "OResultSet::deleteRow(  ) not implemented" );
    1829           0 : }
    1830             : 
    1831           0 : void SAL_CALL OResultSet::cancelRowUpdates(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
    1832             : {
    1833             :     OSL_FAIL( "OResultSet::cancelRowUpdates(  ) not implemented" );
    1834           0 : }
    1835             : 
    1836           0 : void SAL_CALL OResultSet::moveToInsertRow(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
    1837             : {
    1838             :     OSL_FAIL( "OResultSet::moveToInsertRow(  ) not implemented" );
    1839           0 : }
    1840             : 
    1841           0 : void SAL_CALL OResultSet::moveToCurrentRow(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
    1842             : {
    1843           0 :     ResultSetEntryGuard aGuard( *this );
    1844             :     OSL_TRACE("moveToCurrentRow, m_nRowPos = %u", m_nRowPos );
    1845           0 :     if (rowInserted())
    1846             :     {
    1847           0 :         m_nRowPos = m_nOldRowPos;
    1848           0 :         fetchCurrentRow();
    1849           0 :     }
    1850           0 : }
    1851             : 
    1852           4 : bool OResultSet::determineReadOnly()
    1853             : {
    1854             : //    OSL_FAIL( "OResultSet::determineReadOnly(  ) not implemented" );
    1855             : 
    1856           4 :     if (m_bIsReadOnly == -1)
    1857             :     {
    1858           4 :         m_bIsReadOnly = sal_True;
    1859             : //        OConnection* xConnection = static_cast<OConnection*>(m_pStatement->getConnection().get());
    1860             : //        m_bIsReadOnly = !m_aQueryHelper.isWritable(xConnection) || m_bIsAlwaysFalseQuery;
    1861             :     }
    1862             : 
    1863           4 :     return m_bIsReadOnly != 0;
    1864             : }
    1865             : 
    1866           4 : void OResultSet::setTable(OTable* _rTable)
    1867             : {
    1868             :     OSL_TRACE("In : setTable");
    1869           4 :     m_pTable = _rTable;
    1870           4 :     m_pTable->acquire();
    1871           4 :     m_xTableColumns = m_pTable->getColumns();
    1872           4 :     if(m_xTableColumns.is())
    1873           4 :         m_aColumnNames = m_xTableColumns->getElementNames();
    1874             :     OSL_TRACE("Out : setTable");
    1875           4 : }
    1876             : 
    1877           4 : void OResultSet::setOrderByColumns(const ::std::vector<sal_Int32>& _aColumnOrderBy)
    1878             : {
    1879           4 :     m_aOrderbyColumnNumber = _aColumnOrderBy;
    1880           4 : }
    1881             : 
    1882           4 : void OResultSet::setOrderByAscending(const ::std::vector<TAscendingOrder>& _aOrderbyAsc)
    1883             : {
    1884           4 :     m_aOrderbyAscending = _aOrderbyAsc;
    1885           4 : }
    1886           0 : Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const Sequence< Any >& /*rows*/ ) throw(SQLException, RuntimeException, std::exception)
    1887             : {
    1888           0 :     ::dbtools::throwFeatureNotImplementedSQLException( "XDeleteRows::deleteRows", *this );
    1889           0 :     return Sequence< sal_Int32 >();
    1890             : };
    1891             : 
    1892             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10