LCOV - code coverage report
Current view: top level - sc/source/core/tool - rechead.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 73 0.0 %
Date: 2012-08-25 Functions: 0 9 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 62 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                 :            : #include "rechead.hxx"
      30                 :            : #include "scerrors.hxx"
      31                 :            : 
      32                 :            : // STATIC DATA -----------------------------------------------------------
      33                 :            : 
      34                 :            : // =======================================================================
      35                 :            : 
      36                 :          0 : ScMultipleReadHeader::ScMultipleReadHeader(SvStream& rNewStream) :
      37                 :          0 :     rStream( rNewStream )
      38                 :            : {
      39                 :            :     sal_uInt32 nDataSize;
      40         [ #  # ]:          0 :     rStream >> nDataSize;
      41                 :          0 :     sal_uLong nDataPos = rStream.Tell();
      42                 :          0 :     nTotalEnd = nDataPos + nDataSize;
      43                 :          0 :     nEntryEnd = nTotalEnd;
      44                 :            : 
      45         [ #  # ]:          0 :     rStream.SeekRel(nDataSize);
      46                 :            :     sal_uInt16 nID;
      47         [ #  # ]:          0 :     rStream >> nID;
      48         [ #  # ]:          0 :     if (nID != SCID_SIZES)
      49                 :            :     {
      50                 :            :         OSL_FAIL("SCID_SIZES nicht gefunden");
      51         [ #  # ]:          0 :         if ( rStream.GetError() == SVSTREAM_OK )
      52         [ #  # ]:          0 :             rStream.SetError( SVSTREAM_FILEFORMAT_ERROR );
      53                 :            : 
      54                 :            :         //  alles auf 0, damit BytesLeft() wenigstens abbricht
      55                 :          0 :         pBuf = NULL; pMemStream = NULL;
      56                 :          0 :         nEntryEnd = nDataPos;
      57                 :            :     }
      58                 :            :     else
      59                 :            :     {
      60                 :            :         sal_uInt32 nSizeTableLen;
      61         [ #  # ]:          0 :         rStream >> nSizeTableLen;
      62         [ #  # ]:          0 :         pBuf = new sal_uInt8[nSizeTableLen];
      63         [ #  # ]:          0 :         rStream.Read( pBuf, nSizeTableLen );
      64 [ #  # ][ #  # ]:          0 :         pMemStream = new SvMemoryStream( (char*)pBuf, nSizeTableLen, STREAM_READ );
      65                 :            :     }
      66                 :            : 
      67                 :          0 :     nEndPos = rStream.Tell();
      68         [ #  # ]:          0 :     rStream.Seek( nDataPos );
      69                 :          0 : }
      70                 :            : 
      71                 :          0 : ScMultipleReadHeader::~ScMultipleReadHeader()
      72                 :            : {
      73 [ #  # ][ #  # ]:          0 :     if ( pMemStream && pMemStream->Tell() != pMemStream->GetEndOfData() )
                 [ #  # ]
      74                 :            :     {
      75                 :            :         OSL_FAIL( "Sizes nicht vollstaendig gelesen" );
      76         [ #  # ]:          0 :         if ( rStream.GetError() == SVSTREAM_OK )
      77                 :          0 :             rStream.SetError( SCWARN_IMPORT_INFOLOST );
      78                 :            :     }
      79         [ #  # ]:          0 :     delete pMemStream;
      80         [ #  # ]:          0 :     delete[] pBuf;
      81                 :            : 
      82                 :          0 :     rStream.Seek(nEndPos);
      83                 :          0 : }
      84                 :            : 
      85                 :          0 : void ScMultipleReadHeader::EndEntry()
      86                 :            : {
      87                 :          0 :     sal_uLong nPos = rStream.Tell();
      88                 :            :     OSL_ENSURE( nPos <= nEntryEnd, "zuviel gelesen" );
      89         [ #  # ]:          0 :     if ( nPos != nEntryEnd )
      90                 :            :     {
      91         [ #  # ]:          0 :         if ( rStream.GetError() == SVSTREAM_OK )
      92                 :          0 :             rStream.SetError( SCWARN_IMPORT_INFOLOST );
      93                 :          0 :         rStream.Seek( nEntryEnd );          // Rest ueberspringen
      94                 :            :     }
      95                 :            : 
      96                 :          0 :     nEntryEnd = nTotalEnd;          // den ganzen Rest, wenn kein StartEntry kommt
      97                 :          0 : }
      98                 :            : 
      99                 :          0 : void ScMultipleReadHeader::StartEntry()
     100                 :            : {
     101                 :          0 :     sal_uLong nPos = rStream.Tell();
     102                 :            :     sal_uInt32 nEntrySize;
     103         [ #  # ]:          0 :     (*pMemStream) >> nEntrySize;
     104                 :            : 
     105                 :          0 :     nEntryEnd = nPos + nEntrySize;
     106                 :            :     OSL_ENSURE( nEntryEnd <= nTotalEnd, "zuviele Eintraege gelesen" );
     107                 :          0 : }
     108                 :            : 
     109                 :          0 : sal_uLong ScMultipleReadHeader::BytesLeft() const
     110                 :            : {
     111                 :          0 :     sal_uLong nReadEnd = rStream.Tell();
     112         [ #  # ]:          0 :     if (nReadEnd <= nEntryEnd)
     113                 :          0 :         return nEntryEnd-nReadEnd;
     114                 :            : 
     115                 :            :     OSL_FAIL("Fehler bei ScMultipleReadHeader::BytesLeft");
     116                 :          0 :     return 0;
     117                 :            : }
     118                 :            : 
     119                 :            : // -----------------------------------------------------------------------
     120                 :            : 
     121                 :          0 : ScMultipleWriteHeader::ScMultipleWriteHeader(SvStream& rNewStream, sal_uInt32 nDefault) :
     122                 :            :     rStream( rNewStream ),
     123                 :          0 :     aMemStream( 4096, 4096 )
     124                 :            : {
     125                 :          0 :     nDataSize = nDefault;
     126         [ #  # ]:          0 :     rStream << nDataSize;
     127                 :            : 
     128                 :          0 :     nDataPos = rStream.Tell();
     129                 :          0 :     nEntryStart = nDataPos;
     130                 :          0 : }
     131                 :            : 
     132                 :          0 : ScMultipleWriteHeader::~ScMultipleWriteHeader()
     133                 :            : {
     134                 :          0 :     sal_uLong nDataEnd = rStream.Tell();
     135                 :            : 
     136         [ #  # ]:          0 :     rStream << (sal_uInt16) SCID_SIZES;
     137         [ #  # ]:          0 :     rStream << static_cast<sal_uInt32>(aMemStream.Tell());
     138 [ #  # ][ #  # ]:          0 :     rStream.Write( aMemStream.GetData(), aMemStream.Tell() );
     139                 :            : 
     140         [ #  # ]:          0 :     if ( nDataEnd - nDataPos != nDataSize )                 // Default getroffen?
     141                 :            :     {
     142                 :          0 :         nDataSize = nDataEnd - nDataPos;
     143                 :          0 :         sal_uLong nPos = rStream.Tell();
     144         [ #  # ]:          0 :         rStream.Seek(nDataPos-sizeof(sal_uInt32));
     145         [ #  # ]:          0 :         rStream << nDataSize;                               // Groesse am Anfang eintragen
     146         [ #  # ]:          0 :         rStream.Seek(nPos);
     147                 :            :     }
     148                 :          0 : }
     149                 :            : 
     150                 :          0 : void ScMultipleWriteHeader::EndEntry()
     151                 :            : {
     152                 :          0 :     sal_uLong nPos = rStream.Tell();
     153                 :          0 :     aMemStream << static_cast<sal_uInt32>(nPos - nEntryStart);
     154                 :          0 : }
     155                 :            : 
     156                 :          0 : void ScMultipleWriteHeader::StartEntry()
     157                 :            : {
     158                 :          0 :     sal_uLong nPos = rStream.Tell();
     159                 :          0 :     nEntryStart = nPos;
     160                 :          0 : }
     161                 :            : 
     162                 :            : 
     163                 :            : 
     164                 :            : 
     165                 :            : 
     166                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10