diff options
author | Miklos Vajna <vmiklos@frugalware.org> | 2012-01-08 19:48:36 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@frugalware.org> | 2012-01-08 20:11:09 +0100 |
commit | effeb08efd1746a6a2d911452f38dc9c49685548 (patch) | |
tree | 7d5b86b7d53b4996ba8c6a38a3fb5ecf0ad4b7ff /filter | |
parent | 717e3912ed94a10c9405ac11c08eff6caba107ea (diff) |
Kill SvNullStream duplication
Diffstat (limited to 'filter')
-rw-r--r-- | filter/inc/filter/msfilter/escherex.hxx | 3 | ||||
-rw-r--r-- | filter/source/msfilter/escherex.cxx | 31 |
2 files changed, 31 insertions, 3 deletions
diff --git a/filter/inc/filter/msfilter/escherex.hxx b/filter/inc/filter/msfilter/escherex.hxx index 94f700f2ae4c..bfd78364a42c 100644 --- a/filter/inc/filter/msfilter/escherex.hxx +++ b/filter/inc/filter/msfilter/escherex.hxx @@ -1560,6 +1560,7 @@ class MSFILTER_DLLPUBLIC EscherEx : public EscherPersistTable EscherExGlobalRef mxGlobal; ImplEscherExSdrPtr mpImplEscherExSdr; SvStream* mpOutStrm; + bool mbOwnsStrm; sal_uInt32 mnStrmStartOfs; std::vector< sal_uInt32 > mOffsets; std::vector< sal_uInt16 > mRecTypes; @@ -1578,7 +1579,7 @@ class MSFILTER_DLLPUBLIC EscherEx : public EscherPersistTable virtual sal_Bool DoSeek( sal_uInt32 nKey ); public: - explicit EscherEx( const EscherExGlobalRef& rxGlobal, SvStream& rOutStrm ); + explicit EscherEx( const EscherExGlobalRef& rxGlobal, SvStream* pOutStrm ); virtual ~EscherEx(); /** Creates and returns a new shape identifier, updates the internal shape diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index 5aac23ddbdd5..6fdbcd4c3773 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -4365,9 +4365,29 @@ SvStream* EscherExGlobal::ImplQueryPictureStream() return 0; } -EscherEx::EscherEx( const EscherExGlobalRef& rxGlobal, SvStream& rOutStrm ) : +/// Implementation of an empty stream that silently succeeds, but does nothing. +/// +/// In fact, this is a hack. The right solution is to abstract EscherEx to be +/// able to work without SvStream; but at the moment it is better to live with +/// this I guess. +class SvNullStream : public SvStream +{ +protected: + virtual sal_Size GetData( void* pData, sal_Size nSize ) { memset( pData, 0, nSize ); return nSize; } + virtual sal_Size PutData( const void*, sal_Size nSize ) { return nSize; } + virtual sal_Size SeekPos( sal_Size nPos ) { return nPos; } + virtual void SetSize( sal_Size ) {} + virtual void FlushData() {} + +public: + SvNullStream() : SvStream() {} + virtual ~SvNullStream() {} +}; + +EscherEx::EscherEx( const EscherExGlobalRef& rxGlobal, SvStream* pOutStrm ) : mxGlobal ( rxGlobal ), - mpOutStrm ( &rOutStrm ), + mpOutStrm ( pOutStrm ), + mbOwnsStrm ( false ), mnCurrentDg ( 0 ), @@ -4377,12 +4397,19 @@ EscherEx::EscherEx( const EscherExGlobalRef& rxGlobal, SvStream& rOutStrm ) : mbEscherSpgr ( sal_False ), mbEscherDg ( sal_False ) { + if (!mpOutStrm) + { + mpOutStrm = new SvNullStream(); + mbOwnsStrm = true; + } mnStrmStartOfs = mpOutStrm->Tell(); mpImplEscherExSdr.reset( new ImplEscherExSdr( *this ) ); } EscherEx::~EscherEx() { + if (mbOwnsStrm) + delete mpOutStrm; } void EscherEx::Flush( SvStream* pPicStreamMergeBSE /* = NULL */ ) |