Kaydet (Commit) e502463f authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#123104 DOCX import: fix lack of vertical merge due to rounding

Regression from commit 29cbbad6 (DOCX
import: fix rounding error in table cell widths, 2014-11-07), which
changed truncation to rounding for the twips -> 1/10000th of relative
width conversion during import, but left export unchanged.

But adapting the export is not that easy: one part would be the
std::unique() call in
WW8TableNodeInfoInner::getColumnWidthsBasedOnAllRows() to not require
exact comparison, but doing so has it own side effects (multiple failing
tests).

So just revert the mentioned commit, as a minor rounding error is much
better than a broken vertical merge. And once it's clear how to adapt
export at the same time, this rounding on the import side can be
re-introduced.

Change-Id: I9e01ea5cc2c2f8aabe1e21cb8118c9c0e2c45494
Reviewed-on: https://gerrit.libreoffice.org/69065
Tested-by: Jenkins
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
üst af836fe3
......@@ -746,10 +746,16 @@ DECLARE_OOXMLEXPORT_TEST(testBnc891663, "bnc891663.docx")
CPPUNIT_ASSERT( textNextRowTop >= imageTop + imageHeight );
}
DECLARE_OOXMLEXPORT_TEST(testTcwRounding, "tcw-rounding.docx")
DECLARE_OOXMLEXPORT_TEST(testTdf123104, "tdf123104.docx")
{
// Width of the A1 cell in twips was 3200, due to a rounding error.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3201), parseDump("/root/page/body/tab/row/cell[1]/infos/bounds", "width").toInt32());
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
uno::Reference<table::XCell> xCell = xTable->getCellByName("E1");
// See SwXCell::getPropertyValue(), we really put 'long' into an Any there.
// Without the accompanying fix in place, this test would have failed with 'Expected: 3;Actual :
// 2', i.e. the vertical merge covered one less cell, resulting in a cell with white background.
CPPUNIT_ASSERT_EQUAL(static_cast<long>(3), getProperty<long>(xCell, "RowSpan"));
}
DECLARE_OOXMLEXPORT_TEST(testFdo85542, "fdo85542.docx")
......
......@@ -298,7 +298,7 @@ DECLARE_OOXMLEXPORT_TEST(testSegFaultWhileSave, "test_segfault_while_save.docx")
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc)
return;
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(6137), getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").toInt32());
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(6138), getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").toInt32());
// tdf#106572 - preventative test matching danger conditions, but imported OK anyway
CPPUNIT_ASSERT_EQUAL(OUString("First Page"), getProperty<OUString>(getParagraphOrTable(1), "PageDescName"));
......
......@@ -1353,7 +1353,7 @@ DECLARE_RTFEXPORT_TEST(testTdf112507, "tdf112507.rtf")
// 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);
CPPUNIT_ASSERT_GREATEREQUAL(5000, aSeparators[1].Position - aSeparators[0].Position);
}
DECLARE_RTFEXPORT_TEST(testTdf107480, "tdf107480.rtf")
......
......@@ -124,10 +124,10 @@ DECLARE_RTFEXPORT_TEST(testTdf115180, "tdf115180.docx")
CPPUNIT_ASSERT_EQUAL_MESSAGE("Row width", sal_Int32(9360), rowWidth);
sal_Int32 cell1Width
= parseDump("/root/page/body/tab/row/cell[1]/infos/bounds", "width").toInt32();
CPPUNIT_ASSERT_EQUAL_MESSAGE("First cell width", sal_Int32(9142), cell1Width);
CPPUNIT_ASSERT_MESSAGE("First cell width", cell1Width >= 9140 && cell1Width <= 9142);
sal_Int32 cell2Width
= parseDump("/root/page/body/tab/row/cell[2]/infos/bounds", "width").toInt32();
CPPUNIT_ASSERT_EQUAL_MESSAGE("First cell width", sal_Int32(218), cell2Width);
CPPUNIT_ASSERT_MESSAGE("Second cell width", cell2Width >= 218 && cell2Width <= 220);
}
DECLARE_RTFEXPORT_TEST(testTdf116841, "tdf116841.rtf")
......
......@@ -933,7 +933,7 @@ DECLARE_RTFEXPORT_TEST(testTdf97035, "tdf97035.rtf")
// First cell width of the second row should be 2300
uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int16(2300), getProperty<uno::Sequence<text::TableColumnSeparator>>(
CPPUNIT_ASSERT_EQUAL(sal_Int16(2299), getProperty<uno::Sequence<text::TableColumnSeparator>>(
xTableRows->getByIndex(1), "TableColumnSeparators")[0]
.Position);
}
......
......@@ -461,7 +461,7 @@ DECLARE_RTFIMPORT_TEST(testFdo55525, "fdo55525.rtf")
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1877), getProperty<sal_Int32>(xTable, "LeftMargin"));
// Cell width of A1 was 3332 (e.g. not set, 30% percent of total width)
uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int16(897), getProperty<uno::Sequence<text::TableColumnSeparator>>(
CPPUNIT_ASSERT_EQUAL(sal_Int16(896), getProperty<uno::Sequence<text::TableColumnSeparator>>(
xTableRows->getByIndex(0), "TableColumnSeparators")[0]
.Position);
}
......
......@@ -664,7 +664,8 @@ void DomainMapperTableManager::endOfRowAction()
for ( sal_Int32 nGridCount = *aSpansIter; nGridCount > 0; --nGridCount )
fGridWidth += (*pTableGrid)[nBorderGridIndex++];
sal_Int16 nRelPos = rtl::math::round((fGridWidth * 10000) / nFullWidthRelative);
sal_Int16 nRelPos =
sal::static_int_cast< sal_Int16 >((fGridWidth * 10000) / nFullWidthRelative);
pSeparators[nBorder].Position = nRelPos + nLastRelPos;
pSeparators[nBorder].IsVisible = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment