[Libreoffice-commits] core.git: include/oox sw/qa

Miklos Vajna vmiklos at suse.cz
Thu Aug 22 07:36:23 PDT 2013


 dev/null                                          |binary
 include/oox/drawingml/drawingmltypes.hxx          |    3 ++-
 sw/qa/extras/ooxmlexport/data/table-floating.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx          |   19 +++++++++++++++++++
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx          |   19 -------------------
 5 files changed, 21 insertions(+), 20 deletions(-)

New commits:
commit f26e35c93526cdd1c4fcb6614c3fb1f6a3c511e8
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Thu Aug 22 15:13:58 2013 +0200

    oox::drawingml::convertEmuToHmm: fix rounding for negative values
    
    This commit also moves the floating table DOCX import testcase to the
    export suite. That test now passes fine, though previously it failed with:
    
    - Expected: -199
    - Actual  : -198
    
    Due to the rounding error.
    
    Change-Id: I9bdc9295f68b6bd3e5f5bee868aae15194b30804

diff --git a/include/oox/drawingml/drawingmltypes.hxx b/include/oox/drawingml/drawingmltypes.hxx
index 5df664e..9e011f3 100644
--- a/include/oox/drawingml/drawingmltypes.hxx
+++ b/include/oox/drawingml/drawingmltypes.hxx
@@ -150,7 +150,8 @@ inline sal_Int64 convertHmmToEmu( sal_Int32 nValue )
 /** Converts the passed 64-bit integer value from EMUs to 1/100 mm. */
 inline sal_Int32 convertEmuToHmm( sal_Int64 nValue )
 {
-    return getLimitedValue< sal_Int32, sal_Int64 >( (nValue + EMU_PER_HMM / 2) / EMU_PER_HMM, SAL_MIN_INT32, SAL_MAX_INT32 );
+    sal_Int32 nCorrection = (nValue > 0 ? 1 : -1) * EMU_PER_HMM / 2; // So that the implicit floor will round.
+    return getLimitedValue< sal_Int32, sal_Int64 >( (nValue + nCorrection) / EMU_PER_HMM, SAL_MIN_INT32, SAL_MAX_INT32 );
 }
 
 // ============================================================================
diff --git a/sw/qa/extras/ooxmlimport/data/table-floating.docx b/sw/qa/extras/ooxmlexport/data/table-floating.docx
similarity index 100%
rename from sw/qa/extras/ooxmlimport/data/table-floating.docx
rename to sw/qa/extras/ooxmlexport/data/table-floating.docx
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 2129d9c..89c3aab 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -107,6 +107,7 @@ public:
     void testFdo64350();
     void testFdo67013();
     void testParaShadow();
+    void testTableFloating();
     void testTableFloatingMargins();
     void testFdo44689_start_page_7();
 
@@ -192,6 +193,7 @@ void Test::run()
         {"fdo64350.docx", &Test::testFdo64350},
         {"fdo67013.docx", &Test::testFdo67013},
         {"para-shadow.docx", &Test::testParaShadow},
+        {"table-floating.docx", &Test::testTableFloating},
         {"table-floating-margins.docx", &Test::testTableFloatingMargins},
         {"fdo44689_start_page_7.docx", &Test::testFdo44689_start_page_7},
     };
@@ -1151,6 +1153,23 @@ void Test::testParaShadow()
     CPPUNIT_ASSERT_EQUAL(sal_Int16(TWIP_TO_MM100(24/8*20)), aShadow.ShadowWidth);
 }
 
+void Test::testTableFloating()
+{
+    // Both the size and the position of the table was incorrect.
+    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
+    // Second table was too wide: 16249, i.e. as wide as the first table.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(11248), getProperty<sal_Int32>(xTables->getByIndex(1), "Width"));
+
+    uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+    // This was 0, should be the the opposite of (left margin + half of the border width).
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(-199), getProperty<sal_Int32>(xFrame, "HoriOrientPosition"));
+    // Was 0 as well, should be the right margin.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(250), getProperty<sal_Int32>(xFrame, "RightMargin"));
+}
+
 void Test::testTableFloatingMargins()
 {
     uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 3f62931..524ef58 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -128,7 +128,6 @@ public:
     void testFdo66474();
     void testGroupshapeRotation();
     void testBnc780044Spacing();
-    void testTableFloating();
     void testTableFloatingMargins();
 
     CPPUNIT_TEST_SUITE(Test);
@@ -223,7 +222,6 @@ void Test::run()
         {"fdo66474.docx", &Test::testFdo66474},
         {"groupshape-rotation.docx", &Test::testGroupshapeRotation},
         {"bnc780044_spacing.docx", &Test::testBnc780044Spacing},
-        {"table-floating.docx", &Test::testTableFloating},
         {"table-floating-margins.docx", &Test::testTableFloatingMargins},
     };
     header();
@@ -1554,23 +1552,6 @@ void Test::testBnc780044Spacing()
     CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage());
 }
 
-void Test::testTableFloating()
-{
-    // Both the size and the position of the table was incorrect.
-    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
-    uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
-    // Second table was too wide: 16249, i.e. as wide as the first table.
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(11248), getProperty<sal_Int32>(xTables->getByIndex(1), "Width"));
-
-    uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
-    uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
-    uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
-    // This was 0, should be the the opposite of (left margin + half of the border width).
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(-199), getProperty<sal_Int32>(xFrame, "HoriOrientPosition"));
-    // Was 0 as well, should be the right margin.
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(250), getProperty<sal_Int32>(xFrame, "RightMargin"));
-}
-
 void Test::testTableFloatingMargins()
 {
     // In case the table had custom left cell margin, the horizontal position was still incorrect (too small, -199).


More information about the Libreoffice-commits mailing list