[Libreoffice-commits] core.git: sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Nov 7 01:27:16 PST 2014


 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx                |    2 +-
 sw/qa/extras/ooxmlimport/data/tcw-rounding.docx          |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx                 |    6 ++++++
 writerfilter/source/dmapper/DomainMapperTableManager.cxx |    4 ++--
 4 files changed, 9 insertions(+), 3 deletions(-)

New commits:
commit 29cbbad64088354425c606f9eb6c267bdf7731dc
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Nov 7 10:13:08 2014 +0100

    DOCX import: fix rounding error in table cell widths
    
    Change-Id: I733fd4b998ba4d0bde2f91f2b3d76205f0dc8020

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index 3a8502b..e187959 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -295,7 +295,7 @@ DECLARE_OOXMLEXPORT_TEST(testSegFaultWhileSave, "test_segfault_while_save.docx")
     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     if (!pXmlDoc)
         return;
-    CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").match("6138"));
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(6137), getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").toInt32());
 }
 
 DECLARE_OOXMLEXPORT_TEST(fdo69656, "Table_cell_auto_width_fdo69656.docx")
diff --git a/sw/qa/extras/ooxmlimport/data/tcw-rounding.docx b/sw/qa/extras/ooxmlimport/data/tcw-rounding.docx
new file mode 100644
index 0000000..d4055c9
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tcw-rounding.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index d4d1766..3a541ad 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -2391,6 +2391,12 @@ static OString dateTimeToString( const util::DateTime& dt )
     return DateTimeToOString( DateTime( Date( dt.Day, dt.Month, dt.Year ), tools::Time( dt.Hours, dt.Minutes, dt.Seconds )));
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTcwRounding, "tcw-rounding.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());
+}
+
 DECLARE_OOXMLIMPORT_TEST(testBnc821804, "bnc821804.docx")
 {
     CPPUNIT_ASSERT_EQUAL( OUString( "TITLE" ), getRun( getParagraph( 1 ), 1 )->getString());
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index 0caba65..15f4397 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -34,6 +34,7 @@
 #include <ooxml/resourceids.hxx>
 #include <dmapperLoggers.hxx>
 #include <dmapper/DomainMapper.hxx>
+#include <rtl/math.hxx>
 
 namespace writerfilter {
 namespace dmapper {
@@ -745,8 +746,7 @@ void DomainMapperTableManager::endOfRowAction()
                 for ( sal_Int32 nGridCount = *aSpansIter; nGridCount > 0; --nGridCount )
                     fGridWidth += (*pTableGrid.get())[nBorderGridIndex++];
 
-                sal_Int16 nRelPos =
-                    sal::static_int_cast< sal_Int16 >((fGridWidth * 10000) / nFullWidthRelative);
+                sal_Int16 nRelPos = rtl::math::round((fGridWidth * 10000) / nFullWidthRelative);
 
                 pSeparators[nBorder].Position =  nRelPos + nLastRelPos;
                 pSeparators[nBorder].IsVisible = sal_True;


More information about the Libreoffice-commits mailing list