LCOV - code coverage report
Current view: top level - ucbhelper/source/provider - resultset.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 110 613 17.9 %
Date: 2014-11-03 Functions: 22 90 24.4 %
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             : 
      21             : /**************************************************************************
      22             :                                 TODO
      23             :  **************************************************************************
      24             : 
      25             :  *************************************************************************/
      26             : #include <cppuhelper/interfacecontainer.hxx>
      27             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      28             : #include <ucbhelper/getcomponentcontext.hxx>
      29             : #include <ucbhelper/resultset.hxx>
      30             : #include <ucbhelper/resultsetmetadata.hxx>
      31             : 
      32             : using namespace com::sun::star;
      33             : 
      34             : 
      35             : 
      36             : namespace ucbhelper_impl
      37             : {
      38             : 
      39             : struct PropertyInfo
      40             : {
      41             :     const char* pName;
      42             :     sal_Int32   nHandle;
      43             :     sal_Int16   nAttributes;
      44             :     const uno::Type& (*pGetCppuType)();
      45             : };
      46             : 
      47           0 : static const uno::Type& sal_Int32_getCppuType()
      48             : {
      49           0 :     return cppu::UnoType<sal_Int32>::get();
      50             : }
      51             : 
      52           0 : static const uno::Type& sal_Bool_getCppuType()
      53             : {
      54           0 :     return getCppuBooleanType();
      55             : }
      56             : 
      57             : static const PropertyInfo aPropertyTable[] =
      58             : {
      59             :     { "IsRowCountFinal",
      60             :       1000,
      61             :       beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY,
      62             :       &sal_Bool_getCppuType
      63             :     },
      64             :     { "RowCount",
      65             :       1001,
      66             :       beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY,
      67             :       &sal_Int32_getCppuType
      68             :     },
      69             :     { 0,
      70             :       0,
      71             :       0,
      72             :       0
      73             :     }
      74             : };
      75             : 
      76             : #define RESULTSET_PROPERTY_COUNT 2
      77             : 
      78             : 
      79             : 
      80             : // class PropertySetInfo
      81             : 
      82             : 
      83             : 
      84             : class PropertySetInfo :
      85             :         public cppu::OWeakObject,
      86             :         public lang::XTypeProvider,
      87             :         public beans::XPropertySetInfo
      88             : {
      89             :     uno::Sequence< beans::Property >*            m_pProps;
      90             : 
      91             : private:
      92             :     bool queryProperty(
      93             :         const OUString& aName, beans::Property& rProp );
      94             : 
      95             : public:
      96             :     PropertySetInfo(
      97             :         const PropertyInfo* pProps,
      98             :         sal_Int32 nProps );
      99             :     virtual ~PropertySetInfo();
     100             : 
     101             :     // XInterface
     102             :     virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType )
     103             :         throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     104             :     virtual void SAL_CALL acquire()
     105             :         throw() SAL_OVERRIDE;
     106             :     virtual void SAL_CALL release()
     107             :         throw() SAL_OVERRIDE;
     108             : 
     109             :     // XTypeProvider
     110             :     virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
     111             :         throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     112             :     virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
     113             :         throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     114             : 
     115             :     // XPropertySetInfo
     116             :     virtual uno::Sequence< beans::Property > SAL_CALL getProperties()
     117             :         throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     118             :     virtual beans::Property SAL_CALL getPropertyByName(
     119             :             const OUString& aName )
     120             :         throw( beans::UnknownPropertyException, uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     121             :     virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name )
     122             :         throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     123             : };
     124             : 
     125             : typedef cppu::OMultiTypeInterfaceContainerHelperVar<OUString>
     126             :     PropertyChangeListenerContainer;
     127             : 
     128           0 : class PropertyChangeListeners : public PropertyChangeListenerContainer
     129             : {
     130             : public:
     131           0 :     PropertyChangeListeners( osl::Mutex& rMtx )
     132           0 :     : PropertyChangeListenerContainer( rMtx ) {}
     133             : };
     134             : 
     135             : } // namespace ucbhelper_impl
     136             : 
     137             : using namespace ucbhelper_impl;
     138             : 
     139             : namespace ucbhelper
     140             : {
     141             : 
     142             : 
     143             : 
     144             : // struct ResultSet_Impl.
     145             : 
     146             : 
     147             : 
     148             : struct ResultSet_Impl
     149             : {
     150             :     uno::Reference< uno::XComponentContext >    m_xContext;
     151             :     uno::Reference< com::sun::star::ucb::XCommandEnvironment >  m_xEnv;
     152             :     uno::Reference< beans::XPropertySetInfo >       m_xPropSetInfo;
     153             :     uno::Reference< sdbc::XResultSetMetaData >      m_xMetaData;
     154             :     uno::Sequence< beans::Property >                m_aProperties;
     155             :     rtl::Reference< ResultSetDataSupplier >         m_xDataSupplier;
     156             :     osl::Mutex                          m_aMutex;
     157             :     cppu::OInterfaceContainerHelper*    m_pDisposeEventListeners;
     158             :     PropertyChangeListeners*            m_pPropertyChangeListeners;
     159             :     sal_Int32                           m_nPos;
     160             :     bool                            m_bWasNull;
     161             :     bool                            m_bAfterLast;
     162             : 
     163             :     inline ResultSet_Impl(
     164             :         const uno::Reference< uno::XComponentContext >& rxContext,
     165             :         const uno::Sequence< beans::Property >& rProperties,
     166             :         const rtl::Reference< ResultSetDataSupplier >& rDataSupplier,
     167             :         const uno::Reference< com::sun::star::ucb::XCommandEnvironment >&
     168             :             rxEnv );
     169             :     inline ~ResultSet_Impl();
     170             : };
     171             : 
     172          42 : inline ResultSet_Impl::ResultSet_Impl(
     173             :     const uno::Reference< uno::XComponentContext >& rxContext,
     174             :     const uno::Sequence< beans::Property >& rProperties,
     175             :     const rtl::Reference< ResultSetDataSupplier >& rDataSupplier,
     176             :     const uno::Reference< com::sun::star::ucb::XCommandEnvironment >& rxEnv )
     177             : : m_xContext( rxContext ),
     178             :   m_xEnv( rxEnv ),
     179             :   m_aProperties( rProperties ),
     180             :   m_xDataSupplier( rDataSupplier ),
     181             :   m_pDisposeEventListeners( 0 ),
     182             :   m_pPropertyChangeListeners( 0 ),
     183             :   m_nPos( 0 ), // Position is one-based. Zero means: before first element.
     184             :   m_bWasNull( false ),
     185          42 :   m_bAfterLast( false )
     186             : {
     187          42 : }
     188             : 
     189             : 
     190          84 : inline ResultSet_Impl::~ResultSet_Impl()
     191             : {
     192          42 :     delete m_pDisposeEventListeners;
     193          42 :     delete m_pPropertyChangeListeners;
     194          42 : }
     195             : 
     196             : 
     197             : 
     198             : 
     199             : // ResultSet Implementation.
     200             : 
     201             : 
     202             : 
     203             : 
     204           8 : ResultSet::ResultSet(
     205             :     const uno::Reference< uno::XComponentContext >& rxContext,
     206             :     const uno::Sequence< beans::Property >& rProperties,
     207             :     const rtl::Reference< ResultSetDataSupplier >& rDataSupplier )
     208             : : m_pImpl( new ResultSet_Impl(
     209             :                rxContext,
     210             :                rProperties,
     211             :                rDataSupplier,
     212           8 :                uno::Reference< com::sun::star::ucb::XCommandEnvironment >() ) )
     213             : {
     214           8 :     rDataSupplier->m_pResultSet = this;
     215           8 : }
     216             : 
     217             : 
     218          34 : ResultSet::ResultSet(
     219             :     const uno::Reference< uno::XComponentContext >& rxContext,
     220             :     const uno::Sequence< beans::Property >& rProperties,
     221             :     const rtl::Reference< ResultSetDataSupplier >& rDataSupplier,
     222             :     const uno::Reference< com::sun::star::ucb::XCommandEnvironment >& rxEnv )
     223          34 : : m_pImpl( new ResultSet_Impl( rxContext, rProperties, rDataSupplier, rxEnv ) )
     224             : {
     225          34 :     rDataSupplier->m_pResultSet = this;
     226          34 : }
     227             : 
     228             : 
     229             : // virtual
     230         126 : ResultSet::~ResultSet()
     231             : {
     232          42 :     delete m_pImpl;
     233          84 : }
     234             : 
     235             : 
     236             : 
     237             : // XInterface methods.
     238             : 
     239         902 : void SAL_CALL ResultSet::acquire()
     240             :     throw()
     241             : {
     242         902 :     OWeakObject::acquire();
     243         902 : }
     244             : 
     245         902 : void SAL_CALL ResultSet::release()
     246             :     throw()
     247             : {
     248         902 :     OWeakObject::release();
     249         902 : }
     250             : 
     251         214 : css::uno::Any SAL_CALL ResultSet::queryInterface( const css::uno::Type & rType )
     252             :     throw( css::uno::RuntimeException, std::exception )
     253             : {
     254             :     css::uno::Any aRet = cppu::queryInterface( rType,
     255             :                                                (static_cast< lang::XTypeProvider* >(this)),
     256             :                                                (static_cast< lang::XServiceInfo* >(this)),
     257             :                                                (static_cast< lang::XComponent* >(this)),
     258             :                                                (static_cast< css::ucb::XContentAccess* >(this)),
     259             :                                                (static_cast< sdbc::XResultSet* >(this)),
     260             :                                                (static_cast< sdbc::XResultSetMetaDataSupplier* >(this)),
     261             :                                                (static_cast< sdbc::XRow* >(this)),
     262             :                                                (static_cast< sdbc::XCloseable* >(this)),
     263             :                                                (static_cast< beans::XPropertySet* >(this))
     264         214 :                                                );
     265         214 :     return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
     266             : }
     267             : 
     268             : // XTypeProvider methods.
     269             : 
     270             : 
     271             : 
     272           0 : XTYPEPROVIDER_IMPL_9( ResultSet,
     273             :                       lang::XTypeProvider,
     274             :                          lang::XServiceInfo,
     275             :                       lang::XComponent,
     276             :                       com::sun::star::ucb::XContentAccess,
     277             :                       sdbc::XResultSet,
     278             :                       sdbc::XResultSetMetaDataSupplier,
     279             :                       sdbc::XRow,
     280             :                       sdbc::XCloseable,
     281             :                       beans::XPropertySet );
     282             : 
     283             : 
     284             : 
     285             : // XServiceInfo methods.
     286             : 
     287             : 
     288             : 
     289           0 : XSERVICEINFO_NOFACTORY_IMPL_1( ResultSet,
     290             :                     OUString("ResultSet"),
     291             :                     OUString(RESULTSET_SERVICE_NAME ) );
     292             : 
     293             : 
     294             : 
     295             : // XComponent methods.
     296             : 
     297             : 
     298             : 
     299             : // virtual
     300           0 : void SAL_CALL ResultSet::dispose()
     301             :     throw( uno::RuntimeException, std::exception )
     302             : {
     303           0 :     osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     304             : 
     305           0 :     if ( m_pImpl->m_pDisposeEventListeners &&
     306           0 :          m_pImpl->m_pDisposeEventListeners->getLength() )
     307             :     {
     308           0 :         lang::EventObject aEvt;
     309           0 :         aEvt.Source = static_cast< lang::XComponent * >( this );
     310           0 :         m_pImpl->m_pDisposeEventListeners->disposeAndClear( aEvt );
     311             :     }
     312             : 
     313           0 :     if ( m_pImpl->m_pPropertyChangeListeners )
     314             :     {
     315           0 :         lang::EventObject aEvt;
     316           0 :         aEvt.Source = static_cast< beans::XPropertySet * >( this );
     317           0 :         m_pImpl->m_pPropertyChangeListeners->disposeAndClear( aEvt );
     318             :     }
     319             : 
     320           0 :     m_pImpl->m_xDataSupplier->close();
     321           0 : }
     322             : 
     323             : 
     324             : // virtual
     325           0 : void SAL_CALL ResultSet::addEventListener(
     326             :         const uno::Reference< lang::XEventListener >& Listener )
     327             :     throw( uno::RuntimeException, std::exception )
     328             : {
     329           0 :     osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     330             : 
     331           0 :     if ( !m_pImpl->m_pDisposeEventListeners )
     332             :         m_pImpl->m_pDisposeEventListeners =
     333           0 :             new cppu::OInterfaceContainerHelper( m_pImpl->m_aMutex );
     334             : 
     335           0 :     m_pImpl->m_pDisposeEventListeners->addInterface( Listener );
     336           0 : }
     337             : 
     338             : 
     339             : // virtual
     340           0 : void SAL_CALL ResultSet::removeEventListener(
     341             :         const uno::Reference< lang::XEventListener >& Listener )
     342             :     throw( uno::RuntimeException, std::exception )
     343             : {
     344           0 :     osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     345             : 
     346           0 :     if ( m_pImpl->m_pDisposeEventListeners )
     347           0 :         m_pImpl->m_pDisposeEventListeners->removeInterface( Listener );
     348           0 : }
     349             : 
     350             : 
     351             : 
     352             : // XResultSetMetaDataSupplier methods.
     353             : 
     354             : 
     355             : 
     356             : // virtual
     357           6 : uno::Reference< sdbc::XResultSetMetaData > SAL_CALL ResultSet::getMetaData()
     358             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     359             : {
     360           6 :     osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     361             : 
     362           6 :     if ( !m_pImpl->m_xMetaData.is() )
     363          12 :         m_pImpl->m_xMetaData = new ResultSetMetaData( m_pImpl->m_xContext,
     364          12 :                                                       m_pImpl->m_aProperties );
     365             : 
     366           6 :     return m_pImpl->m_xMetaData;
     367             : }
     368             : 
     369             : 
     370             : 
     371             : // XResultSet methods.
     372             : 
     373             : 
     374             : 
     375             : // virtual
     376          44 : sal_Bool SAL_CALL ResultSet::next()
     377             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     378             : {
     379             :     // Note: Cursor is initially positioned before the first row.
     380             :     //       First call to 'next()' moves it to first row.
     381             : 
     382          44 :     osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     383             : 
     384          44 :     if ( m_pImpl->m_bAfterLast )
     385             :     {
     386           0 :         m_pImpl->m_xDataSupplier->validate();
     387           0 :         return sal_False;
     388             :     }
     389             : 
     390             :     // getResult works zero-based!
     391          44 :     if ( !m_pImpl->m_xDataSupplier->getResult( m_pImpl->m_nPos ) )
     392             :     {
     393          36 :         m_pImpl->m_bAfterLast = true;
     394          36 :         m_pImpl->m_xDataSupplier->validate();
     395          36 :         return sal_False;
     396             :     }
     397             : 
     398           8 :     m_pImpl->m_nPos++;
     399           8 :     m_pImpl->m_xDataSupplier->validate();
     400           8 :     return sal_True;
     401             : }
     402             : 
     403             : 
     404             : // virtual
     405           0 : sal_Bool SAL_CALL ResultSet::isBeforeFirst()
     406             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     407             : {
     408           0 :     if ( m_pImpl->m_bAfterLast )
     409             :     {
     410           0 :         m_pImpl->m_xDataSupplier->validate();
     411           0 :         return sal_False;
     412             :     }
     413             : 
     414             :     // getResult works zero-based!
     415           0 :     if ( !m_pImpl->m_xDataSupplier->getResult( 0 ) )
     416             :     {
     417           0 :         m_pImpl->m_xDataSupplier->validate();
     418           0 :         return sal_False;
     419             :     }
     420             : 
     421           0 :     m_pImpl->m_xDataSupplier->validate();
     422           0 :     return ( m_pImpl->m_nPos == 0 );
     423             : }
     424             : 
     425             : 
     426             : // virtual
     427           0 : sal_Bool SAL_CALL ResultSet::isAfterLast()
     428             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     429             : {
     430           0 :     m_pImpl->m_xDataSupplier->validate();
     431           0 :     return m_pImpl->m_bAfterLast;
     432             : }
     433             : 
     434             : 
     435             : // virtual
     436           0 : sal_Bool SAL_CALL ResultSet::isFirst()
     437             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     438             : {
     439           0 :     if ( m_pImpl->m_bAfterLast )
     440             :     {
     441           0 :         m_pImpl->m_xDataSupplier->validate();
     442           0 :         return sal_False;
     443             :     }
     444             : 
     445           0 :     m_pImpl->m_xDataSupplier->validate();
     446           0 :     return ( m_pImpl->m_nPos == 1 );
     447             : }
     448             : 
     449             : 
     450             : // virtual
     451           0 : sal_Bool SAL_CALL ResultSet::isLast()
     452             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     453             : {
     454           0 :     if ( m_pImpl->m_bAfterLast )
     455             :     {
     456           0 :         m_pImpl->m_xDataSupplier->validate();
     457           0 :         return sal_False;
     458             :     }
     459             : 
     460           0 :     sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount();
     461           0 :     if ( !nCount )
     462             :     {
     463           0 :         m_pImpl->m_xDataSupplier->validate();
     464           0 :         return sal_False;
     465             :     }
     466             : 
     467           0 :     m_pImpl->m_xDataSupplier->validate();
     468           0 :     return ( m_pImpl->m_nPos == nCount );
     469             : }
     470             : 
     471             : 
     472             : // virtual
     473           0 : void SAL_CALL ResultSet::beforeFirst()
     474             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     475             : {
     476           0 :     osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     477           0 :     m_pImpl->m_bAfterLast = false;
     478           0 :     m_pImpl->m_nPos = 0;
     479           0 :     m_pImpl->m_xDataSupplier->validate();
     480           0 : }
     481             : 
     482             : 
     483             : // virtual
     484           0 : void SAL_CALL ResultSet::afterLast()
     485             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     486             : {
     487           0 :     osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     488           0 :     m_pImpl->m_bAfterLast = true;
     489           0 :     m_pImpl->m_xDataSupplier->validate();
     490           0 : }
     491             : 
     492             : 
     493             : // virtual
     494           8 : sal_Bool SAL_CALL ResultSet::first()
     495             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     496             : {
     497             :     // getResult works zero-based!
     498           8 :     if ( m_pImpl->m_xDataSupplier->getResult( 0 ) )
     499             :     {
     500           8 :         osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     501           8 :         m_pImpl->m_bAfterLast = false;
     502           8 :         m_pImpl->m_nPos = 1;
     503           8 :         m_pImpl->m_xDataSupplier->validate();
     504           8 :         return sal_True;
     505             :     }
     506             : 
     507           0 :     m_pImpl->m_xDataSupplier->validate();
     508           0 :     return sal_False;
     509             : }
     510             : 
     511             : 
     512             : // virtual
     513           0 : sal_Bool SAL_CALL ResultSet::last()
     514             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     515             : {
     516           0 :     sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount();
     517           0 :     if ( nCount )
     518             :     {
     519           0 :         osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     520           0 :         m_pImpl->m_bAfterLast = false;
     521           0 :         m_pImpl->m_nPos = nCount;
     522           0 :         m_pImpl->m_xDataSupplier->validate();
     523           0 :         return sal_True;
     524             :     }
     525             : 
     526           0 :     m_pImpl->m_xDataSupplier->validate();
     527           0 :     return sal_False;
     528             : }
     529             : 
     530             : 
     531             : // virtual
     532           0 : sal_Int32 SAL_CALL ResultSet::getRow()
     533             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     534             : {
     535           0 :     if ( m_pImpl->m_bAfterLast )
     536             :     {
     537           0 :         m_pImpl->m_xDataSupplier->validate();
     538           0 :         return 0;
     539             :     }
     540             : 
     541           0 :     m_pImpl->m_xDataSupplier->validate();
     542           0 :     return m_pImpl->m_nPos;
     543             : }
     544             : 
     545             : 
     546             : // virtual
     547         142 : sal_Bool SAL_CALL ResultSet::absolute( sal_Int32 row )
     548             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     549             : {
     550             : /*
     551             :     If the row number is positive, the cursor moves to the given row number
     552             :     with respect to the beginning of the result set. The first row is row 1,
     553             :     the second is row 2, and so on.
     554             : 
     555             :     If the given row number is negative, the cursor moves to an absolute row
     556             :     position with respect to the end of the result set. For example, calling
     557             :     absolaute( -1 ) positions the cursor on the last row, absolaute( -2 )
     558             :     indicates the next-to-last row, and so on.
     559             : 
     560             :     An attempt to position the cursor beyond the first/last row in the result
     561             :     set leaves the cursor before/after the first/last row, respectively.
     562             : 
     563             :     Calling absolute( 1 ) is the same as calling first().
     564             : 
     565             :     Calling absolute( -1 ) is the same as calling last().
     566             : */
     567         142 :     if ( row < 0 )
     568             :     {
     569           0 :         sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount();
     570             : 
     571           0 :         if ( ( row * -1 ) > nCount )
     572             :         {
     573           0 :             osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     574           0 :             m_pImpl->m_bAfterLast = false;
     575           0 :             m_pImpl->m_nPos = 0;
     576           0 :             m_pImpl->m_xDataSupplier->validate();
     577           0 :             return sal_False;
     578             :         }
     579             :         else // |row| <= nCount
     580             :         {
     581           0 :             osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     582           0 :             m_pImpl->m_bAfterLast = false;
     583           0 :             m_pImpl->m_nPos = ( nCount + row + 1 );
     584           0 :             m_pImpl->m_xDataSupplier->validate();
     585           0 :             return sal_True;
     586             :         }
     587             :     }
     588         142 :     else if ( row == 0 )
     589             :     {
     590             :         // @throws SQLException
     591             :         //      ... if row is 0 ...
     592           0 :         throw sdbc::SQLException();
     593             :     }
     594             :     else // row > 0
     595             :     {
     596         142 :         sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount();
     597             : 
     598         142 :         if ( row <= nCount )
     599             :         {
     600         136 :             osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     601         136 :             m_pImpl->m_bAfterLast = false;
     602         136 :             m_pImpl->m_nPos = row;
     603         136 :             m_pImpl->m_xDataSupplier->validate();
     604         136 :             return sal_True;
     605             :         }
     606             :         else // row > nCount
     607             :         {
     608           6 :             osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     609           6 :             m_pImpl->m_bAfterLast = true;
     610           6 :             m_pImpl->m_xDataSupplier->validate();
     611           6 :             return sal_False;
     612             :         }
     613             :     }
     614             : 
     615             :     // unreachable...
     616             : }
     617             : 
     618             : 
     619             : // virtual
     620           0 : sal_Bool SAL_CALL ResultSet::relative( sal_Int32 rows )
     621             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     622             : {
     623             : /*
     624             :     Attempting to move beyond the first/last row in the result set
     625             :     positions the cursor before/after the first/last row.
     626             : 
     627             :     Calling relative( 0 ) is valid, but does not change the cursor position.
     628             : 
     629             :     Calling relative( 1 ) is different from calling next() because it makes
     630             :     sense to call next() when there is no current row, for example, when
     631             :     the cursor is positioned before the first row or after the last row of
     632             :     the result set.
     633             : */
     634           0 :     if ( m_pImpl->m_bAfterLast || ( m_pImpl->m_nPos == 0 ) )
     635             :     {
     636             :         // "No current row".
     637           0 :         throw sdbc::SQLException();
     638             :     }
     639             : 
     640           0 :     if ( rows < 0 )
     641             :     {
     642           0 :         if ( ( m_pImpl->m_nPos + rows ) > 0 )
     643             :         {
     644           0 :             osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     645           0 :             m_pImpl->m_bAfterLast = false;
     646           0 :             m_pImpl->m_nPos = ( m_pImpl->m_nPos + rows );
     647           0 :             m_pImpl->m_xDataSupplier->validate();
     648           0 :             return sal_True;
     649             :         }
     650             :         else
     651             :         {
     652           0 :             osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     653           0 :             m_pImpl->m_bAfterLast = false;
     654           0 :             m_pImpl->m_nPos = 0;
     655           0 :             m_pImpl->m_xDataSupplier->validate();
     656           0 :             return sal_False;
     657             :         }
     658             :     }
     659           0 :     else if ( rows == 0 )
     660             :     {
     661             :         // nop.
     662           0 :         m_pImpl->m_xDataSupplier->validate();
     663           0 :         return sal_True;
     664             :     }
     665             :     else // rows > 0
     666             :     {
     667           0 :         sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount();
     668           0 :         if ( ( m_pImpl->m_nPos + rows ) <= nCount )
     669             :         {
     670           0 :             osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     671           0 :             m_pImpl->m_bAfterLast = false;
     672           0 :             m_pImpl->m_nPos = ( m_pImpl->m_nPos + rows );
     673           0 :             m_pImpl->m_xDataSupplier->validate();
     674           0 :             return sal_True;
     675             :         }
     676             :         else
     677             :         {
     678           0 :             osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     679           0 :             m_pImpl->m_bAfterLast = true;
     680           0 :             m_pImpl->m_xDataSupplier->validate();
     681           0 :             return sal_False;
     682             :         }
     683             :     }
     684             : 
     685             :     // unreachable...
     686             : }
     687             : 
     688             : 
     689             : // virtual
     690           0 : sal_Bool SAL_CALL ResultSet::previous()
     691             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     692             : {
     693             : /*
     694             :     previous() is not the same as relative( -1 ) because it makes sense
     695             :     to call previous() when there is no current row.
     696             : */
     697           0 :     osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     698             : 
     699           0 :     if ( m_pImpl->m_bAfterLast )
     700             :     {
     701           0 :         m_pImpl->m_bAfterLast = false;
     702           0 :         sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount();
     703           0 :         m_pImpl->m_nPos = nCount;
     704             :     }
     705           0 :     else if ( m_pImpl->m_nPos )
     706           0 :         m_pImpl->m_nPos--;
     707             : 
     708           0 :     if ( m_pImpl->m_nPos )
     709             :     {
     710           0 :         m_pImpl->m_xDataSupplier->validate();
     711           0 :         return sal_True;
     712             :     }
     713             : 
     714           0 :     m_pImpl->m_xDataSupplier->validate();
     715           0 :     return sal_False;
     716             : }
     717             : 
     718             : 
     719             : // virtual
     720           0 : void SAL_CALL ResultSet::refreshRow()
     721             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     722             : {
     723           0 :     osl::MutexGuard aGuard( m_pImpl->m_aMutex );
     724           0 :     if ( m_pImpl->m_bAfterLast || ( m_pImpl->m_nPos == 0 ) )
     725           0 :         return;
     726             : 
     727           0 :     m_pImpl->m_xDataSupplier->releasePropertyValues( m_pImpl->m_nPos );
     728           0 :     m_pImpl->m_xDataSupplier->validate();
     729             : }
     730             : 
     731             : 
     732             : // virtual
     733           0 : sal_Bool SAL_CALL ResultSet::rowUpdated()
     734             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     735             : {
     736           0 :     m_pImpl->m_xDataSupplier->validate();
     737           0 :     return sal_False;
     738             : }
     739             : 
     740             : 
     741             : // virtual
     742           0 : sal_Bool SAL_CALL ResultSet::rowInserted()
     743             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     744             : {
     745           0 :     m_pImpl->m_xDataSupplier->validate();
     746           0 :     return sal_False;
     747             : }
     748             : 
     749             : 
     750             : // virtual
     751           0 : sal_Bool SAL_CALL ResultSet::rowDeleted()
     752             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     753             : {
     754           0 :     m_pImpl->m_xDataSupplier->validate();
     755           0 :     return sal_False;
     756             : }
     757             : 
     758             : 
     759             : // virtual
     760           0 : uno::Reference< uno::XInterface > SAL_CALL ResultSet::getStatement()
     761             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     762             : {
     763             : /*
     764             :     returns the Statement that produced this ResultSet object. If the
     765             :     result set was generated some other way, ... this method returns null.
     766             : */
     767           0 :     m_pImpl->m_xDataSupplier->validate();
     768           0 :     return uno::Reference< uno::XInterface >();
     769             : }
     770             : 
     771             : 
     772             : 
     773             : // XRow methods.
     774             : 
     775             : 
     776             : 
     777             : // virtual
     778          16 : sal_Bool SAL_CALL ResultSet::wasNull()
     779             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     780             : {
     781             :     // This method can not be implemented correctly!!! Imagine different
     782             :     // threads doing a getXYZ - wasNull calling sequence on the same
     783             :     // implementation object...
     784             : 
     785          16 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
     786             :     {
     787             :         uno::Reference< sdbc::XRow > xValues
     788          16 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
     789          16 :                                                         m_pImpl->m_nPos - 1 );
     790          16 :         if ( xValues.is() )
     791             :         {
     792          16 :             m_pImpl->m_xDataSupplier->validate();
     793          16 :             return xValues->wasNull();
     794           0 :         }
     795             :     }
     796             : 
     797           0 :     m_pImpl->m_xDataSupplier->validate();
     798           0 :     return m_pImpl->m_bWasNull;
     799             : }
     800             : 
     801             : 
     802             : // virtual
     803          60 : OUString SAL_CALL ResultSet::getString( sal_Int32 columnIndex )
     804             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     805             : {
     806          60 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
     807             :     {
     808             :         uno::Reference< sdbc::XRow > xValues
     809          60 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
     810          60 :                                                         m_pImpl->m_nPos - 1 );
     811          60 :         if ( xValues.is() )
     812             :         {
     813          60 :             m_pImpl->m_bWasNull = false;
     814          60 :             m_pImpl->m_xDataSupplier->validate();
     815          60 :             return xValues->getString( columnIndex );
     816           0 :         }
     817             :     }
     818             : 
     819           0 :     m_pImpl->m_bWasNull = true;
     820           0 :     m_pImpl->m_xDataSupplier->validate();
     821           0 :     return OUString();
     822             : }
     823             : 
     824             : 
     825             : // virtual
     826          32 : sal_Bool SAL_CALL ResultSet::getBoolean( sal_Int32 columnIndex )
     827             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     828             : {
     829          32 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
     830             :     {
     831             :         uno::Reference< sdbc::XRow > xValues
     832          32 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
     833          32 :                                                         m_pImpl->m_nPos - 1 );
     834          32 :         if ( xValues.is() )
     835             :         {
     836          32 :             m_pImpl->m_bWasNull = false;
     837          32 :             m_pImpl->m_xDataSupplier->validate();
     838          32 :             return xValues->getBoolean( columnIndex );
     839           0 :         }
     840             :     }
     841             : 
     842           0 :     m_pImpl->m_bWasNull = true;
     843           0 :     m_pImpl->m_xDataSupplier->validate();
     844           0 :     return sal_False;
     845             : }
     846             : 
     847             : 
     848             : // virtual
     849           0 : sal_Int8 SAL_CALL ResultSet::getByte( sal_Int32 columnIndex )
     850             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     851             : {
     852           0 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
     853             :     {
     854             :         uno::Reference< sdbc::XRow > xValues
     855           0 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
     856           0 :                                                         m_pImpl->m_nPos - 1 );
     857           0 :         if ( xValues.is() )
     858             :         {
     859           0 :             m_pImpl->m_bWasNull = false;
     860           0 :             m_pImpl->m_xDataSupplier->validate();
     861           0 :             return xValues->getByte( columnIndex );
     862           0 :         }
     863             :     }
     864             : 
     865           0 :     m_pImpl->m_bWasNull = true;
     866           0 :     m_pImpl->m_xDataSupplier->validate();
     867           0 :     return 0;
     868             : }
     869             : 
     870             : 
     871             : // virtual
     872           0 : sal_Int16 SAL_CALL ResultSet::getShort( sal_Int32 columnIndex )
     873             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     874             : {
     875           0 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
     876             :     {
     877             :         uno::Reference< sdbc::XRow > xValues
     878           0 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
     879           0 :                                                         m_pImpl->m_nPos - 1 );
     880           0 :         if ( xValues.is() )
     881             :         {
     882           0 :             m_pImpl->m_bWasNull = false;
     883           0 :             m_pImpl->m_xDataSupplier->validate();
     884           0 :             return xValues->getShort( columnIndex );
     885           0 :         }
     886             :     }
     887             : 
     888           0 :     m_pImpl->m_bWasNull = true;
     889           0 :     m_pImpl->m_xDataSupplier->validate();
     890           0 :     return 0;
     891             : }
     892             : 
     893             : 
     894             : // virtual
     895           0 : sal_Int32 SAL_CALL ResultSet::getInt( sal_Int32 columnIndex )
     896             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     897             : {
     898           0 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
     899             :     {
     900             :         uno::Reference< sdbc::XRow > xValues
     901           0 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
     902           0 :                                                         m_pImpl->m_nPos - 1 );
     903           0 :         if ( xValues.is() )
     904             :         {
     905           0 :             m_pImpl->m_bWasNull = false;
     906           0 :             m_pImpl->m_xDataSupplier->validate();
     907           0 :             return xValues->getInt( columnIndex );
     908           0 :         }
     909             :     }
     910             : 
     911           0 :     m_pImpl->m_bWasNull = true;
     912           0 :     m_pImpl->m_xDataSupplier->validate();
     913           0 :     return 0;
     914             : }
     915             : 
     916             : 
     917             : // virtual
     918           0 : sal_Int64 SAL_CALL ResultSet::getLong( sal_Int32 columnIndex )
     919             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     920             : {
     921           0 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
     922             :     {
     923             :         uno::Reference< sdbc::XRow > xValues
     924           0 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
     925           0 :                                                         m_pImpl->m_nPos - 1 );
     926           0 :         if ( xValues.is() )
     927             :         {
     928           0 :             m_pImpl->m_bWasNull = false;
     929           0 :             m_pImpl->m_xDataSupplier->validate();
     930           0 :             return xValues->getLong( columnIndex );
     931           0 :         }
     932             :     }
     933             : 
     934           0 :     m_pImpl->m_bWasNull = true;
     935           0 :     m_pImpl->m_xDataSupplier->validate();
     936           0 :     return 0;
     937             : }
     938             : 
     939             : 
     940             : // virtual
     941           0 : float SAL_CALL ResultSet::getFloat( sal_Int32 columnIndex )
     942             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     943             : {
     944           0 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
     945             :     {
     946             :         uno::Reference< sdbc::XRow > xValues
     947           0 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
     948           0 :                                                         m_pImpl->m_nPos - 1 );
     949           0 :         if ( xValues.is() )
     950             :         {
     951           0 :             m_pImpl->m_bWasNull = false;
     952           0 :             m_pImpl->m_xDataSupplier->validate();
     953           0 :             return xValues->getFloat( columnIndex );
     954           0 :         }
     955             :     }
     956             : 
     957           0 :     m_pImpl->m_bWasNull = true;
     958           0 :     m_pImpl->m_xDataSupplier->validate();
     959           0 :     return 0;
     960             : }
     961             : 
     962             : 
     963             : // virtual
     964           0 : double SAL_CALL ResultSet::getDouble( sal_Int32 columnIndex )
     965             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     966             : {
     967           0 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
     968             :     {
     969             :         uno::Reference< sdbc::XRow > xValues
     970           0 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
     971           0 :                                                         m_pImpl->m_nPos - 1 );
     972           0 :         if ( xValues.is() )
     973             :         {
     974           0 :             m_pImpl->m_bWasNull = false;
     975           0 :             m_pImpl->m_xDataSupplier->validate();
     976           0 :             return xValues->getDouble( columnIndex );
     977           0 :         }
     978             :     }
     979             : 
     980           0 :     m_pImpl->m_bWasNull = true;
     981           0 :     m_pImpl->m_xDataSupplier->validate();
     982           0 :     return 0;
     983             : }
     984             : 
     985             : 
     986             : // virtual
     987             : uno::Sequence< sal_Int8 > SAL_CALL
     988           0 : ResultSet::getBytes( sal_Int32 columnIndex )
     989             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
     990             : {
     991           0 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
     992             :     {
     993             :         uno::Reference< sdbc::XRow > xValues
     994           0 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
     995           0 :                                                         m_pImpl->m_nPos - 1 );
     996           0 :         if ( xValues.is() )
     997             :         {
     998           0 :             m_pImpl->m_bWasNull = false;
     999           0 :             m_pImpl->m_xDataSupplier->validate();
    1000           0 :             return xValues->getBytes( columnIndex );
    1001           0 :         }
    1002             :     }
    1003             : 
    1004           0 :     m_pImpl->m_bWasNull = true;
    1005           0 :     m_pImpl->m_xDataSupplier->validate();
    1006           0 :     return uno::Sequence< sal_Int8 >();
    1007             : }
    1008             : 
    1009             : 
    1010             : // virtual
    1011           0 : util::Date SAL_CALL ResultSet::getDate( sal_Int32 columnIndex )
    1012             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
    1013             : {
    1014           0 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
    1015             :     {
    1016             :         uno::Reference< sdbc::XRow > xValues
    1017           0 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
    1018           0 :                                                         m_pImpl->m_nPos - 1 );
    1019           0 :         if ( xValues.is() )
    1020             :         {
    1021           0 :             m_pImpl->m_bWasNull = false;
    1022           0 :             m_pImpl->m_xDataSupplier->validate();
    1023           0 :             return xValues->getDate( columnIndex );
    1024           0 :         }
    1025             :     }
    1026             : 
    1027           0 :     m_pImpl->m_bWasNull = true;
    1028           0 :     m_pImpl->m_xDataSupplier->validate();
    1029           0 :     return util::Date();
    1030             : }
    1031             : 
    1032             : 
    1033             : // virtual
    1034           0 : util::Time SAL_CALL ResultSet::getTime( sal_Int32 columnIndex )
    1035             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
    1036             : {
    1037           0 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
    1038             :     {
    1039             :         uno::Reference< sdbc::XRow > xValues
    1040           0 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
    1041           0 :                                                         m_pImpl->m_nPos - 1 );
    1042           0 :         if ( xValues.is() )
    1043             :         {
    1044           0 :             m_pImpl->m_bWasNull = false;
    1045           0 :             m_pImpl->m_xDataSupplier->validate();
    1046           0 :             return xValues->getTime( columnIndex );
    1047           0 :         }
    1048             :     }
    1049             : 
    1050           0 :     m_pImpl->m_bWasNull = true;
    1051           0 :     m_pImpl->m_xDataSupplier->validate();
    1052           0 :     return util::Time();
    1053             : }
    1054             : 
    1055             : 
    1056             : // virtual
    1057             : util::DateTime SAL_CALL
    1058           0 : ResultSet::getTimestamp( sal_Int32 columnIndex )
    1059             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
    1060             : {
    1061           0 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
    1062             :     {
    1063             :         uno::Reference< sdbc::XRow > xValues
    1064           0 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
    1065           0 :                                                         m_pImpl->m_nPos - 1 );
    1066           0 :         if ( xValues.is() )
    1067             :         {
    1068           0 :             m_pImpl->m_bWasNull = false;
    1069           0 :             m_pImpl->m_xDataSupplier->validate();
    1070           0 :             return xValues->getTimestamp( columnIndex );
    1071           0 :         }
    1072             :     }
    1073             : 
    1074           0 :     m_pImpl->m_bWasNull = true;
    1075           0 :     m_pImpl->m_xDataSupplier->validate();
    1076           0 :     return util::DateTime();
    1077             : }
    1078             : 
    1079             : 
    1080             : // virtual
    1081             : uno::Reference< io::XInputStream > SAL_CALL
    1082           0 : ResultSet::getBinaryStream( sal_Int32 columnIndex )
    1083             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
    1084             : {
    1085           0 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
    1086             :     {
    1087             :         uno::Reference< sdbc::XRow > xValues
    1088           0 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
    1089           0 :                                                         m_pImpl->m_nPos - 1 );
    1090           0 :         if ( xValues.is() )
    1091             :         {
    1092           0 :             m_pImpl->m_bWasNull = false;
    1093           0 :             m_pImpl->m_xDataSupplier->validate();
    1094           0 :             return xValues->getBinaryStream( columnIndex );
    1095           0 :         }
    1096             :     }
    1097             : 
    1098           0 :     m_pImpl->m_bWasNull = true;
    1099           0 :     m_pImpl->m_xDataSupplier->validate();
    1100           0 :     return uno::Reference< io::XInputStream >();
    1101             : }
    1102             : 
    1103             : 
    1104             : // virtual
    1105             : uno::Reference< io::XInputStream > SAL_CALL
    1106           0 : ResultSet::getCharacterStream( sal_Int32 columnIndex )
    1107             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
    1108             : {
    1109           0 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
    1110             :     {
    1111             :         uno::Reference< sdbc::XRow > xValues
    1112           0 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
    1113           0 :                                                         m_pImpl->m_nPos - 1 );
    1114           0 :         if ( xValues.is() )
    1115             :         {
    1116           0 :             m_pImpl->m_bWasNull = false;
    1117           0 :             m_pImpl->m_xDataSupplier->validate();
    1118           0 :             return xValues->getCharacterStream( columnIndex );
    1119           0 :         }
    1120             :     }
    1121             : 
    1122           0 :     m_pImpl->m_bWasNull = true;
    1123           0 :     m_pImpl->m_xDataSupplier->validate();
    1124           0 :     return uno::Reference< io::XInputStream >();
    1125             : }
    1126             : 
    1127             : 
    1128             : // virtual
    1129          88 : uno::Any SAL_CALL ResultSet::getObject(
    1130             :         sal_Int32 columnIndex,
    1131             :         const uno::Reference< container::XNameAccess >& typeMap )
    1132             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
    1133             : {
    1134          88 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
    1135             :     {
    1136             :         uno::Reference< sdbc::XRow > xValues
    1137          88 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
    1138          88 :                                                         m_pImpl->m_nPos - 1 );
    1139          88 :         if ( xValues.is() )
    1140             :         {
    1141          88 :             m_pImpl->m_bWasNull = false;
    1142          88 :             m_pImpl->m_xDataSupplier->validate();
    1143          88 :             return xValues->getObject( columnIndex, typeMap );
    1144           0 :         }
    1145             :     }
    1146             : 
    1147           0 :     m_pImpl->m_bWasNull = true;
    1148           0 :     m_pImpl->m_xDataSupplier->validate();
    1149           0 :     return uno::Any();
    1150             : }
    1151             : 
    1152             : 
    1153             : // virtual
    1154             : uno::Reference< sdbc::XRef > SAL_CALL
    1155           0 : ResultSet::getRef( sal_Int32 columnIndex )
    1156             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
    1157             : {
    1158           0 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
    1159             :     {
    1160             :         uno::Reference< sdbc::XRow > xValues
    1161           0 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
    1162           0 :                                                         m_pImpl->m_nPos - 1 );
    1163           0 :         if ( xValues.is() )
    1164             :         {
    1165           0 :             m_pImpl->m_bWasNull = false;
    1166           0 :             m_pImpl->m_xDataSupplier->validate();
    1167           0 :             return xValues->getRef( columnIndex );
    1168           0 :         }
    1169             :     }
    1170             : 
    1171           0 :     m_pImpl->m_bWasNull = true;
    1172           0 :     m_pImpl->m_xDataSupplier->validate();
    1173           0 :     return uno::Reference< sdbc::XRef >();
    1174             : }
    1175             : 
    1176             : 
    1177             : // virtual
    1178             : uno::Reference< sdbc::XBlob > SAL_CALL
    1179           0 : ResultSet::getBlob( sal_Int32 columnIndex )
    1180             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
    1181             : {
    1182           0 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
    1183             :     {
    1184             :         uno::Reference< sdbc::XRow > xValues
    1185           0 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
    1186           0 :                                                         m_pImpl->m_nPos - 1 );
    1187           0 :         if ( xValues.is() )
    1188             :         {
    1189           0 :             m_pImpl->m_bWasNull = false;
    1190           0 :             m_pImpl->m_xDataSupplier->validate();
    1191           0 :             return xValues->getBlob( columnIndex );
    1192           0 :         }
    1193             :     }
    1194             : 
    1195           0 :     m_pImpl->m_bWasNull = true;
    1196           0 :     m_pImpl->m_xDataSupplier->validate();
    1197           0 :     return uno::Reference< sdbc::XBlob >();
    1198             : }
    1199             : 
    1200             : 
    1201             : // virtual
    1202             : uno::Reference< sdbc::XClob > SAL_CALL
    1203           0 : ResultSet::getClob( sal_Int32 columnIndex )
    1204             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
    1205             : {
    1206           0 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
    1207             :     {
    1208             :         uno::Reference< sdbc::XRow > xValues
    1209           0 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
    1210           0 :                                                         m_pImpl->m_nPos - 1 );
    1211           0 :         if ( xValues.is() )
    1212             :         {
    1213           0 :             m_pImpl->m_bWasNull = false;
    1214           0 :             m_pImpl->m_xDataSupplier->validate();
    1215           0 :             return xValues->getClob( columnIndex );
    1216           0 :         }
    1217             :     }
    1218             : 
    1219           0 :     m_pImpl->m_bWasNull = true;
    1220           0 :     m_pImpl->m_xDataSupplier->validate();
    1221           0 :     return uno::Reference< sdbc::XClob >();
    1222             : }
    1223             : 
    1224             : 
    1225             : // virtual
    1226             : uno::Reference< sdbc::XArray > SAL_CALL
    1227           0 : ResultSet::getArray( sal_Int32 columnIndex )
    1228             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
    1229             : {
    1230           0 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
    1231             :     {
    1232             :         uno::Reference< sdbc::XRow > xValues
    1233           0 :             = m_pImpl->m_xDataSupplier->queryPropertyValues(
    1234           0 :                                                         m_pImpl->m_nPos - 1 );
    1235           0 :         if ( xValues.is() )
    1236             :         {
    1237           0 :             m_pImpl->m_bWasNull = false;
    1238           0 :             m_pImpl->m_xDataSupplier->validate();
    1239           0 :             return xValues->getArray( columnIndex );
    1240           0 :         }
    1241             :     }
    1242             : 
    1243           0 :     m_pImpl->m_bWasNull = true;
    1244           0 :     m_pImpl->m_xDataSupplier->validate();
    1245           0 :     return uno::Reference< sdbc::XArray >();
    1246             : }
    1247             : 
    1248             : 
    1249             : 
    1250             : // XCloseable methods.
    1251             : 
    1252             : 
    1253             : 
    1254             : // virtual
    1255           0 : void SAL_CALL ResultSet::close()
    1256             :     throw( sdbc::SQLException, uno::RuntimeException, std::exception )
    1257             : {
    1258           0 :     m_pImpl->m_xDataSupplier->close();
    1259           0 :     m_pImpl->m_xDataSupplier->validate();
    1260           0 : }
    1261             : 
    1262             : 
    1263             : 
    1264             : // XContentAccess methods.
    1265             : 
    1266             : 
    1267             : 
    1268             : // virtual
    1269           4 : OUString SAL_CALL ResultSet::queryContentIdentifierString()
    1270             :     throw( uno::RuntimeException, std::exception )
    1271             : {
    1272           4 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
    1273           4 :         return m_pImpl->m_xDataSupplier->queryContentIdentifierString(
    1274           4 :                                                         m_pImpl->m_nPos - 1 );
    1275             : 
    1276           0 :     return OUString();
    1277             : }
    1278             : 
    1279             : 
    1280             : // virtual
    1281             : uno::Reference< com::sun::star::ucb::XContentIdentifier > SAL_CALL
    1282           0 : ResultSet::queryContentIdentifier()
    1283             :     throw( uno::RuntimeException, std::exception )
    1284             : {
    1285           0 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
    1286           0 :         return m_pImpl->m_xDataSupplier->queryContentIdentifier(
    1287           0 :                                                         m_pImpl->m_nPos - 1 );
    1288             : 
    1289           0 :     return uno::Reference< com::sun::star::ucb::XContentIdentifier >();
    1290             : }
    1291             : 
    1292             : 
    1293             : // virtual
    1294             : uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
    1295          16 : ResultSet::queryContent()
    1296             :     throw( uno::RuntimeException, std::exception )
    1297             : {
    1298          16 :     if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
    1299          16 :         return m_pImpl->m_xDataSupplier->queryContent( m_pImpl->m_nPos - 1 );
    1300             : 
    1301           0 :     return uno::Reference< com::sun::star::ucb::XContent >();
    1302             : }
    1303             : 
    1304             : 
    1305             : 
    1306             : // XPropertySet methods.
    1307             : 
    1308             : 
    1309             : 
    1310             : // virtual
    1311             : uno::Reference< beans::XPropertySetInfo > SAL_CALL
    1312           0 : ResultSet::getPropertySetInfo()
    1313             :     throw( uno::RuntimeException, std::exception )
    1314             : {
    1315           0 :     osl::MutexGuard aGuard( m_pImpl->m_aMutex );
    1316             : 
    1317           0 :     if ( !m_pImpl->m_xPropSetInfo.is() )
    1318             :         m_pImpl->m_xPropSetInfo
    1319           0 :             = new PropertySetInfo( aPropertyTable,
    1320           0 :                                    RESULTSET_PROPERTY_COUNT );
    1321           0 :     return m_pImpl->m_xPropSetInfo;
    1322             : }
    1323             : 
    1324             : 
    1325             : // virtual
    1326           0 : void SAL_CALL ResultSet::setPropertyValue( const OUString& aPropertyName,
    1327             :                                            const uno::Any& )
    1328             :     throw( beans::UnknownPropertyException,
    1329             :            beans::PropertyVetoException,
    1330             :            lang::IllegalArgumentException,
    1331             :            lang::WrappedTargetException,
    1332             :            uno::RuntimeException, std::exception )
    1333             : {
    1334           0 :     if ( aPropertyName.isEmpty() )
    1335           0 :         throw beans::UnknownPropertyException();
    1336             : 
    1337           0 :     if ( aPropertyName.equals(
    1338           0 :                 OUString("RowCount") ) )
    1339             :     {
    1340             :         // property is read-only.
    1341           0 :         throw lang::IllegalArgumentException();
    1342             :     }
    1343           0 :     else if ( aPropertyName.equals(
    1344           0 :                 OUString("IsRowCountFinal") ) )
    1345             :     {
    1346             :         // property is read-only.
    1347           0 :         throw lang::IllegalArgumentException();
    1348             :     }
    1349             :     else
    1350             :     {
    1351           0 :         throw beans::UnknownPropertyException();
    1352             :     }
    1353             : }
    1354             : 
    1355             : 
    1356             : // virtual
    1357           0 : uno::Any SAL_CALL ResultSet::getPropertyValue(
    1358             :         const OUString& PropertyName )
    1359             :     throw( beans::UnknownPropertyException,
    1360             :            lang::WrappedTargetException,
    1361             :            uno::RuntimeException, std::exception )
    1362             : {
    1363           0 :     if ( PropertyName.isEmpty() )
    1364           0 :         throw beans::UnknownPropertyException();
    1365             : 
    1366           0 :     uno::Any aValue;
    1367             : 
    1368           0 :     if ( PropertyName.equals(
    1369           0 :                 OUString("RowCount") ) )
    1370             :     {
    1371           0 :         aValue <<= m_pImpl->m_xDataSupplier->currentCount();
    1372             :     }
    1373           0 :     else if ( PropertyName.equals(
    1374           0 :                 OUString("IsRowCountFinal") ) )
    1375             :     {
    1376           0 :         aValue <<= m_pImpl->m_xDataSupplier->isCountFinal();
    1377             :     }
    1378             :     else
    1379             :     {
    1380           0 :         throw beans::UnknownPropertyException();
    1381             :     }
    1382             : 
    1383           0 :     return aValue;
    1384             : }
    1385             : 
    1386             : 
    1387             : // virtual
    1388           0 : void SAL_CALL ResultSet::addPropertyChangeListener(
    1389             :         const OUString& aPropertyName,
    1390             :         const uno::Reference< beans::XPropertyChangeListener >& xListener )
    1391             :     throw( beans::UnknownPropertyException,
    1392             :            lang::WrappedTargetException,
    1393             :            uno::RuntimeException, std::exception )
    1394             : {
    1395             :     // Note: An empty property name means a listener for "all" properties.
    1396             : 
    1397           0 :     osl::MutexGuard aGuard( m_pImpl->m_aMutex );
    1398             : 
    1399           0 :     if ( !aPropertyName.isEmpty() &&
    1400             :          !aPropertyName.equals(
    1401           0 :                 OUString("RowCount") ) &&
    1402             :          !aPropertyName.equals(
    1403           0 :                 OUString("IsRowCountFinal") ) )
    1404           0 :         throw beans::UnknownPropertyException();
    1405             : 
    1406           0 :     if ( !m_pImpl->m_pPropertyChangeListeners )
    1407             :         m_pImpl->m_pPropertyChangeListeners
    1408           0 :             = new PropertyChangeListeners( m_pImpl->m_aMutex );
    1409             : 
    1410             :     m_pImpl->m_pPropertyChangeListeners->addInterface(
    1411           0 :                                                 aPropertyName, xListener );
    1412           0 : }
    1413             : 
    1414             : 
    1415             : // virtual
    1416           0 : void SAL_CALL ResultSet::removePropertyChangeListener(
    1417             :         const OUString& aPropertyName,
    1418             :         const uno::Reference< beans::XPropertyChangeListener >& xListener )
    1419             :     throw( beans::UnknownPropertyException,
    1420             :            lang::WrappedTargetException,
    1421             :            uno::RuntimeException, std::exception )
    1422             : {
    1423           0 :     osl::MutexGuard aGuard( m_pImpl->m_aMutex );
    1424             : 
    1425           0 :     if ( !aPropertyName.isEmpty() &&
    1426             :          !aPropertyName.equals(
    1427           0 :                 OUString("RowCount") ) &&
    1428             :          !aPropertyName.equals(
    1429           0 :                 OUString("IsRowCountFinal") ) )
    1430           0 :         throw beans::UnknownPropertyException();
    1431             : 
    1432           0 :     if ( m_pImpl->m_pPropertyChangeListeners )
    1433             :         m_pImpl->m_pPropertyChangeListeners->removeInterface(
    1434           0 :                                                     aPropertyName, xListener );
    1435             : 
    1436           0 : }
    1437             : 
    1438             : 
    1439             : // virtual
    1440           0 : void SAL_CALL ResultSet::addVetoableChangeListener(
    1441             :         const OUString&,
    1442             :         const uno::Reference< beans::XVetoableChangeListener >& )
    1443             :     throw( beans::UnknownPropertyException,
    1444             :            lang::WrappedTargetException,
    1445             :            uno::RuntimeException, std::exception )
    1446             : {
    1447             :     //  No constrained props, at the moment.
    1448           0 : }
    1449             : 
    1450             : 
    1451             : // virtual
    1452           0 : void SAL_CALL ResultSet::removeVetoableChangeListener(
    1453             :         const OUString&,
    1454             :         const uno::Reference< beans::XVetoableChangeListener >& )
    1455             :     throw( beans::UnknownPropertyException,
    1456             :            lang::WrappedTargetException,
    1457             :            uno::RuntimeException, std::exception )
    1458             : {
    1459             :     //  No constrained props, at the moment.
    1460           0 : }
    1461             : 
    1462             : 
    1463             : 
    1464             : // Non-interface methods.
    1465             : 
    1466             : 
    1467             : 
    1468           0 : void ResultSet::propertyChanged( const beans::PropertyChangeEvent& rEvt )
    1469             : {
    1470           0 :     if ( !m_pImpl->m_pPropertyChangeListeners )
    1471           0 :         return;
    1472             : 
    1473             :     // Notify listeners interested especially in the changed property.
    1474             :     cppu::OInterfaceContainerHelper* pPropsContainer
    1475             :         = m_pImpl->m_pPropertyChangeListeners->getContainer(
    1476           0 :                                                         rEvt.PropertyName );
    1477           0 :     if ( pPropsContainer )
    1478             :     {
    1479           0 :         cppu::OInterfaceIteratorHelper aIter( *pPropsContainer );
    1480           0 :         while ( aIter.hasMoreElements() )
    1481             :         {
    1482             :             uno::Reference< beans::XPropertyChangeListener > xListener(
    1483           0 :                 aIter.next(), uno::UNO_QUERY );
    1484           0 :             if ( xListener.is() )
    1485           0 :                 xListener->propertyChange( rEvt );
    1486           0 :         }
    1487             :     }
    1488             : 
    1489             :     // Notify listeners interested in all properties.
    1490             :     pPropsContainer
    1491           0 :         = m_pImpl->m_pPropertyChangeListeners->getContainer( OUString() );
    1492           0 :     if ( pPropsContainer )
    1493             :     {
    1494           0 :         cppu::OInterfaceIteratorHelper aIter( *pPropsContainer );
    1495           0 :         while ( aIter.hasMoreElements() )
    1496             :         {
    1497             :             uno::Reference< beans::XPropertyChangeListener > xListener(
    1498           0 :                 aIter.next(), uno::UNO_QUERY );
    1499           0 :             if ( xListener.is() )
    1500           0 :                 xListener->propertyChange( rEvt );
    1501           0 :         }
    1502             :     }
    1503             : }
    1504             : 
    1505             : 
    1506          20 : void ResultSet::rowCountChanged( sal_uInt32 nOld, sal_uInt32 nNew )
    1507             : {
    1508             :     OSL_ENSURE( nOld < nNew, "ResultSet::rowCountChanged - nOld >= nNew!" );
    1509             : 
    1510          20 :     if ( !m_pImpl->m_pPropertyChangeListeners )
    1511          40 :         return;
    1512             : 
    1513             :     propertyChanged(
    1514             :         beans::PropertyChangeEvent(
    1515             :             static_cast< cppu::OWeakObject * >( this ),
    1516             :             OUString("RowCount"),
    1517             :             sal_False,
    1518             :             1001,
    1519             :             uno::makeAny( nOld ),     // old value
    1520           0 :             uno::makeAny( nNew ) ) ); // new value
    1521             : }
    1522             : 
    1523             : 
    1524          42 : void ResultSet::rowCountFinal()
    1525             : {
    1526          42 :     if ( !m_pImpl->m_pPropertyChangeListeners )
    1527          84 :         return;
    1528             : 
    1529             :     propertyChanged(
    1530             :         beans::PropertyChangeEvent(
    1531             :             static_cast< cppu::OWeakObject * >( this ),
    1532             :             OUString("IsRowCountFinal"),
    1533             :             sal_False,
    1534             :             1000,
    1535             :             uno:: makeAny( sal_False ),   // old value
    1536           0 :             uno::makeAny( sal_True ) ) ); // new value
    1537             : }
    1538             : 
    1539             : 
    1540          40 : const uno::Sequence< beans::Property >& ResultSet::getProperties()
    1541             : {
    1542          40 :     return m_pImpl->m_aProperties;
    1543             : }
    1544             : 
    1545             : 
    1546             : const uno::Reference< com::sun::star::ucb::XCommandEnvironment >&
    1547           0 : ResultSet::getEnvironment()
    1548             : {
    1549           0 :     return m_pImpl->m_xEnv;
    1550             : }
    1551             : 
    1552             : } // namespace ucbhelper
    1553             : 
    1554             : namespace ucbhelper_impl {
    1555             : 
    1556             : 
    1557             : 
    1558             : 
    1559             : // PropertySetInfo Implementation.
    1560             : 
    1561             : 
    1562             : 
    1563             : 
    1564           0 : PropertySetInfo::PropertySetInfo(
    1565             :     const PropertyInfo* pProps,
    1566           0 :     sal_Int32 nProps )
    1567             : {
    1568           0 :     m_pProps = new uno::Sequence< beans::Property >( nProps );
    1569             : 
    1570           0 :     if ( nProps )
    1571             :     {
    1572           0 :         const PropertyInfo* pEntry = pProps;
    1573           0 :         beans::Property* pProperties = m_pProps->getArray();
    1574             : 
    1575           0 :         for ( sal_Int32 n = 0; n < nProps; ++n )
    1576             :         {
    1577           0 :             beans::Property& rProp = pProperties[ n ];
    1578             : 
    1579           0 :             rProp.Name       = OUString::createFromAscii( pEntry->pName );
    1580           0 :             rProp.Handle     = pEntry->nHandle;
    1581           0 :             rProp.Type       = pEntry->pGetCppuType();
    1582           0 :             rProp.Attributes = pEntry->nAttributes;
    1583             : 
    1584           0 :             pEntry++;
    1585             :         }
    1586             :     }
    1587           0 : }
    1588             : 
    1589             : 
    1590             : // virtual
    1591           0 : PropertySetInfo::~PropertySetInfo()
    1592             : {
    1593           0 :     delete m_pProps;
    1594           0 : }
    1595             : 
    1596             : 
    1597             : 
    1598             : // XInterface methods.
    1599           0 : void SAL_CALL PropertySetInfo::acquire()
    1600             :     throw()
    1601             : {
    1602           0 :     OWeakObject::acquire();
    1603           0 : }
    1604             : 
    1605           0 : void SAL_CALL PropertySetInfo::release()
    1606             :     throw()
    1607             : {
    1608           0 :     OWeakObject::release();
    1609           0 : }
    1610             : 
    1611           0 : css::uno::Any SAL_CALL PropertySetInfo::queryInterface(
    1612             :                                 const css::uno::Type & rType )
    1613             :     throw( css::uno::RuntimeException, std::exception )
    1614             : {
    1615             :     css::uno::Any aRet = cppu::queryInterface( rType,
    1616             :                                                (static_cast< lang::XTypeProvider* >(this)),
    1617             :                                                (static_cast< beans::XPropertySetInfo* >(this))
    1618           0 :                                                );
    1619           0 :     return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
    1620             : }
    1621             : 
    1622             : // XTypeProvider methods.
    1623             : 
    1624             : 
    1625             : 
    1626           0 : XTYPEPROVIDER_IMPL_2( PropertySetInfo,
    1627             :                          lang::XTypeProvider,
    1628             :                          beans::XPropertySetInfo );
    1629             : 
    1630             : 
    1631             : 
    1632             : // XPropertySetInfo methods.
    1633             : 
    1634             : 
    1635             : 
    1636             : // virtual
    1637           0 : uno::Sequence< beans::Property > SAL_CALL PropertySetInfo::getProperties()
    1638             :     throw( uno::RuntimeException, std::exception )
    1639             : {
    1640           0 :     return uno::Sequence< beans::Property >( *m_pProps );
    1641             : }
    1642             : 
    1643             : 
    1644             : // virtual
    1645           0 : beans::Property SAL_CALL PropertySetInfo::getPropertyByName(
    1646             :         const OUString& aName )
    1647             :     throw( beans::UnknownPropertyException, uno::RuntimeException, std::exception )
    1648             : {
    1649           0 :     beans::Property aProp;
    1650           0 :     if ( queryProperty( aName, aProp ) )
    1651           0 :         return aProp;
    1652             : 
    1653           0 :     throw beans::UnknownPropertyException();
    1654             : }
    1655             : 
    1656             : 
    1657             : // virtual
    1658           0 : sal_Bool SAL_CALL PropertySetInfo::hasPropertyByName(
    1659             :         const OUString& Name )
    1660             :     throw( uno::RuntimeException, std::exception )
    1661             : {
    1662           0 :     beans::Property aProp;
    1663           0 :     return queryProperty( Name, aProp );
    1664             : }
    1665             : 
    1666             : 
    1667           0 : bool PropertySetInfo::queryProperty(
    1668             :     const OUString& aName, beans::Property& rProp )
    1669             : {
    1670           0 :     sal_Int32 nCount = m_pProps->getLength();
    1671           0 :     const beans::Property* pProps = m_pProps->getConstArray();
    1672           0 :     for ( sal_Int32 n = 0; n < nCount; ++n )
    1673             :     {
    1674           0 :         const beans::Property& rCurr = pProps[ n ];
    1675           0 :         if ( rCurr.Name == aName )
    1676             :         {
    1677           0 :             rProp = rCurr;
    1678           0 :             return true;
    1679             :         }
    1680             :     }
    1681             : 
    1682           0 :     return false;
    1683             : }
    1684             : 
    1685             : } // namespace ucbhelper_impl
    1686             : 
    1687             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10