LibreOffice Module sc (master) 1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
XclExpStream Class Reference

This class is used to export Excel record streams. More...

#include <xestream.hxx>

Collaboration diagram for XclExpStream:
[legend]

Public Member Functions

 XclExpStream (SvStream &rOutStrm, const XclExpRoot &rRoot, sal_uInt16 nMaxRecSize=0)
 Constructs the Excel record export stream. More...
 
 ~XclExpStream ()
 
const XclExpRootGetRoot () const
 Returns the filter root data. More...
 
void StartRecord (sal_uInt16 nRecId, std::size_t nRecSize)
 Starts a new record: writes header data, stores calculated record size. More...
 
void EndRecord ()
 Checks and corrects real record length. More...
 
sal_uInt16 GetRawRecPos () const
 Returns the position inside of current record (starts by 0 in every CONTINUE). More...
 
void SetSliceSize (sal_uInt16 nSize)
 Sets data slice length. More...
 
XclExpStreamoperator<< (sal_Int8 nValue)
 
XclExpStreamoperator<< (sal_uInt8 nValue)
 
XclExpStreamoperator<< (sal_Int16 nValue)
 
XclExpStreamoperator<< (sal_uInt16 nValue)
 
XclExpStreamoperator<< (sal_Int32 nValue)
 
XclExpStreamoperator<< (sal_uInt32 nValue)
 
XclExpStreamoperator<< (float fValue)
 
XclExpStreamoperator<< (double fValue)
 
std::size_t Write (const void *pData, std::size_t nBytes)
 Writes nBytes bytes from memory. More...
 
void WriteZeroBytes (std::size_t nBytes)
 Writes a sequence of nBytes zero bytes (respects slice setting). More...
 
void WriteZeroBytesToRecord (std::size_t nBytes)
 
void CopyFromStream (SvStream &rInStrm, sal_uInt64 nBytes=STREAM_SEEK_TO_END)
 Copies nBytes bytes from current position of the stream rInStrm. More...
 
void WriteUnicodeBuffer (const ScfUInt16Vec &rBuffer, sal_uInt8 nFlags)
 Writes Unicode buffer as 8/16 bit, repeats nFlags at start of a CONTINUE record. More...
 
void WriteByteString (const OString &rString)
 Writes string length field and OString buffer. More...
 
void WriteCharBuffer (const ScfUInt8Vec &rBuffer)
 Writes 8-bit character buffer. More...
 
void SetSvStreamPos (sal_uInt64 nPos)
 Sets position of system stream (only allowed outside of records). More...
 
sal_uInt64 GetSvStreamPos () const
 Returns the absolute position of the system stream. More...
 
void SetEncrypter (XclExpEncrypterRef const &xEncrypter)
 
bool HasValidEncrypter () const
 
void EnableEncryption (bool bEnable=true)
 
void DisableEncryption ()
 

Private Member Functions

void InitRecord (sal_uInt16 nRecId)
 Writes header data, internal setup. More...
 
void UpdateRecSize ()
 Rewrites correct record length, if different from calculated. More...
 
void UpdateSizeVars (std::size_t nSize)
 Recalculates mnCurrSize and mnSliceSize. More...
 
void StartContinue ()
 Writes CONTINUE header, internal setup. More...
 
void PrepareWrite (sal_uInt16 nSize)
 Refreshes counter vars, creates CONTINUE records. More...
 
sal_uInt16 PrepareWrite ()
 Creates CONTINUE record at end of record. More...
 
void WriteRawZeroBytes (std::size_t nBytes)
 Writes a raw sequence of zero bytes. More...
 

Private Attributes

SvStreammrStrm
 
const XclExpRootmrRoot
 Reference to the system output stream. More...
 
bool mbUseEncrypter
 Filter root data. More...
 
XclExpEncrypterRef mxEncrypter
 
sal_uInt16 mnMaxRecSize
 
sal_uInt16 mnMaxContSize
 Maximum size of record content. More...
 
sal_uInt16 mnCurrMaxSize
 Maximum size of CONTINUE content. More...
 
sal_uInt16 mnMaxSliceSize
 Current maximum, either mnMaxRecSize or mnMaxContSize. More...
 
sal_uInt16 mnHeaderSize
 Maximum size of data slices (parts that cannot be split). More...
 
sal_uInt16 mnCurrSize
 Record size written in last record header. More...
 
sal_uInt16 mnSliceSize
 Count of bytes already written in current record. More...
 
std::size_t mnPredictSize
 Count of bytes already written in current slice. More...
 
std::size_t mnLastSizePos
 Predicted size received from calling function. More...
 
bool mbInRec
 Stream position of size field in current header. More...
 

Detailed Description

This class is used to export Excel record streams.

@descr An instance is constructed with an SvStream and the maximum size of Excel record contents (in BIFF5: 2080 bytes, in BIFF8: 8224 bytes).

To start writing a record call StartRecord(). Parameters are the record identifier and any calculated record size. This is for optimizing the write process: if the real written data has the same size as the calculated, the stream will not seek back and update the record size field. But it is not mandatory to calculate a size. Each record must be closed by calling EndRecord(). This will check (and update) the record size field.

If some data exceeds the record size limit, a CONTINUE record is started automatically and the new data will be written to this record.

If specific data pieces must not be split, use SetSliceSize(). For instance: To write a sequence of 16-bit values, where 4 values form a unit and cannot be split, call SetSliceSize( 8 ) first (4*2 bytes == 8).

To write unicode character arrays, call WriteUnicodeBuffer(). It creates CONTINUE records and repeats the unicode string flag byte automatically. This function is used for instance from the class XclExpString which can write complete unicode strings.

Definition at line 72 of file xestream.hxx.

Constructor & Destructor Documentation

◆ XclExpStream()

XclExpStream::XclExpStream ( SvStream rOutStrm,
const XclExpRoot rRoot,
sal_uInt16  nMaxRecSize = 0 
)

Constructs the Excel record export stream.

Parameters
rOutStrmThe system output stream to write to.
nMaxRecSizeThe maximum allowed size of record content (depending on BIFF type). If 0 is passed, the record size will be set automatically, depending on the current BIFF type.

Definition at line 89 of file xestream.cxx.

References EXC_BIFF5, EXC_MAXRECSIZE_BIFF5, EXC_MAXRECSIZE_BIFF8, XclRoot::GetBiff(), mnMaxContSize, mnMaxRecSize, and mrRoot.

◆ ~XclExpStream()

XclExpStream::~XclExpStream ( )

Definition at line 108 of file xestream.cxx.

References SvStream::FlushBuffer(), and mrStrm.

Member Function Documentation

◆ CopyFromStream()

void XclExpStream::CopyFromStream ( SvStream rInStrm,
sal_uInt64  nBytes = STREAM_SEEK_TO_END 
)

Copies nBytes bytes from current position of the stream rInStrm.

@descr Omitting the second parameter means: read to end of stream.

Definition at line 288 of file xestream.cxx.

References SvStream::ReadBytes(), SvStream::remainingSize(), and Write().

◆ DisableEncryption()

void XclExpStream::DisableEncryption ( )

Definition at line 368 of file xestream.cxx.

References EnableEncryption().

Referenced by EndRecord(), and StartRecord().

◆ EnableEncryption()

void XclExpStream::EnableEncryption ( bool  bEnable = true)

Definition at line 363 of file xestream.cxx.

References HasValidEncrypter(), and mbUseEncrypter.

Referenced by DisableEncryption(), and StartRecord().

◆ EndRecord()

void XclExpStream::EndRecord ( )

Checks and corrects real record length.

Must be called every time a record is finished.

Definition at line 125 of file xestream.cxx.

References DisableEncryption(), mbInRec, mrStrm, SvStream::Seek(), STREAM_SEEK_TO_END, and UpdateRecSize().

◆ GetRawRecPos()

sal_uInt16 XclExpStream::GetRawRecPos ( ) const
inline

Returns the position inside of current record (starts by 0 in every CONTINUE).

Definition at line 95 of file xestream.hxx.

References mnCurrSize.

◆ GetRoot()

const XclExpRoot & XclExpStream::GetRoot ( ) const
inline

Returns the filter root data.

Definition at line 87 of file xestream.hxx.

References mrRoot.

◆ GetSvStreamPos()

sal_uInt64 XclExpStream::GetSvStreamPos ( ) const
inline

Returns the absolute position of the system stream.

Definition at line 140 of file xestream.hxx.

References mrStrm, and SvStream::Tell().

Referenced by ExcDocument::Write().

◆ HasValidEncrypter()

bool XclExpStream::HasValidEncrypter ( ) const

Definition at line 358 of file xestream.cxx.

References mxEncrypter.

Referenced by EnableEncryption(), operator<<(), and Write().

◆ InitRecord()

void XclExpStream::InitRecord ( sal_uInt16  nRecId)
private

◆ operator<<() [1/8]

XclExpStream & XclExpStream::operator<< ( double  fValue)

◆ operator<<() [2/8]

XclExpStream & XclExpStream::operator<< ( float  fValue)

◆ operator<<() [3/8]

XclExpStream & XclExpStream::operator<< ( sal_Int16  nValue)

◆ operator<<() [4/8]

XclExpStream & XclExpStream::operator<< ( sal_Int32  nValue)

◆ operator<<() [5/8]

XclExpStream & XclExpStream::operator<< ( sal_Int8  nValue)

◆ operator<<() [6/8]

XclExpStream & XclExpStream::operator<< ( sal_uInt16  nValue)

◆ operator<<() [7/8]

XclExpStream & XclExpStream::operator<< ( sal_uInt32  nValue)

◆ operator<<() [8/8]

XclExpStream & XclExpStream::operator<< ( sal_uInt8  nValue)

◆ PrepareWrite() [1/2]

sal_uInt16 XclExpStream::PrepareWrite ( )
private

Creates CONTINUE record at end of record.

Returns
Maximum data block size remaining.

Definition at line 434 of file xestream.cxx.

References mbInRec, mnCurrMaxSize, mnCurrSize, mnMaxSliceSize, mnSliceSize, StartContinue(), and UpdateSizeVars().

Referenced by operator<<(), Write(), WriteByteString(), and WriteZeroBytes().

◆ PrepareWrite() [2/2]

void XclExpStream::PrepareWrite ( sal_uInt16  nSize)
private

Refreshes counter vars, creates CONTINUE records.

Definition at line 423 of file xestream.cxx.

References mbInRec, mnCurrMaxSize, mnCurrSize, mnMaxSliceSize, mnSliceSize, StartContinue(), and UpdateSizeVars().

◆ SetEncrypter()

void XclExpStream::SetEncrypter ( XclExpEncrypterRef const &  xEncrypter)

Definition at line 353 of file xestream.cxx.

References mxEncrypter.

◆ SetSliceSize()

void XclExpStream::SetSliceSize ( sal_uInt16  nSize)

Sets data slice length.

0 = no slices.

Definition at line 134 of file xestream.cxx.

References mnMaxSliceSize, and mnSliceSize.

Referenced by StartRecord(), WriteByteString(), WriteCharBuffer(), and WriteUnicodeBuffer().

◆ SetSvStreamPos()

void XclExpStream::SetSvStreamPos ( sal_uInt64  nPos)

Sets position of system stream (only allowed outside of records).

Definition at line 373 of file xestream.cxx.

References mbInRec, mrStrm, nPos, and SvStream::Seek().

◆ StartContinue()

void XclExpStream::StartContinue ( )
private

Writes CONTINUE header, internal setup.

Definition at line 415 of file xestream.cxx.

References EXC_ID_CONT, InitRecord(), mnCurrMaxSize, mnCurrSize, mnMaxContSize, mnPredictSize, and UpdateRecSize().

Referenced by PrepareWrite(), WriteByteString(), and WriteUnicodeBuffer().

◆ StartRecord()

void XclExpStream::StartRecord ( sal_uInt16  nRecId,
std::size_t  nRecSize 
)

Starts a new record: writes header data, stores calculated record size.

Definition at line 113 of file xestream.cxx.

References DisableEncryption(), EnableEncryption(), InitRecord(), mbInRec, mnCurrMaxSize, mnMaxContSize, mnMaxRecSize, mnPredictSize, and SetSliceSize().

◆ UpdateRecSize()

void XclExpStream::UpdateRecSize ( )
private

Rewrites correct record length, if different from calculated.

Definition at line 392 of file xestream.cxx.

References mnCurrSize, mnHeaderSize, mnLastSizePos, mrStrm, SvStream::Seek(), and SvStream::WriteUInt16().

Referenced by EndRecord(), and StartContinue().

◆ UpdateSizeVars()

void XclExpStream::UpdateSizeVars ( std::size_t  nSize)
private

Recalculates mnCurrSize and mnSliceSize.

Definition at line 401 of file xestream.cxx.

References mnCurrMaxSize, mnCurrSize, mnMaxSliceSize, and mnSliceSize.

Referenced by PrepareWrite(), Write(), and WriteZeroBytes().

◆ Write()

std::size_t XclExpStream::Write ( const void *  pData,
std::size_t  nBytes 
)

◆ WriteByteString()

void XclExpStream::WriteByteString ( const OString &  rString)

Writes string length field and OString buffer.

Definition at line 333 of file xestream.cxx.

References mbInRec, PrepareWrite(), SetSliceSize(), StartContinue(), and Write().

◆ WriteCharBuffer()

void XclExpStream::WriteCharBuffer ( const ScfUInt8Vec rBuffer)

Writes 8-bit character buffer.

Definition at line 347 of file xestream.cxx.

References SetSliceSize(), and Write().

◆ WriteRawZeroBytes()

void XclExpStream::WriteRawZeroBytes ( std::size_t  nBytes)
private

Writes a raw sequence of zero bytes.

Definition at line 449 of file xestream.cxx.

References mrStrm, SvStream::WriteBytes(), and SvStream::WriteUInt32().

