[Libreoffice-commits] .: 5 commits - sw/Library_msword.mk sw/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Mon Mar 5 01:09:18 PST 2012


 sw/Library_msword.mk                        |    1 
 sw/source/filter/ww8/rtfattributeoutput.cxx |  426 ++++++++++++++--------------
 sw/source/filter/ww8/rtfattributeoutput.hxx |   10 
 sw/source/filter/ww8/rtfsdrexport.cxx       |   12 
 sw/source/filter/ww8/rtfstringbuffer.cxx    |  121 +++++++
 sw/source/filter/ww8/rtfstringbuffer.hxx    |   84 +++++
 6 files changed, 440 insertions(+), 214 deletions(-)

New commits:
commit 4f56b20b567fd6fc0b3c428c8e3811eae7f2e679
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Mar 5 10:01:54 2012 +0100

    RtfAttributeOutput::FlyFrameGraphic: don't try to compare a null pointer

diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index a0c3b0b..b9afd1b 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -3453,7 +3453,7 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const S
        the wmf format wrapped in nonshppict, so as to keep wordpad happy. If its
        a wmf already then we don't need any such wrapping
        */
-    bool bIsWMF = std::strcmp(pBLIPType, OOO_STRING_SVTOOLS_RTF_WMETAFILE) == 0;
+    bool bIsWMF = pBLIPType && std::strcmp(pBLIPType, OOO_STRING_SVTOOLS_RTF_WMETAFILE) == 0;
     if (!bIsWMF)
         m_rExport.Strm() << "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT;
 
commit 622ce4681dbcddfdd5cbcd95ebbf1f14e93489ed
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Mar 5 09:44:48 2012 +0100

    i#118986 RTF: reduce memory usage when exporting large graphics
    
    Delay the call to FlyFrameGraphic() till we can write the result to the
    stream without buffering in memory; 1.048GB -> 330.1MB memory usage with
    the bugdoc.

diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index eaf9ee3..a0c3b0b 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -1538,7 +1538,7 @@ void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Poi
             }
 
             if ( pGrfNode )
-                FlyFrameGraphic( dynamic_cast<const SwFlyFrmFmt*>( &rFrame.GetFrmFmt() ), pGrfNode );
+                m_aRunText.append(dynamic_cast<const SwFlyFrmFmt*>( &rFrame.GetFrmFmt() ), pGrfNode);
             break;
         case sw::Frame::eDrawing:
             {
@@ -3455,10 +3455,10 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const S
        */
     bool bIsWMF = std::strcmp(pBLIPType, OOO_STRING_SVTOOLS_RTF_WMETAFILE) == 0;
     if (!bIsWMF)
-        m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
+        m_rExport.Strm() << "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT;
 
     if (pBLIPType)
-        m_aRunText->append(ExportPICT( pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport ));
+        ExportPICT( pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport, &m_rExport.Strm() );
     else
     {
         aStream.Seek(0);
@@ -3468,12 +3468,12 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const S
         nSize = aStream.Tell();
         pGraphicAry = (sal_uInt8*)aStream.GetData();
 
-        m_aRunText->append(ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport ));
+        ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport, &m_rExport.Strm() );
     }
 
     if (!bIsWMF)
     {
-        m_aRunText->append("}" "{" OOO_STRING_SVTOOLS_RTF_NONSHPPICT);
+        m_rExport.Strm() << "}" "{" OOO_STRING_SVTOOLS_RTF_NONSHPPICT;
 
         aStream.Seek(0);
         GraphicConverter::Export(aStream, aGraphic, CVT_WMF);
@@ -3482,12 +3482,12 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const S
         nSize = aStream.Tell();
         pGraphicAry = (sal_uInt8*)aStream.GetData();
 
-        m_aRunText->append(ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport ));
+        ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport, &m_rExport.Strm() );
 
-        m_aRunText->append('}');
+        m_rExport.Strm() << '}';
     }
 
-    m_aRunText->append(m_rExport.sNewLine);
+    m_rExport.Strm() << m_rExport.sNewLine;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 9b6e7eb1bad4344be0e766f4c05f0a3f28cb737d
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Mar 5 09:44:18 2012 +0100

    make ExportPICT() and WriteHex() be able to write to a stream

diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index ce72a1a..eaf9ee3 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -3160,7 +3160,7 @@ static bool StripMetafileHeader(const sal_uInt8 *&rpGraphicAry, unsigned long &r
     return false;
 }
 
-OString RtfAttributeOutput::WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, sal_uInt32 nLimit)
+OString RtfAttributeOutput::WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, SvStream* pStream, sal_uInt32 nLimit)
 {
     OStringBuffer aRet;
 
@@ -3169,11 +3169,22 @@ OString RtfAttributeOutput::WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, s
     {
         OString sNo = OString::valueOf(sal_Int32(pData[i]), 16);
         if (sNo.getLength() < 2)
-            aRet.append('0');
-        aRet.append(sNo);
+        {
+            if (pStream)
+                (*pStream) << '0';
+            else
+                aRet.append('0');
+        }
+        if (pStream)
+            (*pStream) << sNo.getStr();
+        else
+            aRet.append(sNo);
         if (++nBreak == nLimit)
         {
-            aRet.append(RtfExport::sNewLine);
+            if (pStream)
+                (*pStream) << RtfExport::sNewLine;
+            else
+                aRet.append(RtfExport::sNewLine);
             nBreak = 0;
         }
     }
@@ -3212,7 +3223,7 @@ void lcl_AppendSP( OStringBuffer& rBuffer,
 
 static OString ExportPICT( const SwFlyFrmFmt* pFlyFrmFmt, const Size &rOrig, const Size &rRendered, const Size &rMapped,
     const SwCropGrf &rCr, const char *pBLIPType, const sal_uInt8 *pGraphicAry,
-    unsigned long nSize, const RtfExport& rExport )
+    unsigned long nSize, const RtfExport& rExport, SvStream *pStream = 0 )
 {
     OStringBuffer aRet;
     bool bIsWMF = std::strcmp(pBLIPType, OOO_STRING_SVTOOLS_RTF_WMETAFILE) == 0;
@@ -3274,8 +3285,15 @@ static OString ExportPICT( const SwFlyFrmFmt* pFlyFrmFmt, const Size &rOrig, con
             StripMetafileHeader(pGraphicAry, nSize);
         }
         aRet.append(RtfExport::sNewLine);
-        aRet.append(RtfAttributeOutput::WriteHex(pGraphicAry, nSize));
+        if (pStream)
+            (*pStream) << aRet.makeStringAndClear().getStr();
+        if (pStream)
+            RtfAttributeOutput::WriteHex(pGraphicAry, nSize, pStream);
+        else
+            aRet.append(RtfAttributeOutput::WriteHex(pGraphicAry, nSize));
         aRet.append('}');
+        if (pStream)
+            (*pStream) << aRet.makeStringAndClear().getStr();
     }
     return aRet.makeStringAndClear();
 }
@@ -3307,7 +3325,7 @@ void RtfAttributeOutput::FlyFrameOLEData( SwOLENode& rOLENode )
         const sal_uInt8* pNativeData = (sal_uInt8*)pStream->GetData();
         m_aRunText->append(WriteHex(nNativeDataSize));
         m_aRunText->append(RtfExport::sNewLine);
-        m_aRunText->append(RtfAttributeOutput::WriteHex(pNativeData, nNativeDataSize, 126));
+        m_aRunText->append(RtfAttributeOutput::WriteHex(pNativeData, nNativeDataSize, 0, 126));
         m_aRunText->append(RtfExport::sNewLine);
         delete pStream;
 
