23#include <com/sun/star/beans/NamedValue.hpp>
59 virtual ::comphelper::DocPasswordVerifierResult
verifyPassword(
const OUString& rPassword, css::uno::Sequence< css::beans::NamedValue >& o_rEncryptionData )
override;
60 virtual ::comphelper::DocPasswordVerifierResult
verifyEncryptionData(
const css::uno::Sequence< css::beans::NamedValue >& rEncryptionData )
override;
66 sal_uInt16
Read(
SvStream& rStrm,
void* pData, sal_uInt16 nBytes );
77 virtual css::uno::Sequence< css::beans::NamedValue >
82 virtual void OnUpdate( std::size_t nOldStrmPos, std::size_t nNewStrmPos, sal_uInt16 nRecSize ) = 0;
105 virtual css::uno::Sequence< css::beans::NamedValue >
107 virtual bool OnVerifyEncryptionData(
const css::uno::Sequence< css::beans::NamedValue >& rEncryptionData )
override;
109 virtual void OnUpdate( std::size_t nOldStrmPos, std::size_t nNewStrmPos, sal_uInt16 nRecSize )
override;
125 virtual css::uno::Sequence< css::beans::NamedValue >
127 virtual bool OnVerifyEncryptionData(
const css::uno::Sequence< css::beans::NamedValue >& rEncryptionData )
override;
129 virtual void OnUpdate( std::size_t nOldStrmPos, std::size_t nNewStrmPos, sal_uInt16 nRecSize )
override;
134 static sal_uInt32
GetBlock( std::size_t nStrmPos );
136 static sal_uInt16
GetOffset( std::size_t nStrmPos );
140 std::vector<sal_uInt8>&& rVerifier,
141 std::vector<sal_uInt8>&& rVerifierHash);
156 std::vector<sal_uInt8>&& rVerifier,
157 std::vector<sal_uInt8>&& rVerifierHash)
178 std::vector<sal_uInt8>&& rVerifier,
179 std::vector<sal_uInt8>&& rVerifierHash)
208 void Set(
const SvStream&
rStrm, std::size_t nNextPos, std::size_t nCurrSize,
209 sal_uInt16 nRawRecId, sal_uInt16 nRawRecSize, sal_uInt16 nRawRecLeft,
214 sal_uInt16& rnRawRecId, sal_uInt16& rnRawRecSize, sal_uInt16& rnRawRecLeft,
215 bool& rbValid )
const;
363 sal_uInt16
PeekRecId( std::size_t nPos );
380 std::size_t
Read(
void* pData, std::size_t nBytes );
390 void Seek( std::size_t nPos );
392 void Ignore( std::size_t nBytes );
417 bool& rb16Bit,
bool& rbRich,
bool& rbFareast,
418 sal_uInt16& rnFormatRuns, sal_uInt32& rnExtInf,
sal_uInt8 nFlags );
514 sal_uInt16
ReadRawData(
void* pData, sal_uInt16 nBytes );
523 std::vector< XclImpStreamPos >
void SetError(ErrCode nErrorCode)
Decrypts BIFF5 stream contents.
virtual XclImpBiff5Decrypter * OnClone() const override
Implementation of cloning this object.
XclImpBiff5Decrypter(sal_uInt16 nKey, sal_uInt16 nHash)
virtual void OnUpdate(std::size_t nOldStrmPos, std::size_t nNewStrmPos, sal_uInt16 nRecSize) override
Implementation of updating the decrypter.
virtual sal_uInt16 OnRead(SvStream &rStrm, sal_uInt8 *pnData, sal_uInt16 nBytes) override
Implementation of the decryption.
::msfilter::MSCodec_XorXLS95 maCodec
css::uno::Sequence< css::beans::NamedValue > maEncryptionData
Crypto algorithm implementation.
virtual bool OnVerifyEncryptionData(const css::uno::Sequence< css::beans::NamedValue > &rEncryptionData) override
virtual css::uno::Sequence< css::beans::NamedValue > OnVerifyPassword(const OUString &rPassword) override
Implements password verification and initialization of the decoder.
virtual XclImpBiff8CryptoAPIDecrypter * OnClone() const override
Implementation of cloning this object.
::msfilter::MSCodec_CryptoAPI maCodec
XclImpBiff8CryptoAPIDecrypter(std::vector< sal_uInt8 > &&rSalt, std::vector< sal_uInt8 > &&rVerifier, std::vector< sal_uInt8 > &&rVerifierHash)
Decrypts BIFF8 stream contents using the given document identifier.
virtual void OnUpdate(std::size_t nOldStrmPos, std::size_t nNewStrmPos, sal_uInt16 nRecSize) override
Implementation of updating the decrypter.
std::vector< sal_uInt8 > maVerifier
std::vector< sal_uInt8 > maSalt
static sal_uInt32 GetBlock(std::size_t nStrmPos)
Returns the block number corresponding to the passed stream position.
static sal_uInt16 GetOffset(std::size_t nStrmPos)
Returns the block offset corresponding to the passed stream position.
virtual css::uno::Sequence< css::beans::NamedValue > OnVerifyPassword(const OUString &rPassword) override
Implements password verification and initialization of the decoder.
msfilter::MSCodec97 * mpCodec
virtual bool OnVerifyEncryptionData(const css::uno::Sequence< css::beans::NamedValue > &rEncryptionData) override
virtual sal_uInt16 OnRead(SvStream &rStrm, sal_uInt8 *pnData, sal_uInt16 nBytes) override
Implementation of the decryption.
css::uno::Sequence< css::beans::NamedValue > maEncryptionData
XclImpBiff8Decrypter(std::vector< sal_uInt8 > &&rSalt, std::vector< sal_uInt8 > &&rVerifier, std::vector< sal_uInt8 > &&rVerifierHash)
std::vector< sal_uInt8 > maVerifierHash
::msfilter::MSCodec_Std97 maCodec
XclImpBiff8StdDecrypter(std::vector< sal_uInt8 > &&rSalt, std::vector< sal_uInt8 > &&rVerifier, std::vector< sal_uInt8 > &&rVerifierHash)
virtual XclImpBiff8StdDecrypter * OnClone() const override
Implementation of cloning this object.
Base class for BIFF stream decryption.
XclImpDecrypterRef Clone() const
Creates a (ref-counted) copy of this decrypter object.
virtual bool OnVerifyEncryptionData(const css::uno::Sequence< css::beans::NamedValue > &rEncryptionData)=0
virtual ~XclImpDecrypter() override
virtual ::comphelper::DocPasswordVerifierResult verifyEncryptionData(const css::uno::Sequence< css::beans::NamedValue > &rEncryptionData) override
sal_uInt16 Read(SvStream &rStrm, void *pData, sal_uInt16 nBytes)
Reads and decrypts nBytes bytes and stores data into the existing(!) buffer pData.
void Update(const SvStream &rStrm, sal_uInt16 nRecSize)
Updates the decrypter on start of a new record or after seeking stream.
virtual sal_uInt16 OnRead(SvStream &rStrm, sal_uInt8 *pnData, sal_uInt16 nBytes)=0
Implementation of the decryption.
virtual void OnUpdate(std::size_t nOldStrmPos, std::size_t nNewStrmPos, sal_uInt16 nRecSize)=0
Implementation of updating the decrypter.
bool IsValid() const
Returns true, if the decoder has been initialized correctly.
sal_uInt64 mnOldPos
Decrypter error code.
virtual css::uno::Sequence< css::beans::NamedValue > OnVerifyPassword(const OUString &rPassword)=0
Derived classes implement password verification and initialization of the decoder.
virtual ::comphelper::DocPasswordVerifierResult verifyPassword(const OUString &rPassword, css::uno::Sequence< css::beans::NamedValue > &o_rEncryptionData) override
Implementation of the comphelper::IDocPasswordVerifier interface.
virtual XclImpDecrypter * OnClone() const =0
Implementation of cloning this object.
const ErrCode & GetError() const
Returns the current error code of the decrypter.
sal_uInt16 mnRecSize
Last known stream position.
Access to global data from other classes.
This class represents an Excel stream position.
std::size_t GetPos() const
Returns the stored stream position.
XclImpStreamPos()
Constructs an invalid stream position data object.
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.
sal_uInt16 mnRawRecSize
Current raw record ID (including CONTINUEs).
bool mbValid
Bytes left in current raw record (without following CONTINUEs).
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.
sal_uInt16 mnRawRecLeft
Current raw record size (without following CONTINUEs).
sal_uInt16 mnRawRecId
Current calculated size of the record.
std::size_t mnCurrSize
Absolute position of next record.
std::size_t mnNextPos
Absolute position of the stream.
This class is used to import record oriented streams.
bool IsValid() const
Returns record reading state: false = record overread.
std::size_t mnNextRecPos
Size of system stream.
std::size_t ReadUniStringExtHeader(bool &rb16Bit, bool &rbRich, bool &rbFareast, sal_uInt16 &rnFormatRuns, sal_uInt32 &rnExtInf, sal_uInt8 nFlags)
Reads ext.
bool ReadNextRawRecHeader()
Seeks to next raw record header and reads record ID and size.
std::size_t GetSvStreamSize() const
Returns the stream size.
std::vector< XclImpStreamPos > maPosStack
Start position of current record.
sal_uInt16 GetNextRecId()
Returns the record ID of the following record.
sal_uInt16 GetRecId() const
Returns the current record ID.
std::size_t GetRecPos() const
Returns the position inside of the whole record content.
bool JumpToNextContinue()
Goes to start of the next CONTINUE record.
sal_uInt16 mnRecId
true = mnComplRecSize is valid.
static XclBiff DetectBiffVersion(SvStream &rStrm)
Detects the BIFF version of the passed workbook stream.
void ResetRecord(bool bContLookup, sal_uInt16 nAltContId=EXC_ID_UNKNOWN)
Sets stream pointer to begin of record content.
void EnableDecryption(bool bEnable=true)
Switches usage of current decryption algorithm on/off.
XclImpStreamPos maGlobPos
Stack for record positions.
bool mbCont
Replacement for NUL characters.
void SetupDecrypter()
Initializes the decrypter to read a new record.
void StoreGlobalPosition()
Stores current position.
std::size_t CopyToStream(SvStream &rOutStrm, std::size_t nBytes)
Copies nBytes bytes to rOutStrm.
void Seek(std::size_t nPos)
Seeks absolute in record content to the specified position.
void SeekGlobalPosition()
Seeks to the stored global user position.
void DisableDecryption()
Switches usage of current decryption algorithm off.
void RestorePosition(const XclImpStreamPos &rPos)
Restores stream position contained in rPos.
bool mbValidRec
Usage of decryption.
std::size_t GetSvStreamPos() const
Returns the absolute stream position.
sal_uInt16 mnRawRecId
Alternative record ID for content continuation.
std::size_t GetRecLeft()
Returns remaining data size of the whole record without record headers.
void StorePosition(XclImpStreamPos &rPos)
Stores current stream position into rPos.
XclImpStreamPos maFirstRec
Provides methods to decrypt data.
sal_uInt16 PeekRecId(std::size_t nPos)
const XclImpRoot & mrRoot
Reference to the system input stream.
bool mbHasGlobPos
Was user position a valid record?
bool mbGlobValidRec
Record ID for user defined position.
std::size_t Read(void *pData, std::size_t nBytes)
Reads nBytes bytes to the existing(!) buffer pData.
void SetNulSubstChar(sal_Unicode cNulSubst='?')
Sets a replacement character for NUL characters.
void SetupRecord()
Initializes all members after base stream has been sought to new record.
void SetSvStreamError(const ErrCode &rErrCode)
Set an SVSTREAM_..._ERROR.
sal_uInt16 ReadRawData(void *pData, sal_uInt16 nBytes)
Reads and decrypts nBytes bytes to the existing(!) buffer pData.
bool JumpToNextStringContinue(bool &rb16Bit)
Goes to start of the next CONTINUE record while reading strings.
void Ignore(std::size_t nBytes)
Seeks forward inside the current record.
bool EnsureRawReadSize(sal_uInt16 nBytes)
Ensures that reading nBytes bytes is possible with next stream access.
std::size_t mnCurrRecSize
Start of next record header.
bool mbHasComplRec
Size of complete record data (with CONTINUEs).
sal_uInt16 mnAltContId
Current record ID (not the CONTINUE ID).
void PushPosition()
Pushes current position on user position stack.
sal_Unicode mcNulSubst
Bytes left in current raw record (without following CONTINUEs).
std::size_t mnComplRecSize
Helper for record position.
OUString ReadRawUniString(sal_uInt16 nChars, bool b16Bit)
Reads nChars characters and returns the string.
void IgnoreRawUniString(sal_uInt16 nChars, bool b16Bit)
Ignores nChars characters.
sal_uInt16 GetMaxRawReadSize(std::size_t nBytes) const
Returns the maximum size of raw data possible to read in one block.
sal_uInt16 mnGlobRecId
User defined position elsewhere in stream.
bool IsContinueId(sal_uInt16 nRecId) const
Returns true, if the passed ID is real or alternative continuation record ID.
sal_uInt16 mnRawRecSize
Current raw record ID (including CONTINUEs).
void SetupRawRecord()
Initializes all members after base stream has been sought to new raw record.
void CopyRecordToStream(SvStream &rOutStrm)
Copies the entire record to rOutStrm.
void IgnoreUniString(sal_uInt16 nChars, sal_uInt8 nFlags)
Ignores ext.
void PopPosition()
Seeks to last position from user position stack.
bool StartNextRecord()
Sets stream pointer to the start of the next record content.
bool mbValid
false = No more records to read.
std::size_t mnStreamSize
Is user position defined?
void SetDecrypter(XclImpDecrypterRef const &xDecrypter)
Enables decryption of record contents for the rest of the stream.
OUString ReadUniString()
Reads 16 bit character count, 8 bit flags, ext.
XclImpDecrypterRef mxDecrypter
Filter root data.
bool mbUseDecr
Automatic CONTINUE lookup on/off.
void CopyDecrypterFrom(const XclImpStream &rStrm)
Sets decrypter from another stream.
XclImpStream(SvStream &rInStrm, const XclImpRoot &rRoot)
Constructs the Excel record import stream using a TOOLS stream object.
OUString ReadRawByteString(sal_uInt16 nChars)
Reads nChar byte characters and returns the string.
OUString ReadByteString(bool b16BitLen)
Reads 8/16 bit string length, character array and returns the string.
void RewindRecord()
Sets stream pointer before current record and invalidates stream.
std::size_t GetRecSize()
Returns the data size of the whole record without record headers.
sal_uInt16 mnRawRecLeft
Current raw record size (without following CONTINUEs).
const XclImpRoot & GetRoot() const
Returns the filter root data.
std::shared_ptr< XclImpDecrypter > XclImpDecrypterRef
XclBiff
An enumeration for all Excel file format types (BIFF types).
const sal_uInt16 EXC_ID_UNKNOWN