LCOV - code coverage report
Current view: top level - connectivity/source/commontools - FDatabaseMetaDataResultSet.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 146 427 34.2 %
Date: 2014-04-11 Functions: 34 101 33.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "ParameterSubstitution.hxx"
      22             : #include "FDatabaseMetaDataResultSet.hxx"
      23             : #include "FDatabaseMetaDataResultSetMetaData.hxx"
      24             : #include <com/sun/star/sdbc/DataType.hpp>
      25             : #include <com/sun/star/sdbc/ColumnSearch.hpp>
      26             : #include <com/sun/star/sdbc/KeyRule.hpp>
      27             : #include <com/sun/star/sdbc/ProcedureResult.hpp>
      28             : #include <com/sun/star/sdbc/IndexType.hpp>
      29             : #include <comphelper/property.hxx>
      30             : #include <com/sun/star/lang/DisposedException.hpp>
      31             : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
      32             : #include <com/sun/star/sdbc/ResultSetType.hpp>
      33             : #include <com/sun/star/sdbc/FetchDirection.hpp>
      34             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      35             : #include <cppuhelper/typeprovider.hxx>
      36             : #include <comphelper/sequence.hxx>
      37             : #include <cppuhelper/factory.hxx>
      38             : #include <cppuhelper/implementationentry.hxx>
      39             : #include <cppuhelper/supportsservice.hxx>
      40             : #include "connectivity/dbexception.hxx"
      41             : #include "resource/common_res.hrc"
      42             : #include "TConnection.hxx"
      43             : 
      44             : using namespace connectivity;
      45             : using namespace dbtools;
      46             : using namespace cppu;
      47             : 
      48             : using namespace ::com::sun::star::beans;
      49             : using namespace ::com::sun::star::uno;
      50             : using namespace ::com::sun::star::sdbcx;
      51             : using namespace ::com::sun::star::sdbc;
      52             : using namespace ::com::sun::star::container;
      53             : using namespace ::com::sun::star::lang;
      54             : 
      55           0 : ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet()
      56             :     :ODatabaseMetaDataResultSet_BASE(m_aMutex)
      57             :     ,::comphelper::OPropertyContainer(ODatabaseMetaDataResultSet_BASE::rBHelper)
      58             :     ,m_aStatement(NULL)
      59             :     ,m_xMetaData(NULL)
      60             :     ,m_nColPos(0)
      61             :     ,m_bBOF(sal_True)
      62           0 :     ,m_bEOF(sal_True)
      63             : {
      64           0 :     construct();
      65           0 : }
      66             : 
      67             : 
      68         225 : ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet( MetaDataResultSetType _eType )
      69             :     :ODatabaseMetaDataResultSet_BASE(m_aMutex)
      70             :     ,::comphelper::OPropertyContainer(ODatabaseMetaDataResultSet_BASE::rBHelper)
      71             :     ,m_aStatement(NULL)
      72             :     ,m_xMetaData(NULL)
      73             :     ,m_nColPos(0)
      74             :     ,m_bBOF(sal_True)
      75         225 :     ,m_bEOF(sal_True)
      76             : {
      77         225 :     construct();
      78             : 
      79         225 :     setType(_eType);
      80         225 : }
      81             : 
      82             : 
      83         450 : ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
      84             : {
      85         450 : }
      86             : 
      87         225 : void ODatabaseMetaDataResultSet::construct()
      88             : {
      89         225 :     registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE),           PROPERTY_ID_FETCHSIZE,          0,&m_nFetchSize,        ::getCppuType(static_cast<sal_Int32*>(0)));
      90         225 :     registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE),        PROPERTY_ID_RESULTSETTYPE,          PropertyAttribute::READONLY,&m_nResultSetType,       ::getCppuType(static_cast<sal_Int32*>(0)));
      91         225 :     registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION),      PROPERTY_ID_FETCHDIRECTION,     0,  &m_nFetchDirection, ::getCppuType(static_cast<sal_Int32*>(0)));
      92         225 :     registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), PROPERTY_ID_RESULTSETCONCURRENCY,   PropertyAttribute::READONLY,&m_nResultSetConcurrency,                ::getCppuType(static_cast<sal_Int32*>(0)));
      93         225 : }
      94             : 
      95         225 : void ODatabaseMetaDataResultSet::setType(MetaDataResultSetType _eType)
      96             : {
      97         225 :     switch( _eType )
      98             :     {
      99           0 :         case eCatalogs:             setCatalogsMap(); break;
     100           0 :         case eSchemas:              setSchemasMap(); break;
     101           0 :         case eColumnPrivileges:     setColumnPrivilegesMap(); break;
     102          77 :         case eColumns:              setColumnsMap(); break;
     103          78 :         case eTables:               setTablesMap(); break;
     104          31 :         case eTableTypes:           setTableTypes(); break;
     105           0 :         case eProcedureColumns:     setProcedureColumnsMap(); break;
     106           0 :         case eProcedures:           setProceduresMap(); break;
     107           0 :         case eExportedKeys:         setExportedKeysMap(); break;
     108           1 :         case eImportedKeys:         setImportedKeysMap(); break;
     109           1 :         case ePrimaryKeys:          setPrimaryKeysMap(); break;
     110           0 :         case eIndexInfo:            setIndexInfoMap(); break;
     111           0 :         case eTablePrivileges:      setTablePrivilegesMap(); break;
     112           0 :         case eCrossReference:       setCrossReferenceMap(); break;
     113           6 :         case eTypeInfo:             setTypeInfoMap(); break;
     114           0 :         case eBestRowIdentifier:    setBestRowIdentifierMap(); break;
     115          31 :         case eVersionColumns:       setVersionColumnsMap(); break;
     116           0 :         case eUDTs:                 setUDTsMap(); break;
     117             :         default:
     118             :             OSL_FAIL("Wrong type!");
     119             :     }
     120         225 : }
     121             : 
     122         225 : void ODatabaseMetaDataResultSet::disposing(void)
     123             : {
     124         225 :     OPropertySetHelper::disposing();
     125             : 
     126         225 :     ::osl::MutexGuard aGuard(m_aMutex);
     127         225 :     m_aStatement    = NULL;
     128         225 : m_xMetaData.clear();
     129         225 :     m_aRowsIter = m_aRows.end();
     130         225 :     m_aRows.clear();
     131         225 :     m_aRowsIter = m_aRows.end();
     132         225 : }
     133             : 
     134        1768 : void SAL_CALL ODatabaseMetaDataResultSet::acquire() throw()
     135             : {
     136        1768 :     ODatabaseMetaDataResultSet_BASE::acquire();
     137        1768 : }
     138             : 
     139        1768 : void SAL_CALL ODatabaseMetaDataResultSet::release() throw()
     140             : {
     141        1768 :     ODatabaseMetaDataResultSet_BASE::release();
     142        1768 : }
     143             : 
     144         460 : Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
     145             : {
     146         460 :     Any aRet = OPropertySetHelper::queryInterface(rType);
     147         460 :     return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType);
     148             : }
     149             : 
     150           0 : Sequence< Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes(  ) throw(RuntimeException, std::exception)
     151             : {
     152           0 :     ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
     153           0 :                                     ::getCppuType( (const Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
     154           0 :                                     ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
     155             : 
     156           0 :     return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
     157             : }
     158             : 
     159         191 : void ODatabaseMetaDataResultSet::setRows(const ORows& _rRows)
     160             : {
     161         191 :     m_aRows = _rRows;
     162         191 :     m_bBOF = sal_True;
     163         191 :     m_bEOF = m_aRows.empty();
     164         191 : }
     165             : 
     166           0 : sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const OUString& columnName ) throw(SQLException, RuntimeException, std::exception)
     167             : {
     168           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     169           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
     170             : 
     171             : 
     172           0 :     Reference< XResultSetMetaData > xMeta = getMetaData();
     173           0 :     sal_Int32 nLen = xMeta->getColumnCount();
     174           0 :     sal_Int32 i = 1;
     175           0 :     for(;i<=nLen;++i)
     176             :     {
     177           0 :         if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
     178           0 :             columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i))
     179             :             )
     180           0 :             return i;
     181             :     }
     182             : 
     183           0 :     ::dbtools::throwInvalidColumnException( columnName, *this );
     184             :     assert(false);
     185           0 :     return 0; // Never reached
     186             : }
     187             : 
     188        1953 : void ODatabaseMetaDataResultSet::checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException)
     189             : {
     190        1953 :     if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1)
     191           0 :         ::dbtools::throwInvalidIndexException(*this);
     192        1953 : }
     193             : 
     194           0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     195             : {
     196           0 :     return NULL;
     197             : }
     198             : 
     199           0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     200             : {
     201           0 :     return NULL;
     202             : }
     203             : 
     204             : 
     205         150 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     206             : {
     207         150 :     return getValue(columnIndex);
     208             : }
     209             : 
     210             : 
     211           0 : sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     212             : {
     213           0 :     return getValue(columnIndex);
     214             : }
     215             : 
     216             : 
     217           0 : Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     218             : {
     219           0 :     return getValue(columnIndex);
     220             : }
     221             : 
     222             : 
     223           0 : ::com::sun::star::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     224             : {
     225           0 :     return getValue(columnIndex);
     226             : }
     227             : 
     228             : 
     229           0 : double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     230             : {
     231           0 :     return getValue(columnIndex);
     232             : }
     233             : 
     234             : 
     235           0 : float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     236             : {
     237           0 :     return getValue(columnIndex);
     238             : }
     239             : 
     240             : 
     241         836 : sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     242             : {
     243         836 :     return getValue(columnIndex);
     244             : }
     245             : 
     246             : 
     247             : 
     248           0 : sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow(  ) throw(SQLException, RuntimeException, std::exception)
     249             : {
     250           0 :     return 0;
     251             : }
     252             : 
     253             : 
     254           0 : sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     255             : {
     256           0 :     return getValue(columnIndex);
     257             : }
     258             : 
     259             : 
     260           0 : Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData(  ) throw(SQLException, RuntimeException, std::exception)
     261             : {
     262           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     263           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
     264             : 
     265             : 
     266           0 :     if(!m_xMetaData.is())
     267           0 :         m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
     268             : 
     269           0 :     return m_xMetaData;
     270             : }
     271             : 
     272           0 : Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     273             : {
     274           0 :     return NULL;
     275             : }
     276             : 
     277             : 
     278             : 
     279           0 : Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     280             : {
     281           0 :     return NULL;
     282             : }
     283             : 
     284           0 : Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     285             : {
     286           0 :     return NULL;
     287             : }
     288             : 
     289             : 
     290           0 : Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     291             : {
     292           0 :     return NULL;
     293             : }
     294             : 
     295             : 
     296           0 : Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException, std::exception)
     297             : {
     298           0 :     return getValue(columnIndex).makeAny();
     299             : }
     300             : 
     301             : 
     302          88 : sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     303             : {
     304          88 :     return getValue(columnIndex);
     305             : }
     306             : 
     307             : 
     308         879 : OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     309             : {
     310         879 :     return getValue(columnIndex);
     311             : }
     312             : 
     313             : 
     314             : 
     315             : 
     316           0 : ::com::sun::star::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     317             : {
     318           0 :     return getValue(columnIndex);
     319             : }
     320             : 
     321             : 
     322             : 
     323           0 : ::com::sun::star::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     324             : {
     325           0 :     return getValue(columnIndex);
     326             : }
     327             : 
     328             : 
     329        1953 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast(  ) throw(SQLException, RuntimeException, std::exception)
     330             : {
     331        1953 :     return m_bEOF;
     332             : }
     333             : 
     334             : 
     335             : SAL_WNOUNREACHABLE_CODE_PUSH
     336             : 
     337           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst(  ) throw(SQLException, RuntimeException, std::exception)
     338             : {
     339           0 :     ::dbtools::throwFunctionSequenceException(*this);
     340           0 :     return sal_False;
     341             : }
     342             : 
     343           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast(  ) throw(SQLException, RuntimeException, std::exception)
     344             : {
     345           0 :     ::dbtools::throwFunctionSequenceException(*this);
     346           0 :     return sal_False;
     347             : }
     348             : 
     349             : SAL_WNOUNREACHABLE_CODE_POP
     350             : 
     351             : 
     352           0 : void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst(  ) throw(SQLException, RuntimeException, std::exception)
     353             : {
     354           0 :     ::dbtools::throwFunctionSequenceException(*this);
     355           0 : }
     356             : 
     357           0 : void SAL_CALL ODatabaseMetaDataResultSet::afterLast(  ) throw(SQLException, RuntimeException, std::exception)
     358             : {
     359           0 :     ::dbtools::throwFunctionSequenceException(*this);
     360           0 : }
     361             : 
     362             : 
     363           2 : void SAL_CALL ODatabaseMetaDataResultSet::close(  ) throw(SQLException, RuntimeException, std::exception)
     364             : {
     365             :     {
     366           2 :         ::osl::MutexGuard aGuard( m_aMutex );
     367           2 :         checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
     368             : 
     369             :     }
     370           2 :     dispose();
     371           2 : }
     372             : 
     373             : 
     374             : SAL_WNOUNREACHABLE_CODE_PUSH
     375             : 
     376           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first(  ) throw(SQLException, RuntimeException, std::exception)
     377             : {
     378           0 :     ::dbtools::throwFunctionSequenceException(*this);
     379           0 :     return sal_False;
     380             : }
     381             : 
     382             : 
     383           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last(  ) throw(SQLException, RuntimeException, std::exception)
     384             : {
     385           0 :     ::dbtools::throwFunctionSequenceException(*this);
     386           0 :     return sal_False;
     387             : }
     388             : 
     389           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 /*row*/ ) throw(SQLException, RuntimeException, std::exception)
     390             : {
     391           0 :     ::dbtools::throwFunctionSequenceException(*this);
     392           0 :     return sal_False;
     393             : }
     394             : 
     395           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 /*row*/ ) throw(SQLException, RuntimeException, std::exception)
     396             : {
     397           0 :     ::dbtools::throwFunctionSequenceException(*this);
     398           0 :     return sal_False;
     399             : }
     400             : 
     401           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous(  ) throw(SQLException, RuntimeException, std::exception)
     402             : {
     403           0 :     ::dbtools::throwFunctionSequenceException(*this);
     404           0 :     return sal_False;
     405             : }
     406             : 
     407             : SAL_WNOUNREACHABLE_CODE_POP
     408             : 
     409             : 
     410           0 : Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement(  ) throw(SQLException, RuntimeException, std::exception)
     411             : {
     412           0 :     return m_aStatement.get();
     413             : }
     414             : 
     415             : 
     416             : SAL_WNOUNREACHABLE_CODE_PUSH
     417             : 
     418           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted(  ) throw(SQLException, RuntimeException, std::exception)
     419             : {
     420           0 :     ::dbtools::throwFunctionSequenceException(*this);
     421           0 :     return sal_False;
     422             : }
     423             : 
     424           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted(  ) throw(SQLException, RuntimeException, std::exception)
     425             : {
     426           0 :     ::dbtools::throwFunctionSequenceException(*this);
     427           0 :     return sal_False;
     428             : }
     429             : 
     430           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated(  ) throw(SQLException, RuntimeException, std::exception)
     431             : {
     432           0 :     ::dbtools::throwFunctionSequenceException(*this);
     433           0 :     return sal_False;
     434             : }
     435             : 
     436             : SAL_WNOUNREACHABLE_CODE_POP
     437             : 
     438             : 
     439             : 
     440        1953 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst(  ) throw(SQLException, RuntimeException, std::exception)
     441             : {
     442        1953 :     return m_bBOF;
     443             : }
     444             : 
     445             : 
     446         430 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next(  ) throw(SQLException, RuntimeException, std::exception)
     447             : {
     448         430 :     ::osl::MutexGuard aGuard( m_aMutex );
     449         430 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
     450             : 
     451         430 :     if ( m_bBOF )
     452             :     {
     453         224 :        m_aRowsIter = m_aRows.begin();
     454         224 :        m_bBOF = sal_False;
     455             :     }
     456             :     else
     457             :     {
     458         206 :         if ( m_bEOF )
     459           0 :             throwFunctionSequenceException( *this );
     460             :         else
     461         206 :             if ( m_aRowsIter != m_aRows.end() )
     462         206 :                 ++m_aRowsIter;
     463             :     }
     464             : 
     465         430 :     bool bSuccess = m_aRowsIter != m_aRows.end();
     466         430 :     if ( !bSuccess )
     467             :     {
     468         145 :         m_bEOF = sal_True;
     469         145 :         m_bBOF = m_aRows.empty();
     470             :     }
     471         430 :     return bSuccess;
     472             : }
     473             : 
     474             : 
     475         212 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull(  ) throw(SQLException, RuntimeException, std::exception)
     476             : {
     477         212 :     ::osl::MutexGuard aGuard( m_aMutex );
     478         212 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
     479             : 
     480             : 
     481         212 :     if(m_aRowsIter == m_aRows.end() || !(*m_aRowsIter)[m_nColPos].is())
     482           0 :         return sal_True;
     483             : 
     484         212 :     return (*m_aRowsIter)[m_nColPos]->getValue().isNull();
     485             : }
     486             : 
     487           0 : void SAL_CALL ODatabaseMetaDataResultSet::refreshRow(  ) throw(SQLException, RuntimeException, std::exception)
     488             : {
     489           0 : }
     490             : 
     491             : 
     492           0 : void SAL_CALL ODatabaseMetaDataResultSet::cancel(  ) throw(RuntimeException, std::exception)
     493             : {
     494           0 : }
     495             : 
     496           0 : void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings(  ) throw(SQLException, RuntimeException, std::exception)
     497             : {
     498           0 : }
     499             : 
     500           0 : Any SAL_CALL ODatabaseMetaDataResultSet::getWarnings(  ) throw(SQLException, RuntimeException, std::exception)
     501             : {
     502           0 :     return Any();
     503             : }
     504             : 
     505           0 : ::cppu::IPropertyArrayHelper* ODatabaseMetaDataResultSet::createArrayHelper( ) const
     506             : {
     507           0 :     Sequence< Property > aProps;
     508           0 :     describeProperties(aProps);
     509           0 :     return new ::cppu::OPropertyArrayHelper(aProps);
     510             : }
     511             : 
     512           0 : ::cppu::IPropertyArrayHelper & ODatabaseMetaDataResultSet::getInfoHelper()
     513             : {
     514           0 :     return *const_cast<ODatabaseMetaDataResultSet*>(this)->getArrayHelper();
     515             : }
     516             : 
     517           0 : void ODatabaseMetaDataResultSet::setProceduresMap()
     518             : {
     519           0 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     520           0 :     pMetaData->setProceduresMap();
     521           0 :     m_xMetaData = pMetaData;
     522           0 : }
     523             : 
     524           0 : void ODatabaseMetaDataResultSet::setCatalogsMap()
     525             : {
     526           0 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     527           0 :     pMetaData->setCatalogsMap();
     528           0 :     m_xMetaData = pMetaData;
     529           0 : }
     530             : 
     531           0 : void ODatabaseMetaDataResultSet::setSchemasMap()
     532             : {
     533           0 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     534           0 :     pMetaData->setSchemasMap();
     535           0 :     m_xMetaData = pMetaData;
     536           0 : }
     537             : 
     538           0 : void ODatabaseMetaDataResultSet::setColumnPrivilegesMap()
     539             : {
     540           0 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     541           0 :     pMetaData->setColumnPrivilegesMap();
     542           0 :     m_xMetaData = pMetaData;
     543           0 : }
     544             : 
     545          77 : void ODatabaseMetaDataResultSet::setColumnsMap()
     546             : {
     547             : 
     548          77 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     549          77 :     pMetaData->setColumnsMap();
     550          77 :     m_xMetaData = pMetaData;
     551          77 : }
     552             : 
     553          78 : void ODatabaseMetaDataResultSet::setTablesMap()
     554             : {
     555             : 
     556          78 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     557          78 :     pMetaData->setTablesMap();
     558          78 :     m_xMetaData = pMetaData;
     559          78 : }
     560             : 
     561           0 : void ODatabaseMetaDataResultSet::setProcedureColumnsMap()
     562             : {
     563           0 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     564           0 :     pMetaData->setProcedureColumnsMap();
     565           0 :     m_xMetaData = pMetaData;
     566           0 : }
     567             : 
     568           1 : void ODatabaseMetaDataResultSet::setPrimaryKeysMap()
     569             : {
     570           1 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     571           1 :     pMetaData->setPrimaryKeysMap();
     572           1 :     m_xMetaData = pMetaData;
     573           1 : }
     574             : 
     575           0 : void ODatabaseMetaDataResultSet::setIndexInfoMap()
     576             : {
     577           0 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     578           0 :     pMetaData->setIndexInfoMap();
     579           0 :     m_xMetaData = pMetaData;
     580           0 : }
     581             : 
     582           0 : void ODatabaseMetaDataResultSet::setTablePrivilegesMap()
     583             : {
     584           0 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     585           0 :     pMetaData->setTablePrivilegesMap();
     586           0 :     m_xMetaData = pMetaData;
     587           0 : }
     588             : 
     589           0 : void ODatabaseMetaDataResultSet::setCrossReferenceMap()
     590             : {
     591           0 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     592           0 :     pMetaData->setCrossReferenceMap();
     593           0 :     m_xMetaData = pMetaData;
     594           0 : }
     595             : 
     596          31 : void ODatabaseMetaDataResultSet::setVersionColumnsMap()
     597             : {
     598          31 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     599          31 :     pMetaData->setVersionColumnsMap();
     600          31 :     m_xMetaData = pMetaData;
     601          31 : }
     602             : 
     603           0 : void ODatabaseMetaDataResultSet::setBestRowIdentifierMap()
     604             : {
     605           0 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     606           0 :     pMetaData->setBestRowIdentifierMap();
     607           0 :     m_xMetaData = pMetaData;
     608           0 : }
     609             : 
     610           6 : void ODatabaseMetaDataResultSet::setTypeInfoMap()
     611             : {
     612           6 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     613           6 :     pMetaData->setTypeInfoMap();
     614           6 :     m_xMetaData = pMetaData;
     615           6 : }
     616             : 
     617           0 : void ODatabaseMetaDataResultSet::setUDTsMap()
     618             : {
     619           0 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     620           0 :     pMetaData->setUDTsMap();
     621           0 :     m_xMetaData = pMetaData;
     622           0 : }
     623             : 
     624          31 : void ODatabaseMetaDataResultSet::setTableTypes()
     625             : {
     626          31 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     627          31 :     pMetaData->setTableTypes();
     628          31 :     m_xMetaData = pMetaData;
     629          31 : }
     630             : 
     631           0 : void ODatabaseMetaDataResultSet::setExportedKeysMap()
     632             : {
     633           0 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     634           0 :     pMetaData->setExportedKeysMap();
     635           0 :     m_xMetaData = pMetaData;
     636           0 : }
     637             : 
     638           1 : void ODatabaseMetaDataResultSet::setImportedKeysMap()
     639             : {
     640           1 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     641           1 :     pMetaData->setImportedKeysMap();
     642           1 :     m_xMetaData = pMetaData;
     643           1 : }
     644             : 
     645           0 : Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL ODatabaseMetaDataResultSet::getPropertySetInfo(  ) throw(RuntimeException, std::exception)
     646             : {
     647           0 :     return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
     648             : }
     649             : 
     650        8026 : ORowSetValueDecorator& ORowSetValueDecorator::operator=(const ORowSetValue& _aValue)
     651             : {
     652        8026 :     m_aValue = _aValue;
     653        8026 :     return *this;
     654             : }
     655             : 
     656        1953 : const ORowSetValue& ODatabaseMetaDataResultSet::getValue(sal_Int32 columnIndex)
     657             : {
     658        1953 :     ::osl::MutexGuard aGuard( m_aMutex );
     659        1953 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
     660             : 
     661        1953 :     if ( isBeforeFirst() || isAfterLast() )
     662           0 :         ::dbtools::throwFunctionSequenceException( *this );
     663             : 
     664        1953 :     checkIndex(columnIndex );
     665        1953 :     m_nColPos = columnIndex;
     666             : 
     667        1953 :     if(m_aRowsIter != m_aRows.end() && (*m_aRowsIter)[columnIndex].is())
     668        1953 :         return *(*m_aRowsIter)[columnIndex];
     669           0 :     return m_aEmptyValue;
     670             : }
     671             : 
     672             : /// return an empty ORowSetValueDecorator
     673         468 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getEmptyValue()
     674             : {
     675         468 :     static ORowSetValueDecoratorRef aEmptyValueRef = new ORowSetValueDecorator();
     676         468 :     return aEmptyValueRef;
     677             : }
     678             : 
     679             : /// return an ORowSetValueDecorator with 0 as value
     680          18 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::get0Value()
     681             : {
     682          18 :     static ORowSetValueDecoratorRef a0ValueRef = new ORowSetValueDecorator((sal_Int32)0);
     683          18 :     return a0ValueRef;
     684             : }
     685             : 
     686             : /// return an ORowSetValueDecorator with 1 as value
     687           3 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::get1Value()
     688             : {
     689           3 :     static ORowSetValueDecoratorRef a1ValueRef = new ORowSetValueDecorator((sal_Int32)1);
     690           3 :     return a1ValueRef;
     691             : }
     692             : 
     693             : /// return an ORowSetValueDecorator with ColumnSearch::BASIC as value
     694           1 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getBasicValue()
     695             : {
     696           1 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(ColumnSearch::BASIC);
     697           1 :     return aValueRef;
     698             : }
     699             : 
     700           0 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getSelectValue()
     701             : {
     702           0 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("SELECT"));
     703           0 :     return aValueRef;
     704             : }
     705             : 
     706           0 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getInsertValue()
     707             : {
     708           0 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("INSERT"));
     709           0 :     return aValueRef;
     710             : }
     711             : 
     712           0 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getDeleteValue()
     713             : {
     714           0 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("DELETE"));
     715           0 :     return aValueRef;
     716             : }
     717             : 
     718           0 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getUpdateValue()
     719             : {
     720           0 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("UPDATE"));
     721           0 :     return aValueRef;
     722             : }
     723             : 
     724           0 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getCreateValue()
     725             : {
     726           0 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("CREATE"));
     727           0 :     return aValueRef;
     728             : }
     729             : 
     730           0 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getReadValue()
     731             : {
     732           0 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("READ"));
     733           0 :     return aValueRef;
     734             : }
     735             : 
     736           0 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getAlterValue()
     737             : {
     738           0 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("ALTER"));
     739           0 :     return aValueRef;
     740             : }
     741             : 
     742           0 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getDropValue()
     743             : {
     744           0 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("DROP"));
     745           0 :     return aValueRef;
     746             : }
     747             : 
     748           4 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getQuoteValue()
     749             : {
     750           4 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("'"));
     751           4 :     return aValueRef;
     752             : }
     753             : 
     754           0 : void SAL_CALL ODatabaseMetaDataResultSet::initialize( const Sequence< Any >& _aArguments ) throw (Exception, RuntimeException, std::exception)
     755             : {
     756           0 :     if ( _aArguments.getLength() == 2 )
     757             :     {
     758           0 :         sal_Int32 nResultSetType = 0;
     759           0 :         if ( _aArguments[0] >>= nResultSetType)
     760             :         {
     761           0 :             setType(static_cast<MetaDataResultSetType>(nResultSetType));
     762           0 :             Sequence< Sequence<Any> > aRows;
     763           0 :             if ( _aArguments[1] >>= aRows )
     764             :             {
     765           0 :                 ORows aRowsToSet;
     766           0 :                 const Sequence<Any>* pRowsIter = aRows.getConstArray();
     767           0 :                 const Sequence<Any>* pRowsEnd  = pRowsIter + aRows.getLength();
     768           0 :                 for (; pRowsIter != pRowsEnd;++pRowsIter)
     769             :                 {
     770           0 :                     ORow aRowToSet;
     771           0 :                     const Any* pRowIter = pRowsIter->getConstArray();
     772           0 :                     const Any* pRowEnd = pRowIter + pRowsIter->getLength();
     773           0 :                     for (; pRowIter != pRowEnd;++pRowIter)
     774             :                     {
     775           0 :                         ORowSetValueDecoratorRef aValue;
     776           0 :                         switch( pRowIter->getValueTypeClass() )
     777             :                         {
     778             :                             case TypeClass_BOOLEAN:
     779             :                                 {
     780           0 :                                     sal_Bool bValue = sal_False;
     781           0 :                                     *pRowIter >>= bValue;
     782           0 :                                     aValue = new ORowSetValueDecorator(ORowSetValue(bValue));
     783             :                                 }
     784           0 :                                 break;
     785             :                             case TypeClass_BYTE:
     786             :                                 {
     787           0 :                                     sal_Int8 nValue(0);
     788           0 :                                     *pRowIter >>= nValue;
     789           0 :                                     aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
     790             :                                 }
     791           0 :                                 break;
     792             :                             case TypeClass_SHORT:
     793             :                             case TypeClass_UNSIGNED_SHORT:
     794             :                                 {
     795           0 :                                     sal_Int16 nValue(0);
     796           0 :                                     *pRowIter >>= nValue;
     797           0 :                                     aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
     798             :                                 }
     799           0 :                                 break;
     800             :                             case TypeClass_LONG:
     801             :                             case TypeClass_UNSIGNED_LONG:
     802             :                                 {
     803           0 :                                     sal_Int32 nValue(0);
     804           0 :                                     *pRowIter >>= nValue;
     805           0 :                                     aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
     806             :                                 }
     807           0 :                                 break;
     808             :                             case TypeClass_HYPER:
     809             :                             case TypeClass_UNSIGNED_HYPER:
     810             :                                 {
     811           0 :                                     sal_Int64 nValue(0);
     812           0 :                                     *pRowIter >>= nValue;
     813           0 :                                     aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
     814             :                                 }
     815           0 :                                 break;
     816             :                             case TypeClass_FLOAT:
     817             :                                 {
     818           0 :                                     float nValue(0.0);
     819           0 :                                     *pRowIter >>= nValue;
     820           0 :                                     aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
     821             :                                 }
     822           0 :                                 break;
     823             :                             case TypeClass_DOUBLE:
     824             :                                 {
     825           0 :                                     double nValue(0.0);
     826           0 :                                     *pRowIter >>= nValue;
     827           0 :                                     aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
     828             :                                 }
     829           0 :                                 break;
     830             :                             case TypeClass_STRING:
     831             :                                 {
     832           0 :                                     OUString sValue;
     833           0 :                                     *pRowIter >>= sValue;
     834           0 :                                     aValue = new ORowSetValueDecorator(ORowSetValue(sValue));
     835             :                                 }
     836           0 :                                 break;
     837             :                             default:
     838           0 :                                 break;
     839             :                         }
     840           0 :                         aRowToSet.push_back(aValue);
     841           0 :                     }
     842           0 :                     aRowsToSet.push_back(aRowToSet);
     843           0 :                 } // for (; pRowsIter != pRowsEnd;++pRowsIter
     844           0 :                 setRows(aRowsToSet);
     845           0 :             }
     846             :         }
     847             :     }
     848           0 : }
     849             : // XServiceInfo
     850             : 
     851             : 
     852           0 :     OUString ODatabaseMetaDataResultSet::getImplementationName_Static(  ) throw(RuntimeException)
     853             :     {
     854           0 :         return OUString("org.openoffice.comp.helper.DatabaseMetaDataResultSet");
     855             :     }
     856             : 
     857           0 :     Sequence< OUString > ODatabaseMetaDataResultSet::getSupportedServiceNames_Static(  ) throw (RuntimeException)
     858             :     {
     859           0 :         Sequence< OUString > aSNS( 1 );
     860           0 :         aSNS[0] = "com.sun.star.sdbc.ResultSet";
     861           0 :         return aSNS;
     862             :     }
     863             : 
     864           0 :     OUString SAL_CALL ODatabaseMetaDataResultSet::getImplementationName(  ) throw(RuntimeException, std::exception)
     865             :     {
     866           0 :         return getImplementationName_Static();
     867             :     }
     868             : 
     869           0 :     sal_Bool SAL_CALL ODatabaseMetaDataResultSet::supportsService( const OUString& _rServiceName ) throw(RuntimeException, std::exception)
     870             :     {
     871           0 :         return cppu::supportsService(this, _rServiceName);
     872             :     }
     873             : 
     874           0 :     Sequence< OUString > SAL_CALL ODatabaseMetaDataResultSet::getSupportedServiceNames(  ) throw(RuntimeException, std::exception)
     875             :     {
     876           0 :         return getSupportedServiceNames_Static();
     877             :     }
     878             : 
     879             :     namespace connectivity
     880             :     {
     881           0 :         Reference< XInterface >  SAL_CALL ODatabaseMetaDataResultSet_CreateInstance(const Reference< XComponentContext >& ) throw( Exception )
     882             :         {
     883           0 :             return *(new ODatabaseMetaDataResultSet());
     884             :         }
     885             :     }
     886             : 
     887             : 
     888             : namespace
     889             : {
     890             :     cppu::ImplementationEntry entries[] = {
     891             :         { &ODatabaseMetaDataResultSet_CreateInstance, &ODatabaseMetaDataResultSet::getImplementationName_Static, &ODatabaseMetaDataResultSet::getSupportedServiceNames_Static,
     892             :             &cppu::createSingleComponentFactory, 0, 0 },
     893             :         { &ParameterSubstitution::create, &ParameterSubstitution::getImplementationName_Static, &ParameterSubstitution::getSupportedServiceNames_Static,
     894             :             &cppu::createSingleComponentFactory, 0, 0 },
     895             :         { 0, 0, 0, 0, 0, 0 }
     896             :     };
     897             : }
     898             : using ::com::sun::star::uno::Reference;
     899             : using ::com::sun::star::uno::Sequence;
     900             : using ::com::sun::star::registry::XRegistryKey;
     901             : using ::com::sun::star::registry::InvalidRegistryException;
     902             : using ::com::sun::star::registry::InvalidValueException;
     903             : using ::com::sun::star::lang::XMultiServiceFactory;
     904             : 
     905             : 
     906             : //= registration
     907             : 
     908             : extern "C"
     909             : {
     910             : 
     911             : 
     912           0 : SAL_DLLPUBLIC_EXPORT void* SAL_CALL dbtools_component_getFactory(const sal_Char* implName, ::com::sun::star::lang::XMultiServiceFactory* serviceManager, void* registryKey)
     913             : {
     914           0 :     return cppu::component_getFactoryHelper(implName, serviceManager, registryKey, entries);
     915             : }
     916             : 
     917             : }   // extern "C"
     918             : 
     919             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10