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