From 047c2de1647b974f6091d73d89d152ff09410a8b Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 27 Mar 2012 23:28:50 +0100 Subject: BiffOutputStream never constructed --- sc/source/filter/inc/addressconverter.hxx | 1 - sc/source/filter/inc/biffoutputstream.hxx | 42 ------------------- sc/source/filter/oox/biffoutputstream.cxx | 69 ------------------------------- 3 files changed, 112 deletions(-) (limited to 'sc') diff --git a/sc/source/filter/inc/addressconverter.hxx b/sc/source/filter/inc/addressconverter.hxx index 8cbc50bc3ef0..0354e31cc4ca 100644 --- a/sc/source/filter/inc/addressconverter.hxx +++ b/sc/source/filter/inc/addressconverter.hxx @@ -38,7 +38,6 @@ namespace oox { namespace xls { class BiffInputStream; -class BiffOutputStream; // ============================================================================ // ============================================================================ diff --git a/sc/source/filter/inc/biffoutputstream.hxx b/sc/source/filter/inc/biffoutputstream.hxx index 543c4a8b31c0..20e92ea56c5e 100644 --- a/sc/source/filter/inc/biffoutputstream.hxx +++ b/sc/source/filter/inc/biffoutputstream.hxx @@ -75,48 +75,6 @@ private: } // namespace prv -// ============================================================================ - -/** This class is used to write BIFF record streams. - - An instance is constructed with a BinaryOutputStream object and the - maximum size of BIFF record contents (e.g. 2080 bytes in BIFF2-BIFF5, or - 8224 bytes in BIFF8). -*/ -class BiffOutputStream : public BinaryOutputStream -{ -public: - // record control --------------------------------------------------------- - - // BinaryOutputStream interface (stream write access) --------------------- - - /** Writes the passed data sequence. */ - virtual void writeData( const StreamDataSequence& rData, size_t nAtomSize = 1 ); - /** Writes nBytes bytes from the passed buffer pMem. */ - virtual void writeMemory( const void* pMem, sal_Int32 nBytes, size_t nAtomSize = 1 ); - - /** Stream operator for all data types supported by the writeValue() function. */ - template< typename Type > - inline BiffOutputStream& operator<<( Type nValue ) { writeValue( nValue ); return *this; } - - // ------------------------------------------------------------------------ -private: - /** Checks the remaining size in the current record, creates CONTINUE record if needed. */ - void ensureRawBlock( sal_uInt16 nSize ); - - /** Checks the remaining size in the current record and creates a CONTINUE - record if needed. - @return Maximum size left for writing to current record. */ - sal_uInt16 prepareWriteBlock( sal_Int32 nTotalSize, size_t nAtomSize ); - -private: - prv::BiffOutputRecordBuffer maRecBuffer; /// Raw record data buffer. - sal_uInt8 mnPortionSize; /// Size of data portions. - sal_uInt8 mnPortionPos; /// Position in current portion. -}; - -// ============================================================================ - } // namespace xls } // namespace oox diff --git a/sc/source/filter/oox/biffoutputstream.cxx b/sc/source/filter/oox/biffoutputstream.cxx index 344dd2973db5..dc7f39f89bb7 100644 --- a/sc/source/filter/oox/biffoutputstream.cxx +++ b/sc/source/filter/oox/biffoutputstream.cxx @@ -75,75 +75,6 @@ void BiffOutputRecordBuffer::write( const void* pData, sal_uInt16 nBytes ) } // namespace prv -// BinaryOutputStream interface (stream write access) ------------------------- - -void BiffOutputStream::writeData( const StreamDataSequence& rData, size_t nAtomSize ) -{ - if( rData.hasElements() ) - writeMemory( rData.getConstArray(), rData.getLength(), nAtomSize ); -} - -void BiffOutputStream::writeMemory( const void* pMem, sal_Int32 nBytes, size_t nAtomSize ) -{ - if( pMem && (nBytes > 0) ) - { - const sal_uInt8* pnBuffer = reinterpret_cast< const sal_uInt8* >( pMem ); - sal_Int32 nBytesLeft = nBytes; - while( nBytesLeft > 0 ) - { - sal_uInt16 nBlockSize = prepareWriteBlock( nBytesLeft, nAtomSize ); - maRecBuffer.write( pnBuffer, nBlockSize ); - pnBuffer += nBlockSize; - nBytesLeft -= nBlockSize; - } - } -} - -// private -------------------------------------------------------------------- - -sal_uInt16 BiffOutputStream::prepareWriteBlock( sal_Int32 nTotalSize, size_t nAtomSize ) -{ - sal_uInt16 nRecLeft = maRecBuffer.getRecLeft(); - if( mnPortionSize <= 1 ) - { - // no portions: restrict remaining record size to entire atoms - nRecLeft = static_cast< sal_uInt16 >( (nRecLeft / nAtomSize) * nAtomSize ); - } - else - { - sal_Int32 nPortionLeft = mnPortionSize - mnPortionPos; - if( nTotalSize <= nPortionLeft ) - { - // block fits into the current portion - OSL_ENSURE( nPortionLeft <= nRecLeft, "BiffOutputStream::prepareWriteBlock - portion exceeds record" ); - mnPortionPos = static_cast< sal_uInt8 >( (mnPortionPos + nTotalSize) % mnPortionSize ); - } - else - { - // restrict remaining record size to entire portions - OSL_ENSURE( mnPortionPos == 0, "BiffOutputStream::prepareWriteBlock - writing over multiple portions starts inside portion" ); - mnPortionPos = 0; - // check that atom size matches portion size - OSL_ENSURE( mnPortionSize % nAtomSize == 0, "BiffOutputStream::prepareWriteBlock - atom size does not match portion size" ); - sal_uInt8 nPortionSize = static_cast< sal_uInt8 >( (mnPortionSize / nAtomSize) * nAtomSize ); - // restrict remaining record size to entire portions - nRecLeft = (nRecLeft / nPortionSize) * nPortionSize; - } - } - - // current record has space for some data: return size of available space - if( nRecLeft > 0 ) - return getLimitedValue< sal_uInt16, sal_Int32 >( nTotalSize, 0, nRecLeft ); - - // finish current record and start a new CONTINUE record - maRecBuffer.endRecord(); - maRecBuffer.startRecord( BIFF_ID_CONT ); - mnPortionPos = 0; - return prepareWriteBlock( nTotalSize, nAtomSize ); -} - -// ============================================================================ - } // namespace xls } // namespace oox -- cgit