Update ooo320-m1
[ooovba.git] / sc / source / filter / qpro / biff.cxx
blob0d0beaa5ddb1f9ee9ec9c2a3214ada3d0c733ba4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: biff.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #include <sal/config.h>
35 #include <stdio.h>
36 #include <sfx2/docfile.hxx>
38 #include "global.hxx"
39 #include "scerrors.hxx"
40 #include "docpool.hxx"
41 #include "patattr.hxx"
42 #include "filter.hxx"
43 #include "document.hxx"
44 #include "cell.hxx"
45 #include "biff.hxx"
47 ScBiffReader::ScBiffReader( SfxMedium & rMedium ) :
48 mnId(0),
49 mnLength(0),
50 mnOffset(0)
52 mpStream = rMedium.GetInStream();
53 if( mpStream )
55 mpStream->SetBufferSize( 65535 );
56 mpStream->SetStreamCharSet( RTL_TEXTENCODING_MS_1252 );
60 ScBiffReader::~ScBiffReader()
62 if( mpStream )
63 mpStream->SetBufferSize( 0 );
66 bool ScBiffReader::nextRecord()
68 if( !recordsLeft() )
69 return false;
71 if( IsEndOfFile() )
72 return false;
74 sal_uInt32 nPos = mpStream->Tell();
75 if( nPos != mnOffset + mnLength )
76 mpStream->Seek( mnOffset + mnLength );
78 mnLength = mnId = 0;
79 *mpStream >> mnId >> mnLength;
81 mnOffset = mpStream->Tell();
82 #ifdef DEBUG
83 fprintf( stderr, "Read record 0x%x length 0x%x at offset 0x%x\n",
84 (unsigned)mnId, (unsigned)mnLength, (unsigned)mnOffset );
86 #if 1 // rather verbose
87 int len = mnLength;
88 while (len > 0) {
89 int i, chunk = len < 16 ? len : 16;
90 unsigned char data[16];
91 mpStream->Read( data, chunk );
93 for (i = 0; i < chunk; i++)
94 fprintf( stderr, "%.2x ", data[i] );
95 fprintf( stderr, "| " );
96 for (i = 0; i < chunk; i++)
97 fprintf( stderr, "%c", data[i] < 127 && data[i] > 30 ? data[i] : '.' );
98 fprintf( stderr, "\n" );
100 len -= chunk;
102 mpStream->Seek( mnOffset );
103 #endif
104 #endif
105 return true;