From 5e2708a5a8cad3c2f4578742264610abab677395 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 20 Apr 2015 16:38:32 +0200 Subject: tdf#80708 RTF export: fix unexpected table row break Regression from commit 1f77a5e8d5bf8a7f1b7bd7206996d2b2efc59462 (n#203704 fix RTF export table output for subtables, 2012-02-08), the problem is that RtfAttributeOutput::StartTableRow() has two callers depending on if it's the first or a later row, but the m_bTableRowEnded flag storing if that method is called is only set in one case. Fix the problem by moving the update of the flag to the method itself. Change-Id: Ieae1fb53f9528fc74d037d2fd783b3979b17cab8 --- sw/qa/extras/rtfexport/data/tdf80708.rtf | 15 +++++++++++++++ sw/qa/extras/rtfexport/rtfexport.cxx | 11 +++++++++++ sw/source/filter/ww8/rtfattributeoutput.cxx | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 sw/qa/extras/rtfexport/data/tdf80708.rtf diff --git a/sw/qa/extras/rtfexport/data/tdf80708.rtf b/sw/qa/extras/rtfexport/data/tdf80708.rtf new file mode 100644 index 000000000000..30b6174ede03 --- /dev/null +++ b/sw/qa/extras/rtfexport/data/tdf80708.rtf @@ -0,0 +1,15 @@ +{\rtf1 +\pard\plain +{first table} +\par \trowd\trql\trleft-108\ltrrow\trrh-374\trkeep\trpaddft3\trpaddt0\trpaddfl3\trpaddl0\trpaddfb3\trpaddb0\trpaddfr3\trpaddr0\clbrdrl\brdrhair\brdrcf1\cellx296\clbrdrl\brdrhair\brdrcf1\clbrdrr\brdrhair\brdrcf1\cellx702\pard\plain +{A1} +\cell\pard\plain \s0\ql +{A2} +\cell\row\pard\pard\plain \s42\ql +{\rtlch \ltrch\loch\lang2067 second table} +\par \trowd\trql\trleft-108\ltrrow\trrh-561\trkeep\trpaddft3\trpaddt0\trpaddfl3\trpaddl0\trpaddfb3\trpaddb0\trpaddfr3\trpaddr0\clbrdrl\brdrhair\brdrcf1\cellx296\clbrdrl\brdrhair\brdrcf1\clbrdrr\brdrhair\brdrcf1\cellx702\pard\plain \s0\ql +{A1} +\cell\pard\plain \s0\ql +{A2} +\cell\row\pard\pard\plain\par +} diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 47a91db92771..20f2a7d4c9e4 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -878,6 +879,16 @@ DECLARE_RTFEXPORT_TEST(testHyphpar, "hyphpar.rtf") CPPUNIT_ASSERT_EQUAL(false, getProperty(getParagraph(2), "ParaIsHyphenation")); } +DECLARE_RTFEXPORT_TEST(testTdf80708, "tdf80708.rtf") +{ + uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); + uno::Reference xTable(xTables->getByIndex(1), uno::UNO_QUERY); + uno::Reference xTableRows(xTable->getRows(), uno::UNO_QUERY); + // This was 2, i.e. the second table had 3 cols, now 2 as expected. + CPPUNIT_ASSERT_EQUAL(static_cast(1), getProperty< uno::Sequence >(xTableRows->getByIndex(0), "TableColumnSeparators").getLength()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 2a18d90f67f0..96c1b2c917d7 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -235,7 +235,6 @@ void RtfAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t pTextNo // In case of subtables, we may not get the first cell. if (pDeepInner && (pDeepInner->getCell() == 0 || m_bTableRowEnded)) { - m_bTableRowEnded = false; StartTableRow(pDeepInner); } @@ -873,6 +872,7 @@ void RtfAttributeOutput::StartTableRow(ww8::WW8TableNodeInfoInner::Pointer_t pTa { sal_uInt32 nCurrentDepth = pTableTextNodeInfoInner->getDepth(); SAL_INFO("sw.rtf", OSL_THIS_FUNC << ", (depth is " << nCurrentDepth << ")"); + m_bTableRowEnded = false; TableDefinition(pTableTextNodeInfoInner); -- cgit v1.2.3