LibreOffice Module sc (master)  1
xistream.hxx
Go to the documentation of this file.
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 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XISTREAM_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XISTREAM_HXX
22 
24 #include <com/sun/star/beans/NamedValue.hpp>
26 #include <tools/stream.hxx>
27 #include <memory>
28 #include "xlstream.hxx"
29 #include "xlconst.hxx"
30 
31 class XclImpRoot;
32 
33 /* ============================================================================
34 Input stream class for Excel import
35 - CONTINUE record handling
36 - Decryption
37 ============================================================================ */
38 
39 // Decryption
40 
42 typedef std::shared_ptr< XclImpDecrypter > XclImpDecrypterRef;
43 
46 {
47 public:
48  explicit XclImpDecrypter();
49  virtual ~XclImpDecrypter() override;
50 
52  const ErrCode& GetError() const { return mnError; }
54  bool IsValid() const { return mnError == ERRCODE_NONE; }
55 
57  XclImpDecrypterRef Clone() const;
58 
60  virtual ::comphelper::DocPasswordVerifierResult verifyPassword( const OUString& rPassword, css::uno::Sequence< css::beans::NamedValue >& o_rEncryptionData ) override;
61  virtual ::comphelper::DocPasswordVerifierResult verifyEncryptionData( const css::uno::Sequence< css::beans::NamedValue >& rEncryptionData ) override;
62 
64  void Update( const SvStream& rStrm, sal_uInt16 nRecSize );
67  sal_uInt16 Read( SvStream& rStrm, void* pData, sal_uInt16 nBytes );
68 
69 protected:
71  explicit XclImpDecrypter( const XclImpDecrypter& rSrc );
72 
73 private:
75  virtual XclImpDecrypter* OnClone() const = 0;
78  virtual css::uno::Sequence< css::beans::NamedValue >
79  OnVerifyPassword( const OUString& rPassword ) = 0;
80  virtual bool OnVerifyEncryptionData( const css::uno::Sequence< css::beans::NamedValue >& rEncryptionData ) = 0;
81 
83  virtual void OnUpdate( std::size_t nOldStrmPos, std::size_t nNewStrmPos, sal_uInt16 nRecSize ) = 0;
85  virtual sal_uInt16 OnRead( SvStream& rStrm, sal_uInt8* pnData, sal_uInt16 nBytes ) = 0;
86 
87 private:
89  sal_uInt64 mnOldPos;
90  sal_uInt16 mnRecSize;
91 };
92 
95 {
96 public:
97  explicit XclImpBiff5Decrypter( sal_uInt16 nKey, sal_uInt16 nHash );
98 
99 private:
101  explicit XclImpBiff5Decrypter( const XclImpBiff5Decrypter& rSrc );
102 
104  virtual XclImpBiff5Decrypter* OnClone() const override;
106  virtual css::uno::Sequence< css::beans::NamedValue >
107  OnVerifyPassword( const OUString& rPassword ) override;
108  virtual bool OnVerifyEncryptionData( const css::uno::Sequence< css::beans::NamedValue >& rEncryptionData ) override;
110  virtual void OnUpdate( std::size_t nOldStrmPos, std::size_t nNewStrmPos, sal_uInt16 nRecSize ) override;
112  virtual sal_uInt16 OnRead( SvStream& rStrm, sal_uInt8* pnData, sal_uInt16 nBytes ) override;
113 
114 private:
116  css::uno::Sequence< css::beans::NamedValue > maEncryptionData;
117  sal_uInt16 mnKey;
118  sal_uInt16 mnHash;
119 };
120 
123 {
124 private:
126  virtual css::uno::Sequence< css::beans::NamedValue >
127  OnVerifyPassword( const OUString& rPassword ) override;
128  virtual bool OnVerifyEncryptionData( const css::uno::Sequence< css::beans::NamedValue >& rEncryptionData ) override;
130  virtual void OnUpdate( std::size_t nOldStrmPos, std::size_t nNewStrmPos, sal_uInt16 nRecSize ) override;
132  virtual sal_uInt16 OnRead( SvStream& rStrm, sal_uInt8* pnData, sal_uInt16 nBytes ) override;
133 
135  static sal_uInt32 GetBlock( std::size_t nStrmPos );
137  static sal_uInt16 GetOffset( std::size_t nStrmPos );
138 
139 protected:
140  explicit XclImpBiff8Decrypter(const std::vector<sal_uInt8>& rSalt,
141  const std::vector<sal_uInt8>& rVerifier,
142  const std::vector<sal_uInt8>& rVerifierHash);
143 
144  explicit XclImpBiff8Decrypter(const XclImpBiff8Decrypter& rSrc);
145 
146  css::uno::Sequence< css::beans::NamedValue > maEncryptionData;
147  std::vector< sal_uInt8 > maSalt;
148  std::vector< sal_uInt8 > maVerifier;
149  std::vector< sal_uInt8 > maVerifierHash;
151 };
152 
154 {
155 public:
156  explicit XclImpBiff8StdDecrypter(const std::vector<sal_uInt8>& rSalt,
157  const std::vector<sal_uInt8>& rVerifier,
158  const std::vector<sal_uInt8>& rVerifierHash)
159  : XclImpBiff8Decrypter(rSalt, rVerifier, rVerifierHash)
160  {
161  mpCodec = &maCodec;
162  }
163 
164 private:
166  explicit XclImpBiff8StdDecrypter(const XclImpBiff8StdDecrypter& rSrc);
167 
169  virtual XclImpBiff8StdDecrypter* OnClone() const override;
170 
171 private:
173 };
174 
176 {
177 public:
178  explicit XclImpBiff8CryptoAPIDecrypter(const std::vector<sal_uInt8>& rSalt,
179  const std::vector<sal_uInt8>& rVerifier,
180  const std::vector<sal_uInt8>& rVerifierHash)
181  : XclImpBiff8Decrypter(rSalt, rVerifier, rVerifierHash)
182  {
183  mpCodec = &maCodec;
184  }
185 
186 private:
189 
191  virtual XclImpBiff8CryptoAPIDecrypter* OnClone() const override;
192 
193 private:
195 };
196 
197 // Stream
198 
203 {
204 public:
206  explicit XclImpStreamPos();
207 
209  void Set( const SvStream& rStrm, std::size_t nNextPos, std::size_t nCurrSize,
210  sal_uInt16 nRawRecId, sal_uInt16 nRawRecSize, sal_uInt16 nRawRecLeft,
211  bool bValid );
212 
214  void Get( SvStream& rStrm, std::size_t& rnNextPos, std::size_t& rnCurrSize,
215  sal_uInt16& rnRawRecId, sal_uInt16& rnRawRecSize, sal_uInt16& rnRawRecLeft,
216  bool& rbValid ) const;
217 
219  std::size_t GetPos() const { return mnPos; }
220 
221 private:
222  std::size_t mnPos;
223  std::size_t mnNextPos;
224  std::size_t mnCurrSize;
225  sal_uInt16 mnRawRecId;
226  sal_uInt16 mnRawRecSize;
227  sal_uInt16 mnRawRecLeft;
228  bool mbValid;
229 };
230 
279 {
280 public:
283 
287  explicit XclImpStream(
288  SvStream& rInStrm,
289  const XclImpRoot& rRoot );
290 
291  ~XclImpStream();
292 
294  const XclImpRoot& GetRoot() const { return mrRoot; }
295 
300  bool StartNextRecord();
304  bool StartNextRecord( std::size_t nNextRecPos );
313  void ResetRecord( bool bContLookup,
314  sal_uInt16 nAltContId = EXC_ID_UNKNOWN );
322  void RewindRecord();
323 
325  void SetDecrypter( XclImpDecrypterRef const & xDecrypter );
327  void CopyDecrypterFrom( const XclImpStream& rStrm );
331  void EnableDecryption( bool bEnable = true );
335  void DisableDecryption() { EnableDecryption( false ); }
336 
341  void PushPosition();
344  void PopPosition();
345 
347  void StoreGlobalPosition();
349  void SeekGlobalPosition();
350 
352  bool IsValid() const { return mbValid; }
354  sal_uInt16 GetRecId() const { return mnRecId; }
356  std::size_t GetRecPos() const;
358  std::size_t GetRecSize();
360  std::size_t GetRecLeft();
362  sal_uInt16 GetNextRecId();
363 
364  sal_uInt16 PeekRecId( std::size_t nPos );
365 
366  [[nodiscard]]
368  [[nodiscard]]
369  sal_Int16 ReadInt16();
370  [[nodiscard]]
371  sal_uInt16 ReaduInt16();
372  [[nodiscard]]
373  sal_Int32 ReadInt32();
374  [[nodiscard]]
375  sal_uInt32 ReaduInt32();
376  [[nodiscard]]
377  double ReadDouble();
378 
381  std::size_t Read( void* pData, std::size_t nBytes );
384  std::size_t CopyToStream( SvStream& rOutStrm, std::size_t nBytes );
385 
387  void CopyRecordToStream( SvStream& rOutStrm );
388 
391  void Seek( std::size_t nPos );
393  void Ignore( std::size_t nBytes );
394 
395  // *** special string functions *** ---------------------------------------
396 
397  // *** read/ignore unicode strings *** ------------------------------------
398  /* - look for CONTINUE records even if CONTINUE handling disabled
399  (only if inside of a CONTINUE record - for TXO import)
400  - no overread assertions (for Applix wrong string length export bug)
401 
402  structure of an Excel unicode string:
403  (1) 2 byte character count
404  (2) 1 byte flags (16-bit-characters, rich string, far east string)
405  (3) [2 byte rich string format run count]
406  (4) [4 byte far east data size]
407  (5) character array
408  (6) [4 * (rich string format run count) byte]
409  (7) [(far east data size) byte]
410  header = (1), (2)
411  ext. header = (3), (4)
412  ext. data = (6), (7)
413  */
414 
417  std::size_t ReadUniStringExtHeader(
418  bool& rb16Bit, bool& rbRich, bool& rbFareast,
419  sal_uInt16& rnFormatRuns, sal_uInt32& rnExtInf, sal_uInt8 nFlags );
422  std::size_t ReadUniStringExtHeader( bool& rb16Bit, sal_uInt8 nFlags );
423 
431  void SetNulSubstChar( sal_Unicode cNulSubst = '?' ) { mcNulSubst = cNulSubst; }
432 
434  OUString ReadRawUniString( sal_uInt16 nChars, bool b16Bit );
436  OUString ReadUniString( sal_uInt16 nChars, sal_uInt8 nFlags );
438  OUString ReadUniString( sal_uInt16 nChars );
441  OUString ReadUniString();
442 
444  void IgnoreRawUniString( sal_uInt16 nChars, bool b16Bit );
446  void IgnoreUniString( sal_uInt16 nChars, sal_uInt8 nFlags );
448  void IgnoreUniString( sal_uInt16 nChars );
449 
450  // *** read/ignore 8-bit-strings, store in String *** ---------------------
451 
453  OUString ReadRawByteString( sal_uInt16 nChars );
455  OUString ReadByteString( bool b16BitLen );
456 
457  // *** SvStream functions *** ---------------------------------------------
458 
460  std::size_t GetSvStreamPos() const { return mrStrm.Tell(); }
462  std::size_t GetSvStreamSize() const { return mnStreamSize; }
463 
465  void StorePosition( XclImpStreamPos& rPos );
467  void RestorePosition( const XclImpStreamPos& rPos );
468 
470  void SetSvStreamError( const ErrCode& rErrCode )
471  { mrStrm.SetError( rErrCode ); }
472 
473 private:
479  bool ReadNextRawRecHeader();
480 
482  void SetupDecrypter();
484  void SetupRawRecord();
486  void SetupRecord();
487 
489  bool IsContinueId( sal_uInt16 nRecId ) const;
490 
495  bool JumpToNextContinue();
503  bool JumpToNextStringContinue( bool& rb16Bit );
504 
509  bool EnsureRawReadSize( sal_uInt16 nBytes );
511  sal_uInt16 GetMaxRawReadSize( std::size_t nBytes ) const;
512 
515  sal_uInt16 ReadRawData( void* pData, sal_uInt16 nBytes );
516 
517 private:
520 
522 
524  std::vector< XclImpStreamPos >
526 
528  sal_uInt16 mnGlobRecId;
531 
532  std::size_t mnStreamSize;
533  std::size_t mnNextRecPos;
534  std::size_t mnCurrRecSize;
535  std::size_t mnComplRecSize;
537 
538  sal_uInt16 mnRecId;
539  sal_uInt16 mnAltContId;
540 
541  sal_uInt16 mnRawRecId;
542  sal_uInt16 mnRawRecSize;
543  sal_uInt16 mnRawRecLeft;
544 
546 
547  bool mbCont;
548  bool mbUseDecr;
549  bool mbValidRec;
550  bool mbValid;
551 };
552 
553 #endif
554 
555 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString ReadRawByteString(sal_uInt16 nChars)
Reads nChar byte characters and returns the string.
Definition: xistream.cxx:944
bool IsValid() const
Returns true, if the decoder has been initialized correctly.
Definition: xistream.hxx:54
void SetNulSubstChar(sal_Unicode cNulSubst= '?')
Sets a replacement character for NUL characters.
Definition: xistream.hxx:431
sal_uInt16 GetMaxRawReadSize(std::size_t nBytes) const
Returns the maximum size of raw data possible to read in one block.
Definition: xistream.cxx:1062
virtual XclImpBiff8CryptoAPIDecrypter * OnClone() const override
Implementation of cloning this object.
Definition: xistream.cxx:242
XclImpBiff8CryptoAPIDecrypter(const std::vector< sal_uInt8 > &rSalt, const std::vector< sal_uInt8 > &rVerifier, const std::vector< sal_uInt8 > &rVerifierHash)
Definition: xistream.hxx:178
sal_Unicode mcNulSubst
Bytes left in current raw record (without following CONTINUEs).
Definition: xistream.hxx:545
sal_uInt16 GetNextRecId()
Returns the record ID of the following record.
Definition: xistream.cxx:586
void Seek(std::size_t nPos)
Seeks absolute in record content to the specified position.
Definition: xistream.cxx:778
XclBiff
An enumeration for all Excel file format types (BIFF types).
Definition: xlconst.hxx:30
sal_Int32 ReadInt32()
Definition: xistream.cxx:666
std::size_t GetRecPos() const
Returns the position inside of the whole record content.
Definition: xistream.cxx:563
virtual css::uno::Sequence< css::beans::NamedValue > OnVerifyPassword(const OUString &rPassword)=0
Derived classes implement password verification and initialization of the decoder.
sal_uInt16 ReadRawData(void *pData, sal_uInt16 nBytes)
Reads and decrypts nBytes bytes to the existing(!) buffer pData.
Definition: xistream.cxx:1067
sal_uInt16 GetRecId() const
Returns the current record ID.
Definition: xistream.hxx:354
bool EnsureRawReadSize(sal_uInt16 nBytes)
Ensures that reading nBytes bytes is possible with next stream access.
Definition: xistream.cxx:1051
sal_uInt16 Read(SvStream &rStrm, void *pData, sal_uInt16 nBytes)
Reads and decrypts nBytes bytes and stores data into the existing(!) buffer pData.
Definition: xistream.cxx:92
void SetDecrypter(XclImpDecrypterRef const &xDecrypter)
Enables decryption of record contents for the rest of the stream.
Definition: xistream.cxx:506
virtual css::uno::Sequence< css::beans::NamedValue > OnVerifyPassword(const OUString &rPassword) override
Implements password verification and initialization of the decoder.
Definition: xistream.cxx:247
void RewindRecord()
Sets stream pointer before current record and invalidates stream.
Definition: xistream.cxx:500
sal_uInt16 mnAltContId
Current record ID (not the CONTINUE ID).
Definition: xistream.hxx:539
std::vector< sal_uInt8 > maVerifierHash
Definition: xistream.hxx:149
bool IsValid() const
Returns record reading state: false = record overread.
Definition: xistream.hxx:352
XclImpStream(SvStream &rInStrm, const XclImpRoot &rRoot)
Constructs the Excel record import stream using a TOOLS stream object.
Definition: xistream.cxx:426
std::size_t Read(void *pData, std::size_t nBytes)
Reads nBytes bytes to the existing(!) buffer pData.
Definition: xistream.cxx:720
virtual bool OnVerifyEncryptionData(const css::uno::Sequence< css::beans::NamedValue > &rEncryptionData) override
Definition: xistream.cxx:272
virtual ::comphelper::DocPasswordVerifierResult verifyPassword(const OUString &rPassword, css::uno::Sequence< css::beans::NamedValue > &o_rEncryptionData) override
Implementation of the comphelper::IDocPasswordVerifier interface.
Definition: xistream.cxx:64
bool IsContinueId(sal_uInt16 nRecId) const
Returns true, if the passed ID is real or alternative continuation record ID.
Definition: xistream.cxx:1012
const ErrCode & GetError() const
Returns the current error code of the decrypter.
Definition: xistream.hxx:52
sal_uInt16 mnRawRecLeft
Current raw record size (without following CONTINUEs).
Definition: xistream.hxx:543
virtual sal_uInt16 OnRead(SvStream &rStrm, sal_uInt8 *pnData, sal_uInt16 nBytes) override
Implementation of the decryption.
Definition: xistream.cxx:194
bool mbValidRec
Usage of decryption.
Definition: xistream.hxx:549
virtual void OnUpdate(std::size_t nOldStrmPos, std::size_t nNewStrmPos, sal_uInt16 nRecSize)=0
Implementation of updating the decrypter.
bool JumpToNextContinue()
Goes to start of the next CONTINUE record.
Definition: xistream.cxx:1017
XclImpStreamPos maFirstRec
Provides methods to decrypt data.
Definition: xistream.hxx:523
XclImpBiff8Decrypter(const std::vector< sal_uInt8 > &rSalt, const std::vector< sal_uInt8 > &rVerifier, const std::vector< sal_uInt8 > &rVerifierHash)
Definition: xistream.cxx:201
std::size_t mnComplRecSize
Helper for record position.
Definition: xistream.hxx:535
static sal_uInt32 GetBlock(std::size_t nStrmPos)
Returns the block number corresponding to the passed stream position.
Definition: xistream.cxx:336
sal_uInt16 sal_Unicode
void SeekGlobalPosition()
Seeks to the stored global user position.
Definition: xistream.cxx:550
XclImpBiff8StdDecrypter(const std::vector< sal_uInt8 > &rSalt, const std::vector< sal_uInt8 > &rVerifier, const std::vector< sal_uInt8 > &rVerifierHash)
Definition: xistream.hxx:156
bool mbValid
Bytes left in current raw record (without following CONTINUEs).
Definition: xistream.hxx:228
virtual void OnUpdate(std::size_t nOldStrmPos, std::size_t nNewStrmPos, sal_uInt16 nRecSize) override
Implementation of updating the decrypter.
Definition: xistream.cxx:188
SvStream & mrStrm
Definition: xistream.hxx:518
virtual XclImpBiff8StdDecrypter * OnClone() const override
Implementation of cloning this object.
Definition: xistream.cxx:229
XclImpDecrypterRef mxDecrypter
Filter root data.
Definition: xistream.hxx:521
sal_uInt16 mnGlobRecId
User defined position elsewhere in stream.
Definition: xistream.hxx:528
void StorePosition(XclImpStreamPos &rPos)
Stores current stream position into rPos.
Definition: xistream.cxx:961
void SetupRecord()
Initializes all members after base stream has been sought to new record.
Definition: xistream.cxx:999
XclImpStreamPos maGlobPos
Stack for record positions.
Definition: xistream.hxx:527
sal_uInt16 mnRecId
true = mnComplRecSize is valid.
Definition: xistream.hxx:538
bool mbGlobValidRec
Record ID for user defined position.
Definition: xistream.hxx:529
bool StartNextRecord()
Sets stream pointer to the start of the next record content.
Definition: xistream.cxx:455
sal_uInt16 mnRecSize
Last known stream position.
Definition: xistream.hxx:90
void PopPosition()
Seeks to last position from user position stack.
Definition: xistream.cxx:532
::msfilter::MSCodec_CryptoAPI maCodec
Definition: xistream.hxx:194
std::size_t GetPos() const
Returns the stored stream position.
Definition: xistream.hxx:219
std::size_t GetSvStreamSize() const
Returns the stream size.
Definition: xistream.hxx:462
virtual sal_uInt16 OnRead(SvStream &rStrm, sal_uInt8 *pnData, sal_uInt16 nBytes)=0
Implementation of the decryption.
bool JumpToNextStringContinue(bool &rb16Bit)
Goes to start of the next CONTINUE record while reading strings.
Definition: xistream.cxx:1025
std::vector< XclImpStreamPos > maPosStack
Start position of current record.
Definition: xistream.hxx:525
sal_Int16 ReadInt16()
Definition: xistream.cxx:630
std::size_t GetRecSize()
Returns the data size of the whole record without record headers.
Definition: xistream.cxx:568
void DisableDecryption()
Switches usage of current decryption algorithm off.
Definition: xistream.hxx:335
virtual bool OnVerifyEncryptionData(const css::uno::Sequence< css::beans::NamedValue > &rEncryptionData)=0
bool mbHasComplRec
Size of complete record data (with CONTINUEs).
Definition: xistream.hxx:536
virtual ::comphelper::DocPasswordVerifierResult verifyEncryptionData(const css::uno::Sequence< css::beans::NamedValue > &rEncryptionData) override
Definition: xistream.cxx:71
sal_uInt16 mnRawRecLeft
Current raw record size (without following CONTINUEs).
Definition: xistream.hxx:227
OUString ReadRawUniString(sal_uInt16 nChars, bool b16Bit)
Reads nChars characters and returns the string.
Definition: xistream.cxx:832
sal_uInt16 mnRawRecId
Current calculated size of the record.
Definition: xistream.hxx:225
std::vector< sal_uInt8 > maSalt
Definition: xistream.hxx:147
std::shared_ptr< XclImpDecrypter > XclImpDecrypterRef
Definition: xistream.hxx:41
Decrypts BIFF5 stream contents.
Definition: xistream.hxx:94
void SetupRawRecord()
Initializes all members after base stream has been sought to new raw record.
Definition: xistream.cxx:989
void SetupDecrypter()
Initializes the decrypter to read a new record.
Definition: xistream.cxx:983
void IgnoreUniString(sal_uInt16 nChars, sal_uInt8 nFlags)
Ignores ext.
Definition: xistream.cxx:931
Base class for BIFF stream decryption.
Definition: xistream.hxx:45
double ReadDouble()
Definition: xistream.cxx:702
const sal_uInt16 EXC_ID_UNKNOWN
Definition: xlstream.hxx:37
virtual css::uno::Sequence< css::beans::NamedValue > OnVerifyPassword(const OUString &rPassword) override
Implements password verification and initialization of the decoder.
Definition: xistream.cxx:130
void Get(SvStream &rStrm, std::size_t &rnNextPos, std::size_t &rnCurrSize, sal_uInt16 &rnRawRecId, sal_uInt16 &rnRawRecSize, sal_uInt16 &rnRawRecLeft, bool &rbValid) const
Writes the contained stream position data to the given variables.
Definition: xistream.cxx:372
virtual void OnUpdate(std::size_t nOldStrmPos, std::size_t nNewStrmPos, sal_uInt16 nRecSize) override
Implementation of updating the decrypter.
Definition: xistream.cxx:288
std::size_t mnPos
Definition: xistream.hxx:222
void SetError(ErrCode nErrorCode)
std::size_t mnNextPos
Absolute position of the stream.
Definition: xistream.hxx:223
OUString ReadUniString()
Reads 16 bit character count, 8 bit flags, ext.
Definition: xistream.cxx:900
std::size_t mnNextRecPos
Size of system stream.
Definition: xistream.hxx:533
bool mbValid
false = No more records to read.
Definition: xistream.hxx:550
bool mbCont
Replacement for NUL characters.
Definition: xistream.hxx:547
XclImpDecrypterRef Clone() const
Creates a (ref-counted) copy of this decrypter object.
Definition: xistream.cxx:56
sal_uInt16 ReaduInt16()
Definition: xistream.cxx:648
sal_uInt64 mnOldPos
Decrypter error code.
Definition: xistream.hxx:89
Decrypts BIFF8 stream contents using the given document identifier.
Definition: xistream.hxx:122
void EnableDecryption(bool bEnable=true)
Switches usage of current decryption algorithm on/off.
Definition: xistream.cxx:521
XclImpStreamPos()
Constructs an invalid stream position data object.
Definition: xistream.cxx:347
void IgnoreRawUniString(sal_uInt16 nChars, bool b16Bit)
Ignores nChars characters.
Definition: xistream.cxx:905
void CopyDecrypterFrom(const XclImpStream &rStrm)
Sets decrypter from another stream.
Definition: xistream.cxx:513
const XclImpRoot & GetRoot() const
Returns the filter root data.
Definition: xistream.hxx:294
msfilter::MSCodec97 * mpCodec
Definition: xistream.hxx:150
std::size_t GetRecLeft()
Returns remaining data size of the whole record without record headers.
Definition: xistream.cxx:581
virtual bool OnVerifyEncryptionData(const css::uno::Sequence< css::beans::NamedValue > &rEncryptionData) override
Definition: xistream.cxx:172
XclImpBiff5Decrypter(sal_uInt16 nKey, sal_uInt16 nHash)
Definition: xistream.cxx:109
OUString ReadByteString(bool b16BitLen)
Reads 8/16 bit string length, character array and returns the string.
Definition: xistream.cxx:954
std::size_t ReadUniStringExtHeader(bool &rb16Bit, bool &rbRich, bool &rbFareast, sal_uInt16 &rnFormatRuns, sal_uInt32 &rnExtInf, sal_uInt8 nFlags)
Reads ext.
Definition: xistream.cxx:811
void SetSvStreamError(const ErrCode &rErrCode)
Set an SVSTREAM_..._ERROR.
Definition: xistream.hxx:470
virtual XclImpDecrypter * OnClone() const =0
Implementation of cloning this object.
sal_uInt16 mnRawRecSize
Current raw record ID (including CONTINUEs).
Definition: xistream.hxx:542
void CopyRecordToStream(SvStream &rOutStrm)
Copies the entire record to rOutStrm.
Definition: xistream.cxx:767
virtual XclImpBiff5Decrypter * OnClone() const override
Implementation of cloning this object.
Definition: xistream.cxx:125
ErrCode mnError
Definition: xistream.hxx:88
#define ERRCODE_NONE
void Ignore(std::size_t nBytes)
Seeks forward inside the current record.
Definition: xistream.cxx:795
unsigned char sal_uInt8
bool mbUseDecr
Automatic CONTINUE lookup on/off.
Definition: xistream.hxx:548
sal_uInt8 ReaduInt8()
Definition: xistream.cxx:616
::msfilter::MSCodec_Std97 maCodec
Definition: xistream.hxx:172
css::uno::Sequence< css::beans::NamedValue > maEncryptionData
Definition: xistream.hxx:146
void Update(const SvStream &rStrm, sal_uInt16 nRecSize)
Updates the decrypter on start of a new record or after seeking stream.
Definition: xistream.cxx:78
sal_uInt16 mnRawRecSize
Current raw record ID (including CONTINUEs).
Definition: xistream.hxx:226
bool ReadNextRawRecHeader()
Seeks to next raw record header and reads record ID and size.
Definition: xistream.cxx:972
This class represents an Excel stream position.
Definition: xistream.hxx:202
void ResetRecord(bool bContLookup, sal_uInt16 nAltContId=EXC_ID_UNKNOWN)
Sets stream pointer to begin of record content.
Definition: xistream.cxx:486
std::vector< sal_uInt8 > maVerifier
Definition: xistream.hxx:148
sal_uInt16 mnRawRecId
Alternative record ID for content continuation.
Definition: xistream.hxx:541
sal_uInt64 Tell() const
void PushPosition()
Pushes current position on user position stack.
Definition: xistream.cxx:526
std::size_t mnCurrRecSize
Start of next record header.
Definition: xistream.hxx:534
void StoreGlobalPosition()
Stores current position.
Definition: xistream.cxx:542
std::size_t mnCurrSize
Absolute position of next record.
Definition: xistream.hxx:224
virtual sal_uInt16 OnRead(SvStream &rStrm, sal_uInt8 *pnData, sal_uInt16 nBytes) override
Implementation of the decryption.
Definition: xistream.cxx:311
virtual ~XclImpDecrypter() override
Definition: xistream.cxx:52
css::uno::Sequence< css::beans::NamedValue > maEncryptionData
Crypto algorithm implementation.
Definition: xistream.hxx:116
This class is used to import record oriented streams.
Definition: xistream.hxx:278
std::size_t CopyToStream(SvStream &rOutStrm, std::size_t nBytes)
Copies nBytes bytes to rOutStrm.
Definition: xistream.cxx:745
bool mbHasGlobPos
Was user position a valid record?
Definition: xistream.hxx:530
const XclImpRoot & mrRoot
Reference to the system input stream.
Definition: xistream.hxx:519
void Set(const SvStream &rStrm, std::size_t nNextPos, std::size_t nCurrSize, sal_uInt16 nRawRecId, sal_uInt16 nRawRecSize, sal_uInt16 nRawRecLeft, bool bValid)
Sets the stream position data to the passed values.
Definition: xistream.cxx:358
std::size_t GetSvStreamPos() const
Returns the absolute stream position.
Definition: xistream.hxx:460
void SvStream & rStrm
Access to global data from other classes.
Definition: xiroot.hxx:126
sal_uInt32 ReaduInt32()
Definition: xistream.cxx:684
::msfilter::MSCodec_XorXLS95 maCodec
Definition: xistream.hxx:115
sal_uInt16 PeekRecId(std::size_t nPos)
Definition: xistream.cxx:603
void RestorePosition(const XclImpStreamPos &rPos)
Restores stream position contained in rPos.
Definition: xistream.cxx:966
std::size_t mnStreamSize
Is user position defined?
Definition: xistream.hxx:532
static sal_uInt16 GetOffset(std::size_t nStrmPos)
Returns the block offset corresponding to the passed stream position.
Definition: xistream.cxx:341
static XclBiff DetectBiffVersion(SvStream &rStrm)
Detects the BIFF version of the passed workbook stream.
Definition: xistream.cxx:386