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

Restore the old behavior, even when the data comes from a cache.

Change-Id: I722a53ee0e8a8f757c1d02fa5f604e6ccedf3b1a
üst d502ddff
...@@ -229,6 +229,12 @@ void Test::testFetchVectorRefArray() ...@@ -229,6 +229,12 @@ void Test::testFetchVectorRefArray()
CPPUNIT_ASSERT_MESSAGE("This should be empty.", isEmpty(aArray, 8)); CPPUNIT_ASSERT_MESSAGE("This should be empty.", isEmpty(aArray, 8));
CPPUNIT_ASSERT_MESSAGE("This should be empty.", isEmpty(aArray, 9)); CPPUNIT_ASSERT_MESSAGE("This should be empty.", isEmpty(aArray, 9));
// Get the array for F3:F4. This array should only consist of numeric array.
aArray = m_pDoc->FetchVectorRefArray(ScAddress(5,2,0), 3);
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);
m_pDoc->DeleteTab(0); m_pDoc->DeleteTab(0);
} }
......
...@@ -2614,6 +2614,36 @@ copyFirstFormulaBlock( ...@@ -2614,6 +2614,36 @@ copyFirstFormulaBlock(
return rCxt.setCachedColArray(nTab, nCol, pNumArray, pStrArray); return rCxt.setCachedColArray(nTab, nCol, pNumArray, pStrArray);
} }
struct FiniteValueFinder : std::unary_function<double, bool>
{
bool operator() (double f) const { return !rtl::math::isNan(f); }
};
struct NonNullStringFinder : std::unary_function<const rtl_uString*, bool>
{
bool operator() (const rtl_uString* p) const { return p != NULL; }
};
bool hasNonEmpty( const sc::FormulaGroupContext::NumArrayType& rArray, SCROW nRow1, SCROW nRow2 )
{
// The caller has to make sure the array is at least nRow2+1 long.
sc::FormulaGroupContext::NumArrayType::const_iterator it = rArray.begin();
std::advance(it, nRow1);
sc::FormulaGroupContext::NumArrayType::const_iterator itEnd = it;
std::advance(itEnd, nRow2-nRow1+1);
return std::find_if(it, itEnd, FiniteValueFinder()) != itEnd;
}
bool hasNonEmpty( const sc::FormulaGroupContext::StrArrayType& rArray, SCROW nRow1, SCROW nRow2 )
{
// The caller has to make sure the array is at least nRow2+1 long.
sc::FormulaGroupContext::StrArrayType::const_iterator it = rArray.begin();
std::advance(it, nRow1);
sc::FormulaGroupContext::StrArrayType::const_iterator itEnd = it;
std::advance(itEnd, nRow2-nRow1+1);
return std::find_if(it, itEnd, NonNullStringFinder()) != itEnd;
}
} }
formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2 ) formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2 )
...@@ -2627,11 +2657,11 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2 ...@@ -2627,11 +2657,11 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
if (pColArray) if (pColArray)
{ {
const double* pNum = NULL; const double* pNum = NULL;
if (pColArray->mpNumArray) if (pColArray->mpNumArray && hasNonEmpty(*pColArray->mpNumArray, nRow1, nRow2))
pNum = &(*pColArray->mpNumArray)[nRow1]; pNum = &(*pColArray->mpNumArray)[nRow1];
rtl_uString** pStr = NULL; rtl_uString** pStr = NULL;
if (pColArray->mpStrArray) if (pColArray->mpStrArray && hasNonEmpty(*pColArray->mpStrArray, nRow1, nRow2))
pStr = &(*pColArray->mpStrArray)[nRow1]; pStr = &(*pColArray->mpStrArray)[nRow1];
return formula::VectorRefArray(pNum, pStr); return formula::VectorRefArray(pNum, pStr);
......
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