[Libreoffice] [PATCH] RTF: fix non-text frames
Miklos Vajna
vmiklos at frugalware.org
Mon Oct 18 04:59:24 PDT 2010
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? :)
-------------- next part --------------
From 1bcf42ef0f2310a4aee05053a21ad4da6decf3ec Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20101018/8e44c4bf/attachment.pgp>
More information about the LibreOffice
mailing list