sc/qa/unit/ucalc_formula.cxx | 19 +++++++++++++++++++ sc/source/core/data/column2.cxx | 10 +++++----- 2 files changed, 24 insertions(+), 5 deletions(-)
New commits: commit 507d348454f6fd2d6475d2878bbc56efd9d73ca1 Author: Kohei Yoshida <[email protected]> Date: Tue Nov 26 20:34:45 2013 -0500 Fix additional bugs in the vector array fetching code. And a test case to catch it. Change-Id: I233269822b383afa9783bdc7318eddee31d1eaa3 diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index ff89dbe..a51308c 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -451,6 +451,25 @@ void Test::testFetchVectorRefArray() CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 2, "baz")); CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 3, "quack")); + // Column H starts with formula cells. + for (SCROW i = 0; i < 10; ++i) + m_pDoc->SetString(ScAddress(7,i,0), "=ROW()"); + + m_pDoc->CalcAll(); + aArray = m_pDoc->FetchVectorRefArray(ScAddress(7,3,0), 3); // H4:H6 + CPPUNIT_ASSERT_MESSAGE("Failed to fetch vector ref array.", aArray.isValid()); + CPPUNIT_ASSERT_MESSAGE("Array should have a numeric array.", aArray.mpNumericArray); + CPPUNIT_ASSERT_MESSAGE("Array should NOT have a string array.", !aArray.mpStringArray); + CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 0, 4.0)); + CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 1, 5.0)); + CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 2, 6.0)); + + aArray = m_pDoc->FetchVectorRefArray(ScAddress(7,4,0), 10); // H5:H15 + CPPUNIT_ASSERT_MESSAGE("Failed to fetch vector ref array.", aArray.isValid()); + CPPUNIT_ASSERT_MESSAGE("Array should have a numeric array.", aArray.mpNumericArray); + CPPUNIT_ASSERT_MESSAGE("Array should NOT have a string array.", !aArray.mpStringArray); + CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 0, 5.0)); + m_pDoc->DeleteTab(0); } diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 65d6c88..24cd615 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -2752,9 +2752,9 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2 const double* pNum = NULL; rtl_uString** pStr = NULL; if (pColArray->mpNumArray) - pNum = &(*pColArray->mpNumArray)[0]; + pNum = &(*pColArray->mpNumArray)[nRow1]; if (pColArray->mpStrArray) - pStr = &(*pColArray->mpStrArray)[0]; + pStr = &(*pColArray->mpStrArray)[nRow1]; return formula::VectorRefArray(pNum, pStr); } @@ -2772,9 +2772,9 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2 const double* pNum = NULL; rtl_uString** pStr = NULL; if (pColArray->mpNumArray) - pNum = &(*pColArray->mpNumArray)[0]; + pNum = &(*pColArray->mpNumArray)[nRow1]; if (pColArray->mpStrArray) - pStr = &(*pColArray->mpStrArray)[0]; + pStr = &(*pColArray->mpStrArray)[nRow1]; return formula::VectorRefArray(pNum, pStr); } @@ -2790,7 +2790,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2 return formula::VectorRefArray(); if (static_cast<size_t>(nRow2) < itBlk->size) - return formula::VectorRefArray(&(*pColArray->mpNumArray)[0]); + return formula::VectorRefArray(&(*pColArray->mpNumArray)[nRow1]); // Fill the remaining array with values from the following blocks. size_t nPos = itBlk->size; _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
