From 12fef6566fbdad29ebfd8493e2fff56071cf0be3 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Thu, 24 Apr 2014 12:26:01 -0400 Subject: fdo#76663: Let's not skip the first element of a matrix in PRODUCT. Change-Id: I00683ce64fea58a80cd7137384e8f30464c44e9f (cherry picked from commit 4158d8843d50d50e9830c8dc24af8722de77f4af) Reviewed-on: https://gerrit.libreoffice.org/9153 Reviewed-by: Eike Rathke Tested-by: Eike Rathke (cherry picked from commit a686162553f68f19663694b8407a47d2ec9be700) Reviewed-on: https://gerrit.libreoffice.org/9158 Reviewed-by: Markus Mohrhard Reviewed-by: David Tardon --- sc/source/core/tool/interpr6.cxx | 1 + sc/source/core/tool/scmatrix.cxx | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx index b98fb9bed306..d6b46a763a93 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 45c8e4868094..215bb763720c 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -951,7 +951,7 @@ namespace { struct SumOp { - static const int InitVal = 0; + static const double InitVal; void operator() (double& rAccum, double fVal) { @@ -959,9 +959,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) { @@ -969,9 +971,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) { @@ -979,6 +983,8 @@ struct ProductOp } }; +const double ProductOp::InitVal = 1.0; + template class WalkElementBlocks : std::unary_function { @@ -988,7 +994,7 @@ class WalkElementBlocks : std::unary_function