[Libreoffice] Fix RTF export crash with nested tables

Miklos Vajna vmiklos at frugalware.org
Tue Oct 12 18:21:29 PDT 2010


Hi Cedric,

I recently updated
http://cgit.freedesktop.org/~vmiklos/ooo-gsoc/tree/writer/table.odt?h=ooo-test-files
and the patch is necessary to avoid a crash in the exporter.

OK to push the attached patch?

Thanks.
-------------- next part --------------
From 35d860e8d244f03e91751cedd13b21f8613cb5f1 Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos at frugalware.org>
Date: Wed, 13 Oct 2010 03:14:00 +0200
Subject: [PATCH] RTF: fix for nested tables

The case when the original and the nested table has different cell / row number
is now handled. This is done by invalidating the table writer before starting a
new table and after finishing one.

This is needed to prevent a crash when exporting such tables and also to
produce correct output, which conforms to the specification.
---
 sw/source/filter/ww8/rtfattributeoutput.cxx |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 07ea880..a2931fe 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -299,6 +299,8 @@ void RtfAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextN
                 {
                     ww8::WW8TableNodeInfoInner::Pointer_t pInner( pTextNodeInfo->getInnerForDepth( nDepth ) );
 
+                    delete m_pTableWrt, m_pTableWrt = NULL;
+
                     StartTable( pInner );
                     StartTableRow( pInner );
                     StartTableCell( pInner );
@@ -965,8 +967,10 @@ void RtfAttributeOutput::EndTable()
 {
     OSL_TRACE("%s", OSL_THIS_FUNC);
 
-    if ( m_nTableDepth > 0 )
+    if ( m_nTableDepth > 0 ) {
         m_nTableDepth--;
+        delete m_pTableWrt, m_pTableWrt = NULL;
+    }
 
     // We closed the table; if it is a nested table, the cell that contains it
     // still continues
-- 
1.7.2.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/20101013/8d6e1a91/attachment.pgp>


More information about the LibreOffice mailing list