From 8d1f528394bdd81057c9776cbd5445a7da073c25 Mon Sep 17 00:00:00 2001 Message-Id: <8d1f528394bdd81057c9776cbd5445a7da073c25.1399376034.git.erack@redhat.com> From: Kohei Yoshida <kohei.yoshida@collabora.com> Date: Thu, 24 Apr 2014 12:26:01 -0400 Subject: [PATCH] fdo#76663: Let's not skip the first element of a matrix in PRODUCT. MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------erAck-patch-parts" This is a multi-part message in MIME format. --------------erAck-patch-parts Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit (cherry picked from commit 4158d8843d50d50e9830c8dc24af8722de77f4af) Conflicts: sc/source/core/tool/interpr6.cxx Backported. Change-Id: I00683ce64fea58a80cd7137384e8f30464c44e9f Reviewed-on: https://gerrit.libreoffice.org/9159 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com> (cherry picked from commit b3d3c64a83c510a5c9aacf517eee8ca697e21d8f) Reviewed-on: https://gerrit.libreoffice.org/9160 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Reviewed-by: David Tardon <dtardon@redhat.com> --- sc/source/core/tool/interpr1.cxx | 1 + sc/source/core/tool/scmatrix.cxx | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) --------------erAck-patch-parts Content-Type: text/x-patch; name="0001-fdo-76663-Let-s-not-skip-the-first-element-of-a-matr.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0001-fdo-76663-Let-s-not-skip-the-first-element-of-a-matr.patch" diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index a03b13a..fd684ee 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -3946,6 +3946,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 eea3a71..933e808 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -976,7 +976,7 @@ namespace { struct SumOp { - static const int InitVal = 0; + static const double InitVal; void operator() (double& rAccum, double fVal) { @@ -984,9 +984,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) { @@ -994,9 +996,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) { @@ -1004,6 +1008,8 @@ struct ProductOp } }; +const double ProductOp::InitVal = 1.0; + template<typename _Op> class WalkElementBlocks : std::unary_function<MatrixImplType::element_block_node_type, void> { @@ -1013,7 +1019,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; } --------------erAck-patch-parts--