[Libreoffice-commits] core.git: 2 commits - writerfilter/CppunitTest_writerfilter_misc.mk writerfilter/qa writerfilter/source

Matúš Kukan matus.kukan at collabora.com
Wed Jul 9 14:03:36 PDT 2014


 writerfilter/CppunitTest_writerfilter_misc.mk    |    5 ----
 writerfilter/qa/cppunittests/misc/misc.cxx       |   27 ++++++++++++++++++++++-
 writerfilter/source/dmapper/ConversionHelper.cxx |   10 ++++----
 writerfilter/source/dmapper/ConversionHelper.hxx |    5 ++--
 4 files changed, 34 insertions(+), 13 deletions(-)

New commits:
commit 6bcf07ec389ee78720e2dcfd66ee8ec57dd168a3
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Wed Jul 9 22:35:37 2014 +0200

    unit test for convertTwipToMM100 functions (cp#1000087)
    
    Change-Id: I36d68ecaa71319d90b9abaec21543cc5d4e76f24

diff --git a/writerfilter/CppunitTest_writerfilter_misc.mk b/writerfilter/CppunitTest_writerfilter_misc.mk
index 1cdcd80..ad6bd7f 100644
--- a/writerfilter/CppunitTest_writerfilter_misc.mk
+++ b/writerfilter/CppunitTest_writerfilter_misc.mk
@@ -23,11 +23,6 @@ $(eval $(call gb_CppunitTest_use_libraries,writerfilter_misc, \
 	$(gb_UWINAPI) \
 ))
 
-$(eval $(call gb_CppunitTest_set_include,writerfilter_misc, \
-	$$(INCLUDE) \
-	-I$(SRCDIR)/writerfilter/inc \
-))
-
 $(eval $(call gb_CppunitTest_add_exception_objects,writerfilter_misc, \
 	writerfilter/qa/cppunittests/misc/misc \
 ))
diff --git a/writerfilter/qa/cppunittests/misc/misc.cxx b/writerfilter/qa/cppunittests/misc/misc.cxx
index ea0cfd2..fc37b14 100644
--- a/writerfilter/qa/cppunittests/misc/misc.cxx
+++ b/writerfilter/qa/cppunittests/misc/misc.cxx
@@ -25,8 +25,11 @@
 
 using namespace std;
 
-
 namespace writerfilter { namespace dmapper {
+    namespace ConversionHelper{
+        SAL_DLLPUBLIC_IMPORT sal_Int32 convertTwipToMM100(sal_Int32 _t);
+        SAL_DLLPUBLIC_IMPORT sal_uInt32 convertTwipToMM100Unsigned(sal_Int32 _t);
+    }
 
 SAL_DLLPUBLIC_IMPORT // export just for test
 boost::tuple<OUString, vector<OUString>, vector<OUString> >
@@ -44,9 +47,11 @@ public:
     virtual void setUp() SAL_OVERRIDE;
     virtual void tearDown() SAL_OVERRIDE;
 
+    void testTwipConversions();
     void testFieldParameters();
 
     CPPUNIT_TEST_SUITE(WriterfilterMiscTest);
+    CPPUNIT_TEST(testTwipConversions);
     CPPUNIT_TEST(testFieldParameters);
     CPPUNIT_TEST_SUITE_END();
 };
@@ -59,6 +64,26 @@ void WriterfilterMiscTest::tearDown()
 {
 }
 
+void WriterfilterMiscTest::testTwipConversions()
+{
+    using writerfilter::dmapper::ConversionHelper::convertTwipToMM100;
+    using writerfilter::dmapper::ConversionHelper::convertTwipToMM100Unsigned;
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(-2), convertTwipToMM100(-1));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(-17639), convertTwipToMM100(-10000));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(-70556), convertTwipToMM100(-40000));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), convertTwipToMM100(1));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(17639), convertTwipToMM100(10000));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), convertTwipToMM100(40000));
+
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), convertTwipToMM100Unsigned(-1));
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), convertTwipToMM100Unsigned(-10000));
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), convertTwipToMM100Unsigned(-40000));
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(2), convertTwipToMM100Unsigned(1));
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(17639), convertTwipToMM100Unsigned(10000));
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), convertTwipToMM100Unsigned(40000));
+}
+
 void WriterfilterMiscTest::testFieldParameters()
 {
     using writerfilter::dmapper::lcl_SplitFieldCommand;
diff --git a/writerfilter/source/dmapper/ConversionHelper.hxx b/writerfilter/source/dmapper/ConversionHelper.hxx
index da0805c..596237c 100644
--- a/writerfilter/source/dmapper/ConversionHelper.hxx
+++ b/writerfilter/source/dmapper/ConversionHelper.hxx
@@ -43,8 +43,9 @@ namespace ConversionHelper{
     //convert the number format string form MS format to SO format
     OUString ConvertMSFormatStringToSO(
             const OUString& rFormat, ::com::sun::star::lang::Locale& rLocale, bool bHijri);
-    sal_Int32 convertTwipToMM100(sal_Int32 _t);
-    sal_uInt32 convertTwipToMM100Unsigned(sal_Int32 _t);
+    // export just for test
+    SAL_DLLPUBLIC_EXPORT sal_Int32 convertTwipToMM100(sal_Int32 _t);
+    SAL_DLLPUBLIC_EXPORT sal_uInt32 convertTwipToMM100Unsigned(sal_Int32 _t);
     // probably the most useless unit in the world - English Metric Units (EMU) 360 000 EMU == 1cm
     sal_Int32 convertEMUToMM100(sal_Int32 _t);
     sal_Int16 convertTableJustification( sal_Int32 nIntValue );
commit 4d1621136c464b462a598571ecdcfe2ae119d8c7
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Wed Jul 9 14:25:04 2014 +0200

    Fix ignoring large twips values like MSO does (cp#1000087)
    
    which was introduced in 10b4da63e3143108ba75891e9e98fdaa2f7953ab.
    
    Since 1e47614cdb84b018a22a334dad0cdd9f0f53892c, only
    convertTwipToMM100Unsigned() ignores large values, which presumably
    was not the intention. At least commit message suggests so.
    
    So, move the check back to convertTwipToMM100().
    
    Change-Id: I17040f1987e24789b9de39a837d9f7ecaed520fb

diff --git a/writerfilter/source/dmapper/ConversionHelper.cxx b/writerfilter/source/dmapper/ConversionHelper.cxx
index ddde98d..95d46f7 100644
--- a/writerfilter/source/dmapper/ConversionHelper.cxx
+++ b/writerfilter/source/dmapper/ConversionHelper.cxx
@@ -228,6 +228,10 @@ OUString ConvertMSFormatStringToSO(
 
 sal_Int32 convertTwipToMM100(sal_Int32 _t)
 {
+    // It appears that MSO handles large twip values specially, probably legacy 16bit handling,
+    // anything that's bigger than 32767 appears to be simply ignored.
+    if( _t >= 0x8000 )
+        return 0;
     return ::convertTwipToMm100( _t );
 }
 
@@ -235,11 +239,7 @@ sal_uInt32 convertTwipToMM100Unsigned(sal_Int32 _t)
 {
     if( _t < 0 )
         return 0;
-    // It appears that MSO handles large twip values specially, probably legacy 16bit handling,
-    // anything that's bigger than 32767 appears to be simply ignored.
-    if( _t >= 0x8000 )
-        return 0;
-    return ::convertTwipToMm100( _t );
+    return convertTwipToMM100( _t );
 }
 
 sal_Int32 convertEMUToMM100(sal_Int32 _t)


More information about the Libreoffice-commits mailing list