[Libreoffice-commits] .: filter/inc filter/source oox/source sc/source sd/source sw/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Sun Jan 8 11:11:13 PST 2012


 filter/inc/filter/msfilter/escherex.hxx |    3 ++-
 filter/source/msfilter/escherex.cxx     |   31 +++++++++++++++++++++++++++++--
 oox/source/export/vmlexport.cxx         |   21 +--------------------
 sc/source/filter/xcl97/xcl97esc.cxx     |    2 +-
 sd/source/filter/eppt/escherex.cxx      |    2 +-
 sw/source/filter/ww8/rtfsdrexport.cxx   |   21 +--------------------
 sw/source/filter/ww8/wrtw8esh.cxx       |    2 +-
 7 files changed, 36 insertions(+), 46 deletions(-)

New commits:
commit effeb08efd1746a6a2d911452f38dc9c49685548
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Sun Jan 8 19:48:36 2012 +0100

    Kill SvNullStream duplication

diff --git a/filter/inc/filter/msfilter/escherex.hxx b/filter/inc/filter/msfilter/escherex.hxx
index 94f700f..bfd7836 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 5aac23d..6fdbcd4 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 */ )
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index 554d49f..1912381 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -45,27 +45,8 @@ using rtl::OUStringBuffer;
 using namespace sax_fastparser;
 using namespace oox::vml;
 
-/// 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() {}
-};
-
 VMLExport::VMLExport( ::sax_fastparser::FSHelperPtr pSerializer )
-    : EscherEx( EscherExGlobalRef(new EscherExGlobal(0)), *( new SvNullStream ) ),
+    : EscherEx( EscherExGlobalRef(new EscherExGlobal(0)), 0 ),
       m_pSerializer( pSerializer ),
       m_pShapeAttrList( NULL ),
       m_nShapeType( ESCHER_ShpInst_Nil ),
diff --git a/sc/source/filter/xcl97/xcl97esc.cxx b/sc/source/filter/xcl97/xcl97esc.cxx
index e001062..eea131a 100644
--- a/sc/source/filter/xcl97/xcl97esc.cxx
+++ b/sc/source/filter/xcl97/xcl97esc.cxx
@@ -98,7 +98,7 @@ SvStream* XclEscherExGlobal::ImplQueryPictureStream()
 // ============================================================================
 
 XclEscherEx::XclEscherEx( const XclExpRoot& rRoot, XclExpObjectManager& rObjMgr, SvStream& rStrm, const XclEscherEx* pParent ) :
-    EscherEx( pParent ? pParent->mxGlobal : EscherExGlobalRef( new XclEscherExGlobal( rRoot ) ), rStrm ),
+    EscherEx( pParent ? pParent->mxGlobal : EscherExGlobalRef( new XclEscherExGlobal( rRoot ) ), &rStrm ),
     XclExpRoot( rRoot ),
     mrObjMgr( rObjMgr ),
     pCurrXclObj( NULL ),
diff --git a/sd/source/filter/eppt/escherex.cxx b/sd/source/filter/eppt/escherex.cxx
index d42bc0b..54ad99c 100644
--- a/sd/source/filter/eppt/escherex.cxx
+++ b/sd/source/filter/eppt/escherex.cxx
@@ -35,7 +35,7 @@
 // ---------------------------------------------------------------------------------------------
 
 PptEscherEx::PptEscherEx( SvStream& rOutStrm, const rtl::OUString& rBaseURI ) :
-    EscherEx( EscherExGlobalRef( new EscherExGlobal ), rOutStrm )
+    EscherEx( EscherExGlobalRef( new EscherExGlobal ), &rOutStrm )
 {
     mxGlobal->SetBaseURI( rBaseURI );
     mnCurrentDg = 0;
diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx
index dc1b67b..0db8dd2 100644
--- a/sw/source/filter/ww8/rtfsdrexport.cxx
+++ b/sw/source/filter/ww8/rtfsdrexport.cxx
@@ -40,27 +40,8 @@ using rtl::OUString;
 using rtl::OUStringBuffer;
 using namespace sw::util;
 
-/// 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() {}
-};
-
 RtfSdrExport::RtfSdrExport( RtfExport &rExport )
-    : EscherEx( EscherExGlobalRef( new EscherExGlobal ), *( new SvNullStream )),
+    : EscherEx( EscherExGlobalRef( new EscherExGlobal ), 0 ),
       m_rExport( rExport ),
       m_rAttrOutput( (RtfAttributeOutput&)m_rExport.AttrOutput() ),
       m_nShapeType( ESCHER_ShpInst_Nil ),
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 143b824..5529449 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -1306,7 +1306,7 @@ SvStream* SwEscherExGlobal::ImplQueryPictureStream()
 }
 
 SwBasicEscherEx::SwBasicEscherEx(SvStream* pStrm, WW8Export& rWW8Wrt)
-    : EscherEx( EscherExGlobalRef( new SwEscherExGlobal ), *pStrm), rWrt(rWW8Wrt), pEscherStrm(pStrm)
+    : EscherEx( EscherExGlobalRef( new SwEscherExGlobal ), pStrm), rWrt(rWW8Wrt), pEscherStrm(pStrm)
 {
     Init();
 }


More information about the Libreoffice-commits mailing list