Referenced by WriteZeroBytes().

◆ WriteUnicodeBuffer()

void XclExpStream::WriteUnicodeBuffer ( const ScfUInt16Vec rBuffer,
sal_uInt8  nFlags 
)

Writes Unicode buffer as 8/16 bit, repeats nFlags at start of a CONTINUE record.

Definition at line 310 of file xestream.cxx.

References EXC_STRF_16BIT, mbInRec, mnCurrMaxSize, mnCurrSize, operator<<(), SetSliceSize(), and StartContinue().

◆ WriteZeroBytes()

void XclExpStream::WriteZeroBytes ( std::size_t  nBytes)

Writes a sequence of nBytes zero bytes (respects slice setting).

Definition at line 261 of file xestream.cxx.

References mbInRec, PrepareWrite(), UpdateSizeVars(), and WriteRawZeroBytes().

Referenced by XclExpHyperlink::XclExpHyperlink().

◆ WriteZeroBytesToRecord()

void XclExpStream::WriteZeroBytesToRecord ( std::size_t  nBytes)

Definition at line 278 of file xestream.cxx.

References i, and mbInRec.

Member Data Documentation

◆ mbInRec

bool XclExpStream::mbInRec
private

Stream position of size field in current header.

Definition at line 187 of file xestream.hxx.

Referenced by EndRecord(), PrepareWrite(), SetSvStreamPos(), StartRecord(), Write(), WriteByteString(), WriteUnicodeBuffer(), WriteZeroBytes(), and WriteZeroBytesToRecord().

◆ mbUseEncrypter

bool XclExpStream::mbUseEncrypter
private

Filter root data.

Definition at line 172 of file xestream.hxx.

Referenced by EnableEncryption(), operator<<(), and Write().

◆ mnCurrMaxSize

sal_uInt16 XclExpStream::mnCurrMaxSize
private

Maximum size of CONTINUE content.

Definition at line 178 of file xestream.hxx.

Referenced by InitRecord(), PrepareWrite(), StartContinue(), StartRecord(), UpdateSizeVars(), and WriteUnicodeBuffer().

◆ mnCurrSize

sal_uInt16 XclExpStream::mnCurrSize
private

Record size written in last record header.

Definition at line 181 of file xestream.hxx.

Referenced by GetRawRecPos(), InitRecord(), PrepareWrite(), StartContinue(), UpdateRecSize(), UpdateSizeVars(), and WriteUnicodeBuffer().

◆ mnHeaderSize

sal_uInt16 XclExpStream::mnHeaderSize
private

Maximum size of data slices (parts that cannot be split).

Definition at line 180 of file xestream.hxx.

Referenced by InitRecord(), and UpdateRecSize().

◆ mnLastSizePos

std::size_t XclExpStream::mnLastSizePos
private

Predicted size received from calling function.

Definition at line 186 of file xestream.hxx.

Referenced by InitRecord(), and UpdateRecSize().

◆ mnMaxContSize

sal_uInt16 XclExpStream::mnMaxContSize
private

Maximum size of record content.

Definition at line 177 of file xestream.hxx.

Referenced by StartContinue(), StartRecord(), and XclExpStream().

◆ mnMaxRecSize

sal_uInt16 XclExpStream::mnMaxRecSize
private

Definition at line 176 of file xestream.hxx.

Referenced by StartRecord(), and XclExpStream().

◆ mnMaxSliceSize

sal_uInt16 XclExpStream::mnMaxSliceSize
private

Current maximum, either mnMaxRecSize or mnMaxContSize.

Definition at line 179 of file xestream.hxx.

Referenced by PrepareWrite(), SetSliceSize(), and UpdateSizeVars().

◆ mnPredictSize

std::size_t XclExpStream::mnPredictSize
private

Count of bytes already written in current slice.

Definition at line 183 of file xestream.hxx.

Referenced by InitRecord(), StartContinue(), and StartRecord().

◆ mnSliceSize

sal_uInt16 XclExpStream::mnSliceSize
private

Count of bytes already written in current record.

Definition at line 182 of file xestream.hxx.

Referenced by InitRecord(), PrepareWrite(), SetSliceSize(), and UpdateSizeVars().

◆ mrRoot

const XclExpRoot& XclExpStream::mrRoot
private

Reference to the system output stream.

Definition at line 170 of file xestream.hxx.

Referenced by GetRoot(), and XclExpStream().

◆ mrStrm

SvStream& XclExpStream::mrStrm
private

◆ mxEncrypter

XclExpEncrypterRef XclExpStream::mxEncrypter
private

Definition at line 173 of file xestream.hxx.

Referenced by HasValidEncrypter(), operator<<(), SetEncrypter(), and Write().


The documentation for this class was generated from the following files: