LCOV - code coverage report
Current view: top level - connectivity/source/drivers/file - FResultSetMetaData.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 41 63 65.1 %
Date: 2014-11-03 Functions: 17 25 68.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 "file/FResultSetMetaData.hxx"
      21             : #include "file/FTable.hxx"
      22             : #include <comphelper/extract.hxx>
      23             : #include <connectivity/dbexception.hxx>
      24             : #include <comphelper/types.hxx>
      25             : 
      26             : 
      27             : using namespace ::comphelper;
      28             : using namespace connectivity;
      29             : using namespace dbtools;
      30             : using namespace connectivity::file;
      31             : using namespace ::com::sun::star::beans;
      32             : using namespace ::com::sun::star::uno;
      33             : using namespace ::com::sun::star::sdbcx;
      34             : using namespace ::com::sun::star::sdbc;
      35             : using namespace ::com::sun::star::container;
      36             : using namespace ::com::sun::star::lang;
      37             : 
      38             : 
      39          88 : OResultSetMetaData::OResultSetMetaData(const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns,const OUString& _aTableName,OFileTable* _pTable)
      40             :     :m_aTableName(_aTableName)
      41             :     ,m_xColumns(_rxColumns)
      42          88 :     ,m_pTable(_pTable)
      43             : {
      44          88 : }
      45             : 
      46             : 
      47         264 : OResultSetMetaData::~OResultSetMetaData()
      48             : {
      49          88 :     m_xColumns = NULL;
      50         176 : }
      51             : 
      52        4164 : void OResultSetMetaData::checkColumnIndex(sal_Int32 column)  throw(SQLException, RuntimeException)
      53             : {
      54        4164 :     if(column <= 0 || column > (sal_Int32)(sal_Int32)m_xColumns->get().size())
      55           0 :         throwInvalidIndexException(*this);
      56        4164 : }
      57             : 
      58           0 : sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
      59             : {
      60           0 :     return getPrecision(column);
      61             : }
      62             : 
      63             : 
      64        1018 : sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
      65             : {
      66        1018 :     checkColumnIndex(column);
      67        1018 :     return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)));
      68             : }
      69             : 
      70             : 
      71         530 : sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount(  ) throw(SQLException, RuntimeException, std::exception)
      72             : {
      73         530 :     return (m_xColumns->get()).size();
      74             : }
      75             : 
      76             : 
      77           0 : sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
      78             : {
      79           0 :     return sal_False;
      80             : }
      81             : 
      82             : 
      83          62 : OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
      84             : {
      85          62 :     return OUString();
      86             : }
      87             : 
      88             : 
      89        2478 : OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
      90             : {
      91        2478 :     checkColumnIndex(column);
      92             : 
      93        2478 :     Any aName((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)));
      94        2478 :     return aName.hasValue() ? getString(aName) : getString((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)));
      95             : }
      96             : 
      97          62 : OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
      98             : {
      99          62 :     return m_aTableName;
     100             : }
     101             : 
     102          62 : OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
     103             : {
     104          62 :     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        1346 : OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
     114             : {
     115        1346 :     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          68 : sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
     125             : {
     126          68 :     checkColumnIndex(column);
     127          68 :     return getBOOL((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)));
     128             : }
     129             : 
     130             : 
     131          62 : sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 /*setCatalogcolumn*/ ) throw(SQLException, RuntimeException, std::exception)
     132             : {
     133          62 :     return sal_False;
     134             : }
     135             : 
     136         504 : sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
     137             : {
     138         504 :     return sal_True;
     139             : }
     140             : 
     141          34 : sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
     142             : {
     143          34 :     checkColumnIndex(column);
     144          34 :     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         566 : sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
     155             : {
     156         566 :     checkColumnIndex(column);
     157         566 :     return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)));
     158             : }
     159             : 
     160             : 
     161          33 : sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
     162             : {
     163          33 :     return sal_True;
     164             : }
     165             : 
     166             : 
     167           0 : sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
     168             : {
     169           0 :     checkColumnIndex(column);
     170           0 :     return m_pTable->isReadOnly() || (
     171           0 :                             (m_xColumns->get())[column-1]->getPropertySetInfo()->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)) &&
     172           0 :                                 ::cppu::any2bool((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION))));
     173             : }
     174             : 
     175             : 
     176           0 : sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
     177             : {
     178           0 :     return !isReadOnly(column);
     179             : }
     180             : 
     181           0 : sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
     182             : {
     183           0 :     return !isReadOnly(column);
     184             : }
     185             : 
     186             : 
     187             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10