Kaydet (Commit) 94a569c2 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Don't hard-code the start row position of string array to 0...

Change-Id: I06724e2e8754ac20217f5375a445c85f9a5b31e6
üst 6d2f4219
......@@ -237,13 +237,12 @@ void ScOpenclTest::testCompilerString()
// Check the results of formula cells in the shared formula range.
for (SCROW i = 1; i < 5; ++i)
{
#if 0
double fLibre = pDoc->GetValue(ScAddress(2, i, 0));
double fExcel = pDocRes->GetValue(ScAddress(2, i, 0));
CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
#endif
double fLibre = pDoc->GetValue(ScAddress(3, i, 0));
double fExcel = pDocRes->GetValue(ScAddress(3, i, 0));
fLibre = pDoc->GetValue(ScAddress(3, i, 0));
fExcel = pDocRes->GetValue(ScAddress(3, i, 0));
CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
}
xDocSh->DoClose();
......
......@@ -61,7 +61,13 @@ bool equals( const formula::VectorRefArray& rArray, size_t nPos, const OUString&
if (!rArray.mpStringArray)
return false;
return OUString(rArray.mpStringArray[nPos]).equalsIgnoreAsciiCase(rVal);
bool bEquals = OUString(rArray.mpStringArray[nPos]).equalsIgnoreAsciiCase(rVal);
if (!bEquals)
{
cerr << "Expected: " << rVal.toAsciiUpperCase() << " (upcased)" << endl;
cerr << "Actual: " << OUString(rArray.mpStringArray[nPos]) << " (upcased)" << endl;
}
return bEquals;
}
}
......@@ -235,6 +241,34 @@ void Test::testFetchVectorRefArray()
CPPUNIT_ASSERT_MESSAGE("Array should have a numeric array.", aArray.mpNumericArray);
CPPUNIT_ASSERT_MESSAGE("Array should NOT have a string array.", !aArray.mpStringArray);
// Column G consists only of strings.
m_pDoc->SetString(ScAddress(6,0,0), "Title");
m_pDoc->SetString(ScAddress(6,1,0), "foo");
m_pDoc->SetString(ScAddress(6,2,0), "bar");
m_pDoc->SetString(ScAddress(6,3,0), "foo");
m_pDoc->SetString(ScAddress(6,4,0), "baz");
m_pDoc->SetString(ScAddress(6,5,0), "quack");
m_pDoc->SetString(ScAddress(6,6,0), "beep");
m_pDoc->SetString(ScAddress(6,7,0), "kerker");
aArray = m_pDoc->FetchVectorRefArray(ScAddress(6,1,0), 4); // G2:G5
CPPUNIT_ASSERT_MESSAGE("Failed to fetch vector ref array.", aArray.isValid());
CPPUNIT_ASSERT_MESSAGE("Array should NOT have a numeric array.", !aArray.mpNumericArray);
CPPUNIT_ASSERT_MESSAGE("Array should have a string array.", aArray.mpStringArray);
CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 0, "foo"));
CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 1, "bar"));
CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 2, "foo"));
CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 3, "baz"));
aArray = m_pDoc->FetchVectorRefArray(ScAddress(6,2,0), 4); // G3:G6
CPPUNIT_ASSERT_MESSAGE("Failed to fetch vector ref array.", aArray.isValid());
CPPUNIT_ASSERT_MESSAGE("Array should NOT have a numeric array.", !aArray.mpNumericArray);
CPPUNIT_ASSERT_MESSAGE("Array should have a string array.", aArray.mpStringArray);
CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 0, "bar"));
CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 1, "foo"));
CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 2, "baz"));
CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 3, "quack"));
m_pDoc->DeleteTab(0);
}
......
......@@ -2722,7 +2722,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
{
// Requested range falls within the first block.
copyFirstStringBlock(*pDocument, rArray, nRow2+1, itBlk);
return formula::VectorRefArray(&rArray[0]);
return formula::VectorRefArray(&rArray[nRow1]);
}
copyFirstStringBlock(*pDocument, rArray, itBlk->size, itBlk);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment