sc/source/core/data/column2.cxx | 6 +++- sc/source/core/tool/formulagroup.cxx | 44 +++++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-)
New commits: commit 21567d48e49bb91f4dd2610f21630a68108218fc Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Mon Sep 9 15:32:25 2013 -0400 Do the same for range vector tokens. Change-Id: Id80f76dbe575fc6b279dafbfc524a9230755ddc8 diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 5f7f843..34ecbb2 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 ca888dc..f6a1dff 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 { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits