LCOV - code coverage report
Current view: top level - libreoffice/connectivity/source/drivers/file - FResultSetMetaData.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 63 0.0 %
Date: 2012-12-27 Functions: 0 25 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 "file/FResultSetMetaData.hxx"
      21             : #include "file/FTable.hxx"
      22             : #include <comphelper/extract.hxx>
      23             : #include "connectivity/dbexception.hxx"
      24             : #include <comphelper/types.hxx>
      25             : #include <rtl/logfile.hxx>
      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           0 : OResultSetMetaData::OResultSetMetaData(const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns,const ::rtl::OUString& _aTableName,OFileTable* _pTable)
      40             :     :m_aTableName(_aTableName)
      41             :     ,m_xColumns(_rxColumns)
      42           0 :     ,m_pTable(_pTable)
      43             : {
      44             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::OResultSetMetaData" );
      45           0 : }
      46             : 
      47             : // -------------------------------------------------------------------------
      48           0 : OResultSetMetaData::~OResultSetMetaData()
      49             : {
      50           0 :     m_xColumns = NULL;
      51           0 : }
      52             : // -----------------------------------------------------------------------------
      53           0 : void OResultSetMetaData::checkColumnIndex(sal_Int32 column)  throw(SQLException, RuntimeException)
      54             : {
      55             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::checkColumnIndex" );
      56           0 :     if(column <= 0 || column > (sal_Int32)(sal_Int32)m_xColumns->get().size())
      57           0 :         throwInvalidIndexException(*this);
      58           0 : }
      59             : // -------------------------------------------------------------------------
      60           0 : sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException)
      61             : {
      62             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnDisplaySize" );
      63           0 :     return getPrecision(column);
      64             : }
      65             : // -------------------------------------------------------------------------
      66             : 
      67           0 : sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException)
      68             : {
      69             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnType" );
      70           0 :     checkColumnIndex(column);
      71           0 :     return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)));
      72             : }
      73             : // -------------------------------------------------------------------------
      74             : 
      75           0 : sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount(  ) throw(SQLException, RuntimeException)
      76             : {
      77             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnCount" );
      78           0 :     return (m_xColumns->get()).size();
      79             : }
      80             : // -------------------------------------------------------------------------
      81             : 
      82           0 : sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
      83             : {
      84             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isCaseSensitive" );
      85           0 :     return sal_False;
      86             : }
      87             : // -------------------------------------------------------------------------
      88             : 
      89           0 : ::rtl::OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
      90             : {
      91             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getSchemaName" );
      92           0 :     return ::rtl::OUString();
      93             : }
      94             : // -------------------------------------------------------------------------
      95             : 
      96           0 : ::rtl::OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException)
      97             : {
      98             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnName" );
      99           0 :     checkColumnIndex(column);
     100             : 
     101           0 :     Any aName((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)));
     102           0 :     return aName.hasValue() ? getString(aName) : getString((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)));
     103             : }
     104             : // -------------------------------------------------------------------------
     105           0 : ::rtl::OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
     106             : {
     107             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getTableName" );
     108           0 :     return m_aTableName;
     109             : }
     110             : // -------------------------------------------------------------------------
     111           0 : ::rtl::OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
     112             : {
     113             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getCatalogName" );
     114           0 :     return ::rtl::OUString();
     115             : }
     116             : // -------------------------------------------------------------------------
     117           0 : ::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException)
     118             : {
     119             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnTypeName" );
     120           0 :     checkColumnIndex(column);
     121           0 :     return getString((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)));
     122             : }
     123             : // -------------------------------------------------------------------------
     124           0 : ::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException)
     125             : {
     126             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnLabel" );
     127           0 :     return getColumnName(column);
     128             : }
     129             : // -------------------------------------------------------------------------
     130           0 : ::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
     131             : {
     132             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnServiceName" );
     133           0 :     return ::rtl::OUString();
     134             : }
     135             : // -------------------------------------------------------------------------
     136             : 
     137           0 : sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException)
     138             : {
     139             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isCurrency" );
     140           0 :     checkColumnIndex(column);
     141           0 :     return getBOOL((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)));
     142             : }
     143             : // -------------------------------------------------------------------------
     144             : 
     145           0 : sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 /*setCatalogcolumn*/ ) throw(SQLException, RuntimeException)
     146             : {
     147             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isAutoIncrement" );
     148           0 :     return sal_False;
     149             : }
     150             : // -------------------------------------------------------------------------
     151           0 : sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
     152             : {
     153             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isSigned" );
     154           0 :     return sal_True;
     155             : }
     156             : // -------------------------------------------------------------------------
     157           0 : sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException)
     158             : {
     159             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getPrecision" );
     160           0 :     checkColumnIndex(column);
     161           0 :     return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)));
     162             : }
     163             : // -------------------------------------------------------------------------
     164           0 : sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
     165             : {
     166             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getScale" );
     167           0 :     checkColumnIndex(column);
     168           0 :     return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)));
     169             : }
     170             : // -------------------------------------------------------------------------
     171             : 
     172           0 : sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
     173             : {
     174             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isNullable" );
     175           0 :     checkColumnIndex(column);
     176           0 :     return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)));
     177             : }
     178             : // -------------------------------------------------------------------------
     179             : 
     180           0 : sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
     181             : {
     182             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isSearchable" );
     183           0 :     return sal_True;
     184             : }
     185             : // -------------------------------------------------------------------------
     186             : 
     187           0 : sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException)
     188             : {
     189             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isReadOnly" );
     190           0 :     checkColumnIndex(column);
     191           0 :     return m_pTable->isReadOnly() || (
     192           0 :                             (m_xColumns->get())[column-1]->getPropertySetInfo()->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)) &&
     193           0 :                                 ::cppu::any2bool((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION))));
     194             : }
     195             : // -------------------------------------------------------------------------
     196             : 
     197           0 : sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
     198             : {
     199             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isDefinitelyWritable" );
     200           0 :     return !isReadOnly(column);
     201             : }
     202             : // -------------------------------------------------------------------------
     203           0 : sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
     204             : {
     205             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isWritable" );
     206           0 :     return !isReadOnly(column);
     207             : }
     208             : // -------------------------------------------------------------------------
     209             : 
     210             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10