LCOV - code coverage report
Current view: top level - unotools/source/streaming - streamhelper.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 55 0.0 %
Date: 2014-04-14 Functions: 0 10 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 <unotools/streamhelper.hxx>
      21             : 
      22             : namespace utl
      23             : {
      24             : 
      25           0 : void SAL_CALL OInputStreamHelper::acquire() throw ()
      26             : {
      27           0 :     InputStreamHelper_Base::acquire();
      28           0 : }
      29             : 
      30           0 : void SAL_CALL OInputStreamHelper::release() throw ()
      31             : {
      32           0 :     InputStreamHelper_Base::release();
      33           0 : }
      34             : 
      35           0 : sal_Int32 SAL_CALL OInputStreamHelper::readBytes(staruno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead)
      36             :     throw(stario::NotConnectedException, stario::BufferSizeExceededException, stario::IOException, staruno::RuntimeException, std::exception)
      37             : {
      38           0 :     if (!m_xLockBytes.Is())
      39           0 :         throw stario::NotConnectedException(OUString(), static_cast<staruno::XWeak*>(this));
      40             : 
      41           0 :     if (nBytesToRead < 0)
      42           0 :         throw stario::BufferSizeExceededException(OUString(), static_cast<staruno::XWeak*>(this));
      43             : 
      44           0 :     ::osl::MutexGuard aGuard( m_aMutex );
      45           0 :     aData.realloc(nBytesToRead);
      46             : 
      47           0 :     sal_Size nRead(0);
      48           0 :     ErrCode nError = m_xLockBytes->ReadAt(m_nActPos, (void*)aData.getArray(), nBytesToRead, &nRead);
      49           0 :     m_nActPos += nRead;
      50             : 
      51           0 :     if (nError != ERRCODE_NONE)
      52           0 :         throw stario::IOException(OUString(), static_cast<staruno::XWeak*>(this));
      53             : 
      54             :     // adjust sequence if data read is lower than the desired data
      55           0 :     if (nRead < (sal_uInt32)nBytesToRead)
      56           0 :         aData.realloc( nRead );
      57             : 
      58           0 :     return nRead;
      59             : }
      60             : 
      61           0 : void SAL_CALL OInputStreamHelper::seek( sal_Int64 location ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception)
      62             : {
      63           0 :     ::osl::MutexGuard aGuard( m_aMutex );
      64           0 :     m_nActPos = location;
      65           0 : }
      66             : 
      67           0 : sal_Int64 SAL_CALL OInputStreamHelper::getPosition(  ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception)
      68             : {
      69           0 :     return m_nActPos;
      70             : }
      71             : 
      72           0 : sal_Int64 SAL_CALL OInputStreamHelper::getLength(  ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception)
      73             : {
      74           0 :     if (!m_xLockBytes.Is())
      75           0 :         return 0;
      76             : 
      77           0 :     ::osl::MutexGuard aGuard( m_aMutex );
      78           0 :     SvLockBytesStat aStat;
      79           0 :     m_xLockBytes->Stat( &aStat, SVSTATFLAG_DEFAULT );
      80           0 :     return aStat.nSize;
      81             : }
      82             : 
      83           0 : sal_Int32 SAL_CALL OInputStreamHelper::readSomeBytes(staruno::Sequence< sal_Int8 >& aData,
      84             :                                                      sal_Int32 nMaxBytesToRead)
      85             :     throw (stario::NotConnectedException, stario::BufferSizeExceededException, stario::IOException, staruno::RuntimeException, std::exception)
      86             : {
      87             :     // read all data desired
      88           0 :     return readBytes(aData, nMaxBytesToRead);
      89             : }
      90             : 
      91           0 : void SAL_CALL OInputStreamHelper::skipBytes(sal_Int32 nBytesToSkip)
      92             :     throw (stario::NotConnectedException, stario::BufferSizeExceededException, stario::IOException, staruno::RuntimeException, std::exception)
      93             : {
      94           0 :     ::osl::MutexGuard aGuard( m_aMutex );
      95           0 :     if (!m_xLockBytes.Is())
      96           0 :         throw stario::NotConnectedException(OUString(), static_cast<staruno::XWeak*>(this));
      97             : 
      98           0 :     if (nBytesToSkip < 0)
      99           0 :         throw stario::BufferSizeExceededException(OUString(), static_cast<staruno::XWeak*>(this));
     100             : 
     101           0 :     m_nActPos += nBytesToSkip;
     102           0 : }
     103             : 
     104           0 : sal_Int32 SAL_CALL OInputStreamHelper::available()
     105             :     throw (stario::NotConnectedException, stario::IOException, staruno::RuntimeException, std::exception)
     106             : {
     107           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     108           0 :     if (!m_xLockBytes.Is())
     109           0 :         throw stario::NotConnectedException(OUString(), static_cast<staruno::XWeak*>(this));
     110             : 
     111           0 :     return m_nAvailable;
     112             : }
     113             : 
     114           0 : void SAL_CALL OInputStreamHelper::closeInput()
     115             :     throw (stario::NotConnectedException, stario::IOException, staruno::RuntimeException, std::exception)
     116             : {
     117           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     118           0 :     if (!m_xLockBytes.Is())
     119           0 :         throw stario::NotConnectedException(OUString(), static_cast<staruno::XWeak*>(this));
     120             : 
     121           0 :     m_xLockBytes = NULL;
     122           0 : }
     123             : 
     124             : } // namespace utl
     125             : 
     126             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10