@@ -3319,7 +3337,7 @@ void RtfAttributeOutput::FlyFrameOLEData( SwOLENode& rOLENode )
         pStream->Seek(STREAM_SEEK_TO_END);
         sal_uInt32 nPresentationDataSize = pStream->Tell();
         const sal_uInt8* pPresentationData = (sal_uInt8*)pStream->GetData();
-        m_aRunText->append(WriteHex(pPresentationData, nPresentationDataSize, 126));
+        m_aRunText->append(WriteHex(pPresentationData, nPresentationDataSize, 0, 126));
     }
 }
 
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index c930357..4be68db 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -571,7 +571,7 @@ public:
     void FontPitchType( FontPitch ePitch ) const;
 
     /// Writes binary data as a hex dump.
-    static rtl::OString WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, sal_uInt32 nLimit = 64);
+    static rtl::OString WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, SvStream* pStream = 0, sal_uInt32 nLimit = 64);
     static rtl::OString WriteHex(sal_Int32 nNum);
     static rtl::OString WriteHex(rtl::OString sString);
 };
commit 4ed3acc18e70a6c867e827c19f8ccf7fa925b9c5
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Mar 5 09:43:25 2012 +0100

    introduce RtfStringBuffer
    
    It's a wrapper around OStringBuffer to handle export of graphics more
    efficiently.

diff --git a/sw/Library_msword.mk b/sw/Library_msword.mk
index c835643..6f082bb 100644
--- a/sw/Library_msword.mk
+++ b/sw/Library_msword.mk
@@ -90,6 +90,7 @@ $(eval $(call gb_Library_add_exception_objects,msword,\
     sw/source/filter/ww8/rtfexportfilter \
     sw/source/filter/ww8/rtfimportfilter \
     sw/source/filter/ww8/rtfsdrexport \
+    sw/source/filter/ww8/rtfstringbuffer \
     sw/source/filter/ww8/WW8FFData \
     sw/source/filter/ww8/WW8FibData \
     sw/source/filter/ww8/WW8Sttbf \
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 3443ec1..ce72a1a 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -301,26 +301,26 @@ void RtfAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTe
 
     FinishTableRowCell( pTextNodeInfoInner );
 
-    OStringBuffer aParagraph;
+    RtfStringBuffer aParagraph;
 
-    aParagraph.append(m_aRun.makeStringAndClear());
-    aParagraph.append(m_aAfterRuns.makeStringAndClear());
+    aParagraph.appendAndClear(m_aRun);
+    aParagraph->append(m_aAfterRuns.makeStringAndClear());
     if (m_bTblAfterCell)
         m_bTblAfterCell = false;
     else
     {
-        aParagraph.append(m_rExport.sNewLine);
-        aParagraph.append(OOO_STRING_SVTOOLS_RTF_PAR);
-        aParagraph.append(' ');
+        aParagraph->append(m_rExport.sNewLine);
+        aParagraph->append(OOO_STRING_SVTOOLS_RTF_PAR);
+        aParagraph->append(' ');
     }
     if (m_nColBreakNeeded)
     {
-        aParagraph.append(OOO_STRING_SVTOOLS_RTF_COLUMN);
+        aParagraph->append(OOO_STRING_SVTOOLS_RTF_COLUMN);
         m_nColBreakNeeded = false;
     }
 
     if (!m_bBufferSectionHeaders)
-        m_rExport.Strm() << aParagraph.makeStringAndClear().getStr();
+        aParagraph.makeStringAndClear(this);
     else
         m_aSectionHeaders.append(aParagraph.makeStringAndClear());
 }
@@ -383,7 +383,7 @@ void RtfAttributeOutput::StartRun( const SwRedlineData* pRedlineData )
 {
     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
 
-    m_aRun.append('{');
+    m_aRun->append('{');
 
     // if there is some redlining in the document, output it
     Redline( pRedlineData );
@@ -394,9 +394,9 @@ void RtfAttributeOutput::StartRun( const SwRedlineData* pRedlineData )
 void RtfAttributeOutput::EndRun()
 {
     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
-    m_aRun.append(m_rExport.sNewLine);
-    m_aRun.append(m_aRunText.makeStringAndClear());
-    m_aRun.append('}');
+    m_aRun->append(m_rExport.sNewLine);
+    m_aRun.appendAndClear(m_aRunText);
+    m_aRun->append('}');
 }
 
 void RtfAttributeOutput::StartRunProperties()
@@ -409,7 +409,7 @@ void RtfAttributeOutput::EndRunProperties( const SwRedlineData* /*pRedlineData*/
 {
     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     m_aStyles.append(m_aStylesEnd.makeStringAndClear());
-    m_aRun.append(m_aStyles.makeStringAndClear());
+    m_aRun->append(m_aStyles.makeStringAndClear());
 }
 
 void RtfAttributeOutput::RunText( const String& rText, rtl_TextEncoding eCharSet )
@@ -420,7 +420,7 @@ void RtfAttributeOutput::RunText( const String& rText, rtl_TextEncoding eCharSet
 
 OStringBuffer& RtfAttributeOutput::RunText()
 {
-    return m_aRunText;
+    return m_aRunText.getLastBuffer();
 }
 
 OStringBuffer& RtfAttributeOutput::Styles()
@@ -431,7 +431,7 @@ OStringBuffer& RtfAttributeOutput::Styles()
 void RtfAttributeOutput::RawText( const String& rText, bool /*bForceUnicode*/, rtl_TextEncoding eCharSet )
 {
     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
-    m_aRunText.append(m_rExport.OutString(rText, eCharSet));
+    m_aRunText->append(m_rExport.OutString(rText, eCharSet));
 }
 
 void RtfAttributeOutput::StartRuby( const SwTxtNode& /*rNode*/, xub_StrLen /*nPos*/, const SwFmtRuby& /*rRuby*/ )
@@ -481,9 +481,9 @@ bool RtfAttributeOutput::EndURL()
 
     // close the fldrslt group
     if (m_bHadFieldResult)
-        m_aRunText.append('}');
+        m_aRunText->append('}');
     // close the field group
-    m_aRunText.append('}');
+    m_aRunText->append('}');
     return true;
 }
 
@@ -501,20 +501,20 @@ void RtfAttributeOutput::Redline( const SwRedlineData* pRedline )
 
     if (pRedline->GetType() == nsRedlineType_t::REDLINE_INSERT)
     {
-        m_aRun.append(OOO_STRING_SVTOOLS_RTF_REVISED);
-        m_aRun.append(OOO_STRING_SVTOOLS_RTF_REVAUTH);
-        m_aRun.append((sal_Int32)m_rExport.GetRedline(SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor())));
-        m_aRun.append(OOO_STRING_SVTOOLS_RTF_REVDTTM);
+        m_aRun->append(OOO_STRING_SVTOOLS_RTF_REVISED);
+        m_aRun->append(OOO_STRING_SVTOOLS_RTF_REVAUTH);
+        m_aRun->append((sal_Int32)m_rExport.GetRedline(SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor())));
+        m_aRun->append(OOO_STRING_SVTOOLS_RTF_REVDTTM);
     }
     else if(pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE)
     {
-        m_aRun.append(OOO_STRING_SVTOOLS_RTF_DELETED);
-        m_aRun.append(OOO_STRING_SVTOOLS_RTF_REVAUTHDEL);
-        m_aRun.append((sal_Int32)m_rExport.GetRedline(SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor())));
-        m_aRun.append(OOO_STRING_SVTOOLS_RTF_REVDTTMDEL);
+        m_aRun->append(OOO_STRING_SVTOOLS_RTF_DELETED);
+        m_aRun->append(OOO_STRING_SVTOOLS_RTF_REVAUTHDEL);
+        m_aRun->append((sal_Int32)m_rExport.GetRedline(SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor())));
+        m_aRun->append(OOO_STRING_SVTOOLS_RTF_REVDTTMDEL);
     }
