summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-05-14 16:23:11 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-05-14 16:25:38 -0400
commitb6b0b95bae845a2a59831f4e3ae63de3e54a2984 (patch)
tree87f6b12bc3d01390701454ab6aa77d25f0d00597 /sc
parent0c53ccd11f6a4318c29fd76cbc3de4e80dff769c (diff)
Bail out of group calculation in case the array fetching fails.
Change-Id: Ibb7575eeb025fc025d05b147629113796185c5d3
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/column2.cxx20
-rw-r--r--sc/source/core/data/grouptokenconverter.cxx6
2 files changed, 16 insertions, 10 deletions
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 56fe643b0732..d6019bed5f30 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2426,7 +2426,7 @@ bool hasNonEmpty( const sc::FormulaGroupContext::StrArrayType& rArray, SCROW nRo
formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2 )
{
if (nRow1 > nRow2)
- return formula::VectorRefArray();
+ return formula::VectorRefArray(formula::VectorRefArray::Invalid);
// See if the requested range is already cached.
sc::FormulaGroupContext& rCxt = pDocument->GetFormulaGroupContext();
@@ -2470,13 +2470,13 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
pColArray = rCxt.setCachedColArray(nTab, nCol, &rArray, NULL);
if (!pColArray)
// Failed to insert a new cached column array.
- return formula::VectorRefArray();
+ return formula::VectorRefArray(formula::VectorRefArray::Invalid);
// Fill the remaining array with values from the following blocks.
size_t nPos = itBlk->size;
++itBlk;
if (!appendToBlock(pDocument, rCxt, *pColArray, nPos, nRow2+1, itBlk, maCells.end()))
- return formula::VectorRefArray();
+ return formula::VectorRefArray(formula::VectorRefArray::Invalid);
if (pColArray->mpStrArray)
return formula::VectorRefArray(&(*pColArray->mpNumArray)[nRow1], &(*pColArray->mpStrArray)[nRow1]);
@@ -2507,7 +2507,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
size_t nPos = itBlk->size;
++itBlk;
if (!appendToBlock(pDocument, rCxt, *pColArray, nPos, nRow2+1, itBlk, maCells.end()))
- return formula::VectorRefArray();
+ return formula::VectorRefArray(formula::VectorRefArray::Invalid);
if (pColArray->mpNumArray)
return formula::VectorRefArray(&(*pColArray->mpNumArray)[nRow1], &(*pColArray->mpStrArray)[nRow1]);
@@ -2524,7 +2524,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
pColArray = copyFirstFormulaBlock(rCxt, itBlk, nRow2+1, nTab, nCol);
if (!pColArray)
// Failed to insert a new cached column array.
- return formula::VectorRefArray();
+ return formula::VectorRefArray(formula::VectorRefArray::Invalid);
const double* pNum = NULL;
rtl_uString** pStr = NULL;
@@ -2539,12 +2539,12 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
pColArray = copyFirstFormulaBlock(rCxt, itBlk, nRow2+1, nTab, nCol);
if (!pColArray)
// Failed to insert a new cached column array.
- return formula::VectorRefArray();
+ return formula::VectorRefArray(formula::VectorRefArray::Invalid);
size_t nPos = itBlk->size;
++itBlk;
if (!appendToBlock(pDocument, rCxt, *pColArray, nPos, nRow2+1, itBlk, maCells.end()))
- return formula::VectorRefArray();
+ return formula::VectorRefArray(formula::VectorRefArray::Invalid);
const double* pNum = NULL;
rtl_uString** pStr = NULL;
@@ -2564,7 +2564,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
pColArray = rCxt.setCachedColArray(nTab, nCol, &rArray, NULL);
if (!pColArray)
// Failed to insert a new cached column array.
- return formula::VectorRefArray();
+ return formula::VectorRefArray(formula::VectorRefArray::Invalid);
if (static_cast<size_t>(nRow2) < itBlk->size)
return formula::VectorRefArray(&(*pColArray->mpNumArray)[nRow1]);
@@ -2573,7 +2573,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
size_t nPos = itBlk->size;
++itBlk;
if (!appendToBlock(pDocument, rCxt, *pColArray, nPos, nRow2+1, itBlk, maCells.end()))
- return formula::VectorRefArray();
+ return formula::VectorRefArray(formula::VectorRefArray::Invalid);
if (pColArray->mpStrArray && hasNonEmpty(*pColArray->mpStrArray, nRow1, nRow2))
return formula::VectorRefArray(&(*pColArray->mpNumArray)[nRow1], &(*pColArray->mpStrArray)[nRow1]);
@@ -2585,7 +2585,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
;
}
- return formula::VectorRefArray();
+ return formula::VectorRefArray(formula::VectorRefArray::Invalid);
}
void ScColumn::SetFormulaResults( SCROW nRow, const double* pResults, size_t nLen )
diff --git a/sc/source/core/data/grouptokenconverter.cxx b/sc/source/core/data/grouptokenconverter.cxx
index a43efb05aa31..537bd2154efa 100644
--- a/sc/source/core/data/grouptokenconverter.cxx
+++ b/sc/source/core/data/grouptokenconverter.cxx
@@ -119,6 +119,9 @@ bool ScGroupTokenConverter::convert(ScTokenArray& rCode)
if (nTrimLen)
aArray = mrDoc.FetchVectorRefArray(aRefPos, nTrimLen);
+ if (!aArray.isValid())
+ return false;
+
formula::SingleVectorRefToken aTok(aArray, nLen, nTrimLen);
mrGroupTokens.AddToken(aTok);
}
@@ -188,6 +191,9 @@ bool ScGroupTokenConverter::convert(ScTokenArray& rCode)
if (nArrayLength)
aArray = mrDoc.FetchVectorRefArray(aRefPos, nArrayLength);
+ if (!aArray.isValid())
+ return false;
+
aArrays.push_back(aArray);
}