[Libreoffice-commits] core.git: Branch 'feature/unitver' - 2 commits - sc/qa sc/source

Markus Mohrhard markus.mohrhard at googlemail.com
Tue Jun 30 01:35:18 PDT 2015


 sc/qa/unit/units.cxx               |   20 ++++++++++++++++++++
 sc/source/core/units/unitsimpl.cxx |    2 +-
 2 files changed, 21 insertions(+), 1 deletion(-)

New commits:
commit 122874c94da9da8b5a05bef3f883338fb68cd32e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Jun 30 09:25:29 2015 +0200

    add test case for unit conversion
    
    Change-Id: I726758c93b25ed16b5708a71645004537f32ac76

diff --git a/sc/qa/unit/units.cxx b/sc/qa/unit/units.cxx
index 1dbf74f..ee6af8a 100644
--- a/sc/qa/unit/units.cxx
+++ b/sc/qa/unit/units.cxx
@@ -14,6 +14,8 @@
 
 #include "helper/qahelper.hxx"
 
+#include "rangelst.hxx"
+
 #include <com/sun/star/util/NumberFormat.hpp>
 
 using namespace sc::units;
@@ -50,6 +52,7 @@ public:
 
     void testUnitsCompatible();
     void testCellConversion();
+    void testConvertCellUnits();
     void testUnitsForRange();
     void testRangeConversion();
 
@@ -64,6 +67,7 @@ public:
 
     CPPUNIT_TEST(testUnitsCompatible);
     CPPUNIT_TEST(testCellConversion);
+    CPPUNIT_TEST(testConvertCellUnits);
     CPPUNIT_TEST(testUnitsForRange);
     CPPUNIT_TEST(testRangeConversion);
 
@@ -877,6 +881,22 @@ void UnitsTest::testRangeConversion() {
     // 3. actual sensible ranges
 }
 
+void UnitsTest::testConvertCellUnits()
+{
+    mpDoc->EnsureTable(0);
+
+    // Set up a column with a normal header and a few data values
+    ScAddress aAddress(20, 0, 0);
+    mpDoc->SetString(aAddress, "100km");
+    ScRange aRange(aAddress);
+    ScRangeList aRangeList(aRange);
+    OUString aOutput("miles");
+    bool bConverted = mpUnitsImpl->convertCellUnits(aRangeList, mpDoc, aOutput);
+    CPPUNIT_ASSERT(bConverted);
+    double nVal = mpDoc->GetValue(aAddress);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(62.1371192932129, nVal, 1e-14);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(UnitsTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 4f50fc6d1740a47220c4cbafd91af9bde80113b9
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Jun 30 09:25:07 2015 +0200

    fix crash when converting units
    
    Change-Id: Ic883e13b5c6923c31e65a887597f0910807dc94d

diff --git a/sc/source/core/units/unitsimpl.cxx b/sc/source/core/units/unitsimpl.cxx
index 7d16ae3..4f0057c 100644
--- a/sc/source/core/units/unitsimpl.cxx
+++ b/sc/source/core/units/unitsimpl.cxx
@@ -780,7 +780,7 @@ bool UnitsImpl::convertCellUnitsForColumnRange(const ScRange& rRange,
                 }
             }
 
-            bool bLocalAnnotationRequired = (!rRange.In(*aHeader.address)) &&
+            bool bLocalAnnotationRequired = (aHeader.address && !rRange.In(*aHeader.address)) &&
                 (rOutputUnit != aHeader.unit);
             double nValue = pDoc->GetValue(aCurrent);
 


More information about the Libreoffice-commits mailing list