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.

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 71 of file xestream.hxx.

Constructor & Destructor Documentation

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 84 of file xestream.cxx.

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

XclExpStream::~XclExpStream ( )

Definition at line 103 of file xestream.cxx.

References SvStream::Flush(), and mrStrm.

Member Function Documentation

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

Copies nBytes bytes from current position of the stream rInStrm.

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

Definition at line 283 of file xestream.cxx.

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

Referenced by XclExpSstImpl::Save(), XclExpMsoDrawingBase::WriteBody(), XclObj::WriteBody(), XclExpChEscherFormat::WriteBody(), and XclExpHyperlink::WriteEmbeddedData().

void XclExpStream::DisableEncryption ( )
void XclExpStream::EnableEncryption ( bool  bEnable = true)
void XclExpStream::EndRecord ( )

Checks and corrects real record length.

Must be called every time a record is finished.

Definition at line 120 of file xestream.cxx.

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

Referenced by XclExpChRootData::InitializeFutureRecBlock(), XclExpMergedcells::Save(), XclExpSstImpl::Save(), XclExpLabelranges::Save(), XclExpImgData::Save(), XclExpRecord::Save(), XclTxo::Save(), XclExpFutureRecord::Save(), XclExpNote::Save(), XclExpWebQuery::Save(), XclExpSubStream::Save(), XclExpChSourceLink::Save(), XclExpMultiCellBase::Save(), XclExpChLabelRange::Save(), XclExpPivotCache::WriteDConName(), XclExpPivotCache::WriteDconref(), XclExpNumFmtBuffer::WriteFormatRecord(), XclExpControlHelper::WriteFormulaSubRec(), XclExpPivotTable::WriteQsiSxTag(), XclExpTbxControlObj::WriteSbs(), XclExpChEscherFormat::WriteSubRecords(), XclExpChChart::WriteSubRecords(), XclObjDropDown::WriteSubRecs(), XclExpOcxControlObj::WriteSubRecs(), XclObjOle::WriteSubRecs(), XclExpTbxControlObj::WriteSubRecs(), XclExpPivotCache::WriteSxdb(), XclExpPivotCache::WriteSxdbex(), XclExpPTField::WriteSxdi(), XclExpPivotTable::WriteSxex(), XclExpPCField::WriteSxgroupinfo(), XclExpPivotCache::WriteSxindexlistList(), XclExpPivotTable::WriteSxivd(), XclExpPivotTable::WriteSxli(), XclExpPCField::WriteSxnumgroup(), XclExpPivotTable::WriteSxpi(), XclExpPTField::WriteSxvd(), XclExpPTField::WriteSxvdex(), XclExpPivotTable::WriteSxview(), and XclExpPivotTable::WriteSxViewEx9().

sal_uInt16 XclExpStream::GetRawRecPos ( ) const
inline

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

Definition at line 94 of file xestream.hxx.

References mnCurrSize.

Referenced by XclExpSstImpl::Save().

const XclExpRoot& XclExpStream::GetRoot ( ) const
inline
sal_uInt64 XclExpStream::GetSvStreamPos ( ) const
inline

Returns the absolute position of the system stream.

Definition at line 139 of file xestream.hxx.

References mrStrm, and SvStream::Tell().

Referenced by XclExpSstImpl::Save(), ExcBundlesheet::SaveCont(), ExcBundlesheet8::SaveCont(), and ExcDocument::Write().

bool XclExpStream::HasValidEncrypter ( ) const

Definition at line 353 of file xestream.cxx.

References mxEncrypter.

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

void XclExpStream::InitRecord ( sal_uInt16  nRecId)
private
XclExpStream & XclExpStream::operator<< ( sal_Int8  nValue)
XclExpStream & XclExpStream::operator<< ( sal_uInt8  nValue)
XclExpStream & XclExpStream::operator<< ( sal_Int16  nValue)
XclExpStream & XclExpStream::operator<< ( sal_uInt16  nValue)
XclExpStream & XclExpStream::operator<< ( sal_Int32  nValue)
XclExpStream & XclExpStream::operator<< ( sal_uInt32  nValue)
XclExpStream & XclExpStream::operator<< ( float  fValue)
XclExpStream & XclExpStream::operator<< ( double  fValue)
void XclExpStream::PrepareWrite ( sal_uInt16  nSize)
private

Refreshes counter vars, creates CONTINUE records.

Definition at line 418 of file xestream.cxx.

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

sal_uInt16 XclExpStream::PrepareWrite ( )
private

Creates CONTINUE record at end of record.

Returns
Maximum data block size remaining.

Definition at line 429 of file xestream.cxx.

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

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

void XclExpStream::SetEncrypter ( XclExpEncrypterRef const &  xEncrypter)

Definition at line 348 of file xestream.cxx.

References mxEncrypter.

Referenced by XclExpFileEncryption::WriteBody().

void XclExpStream::SetSliceSize ( sal_uInt16  nSize)
void XclExpStream::SetSvStreamPos ( sal_uInt64  nPos)

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

Definition at line 368 of file xestream.cxx.

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

Referenced by ExcBundlesheetBase::UpdateStreamPos().

void XclExpStream::StartContinue ( )
private

Writes CONTINUE header, internal setup.

Definition at line 410 of file xestream.cxx.

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

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

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

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

Definition at line 108 of file xestream.cxx.

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

Referenced by XclExpChRootData::InitializeFutureRecBlock(), XclExpMergedcells::Save(), XclExpSstImpl::Save(), XclExpLabelranges::Save(), XclExpImgData::Save(), XclExpRecord::Save(), XclTxo::Save(), XclExpFutureRecord::Save(), XclExpNote::Save(), XclExpWebQuery::Save(), XclExpSubStream::Save(), XclExpChSourceLink::Save(), XclExpMultiCellBase::Save(), XclExpChLabelRange::Save(), XclExpPivotCache::WriteDConName(), XclExpPivotCache::WriteDconref(), XclExpNumFmtBuffer::WriteFormatRecord(), XclExpControlHelper::WriteFormulaSubRec(), XclExpPivotTable::WriteQsiSxTag(), XclExpTbxControlObj::WriteSbs(), XclExpChEscherFormat::WriteSubRecords(), XclExpChChart::WriteSubRecords(), XclObjDropDown::WriteSubRecs(), XclExpOcxControlObj::WriteSubRecs(), XclObjOle::WriteSubRecs(), XclExpTbxControlObj::WriteSubRecs(), XclExpPivotCache::WriteSxdb(), XclExpPivotCache::WriteSxdbex(), XclExpPTField::WriteSxdi(), XclExpPivotTable::WriteSxex(), XclExpPCField::WriteSxgroupinfo(), XclExpPivotCache::WriteSxindexlistList(), XclExpPivotTable::WriteSxivd(), XclExpPivotTable::WriteSxli(), XclExpPCField::WriteSxnumgroup(), XclExpPivotTable::WriteSxpi(), XclExpPTField::WriteSxvd(), XclExpPTField::WriteSxvdex(), XclExpPivotTable::WriteSxview(), and XclExpPivotTable::WriteSxViewEx9().

void XclExpStream::UpdateRecSize ( )
private

Rewrites correct record length, if different from calculated.

Definition at line 387 of file xestream.cxx.

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

Referenced by EndRecord(), and StartContinue().

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

Recalculates mnCurrSize and mnSliceSize.

Definition at line 396 of file xestream.cxx.

References mnCurrMaxSize, mnCurrSize, mnMaxSliceSize, and mnSliceSize.

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

std::size_t XclExpStream::Write ( const void pData,
std::size_t  nBytes 
)
void XclExpStream::WriteByteString ( const OString &  rString)

Writes string length field and OString buffer.

Definition at line 328 of file xestream.cxx.

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

Referenced by ExcBundlesheet::SaveCont().

void XclExpStream::WriteCharBuffer ( const ScfUInt8Vec rBuffer)

Writes 8-bit character buffer.

Definition at line 342 of file xestream.cxx.

References SetSliceSize(), and Write().

Referenced by XclExpString::WriteBuffer().

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

Writes a raw sequence of zero bytes.

Definition at line 444 of file xestream.cxx.

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

Referenced by WriteZeroBytes().

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 305 of file xestream.cxx.

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

Referenced by XclExpString::WriteBuffer().

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

Definition at line 273 of file xestream.cxx.

References i, and mbInRec.

Referenced by XclExpSheetEnhancedProtection::WriteBody(), and XclExpCFImpl::WriteBody().

Member Data Documentation

bool XclExpStream::mbInRec
private

Stream position of size field in current header.

Definition at line 186 of file xestream.hxx.

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

bool XclExpStream::mbUseEncrypter
private

Filter root data.

Definition at line 171 of file xestream.hxx.

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

sal_uInt16 XclExpStream::mnCurrMaxSize
private

Maximum size of CONTINUE content.

Definition at line 177 of file xestream.hxx.

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

sal_uInt16 XclExpStream::mnCurrSize
private

Record size written in last record header.

Definition at line 180 of file xestream.hxx.

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

sal_uInt16 XclExpStream::mnHeaderSize
private

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

Definition at line 179 of file xestream.hxx.

Referenced by InitRecord(), and UpdateRecSize().

std::size_t XclExpStream::mnLastSizePos
private

Predicted size received from calling function.

Definition at line 185 of file xestream.hxx.

Referenced by InitRecord(), and UpdateRecSize().

sal_uInt16 XclExpStream::mnMaxContSize
private

Maximum size of record content.

Definition at line 176 of file xestream.hxx.

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

sal_uInt16 XclExpStream::mnMaxRecSize
private

Definition at line 175 of file xestream.hxx.

Referenced by StartRecord(), and XclExpStream().

sal_uInt16 XclExpStream::mnMaxSliceSize
private

Current maximum, either mnMaxRecSize or mnMaxContSize.

Definition at line 178 of file xestream.hxx.

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

std::size_t XclExpStream::mnPredictSize
private

Count of bytes already written in current slice.

Definition at line 182 of file xestream.hxx.

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

sal_uInt16 XclExpStream::mnSliceSize
private

Count of bytes already written in current record.

Definition at line 181 of file xestream.hxx.

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

const XclExpRoot& XclExpStream::mrRoot
private

Reference to the system output stream.

Definition at line 169 of file xestream.hxx.

Referenced by GetRoot(), and XclExpStream().

SvStream& XclExpStream::mrStrm
private
XclExpEncrypterRef XclExpStream::mxEncrypter
private

Definition at line 172 of file xestream.hxx.

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


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