LCOV - code coverage report
Current view: top level - connectivity/source/drivers/mork - MResultSetMetaData.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 64 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 24 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <connectivity/dbexception.hxx>
      21             : #include <connectivity/dbtools.hxx>
      22             : #include <comphelper/types.hxx>
      23             : #include <comphelper/extract.hxx>
      24             : #include <cppuhelper/typeprovider.hxx>
      25             : #include <tools/diagnose_ex.h>
      26             : #include "MResultSetMetaData.hxx"
      27             : #include <com/sun/star/sdbc/DataType.hpp>
      28             : 
      29             : using namespace connectivity::mork;
      30             : using namespace com::sun::star::uno;
      31             : using namespace com::sun::star::lang;
      32             : using namespace com::sun::star::sdbc;
      33             : using namespace com::sun::star::beans;
      34             : using namespace ::dbtools;
      35             : using namespace ::comphelper;
      36             : 
      37             : 
      38           0 : OResultSetMetaData::~OResultSetMetaData()
      39             : {
      40           0 :    m_xColumns = NULL;
      41           0 : }
      42             : 
      43             : 
      44           0 : void OResultSetMetaData::checkColumnIndex(sal_Int32 column)  throw(SQLException, RuntimeException)
      45             : {
      46           0 :     if(column <= 0 || column > (sal_Int32)(sal_Int32)m_xColumns->get().size())
      47           0 :         throwInvalidIndexException(*this);
      48           0 : }
      49             : 
      50           0 : sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
      51             : {
      52           0 :     return getPrecision(column);
      53             : }
      54             : 
      55             : 
      56           0 : sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
      57             : {
      58           0 :     return DataType::VARCHAR; // at the moment there exists only this type
      59             : }
      60             : 
      61             : 
      62           0 : sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount(  ) throw(SQLException, RuntimeException, std::exception)
      63             : {
      64           0 :     return static_cast<sal_Int32>((m_xColumns->get()).size());
      65             : }
      66             : 
      67             : 
      68           0 : sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
      69             : {
      70           0 :     return sal_False;
      71             : }
      72             : 
      73             : 
      74           0 : OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
      75             : {
      76           0 :     return OUString();
      77             : }
      78             : 
      79             : 
      80           0 : OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
      81             : {
      82           0 :     checkColumnIndex(column);
      83             : 
      84           0 :     OUString sColumnName;
      85             :     try
      86             :     {
      87           0 :         Reference< XPropertySet > xColumnProps( (m_xColumns->get())[column-1], UNO_QUERY_THROW );
      88           0 :         OSL_VERIFY( xColumnProps->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_NAME ) ) >>= sColumnName );
      89             :     }
      90           0 :     catch( const Exception& )
      91             :     {
      92             :         DBG_UNHANDLED_EXCEPTION();
      93             :     }
      94           0 :     return sColumnName;
      95             : }
      96             : 
      97           0 : OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
      98             : {
      99           0 :     return m_aTableName;
     100             : }
     101             : 
     102           0 : OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
     103             : {
     104           0 :     return OUString();
     105             : }
     106             : 
     107           0 : OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
     108             : {
     109           0 :     checkColumnIndex(column);
     110           0 :     return getString((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)));
     111             : }
     112             : 
     113           0 : OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
     114             : {
     115           0 :     return getColumnName(column);
     116             : }
     117             : 
     118           0 : OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
     119             : {
     120           0 :     return OUString();
     121             : }
     122             : 
     123             : 
     124           0 : sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
     125             : {
     126           0 :     checkColumnIndex(column);
     127           0 :     return getBOOL((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)));
     128             : }
     129             : 
     130             : 
     131           0 : sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
     132             : {
     133           0 :     return sal_False;
     134             : }
     135             : 
     136           0 : sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
     137             : {
     138           0 :     return sal_False;
     139             : }
     140             : 
     141           0 : sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
     142             : {
     143           0 :     checkColumnIndex(column);
     144           0 :     return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)));
     145             : }
     146             : 
     147           0 : sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
     148             : {
     149           0 :     checkColumnIndex(column);
     150           0 :     return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)));
     151             : }
     152             : 
     153             : 
     154           0 : sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
     155             : {
     156           0 :     checkColumnIndex(column);
     157           0 :     return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)));
     158             : }
     159             : 
     160             : 
     161           0 : sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
     162             : {
     163           0 :     if ( !m_pTable || !m_pTable->getConnection() )
     164             :     {
     165             :         OSL_FAIL( "OResultSetMetaData::isSearchable: suspicious: called without table or connection!" );
     166           0 :         return sal_False;
     167             :     }
     168             : 
     169           0 :     return sal_True;
     170             : }
     171             : 
     172             : 
     173           0 : sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
     174             : {
     175           0 :     checkColumnIndex(column);
     176           0 :     bool bReadOnly = (m_xColumns->get())[column-1]->getPropertySetInfo()->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)) &&
     177           0 :         ::cppu::any2bool((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)));
     178             : 
     179           0 :     return m_bReadOnly || bReadOnly || OTable::isReadOnly();
     180             : }
     181             : 
     182             : 
     183           0 : sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
     184             : {
     185           0 :     return !isReadOnly(column);
     186             : }
     187             : 
     188           0 : sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
     189             : {
     190           0 :     return !isReadOnly(column);
     191             : }
     192             : 
     193             : 
     194             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11