-    m_aRun.append((sal_Int32)sw::ms::DateTime2DTTM(pRedline->GetTimeStamp()));
-    m_aRun.append(' ');
+    m_aRun->append((sal_Int32)sw::ms::DateTime2DTTM(pRedline->GetTimeStamp()));
+    m_aRun->append(' ');
 }
 
 void RtfAttributeOutput::FormatDrop( const SwTxtNode& /*rNode*/, const SwFmtDrop& /*rSwFmtDrop*/, sal_uInt16 /*nStyle*/, ww8::WW8TableNodeInfo::Pointer_t /*pTextNodeInfo*/, ww8::WW8TableNodeInfoInner::Pointer_t /*pTextNodeInfoInner*/ )
@@ -1422,32 +1422,32 @@ void RtfAttributeOutput::WriteField_Impl( const SwField* pFld, ww::eField /*eTyp
     bool bHasInstructions = rFldCmd.Len() > 0;
     if (bHasInstructions)
     {
-        m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_FIELD);
-        m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FLDINST " ");
-        m_aRunText.append(m_rExport.OutString(rFldCmd, m_rExport.eCurrentEncoding));
-        m_aRunText.append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
+        m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_FIELD);
+        m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FLDINST " ");
+        m_aRunText->append(m_rExport.OutString(rFldCmd, m_rExport.eCurrentEncoding));
+        m_aRunText->append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
     }
     if (pFld)
-        m_aRunText.append(m_rExport.OutString(pFld->ExpandField(true), m_rExport.eDefaultEncoding));
+        m_aRunText->append(m_rExport.OutString(pFld->ExpandField(true), m_rExport.eDefaultEncoding));
     if (bHasInstructions)
-        m_aRunText.append("}}");
+        m_aRunText->append("}}");
 }
 
 void RtfAttributeOutput::WriteBookmarks_Impl( std::vector< rtl::OUString >& rStarts, std::vector< rtl::OUString >& rEnds )
 {
     for ( std::vector< OUString >::const_iterator it = rStarts.begin(), end = rStarts.end(); it < end; ++it )
     {
-        m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BKMKSTART " ");
-        m_aRun.append(m_rExport.OutString(*it, m_rExport.eCurrentEncoding));
-        m_aRun.append('}');
+        m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BKMKSTART " ");
+        m_aRun->append(m_rExport.OutString(*it, m_rExport.eCurrentEncoding));
+        m_aRun->append('}');
     }
     rStarts.clear();
 
     for ( std::vector< OUString >::const_iterator it = rEnds.begin(), end = rEnds.end(); it < end; ++it )
     {
-        m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BKMKEND " ");
-        m_aRun.append(m_rExport.OutString(*it, m_rExport.eCurrentEncoding));
-        m_aRun.append('}');
+        m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BKMKEND " ");
+        m_aRun->append(m_rExport.OutString(*it, m_rExport.eCurrentEncoding));
+        m_aRun->append('}');
     }
     rEnds.clear();
 }
@@ -1456,8 +1456,8 @@ void RtfAttributeOutput::WriteHeaderFooter_Impl( const SwFrmFmt& rFmt, bool bHea
 {
     OStringBuffer aSectionBreaks = m_aSectionBreaks;
     m_aSectionBreaks.setLength(0);
-    OStringBuffer aRun = m_aRun;
-    m_aRun.setLength(0);
+    RtfStringBuffer aRun = m_aRun;
+    m_aRun.clear();
 
     m_aSectionHeaders.append(bHeader ? OOO_STRING_SVTOOLS_RTF_HEADERY : OOO_STRING_SVTOOLS_RTF_FOOTERY);
     m_aSectionHeaders.append((sal_Int32)m_rExport.pAktPageDesc->GetMaster().GetULSpace().GetUpper());
@@ -1517,8 +1517,8 @@ void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Poi
 
                 m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_PARD;
                 m_rExport.bRTFFlySyntax = false;
-                m_aRun.append(aSave);
-                m_aRunText.setLength(0);
+                m_aRun->append(aSave);
+                m_aRunText.clear();
             }
 
             m_rExport.mpParentFrame = NULL;
@@ -1531,9 +1531,9 @@ void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Poi
                 m_rExport.bRTFFlySyntax = true;
                 m_rExport.OutputFormat( rFrame.GetFrmFmt(), false, false, true );
                 m_rExport.bRTFFlySyntax = false;
-                m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE);
+                m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE);
                 m_rExport.OutputFormat( rFrame.GetFrmFmt(), false, false, true );
-                m_aRunText.append('}');
+                m_aRunText->append('}');
                 m_rExport.mpParentFrame = NULL;
             }
 
@@ -1558,16 +1558,16 @@ void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Poi
                         }
                     }
 
-                    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_FIELD "{");
-                    m_aRunText.append(OOO_STRING_SVTOOLS_RTF_IGNORE);
-                    m_aRunText.append(OOO_STRING_SVTOOLS_RTF_FLDINST);
-                    m_aRunText.append(" SHAPE ");
-                    m_aRunText.append("}" "{" OOO_STRING_SVTOOLS_RTF_FLDRSLT);
+                    m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_FIELD "{");
+                    m_aRunText->append(OOO_STRING_SVTOOLS_RTF_IGNORE);
+                    m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLDINST);
+                    m_aRunText->append(" SHAPE ");
+                    m_aRunText->append("}" "{" OOO_STRING_SVTOOLS_RTF_FLDRSLT);
 
                     m_rExport.SdrExporter().AddSdrObject( *pSdrObj );
 
-                    m_aRunText.append('}');
-                    m_aRunText.append('}');
+                    m_aRunText->append('}');
+                    m_aRunText->append('}');
 
                     if ( bSwapInPage )
                         const_cast< SdrObject* >( pSdrObj )->SetPage( 0 );
@@ -1579,8 +1579,8 @@ void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Poi
                 const SwFrmFmt &rFrmFmt = rFrame.GetFrmFmt();
                 const SdrObject *pObject = rFrmFmt.FindRealSdrObject();
 
-                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_FIELD);
-                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FLDINST);
+                m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_FIELD);
+                m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FLDINST);
 
                 if (pObject && pObject->GetObjInventor() == FmFormInventor)
                 {
@@ -1595,54 +1595,54 @@ void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Poi
                         if (xInfo->supportsService(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.CheckBox"))))
                         {
 
-                            m_aRun.append(OUStringToOString(OUString(FieldString(ww::eFORMCHECKBOX)), m_rExport.eCurrentEncoding));
-                            m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
-                            m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFTYPE "1"); // 1 = checkbox
+                            m_aRun->append(OUStringToOString(OUString(FieldString(ww::eFORMCHECKBOX)), m_rExport.eCurrentEncoding));
+                            m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
+                            m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFTYPE "1"); // 1 = checkbox
                             // checkbox size in half points, this seems to be always 20, see WW8Export::DoCheckBox()
-                            m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFHPS "20");
+                            m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFHPS "20");
 
                             OUString aStr;
                             sName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"));
                             if (xPropSetInfo->hasPropertyByName(sName))
                             {
                                 xPropSet->getPropertyValue(sName) >>= aStr;
-                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFNAME " ");
-                                m_aRun.append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
-                                m_aRun.append('}');
+                                m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFNAME " ");
+                                m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
+                                m_aRun->append('}');
                             }
 
                             sName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HelpText"));
                             if (xPropSetInfo->hasPropertyByName(sName))
                             {
                                 xPropSet->getPropertyValue(sName) >>= aStr;
-                                m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
-                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
-                                m_aRun.append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
-                                m_aRun.append('}');
+                                m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
+                                m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
+                                m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
+                                m_aRun->append('}');
                             }
 
                             sName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HelpF1Text"));
                             if (xPropSetInfo->hasPropertyByName(sName))
                             {
                                 xPropSet->getPropertyValue(sName) >>= aStr;
-                                m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
-                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
-                                m_aRun.append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
-                                m_aRun.append('}');
+                                m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
+                                m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
+                                m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
+                                m_aRun->append('}');
                             }
 
                             sal_Int16 nTemp = 0;
                             xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultState"))) >>= nTemp;
-                            m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFDEFRES);
-                            m_aRun.append((sal_Int32)nTemp);
+                            m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFDEFRES);
+                            m_aRun->append((sal_Int32)nTemp);
                             xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("State"))) >>= nTemp;
-                            m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFRES);
-                            m_aRun.append((sal_Int32)nTemp);
+                            m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFRES);
+                            m_aRun->append((sal_Int32)nTemp);
 
-                            m_aRun.append("}}");
+                            m_aRun->append("}}");
 
                             // field result is empty, ffres already contains the form result
-                            m_aRun.append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
+                            m_aRun->append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
                         }
                         else if (xInfo->supportsService(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.TextField"))))
                         {
@@ -1651,8 +1651,8 @@ void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Poi
                             OUString aTmp;
                             const sal_Char* pStr;
 
-                            m_aRun.append(OUStringToOString(OUString(FieldString(ww::eFORMTEXT)), m_rExport.eCurrentEncoding));
-                            m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_DATAFIELD " ");
+                            m_aRun->append(OUStringToOString(OUString(FieldString(ww::eFORMTEXT)), m_rExport.eCurrentEncoding));
+                            m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_DATAFIELD " ");
                             for (int i = 0; i < 8; i++) aBuf.append((sal_Char)0x00);
                             xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"))) >>= aTmp;
                             aStr = OUStringToOString(aTmp, m_rExport.eCurrentEncoding);
@@ -1667,33 +1667,33 @@ void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Poi
                             aStr = aBuf.makeStringAndClear();
                             pStr = aStr.getStr();
                             for (int i = 0; i < aStr.getLength(); i++, pStr++)
-                                m_aRun.append(m_rExport.OutHex(*pStr, 2));
-                            m_aRun.append('}');
-                            m_aRun.append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
+                                m_aRun->append(m_rExport.OutHex(*pStr, 2));
+                            m_aRun->append('}');
+                            m_aRun->append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
                             xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Text"))) >>= aTmp;
-                            m_aRun.append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
-                            m_aRun.append('}');
-                            m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
+                            m_aRun->append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
+                            m_aRun->append('}');
+                            m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
                             sName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HelpText"));
                             if (xPropSetInfo->hasPropertyByName(sName))
                             {
                                 xPropSet->getPropertyValue(sName) >>= aTmp;
-                                m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
-                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
-                                m_aRun.append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
-                                m_aRun.append('}');
+                                m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
+                                m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
+                                m_aRun->append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
+                                m_aRun->append('}');
                             }
 
                             sName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HelpF1Text"));
                             if (xPropSetInfo->hasPropertyByName(sName))
                             {
                                 xPropSet->getPropertyValue(sName) >>= aTmp;
-                                m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
-                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
-                                m_aRun.append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
-                                m_aRun.append('}');
+                                m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
+                                m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
+                                m_aRun->append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
+                                m_aRun->append('}');
                             }
-                            m_aRun.append("}");
+                            m_aRun->append("}");
                         }
                         else if (xInfo->supportsService(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.ListBox"))))
                         {
@@ -1701,75 +1701,75 @@ void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Poi
                             uno::Sequence<sal_Int16> aIntSeq;
                             uno::Sequence<OUString> aStrSeq;
 
-                            m_aRun.append(OUStringToOString(OUString(FieldString(ww::eFORMDROPDOWN)), m_rExport.eCurrentEncoding));
-                            m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
-                            m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFTYPE "2"); // 2 = list
-                            m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFHASLISTBOX);
+                            m_aRun->append(OUStringToOString(OUString(FieldString(ww::eFORMDROPDOWN)), m_rExport.eCurrentEncoding));
+                            m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
+                            m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFTYPE "2"); // 2 = list
+                            m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFHASLISTBOX);
 
                             xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultSelection"))) >>= aIntSeq;
                             if( aIntSeq.getLength() )
                             {
-                                m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFDEFRES);
+                                m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFDEFRES);
                                 // a dropdown list can have only one 'selected item by default'
-                                m_aRun.append((sal_Int32)aIntSeq[0]);
+                                m_aRun->append((sal_Int32)aIntSeq[0]);
                             }
 
                             xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SelectedItems"))) >>= aIntSeq;
                             if( aIntSeq.getLength() )
                             {
-                                m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFRES);
+                                m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFRES);
                                 // a dropdown list can have only one 'currently selected item'
-                                m_aRun.append((sal_Int32)aIntSeq[0]);
+                                m_aRun->append((sal_Int32)aIntSeq[0]);
                             }
 
                             sName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"));
                             if (xPropSetInfo->hasPropertyByName(sName))
                             {
                                 xPropSet->getPropertyValue(sName) >>= aStr;
-                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFNAME " ");
-                                m_aRun.append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
-                                m_aRun.append('}');
+                                m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFNAME " ");
+                                m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
+                                m_aRun->append('}');
                             }
 
                             sName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HelpText"));
                             if (xPropSetInfo->hasPropertyByName(sName))
                             {
                                 xPropSet->getPropertyValue(sName) >>= aStr;
-                                m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
-                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
-                                m_aRun.append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
-                                m_aRun.append('}');
+                                m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
+                                m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
+                                m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
+                                m_aRun->append('}');
                             }
 
                             sName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HelpF1Text"));
                             if (xPropSetInfo->hasPropertyByName(sName))
                             {
                                 xPropSet->getPropertyValue(sName) >>= aStr;
-                                m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
-                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
-                                m_aRun.append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
-                                m_aRun.append('}');
+                                m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
+                                m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
+                                m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
+                                m_aRun->append('}');
                             }
 
 
                             xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StringItemList"))) >>= aStrSeq;
                             sal_uInt32 nListItems = aStrSeq.getLength();
                             for (sal_uInt32 i = 0; i < nListItems; i++)
-                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFL " ")
+                                m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFL " ")
                                     .append(OUStringToOString(aStrSeq[i], m_rExport.eCurrentEncoding)).append('}');
 
-                            m_aRun.append("}}");
+                            m_aRun->append("}}");
 
                             // field result is empty, ffres already contains the form result
-                            m_aRun.append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
+                            m_aRun->append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
                         }
                         else
                             SAL_INFO("sw.rtf", OSL_THIS_FUNC << " unhandled form control: '" << xInfo->getImplementationName()<< "'");
-                        m_aRun.append('}');
+                        m_aRun->append('}');
                     }
                 }
 
-                m_aRun.append('}');
+                m_aRun->append('}');
             }
             break;
         case sw::Frame::eOle:
@@ -2301,21 +2301,21 @@ void RtfAttributeOutput::TextCharFormat( const SwFmtCharFmt& rCharFmt )
 void RtfAttributeOutput::WriteTextFootnoteNumStr(const SwFmtFtn& rFootnote)
 {
     if (!rFootnote.GetNumStr().Len())
-        m_aRun.append(OOO_STRING_SVTOOLS_RTF_CHFTN);
+        m_aRun->append(OOO_STRING_SVTOOLS_RTF_CHFTN);
     else
-        m_aRun.append(m_rExport.OutString(rFootnote.GetNumStr(), m_rExport.eCurrentEncoding));
+        m_aRun->append(m_rExport.OutString(rFootnote.GetNumStr(), m_rExport.eCurrentEncoding));
 }
 
 void RtfAttributeOutput::TextFootnote_Impl( const SwFmtFtn& rFootnote )
 {
     SAL_INFO("sw.rtf", OSL_THIS_FUNC << " start");
 
-    m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_SUPER " ");
+    m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_SUPER " ");
     WriteTextFootnoteNumStr(rFootnote);
-    m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FOOTNOTE);
+    m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FOOTNOTE);
     if( rFootnote.IsEndNote() )
-        m_aRun.append(OOO_STRING_SVTOOLS_RTF_FTNALT);
-    m_aRun.append(' ');
+        m_aRun->append(OOO_STRING_SVTOOLS_RTF_FTNALT);
+    m_aRun->append(' ');
     WriteTextFootnoteNumStr(rFootnote);
 
     /*
@@ -2324,18 +2324,18 @@ void RtfAttributeOutput::TextFootnote_Impl( const SwFmtFtn& rFootnote )
      * 2) Buffer the output of the whole paragraph, as we do so for section headers already.
      */
     const SwNodeIndex* pIndex = rFootnote.GetTxtFtn()->GetStartNode();
-    OStringBuffer aRun = m_aRun;
-    m_aRun.setLength(0);
+    RtfStringBuffer aRun = m_aRun;
+    m_aRun.clear();
     m_bBufferSectionHeaders = true;
     m_rExport.WriteSpecialText( pIndex->GetIndex() + 1,
             pIndex->GetNode().EndOfSectionIndex(),
             !rFootnote.IsEndNote() ? TXT_FTN : TXT_EDN);
     m_bBufferSectionHeaders = false;
     m_aRun = aRun;
-    m_aRun.append(m_aSectionHeaders.makeStringAndClear());
+    m_aRun->append(m_aSectionHeaders.makeStringAndClear());
 
-    m_aRun.append("}");
-    m_aRun.append("}");
+    m_aRun->append("}");
+    m_aRun->append("}");
 
     SAL_INFO("sw.rtf", OSL_THIS_FUNC << " end");
 }
@@ -2596,8 +2596,8 @@ void RtfAttributeOutput::FormatFrameSize( const SwFmtFrmSize& rSize )
     {
         if( rSize.GetWidth() )
         {
-            m_aRunText.append(OOO_STRING_SVTOOLS_RTF_ABSW);
-            m_aRunText.append((sal_Int32)rSize.GetWidth());
+            m_aRunText->append(OOO_STRING_SVTOOLS_RTF_ABSW);
+            m_aRunText->append((sal_Int32)rSize.GetWidth());
         }
 
         if( rSize.GetHeight() )
@@ -2605,8 +2605,8 @@ void RtfAttributeOutput::FormatFrameSize( const SwFmtFrmSize& rSize )
             long nH = rSize.GetHeight();
             if( ATT_FIX_SIZE == rSize.GetHeightSizeType() )
                 nH = -nH;
-            m_aRunText.append(OOO_STRING_SVTOOLS_RTF_ABSH);
-            m_aRunText.append((sal_Int32)nH);
+            m_aRunText->append(OOO_STRING_SVTOOLS_RTF_ABSH);
+            m_aRunText->append((sal_Int32)nH);
         }
     }
     else if (m_rExport.bOutPageDescs)
@@ -2733,8 +2733,8 @@ void RtfAttributeOutput::FormatSurround( const SwFmtSurround& rSurround )
         if( bGold )
             eSurround = SURROUND_PARALLEL;
         RTFSurround aMC( bGold, static_cast< sal_uInt8 >(eSurround) );
-        m_aRunText.append(OOO_STRING_SVTOOLS_RTF_FLYMAINCNT);
-        m_aRunText.append( (sal_Int32) aMC.GetValue() );
+        m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYMAINCNT);
+        m_aRunText->append( (sal_Int32) aMC.GetValue() );
     }
 }
 
@@ -2744,25 +2744,25 @@ void RtfAttributeOutput::FormatVertOrientation( const SwFmtVertOrient& rFlyVert
 
     if ( m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax )
     {
-        m_aRunText.append(OOO_STRING_SVTOOLS_RTF_PVPARA);
+        m_aRunText->append(OOO_STRING_SVTOOLS_RTF_PVPARA);
 
         switch (rFlyVert.GetVertOrient())
         {
             case text::VertOrientation::TOP:
             case text::VertOrientation::LINE_TOP:
-                m_aRunText.append(OOO_STRING_SVTOOLS_RTF_POSYT);
+                m_aRunText->append(OOO_STRING_SVTOOLS_RTF_POSYT);
                 break;
             case text::VertOrientation::BOTTOM:
             case text::VertOrientation::LINE_BOTTOM:
-                m_aRunText.append(OOO_STRING_SVTOOLS_RTF_POSYB);
+                m_aRunText->append(OOO_STRING_SVTOOLS_RTF_POSYB);
                 break;
             case text::VertOrientation::CENTER:
             case text::VertOrientation::LINE_CENTER:
-                m_aRunText.append(OOO_STRING_SVTOOLS_RTF_POSYC);
+                m_aRunText->append(OOO_STRING_SVTOOLS_RTF_POSYC);
                 break;
             case text::VertOrientation::NONE:
-                m_aRunText.append(OOO_STRING_SVTOOLS_RTF_POSY);
-                m_aRunText.append((sal_Int32)rFlyVert.GetPos());
+                m_aRunText->append(OOO_STRING_SVTOOLS_RTF_POSY);
+                m_aRunText->append((sal_Int32)rFlyVert.GetPos());
                 break;
             default:
                 break;
@@ -2771,8 +2771,8 @@ void RtfAttributeOutput::FormatVertOrientation( const SwFmtVertOrient& rFlyVert
     else if ( !m_rExport.bRTFFlySyntax )
     {
         RTFVertOrient aVO( static_cast< sal_uInt16 >(rFlyVert.GetVertOrient()), static_cast< sal_uInt16 >(rFlyVert.GetRelationOrient()) );
-        m_aRunText.append(OOO_STRING_SVTOOLS_RTF_FLYVERT);
-        m_aRunText.append((sal_Int32)aVO.GetValue());
+        m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYVERT);
+        m_aRunText->append((sal_Int32)aVO.GetValue());
     }
 }
 
@@ -2782,7 +2782,7 @@ void RtfAttributeOutput::FormatHorizOrientation( const SwFmtHoriOrient& rFlyHori
 
     if ( m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax )
     {
-        m_aRunText.append(OOO_STRING_SVTOOLS_RTF_PHCOL);
+        m_aRunText->append(OOO_STRING_SVTOOLS_RTF_PHCOL);
 
         const char* pS = 0;
         switch(rFlyHori.GetHoriOrient())
@@ -2797,20 +2797,20 @@ void RtfAttributeOutput::FormatHorizOrientation( const SwFmtHoriOrient& rFlyHori
                 pS = OOO_STRING_SVTOOLS_RTF_POSXC;
                 break;
             case text::HoriOrientation::NONE:
-                m_aRunText.append(OOO_STRING_SVTOOLS_RTF_POSX);
-                m_aRunText.append((sal_Int32)rFlyHori.GetPos());
+                m_aRunText->append(OOO_STRING_SVTOOLS_RTF_POSX);
+                m_aRunText->append((sal_Int32)rFlyHori.GetPos());
                 break;
             default:
                 break;
         }
         if (pS)
-            m_aRunText.append(pS);
+            m_aRunText->append(pS);
     } else if ( !m_rExport.bRTFFlySyntax )
     {
         RTFHoriOrient aHO( static_cast< sal_uInt16 >(rFlyHori.GetHoriOrient()),
                 static_cast< sal_uInt16 >(rFlyHori.GetRelationOrient()) );
-        m_aRunText.append(OOO_STRING_SVTOOLS_RTF_FLYHORZ);
-        m_aRunText.append((sal_Int32)aHO.GetValue());
+        m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYHORZ);
+        m_aRunText->append((sal_Int32)aHO.GetValue());
     }
 }
 
@@ -2821,17 +2821,17 @@ void RtfAttributeOutput::FormatAnchor( const SwFmtAnchor& rAnchor )
     if ( !m_rExport.bRTFFlySyntax )
     {
         sal_uInt16 nId = static_cast< sal_uInt16 >(rAnchor.GetAnchorId());
-        m_aRunText.append(OOO_STRING_SVTOOLS_RTF_FLYANCHOR);
-        m_aRunText.append((sal_Int32)nId);
+        m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYANCHOR);
+        m_aRunText->append((sal_Int32)nId);
         switch( nId )
         {
             case FLY_AT_PAGE:
-                m_aRunText.append(OOO_STRING_SVTOOLS_RTF_FLYPAGE);
-                m_aRunText.append((sal_Int32)rAnchor.GetPageNum());
+                m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYPAGE);
+                m_aRunText->append((sal_Int32)rAnchor.GetPageNum());
                 break;
             case FLY_AT_PARA:
             case FLY_AS_CHAR:
-                m_aRunText.append(OOO_STRING_SVTOOLS_RTF_FLYCNTNT);
+                m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYCNTNT);
                 break;
         }
     }
