LCOV - code coverage report
Current view: top level - ucb/source/ucp/file - filrow.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 158 0.0 %
Date: 2014-04-14 Functions: 0 41 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 "filrow.hxx"
      21             : #include "shell.hxx"
      22             : #include "prov.hxx"
      23             : #include <com/sun/star/script/Converter.hpp>
      24             : #include <comphelper/processfactory.hxx>
      25             : 
      26             : using namespace fileaccess;
      27             : using namespace com::sun::star;
      28             : using namespace com::sun::star::uno;
      29             : 
      30             : #if OSL_DEBUG_LEVEL > 0
      31             : #define THROW_WHERE SAL_WHERE
      32             : #else
      33             : #define THROW_WHERE ""
      34             : #endif
      35             : 
      36             : // Function for TypeConverting
      37             : 
      38             : template< class _type_ >
      39           0 : sal_Bool convert( shell* pShell,
      40             :                   uno::Reference< script::XTypeConverter >& xConverter,
      41             :                   uno::Any& rValue,
      42             :                   _type_& aReturn  )
      43             : {
      44             :     // Try first without converting
      45           0 :     sal_Bool no_success = ! ( rValue >>= aReturn );
      46             : 
      47           0 :     if ( no_success )
      48             :     {
      49           0 :         if( ! xConverter.is() )
      50             :         {
      51           0 :             xConverter = script::Converter::create(pShell->m_xContext);
      52             :         }
      53             : 
      54             :         try
      55             :         {
      56           0 :             if( rValue.hasValue() )
      57             :             {
      58             :                 uno::Any aConvertedValue
      59           0 :                     = xConverter->convertTo( rValue,getCppuType( static_cast< const _type_* >(0) ) );
      60           0 :                 no_success = ! ( aConvertedValue >>= aReturn );
      61             :             }
      62             :             else
      63           0 :                 no_success = sal_True;
      64             :         }
      65           0 :         catch (const lang::IllegalArgumentException&)
      66             :         {
      67           0 :             no_success = sal_True;
      68             :         }
      69           0 :         catch (const script::CannotConvertException&)
      70             :         {
      71           0 :             no_success = sal_True;
      72             :         }
      73             :     }
      74           0 :     return no_success;
      75             : }
      76             : 
      77             : 
      78           0 : XRow_impl::XRow_impl( shell* pMyShell,const uno::Sequence< uno::Any >& seq )
      79             :     : m_aValueMap( seq ),
      80             :       m_pMyShell( pMyShell ),
      81             :       m_xProvider( pMyShell->m_pProvider ),
      82           0 :       m_xTypeConverter( 0 )
      83             : {
      84           0 : }
      85             : 
      86           0 : XRow_impl::~XRow_impl()
      87             : {
      88           0 : }
      89             : 
      90             : 
      91             : sal_Bool SAL_CALL
      92           0 : XRow_impl::wasNull(
      93             :            void )
      94             :   throw( sdbc::SQLException,
      95             :      uno::RuntimeException, std::exception)
      96             : {
      97           0 :   return m_nWasNull;
      98             : }
      99             : 
     100             : 
     101             : OUString SAL_CALL
     102           0 : XRow_impl::getString(
     103             :              sal_Int32 columnIndex )
     104             :   throw( sdbc::SQLException,
     105             :      uno::RuntimeException, std::exception)
     106             : {
     107           0 :   if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     108           0 :     throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     109           0 :   OUString  Value;
     110           0 :   osl::MutexGuard aGuard( m_aMutex );
     111           0 :   m_nWasNull = ::convert<OUString>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
     112           0 :   return Value;
     113             : }
     114             : 
     115             : sal_Bool SAL_CALL
     116           0 : XRow_impl::getBoolean(
     117             :     sal_Int32 columnIndex )
     118             :     throw( sdbc::SQLException,
     119             :            uno::RuntimeException, std::exception)
     120             : {
     121           0 :     if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     122           0 :         throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     123           0 :     sal_Bool  Value( false );
     124           0 :     osl::MutexGuard aGuard( m_aMutex );
     125           0 :     m_nWasNull = ::convert<sal_Bool>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
     126           0 :     return Value;
     127             : }
     128             : 
     129             : 
     130             : sal_Int8 SAL_CALL
     131           0 : XRow_impl::getByte(
     132             :     sal_Int32 columnIndex )
     133             :     throw( sdbc::SQLException,
     134             :            uno::RuntimeException, std::exception)
     135             : {
     136           0 :     if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     137           0 :         throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     138           0 :     sal_Int8  Value( 0 );
     139           0 :     osl::MutexGuard aGuard( m_aMutex );
     140           0 :     m_nWasNull = ::convert<sal_Int8>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
     141           0 :     return Value;
     142             : }
     143             : 
     144             : sal_Int16 SAL_CALL
     145           0 : XRow_impl::getShort(
     146             :     sal_Int32 columnIndex )
     147             :     throw( sdbc::SQLException,
     148             :            uno::RuntimeException, std::exception)
     149             : {
     150           0 :     if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     151           0 :         throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     152           0 :     sal_Int16  Value( 0 );
     153           0 :     osl::MutexGuard aGuard( m_aMutex );
     154           0 :     m_nWasNull = ::convert<sal_Int16>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
     155           0 :     return Value;
     156             : }
     157             : 
     158             : 
     159             : sal_Int32 SAL_CALL
     160           0 : XRow_impl::getInt(
     161             :           sal_Int32 columnIndex )
     162             :     throw( sdbc::SQLException,
     163             :            uno::RuntimeException, std::exception)
     164             : {
     165           0 :     if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     166           0 :         throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     167           0 :     sal_Int32  Value( 0 );
     168           0 :     osl::MutexGuard aGuard( m_aMutex );
     169           0 :     m_nWasNull = ::convert<sal_Int32>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
     170           0 :     return Value;
     171             : }
     172             : 
     173             : sal_Int64 SAL_CALL
     174           0 : XRow_impl::getLong(
     175             :            sal_Int32 columnIndex )
     176             :   throw( sdbc::SQLException,
     177             :      uno::RuntimeException, std::exception)
     178             : {
     179           0 :     if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     180           0 :         throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     181           0 :     sal_Int64  Value( 0 );
     182           0 :     osl::MutexGuard aGuard( m_aMutex );
     183           0 :     m_nWasNull = ::convert<sal_Int64>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
     184           0 :     return Value;
     185             : }
     186             : 
     187             : float SAL_CALL
     188           0 : XRow_impl::getFloat(
     189             :     sal_Int32 columnIndex )
     190             :     throw( sdbc::SQLException,
     191             :            uno::RuntimeException, std::exception)
     192             : {
     193           0 :     if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     194           0 :         throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     195           0 :     float  Value( 0 );
     196           0 :     osl::MutexGuard aGuard( m_aMutex );
     197           0 :     m_nWasNull = ::convert<float>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
     198           0 :     return Value;
     199             : }
     200             : 
     201             : double SAL_CALL
     202           0 : XRow_impl::getDouble(
     203             :     sal_Int32 columnIndex )
     204             :     throw( sdbc::SQLException,
     205             :            uno::RuntimeException, std::exception)
     206             : {
     207           0 :     if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     208           0 :         throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     209           0 :     double  Value( 0 );
     210           0 :     osl::MutexGuard aGuard( m_aMutex );
     211           0 :     m_nWasNull = ::convert<double>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
     212           0 :     return Value;
     213             : }
     214             : 
     215             : uno::Sequence< sal_Int8 > SAL_CALL
     216           0 : XRow_impl::getBytes(
     217             :     sal_Int32 columnIndex )
     218             :     throw( sdbc::SQLException,
     219             :            uno::RuntimeException, std::exception)
     220             : {
     221           0 :     if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     222           0 :         throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     223           0 :     uno::Sequence< sal_Int8 >  Value(0);
     224           0 :     osl::MutexGuard aGuard( m_aMutex );
     225           0 :     m_nWasNull = ::convert<uno::Sequence< sal_Int8 > >( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
     226           0 :     return Value;
     227             : }
     228             : 
     229             : util::Date SAL_CALL
     230           0 : XRow_impl::getDate(
     231             :     sal_Int32 columnIndex )
     232             :     throw( sdbc::SQLException,
     233             :            uno::RuntimeException, std::exception)
     234             : {
     235           0 :     if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     236           0 :         throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     237           0 :     util::Date  Value;
     238           0 :     osl::MutexGuard aGuard( m_aMutex );
     239           0 :     m_nWasNull = ::convert<util::Date>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
     240           0 :     return Value;
     241             : }
     242             : 
     243             : util::Time SAL_CALL
     244           0 : XRow_impl::getTime(
     245             :     sal_Int32 columnIndex )
     246             :   throw( sdbc::SQLException,
     247             :          uno::RuntimeException, std::exception)
     248             : {
     249           0 :     if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     250           0 :         throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     251           0 :     util::Time  Value;
     252           0 :     osl::MutexGuard aGuard( m_aMutex );
     253           0 :     m_nWasNull = ::convert<util::Time>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
     254           0 :     return Value;
     255             : }
     256             : 
     257             : util::DateTime SAL_CALL
     258           0 : XRow_impl::getTimestamp(
     259             :             sal_Int32 columnIndex )
     260             :   throw( sdbc::SQLException,
     261             :      uno::RuntimeException, std::exception)
     262             : {
     263           0 :   if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     264           0 :     throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     265           0 :   util::DateTime  Value;
     266           0 :   osl::MutexGuard aGuard( m_aMutex );
     267           0 :   m_nWasNull = ::convert<util::DateTime>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
     268           0 :   return Value;
     269             : }
     270             : 
     271             : 
     272             : uno::Reference< io::XInputStream > SAL_CALL
     273           0 : XRow_impl::getBinaryStream(
     274             :                sal_Int32 columnIndex )
     275             :   throw( sdbc::SQLException,
     276             :      uno::RuntimeException, std::exception)
     277             : {
     278           0 :   if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     279           0 :     throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     280           0 :   uno::Reference< io::XInputStream >  Value;
     281           0 :   osl::MutexGuard aGuard( m_aMutex );
     282           0 :   m_nWasNull = ::convert<uno::Reference< io::XInputStream > >( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
     283           0 :   return Value;
     284             : }
     285             : 
     286             : 
     287             : uno::Reference< io::XInputStream > SAL_CALL
     288           0 : XRow_impl::getCharacterStream(
     289             :                   sal_Int32 columnIndex )
     290             :     throw( sdbc::SQLException,
     291             :            uno::RuntimeException, std::exception)
     292             : {
     293           0 :   if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     294           0 :       throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     295           0 :   uno::Reference< io::XInputStream > Value;
     296           0 :   osl::MutexGuard aGuard( m_aMutex );
     297           0 :   m_nWasNull = ::convert< uno::Reference< io::XInputStream> >( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
     298           0 :   return Value;
     299             : }
     300             : 
     301             : 
     302             : uno::Any SAL_CALL
     303           0 : XRow_impl::getObject(
     304             :     sal_Int32 columnIndex,
     305             :     const uno::Reference< container::XNameAccess >& )
     306             :     throw( sdbc::SQLException,
     307             :            uno::RuntimeException, std::exception)
     308             : {
     309           0 :     if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     310           0 :         throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     311           0 :     uno::Any  Value;
     312           0 :     osl::MutexGuard aGuard( m_aMutex );
     313           0 :     m_nWasNull = ::convert<uno::Any>( m_pMyShell,m_xTypeConverter,m_aValueMap[ --columnIndex ],Value );
     314           0 :     return Value;
     315             : }
     316             : 
     317             : uno::Reference< sdbc::XRef > SAL_CALL
     318           0 : XRow_impl::getRef(
     319             :     sal_Int32 columnIndex )
     320             :     throw( sdbc::SQLException,
     321             :            uno::RuntimeException, std::exception)
     322             : {
     323           0 :     if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     324           0 :         throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     325           0 :     uno::Reference< sdbc::XRef > Value;
     326           0 :     osl::MutexGuard aGuard( m_aMutex );
     327             :     m_nWasNull = ::convert<uno::Reference< sdbc::XRef> >( m_pMyShell,
     328             :                                                           m_xTypeConverter,
     329           0 :                                                           m_aValueMap[ --columnIndex ],
     330           0 :                                                           Value );
     331           0 :     return Value;
     332             : }
     333             : 
     334             : uno::Reference< sdbc::XBlob > SAL_CALL
     335           0 : XRow_impl::getBlob(
     336             :            sal_Int32 columnIndex )
     337             :   throw( sdbc::SQLException,
     338             :      uno::RuntimeException, std::exception)
     339             : {
     340           0 :     if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     341           0 :         throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     342           0 :     uno::Reference< sdbc::XBlob > Value;
     343           0 :     osl::MutexGuard aGuard( m_aMutex );
     344             :     m_nWasNull = ::convert<uno::Reference< sdbc::XBlob> >( m_pMyShell,
     345             :                                                            m_xTypeConverter,
     346           0 :                                                            m_aValueMap[ --columnIndex ],
     347           0 :                                                            Value );
     348           0 :     return Value;
     349             : }
     350             : 
     351             : uno::Reference< sdbc::XClob > SAL_CALL
     352           0 : XRow_impl::getClob(
     353             :            sal_Int32 columnIndex )
     354             :   throw( sdbc::SQLException,
     355             :      uno::RuntimeException, std::exception)
     356             : {
     357           0 :     if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     358           0 :         throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     359           0 :     uno::Reference< sdbc::XClob > Value;
     360           0 :     osl::MutexGuard aGuard( m_aMutex );
     361             :     m_nWasNull = ::convert<uno::Reference< sdbc::XClob> >( m_pMyShell,
     362             :                                                            m_xTypeConverter,
     363           0 :                                                            m_aValueMap[ --columnIndex ],
     364           0 :                                                            Value );
     365           0 :     return Value;
     366             : }
     367             : 
     368             : 
     369             : uno::Reference< sdbc::XArray > SAL_CALL
     370           0 : XRow_impl::getArray(
     371             :     sal_Int32 columnIndex )
     372             :     throw( sdbc::SQLException,
     373             :            uno::RuntimeException, std::exception)
     374             : {
     375           0 :     if( columnIndex < 1 || columnIndex > m_aValueMap.getLength() )
     376           0 :         throw sdbc::SQLException( OUString(THROW_WHERE), uno::Reference< uno::XInterface >(), OUString(), 0, uno::Any() );
     377           0 :     uno::Reference< sdbc::XArray > Value;
     378           0 :     osl::MutexGuard aGuard( m_aMutex );
     379             :     m_nWasNull = ::convert<uno::Reference< sdbc::XArray> >( m_pMyShell,
     380             :                                                             m_xTypeConverter,
     381           0 :                                                             m_aValueMap[ --columnIndex ],
     382           0 :                                                             Value );
     383           0 :     return Value;
     384             : }
     385             : 
     386             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10