LCOV - code coverage report
Current view: top level - xmlhelp/source/cxxhelp/provider - inputstream.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 65 0.0 %
Date: 2012-08-25 Functions: 0 15 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 78 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "inputstream.hxx"
      31                 :            : 
      32                 :            : 
      33                 :            : using namespace chelp;
      34                 :            : using namespace com::sun::star;
      35                 :            : using namespace com::sun::star::ucb;
      36                 :            : 
      37                 :            : 
      38                 :            : 
      39                 :          0 : XInputStream_impl::XInputStream_impl( const rtl::OUString& aUncPath )
      40                 :            :     : m_bIsOpen( false ),
      41                 :          0 :       m_aFile( aUncPath )
      42                 :            : {
      43         [ #  # ]:          0 :     m_bIsOpen = ( osl::FileBase::E_None == m_aFile.open( osl_File_OpenFlag_Read ) );
      44                 :          0 : }
      45                 :            : 
      46                 :            : 
      47         [ #  # ]:          0 : XInputStream_impl::~XInputStream_impl()
      48                 :            : {
      49         [ #  # ]:          0 :     closeInput();
      50         [ #  # ]:          0 : }
      51                 :            : 
      52                 :            : 
      53                 :          0 : bool SAL_CALL XInputStream_impl::CtorSuccess()
      54                 :            : {
      55                 :          0 :     return m_bIsOpen;
      56                 :            : };
      57                 :            : 
      58                 :            : 
      59                 :            : uno::Any SAL_CALL
      60                 :          0 : XInputStream_impl::queryInterface(
      61                 :            :     const uno::Type& rType )
      62                 :            :     throw( uno::RuntimeException)
      63                 :            : {
      64                 :            :     uno::Any aRet = cppu::queryInterface( rType,
      65                 :            :                                           (static_cast< io::XInputStream* >(this)),
      66         [ #  # ]:          0 :                                           (static_cast< io::XSeekable* >(this)) );
      67 [ #  # ][ #  # ]:          0 :     return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
      68                 :            : }
      69                 :            : 
      70                 :            : 
      71                 :            : void SAL_CALL
      72                 :          0 : XInputStream_impl::acquire(
      73                 :            :     void )
      74                 :            :     throw()
      75                 :            : {
      76                 :          0 :     OWeakObject::acquire();
      77                 :          0 : }
      78                 :            : 
      79                 :            : 
      80                 :            : void SAL_CALL
      81                 :          0 : XInputStream_impl::release(
      82                 :            :     void )
      83                 :            :     throw()
      84                 :            : {
      85                 :          0 :     OWeakObject::release();
      86                 :          0 : }
      87                 :            : 
      88                 :            : 
      89                 :            : 
      90                 :            : sal_Int32 SAL_CALL
      91                 :          0 : XInputStream_impl::readBytes(
      92                 :            :                  uno::Sequence< sal_Int8 >& aData,
      93                 :            :                  sal_Int32 nBytesToRead )
      94                 :            :     throw( io::NotConnectedException,
      95                 :            :            io::BufferSizeExceededException,
      96                 :            :            io::IOException,
      97                 :            :            uno::RuntimeException)
      98                 :            : {
      99         [ #  # ]:          0 :     if( ! m_bIsOpen )
     100         [ #  # ]:          0 :         throw io::IOException();
     101                 :            : 
     102         [ #  # ]:          0 :     aData.realloc(nBytesToRead);
     103                 :            :     //TODO! translate memory exhaustion (if it were detectable...) into
     104                 :            :     // io::BufferSizeExceededException
     105                 :            : 
     106                 :            :     sal_uInt64 nrc;
     107 [ #  # ][ #  # ]:          0 :     m_aFile.read( aData.getArray(),sal_uInt64(nBytesToRead),nrc );
     108                 :            : 
     109                 :            :     // Shrink aData in case we read less than nBytesToRead (XInputStream
     110                 :            :     // documentation does not tell whether this is required, and I do not know
     111                 :            :     // if any code relies on this, so be conservative---SB):
     112         [ #  # ]:          0 :     if (nrc != sal::static_int_cast<sal_uInt64>( nBytesToRead) )
     113         [ #  # ]:          0 :         aData.realloc(sal_Int32(nrc));
     114                 :          0 :     return ( sal_Int32 ) nrc;
     115                 :            : }
     116                 :            : 
     117                 :            : sal_Int32 SAL_CALL
     118                 :          0 : XInputStream_impl::readSomeBytes(
     119                 :            :     uno::Sequence< sal_Int8 >& aData,
     120                 :            :     sal_Int32 nMaxBytesToRead )
     121                 :            :     throw( io::NotConnectedException,
     122                 :            :            io::BufferSizeExceededException,
     123                 :            :            io::IOException,
     124                 :            :            uno::RuntimeException)
     125                 :            : {
     126                 :          0 :     return readBytes( aData,nMaxBytesToRead );
     127                 :            : }
     128                 :            : 
     129                 :            : 
     130                 :            : void SAL_CALL
     131                 :          0 : XInputStream_impl::skipBytes(
     132                 :            :     sal_Int32 nBytesToSkip )
     133                 :            :     throw( io::NotConnectedException,
     134                 :            :            io::BufferSizeExceededException,
     135                 :            :            io::IOException,
     136                 :            :            uno::RuntimeException)
     137                 :            : {
     138         [ #  # ]:          0 :     if (m_aFile.setPos(osl_Pos_Current, sal_uInt64(nBytesToSkip)) != osl::FileBase::E_None)
     139                 :            :     {
     140                 :            :         throw io::IOException(::rtl::OUString(
     141 [ #  # ][ #  # ]:          0 :             RTL_CONSTASCII_USTRINGPARAM("XInputStream_impl::skipBytes failed seek")), uno::Reference< uno::XInterface >());
     142                 :            :     }
     143                 :          0 : }
     144                 :            : 
     145                 :            : 
     146                 :            : sal_Int32 SAL_CALL
     147                 :          0 : XInputStream_impl::available(
     148                 :            :     void )
     149                 :            :     throw( io::NotConnectedException,
     150                 :            :            io::IOException,
     151                 :            :            uno::RuntimeException)
     152                 :            : {
     153                 :          0 :     return 0;
     154                 :            : }
     155                 :            : 
     156                 :            : 
     157                 :            : void SAL_CALL
     158                 :          0 : XInputStream_impl::closeInput(
     159                 :            :     void )
     160                 :            :     throw( io::NotConnectedException,
     161                 :            :            io::IOException,
     162                 :            :            uno::RuntimeException )
     163                 :            : {
     164         [ #  # ]:          0 :     if( m_bIsOpen )
     165                 :            :     {
     166                 :          0 :         osl::FileBase::RC err = m_aFile.close();
     167         [ #  # ]:          0 :         if( err != osl::FileBase::E_None )
     168         [ #  # ]:          0 :             throw io::IOException();
     169                 :          0 :         m_bIsOpen = false;
     170                 :            :     }
     171                 :          0 : }
     172                 :            : 
     173                 :            : 
     174                 :            : void SAL_CALL
     175                 :          0 : XInputStream_impl::seek(
     176                 :            :     sal_Int64 location )
     177                 :            :     throw( lang::IllegalArgumentException,
     178                 :            :            io::IOException,
     179                 :            :            uno::RuntimeException )
     180                 :            : {
     181         [ #  # ]:          0 :     if( location < 0 )
     182         [ #  # ]:          0 :         throw lang::IllegalArgumentException();
     183         [ #  # ]:          0 :     if( osl::FileBase::E_None != m_aFile.setPos( osl_Pos_Absolut, sal_uInt64( location ) ) )
     184         [ #  # ]:          0 :         throw io::IOException();
     185                 :          0 : }
     186                 :            : 
     187                 :            : 
     188                 :            : sal_Int64 SAL_CALL
     189                 :          0 : XInputStream_impl::getPosition(
     190                 :            :     void )
     191                 :            :     throw( io::IOException,
     192                 :            :            uno::RuntimeException )
     193                 :            : {
     194                 :            :     sal_uInt64 uPos;
     195 [ #  # ][ #  # ]:          0 :     if( osl::FileBase::E_None != m_aFile.getPos( uPos ) )
     196         [ #  # ]:          0 :         throw io::IOException();
     197                 :          0 :     return sal_Int64( uPos );
     198                 :            : }
     199                 :            : 
     200                 :            : sal_Int64 SAL_CALL
     201                 :          0 : XInputStream_impl::getLength(
     202                 :            :     void )
     203                 :            :     throw( io::IOException,
     204                 :            :            uno::RuntimeException )
     205                 :            : {
     206                 :            :     osl::FileBase::RC   err;
     207                 :            :     sal_uInt64          uCurrentPos, uEndPos;
     208                 :            : 
     209         [ #  # ]:          0 :     err = m_aFile.getPos( uCurrentPos );
     210         [ #  # ]:          0 :     if( err != osl::FileBase::E_None )
     211         [ #  # ]:          0 :         throw io::IOException();
     212                 :            : 
     213         [ #  # ]:          0 :     err = m_aFile.setPos( osl_Pos_End, 0 );
     214         [ #  # ]:          0 :     if( err != osl::FileBase::E_None )
     215         [ #  # ]:          0 :         throw io::IOException();
     216                 :            : 
     217         [ #  # ]:          0 :     err = m_aFile.getPos( uEndPos );
     218         [ #  # ]:          0 :     if( err != osl::FileBase::E_None )
     219         [ #  # ]:          0 :         throw io::IOException();
     220                 :            : 
     221         [ #  # ]:          0 :     err = m_aFile.setPos( osl_Pos_Absolut, uCurrentPos );
     222         [ #  # ]:          0 :     if( err != osl::FileBase::E_None )
     223         [ #  # ]:          0 :         throw io::IOException();
     224                 :            :     else
     225                 :          0 :         return sal_Int64( uEndPos );
     226                 :            : }
     227                 :            : 
     228                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10