@@ -2985,20 +2985,20 @@ void RtfAttributeOutput::PostitField( const SwField* pFld )
 
     const SwPostItField& rPFld = *(SwPostItField*)pFld;
 
-    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNID " ");
-    m_aRunText.append(OUStringToOString(OUString(rPFld.GetPar1()), m_rExport.eCurrentEncoding));
-    m_aRunText.append("}");
-    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNAUTHOR " ");
-    m_aRunText.append(OUStringToOString(OUString(rPFld.GetPar1()), m_rExport.eCurrentEncoding));
-    m_aRunText.append("}");
-    m_aRunText.append(OOO_STRING_SVTOOLS_RTF_CHATN);
+    m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNID " ");
+    m_aRunText->append(OUStringToOString(OUString(rPFld.GetPar1()), m_rExport.eCurrentEncoding));
+    m_aRunText->append("}");
+    m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNAUTHOR " ");
+    m_aRunText->append(OUStringToOString(OUString(rPFld.GetPar1()), m_rExport.eCurrentEncoding));
+    m_aRunText->append("}");
+    m_aRunText->append(OOO_STRING_SVTOOLS_RTF_CHATN);
 
-    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ANNOTATION);
-    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNDATE " ");
-    m_aRunText.append((sal_Int32)sw::ms::DateTime2DTTM(rPFld.GetDateTime()));
-    m_aRunText.append('}');
-    m_aRunText.append(OUStringToOString(OUString(rPFld.GetTxt()), m_rExport.eCurrentEncoding));
-    m_aRunText.append('}');
+    m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ANNOTATION);
+    m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNDATE " ");
+    m_aRunText->append((sal_Int32)sw::ms::DateTime2DTTM(rPFld.GetDateTime()));
+    m_aRunText->append('}');
+    m_aRunText->append(OUStringToOString(OUString(rPFld.GetTxt()), m_rExport.eCurrentEncoding));
+    m_aRunText->append('}');
 }
 
 bool RtfAttributeOutput::DropdownField( const SwField* /*pFld*/ )
@@ -3188,10 +3188,10 @@ OString RtfAttributeOutput::WriteHex(sal_Int32 nNum)
 
 OString RtfAttributeOutput::WriteHex(OString sString)
 {
-    OStringBuffer aRet;
+    RtfStringBuffer aRet;
 
-    aRet.append(WriteHex(sString.getLength()+1));
-    aRet.append(RtfAttributeOutput::WriteHex((sal_uInt8*)sString.getStr(), sString.getLength()+1));
+    aRet->append(WriteHex(sString.getLength()+1));
+    aRet->append(RtfAttributeOutput::WriteHex((sal_uInt8*)sString.getStr(), sString.getLength()+1));
 
     return aRet.makeStringAndClear();
 }
@@ -3292,11 +3292,11 @@ void RtfAttributeOutput::FlyFrameOLEData( SwOLENode& rOLENode )
     if (SotExchange::IsMath(aObjName))
     {
         // ObjectHeader
-        m_aRunText.append(WriteHex(0x00000501)); // OLEVersion
-        m_aRunText.append(WriteHex(0x00000002)); // FormatID
-        m_aRunText.append(WriteHex(OString("Equation.3"))); // ClassName
-        m_aRunText.append(WriteHex(0x00000000)); // TopicName
-        m_aRunText.append(WriteHex(0x00000000)); // ItemName
+        m_aRunText->append(WriteHex(0x00000501)); // OLEVersion
+        m_aRunText->append(WriteHex(0x00000002)); // FormatID
+        m_aRunText->append(WriteHex(OString("Equation.3"))); // ClassName
+        m_aRunText->append(WriteHex(0x00000000)); // TopicName
+        m_aRunText->append(WriteHex(0x00000000)); // ItemName
 
         // NativeData
         SvMemoryStream *pStream = new SvMemoryStream;
@@ -3305,10 +3305,10 @@ void RtfAttributeOutput::FlyFrameOLEData( SwOLENode& rOLENode )
         pStream->Seek(STREAM_SEEK_TO_END);
         sal_uInt32 nNativeDataSize = pStream->Tell();
         const sal_uInt8* pNativeData = (sal_uInt8*)pStream->GetData();
-        m_aRunText.append(WriteHex(nNativeDataSize));
-        m_aRunText.append(RtfExport::sNewLine);
-        m_aRunText.append(RtfAttributeOutput::WriteHex(pNativeData, nNativeDataSize, 126));
-        m_aRunText.append(RtfExport::sNewLine);
+        m_aRunText->append(WriteHex(nNativeDataSize));
+        m_aRunText->append(RtfExport::sNewLine);
+        m_aRunText->append(RtfAttributeOutput::WriteHex(pNativeData, nNativeDataSize, 126));
+        m_aRunText->append(RtfExport::sNewLine);
         delete pStream;
 
         // MetaFilePresentationObject
@@ -3319,7 +3319,7 @@ void RtfAttributeOutput::FlyFrameOLEData( SwOLENode& rOLENode )
         pStream->Seek(STREAM_SEEK_TO_END);
         sal_uInt32 nPresentationDataSize = pStream->Tell();
         const sal_uInt8* pPresentationData = (sal_uInt8*)pStream->GetData();
-        m_aRunText.append(WriteHex(pPresentationData, nPresentationDataSize, 126));
+        m_aRunText->append(WriteHex(pPresentationData, nPresentationDataSize, 126));
     }
 }
 
@@ -3346,21 +3346,21 @@ void RtfAttributeOutput::FlyFrameOLE( const SwFlyFrmFmt* pFlyFrmFmt, SwOLENode&
     nSize = aStream.Tell();
     pGraphicAry = (sal_uInt8*)aStream.GetData();
 
-    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_OBJECT OOO_STRING_SVTOOLS_RTF_OBJEMB);
+    m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_OBJECT OOO_STRING_SVTOOLS_RTF_OBJEMB);
 
     // export the object data in the appropriate format; RTF requires the usage of the OLE 1.0 format
-    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_OBJDATA " ");
+    m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_OBJDATA " ");
     FlyFrameOLEData(rOLENode);
-    m_aRunText.append("}{" OOO_STRING_SVTOOLS_RTF_RESULT);
+    m_aRunText->append("}{" OOO_STRING_SVTOOLS_RTF_RESULT);
 
     SwTwips nHeight = aSize.Height();
     nHeight/=20; //nHeight was in twips, want it in half points, but then half of total height.
     long nFontHeight = ((const SvxFontHeightItem&)m_rExport.GetItem(RES_CHRATR_FONTSIZE)).GetHeight();
     nHeight-=nFontHeight/20;
-    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_DN).append(nHeight);
-    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
-    m_aRunText.append(ExportPICT( pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport ));
-    m_aRunText.append("}}}}");
+    m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_DN).append(nHeight);
+    m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
+    m_aRunText->append(ExportPICT( pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport ));
+    m_aRunText->append("}}}}");
 }
 
 void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode)
@@ -3437,10 +3437,10 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const S
        */
     bool bIsWMF = std::strcmp(pBLIPType, OOO_STRING_SVTOOLS_RTF_WMETAFILE) == 0;
     if (!bIsWMF)
-        m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
+        m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
 
     if (pBLIPType)
-        m_aRunText.append(ExportPICT( pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport));
+        m_aRunText->append(ExportPICT( pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport ));
     else
     {
         aStream.Seek(0);
@@ -3450,12 +3450,12 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const S
         nSize = aStream.Tell();
         pGraphicAry = (sal_uInt8*)aStream.GetData();
 
-        m_aRunText.append(ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport ));
+        m_aRunText->append(ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport ));
     }
 
     if (!bIsWMF)
     {
-        m_aRunText.append("}" "{" OOO_STRING_SVTOOLS_RTF_NONSHPPICT);
+        m_aRunText->append("}" "{" OOO_STRING_SVTOOLS_RTF_NONSHPPICT);
 
         aStream.Seek(0);
         GraphicConverter::Export(aStream, aGraphic, CVT_WMF);
@@ -3464,12 +3464,12 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const S
         nSize = aStream.Tell();
         pGraphicAry = (sal_uInt8*)aStream.GetData();
 
-        m_aRunText.append(ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport ));
+        m_aRunText->append(ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport ));
 
-        m_aRunText.append('}');
+        m_aRunText->append('}');
     }
 
-    m_aRunText.append(m_rExport.sNewLine);
+    m_aRunText->append(m_rExport.sNewLine);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index c08cfb9..c930357 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -32,6 +32,7 @@
 
 #include "attributeoutputbase.hxx"
 #include "rtfexport.hxx"
+#include "rtfstringbuffer.hxx"
 
 #include <rtl/strbuf.hxx>
 
@@ -43,6 +44,7 @@ class SwFlyFrmFmt;
 /// The class that has handlers for various resource types when exporting as RTF
 class RtfAttributeOutput : public AttributeOutputBase
 {
+    friend class RtfStringBufferValue;
 public:
     /// Export the state of RTL/CJK.
     virtual void RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript );
@@ -446,8 +448,8 @@ private:
      * This is needed because the call order is: run text, run properties, paragraph properties.
      * What we need is the opposite.
      */
-    rtl::OStringBuffer m_aRun;
-    rtl::OStringBuffer m_aRunText;
+    RtfStringBuffer m_aRun;
+    RtfStringBuffer m_aRunText;
     /*
      * This is written after runs.
      */
diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx
index 8d9644c..3ea0613 100644
--- a/sw/source/filter/ww8/rtfsdrexport.cxx
+++ b/sw/source/filter/ww8/rtfsdrexport.cxx
@@ -447,12 +447,12 @@ void RtfSdrExport::impl_writeGraphic()
     Size aMapped(aGraphic.GetPrefSize());
 
     // Add it to the properties.
-    OStringBuffer aBuf;
-    aBuf.append('{').append(OOO_STRING_SVTOOLS_RTF_PICT).append(OOO_STRING_SVTOOLS_RTF_PNGBLIP);
-    aBuf.append(OOO_STRING_SVTOOLS_RTF_PICW).append(sal_Int32(aMapped.Width()));
-    aBuf.append(OOO_STRING_SVTOOLS_RTF_PICH).append(sal_Int32(aMapped.Height())).append(RtfExport::sNewLine);
-    aBuf.append(RtfAttributeOutput::WriteHex(pGraphicAry, nSize));
-    aBuf.append('}');
+    RtfStringBuffer aBuf;
+    aBuf->append('{').append(OOO_STRING_SVTOOLS_RTF_PICT).append(OOO_STRING_SVTOOLS_RTF_PNGBLIP);
+    aBuf->append(OOO_STRING_SVTOOLS_RTF_PICW).append(sal_Int32(aMapped.Width()));
+    aBuf->append(OOO_STRING_SVTOOLS_RTF_PICH).append(sal_Int32(aMapped.Height())).append(RtfExport::sNewLine);
+    aBuf->append(RtfAttributeOutput::WriteHex(pGraphicAry, nSize));
+    aBuf->append('}');
     m_aShapeProps.insert(std::pair<OString,OString>(OString("pib"), aBuf.makeStringAndClear()));
 }
 
