LCOV - code coverage report
Current view: top level - connectivity/source/drivers/postgresql - pq_baseresultset.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 303 0.0 %
Date: 2014-11-03 Functions: 0 55 0.0 %
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             :  *
       4             :  *  Effective License of whole file:
       5             :  *
       6             :  *    This library is free software; you can redistribute it and/or
       7             :  *    modify it under the terms of the GNU Lesser General Public
       8             :  *    License version 2.1, as published by the Free Software Foundation.
       9             :  *
      10             :  *    This library is distributed in the hope that it will be useful,
      11             :  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13             :  *    Lesser General Public License for more details.
      14             :  *
      15             :  *    You should have received a copy of the GNU Lesser General Public
      16             :  *    License along with this library; if not, write to the Free Software
      17             :  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      18             :  *    MA  02111-1307  USA
      19             :  *
      20             :  *  Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
      21             :  *
      22             :  *    The Contents of this file are made available subject to the terms of
      23             :  *    the GNU Lesser General Public License Version 2.1
      24             :  *
      25             :  *    Copyright: 2000 by Sun Microsystems, Inc.
      26             :  *
      27             :  *    Contributor(s): Joerg Budischewski
      28             :  *
      29             :  *  All parts contributed on or after August 2011:
      30             :  *
      31             :  *    This Source Code Form is subject to the terms of the Mozilla Public
      32             :  *    License, v. 2.0. If a copy of the MPL was not distributed with this
      33             :  *    file, You can obtain one at http://mozilla.org/MPL/2.0/.
      34             :  *
      35             :  ************************************************************************/
      36             : 
      37             : #include <osl/thread.h>
      38             : 
      39             : #include <rtl/ustrbuf.hxx>
      40             : 
      41             : #include <cppuhelper/typeprovider.hxx>
      42             : #include <cppuhelper/queryinterface.hxx>
      43             : 
      44             : #include "pq_tools.hxx"
      45             : #include "pq_array.hxx"
      46             : #include "pq_statement.hxx"
      47             : #include "pq_baseresultset.hxx"
      48             : #include "pq_resultsetmetadata.hxx"
      49             : 
      50             : #include <com/sun/star/lang/DisposedException.hpp>
      51             : 
      52             : #include <connectivity/dbconversion.hxx>
      53             : 
      54             : using osl::Mutex;
      55             : using osl::MutexGuard;
      56             : 
      57             : 
      58             : using com::sun::star::beans::XPropertySetInfo;
      59             : using com::sun::star::beans::XPropertySet;
      60             : using com::sun::star::beans::XMultiPropertySet;
      61             : using com::sun::star::beans::XFastPropertySet;
      62             : 
      63             : using com::sun::star::uno::Any;
      64             : using com::sun::star::uno::makeAny;
      65             : using com::sun::star::uno::Type;
      66             : using com::sun::star::uno::RuntimeException;
      67             : using com::sun::star::uno::Exception;
      68             : using com::sun::star::uno::Sequence;
      69             : using com::sun::star::uno::Reference;
      70             : using com::sun::star::uno::XInterface;
      71             : 
      72             : using com::sun::star::lang::IllegalArgumentException;
      73             : 
      74             : using com::sun::star::sdbc::XWarningsSupplier;
      75             : using com::sun::star::sdbc::XCloseable;
      76             : using com::sun::star::sdbc::XStatement;
      77             : using com::sun::star::sdbc::XResultSet;
      78             : using com::sun::star::sdbc::XConnection;
      79             : using com::sun::star::sdbc::SQLException;
      80             : using com::sun::star::sdbc::XRow;
      81             : using com::sun::star::sdbc::XColumnLocate;
      82             : using com::sun::star::sdbc::XResultSetMetaData;
      83             : using com::sun::star::sdbc::XResultSetMetaDataSupplier;
      84             : 
      85             : 
      86             : using com::sun::star::beans::Property;
      87             : 
      88             : using namespace dbtools;
      89             : 
      90             : namespace pq_sdbc_driver
      91             : {
      92           0 : static ::cppu::IPropertyArrayHelper & getResultSetPropertyArrayHelper()
      93             : {
      94             :     static ::cppu::IPropertyArrayHelper *pArrayHelper;
      95           0 :     if( ! pArrayHelper )
      96             :     {
      97           0 :         MutexGuard guard( Mutex::getGlobalMutex() );
      98           0 :         if( ! pArrayHelper )
      99             :         {
     100             :             static Property aTable[] =
     101             :                 {
     102             :                     // LEM TODO: this needs to be kept in sync with other, e.g. pq_statics.css:508
     103             :                     // Should really share!
     104             :                     // At least use for the handles the #define'd values in .hxx file...
     105             :                     Property(
     106             :                         OUString("CursorName"), 0,
     107           0 :                         ::cppu::UnoType<OUString>::get() , 0 ),
     108             :                     Property(
     109             :                         OUString("EscapeProcessing"), 1,
     110           0 :                         ::getBooleanCppuType() , 0 ),
     111             :                     Property(
     112             :                         OUString("FetchDirection"), 2,
     113           0 :                         ::cppu::UnoType<sal_Int32>::get() , 0 ),
     114             :                     Property(
     115             :                         OUString("FetchSize"), 3,
     116           0 :                         ::cppu::UnoType<sal_Int32>::get() , 0 ),
     117             :                     Property(
     118             :                         OUString("IsBookmarkable"), 4,
     119           0 :                         ::getBooleanCppuType() , 0 ),
     120             :                     Property(
     121             :                         OUString("ResultSetConcurrency"), 5,
     122           0 :                         ::cppu::UnoType<sal_Int32>::get() , 0 ),
     123             :                     Property(
     124             :                         OUString("ResultSetType"), 6,
     125           0 :                         ::cppu::UnoType<sal_Int32>::get() , 0 )
     126           0 :                 };
     127             :             OSL_ASSERT( sizeof(aTable) / sizeof(Property) == BASERESULTSET_SIZE );
     128           0 :             static ::cppu::OPropertyArrayHelper arrayHelper( aTable, BASERESULTSET_SIZE, sal_True );
     129           0 :             pArrayHelper = &arrayHelper;
     130           0 :         }
     131             :     }
     132           0 :     return *pArrayHelper;
     133             : }
     134             : 
     135           0 : BaseResultSet::BaseResultSet(
     136             :     const ::rtl::Reference< RefCountedMutex > & refMutex,
     137             :     const Reference< XInterface > & owner,
     138             :     sal_Int32 rowCount,
     139             :     sal_Int32 colCount,
     140             :     const Reference< com::sun::star::script::XTypeConverter > & tc )
     141           0 :     : OComponentHelper( refMutex->mutex )
     142             :     , OPropertySetHelper( OComponentHelper::rBHelper )
     143             :     , m_owner( owner )
     144             :     , m_tc( tc )
     145             :     , m_refMutex( refMutex )
     146             :     , m_row( -1 )
     147             :     , m_rowCount( rowCount )
     148             :     , m_fieldCount( colCount )
     149           0 :     , m_wasNull(false)
     150             : {
     151             :     POSTGRE_TRACE( "ctor BaseResultSet" );
     152           0 : }
     153             : 
     154             : // LEM TODO: refMutex->mutex should live longer than OComponentHelper,
     155             : // but calling OComponentHelper::dispose explicitly here calls
     156             : // BaseResultSet::~BaseResultSet in an infinite loop :(
     157           0 : BaseResultSet::~BaseResultSet()
     158             : {
     159             :     POSTGRE_TRACE( "dtor BaseResultSet" );
     160           0 : }
     161             : 
     162           0 : Any BaseResultSet::queryInterface( const Type & reqType ) throw (RuntimeException, std::exception)
     163             : {
     164           0 :     Any ret;
     165             : 
     166           0 :     ret = OComponentHelper::queryInterface( reqType );
     167           0 :     if( ! ret.hasValue() )
     168           0 :         ret = ::cppu::queryInterface( reqType,
     169             :                                     static_cast< XResultSet * > ( this  ),
     170             :                                     static_cast< XResultSetMetaDataSupplier * > ( this ),
     171             :                                     static_cast< XRow * > ( this ),
     172             :                                     static_cast< XColumnLocate * > ( this ),
     173             :                                     static_cast< XCloseable * > ( this ),
     174             :                                     static_cast< XPropertySet * > ( this ),
     175             :                                     static_cast< XMultiPropertySet * > ( this ),
     176           0 :                                     static_cast< XFastPropertySet * > ( this ) );
     177           0 :     return ret;
     178             : }
     179             : 
     180             : // void BaseResultSet::close(  ) throw (SQLException, RuntimeException)
     181             : // {
     182             : //     Reference< XInterface > owner;
     183             : //     {
     184             : //         ResultSetGuard guard(*this);
     185             : //         if( m_result )
     186             : //         {
     187             : //             PQclear(m_result );
     188             : //             m_result = 0;
     189             : //             m_row = -1;
     190             : //         }
     191             : //         owner = m_owner;
     192             : //         m_owner.clear();
     193             : //     }
     194             : // }
     195             : 
     196           0 : Sequence<Type > BaseResultSet::getTypes() throw( RuntimeException, std::exception )
     197             : {
     198             :     static cppu::OTypeCollection *pCollection;
     199           0 :     if( ! pCollection )
     200             :     {
     201           0 :         MutexGuard guard( osl::Mutex::getGlobalMutex() );
     202           0 :         if( !pCollection )
     203             :         {
     204             :             static cppu::OTypeCollection collection(
     205           0 :                 cppu::UnoType<XResultSet>::get(),
     206           0 :                 cppu::UnoType<XResultSetMetaDataSupplier>::get(),
     207           0 :                 cppu::UnoType<XRow>::get(),
     208           0 :                 cppu::UnoType<XColumnLocate>::get(),
     209           0 :                 cppu::UnoType<XCloseable>::get(),
     210           0 :                 cppu::UnoType<XPropertySet>::get(),
     211           0 :                 cppu::UnoType<XFastPropertySet>::get(),
     212           0 :                 cppu::UnoType<XMultiPropertySet>::get(),
     213           0 :                 OComponentHelper::getTypes());
     214           0 :             pCollection = &collection;
     215           0 :         }
     216             :     }
     217           0 :     return pCollection->getTypes();
     218             : }
     219             : 
     220           0 : Sequence< sal_Int8> BaseResultSet::getImplementationId() throw( RuntimeException, std::exception )
     221             : {
     222           0 :     return css::uno::Sequence<sal_Int8>();
     223             : }
     224             : 
     225             : // Reference< XResultSetMetaData > BaseResultSet::getMetaData(  ) throw (SQLException, RuntimeException)
     226             : // {
     227             : //     ResultSetGuard guard(*this);
     228             : //     checkClosed();
     229             : //     return new ResultSetMetaData( m_refMutex, this, &m_result );
     230             : // }
     231             : 
     232           0 : sal_Bool BaseResultSet::next(  ) throw (SQLException, RuntimeException, std::exception)
     233             : {
     234           0 :     MutexGuard guard( m_refMutex->mutex );
     235           0 :     checkClosed();
     236           0 :     m_row ++;
     237           0 :     return m_row < m_rowCount;
     238             : }
     239             : 
     240           0 : sal_Bool BaseResultSet::isBeforeFirst(  ) throw (SQLException, RuntimeException, std::exception)
     241             : {
     242           0 :     MutexGuard guard( m_refMutex->mutex );
     243           0 :     checkClosed();
     244           0 :     return m_row == -1;
     245             : }
     246             : 
     247           0 : sal_Bool BaseResultSet::isAfterLast(  ) throw (SQLException, RuntimeException, std::exception)
     248             : {
     249           0 :     MutexGuard guard( m_refMutex->mutex );
     250           0 :     checkClosed();
     251           0 :     return m_row >= m_rowCount;
     252             : }
     253             : 
     254           0 : sal_Bool BaseResultSet::isFirst(  ) throw (SQLException, RuntimeException, std::exception)
     255             : {
     256           0 :     MutexGuard guard( m_refMutex->mutex );
     257           0 :     checkClosed();
     258           0 :     return m_row == 0 && m_rowCount;
     259             : }
     260             : 
     261           0 : sal_Bool BaseResultSet::isLast(  ) throw (SQLException, RuntimeException, std::exception)
     262             : {
     263           0 :     MutexGuard guard( m_refMutex->mutex );
     264           0 :     checkClosed();
     265           0 :     return m_row >= 0 && m_row + 1 == m_rowCount;
     266             : }
     267             : 
     268           0 : void BaseResultSet::beforeFirst(  ) throw (SQLException, RuntimeException, std::exception)
     269             : {
     270           0 :     MutexGuard guard( m_refMutex->mutex );
     271           0 :     checkClosed();
     272           0 :     m_row = -1;
     273           0 : }
     274             : 
     275           0 : void BaseResultSet::afterLast(  ) throw (SQLException, RuntimeException, std::exception)
     276             : {
     277           0 :     MutexGuard guard( m_refMutex->mutex );
     278           0 :     checkClosed();
     279           0 :     m_row = m_rowCount;
     280           0 : }
     281             : 
     282           0 : sal_Bool BaseResultSet::first(  ) throw (SQLException, RuntimeException, std::exception)
     283             : {
     284           0 :     MutexGuard guard( m_refMutex->mutex );
     285           0 :     checkClosed();
     286           0 :     bool bRet = ( m_rowCount > 0 );
     287           0 :     if( bRet )
     288           0 :         m_row = 0;
     289           0 :     return bRet;
     290             : }
     291             : 
     292           0 : sal_Bool BaseResultSet::last(  ) throw (SQLException, RuntimeException, std::exception)
     293             : {
     294           0 :     MutexGuard guard( m_refMutex->mutex );
     295           0 :     checkClosed();
     296           0 :     bool bRet = ( m_rowCount > 0 );
     297           0 :     if( bRet )
     298           0 :         m_row = m_rowCount -1;
     299           0 :     return bRet;
     300             : }
     301             : 
     302           0 : sal_Int32 BaseResultSet::getRow(  ) throw (SQLException, RuntimeException, std::exception)
     303             : {
     304           0 :     MutexGuard guard( m_refMutex->mutex );
     305           0 :     checkClosed();
     306           0 :     return m_row +1;
     307             : }
     308             : 
     309           0 : sal_Bool BaseResultSet::absolute( sal_Int32 row ) throw (SQLException, RuntimeException, std::exception)
     310             : {
     311           0 :     MutexGuard guard( m_refMutex->mutex );
     312           0 :     checkClosed();
     313           0 :     if( row > 0 )
     314             :     {
     315           0 :         m_row = row -1;
     316           0 :         if( m_row > m_rowCount )
     317           0 :             m_row = m_rowCount;
     318             :     }
     319             :     else
     320             :     {
     321           0 :         m_row = m_rowCount + row;
     322           0 :         if( m_row < -1 )
     323           0 :             m_row = -1;
     324             :     }
     325           0 :     return sal_True;
     326             : }
     327             : 
     328           0 : sal_Bool BaseResultSet::relative( sal_Int32 rows ) throw (SQLException, RuntimeException, std::exception)
     329             : {
     330           0 :     MutexGuard guard( m_refMutex->mutex );
     331           0 :     checkClosed();
     332           0 :     m_row += rows;
     333             : 
     334           0 :     if( m_row > m_rowCount )
     335           0 :         m_row = m_rowCount;
     336           0 :     else if ( m_row < -1 )
     337           0 :         m_row = -1;
     338           0 :     return sal_True;
     339             : }
     340             : 
     341           0 : sal_Bool BaseResultSet::previous(  ) throw (SQLException, RuntimeException, std::exception)
     342             : {
     343           0 :     MutexGuard guard( m_refMutex->mutex );
     344           0 :     checkClosed();
     345           0 :     bool bRet = ( m_row != -1 );
     346           0 :     if( bRet )
     347           0 :         m_row --;
     348           0 :     return bRet;
     349             : }
     350             : 
     351           0 : void BaseResultSet::refreshRow(  ) throw (SQLException, RuntimeException, std::exception)
     352             : {
     353             :     // TODO: not supported for now
     354           0 : }
     355             : 
     356           0 : sal_Bool BaseResultSet::rowUpdated(  ) throw (SQLException, RuntimeException, std::exception)
     357             : {
     358           0 :     return sal_False;
     359             : }
     360             : 
     361           0 : sal_Bool BaseResultSet::rowInserted(  ) throw (SQLException, RuntimeException, std::exception)
     362             : {
     363           0 :     return sal_False;
     364             : }
     365             : 
     366           0 : sal_Bool BaseResultSet::rowDeleted(  ) throw (SQLException, RuntimeException, std::exception)
     367             : {
     368           0 :     return sal_False;
     369             : }
     370             : 
     371           0 : Reference< XInterface > BaseResultSet::getStatement() throw (SQLException, RuntimeException, std::exception)
     372             : {
     373           0 :     MutexGuard guard( m_refMutex->mutex );
     374           0 :     checkClosed();
     375           0 :     return m_owner;
     376             : }
     377             : 
     378             : 
     379             : //----------------- XRow interface ----------------------------------------------------
     380             : 
     381           0 : sal_Bool BaseResultSet::wasNull(  ) throw (SQLException, RuntimeException, std::exception)
     382             : {
     383           0 :     return m_wasNull;
     384             : }
     385             : 
     386           0 : Any BaseResultSet::convertTo( const Any & val , const Type & type )
     387             : {
     388           0 :     Any aRet;
     389             :     try
     390             :     {
     391           0 :         aRet = m_tc->convertTo( val , type );
     392             :     }
     393           0 :     catch( com::sun::star::lang::IllegalArgumentException & )
     394             :     {}
     395           0 :     catch( com::sun::star::script::CannotConvertException & )
     396             :     {}
     397           0 :     return aRet;
     398             : }
     399             : 
     400           0 : sal_Bool BaseResultSet::getBoolean( sal_Int32 columnIndex ) throw (SQLException, RuntimeException, std::exception)
     401             : {
     402           0 :     MutexGuard guard( m_refMutex->mutex );
     403           0 :     checkClosed();
     404           0 :     checkColumnIndex( columnIndex );
     405           0 :     checkRowIndex( true /* must be on row */ );
     406             : 
     407           0 :     OUString str = getString( columnIndex );
     408             : 
     409           0 :     if( str.getLength() > 0 )
     410             :     {
     411           0 :         switch(str[0])
     412             :         {
     413             :         case '1':
     414             :         case 't':
     415             :         case 'T':
     416             :         case 'y':
     417             :         case 'Y':
     418             : 
     419           0 :             return sal_True;
     420             :         }
     421             :     }
     422           0 :     return sal_False;
     423             : }
     424             : 
     425           0 : sal_Int8 BaseResultSet::getByte( sal_Int32 columnIndex )
     426             :         throw (SQLException, RuntimeException, std::exception)
     427             : {
     428           0 :     MutexGuard guard( m_refMutex->mutex );
     429           0 :     checkClosed();
     430           0 :     checkColumnIndex( columnIndex );
     431           0 :     checkRowIndex( true /* must be on row */ );
     432           0 :     sal_Int8 b = 0;
     433           0 :     convertTo( getValue( columnIndex ), getCppuType( &b )) >>= b;
     434           0 :     return b;
     435             : }
     436             : 
     437           0 : sal_Int16 BaseResultSet::getShort( sal_Int32 columnIndex )
     438             :         throw (SQLException, RuntimeException, std::exception)
     439             : {
     440           0 :     MutexGuard guard( m_refMutex->mutex );
     441           0 :     checkClosed();
     442           0 :     checkColumnIndex( columnIndex );
     443           0 :     checkRowIndex( true /* must be on row */ );
     444           0 :     sal_Int16 i = 0;
     445           0 :     convertTo( getValue( columnIndex ), getCppuType( &i )) >>= i;
     446           0 :     return i;
     447             : }
     448             : 
     449           0 : OUString BaseResultSet::getString( sal_Int32 columnIndex ) throw (SQLException, RuntimeException, std::exception)
     450             : {
     451           0 :     MutexGuard guard(m_refMutex->mutex);
     452           0 :     checkClosed();
     453           0 :     checkColumnIndex( columnIndex );
     454           0 :     checkRowIndex( true /* must be on row */ );
     455           0 :     OUString ret;
     456           0 :     convertTo( getValue(  columnIndex ), getCppuType( &ret ) ) >>= ret;
     457             : //     printf( "BaseResultSet::getString() %s\n" , OUStringToOString( ret, RTL_TEXTENCODING_ASCII_US ).getStr() );
     458           0 :     return ret;
     459             : }
     460             : 
     461           0 : sal_Int32 BaseResultSet::getInt( sal_Int32 columnIndex )
     462             :         throw (SQLException, RuntimeException, std::exception)
     463             : {
     464           0 :     MutexGuard guard( m_refMutex->mutex );
     465           0 :     checkClosed();
     466           0 :     checkColumnIndex( columnIndex );
     467           0 :     checkRowIndex( true /* must be on row */ );
     468           0 :     sal_Int32 i = 0;
     469           0 :     convertTo( getValue( columnIndex ), getCppuType( &i )) >>= i;
     470           0 :     return i;
     471             : }
     472             : 
     473           0 : sal_Int64 BaseResultSet::getLong( sal_Int32 columnIndex )
     474             :         throw (SQLException, RuntimeException, std::exception)
     475             : {
     476           0 :     MutexGuard guard( m_refMutex->mutex );
     477           0 :     checkClosed();
     478           0 :     checkColumnIndex( columnIndex );
     479           0 :     checkRowIndex( true /* must be on row */ );
     480           0 :     sal_Int64 i = 0;
     481           0 :     convertTo( getValue( columnIndex ), getCppuType( &i )) >>= i;
     482           0 :     return i;
     483             : }
     484             : 
     485           0 : float BaseResultSet::getFloat( sal_Int32 columnIndex )
     486             :         throw (SQLException, RuntimeException, std::exception)
     487             : {
     488           0 :     MutexGuard guard( m_refMutex->mutex );
     489           0 :     checkClosed();
     490           0 :     checkColumnIndex( columnIndex );
     491           0 :     checkRowIndex( true /* must be on row */ );
     492           0 :     float f = 0.;
     493           0 :     convertTo( getValue( columnIndex ), getCppuType( &f )) >>= f;
     494           0 :     return f;
     495             : }
     496             : 
     497           0 : double BaseResultSet::getDouble( sal_Int32 columnIndex )
     498             :         throw (SQLException, RuntimeException, std::exception)
     499             : {
     500           0 :     MutexGuard guard( m_refMutex->mutex );
     501           0 :     checkClosed();
     502           0 :     checkColumnIndex( columnIndex );
     503           0 :     double d = 0.;
     504           0 :     convertTo( getValue( columnIndex ), getCppuType( &d )) >>= d;
     505           0 :     return d;
     506             : }
     507             : 
     508           0 : Sequence< sal_Int8 > BaseResultSet::getBytes( sal_Int32 columnIndex )
     509             :         throw (SQLException, RuntimeException, std::exception)
     510             : {
     511           0 :     MutexGuard guard( m_refMutex->mutex );
     512           0 :     checkClosed();
     513           0 :     checkColumnIndex( columnIndex );
     514           0 :     checkRowIndex( true /* must be on row */ );
     515             : 
     516           0 :     Sequence< sal_Int8 > ret;
     517           0 :     OUString ustr;
     518           0 :     if( ! (getValue( columnIndex ) >>= ustr) )
     519           0 :         m_wasNull = true;
     520             :     else
     521             :     {
     522             :         // if this is a binary, it must contain escaped data !
     523           0 :         OString val = OUStringToOString( ustr, RTL_TEXTENCODING_ASCII_US );
     524             : 
     525             :         size_t length;
     526           0 :         char * res = (char*) PQunescapeBytea( (unsigned char *)val.getStr() , &length);
     527           0 :         ret = Sequence< sal_Int8 > ( (sal_Int8*)res, length );
     528           0 :         if( res )
     529           0 :             free( res );
     530             :     }
     531           0 :     return ret;
     532             : }
     533             : 
     534             : 
     535           0 : ::com::sun::star::util::Date BaseResultSet::getDate( sal_Int32 columnIndex )
     536             :         throw (SQLException, RuntimeException, std::exception)
     537             : {
     538           0 :     return DBTypeConversion::toDate( getString( columnIndex ) );
     539             : }
     540             : 
     541           0 : ::com::sun::star::util::Time BaseResultSet::getTime( sal_Int32 columnIndex )
     542             :         throw (SQLException, RuntimeException, std::exception)
     543             : {
     544           0 :     return DBTypeConversion::toTime( getString( columnIndex ) );
     545             : }
     546             : 
     547           0 : ::com::sun::star::util::DateTime BaseResultSet::getTimestamp( sal_Int32 columnIndex )
     548             :         throw (SQLException, RuntimeException, std::exception)
     549             : {
     550           0 :     return DBTypeConversion::toDateTime( getString( columnIndex ) );
     551             : }
     552             : 
     553             :   // LEM TODO: these look like they are missing an actual implementation
     554           0 : Reference< ::com::sun::star::io::XInputStream > BaseResultSet::getBinaryStream( sal_Int32 /* columnIndex */ )
     555             :         throw (SQLException, RuntimeException, std::exception)
     556             : {
     557           0 :     return 0;
     558             : }
     559             : 
     560           0 : Reference< ::com::sun::star::io::XInputStream > BaseResultSet::getCharacterStream( sal_Int32 /* columnIndex */ )
     561             :         throw (SQLException, RuntimeException, std::exception)
     562             : {
     563           0 :     return 0;
     564             : }
     565             : 
     566           0 : Any BaseResultSet::getObject(
     567             :         sal_Int32 /* columnIndex */,
     568             :         const Reference< ::com::sun::star::container::XNameAccess >& /* typeMap */ )
     569             :         throw (SQLException, RuntimeException, std::exception)
     570             : {
     571           0 :     return Any();
     572             : }
     573             : 
     574           0 : Reference< ::com::sun::star::sdbc::XRef > BaseResultSet::getRef( sal_Int32 /* columnIndex */ )
     575             :         throw (SQLException, RuntimeException, std::exception)
     576             : {
     577           0 :     return Reference< com::sun::star::sdbc::XRef > ();
     578             : }
     579             : 
     580           0 : Reference< ::com::sun::star::sdbc::XBlob > BaseResultSet::getBlob( sal_Int32 /* columnIndex */ )
     581             :         throw (SQLException, RuntimeException, std::exception)
     582             : {
     583           0 :     return Reference< com::sun::star::sdbc::XBlob > ();
     584             : }
     585             : 
     586           0 : Reference< ::com::sun::star::sdbc::XClob > BaseResultSet::getClob( sal_Int32 /* columnIndex */ )
     587             :         throw (SQLException, RuntimeException, std::exception)
     588             : {
     589           0 :     return Reference< com::sun::star::sdbc::XClob > ();
     590             : }
     591             : 
     592           0 : Reference< ::com::sun::star::sdbc::XArray > BaseResultSet::getArray( sal_Int32 columnIndex )
     593             :         throw (SQLException, RuntimeException, std::exception)
     594             : {
     595           0 :     return new Array( m_refMutex, parseArray( getString( columnIndex ) ), *this, m_tc );
     596             : }
     597             : 
     598           0 : ::cppu::IPropertyArrayHelper & BaseResultSet::getInfoHelper()
     599             : {
     600           0 :     return getResultSetPropertyArrayHelper();
     601             : }
     602             : 
     603           0 : sal_Bool BaseResultSet::convertFastPropertyValue(
     604             :         Any & /* rConvertedValue */, Any & /* rOldValue */, sal_Int32 nHandle, const Any& rValue )
     605             :         throw (IllegalArgumentException)
     606             : {
     607             :     bool bRet;
     608           0 :     switch( nHandle )
     609             :     {
     610             :     case BASERESULTSET_CURSOR_NAME:
     611             :     {
     612           0 :         OUString val;
     613           0 :         bRet = ( rValue >>= val );
     614           0 :         m_props[nHandle] = makeAny( val );
     615           0 :         break;
     616             :     }
     617             :     case BASERESULTSET_ESCAPE_PROCESSING:
     618             :     case BASERESULTSET_IS_BOOKMARKABLE:
     619             :     {
     620           0 :         bool val(false);
     621           0 :         bRet = ( rValue >>= val );
     622           0 :         m_props[nHandle] = makeAny( val );
     623           0 :         break;
     624             :     }
     625             :     case BASERESULTSET_FETCH_DIRECTION:
     626             :     case BASERESULTSET_FETCH_SIZE:
     627             :     case BASERESULTSET_RESULT_SET_CONCURRENCY:
     628             :     case BASERESULTSET_RESULT_SET_TYPE:
     629             :     {
     630             :         sal_Int32 val;
     631           0 :         bRet = ( rValue >>= val );
     632           0 :         m_props[nHandle] = makeAny( val );
     633           0 :         break;
     634             :     }
     635             :     default:
     636             :     {
     637           0 :         OUStringBuffer buf(128);
     638           0 :         buf.appendAscii( "pq_resultset: Invalid property handle (" );
     639           0 :         buf.append( nHandle );
     640           0 :         buf.appendAscii( ")" );
     641           0 :         throw IllegalArgumentException( buf.makeStringAndClear(), *this, 2 );
     642             :     }
     643             :     }
     644           0 :     return bRet;
     645             : }
     646             : 
     647             : 
     648           0 : void BaseResultSet::setFastPropertyValue_NoBroadcast(
     649             :     sal_Int32 nHandle,const Any& rValue ) throw (Exception, std::exception)
     650             : {
     651           0 :     m_props[nHandle] = rValue;
     652           0 : }
     653             : 
     654           0 : void BaseResultSet::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
     655             : {
     656           0 :     rValue = m_props[nHandle];
     657           0 : }
     658             : 
     659           0 : Reference < XPropertySetInfo >  BaseResultSet::getPropertySetInfo()
     660             :         throw(RuntimeException, std::exception)
     661             : {
     662           0 :     return OPropertySetHelper::createPropertySetInfo( getResultSetPropertyArrayHelper() );
     663             : }
     664             : 
     665           0 : void BaseResultSet::disposing()
     666             : {
     667           0 :     close();
     668           0 : }
     669             : 
     670           0 : void BaseResultSet::checkColumnIndex(sal_Int32 index ) throw ( SQLException, RuntimeException )
     671             : {
     672           0 :     if( index < 1 || index > m_fieldCount )
     673             :     {
     674           0 :         OUStringBuffer buf(128);
     675           0 :         buf.appendAscii( "pq_resultset: index out of range (" );
     676           0 :         buf.append( index );
     677           0 :         buf.appendAscii( ", allowed range is 1 to " );
     678           0 :         buf.append( m_fieldCount );
     679           0 :         buf.appendAscii( ")" );
     680           0 :         throw SQLException( buf.makeStringAndClear(), *this, OUString(), 1, Any() );
     681             :     }
     682             : 
     683           0 : }
     684             : 
     685           0 : void BaseResultSet::checkRowIndex( bool mustBeOnValidRow )
     686             : {
     687           0 :     OUStringBuffer buf( 128 );
     688           0 :     buf.appendAscii( "pq_baseresultset: row index out of range, allowed is " );
     689           0 :     if( mustBeOnValidRow )
     690             :     {
     691           0 :         if( m_row < 0 || m_row >= m_rowCount )
     692             :         {
     693           0 :             buf.appendAscii( "0 to " );
     694           0 :             buf.append( ((sal_Int32)(m_rowCount -1)) );
     695           0 :             buf.appendAscii( ", got " );
     696           0 :             buf.append( m_row );
     697           0 :             throw SQLException( buf.makeStringAndClear(), *this, OUString(),1, Any() );
     698             :         }
     699             :     }
     700             :     else
     701             :     {
     702           0 :         if( m_row < -1 || m_row > m_rowCount )
     703             :         {
     704           0 :             buf.appendAscii( "-1 to " );
     705           0 :             buf.append( m_rowCount );
     706           0 :             buf.appendAscii( ", got " );
     707           0 :             buf.append( m_row );
     708           0 :             throw SQLException( buf.makeStringAndClear(), *this, OUString(),1, Any() );
     709             :         }
     710           0 :     }
     711           0 : }
     712             : 
     713             : }
     714             : 
     715             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10