LCOV - code coverage report
Current view: top level - connectivity/source/commontools - FDatabaseMetaDataResultSet.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 175 427 41.0 %
Date: 2015-06-13 12:38:46 Functions: 46 101 45.5 %
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           1 : 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(true)
      62           1 :     ,m_bEOF(true)
      63             : {
      64           1 :     construct();
      65           1 : }
      66             : 
      67             : 
      68         244 : 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(true)
      75         244 :     ,m_bEOF(true)
      76             : {
      77         244 :     construct();
      78             : 
      79         244 :     setType(_eType);
      80         244 : }
      81             : 
      82             : 
      83         481 : ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
      84             : {
      85         481 : }
      86             : 
      87         245 : void ODatabaseMetaDataResultSet::construct()
      88             : {
      89         245 :     registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE),           PROPERTY_ID_FETCHSIZE,          0,&m_nFetchSize,        ::cppu::UnoType<sal_Int32>::get());
      90         245 :     registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE),        PROPERTY_ID_RESULTSETTYPE,          PropertyAttribute::READONLY,&m_nResultSetType,       ::cppu::UnoType<sal_Int32>::get());
      91         245 :     registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION),      PROPERTY_ID_FETCHDIRECTION,     0,  &m_nFetchDirection, ::cppu::UnoType<sal_Int32>::get());
      92         245 :     registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), PROPERTY_ID_RESULTSETCONCURRENCY,   PropertyAttribute::READONLY,&m_nResultSetConcurrency,                ::cppu::UnoType<sal_Int32>::get());
      93         245 : }
      94             : 
      95         244 : void ODatabaseMetaDataResultSet::setType(MetaDataResultSetType _eType)
      96             : {
      97         244 :     switch( _eType )
      98             :     {
      99           0 :         case eCatalogs:             setCatalogsMap(); break;
     100           0 :         case eSchemas:              setSchemasMap(); break;
     101           0 :         case eColumnPrivileges:     setColumnPrivilegesMap(); break;
     102          76 :         case eColumns:              setColumnsMap(); break;
     103          84 :         case eTables:               setTablesMap(); break;
     104          38 :         case eTableTypes:           setTableTypes(); break;
     105           0 :         case eProcedureColumns:     setProcedureColumnsMap(); break;
     106           0 :         case eProcedures:           setProceduresMap(); break;
     107           0 :         case eExportedKeys:         setExportedKeysMap(); break;
     108           0 :         case eImportedKeys:         setImportedKeysMap(); break;
     109           0 :         case ePrimaryKeys:          setPrimaryKeysMap(); break;
     110           0 :         case eIndexInfo:            setIndexInfoMap(); break;
     111           9 :         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         244 : }
     121             : 
     122         245 : void ODatabaseMetaDataResultSet::disposing()
     123             : {
     124         245 :     OPropertySetHelper::disposing();
     125             : 
     126         245 :     ::osl::MutexGuard aGuard(m_aMutex);
     127         245 :     m_aStatement    = NULL;
     128         245 : m_xMetaData.clear();
     129         245 :     m_aRowsIter = m_aRows.end();
     130         245 :     m_aRows.clear();
     131         245 :     m_aRowsIter = m_aRows.end();
     132         245 : }
     133             : 
     134        1995 : void SAL_CALL ODatabaseMetaDataResultSet::acquire() throw()
     135             : {
     136        1995 :     ODatabaseMetaDataResultSet_BASE::acquire();
     137        1995 : }
     138             : 
     139        1995 : void SAL_CALL ODatabaseMetaDataResultSet::release() throw()
     140             : {
     141        1995 :     ODatabaseMetaDataResultSet_BASE::release();
     142        1995 : }
     143             : 
     144         530 : Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
     145             : {
     146         530 :     Any aRet = OPropertySetHelper::queryInterface(rType);
     147         530 :     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( cppu::UnoType<com::sun::star::beans::XMultiPropertySet>::get(),
     153           0 :                                     cppu::UnoType<com::sun::star::beans::XFastPropertySet>::get(),
     154           0 :                                     cppu::UnoType<com::sun::star::beans::XPropertySet>::get());
     155             : 
     156           0 :     return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
     157             : }
     158             : 
     159         213 : void ODatabaseMetaDataResultSet::setRows(const ORows& _rRows)
     160             : {
     161         213 :     m_aRows = _rRows;
     162         213 :     m_bBOF = true;
     163         213 :     m_bEOF = m_aRows.empty();
     164         213 : }
     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        1723 : void ODatabaseMetaDataResultSet::checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException)
     189             : {
     190        1723 :     if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1)
     191           0 :         ::dbtools::throwInvalidIndexException(*this);
     192        1723 : }
     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          40 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     206             : {
     207          40 :     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         766 : sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     242             : {
     243         766 :     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           0 : sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     303             : {
     304           0 :     return getValue(columnIndex);
     305             : }
     306             : 
     307             : 
     308         917 : OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     309             : {
     310         917 :     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        1723 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast(  ) throw(SQLException, RuntimeException, std::exception)
     330             : {
     331        1723 :     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           0 : void SAL_CALL ODatabaseMetaDataResultSet::close(  ) throw(SQLException, RuntimeException, std::exception)
     364             : {
     365             :     {
     366           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     367           0 :         checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
     368             : 
     369             :     }
     370           0 :     dispose();
     371           0 : }
     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        1723 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst(  ) throw(SQLException, RuntimeException, std::exception)
     441             : {
     442        1723 :     return m_bBOF;
     443             : }
     444             : 
     445             : 
     446         517 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next(  ) throw(SQLException, RuntimeException, std::exception)
     447             : {
     448         517 :     ::osl::MutexGuard aGuard( m_aMutex );
     449         517 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
     450             : 
     451         517 :     if ( m_bBOF )
     452             :     {
     453         243 :        m_aRowsIter = m_aRows.begin();
     454         243 :        m_bBOF = false;
     455             :     }
     456             :     else
     457             :     {
     458         274 :         if ( m_bEOF )
     459           0 :             throwFunctionSequenceException( *this );
     460             :         else
     461         274 :             if ( m_aRowsIter != m_aRows.end() )
     462         274 :                 ++m_aRowsIter;
     463             :     }
     464             : 
     465         517 :     bool bSuccess = m_aRowsIter != m_aRows.end();
     466         517 :     if ( !bSuccess )
     467             :     {
     468         162 :         m_bEOF = true;
     469         162 :         m_bBOF = m_aRows.empty();
     470             :     }
     471         517 :     return bSuccess;
     472             : }
     473             : 
     474             : 
     475         218 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull(  ) throw(SQLException, RuntimeException, std::exception)
     476             : {
     477         218 :     ::osl::MutexGuard aGuard( m_aMutex );
     478         218 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
     479             : 
     480             : 
     481         218 :     if(m_aRowsIter == m_aRows.end() || !(*m_aRowsIter)[m_nColPos].is())
     482           0 :         return sal_True;
     483             : 
     484         218 :     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 *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          76 : void ODatabaseMetaDataResultSet::setColumnsMap()
     546             : {
     547             : 
     548          76 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     549          76 :     pMetaData->setColumnsMap();
     550          76 :     m_xMetaData = pMetaData;
     551          76 : }
     552             : 
     553          84 : void ODatabaseMetaDataResultSet::setTablesMap()
     554             : {
     555             : 
     556          84 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     557          84 :     pMetaData->setTablesMap();
     558          84 :     m_xMetaData = pMetaData;
     559          84 : }
     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           0 : void ODatabaseMetaDataResultSet::setPrimaryKeysMap()
     569             : {
     570           0 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     571           0 :     pMetaData->setPrimaryKeysMap();
     572           0 :     m_xMetaData = pMetaData;
     573           0 : }
     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           9 : void ODatabaseMetaDataResultSet::setTablePrivilegesMap()
     583             : {
     584           9 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     585           9 :     pMetaData->setTablePrivilegesMap();
     586           9 :     m_xMetaData = pMetaData;
     587           9 : }
     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          38 : void ODatabaseMetaDataResultSet::setTableTypes()
     625             : {
     626          38 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     627          38 :     pMetaData->setTableTypes();
     628          38 :     m_xMetaData = pMetaData;
     629          38 : }
     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           0 : void ODatabaseMetaDataResultSet::setImportedKeysMap()
     639             : {
     640           0 :     ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
     641           0 :     pMetaData->setImportedKeysMap();
     642           0 :     m_xMetaData = pMetaData;
     643           0 : }
     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       12004 : ORowSetValueDecorator& ORowSetValueDecorator::operator=(const ORowSetValue& _aValue)
     651             : {
     652       12004 :     m_aValue = _aValue;
     653       12004 :     return *this;
     654             : }
     655             : 
     656        1723 : const ORowSetValue& ODatabaseMetaDataResultSet::getValue(sal_Int32 columnIndex)
     657             : {
     658        1723 :     ::osl::MutexGuard aGuard( m_aMutex );
     659        1723 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
     660             : 
     661        1723 :     if ( isBeforeFirst() || isAfterLast() )
     662           0 :         ::dbtools::throwFunctionSequenceException( *this );
     663             : 
     664        1723 :     checkIndex(columnIndex );
     665        1723 :     m_nColPos = columnIndex;
     666             : 
     667        1723 :     if(m_aRowsIter != m_aRows.end() && (*m_aRowsIter)[columnIndex].is())
     668        1723 :         return *(*m_aRowsIter)[columnIndex];
     669           0 :     return m_aEmptyValue;
     670             : }
     671             : 
     672             : /// return an empty ORowSetValueDecorator
     673         483 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getEmptyValue()
     674             : {
     675         483 :     static ORowSetValueDecoratorRef aEmptyValueRef = new ORowSetValueDecorator();
     676         483 :     return aEmptyValueRef;
     677             : }
     678             : 
     679             : /// return an ORowSetValueDecorator with 0 as value
     680           4 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::get0Value()
     681             : {
     682           4 :     static ORowSetValueDecoratorRef a0ValueRef = new ORowSetValueDecorator((sal_Int32)0);
     683           4 :     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           9 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getSelectValue()
     701             : {
     702           9 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("SELECT"));
     703           9 :     return aValueRef;
     704             : }
     705             : 
     706           9 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getInsertValue()
     707             : {
     708           9 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("INSERT"));
     709           9 :     return aValueRef;
     710             : }
     711             : 
     712           9 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getDeleteValue()
     713             : {
     714           9 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("DELETE"));
     715           9 :     return aValueRef;
     716             : }
     717             : 
     718           9 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getUpdateValue()
     719             : {
     720           9 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("UPDATE"));
     721           9 :     return aValueRef;
     722             : }
     723             : 
     724           9 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getCreateValue()
     725             : {
     726           9 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("CREATE"));
     727           9 :     return aValueRef;
     728             : }
     729             : 
     730           9 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getReadValue()
     731             : {
     732           9 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("READ"));
     733           9 :     return aValueRef;
     734             : }
     735             : 
     736           9 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getAlterValue()
     737             : {
     738           9 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("ALTER"));
     739           9 :     return aValueRef;
     740             : }
     741             : 
     742           9 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getDropValue()
     743             : {
     744           9 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("DROP"));
     745           9 :     return aValueRef;
     746             : }
     747             : 
     748           2 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getQuoteValue()
     749             : {
     750           2 :     static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("'"));
     751           2 :     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 :                                     bool bValue = 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           2 :     OUString ODatabaseMetaDataResultSet::getImplementationName_Static(  ) throw(RuntimeException)
     853             :     {
     854           2 :         return OUString("org.openoffice.comp.helper.DatabaseMetaDataResultSet");
     855             :     }
     856             : 
     857           2 :     Sequence< OUString > ODatabaseMetaDataResultSet::getSupportedServiceNames_Static(  ) throw (RuntimeException)
     858             :     {
     859           2 :         Sequence< OUString > aSNS( 1 );
     860           2 :         aSNS[0] = "com.sun.star.sdbc.ResultSet";
     861           2 :         return aSNS;
     862             :     }
     863             : 
     864           1 :     OUString SAL_CALL ODatabaseMetaDataResultSet::getImplementationName(  ) throw(RuntimeException, std::exception)
     865             :     {
     866           1 :         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           1 :     Sequence< OUString > SAL_CALL ODatabaseMetaDataResultSet::getSupportedServiceNames(  ) throw(RuntimeException, std::exception)
     875             :     {
     876           1 :         return getSupportedServiceNames_Static();
     877             :     }
     878             : 
     879             :     namespace connectivity
     880             :     {
     881           1 :         Reference< XInterface >  SAL_CALL ODatabaseMetaDataResultSet_CreateInstance(const Reference< XComponentContext >& ) throw( Exception )
     882             :         {
     883           1 :             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             : 
     899             : extern "C"
     900             : {
     901             : 
     902             : 
     903           1 : SAL_DLLPUBLIC_EXPORT void* SAL_CALL dbtools_component_getFactory(const sal_Char* implName, void* serviceManager, void* registryKey)
     904             : {
     905           1 :     return cppu::component_getFactoryHelper(implName, serviceManager, registryKey, entries);
     906             : }
     907             : 
     908             : }
     909             : 
     910             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11