xref: /trunk/main/sc/source/filter/inc/xistream.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SC_XISTREAM_HXX
29 #define SC_XISTREAM_HXX
30 
31 #include <comphelper/docpasswordhelper.hxx>
32 #include <filter/msfilter/mscodec.hxx>
33 #include "xlstream.hxx"
34 #include "xlconst.hxx"
35 
36 class XclImpRoot;
37 
38 /* ============================================================================
39 Input stream class for Excel import
40 - CONTINUE record handling
41 - ByteString and UniString support
42 - Decryption
43 ============================================================================ */
44 
45 // ============================================================================
46 // Decryption
47 // ============================================================================
48 
49 class XclImpDecrypter;
50 typedef ScfRef< XclImpDecrypter > XclImpDecrypterRef;
51 
52 /** Base class for BIFF stream decryption. */
53 class XclImpDecrypter : public ::comphelper::IDocPasswordVerifier
54 {
55 public:
56     explicit            XclImpDecrypter();
57     virtual             ~XclImpDecrypter();
58 
59     /** Returns the current error code of the decrypter. */
60     inline ErrCode      GetError() const { return mnError; }
61     /** Returns true, if the decoder has been initialized correctly. */
62     inline bool         IsValid() const { return mnError == ERRCODE_NONE; }
63 
64     /** Creates a (ref-counted) copy of this decrypter object. */
65     XclImpDecrypterRef  Clone() const;
66 
67     /** Implementation of the ::comphelper::IDocPasswordVerifier interface */
68     virtual ::comphelper::DocPasswordVerifierResult verifyPassword( const ::rtl::OUString& rPassword, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& o_rEncryptionData );
69     virtual ::comphelper::DocPasswordVerifierResult verifyEncryptionData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rEncryptionData );
70 
71     /** Updates the decrypter on start of a new record or after seeking stream. */
72     void                Update( SvStream& rStrm, sal_uInt16 nRecSize );
73     /** Reads and decrypts nBytes bytes and stores data into the existing(!) buffer pData.
74         @return  Count of bytes really read. */
75     sal_uInt16          Read( SvStream& rStrm, void* pData, sal_uInt16 nBytes );
76 
77 protected:
78     /** Protected copy c'tor for OnClone(). */
79     explicit            XclImpDecrypter( const XclImpDecrypter& rSrc );
80 
81 private:
82     /** Implementation of cloning this object. */
83     virtual XclImpDecrypter* OnClone() const = 0;
84     /** Derived classes implement password verification and initialization of
85         the decoder. */
86     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >
87         OnVerifyPassword( const ::rtl::OUString& rPassword ) = 0;
88     virtual bool OnVerifyEncryptionData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rEncryptionData ) = 0;
89 
90     /** Implementation of updating the decrypter. */
91     virtual void        OnUpdate( sal_Size nOldStrmPos, sal_Size nNewStrmPos, sal_uInt16 nRecSize ) = 0;
92     /** Implementation of the decryption. */
93     virtual sal_uInt16  OnRead( SvStream& rStrm, sal_uInt8* pnData, sal_uInt16 nBytes ) = 0;
94 
95 private:
96     ErrCode             mnError;        /// Decrypter error code.
97     sal_Size            mnOldPos;       /// Last known stream position.
98     sal_uInt16          mnRecSize;      /// Current record size.
99 };
100 
101 // ----------------------------------------------------------------------------
102 
103 /** Decrypts BIFF5 stream contents. */
104 class XclImpBiff5Decrypter : public XclImpDecrypter
105 {
106 public:
107     explicit            XclImpBiff5Decrypter( sal_uInt16 nKey, sal_uInt16 nHash );
108 
109 private:
110     /** Private copy c'tor for OnClone(). */
111     explicit            XclImpBiff5Decrypter( const XclImpBiff5Decrypter& rSrc );
112 
113     /** Implementation of cloning this object. */
114     virtual XclImpBiff5Decrypter* OnClone() const;
115     /** Implements password verification and initialization of the decoder. */
116     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >
117         OnVerifyPassword( const ::rtl::OUString& rPassword );
118     virtual bool OnVerifyEncryptionData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rEncryptionData );
119     /** Implementation of updating the decrypter. */
120     virtual void        OnUpdate( sal_Size nOldStrmPos, sal_Size nNewStrmPos, sal_uInt16 nRecSize );
121     /** Implementation of the decryption. */
122     virtual sal_uInt16  OnRead( SvStream& rStrm, sal_uInt8* pnData, sal_uInt16 nBytes );
123 
124 private:
125     ::msfilter::MSCodec_XorXLS95 maCodec;       /// Crypto algorithm implementation.
126     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > maEncryptionData;
127     sal_uInt16          mnKey;
128     sal_uInt16          mnHash;
129 };
130 
131 // ----------------------------------------------------------------------------
132 
133 /** Decrypts BIFF8 stream contents using the given document identifier. */
134 class XclImpBiff8Decrypter : public XclImpDecrypter
135 {
136 public:
137     explicit            XclImpBiff8Decrypter( sal_uInt8 pnSalt[ 16 ],
138                             sal_uInt8 pnVerifier[ 16 ], sal_uInt8 pnVerifierHash[ 16 ] );
139 
140 private:
141     /** Private copy c'tor for OnClone(). */
142     explicit            XclImpBiff8Decrypter( const XclImpBiff8Decrypter& rSrc );
143 
144     /** Implementation of cloning this object. */
145     virtual XclImpBiff8Decrypter* OnClone() const;
146     /** Implements password verification and initialization of the decoder. */
147     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >
148         OnVerifyPassword( const ::rtl::OUString& rPassword );
149     virtual bool OnVerifyEncryptionData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rEncryptionData );
150     /** Implementation of updating the decrypter. */
151     virtual void        OnUpdate( sal_Size nOldStrmPos, sal_Size nNewStrmPos, sal_uInt16 nRecSize );
152     /** Implementation of the decryption. */
153     virtual sal_uInt16  OnRead( SvStream& rStrm, sal_uInt8* pnData, sal_uInt16 nBytes );
154 
155     /** Returns the block number corresponding to the passed stream position. */
156     sal_uInt32          GetBlock( sal_Size nStrmPos ) const;
157     /** Returns the block offset corresponding to the passed stream position. */
158     sal_uInt16          GetOffset( sal_Size nStrmPos ) const;
159 
160 private:
161     ::msfilter::MSCodec_Std97 maCodec;       /// Crypto algorithm implementation.
162     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > maEncryptionData;
163     ::std::vector< sal_uInt8 > maSalt;
164     ::std::vector< sal_uInt8 > maVerifier;
165     ::std::vector< sal_uInt8 > maVerifierHash;
166 };
167 
168 // ============================================================================
169 // Stream
170 // ============================================================================
171 
172 /** This class represents an Excel stream position.
173     @descr  It contains the relevant data for a stream position inside of a record
174     (including CONTINUE records). */
175 class XclImpStreamPos
176 {
177 public:
178     /** Constructs an invalid stream position data object. */
179     explicit            XclImpStreamPos();
180 
181     /** Sets the stream position data to the passed values. */
182     void                Set( const SvStream& rStrm, sal_Size nNextPos, sal_Size nCurrSize,
183                             sal_uInt16 nRawRecId, sal_uInt16 nRawRecSize, sal_uInt16 nRawRecLeft,
184                             bool bValid );
185 
186     /** Writes the contained stream position data to the given variables. */
187     void                Get( SvStream& rStrm, sal_Size& rnNextPos, sal_Size& rnCurrSize,
188                             sal_uInt16& rnRawRecId, sal_uInt16& rnRawRecSize, sal_uInt16& rnRawRecLeft,
189                             bool& rbValid ) const;
190 
191     /** Returns the stored stream position. */
192     inline sal_Size     GetPos() const { return mnPos; }
193 
194 private:
195     sal_Size            mnPos;          /// Absolute position of the stream.
196     sal_Size            mnNextPos;      /// Absolute position of next record.
197     sal_Size            mnCurrSize;     /// Current calculated size of the record.
198     sal_uInt16          mnRawRecId;     /// Current raw record ID (including CONTINUEs).
199     sal_uInt16          mnRawRecSize;   /// Current raw record size (without following CONTINUEs).
200     sal_uInt16          mnRawRecLeft;   /// Bytes left in current raw record (without following CONTINUEs).
201     bool                mbValid;        /// Read state: false = record overread.
202 };
203 
204 // ============================================================================
205 
206 /** This class is used to import record oriented streams.
207     @descr  An instance is constructed with an SvStream. The SvStream stream is
208     reset to its start while constructing this stream.
209 
210     To start reading a record call StartNextRecord(). Now it is possible to
211     read all contents of the record using operator>>() or any of the Read***()
212     functions. If some data exceeds the record size limit, the stream looks for
213     a following CONTINUE record and jumps automatically to it. It is NOT
214     allowed that an atomic data type is split into two records (i.e. 4 bytes of
215     a double in one record and the other 4 bytes in a following CONTINUE).
216 
217     Trying to read over the record limits results in a stream error. The
218     IsValid() function indicates that with returning false. From now on it is
219     undefined what data the read functions will return. The error state will be
220     reset, if the record is reset (with the method ResetRecord()) or if the
221     next record is started.
222 
223     To switch off the automatic lookup of CONTINUE records, use ResetRecord()
224     with false parameter. This is useful i.e. on import of Escher objects,
225     where sometimes solely CONTINUE records will occur. The automatic lookup
226     keeps switched off until the method ResetRecord() is called with parameter
227     true. All other settings done on the stream (i.e. alternative CONTINUE
228     record identifier, enabled decryption, NUL substitution character) will be
229     reset to default values, if a new record is started.
230 
231     The import stream supports decrypting the stream data. The contents of a
232     record (not the record header) will be encrypted by Excel if the file has
233     been stored with password protection. The functions SetDecrypter(),
234     EnableDecryption(), and DisableDecryption() control the usage of the
235     decryption algorithms. SetDecrypter() sets a new decryption algorithm and
236     initially enables it. DisableDecryption() may be used to stop the usage of
237     the decryption temporarily (sometimes record contents are never encrypted,
238     i.e. all BOF records or the stream position in BOUNDSHEET). Decryption will
239     be reenabled automatically, if a new record is started with the function
240     StartNextRecord().
241 
242     It is possible to store several stream positions inside a record (including
243     its CONTINUE records). The positions are stored on a stack, which can be
244     controlled with the functions PushPosition(), PopPosition() and
245     RejectPosition(). The stack will be cleared whenever a new record is
246     started with the function StartNextRecord().
247 
248     Additionally a single global stream position can be stored which keeps
249     valid during the whole import process (methods StoreGlobalPosition(),
250     SeekGlobalPosition() and DeleteGlobalPosition()). This is the only way to
251     jump back to a previous record (that is a real jump without return).
252 */
253 class XclImpStream
254 {
255 public:
256     /** Detects the BIFF version of the passed workbook stream. */
257     static XclBiff      DetectBiffVersion( SvStream& rStrm );
258 
259     /** Constructs the Excel record import stream using a TOOLS stream object.
260         @param rInStrm  The system input stream. Will be set to its start position.
261         Must exist as long as this object exists.
262         @param bContLookup  Automatic CONTINUE lookup on/off. */
263     explicit            XclImpStream(
264                             SvStream& rInStrm,
265                             const XclImpRoot& rRoot,
266                             bool bContLookup = true );
267 
268                         ~XclImpStream();
269 
270     /** Returns the filter root data. */
271     inline const XclImpRoot& GetRoot() const { return mrRoot; }
272 
273     /** Sets stream pointer to the start of the next record content.
274         @descr  Ignores all CONTINUE records of the current record, if automatic
275         CONTINUE usage is switched on.
276         @return  false = no record found (end of stream). */
277     bool                StartNextRecord();
278     /** Sets stream pointer to the start of the record content for the record
279         at the passed absolute stream position.
280         @return  false = no record found (end of stream). */
281     bool                StartNextRecord( sal_Size nNextRecPos );
282     /** Sets stream pointer to begin of record content.
283         @param bContLookup  Automatic CONTINUE lookup on/off. In difference
284         to other stream settings, this setting is persistent until next call of
285         this function (because it is wanted to receive the next CONTINUE
286         records separately).
287         @param nAltContId  Sets an alternative record ID for content
288         continuation. This value is reset automatically when a new record is
289         started with StartNextRecord(). */
290     void                ResetRecord( bool bContLookup,
291                             sal_uInt16 nAltContId = EXC_ID_UNKNOWN );
292     /** Sets stream pointer before current record and invalidates stream.
293         @descr  The next call to StartNextRecord() will start again the current
294         record. This can be used in situations where a loop or a function
295         leaves on a specific record, but the parent context expects to start
296         this record by itself. The stream is invalid as long as the first
297         record has not been started (it is not allowed to call any other stream
298         operation then). */
299     void                RewindRecord();
300 
301     /** Enables decryption of record contents for the rest of the stream. */
302     void                SetDecrypter( XclImpDecrypterRef xDecrypter );
303     /** Sets decrypter from another stream. */
304     void                CopyDecrypterFrom( const XclImpStream& rStrm );
305     /** Returns true, if a valid decrypter is set at the stream. */
306     bool                HasValidDecrypter() const;
307     /** Switches usage of current decryption algorithm on/off.
308         @descr  Encryption is re-enabled automatically, if a new record is
309         started using the function StartNextRecord(). */
310     void                EnableDecryption( bool bEnable = true );
311     /** Switches usage of current decryption algorithm off.
312         @descr  This is a record-local setting. The function StartNextRecord()
313         always enables decryption. */
314     inline void         DisableDecryption() { EnableDecryption( false ); }
315 
316     /** Pushes current position on user position stack.
317         @descr  This stack is emptied when starting a new record with
318         StartNextRecord(). The decryption state (enabled/disabled) is not
319         pushed onto the stack. */
320     void                PushPosition();
321     /** Seeks to last position from user position stack.
322         @descr  This position will be removed from the stack. */
323     void                PopPosition();
324 //UNUSED2008-05  /** Removes last position from user position stack, but does not seek to it. */
325 //UNUSED2008-05  void                RejectPosition();
326 
327     /** Stores current position. This position keeps valid in all records. */
328     void                StoreGlobalPosition();
329     /** Seeks to the stored global user position. */
330     void                SeekGlobalPosition();
331     /** Invalidates global user position. */
332     inline void         DeleteGlobalPosition() { mbHasGlobPos = false; }
333 
334     /** Returns record reading state: false = record overread. */
335     inline bool         IsValid() const { return mbValid; }
336     /** Returns the current record ID. */
337     inline sal_uInt16   GetRecId() const { return mnRecId; }
338     /** Returns the position inside of the whole record content. */
339     sal_Size            GetRecPos() const;
340     /** Returns the data size of the whole record without record headers. */
341     sal_Size            GetRecSize();
342     /** Returns remaining data size of the whole record without record headers. */
343     sal_Size            GetRecLeft();
344     /** Returns the record ID of the following record. */
345     sal_uInt16          GetNextRecId();
346 
347     XclImpStream&       operator>>( sal_Int8& rnValue );
348     XclImpStream&       operator>>( sal_uInt8& rnValue );
349     XclImpStream&       operator>>( sal_Int16& rnValue );
350     XclImpStream&       operator>>( sal_uInt16& rnValue );
351     XclImpStream&       operator>>( sal_Int32& rnValue );
352     XclImpStream&       operator>>( sal_uInt32& rnValue );
353     XclImpStream&       operator>>( float& rfValue );
354     XclImpStream&       operator>>( double& rfValue );
355 
356     sal_Int8            ReadInt8();
357     sal_uInt8           ReaduInt8();
358     sal_Int16           ReadInt16();
359     sal_uInt16          ReaduInt16();
360     sal_Int32           ReadInt32();
361     sal_uInt32          ReaduInt32();
362     float               ReadFloat();
363     double              ReadDouble();
364 
365     /** Reads nBytes bytes to the existing(!) buffer pData.
366         @return  Count of bytes really read. */
367     sal_Size            Read( void* pData, sal_Size nBytes );
368     /** Copies nBytes bytes to rOutStrm.
369         @return  Count of bytes really written. */
370     sal_Size            CopyToStream( SvStream& rOutStrm, sal_Size nBytes );
371 
372     /** Copies the entire record to rOutStrm. The current record position keeps unchanged.
373         @return  Count of bytes really written. */
374     sal_Size            CopyRecordToStream( SvStream& rOutStrm );
375 
376     /** Seeks absolute in record content to the specified position.
377         @descr  The value 0 means start of record, independent from physical stream position. */
378     void                Seek( sal_Size nPos );
379     /** Seeks forward inside the current record. */
380     void                Ignore( sal_Size nBytes );
381 
382     // *** special string functions *** ---------------------------------------
383 
384     // *** read/ignore unicode strings *** ------------------------------------
385     /*  - look for CONTINUE records even if CONTINUE handling disabled
386           (only if inside of a CONTINUE record - for TXO import)
387         - no overread assertions (for Applix wrong string length export bug)
388 
389         structure of an Excel unicode string:
390         (1) 2 byte character count
391         (2) 1 byte flags (16-bit-characters, rich string, far east string)
392         (3) [2 byte rich string format run count]
393         (4) [4 byte far east data size]
394         (5) character array
395         (6) [4 * (rich string format run count) byte]
396         (7) [(far east data size) byte]
397         header = (1), (2)
398         ext. header = (3), (4)
399         ext. data = (6), (7)
400      */
401 
402     /** Reads ext. header, detects 8/16 bit mode, sets all ext. info.
403         @return  Total size of ext. data. */
404     sal_Size            ReadUniStringExtHeader(
405                             bool& rb16Bit, bool& rbRich, bool& rbFareast,
406                             sal_uInt16& rnFormatRuns, sal_uInt32& rnExtInf, sal_uInt8 nFlags );
407     /** Seeks to begin of character array, detects 8/16 bit mode.
408         @return  Total size of ext. data. */
409     sal_Size            ReadUniStringExtHeader( bool& rb16Bit, sal_uInt8 nFlags );
410 
411     /** Sets a replacement character for NUL characters.
412         @descr  NUL characters must be replaced, because Tools strings cannot
413         handle them. The substitution character is reset to '?' automatically,
414         if a new record is started using the function StartNextRecord().
415         @param cNulSubst  The character to use for NUL replacement. It is
416         possible to specify NUL here. in this case strings are terminated when
417         the first NUL occurs during string import. */
418     inline void         SetNulSubstChar( sal_Unicode cNulSubst = '?' ) { mcNulSubst = cNulSubst; }
419 
420     /** Reads nChars characters and returns the string. */
421     String              ReadRawUniString( sal_uInt16 nChars, bool b16Bit );
422     /** Reads ext. header, nChar characters, ext. data and returns the string. */
423     String              ReadUniString( sal_uInt16 nChars, sal_uInt8 nFlags );
424     /** Reads 8 bit flags, ext. header, nChar characters, ext. data and returns the string. */
425     String              ReadUniString( sal_uInt16 nChars );
426     /** Reads 16 bit character count, 8 bit flags, ext. header, character array,
427         ext. data and returns the string. */
428     String              ReadUniString();
429 
430     /** Ignores nChars characters. */
431     void                IgnoreRawUniString( sal_uInt16 nChars, bool b16Bit );
432     /** Ignores ext. header, nChar characters, ext. data. */
433     void                IgnoreUniString( sal_uInt16 nChars, sal_uInt8 nFlags );
434     /** Ignores 8 bit flags, ext. header, nChar characters, ext. data. */
435     void                IgnoreUniString( sal_uInt16 nChars );
436     /** Ignores 16 bit character count, 8 bit flags, ext. header, character array, ext. data. */
437     void                IgnoreUniString();
438 
439     // *** read/ignore 8-bit-strings, store in String *** ---------------------
440 
441     /** Reads nChar byte characters and returns the string. */
442     String              ReadRawByteString( sal_uInt16 nChars );
443     /** Reads 8/16 bit string length, character array and returns the string. */
444     String              ReadByteString( bool b16BitLen );
445 
446     // *** SvStream functions *** ---------------------------------------------
447 
448     /** Returns the absolute stream position. */
449     inline sal_Size     GetSvStreamPos() const { return mrStrm.Tell(); }
450     /** Returns the stream size. */
451     inline sal_Size     GetSvStreamSize() const { return mnStreamSize; }
452 
453 private:
454     /** Stores current stream position into rPos. */
455     void                StorePosition( XclImpStreamPos& rPos );
456     /** Restores stream position contained in rPos. */
457     void                RestorePosition( const XclImpStreamPos& rPos );
458 
459     /** Seeks to next raw record header and reads record ID and size.
460         @descr  This is a "raw" function, means that stream members are
461         inconsistent after return. Does only change mnRawRecId, mnRawRecSize,
462         and the base stream position, but no other members.
463         @return  false = No record header found (end of stream). */
464     bool                ReadNextRawRecHeader();
465 
466     /** Initializes the decrypter to read a new record. */
467     void                SetupDecrypter();
468     /** Initializes all members after base stream has been seeked to new raw record. */
469     void                SetupRawRecord();
470     /** Initializes all members after base stream has been seeked to new record. */
471     void                SetupRecord();
472 
473     /** Returns true, if the passed ID is real or alternative continuation record ID. */
474     bool                IsContinueId( sal_uInt16 nRecId ) const;
475 
476     /** Goes to start of the next CONTINUE record.
477         @descr  Stream must be located at the end of a raw record, and handling
478         of CONTINUE records must be enabled.
479         @return  Copy of mbValid. */
480     bool                JumpToNextContinue();
481     /** Goes to start of the next CONTINUE record while reading strings.
482         @descr  Stream must be located at the end of a raw record. If reading
483         has been started in a CONTINUE record, jumps to an existing following
484         CONTINUE record, even if handling of CONTINUE records is disabled (This
485         is a special handling for TXO string data). Reads additional Unicode
486         flag byte at start of the new raw record and sets or resets rb16Bit.
487         @return  Copy of mbValid. */
488     bool                JumpToNextStringContinue( bool& rb16Bit );
489 
490     /** Ensures that reading nBytes bytes is possible with next stream access.
491         @descr  Stream must be located at the end of a raw record, and handling
492         of CONTINUE records must be enabled.
493         @return  Copy of mbValid. */
494     bool                EnsureRawReadSize( sal_uInt16 nBytes );
495     /** Returns the maximum size of raw data possible to read in one block. */
496     sal_uInt16          GetMaxRawReadSize( sal_Size nBytes ) const;
497 
498     /** Reads and decrypts nBytes bytes to the existing(!) buffer pData.
499         @return  Count of bytes really read. */
500     sal_uInt16          ReadRawData( void* pData, sal_uInt16 nBytes );
501 
502     /** Reads 8 bit/16 bit string length. */
503     inline sal_uInt16   ReadByteStrLen( bool b16BitLen )
504                             { return b16BitLen ? ReaduInt16() : ReaduInt8(); }
505 
506 private:
507     typedef ::std::vector< XclImpStreamPos > XclImpStreamPosStack;
508 
509     SvStream&           mrStrm;         /// Reference to the system input stream.
510     const XclImpRoot&   mrRoot;         /// Filter root data.
511 
512     XclImpDecrypterRef  mxDecrypter;    /// Provides methods to decrypt data.
513 
514     XclImpStreamPos     maFirstRec;     /// Start position of current record.
515     XclImpStreamPosStack maPosStack;    /// Stack for record positions.
516 
517     XclImpStreamPos     maGlobPos;      /// User defined position elsewhere in stream.
518     sal_uInt16          mnGlobRecId;    /// Record ID for user defined position.
519     bool                mbGlobValidRec; /// Was user position a valid record?
520     bool                mbHasGlobPos;   /// Is user position defined?
521 
522     sal_Size            mnStreamSize;   /// Size of system stream.
523     sal_Size            mnNextRecPos;   /// Start of next record header.
524     sal_Size            mnCurrRecSize;  /// Helper for record position.
525     sal_Size            mnComplRecSize; /// Size of complete record data (with CONTINUEs).
526     bool                mbHasComplRec;  /// true = mnComplRecSize is valid.
527 
528     sal_uInt16          mnRecId;        /// Current record ID (not the CONTINUE ID).
529     sal_uInt16          mnAltContId;    /// Alternative record ID for content continuation.
530 
531     sal_uInt16          mnRawRecId;     /// Current raw record ID (including CONTINUEs).
532     sal_uInt16          mnRawRecSize;   /// Current raw record size (without following CONTINUEs).
533     sal_uInt16          mnRawRecLeft;   /// Bytes left in current raw record (without following CONTINUEs).
534 
535     sal_Unicode         mcNulSubst;     /// Replacement for NUL characters.
536 
537     bool                mbCont;         /// Automatic CONTINUE lookup on/off.
538     bool                mbUseDecr;      /// Usage of decryption.
539     bool                mbValidRec;     /// false = No more records to read.
540     bool                mbValid;        /// false = Record overread.
541 };
542 
543 // ============================================================================
544 
545 #endif
546 
547