LCOV - code coverage report
Current view: top level - package/source/zippackage - ZipPackageBuffer.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 56 0.0 %
Date: 2014-04-14 Functions: 0 14 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 <ZipPackageBuffer.hxx>
      21             : #include <string.h>
      22             : 
      23             : using namespace ::com::sun::star;
      24             : using namespace com::sun::star::uno;
      25             : using namespace com::sun::star::io;
      26             : using com::sun::star::lang::IllegalArgumentException;
      27             : 
      28             : #if OSL_DEBUG_LEVEL > 0
      29             : #define THROW_WHERE SAL_WHERE
      30             : #else
      31             : #define THROW_WHERE ""
      32             : #endif
      33             : 
      34           0 : ZipPackageBuffer::ZipPackageBuffer(sal_Int64 nNewBufferSize )
      35             : : m_nBufferSize (nNewBufferSize)
      36             : , m_nEnd(0)
      37             : , m_nCurrent(0)
      38           0 : , m_bMustInitBuffer ( sal_True )
      39             : {
      40           0 : }
      41           0 : ZipPackageBuffer::~ZipPackageBuffer(void)
      42             : {
      43           0 : }
      44             : 
      45           0 : sal_Int32 SAL_CALL ZipPackageBuffer::readBytes( Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
      46             :         throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException, std::exception)
      47             : {
      48           0 :     if (nBytesToRead < 0)
      49           0 :         throw BufferSizeExceededException(THROW_WHERE, *this );
      50             : 
      51           0 :     if (nBytesToRead + m_nCurrent > m_nEnd)
      52           0 :         nBytesToRead = static_cast < sal_Int32 > (m_nEnd - m_nCurrent);
      53             : 
      54           0 :     aData.realloc ( nBytesToRead );
      55           0 :     memcpy(aData.getArray(), m_aBuffer.getConstArray() + m_nCurrent, nBytesToRead);
      56           0 :     m_nCurrent +=nBytesToRead;
      57           0 :     return nBytesToRead;
      58             : }
      59             : 
      60           0 : sal_Int32 SAL_CALL ZipPackageBuffer::readSomeBytes( Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
      61             :         throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException, std::exception)
      62             : {
      63           0 :     return readBytes(aData, nMaxBytesToRead);
      64             : }
      65           0 : void SAL_CALL ZipPackageBuffer::skipBytes( sal_Int32 nBytesToSkip )
      66             :         throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException, std::exception)
      67             : {
      68           0 :     if (nBytesToSkip < 0)
      69           0 :         throw BufferSizeExceededException(THROW_WHERE, *this );
      70             : 
      71           0 :     if (nBytesToSkip + m_nCurrent > m_nEnd)
      72           0 :         nBytesToSkip = static_cast < sal_Int32 > (m_nEnd - m_nCurrent);
      73             : 
      74           0 :     m_nCurrent+=nBytesToSkip;
      75           0 : }
      76           0 : sal_Int32 SAL_CALL ZipPackageBuffer::available(  )
      77             :         throw(NotConnectedException, IOException, RuntimeException, std::exception)
      78             : {
      79           0 :     return static_cast < sal_Int32 > (m_nEnd - m_nCurrent);
      80             : }
      81           0 : void SAL_CALL ZipPackageBuffer::closeInput(  )
      82             :         throw(NotConnectedException, IOException, RuntimeException, std::exception)
      83             : {
      84           0 : }
      85           0 : void SAL_CALL ZipPackageBuffer::writeBytes( const Sequence< sal_Int8 >& aData )
      86             :         throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException, std::exception)
      87             : {
      88           0 :     sal_Int64 nDataLen = aData.getLength(), nCombined = m_nEnd + nDataLen;
      89             : 
      90           0 :     if ( nCombined > m_nBufferSize)
      91             :     {
      92           0 :         do
      93           0 :             m_nBufferSize *=2;
      94           0 :         while (nCombined > m_nBufferSize);
      95           0 :         m_aBuffer.realloc(static_cast < sal_Int32 > (m_nBufferSize));
      96           0 :         m_bMustInitBuffer = sal_False;
      97             :     }
      98           0 :     else if (m_bMustInitBuffer)
      99             :     {
     100           0 :          m_aBuffer.realloc ( static_cast < sal_Int32 > ( m_nBufferSize ) );
     101           0 :         m_bMustInitBuffer = sal_False;
     102             :     }
     103           0 :     memcpy( m_aBuffer.getArray() + m_nCurrent, aData.getConstArray(), static_cast < sal_Int32 > (nDataLen));
     104           0 :     m_nCurrent+=nDataLen;
     105           0 :     if (m_nCurrent>m_nEnd)
     106           0 :         m_nEnd = m_nCurrent;
     107           0 : }
     108           0 : void SAL_CALL ZipPackageBuffer::flush(  )
     109             :         throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException, std::exception)
     110             : {
     111           0 : }
     112           0 : void SAL_CALL ZipPackageBuffer::closeOutput(  )
     113             :         throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException, std::exception)
     114             : {
     115           0 : }
     116           0 : void SAL_CALL ZipPackageBuffer::seek( sal_Int64 location )
     117             :         throw( IllegalArgumentException, IOException, RuntimeException, std::exception)
     118             : {
     119           0 :     if ( location > m_nEnd || location < 0 )
     120           0 :         throw IllegalArgumentException(THROW_WHERE, uno::Reference< uno::XInterface >(), 1 );
     121           0 :     m_nCurrent = location;
     122           0 : }
     123           0 : sal_Int64 SAL_CALL ZipPackageBuffer::getPosition(  )
     124             :         throw(IOException, RuntimeException, std::exception)
     125             : {
     126           0 :     return m_nCurrent;
     127             : }
     128           0 : sal_Int64 SAL_CALL ZipPackageBuffer::getLength(  )
     129             :         throw(IOException, RuntimeException, std::exception)
     130             : {
     131           0 :     return m_nEnd;
     132             : }
     133             : 
     134             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10