[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - sw/qa writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Nov 10 03:48:19 PST 2015
sw/qa/extras/rtfimport/data/tdf59454.rtf | 8 ++++++++
sw/qa/extras/rtfimport/rtfimport.cxx | 6 ++++++
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 18 ++++++++++++++++++
3 files changed, 32 insertions(+)
New commits:
commit 610e6fddbc19dd2ac23b6a6cf4d8cbfb0dcf589a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Oct 26 08:56:05 2015 +0100
tdf#59454 RTF import: handle section break right before a table
DOCX import could handle this situation, as commit
2e8aad6d45c53d554ccaf26de998ede708cfc289 (fdo#39056 fdo#75431 Section
Properties if section starts with table, 2014-04-18) added support for
this situation, in case NS_ooxml::LN_tblStart/End is emitted by the
tokenizer.
Fix the problem by sending these tokens in the RTF tokenizer as well, at
least for non-nested tables.
Change-Id: Ifedb121754634529c27820dd5175e7f9e24019e1
(cherry picked from commit e57752170e604c85a6fe8aeaa38784796e00bab1)
Reviewed-on: https://gerrit.libreoffice.org/19878
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/qa/extras/rtfimport/data/tdf59454.rtf b/sw/qa/extras/rtfimport/data/tdf59454.rtf
new file mode 100644
index 0000000..b10820a
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/tdf59454.rtf
@@ -0,0 +1,8 @@
+{\rtf1
+foo\par
+\sect\sectd
+\trowd\cellx980\cellx11480\cellx14000\pard\plain \intbl\itap1\s33\qj\hyphpar1 \fs24 \qc\hyphpar1 A1\cell
+\pard\plain \intbl\itap1\s33\qj\hyphpar1 \fs24 \qc\hyphpar1 B1\cell
+\pard\plain \intbl\itap1\s33\qj\hyphpar1 \fs24 \qc\hyphpar1 C1\cell
+\trowd\cellx980\clbrdrt\brdrs\brdrw10\clbrdrl\brdrs\brdrw10\clbrdrb\brdrs\brdrw10\clbrdrr\brdrs\brdrw10\clvertalt\cellx11480\clbrdrt\brdrs\brdrw10\clbrdrl\brdrs\brdrw10\clbrdrb\brdrs\brdrw10\clbrdrr\brdrs\brdrw10\clvertalt\cellx14000\row
+\pard\plain bar\par }
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index c7f34c2..b718572 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2344,6 +2344,12 @@ DECLARE_RTFIMPORT_TEST(testTdf94435, "tdf94435.rtf")
CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(1), "ParaAdjust")));
}
+DECLARE_RTFIMPORT_TEST(testTdf59454, "tdf59454.rtf")
+{
+ // This was 1, section break was ignored right before a table.
+ CPPUNIT_ASSERT_EQUAL(2, getPages());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index d61c664..6dd2405 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2138,6 +2138,15 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
{
parBreak();
// Not in table? Reset max width.
+ if (m_nCellxMax)
+ {
+ // Was in table, but not anymore -> tblEnd.
+ RTFSprms aAttributes;
+ RTFSprms aSprms;
+ aSprms.set(NS_ooxml::LN_tblEnd, std::make_shared<RTFValue>(1));
+ writerfilter::Reference<Properties>::Pointer_t pProperties = std::make_shared<RTFReferenceProperties>(aAttributes, aSprms);
+ Mapper().props(pProperties);
+ }
m_nCellxMax = 0;
}
else if (m_aStates.top().eDestination != Destination::SHAPETEXT)
@@ -4236,6 +4245,15 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
m_aStates.top().aTableCellAttributes = m_aDefaultState.aTableCellAttributes;
// We assume text after a row definition always belongs to the table, to handle text before the real INTBL token
dispatchFlag(RTF_INTBL);
+ if (!m_nCellxMax)
+ {
+ // Wasn't in table, but now is -> tblStart.
+ RTFSprms aAttributes;
+ RTFSprms aSprms;
+ aSprms.set(NS_ooxml::LN_tblStart, std::make_shared<RTFValue>(1));
+ writerfilter::Reference<Properties>::Pointer_t pProperties = std::make_shared<RTFReferenceProperties>(aAttributes, aSprms);
+ Mapper().props(pProperties);
+ }
m_nCellxMax = std::max(m_nCellxMax, nParam);
}
break;
More information about the Libreoffice-commits
mailing list