LCOV - code coverage report
Current view: top level - sc/source/filter/qpro - biff.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 22 23 95.7 %
Date: 2014-04-11 Functions: 3 3 100.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             : 
      21             : #include <sal/config.h>
      22             : #include <stdio.h>
      23             : #include <sfx2/docfile.hxx>
      24             : 
      25             : #include "global.hxx"
      26             : #include "scerrors.hxx"
      27             : #include "docpool.hxx"
      28             : #include "patattr.hxx"
      29             : #include "filter.hxx"
      30             : #include "document.hxx"
      31             : #include "formulacell.hxx"
      32             : #include "biff.hxx"
      33             : 
      34           3 : ScBiffReader::ScBiffReader(SfxMedium& rMedium)
      35             :     : mnId(0)
      36             :     , mnLength(0)
      37             :     , mnOffset(0)
      38           3 :     , mbEndOfFile(false)
      39             : {
      40           3 :     mpStream = rMedium.GetInStream();
      41           3 :     if( mpStream )
      42             :     {
      43           3 :         mpStream->SetBufferSize( 65535 );
      44           3 :         mpStream->SetStreamCharSet( RTL_TEXTENCODING_MS_1252 );
      45             :     }
      46           3 : }
      47             : 
      48           3 : ScBiffReader::~ScBiffReader()
      49             : {
      50           3 :     if( mpStream )
      51           3 :         mpStream->SetBufferSize( 0 );
      52           3 : }
      53             : 
      54       10010 : bool ScBiffReader::nextRecord()
      55             : {
      56       10010 :     if( !recordsLeft() )
      57           2 :         return false;
      58             : 
      59       10008 :     if( IsEndOfFile() )
      60           0 :         return false;
      61             : 
      62       10008 :     sal_uInt32 nPos = mpStream->Tell();
      63       10008 :     if( nPos != mnOffset + mnLength )
      64           2 :         mpStream->Seek( mnOffset + mnLength );
      65             : 
      66       10008 :     mnLength = mnId = 0;
      67       10008 :     mpStream->ReadUInt16( mnId ).ReadUInt16( mnLength );
      68             : 
      69       10008 :     mnOffset = mpStream->Tell();
      70             : #if OSL_DEBUG_LEVEL > 1
      71             :     fprintf( stderr, "Read record 0x%x length 0x%x at offset 0x%x\n",
      72             :         (unsigned)mnId, (unsigned)mnLength, (unsigned)mnOffset );
      73             : 
      74             : #if 1  // rather verbose
      75             :     int len = mnLength;
      76             :     while (len > 0) {
      77             :         int i, chunk = len < 16 ? len : 16;
      78             :         unsigned char data[16];
      79             :         mpStream->Read( data, chunk );
      80             : 
      81             :         for (i = 0; i < chunk; i++)
      82             :             fprintf( stderr, "%.2x ", data[i] );
      83             :         fprintf( stderr, "| " );
      84             :         for (i = 0; i < chunk; i++)
      85             :             fprintf( stderr, "%c", data[i] < 127 && data[i] > 30 ? data[i] : '.' );
      86             :         fprintf( stderr, "\n" );
      87             : 
      88             :         len -= chunk;
      89             :     }
      90             :     mpStream->Seek( mnOffset );
      91             : #endif
      92             : #endif
      93       10008 :     return true;
      94             : }
      95             : 
      96             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10