sc/qa/unit/ucalc_formula.cxx | 19 ++++++++++++++----- sc/source/core/tool/interpr6.cxx | 5 ++--- 2 files changed, 16 insertions(+), 8 deletions(-)
New commits: commit 3e9f9bff4a3d8365f58545dae0c004a1254a56e3 Author: Eike Rathke <[email protected]> Date: Mon May 22 16:23:25 2017 +0200 Unit test for SUBTOTAL AVERAGE with array of references, tdf#58874 To test the count vector as well. Change-Id: Idc6bcdc779ea0e6e8a6118934fd8e7856eba1518 diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 92f93722c531..69f3a47962c1 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -7928,18 +7928,27 @@ void Test::testFuncRefListArraySUBTOTAL() aPos.IncRow(); CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL SUM for A4:A5 failed", 24.0, m_pDoc->GetValue(aPos)); - // Matrix in C7:C9, individual MIN of A2:A3, A3:A4 and A4:A5 - m_pDoc->InsertMatrixFormula(2, 6, 2, 8, aMark, "=SUBTOTAL(5;OFFSET(A1;ROW(1:3);0;2))"); + // Matrix in C7:C9, individual AVERAGE of A2:A3, A3:A4 and A4:A5 + m_pDoc->InsertMatrixFormula(2, 6, 2, 8, aMark, "=SUBTOTAL(1;OFFSET(A1;ROW(1:3);0;2))"); aPos.Set(2,6,0); + CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL AVERAGE for A2:A3 failed", 3.0, m_pDoc->GetValue(aPos)); + aPos.IncRow(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL AVERAGE for A3:A4 failed", 6.0, m_pDoc->GetValue(aPos)); + aPos.IncRow(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL AVERAGE for A4:A5 failed", 12.0, m_pDoc->GetValue(aPos)); + + // Matrix in D7:D9, individual MIN of A2:A3, A3:A4 and A4:A5 + m_pDoc->InsertMatrixFormula(3, 6, 3, 8, aMark, "=SUBTOTAL(5;OFFSET(A1;ROW(1:3);0;2))"); + aPos.Set(3,6,0); CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL MIN for A2:A3 failed", 2.0, m_pDoc->GetValue(aPos)); aPos.IncRow(); CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL MIN for A3:A4 failed", 4.0, m_pDoc->GetValue(aPos)); aPos.IncRow(); CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL MIN for A4:A5 failed", 8.0, m_pDoc->GetValue(aPos)); - // Matrix in D7:D9, individual MAX of A2:A3, A3:A4 and A4:A5 - m_pDoc->InsertMatrixFormula(3, 6, 3, 8, aMark, "=SUBTOTAL(4;OFFSET(A1;ROW(1:3);0;2))"); - aPos.Set(3,6,0); + // Matrix in E7:E9, individual MAX of A2:A3, A3:A4 and A4:A5 + m_pDoc->InsertMatrixFormula(4, 6, 4, 8, aMark, "=SUBTOTAL(4;OFFSET(A1;ROW(1:3);0;2))"); + aPos.Set(4,6,0); CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL MAX for A2:A3 failed", 4.0, m_pDoc->GetValue(aPos)); aPos.IncRow(); CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL MAX for A3:A4 failed", 8.0, m_pDoc->GetValue(aPos)); commit 44b56bab060b3268617ed930fb783a20e617d137 Author: Eike Rathke <[email protected]> Date: Mon May 22 16:20:59 2017 +0200 Get vector count right, tdf#58874 Change-Id: I1d4224c6a87af4ed9f879e144958f95418fabbf7 diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx index 35004f2846bc..6e614098e4a7 100644 --- a/sc/source/core/tool/interpr6.cxx +++ b/sc/source/core/tool/interpr6.cxx @@ -997,14 +997,13 @@ void ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) // Include value of last non-references-array type and calculate final result. for (SCSIZE i=0; i < nMatRows; ++i) { - if (xResCount) - nCount += xResCount->GetDouble(0,i); + sal_uLong nVecCount = (xResCount ? nCount + xResCount->GetDouble(0,i) : nCount); double fVecRes = xResMat->GetDouble(0,i); if (eFunc == ifPRODUCT) fVecRes *= fRes; else fVecRes += fRes; - fVecRes = lcl_IterResult( eFunc, fVecRes, fMem, nCount); + fVecRes = lcl_IterResult( eFunc, fVecRes, fMem, nVecCount); xResMat->PutDouble( fVecRes, 0,i); } PushMatrix( xResMat); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
