sc/qa/unit/ucalc_formula.cxx | 8 ++++---- sc/source/core/tool/interpr6.cxx | 1 + sc/source/core/tool/scmatrix.cxx | 14 ++++++++++---- 3 files changed, 15 insertions(+), 8 deletions(-)
New commits: commit 4158d8843d50d50e9830c8dc24af8722de77f4af Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Thu Apr 24 12:26:01 2014 -0400 fdo#76663: Let's not skip the first element of a matrix in PRODUCT. Change-Id: I00683ce64fea58a80cd7137384e8f30464c44e9f diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx index 97282d0..84d4599 100644 --- a/sc/source/core/tool/interpr6.cxx +++ b/sc/source/core/tool/interpr6.cxx @@ -387,6 +387,7 @@ void IterateMatrix( case ifPRODUCT: { ScMatrix::IterateResult aRes = pMat->Product(bTextAsZero); + fRes = aRes.mfFirst; fRes *= aRes.mfRest; rCount += aRes.mnCount; } diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index e926e4b..b71da72 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -950,7 +950,7 @@ namespace { struct SumOp { - static const int InitVal = 0; + static const double InitVal; void operator() (double& rAccum, double fVal) { @@ -958,9 +958,11 @@ struct SumOp } }; +const double SumOp::InitVal = 0.0; + struct SumSquareOp { - static const int InitVal = 0; + static const double InitVal; void operator() (double& rAccum, double fVal) { @@ -968,9 +970,11 @@ struct SumSquareOp } }; +const double SumSquareOp::InitVal = 0.0; + struct ProductOp { - static const int InitVal = 1; + static const double InitVal; void operator() (double& rAccum, double fVal) { @@ -978,6 +982,8 @@ struct ProductOp } }; +const double ProductOp::InitVal = 1.0; + template<typename _Op> class WalkElementBlocks : std::unary_function<MatrixImplType::element_block_node_type, void> { @@ -987,7 +993,7 @@ class WalkElementBlocks : std::unary_function<MatrixImplType::element_block_node bool mbFirst:1; bool mbTextAsZero:1; public: - WalkElementBlocks(bool bTextAsZero) : maRes(0.0, _Op::InitVal, 0), mbFirst(true), mbTextAsZero(bTextAsZero) {} + WalkElementBlocks(bool bTextAsZero) : maRes(_Op::InitVal, _Op::InitVal, 0), mbFirst(true), mbTextAsZero(bTextAsZero) {} const ScMatrix::IterateResult& getResult() const { return maRes; } commit d36442aa31a57b8c559f33564dde5366358564f1 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Thu Apr 24 12:31:02 2014 -0400 fdo#76663: Better test to really test PRODUCT with array input. The first element should be something other than 1 to make this a better check. Change-Id: I2dc108a2e755034f584fef781eb5668b629dc3fd diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 4544ac6..254962e 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -2163,6 +2163,8 @@ void Test::testFuncSUM() void Test::testFuncPRODUCT() { + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto recalc. + OUString aTabName("foo"); CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, aTabName)); @@ -2175,14 +2177,12 @@ void Test::testFuncPRODUCT() val = 3; m_pDoc->SetValue(0, 2, 0, val); m_pDoc->SetString(0, 3, 0, OUString("=PRODUCT(A1:A3)")); - m_pDoc->CalcAll(); m_pDoc->GetValue(0, 3, 0, result); CPPUNIT_ASSERT_MESSAGE("Calculation of PRODUCT failed", result == 6.0); - m_pDoc->SetString(0, 4, 0, OUString("=PRODUCT({1;2;3})")); - m_pDoc->CalcAll(); + m_pDoc->SetString(0, 4, 0, OUString("=PRODUCT({2;3;4})")); m_pDoc->GetValue(0, 4, 0, result); - CPPUNIT_ASSERT_MESSAGE("Calculation of PRODUCT with inline array failed", result == 6.0); + CPPUNIT_ASSERT_MESSAGE("Calculation of PRODUCT with inline array failed", result == 24.0); m_pDoc->DeleteTab(0); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits