diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-09-09 15:32:25 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-09-10 11:47:45 -0400 |
commit | 6dd0d051e986b868bf2225c16137e72d6e2dd3b6 (patch) | |
tree | d46a79ac013cc1c3418f6411f92f98c01f211b52 | |
parent | d1c90e929ef765b0d88a8d1e0bda434a1e340bee (diff) |
Do the same for range vector tokens.
Change-Id: Id80f76dbe575fc6b279dafbfc524a9230755ddc8
-rw-r--r-- | sc/source/core/data/column2.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/tool/formulagroup.cxx | 44 |
2 files changed, 46 insertions, 4 deletions
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 5f7f8437bc13..34ecbb2f79f7 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -2268,8 +2268,10 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( sc::FormulaGroupContext& { if (nLenRequested <= nLen) { - // Fill the whole length with zero. - rCxt.maNumArrays.push_back(new sc::FormulaGroupContext::NumArrayType(nLenRequested, 0.0)); + // Fill the whole length with NaN's. + double fNan; + rtl::math::setNan(&fNan); + rCxt.maNumArrays.push_back(new sc::FormulaGroupContext::NumArrayType(nLenRequested, fNan)); return formula::VectorRefArray(&rCxt.maNumArrays.back()[0]); } diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx index ca888dcfc298..f6a1dff37e5d 100644 --- a/sc/source/core/tool/formulagroup.cxx +++ b/sc/source/core/tool/formulagroup.cxx @@ -29,6 +29,46 @@ namespace sc { +namespace { + +/** + * Input double array consists of segments of NaN's and normal values. + * Insert only the normal values into the matrix while skipping the NaN's. + */ +void fillMatrix( ScMatrix& rMat, size_t nCol, const double* pNums, size_t nLen ) +{ + const double* p = pNums; + const double* pEnd = p + nLen; + const double* pHead = NULL; + for (; p != pEnd; ++p) + { + if (!rtl::math::isNan(*p)) + { + if (!pHead) + // Store the first non-NaN position. + pHead = p; + + continue; + } + + if (pHead) + { + // Flush this non-NaN segment to the matrix. + rMat.PutDouble(pHead, p - pHead, nCol, pHead - pNums); + pHead = NULL; + } + } + + if (pHead) + { + // Flush last non-NaN segment to the matrix. + rMat.PutDouble(pHead, p - pHead, nCol, pHead - pNums); + pHead = NULL; + } +} + +} + ScMatrixRef FormulaGroupInterpreterSoftware::inverseMatrix(const ScMatrix& /*rMat*/) { return ScMatrixRef(); @@ -97,7 +137,7 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres if (!p2->IsEndFixed()) nRowEnd += i; size_t nRowSize = nRowEnd - nRowStart + 1; - ScMatrixRef pMat(new ScMatrix(nColSize, nRowSize, 0.0)); + ScMatrixRef pMat(new ScMatrix(nColSize, nRowSize)); for (size_t nCol = 0; nCol < nColSize; ++nCol) { const formula::VectorRefArray& rArray = rArrays[nCol]; @@ -105,7 +145,7 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres { const double* pNums = rArray.mpNumericArray; pNums += nRowStart; - pMat->PutDouble(pNums, nRowSize, nCol, 0); + fillMatrix(*pMat, nCol, pNums, nRowSize); } else { |