[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - sw/qa writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Mar 13 11:35:08 UTC 2019


 dev/null                                                 |binary
 sw/qa/extras/ooxmlexport/data/tdf123104.docx             |binary
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx               |   12 +++++++++---
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx                |    2 +-
 sw/qa/extras/rtfexport/rtfexport.cxx                     |    2 +-
 sw/qa/extras/rtfexport/rtfexport2.cxx                    |    2 +-
 sw/qa/extras/rtfexport/rtfexport3.cxx                    |    4 ++--
 sw/qa/extras/rtfimport/rtfimport.cxx                     |    2 +-
 writerfilter/source/dmapper/DomainMapperTableManager.cxx |    3 ++-
 9 files changed, 17 insertions(+), 10 deletions(-)

New commits:
commit 77cc7463bcd3fe9a6528ed1b0309708608cd1cc7
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Mar 11 21:40:44 2019 +0100
Commit:     Xisco FaulĂ­ <xiscofauli at libreoffice.org>
CommitDate: Wed Mar 13 12:34:43 2019 +0100

    tdf#123104 DOCX import: fix lack of vertical merge due to rounding
    
    Regression from commit 29cbbad64088354425c606f9eb6c267bdf7731dc (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.
    
    (cherry picked from commit e502463fa9a601963aa9f5a8783eb1318de36c13)
    
    Conflicts:
            sw/qa/extras/rtfexport/rtfexport5.cxx
    
    Change-Id: I9e01ea5cc2c2f8aabe1e21cb8118c9c0e2c45494
    Reviewed-on: https://gerrit.libreoffice.org/69154
    Tested-by: Jenkins
    Reviewed-by: Xisco FaulĂ­ <xiscofauli at libreoffice.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tcw-rounding.docx b/sw/qa/extras/ooxmlexport/data/tcw-rounding.docx
deleted file mode 100644
index d4055c953b6f..000000000000
Binary files a/sw/qa/extras/ooxmlexport/data/tcw-rounding.docx and /dev/null differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf123104.docx b/sw/qa/extras/ooxmlexport/data/tdf123104.docx
new file mode 100644
index 000000000000..73cad8617c7e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf123104.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index b3494c754f16..009b77069055 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -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")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index beaa1b936cc4..70fb4a16a73e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -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"));
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 7dd8d79ced50..b42e855aa616 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -1419,7 +1419,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")
diff --git a/sw/qa/extras/rtfexport/rtfexport2.cxx b/sw/qa/extras/rtfexport/rtfexport2.cxx
index e5b2fd4f958b..307b6465ecad 100644
--- a/sw/qa/extras/rtfexport/rtfexport2.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport2.cxx
@@ -1831,7 +1831,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);
 }
diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx
index 576f7b6c85b8..85dbb38413ba 100644
--- a/sw/qa/extras/rtfexport/rtfexport3.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport3.cxx
@@ -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")
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index f09169ed77d3..5d7e6f34db79 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -460,7 +460,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);
 }
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index b1b08b72c8d2..b698fabe0c44 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -679,7 +679,8 @@ void DomainMapperTableManager::endOfRowAction()
                 for ( sal_Int32 nGridCount = *aSpansIter; nGridCount > 0; --nGridCount )
                     fGridWidth += (*pTableGrid.get())[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;


More information about the Libreoffice-commits mailing list