Date: prev next · Thread: first prev next last
2010 Archives by date, by thread · List index


Hi Cedric,

I'm attaching a patch that fixes a crash on non-text frames when
exporting as RTF.

A reproducer is here:

http://cgit.freedesktop.org/~vmiklos/ooo-gsoc/tree/writer/21976.doc?h=ooo-test-files

OK to push? :)
From 1bcf42ef0f2310a4aee05053a21ad4da6decf3ec Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@frugalware.org>
Date: Mon, 18 Oct 2010 13:54:27 +0200
Subject: [PATCH] RTF: fix non-text frames

Previously the exporter just crashed when the document contained a non-text
frame (e.g. table). Fix this by properly calling MSWordExportBase::WriteText()
instead of our custom method that handled text frames only.
---
 sw/source/filter/ww8/rtfattributeoutput.cxx |   11 ++++++++++-
 sw/source/filter/ww8/rtfexport.cxx          |    5 -----
 sw/source/filter/ww8/rtfexport.hxx          |    1 -
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx 
b/sw/source/filter/ww8/rtfattributeoutput.cxx
index e29526e..98e2830 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -1490,7 +1490,16 @@ void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const 
Poi
                  */
                 OString aSave = m_aRun.makeStringAndClear();
                 m_rExport.bRTFFlySyntax = true;
-                m_rExport.OutContent(*rFrame.GetContent());
+
+                const SwFrmFmt& rFrmFmt = rFrame.GetFrmFmt( );
+                const SwNodeIndex* pNodeIndex = rFrmFmt.GetCntnt().GetCntntIdx();
+                ULONG nStt = pNodeIndex ? pNodeIndex->GetIndex()+1                  : 0;
+                ULONG nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : 0;
+                m_rExport.SaveData( nStt, nEnd );
+                m_rExport.mpParentFrame = &rFrame;
+                m_rExport.WriteText( );
+                m_rExport.RestoreData();
+
                 m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_PARD;
                 m_rExport.bRTFFlySyntax = false;
                 m_aRun.append(aSave);
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index 282dc2e..b1aed21 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -1116,11 +1116,6 @@ USHORT RtfExport::GetRedline( const String& rAuthor )
     }
 }
 
-void RtfExport::OutContent( const SwNode& rNode )
-{
-        OutputContentNode(*rNode.GetCntntNode());
-}
-
 void RtfExport::OutPageDescription( const SwPageDesc& rPgDsc, BOOL bWriteReset, BOOL 
bCheckForFirstPage )
 {
     OSL_TRACE("%s start", OSL_THIS_FUNC);
diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx
index b96e6f7..e87d008 100644
--- a/sw/source/filter/ww8/rtfexport.hxx
+++ b/sw/source/filter/ww8/rtfexport.hxx
@@ -176,7 +176,6 @@ public:
     rtl::OString OutString(const String &rStr, rtl_TextEncoding eDestEnc);
     rtl::OString OutHex(ULONG nHex, BYTE nLen);
     void OutPageDescription( const SwPageDesc& rPgDsc, BOOL bWriteReset, BOOL bCheckForFirstPage );
-    void OutContent( const SwNode& rNode );
 
     USHORT GetColor( const Color& rColor ) const;
     void InsColor( const Color& rCol );
-- 
1.7.3.1

Attachment: pgpU4I23l0x8z.pgp
Description: PGP signature


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.