LCOV - code coverage report
Current view: top level - svl/source/numbers - numhead.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 62 0.0 %
Date: 2014-04-14 Functions: 0 9 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 <tools/debug.hxx>
      21             : 
      22             : #include "numhead.hxx"
      23             : 
      24             : // ID's for files:
      25             : #define SV_NUMID_SIZES                      0x4200
      26             : 
      27             : //#pragma SEG_FUNCDEF(numhead_06)
      28             : 
      29             : //! Synchronous with Skip()
      30           0 : ImpSvNumMultipleReadHeader::ImpSvNumMultipleReadHeader(SvStream& rNewStream) :
      31           0 :     rStream( rNewStream )
      32             : {
      33             :     sal_uInt32 nDataSize;
      34           0 :     rStream.ReadUInt32( nDataSize );
      35           0 :     sal_uLong nDataPos = rStream.Tell();
      36           0 :     nEntryEnd = nDataPos;
      37             : 
      38           0 :     rStream.SeekRel(nDataSize);
      39             :     sal_uInt16 nID;
      40           0 :     rStream.ReadUInt16( nID );
      41           0 :     if (nID != SV_NUMID_SIZES)
      42             :     {
      43             :         OSL_FAIL("SV_NUMID_SIZES not found");
      44             :     }
      45             :     sal_uInt32 nSizeTableLen;
      46           0 :     rStream.ReadUInt32( nSizeTableLen );
      47           0 :     pBuf = new char[nSizeTableLen];
      48           0 :     rStream.Read( pBuf, nSizeTableLen );
      49           0 :     pMemStream = new SvMemoryStream( pBuf, nSizeTableLen, STREAM_READ );
      50             : 
      51           0 :     nEndPos = rStream.Tell();
      52           0 :     rStream.Seek( nDataPos );
      53           0 : }
      54             : 
      55             : //#pragma SEG_FUNCDEF(numhead_07)
      56             : 
      57           0 : ImpSvNumMultipleReadHeader::~ImpSvNumMultipleReadHeader()
      58             : {
      59             :     DBG_ASSERT( pMemStream->Tell() == pMemStream->GetEndOfData(),
      60             :                 "Sizes not completely read" );
      61           0 :     delete pMemStream;
      62           0 :     delete [] pBuf;
      63             : 
      64           0 :     rStream.Seek(nEndPos);
      65           0 : }
      66             : 
      67             : //#pragma SEG_FUNCDEF(numhead_08)
      68             : 
      69           0 : void ImpSvNumMultipleReadHeader::EndEntry()
      70             : {
      71           0 :     sal_uLong nPos = rStream.Tell();
      72             :     DBG_ASSERT( nPos <= nEntryEnd, "Read too much" );
      73           0 :     if ( nPos != nEntryEnd )
      74           0 :         rStream.Seek( nEntryEnd ); // Skip the rest
      75           0 : }
      76             : 
      77             : //#pragma SEG_FUNCDEF(numhead_0d)
      78             : 
      79           0 : void ImpSvNumMultipleReadHeader::StartEntry()
      80             : {
      81           0 :     sal_uLong nPos = rStream.Tell();
      82             :     sal_uInt32 nEntrySize;
      83           0 :     (*pMemStream).ReadUInt32( nEntrySize );
      84             : 
      85           0 :     nEntryEnd = nPos + nEntrySize;
      86           0 : }
      87             : 
      88             : //#pragma SEG_FUNCDEF(numhead_09)
      89             : 
      90           0 : sal_uLong ImpSvNumMultipleReadHeader::BytesLeft() const
      91             : {
      92           0 :     sal_uLong nReadEnd = rStream.Tell();
      93           0 :     if (nReadEnd <= nEntryEnd)
      94           0 :         return nEntryEnd-nReadEnd;
      95             : 
      96             :     OSL_FAIL("Error in ImpSvNumMultipleReadHeader::BytesLeft");
      97           0 :     return 0;
      98             : }
      99             : 
     100             : 
     101             : //#pragma SEG_FUNCDEF(numhead_0a)
     102             : 
     103           0 : ImpSvNumMultipleWriteHeader::ImpSvNumMultipleWriteHeader(SvStream& rNewStream,
     104             :                                                    sal_uLong nDefault) :
     105             :     rStream( rNewStream ),
     106           0 :     aMemStream( 4096, 4096 )
     107             : {
     108           0 :     nDataSize = nDefault;
     109           0 :     rStream.WriteUInt32( nDataSize );
     110             : 
     111           0 :     nDataPos = rStream.Tell();
     112           0 :     nEntryStart = nDataPos;
     113           0 : }
     114             : 
     115             : //#pragma SEG_FUNCDEF(numhead_0b)
     116             : 
     117           0 : ImpSvNumMultipleWriteHeader::~ImpSvNumMultipleWriteHeader()
     118             : {
     119           0 :     sal_uLong nDataEnd = rStream.Tell();
     120             : 
     121           0 :     rStream.WriteUInt16( (sal_uInt16) SV_NUMID_SIZES );
     122           0 :     rStream.WriteUInt32( static_cast<sal_uInt32>(aMemStream.Tell()) );
     123           0 :     rStream.Write( aMemStream.GetData(), aMemStream.Tell() );
     124             : 
     125           0 :     if ( nDataEnd - nDataPos != nDataSize ) // Hit Default?
     126             :     {
     127           0 :         nDataSize = nDataEnd - nDataPos;
     128           0 :         sal_uLong nPos = rStream.Tell();
     129           0 :         rStream.Seek(nDataPos-sizeof(sal_uInt32));
     130           0 :         rStream.WriteUInt32( nDataSize ); // Add size at the start
     131           0 :         rStream.Seek(nPos);
     132             :     }
     133           0 : }
     134             : 
     135             : //#pragma SEG_FUNCDEF(numhead_0c)
     136             : 
     137           0 : void ImpSvNumMultipleWriteHeader::EndEntry()
     138             : {
     139           0 :     sal_uLong nPos = rStream.Tell();
     140           0 :     aMemStream.WriteUInt32( static_cast<sal_uInt32>(nPos - nEntryStart) );
     141           0 : }
     142             : 
     143             : //#pragma SEG_FUNCDEF(numhead_0e)
     144             : 
     145           0 : void ImpSvNumMultipleWriteHeader::StartEntry()
     146             : {
     147           0 :     sal_uLong nPos = rStream.Tell();
     148           0 :     nEntryStart = nPos;
     149           0 : }
     150             : 
     151             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10