[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sw/qa writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Oct 4 09:52:16 UTC 2017
sw/qa/extras/rtfexport/data/tdf112507.rtf | 38 +++++++++++++++++++++++
sw/qa/extras/rtfexport/rtfexport.cxx | 15 ++++++++-
writerfilter/source/rtftok/rtfdispatchsymbol.cxx | 11 +++---
3 files changed, 57 insertions(+), 7 deletions(-)
New commits:
commit 476cdd99d76d108e1b4f21382fabedc38e9e6d6b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Oct 3 09:16:52 2017 +0200
tdf#112507 RTF import: fix too narrow table cell
Commit e6ec0794858df1444f43659b568119bf126a90e6 (tdf#104937 RTF import:
\trwWidthA is an absolute value, 2017-08-29) changed the handling of the
fake empty cell at the end of table rows so that the parameter of the
control word is an absolute, not a relative value. Turns out this
wasn't correct, the DOCX equivalent of that bugdoc shows that the
parameter is a relative value after all. The RTF spec also talks about a
"width", which is assumed to be a relative value.
So fix that bug in a different way again (by making sure that this
additional fake cell contributes to the total width of the table, so
column separators are counted correctly), this time without less
side-effects.
(cherry picked from commit 409c230ed70707eeb5e6fcd4ab904bb4a411608a)
Change-Id: Ic64fd3a6abae8e0398e8e77123f0473d73f0c4b0
Reviewed-on: https://gerrit.libreoffice.org/43080
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Stahl <mstahl at redhat.com>
diff --git a/sw/qa/extras/rtfexport/data/tdf112507.rtf b/sw/qa/extras/rtfexport/data/tdf112507.rtf
new file mode 100644
index 000000000000..648a9a865779
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf112507.rtf
@@ -0,0 +1,38 @@
+{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1036\deflangfe1036
+\paperw11906\paperh16838\margl964\margr851\margt2234\margb284 \deftab709\widowctrl\ftnbj\aenddoc\hyphhotz425\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\lytprtmet\hyphcaps0\formshade\horzdoc\dghspace120\dgvspace120
+\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind1\viewscale100\pgbrdrhead\pgbrdrfoot\nolnhtadjtbl \fet0
+\sectd \psz9\linex0\headery340\footery0\colsx709\endnhere\pgbrdropt32\sectdefaultcl
+\pard\plain \s16\ql \li0\ri0\widctlpar\faauto\adjustright\rin0\lin0\itap0
+\fs20\expnd2\expndtw12\lang1036\langfe1036\cgrid\langnp1036\langfenp1036
+{\expnd0\expndtw0 before table
+\par }
+\trowd \trgaph70\trrh327\trleft-70\trkeep\trftsWidth3\trwWidth11620\trftsWidthB3\trftsWidthA3\trpaddl70\trpaddr70\trpaddfl3\trpaddfr3 \clvmgf\clvertalt\clbrdrt\brdrnone \clbrdrl\brdrnone \clbrdrb\brdrnone \clbrdrr\brdrnone
+\cltxlrtb\clftsWidth3\clwWidth4890 \cellx4820\clvertalt\clbrdrt\brdrnone \clbrdrl\brdrnone \clbrdrb\brdrnone \clbrdrr\brdrnone \cltxlrtb\clftsWidth3\clwWidth3118 \cellx7938\clvertalt\clbrdrt\brdrnone \clbrdrl\brdrnone \clbrdrb\brdrnone \clbrdrr\brdrnone
+\cltxlrtb\clftsWidth3\clwWidth3612 \cellx11550\pard\plain \s20\ql \li0\ri0\sl-230\slmult0\widctlpar\intbl\tx6804\faauto\adjustright\rin0\lin0 \caps\f1\fs13\expnd2\expndtw12\lang1036\langfe1036\cgrid\langnp1036\langfenp1036
+{\b A1\cell }
+{\fs14 B1\cell }
+\pard\plain
+{\f31\fs13
+C1\par }
+\pard\plain \s19\ql \li0\ri0\sl-230\slmult0\widctlpar\intbl\faauto\adjustright\rin0\lin0 \caps\f1\fs13\expnd2\expndtw12\lang1036\langfe1036\cgrid\langnp1036\langfenp1036
+{\caps0\f0\expnd0\expndtw0 \cell }
+\pard\plain
+\ql \li0\ri0\widctlpar\intbl\aspalpha\aspnum\faauto\adjustright\rin0\lin0 \fs20\lang1036\langfe1036\cgrid\langnp1036\langfenp1036
+{\trowd
+\trgaph70\trrh327\trleft-70\trkeep\trftsWidth3\trwWidth11620\trftsWidthB3\trftsWidthA3\trpaddl70\trpaddr70\trpaddfl3\trpaddfr3 \clvmgf\clvertalt\clbrdrt\brdrnone \clbrdrl\brdrnone \clbrdrb\brdrnone \clbrdrr\brdrnone \cltxlrtb\clftsWidth3\clwWidth4890
+\cellx4820\clvertalt\clbrdrt\brdrnone \clbrdrl\brdrnone \clbrdrb\brdrnone \clbrdrr\brdrnone \cltxlrtb\clftsWidth3\clwWidth3118 \cellx7938\clvertalt\clbrdrt\brdrnone \clbrdrl\brdrnone \clbrdrb\brdrnone \clbrdrr\brdrnone \cltxlrtb\clftsWidth3\clwWidth3612
+\cellx11550\row }
+\trowd \trgaph70\trrh488\trleft-70\trkeep\trftsWidth3\trwWidth11620\trftsWidthB3\trftsWidthA3\trwWidthA918\trpaddl70\trpaddr70\trpaddfl3\trpaddfr3 \clvmrg\clvertalt\clbrdrt\brdrnone \clbrdrl\brdrnone \clbrdrb\brdrnone \clbrdrr\brdrnone
+\cltxlrtb\clftsWidth3\clwWidth4890 \cellx4820\clvertalt\clbrdrt\brdrnone \clbrdrl\brdrnone \clbrdrb\brdrnone \clbrdrr\brdrnone \cltxlrtb\clftsWidth3\clwWidth5812 \cellx10632\pard\plain \s20\ql \li0\ri0\sl-230\slmult0\widctlpar\intbl
+\tx6804\faauto\adjustright\rin0\lin0 \caps\f1\fs13\expnd2\expndtw12\lang1036\langfe1036\cgrid\langnp1036\langfenp1036
+{\b\fs16 \cell }
+\pard\plain \s16\ql \li0\ri0\widctlpar\intbl\tx6804\faauto\adjustright\rin0\lin0
+\fs20\expnd2\expndtw12\lang1036\langfe1036\cgrid\langnp1036\langfenp1036
+{\expnd0\expndtw0 He heard quiet steps behind him. That didn't bode well.\cell }
+\pard\plain \ql \li0\ri0\widctlpar\intbl\aspalpha\aspnum\faauto\adjustright\rin0\lin0 \fs20\lang1036\langfe1036\cgrid\langnp1036\langfenp1036
+{\trowd
+\trgaph70\trrh488\trleft-70\trkeep\trftsWidth3\trwWidth11620\trftsWidthB3\trftsWidthA3\trwWidthA918\trpaddl70\trpaddr70\trpaddfl3\trpaddfr3 \clvmrg\clvertalt\clbrdrt\brdrnone \clbrdrl\brdrnone \clbrdrb\brdrnone \clbrdrr\brdrnone
+\cltxlrtb\clftsWidth3\clwWidth4890 \cellx4820\clvertalt\clbrdrt\brdrnone \clbrdrl\brdrnone \clbrdrb\brdrnone \clbrdrr\brdrnone \cltxlrtb\clftsWidth3\clwWidth5812 \cellx10632\row }
+\pard\plain
+after table\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index d3b1a4375492..edb17196f352 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -1233,7 +1233,20 @@ DECLARE_RTFEXPORT_TEST(testTdf104937, "tdf104937.rtf")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(8), aSeparators.getLength());
// This was 3174, i.e. last cell was wider than expected, while others were
// narrower.
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(4651), aSeparators[7].Position);
+ CPPUNIT_ASSERT_GREATER(static_cast<sal_Int16>(4500), aSeparators[7].Position);
+}
+
+DECLARE_RTFEXPORT_TEST(testTdf112507, "tdf112507.rtf")
+{
+ uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
+ uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
+ auto aSeparators = getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(1), "TableColumnSeparators");
+ // First table's second row had 3 cells (so 2 separators).
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), aSeparators.getLength());
+ // This was 3333, i.e. the B2 cell was too narrow and the text needed 2 lines.
+ CPPUNIT_ASSERT_GREATER(5000, aSeparators[1].Position - aSeparators[0].Position);
}
DECLARE_RTFEXPORT_TEST(testTdf107480, "tdf107480.rtf")
diff --git a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
index e7b09b7a5f92..68c43c40cefe 100644
--- a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
@@ -236,16 +236,15 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
m_bAfterCellBeforeRow = false;
if (m_aStates.top().nTableRowWidthAfter > 0)
{
- // nTableRowWidthAfter is an absolute value, gridCol wants a
- // relative value, so count the delta from the last cellx.
- int& rCurrentCellX((Destination::NESTEDTABLEPROPERTIES == m_aStates.top().eDestination) ? m_nNestedCurrentCellX : m_nTopLevelCurrentCellX);
- int nCellX = m_aStates.top().nTableRowWidthAfter - rCurrentCellX;
-
// Add fake cellx / cell, RTF equivalent of
// OOXMLFastContextHandlerTextTableRow::handleGridAfter().
- auto pXValue = std::make_shared<RTFValue>(nCellX);
+ auto pXValue = std::make_shared<RTFValue>(m_aStates.top().nTableRowWidthAfter);
m_aStates.top().aTableRowSprms.set(NS_ooxml::LN_CT_TblGridBase_gridCol, pXValue, RTFOverwrite::NO_APPEND);
dispatchSymbol(RTF_CELL);
+
+ // Adjust total width, which is done in the \cellx handler for normal cells.
+ m_nTopLevelCurrentCellX += m_aStates.top().nTableRowWidthAfter;
+
m_aStates.top().nTableRowWidthAfter = 0;
}
More information about the Libreoffice-commits
mailing list