diff --git a/sw/source/filter/ww8/rtfstringbuffer.cxx b/sw/source/filter/ww8/rtfstringbuffer.cxx
new file mode 100644
index 0000000..554adb1
--- /dev/null
+++ b/sw/source/filter/ww8/rtfstringbuffer.cxx
@@ -0,0 +1,121 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at suse.cz> (SUSE, Inc.)
+ * Portions created by the Initial Developer are Copyright (C) 2012 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "rtfattributeoutput.hxx"
+#include "rtfstringbuffer.hxx"
+
+RtfStringBufferValue::RtfStringBufferValue()
+    : m_aBuffer(),
+    m_pFlyFrmFmt(0),
+    m_pGrfNode(0)
+{
+}
+
+RtfStringBufferValue::RtfStringBufferValue(const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode)
+    : m_aBuffer(),
+    m_pFlyFrmFmt(pFlyFrmFmt),
+    m_pGrfNode(pGrfNode)
+{
+}
+
+void RtfStringBufferValue::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
+{
+    if (!isGraphic())
+        pAttributeOutput->m_rExport.Strm() << m_aBuffer.makeStringAndClear().getStr();
+    else
+        pAttributeOutput->FlyFrameGraphic(m_pFlyFrmFmt, m_pGrfNode);
+}
+
+rtl::OString RtfStringBufferValue::makeStringAndClear()
+{
+    return m_aBuffer.makeStringAndClear();
+}
+
+bool RtfStringBufferValue::isGraphic() const
+{
+    return m_pFlyFrmFmt != 0 && m_pGrfNode != 0;
+}
+
+RtfStringBuffer::RtfStringBuffer()
+    : m_aValues()
+{
+}
+
+sal_Int32 RtfStringBuffer::getLength() const
+{
+    sal_Int32 nRet = 0;
+    for (RtfStringBuffer::Values_t::const_iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
+        if (!i->isGraphic())
+            nRet += i->m_aBuffer.getLength();
+    return nRet;
+}
+
+void RtfStringBuffer::makeStringAndClear(RtfAttributeOutput* pAttributeOutput)
+{
+    for (RtfStringBuffer::Values_t::iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
+        i->makeStringAndClear(pAttributeOutput);
+}
+
+rtl::OString RtfStringBuffer::makeStringAndClear()
+{
+    rtl::OStringBuffer aBuf;
+    for (RtfStringBuffer::Values_t::iterator i = m_aValues.begin(); i != m_aValues.end(); ++i)
+        if (!i->isGraphic())
+            aBuf.append(i->makeStringAndClear());
+    return aBuf.makeStringAndClear();
+}
+
+rtl::OStringBuffer& RtfStringBuffer::getLastBuffer()
+{
+    if (!m_aValues.size() || m_aValues.back().isGraphic())
+        m_aValues.push_back(RtfStringBufferValue());
+    return m_aValues.back().m_aBuffer;
+}
+
+rtl::OStringBuffer* RtfStringBuffer::operator->()
+{
+    return &getLastBuffer();
+}
+
+void RtfStringBuffer::clear()
+{
+    m_aValues.clear();
+}
+
+void RtfStringBuffer::append(const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode)
+{
+    m_aValues.push_back(RtfStringBufferValue(pFlyFrmFmt, pGrfNode));
+}
+
+void RtfStringBuffer::appendAndClear(RtfStringBuffer& rBuf)
+{
+    for (RtfStringBuffer::Values_t::iterator i = rBuf.m_aValues.begin(); i != rBuf.m_aValues.end(); ++i)
+        m_aValues.push_back(*i);
+    rBuf.clear();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/rtfstringbuffer.hxx b/sw/source/filter/ww8/rtfstringbuffer.hxx
new file mode 100644
index 0000000..a6a8a8a
--- /dev/null
+++ b/sw/source/filter/ww8/rtfstringbuffer.hxx
@@ -0,0 +1,84 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at suse.cz> (SUSE, Inc.)
+ * Portions created by the Initial Developer are Copyright (C) 2012 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef _RTFSTRINGBUFFER_HXX_
+#define _RTFSTRINGBUFFER_HXX_
+
+#include <rtl/strbuf.hxx>
+#include <vector>
+
+class SwGrfNode;
+class SwFlyFrmFmt;
+class RtfAttributeOutput;
+
+/// Contains a buffered string or graphic during RTF export.
+class RtfStringBufferValue
+{
+public:
+    /// Constructor for a string buffering.
+    RtfStringBufferValue();
+    /// Constructor for graphic buffering.
+    RtfStringBufferValue(const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode);
+    /// This version handles graphics.
+    void makeStringAndClear(RtfAttributeOutput* pAttributeOutput);
+    /// This one doesn't.
+    rtl::OString makeStringAndClear();
+    bool isGraphic() const;
+
+    rtl::OStringBuffer m_aBuffer;
+    const SwFlyFrmFmt* m_pFlyFrmFmt;
+    const SwGrfNode* m_pGrfNode;
+};
+
+/// Wrapper around OStringBuffers, so less hexdump of graphics have to be kept in memory during RTF export.
+class RtfStringBuffer
+{
+public:
+    RtfStringBuffer();
+    /// Length of all the contained buffers.
+    sal_Int32 getLength() const;
+    /// Writes the contents of the buffer directly to the supplied stream.
+    void makeStringAndClear(RtfAttributeOutput* pAttributeOutput);
+    /// Returns the bufferent strings as a string (ignores graphic elements!)
+    rtl::OString makeStringAndClear();
+    /// Access to the last buffer.
+    rtl::OStringBuffer& getLastBuffer();
+    rtl::OStringBuffer* operator->();
+    /// Similar to ->setLength(0), but for all buffers.
+    void clear();
+    /// Same as ->append(), but for graphics and without expanding contents to save memory.
+    void append(const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode);
+    /// Append all contained buffers and clear the argument.
+    void appendAndClear(RtfStringBuffer& rBuf);
+private:
+    typedef std::vector<RtfStringBufferValue> Values_t;
+    Values_t m_aValues;
+};
+
+#endif // _RTFSTRINGBUFFER_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 85887d554141c33d4a9803ab2fd7765dadf7e64d
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Mar 5 09:42:12 2012 +0100

    this can be just a pointer as well

diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 0dd4f10..3443ec1 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -1538,7 +1538,7 @@ void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Poi
             }
 
             if ( pGrfNode )
-                FlyFrameGraphic( dynamic_cast<const SwFlyFrmFmt*>( &rFrame.GetFrmFmt() ), *pGrfNode );
+                FlyFrameGraphic( dynamic_cast<const SwFlyFrmFmt*>( &rFrame.GetFrmFmt() ), pGrfNode );
             break;
         case sw::Frame::eDrawing:
             {
@@ -3363,7 +3363,7 @@ void RtfAttributeOutput::FlyFrameOLE( const SwFlyFrmFmt* pFlyFrmFmt, SwOLENode&
     m_aRunText.append("}}}}");
 }
 
-void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode& rGrfNode)
+void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode)
 {
     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
 
@@ -3371,7 +3371,7 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const S
     const sal_uInt8* pGraphicAry = 0;
     sal_uInt32 nSize = 0;
 
-    Graphic aGraphic(rGrfNode.GetGrf());
+    Graphic aGraphic(pGrfNode->GetGrf());
 
     // If there is no graphic there is not much point in parsing it
     if(aGraphic.GetType()==GRAPHIC_NONE)
@@ -3417,10 +3417,10 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const S
 
     Size aMapped(eGraphicType == GRAPHIC_BITMAP ? aGraphic.GetSizePixel() : aGraphic.GetPrefSize());
 
-    const SwCropGrf &rCr = (const SwCropGrf &)rGrfNode.GetAttr(RES_GRFATR_CROPGRF);
+    const SwCropGrf &rCr = (const SwCropGrf &)pGrfNode->GetAttr(RES_GRFATR_CROPGRF);
 
     //Get original size in twips
-    Size aSize(sw::util::GetSwappedInSize(rGrfNode));
+    Size aSize(sw::util::GetSwappedInSize(*pGrfNode));
     Size aRendered(aSize);
     if (pFlyFrmFmt)
     {
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index eea4b8c..c08cfb9 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -412,7 +412,7 @@ protected:
 private:
 
     /// Output graphic fly frames.
-    void FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode& rGrfNode );
+    void FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode );
     void FlyFrameOLE( const SwFlyFrmFmt* pFlyFrmFmt, SwOLENode& rOLENode, const Size& rSize );
     void FlyFrameOLEData( SwOLENode& rOLENode );
 


More information about the Libreoffice-commits mailing list