diff --git a/sc/qa/unit/data/ods/tdf149940.ods b/sc/qa/unit/data/ods/tdf149940.ods new file mode 100644 index 000000000000..5e117ac469f7 Binary files /dev/null and b/sc/qa/unit/data/ods/tdf149940.ods differ diff --git a/sc/qa/unit/opencl-test-2.cxx b/sc/qa/unit/opencl-test-2.cxx index 4c7fbdbcb96d..910e09b87ec3 100644 --- a/sc/qa/unit/opencl-test-2.cxx +++ b/sc/qa/unit/opencl-test-2.cxx @@ -1844,6 +1844,33 @@ CPPUNIT_TEST_FIXTURE(ScOpenCLTest2, testStatisticalFormulaStDevPA1) } } +CPPUNIT_TEST_FIXTURE(ScOpenCLTest2, testTdf149940_VLookup) +{ + initTestEnv(u"ods/tdf149940.ods"); + ScDocument* pDoc = getScDoc2(); + ScDocument* pDocRes = getScDoc(); + pDoc->CalcAll(); + + for (SCROW i = 4; i <= 12; ++i) + { + double fLibre = pDoc->GetValue(ScAddress(1,i,1)); + double fExcel = pDocRes->GetValue(ScAddress(1,i,1)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.00001)); + } + for (SCROW i = 4; i <= 12; ++i) + { + double fLibre = pDoc->GetValue(ScAddress(2,i,1)); + double fExcel = pDocRes->GetValue(ScAddress(2,i,1)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.00001)); + } + for (SCROW i = 4; i <= 12; ++i) + { + double fLibre = pDoc->GetValue(ScAddress(3,i,1)); + double fExcel = pDocRes->GetValue(ScAddress(3,i,1)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.00001)); + } +} + ScOpenCLTest2::ScOpenCLTest2() : ScModelTestBase( "sc/qa/unit/data" ) { diff --git a/sc/source/core/opencl/op_spreadsheet.cxx b/sc/source/core/opencl/op_spreadsheet.cxx index db99a1e7cf74..815f95b1f39f 100644 --- a/sc/source/core/opencl/op_spreadsheet.cxx +++ b/sc/source/core/opencl/op_spreadsheet.cxx @@ -171,7 +171,9 @@ void OpVLookup::GenSlidingWindowFunction(outputstream &ss, } ss << " }\n"; - ss << " if(rowNum!=-1)\n"; + ss << " if(rowNum!=-1 && tmp"; + ss << 3 + (secondParaWidth - 1); + ss << " == 0)\n"; ss << " {\n"; for (int j = 0; j < secondParaWidth; j++) {