LibreOffice Module sc (master) 1
|
This class is used to export Excel record streams. More...
#include <xestream.hxx>
Public Member Functions | |
XclExpStream (SvStream &rOutStrm, const XclExpRoot &rRoot, sal_uInt16 nMaxRecSize=0) | |
Constructs the Excel record export stream. More... | |
~XclExpStream () | |
const XclExpRoot & | GetRoot () 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... | |
XclExpStream & | operator<< (sal_Int8 nValue) |
XclExpStream & | operator<< (sal_uInt8 nValue) |
XclExpStream & | operator<< (sal_Int16 nValue) |
XclExpStream & | operator<< (sal_uInt16 nValue) |
XclExpStream & | operator<< (sal_Int32 nValue) |
XclExpStream & | operator<< (sal_uInt32 nValue) |
XclExpStream & | operator<< (float fValue) |
XclExpStream & | operator<< (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 | |
SvStream & | mrStrm |
const XclExpRoot & | mrRoot |
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... | |
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.
XclExpStream::XclExpStream | ( | SvStream & | rOutStrm, |
const XclExpRoot & | rRoot, | ||
sal_uInt16 | nMaxRecSize = 0 |
||
) |
Constructs the Excel record export stream.
rOutStrm | The system output stream to write to. |
nMaxRecSize | The 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 93 of file xestream.cxx.
References EXC_BIFF5, EXC_MAXRECSIZE_BIFF5, EXC_MAXRECSIZE_BIFF8, XclRoot::GetBiff(), mnMaxContSize, mnMaxRecSize, and mrRoot.
XclExpStream::~XclExpStream | ( | ) |
Definition at line 112 of file xestream.cxx.
References SvStream::FlushBuffer(), and mrStrm.
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 292 of file xestream.cxx.
References SvStream::ReadBytes(), SvStream::remainingSize(), and Write().
void XclExpStream::DisableEncryption | ( | ) |
Definition at line 372 of file xestream.cxx.
References EnableEncryption().
Referenced by EndRecord(), and StartRecord().
void XclExpStream::EnableEncryption | ( | bool | bEnable = true | ) |
Definition at line 367 of file xestream.cxx.
References HasValidEncrypter(), and mbUseEncrypter.
Referenced by DisableEncryption(), and StartRecord().
void XclExpStream::EndRecord | ( | ) |
Checks and corrects real record length.
Must be called every time a record is finished.
Definition at line 129 of file xestream.cxx.
References DisableEncryption(), mbInRec, mrStrm, SvStream::Seek(), STREAM_SEEK_TO_END, and UpdateRecSize().
|
inline |
Returns the position inside of current record (starts by 0 in every CONTINUE).
Definition at line 95 of file xestream.hxx.
References mnCurrSize.
|
inline |
|
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().
bool XclExpStream::HasValidEncrypter | ( | ) | const |
Definition at line 362 of file xestream.cxx.
References mxEncrypter.
Referenced by EnableEncryption(), operator<<(), and Write().
|
private |
Writes header data, internal setup.
Definition at line 385 of file xestream.cxx.
References mnCurrMaxSize, mnCurrSize, mnHeaderSize, mnLastSizePos, mnPredictSize, mnSliceSize, mrStrm, SvStream::Seek(), STREAM_SEEK_TO_END, SvStream::Tell(), and SvStream::WriteUInt16().
Referenced by StartContinue(), and StartRecord().
XclExpStream & XclExpStream::operator<< | ( | double | fValue | ) |
Definition at line 214 of file xestream.cxx.
References HasValidEncrypter(), mbUseEncrypter, mrStrm, mxEncrypter, PrepareWrite(), and SvStream::WriteDouble().
XclExpStream & XclExpStream::operator<< | ( | float | fValue | ) |
Definition at line 204 of file xestream.cxx.
References HasValidEncrypter(), mbUseEncrypter, mrStrm, mxEncrypter, PrepareWrite(), and SvStream::WriteFloat().
XclExpStream & XclExpStream::operator<< | ( | sal_Int16 | nValue | ) |
Definition at line 164 of file xestream.cxx.
References HasValidEncrypter(), mbUseEncrypter, mrStrm, mxEncrypter, nValue, PrepareWrite(), and SvStream::WriteInt16().
XclExpStream & XclExpStream::operator<< | ( | sal_Int32 | nValue | ) |
Definition at line 184 of file xestream.cxx.
References HasValidEncrypter(), mbUseEncrypter, mrStrm, mxEncrypter, nValue, PrepareWrite(), and SvStream::WriteInt32().
XclExpStream & XclExpStream::operator<< | ( | sal_Int8 | nValue | ) |
Definition at line 144 of file xestream.cxx.
References HasValidEncrypter(), mbUseEncrypter, mrStrm, mxEncrypter, nValue, PrepareWrite(), and SvStream::WriteSChar().
Referenced by WriteUnicodeBuffer().
XclExpStream & XclExpStream::operator<< | ( | sal_uInt16 | nValue | ) |
Definition at line 174 of file xestream.cxx.
References HasValidEncrypter(), mbUseEncrypter, mrStrm, mxEncrypter, nValue, PrepareWrite(), and SvStream::WriteUInt16().
XclExpStream & XclExpStream::operator<< | ( | sal_uInt32 | nValue | ) |
Definition at line 194 of file xestream.cxx.
References HasValidEncrypter(), mbUseEncrypter, mrStrm, mxEncrypter, nValue, PrepareWrite(), and SvStream::WriteUInt32().
XclExpStream & XclExpStream::operator<< | ( | sal_uInt8 | nValue | ) |
Definition at line 154 of file xestream.cxx.
References HasValidEncrypter(), mbUseEncrypter, mrStrm, mxEncrypter, nValue, PrepareWrite(), and SvStream::WriteUChar().
|
private |
Creates CONTINUE record at end of record.
Definition at line 438 of file xestream.cxx.
References mbInRec, mnCurrMaxSize, mnCurrSize, mnMaxSliceSize, mnSliceSize, StartContinue(), and UpdateSizeVars().
Referenced by operator<<(), Write(), WriteByteString(), and WriteZeroBytes().
|
private |
Refreshes counter vars, creates CONTINUE records.
Definition at line 427 of file xestream.cxx.
References mbInRec, mnCurrMaxSize, mnCurrSize, mnMaxSliceSize, mnSliceSize, StartContinue(), and UpdateSizeVars().
void XclExpStream::SetEncrypter | ( | XclExpEncrypterRef const & | xEncrypter | ) |
Definition at line 357 of file xestream.cxx.
References mxEncrypter.
void XclExpStream::SetSliceSize | ( | sal_uInt16 | nSize | ) |
Sets data slice length.
0 = no slices.
Definition at line 138 of file xestream.cxx.
References mnMaxSliceSize, and mnSliceSize.
Referenced by StartRecord(), WriteByteString(), WriteCharBuffer(), and WriteUnicodeBuffer().
void XclExpStream::SetSvStreamPos | ( | sal_uInt64 | nPos | ) |
Sets position of system stream (only allowed outside of records).
Definition at line 377 of file xestream.cxx.
References mbInRec, mrStrm, nPos, and SvStream::Seek().
|
private |
Writes CONTINUE header, internal setup.
Definition at line 419 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 117 of file xestream.cxx.
References DisableEncryption(), EnableEncryption(), InitRecord(), mbInRec, mnCurrMaxSize, mnMaxContSize, mnMaxRecSize, mnPredictSize, and SetSliceSize().
|
private |
Rewrites correct record length, if different from calculated.
Definition at line 396 of file xestream.cxx.
References mnCurrSize, mnHeaderSize, mnLastSizePos, mrStrm, SvStream::Seek(), and SvStream::WriteUInt16().
Referenced by EndRecord(), and StartContinue().
|
private |
Recalculates mnCurrSize and mnSliceSize.
Definition at line 405 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 | ||
) |
Writes nBytes bytes from memory.
Definition at line 224 of file xestream.cxx.
References HasValidEncrypter(), mbInRec, mbUseEncrypter, mrStrm, mxEncrypter, pData, PrepareWrite(), UpdateSizeVars(), and SvStream::WriteBytes().
Referenced by CopyFromStream(), operator<<(), WriteByteString(), WriteCharBuffer(), and XclExpHyperlink::XclExpHyperlink().
void XclExpStream::WriteByteString | ( | const OString & | rString | ) |
Writes string length field and OString buffer.
Definition at line 337 of file xestream.cxx.
References mbInRec, PrepareWrite(), SetSliceSize(), StartContinue(), and Write().
void XclExpStream::WriteCharBuffer | ( | const ScfUInt8Vec & | rBuffer | ) |
Writes 8-bit character buffer.
Definition at line 351 of file xestream.cxx.
References SetSliceSize(), and Write().
|
private |
Writes a raw sequence of zero bytes.
Definition at line 453 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 314 of file xestream.cxx.
References EXC_STRF_16BIT, mbInRec, mnCurrMaxSize, mnCurrSize, operator<<(), SetSliceSize(), and StartContinue().
void XclExpStream::WriteZeroBytes | ( | std::size_t | nBytes | ) |
Writes a sequence of nBytes zero bytes (respects slice setting).
Definition at line 265 of file xestream.cxx.
References mbInRec, PrepareWrite(), UpdateSizeVars(), and WriteRawZeroBytes().
Referenced by XclExpHyperlink::XclExpHyperlink().
void XclExpStream::WriteZeroBytesToRecord | ( | std::size_t | nBytes | ) |
Definition at line 282 of file xestream.cxx.
|
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().
|
private |
Filter root data.
Definition at line 172 of file xestream.hxx.
Referenced by EnableEncryption(), operator<<(), and Write().
|
private |
Maximum size of CONTINUE content.
Definition at line 178 of file xestream.hxx.
Referenced by InitRecord(), PrepareWrite(), StartContinue(), StartRecord(), UpdateSizeVars(), and WriteUnicodeBuffer().
|
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().
|
private |
Maximum size of data slices (parts that cannot be split).
Definition at line 180 of file xestream.hxx.
Referenced by InitRecord(), and UpdateRecSize().
|
private |
Predicted size received from calling function.
Definition at line 186 of file xestream.hxx.
Referenced by InitRecord(), and UpdateRecSize().
|
private |
Maximum size of record content.
Definition at line 177 of file xestream.hxx.
Referenced by StartContinue(), StartRecord(), and XclExpStream().
|
private |
Definition at line 176 of file xestream.hxx.
Referenced by StartRecord(), and XclExpStream().
|
private |
Current maximum, either mnMaxRecSize or mnMaxContSize.
Definition at line 179 of file xestream.hxx.
Referenced by PrepareWrite(), SetSliceSize(), and UpdateSizeVars().
|
private |
Count of bytes already written in current slice.
Definition at line 183 of file xestream.hxx.
Referenced by InitRecord(), StartContinue(), and StartRecord().
|
private |
Count of bytes already written in current record.
Definition at line 182 of file xestream.hxx.
Referenced by InitRecord(), PrepareWrite(), SetSliceSize(), and UpdateSizeVars().
|
private |
Reference to the system output stream.
Definition at line 170 of file xestream.hxx.
Referenced by GetRoot(), and XclExpStream().
|
private |
Definition at line 169 of file xestream.hxx.
Referenced by EndRecord(), GetSvStreamPos(), InitRecord(), operator<<(), SetSvStreamPos(), UpdateRecSize(), Write(), WriteRawZeroBytes(), and ~XclExpStream().
|
private |
Definition at line 173 of file xestream.hxx.
Referenced by HasValidEncrypter(), operator<<(), SetEncrypter(), and Write().