sc/qa/unit/ucalc.hxx | 2 ++ sc/qa/unit/ucalc_formula.cxx | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)
New commits: commit a3ed62e2707a27f6f3b51c41771301b5cf9a48f5 Author: Eike Rathke <[email protected]> AuthorDate: Tue Feb 26 21:40:05 2019 +0100 Commit: Eike Rathke <[email protected]> CommitDate: Wed Feb 27 11:08:36 2019 +0100 Unit test for array formula and OFFSET() non-ReferenceOrRefArray, tdf#123477 Change-Id: I1ffe56ada6caed305fd2dbd5fb838e6a7ab3c2e2 Reviewed-on: https://gerrit.libreoffice.org/68408 Reviewed-by: Eike Rathke <[email protected]> Tested-by: Jenkins diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 35378b152711..fed2f4e718de 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -225,6 +225,7 @@ public: void testFuncSUMIFS(); void testFuncRefListArraySUBTOTAL(); void testFuncJumpMatrixArrayIF(); + void testFuncJumpMatrixArrayOFFSET(); void testMatConcat(); void testMatConcatReplication(); void testRefR1C1WholeCol(); @@ -658,6 +659,7 @@ public: CPPUNIT_TEST(testFuncSUMIFS); CPPUNIT_TEST(testFuncRefListArraySUBTOTAL); CPPUNIT_TEST(testFuncJumpMatrixArrayIF); + CPPUNIT_TEST(testFuncJumpMatrixArrayOFFSET); CPPUNIT_TEST(testMatConcat); CPPUNIT_TEST(testMatConcatReplication); CPPUNIT_TEST(testExternalRef); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 5b66732ec2d0..1248692f5a50 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -8774,6 +8774,33 @@ void Test::testFuncJumpMatrixArrayIF() m_pDoc->DeleteTab(0); } +// tdf#123477 OFFSET() returns the matrix result instead of the reference list +// array if result is not used as ReferenceOrRefArray. +void Test::testFuncJumpMatrixArrayOFFSET() +{ + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on. + m_pDoc->InsertTab(0, "Test"); + + std::vector<std::vector<const char*>> aData = { + { "abc" }, + { "bcd" }, + { "cde" } + }; + insertRangeData(m_pDoc, ScAddress(0,0,0), aData); // A1:A3 + + ScMarkData aMark; + aMark.SelectOneTable(0); + + // Matrix in C5:C7, COLUMN()-3 here offsets by 0 but the entire expression + // is in array/matrix context. + m_pDoc->InsertMatrixFormula( 2,4, 2,6, aMark, "=FIND(\"c\";OFFSET(A1:A3;0;COLUMN()-3))"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula C5 failed", 3.0, m_pDoc->GetValue(ScAddress(2,4,0))); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula C6 failed", 2.0, m_pDoc->GetValue(ScAddress(2,5,0))); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula C7 failed", 1.0, m_pDoc->GetValue(ScAddress(2,6,0))); + + m_pDoc->DeleteTab(0); +} + // Test iterations with circular chain of references. void Test::testIterations() { _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
