From f243d07019ca205ef536b0d7b0e1fe4b84469f75 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 16 Aug 2013 16:29:14 +0200 Subject: sc/externalrefmgr: reduce individual cell queries Change-Id: Ic0dda47f02cd392234876a8945e240bbc915fa6a Reviewed-on: https://gerrit.libreoffice.org/5453 Reviewed-by: Petr Mladek Tested-by: Petr Mladek --- sc/source/ui/docshell/externalrefmgr.cxx | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'sc') diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index 8ab55db2a17d..f27f25809cf8 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -764,21 +764,30 @@ void ScExternalRefCache::setCellRangeData(sal_uInt16 nFileId, const ScRange& rRa if (!pTabData.get()) pTabData.reset(new Table); + const ScMatrixRef& pMat = itrData->mpRangeData; for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow) { + const SCSIZE nR = nRow - nRow1; for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol) { - SCSIZE nC = nCol - nCol1, nR = nRow - nRow1; + const SCSIZE nC = nCol - nCol1; + + ScMatrixValue value = pMat->Get(nC, nR); + TokenRef pToken; - const ScMatrixRef& pMat = itrData->mpRangeData; - if (pMat->IsEmpty(nC, nR)) - // Don't cache empty cells. - continue; - if (pMat->IsValue(nC, nR)) - pToken.reset(new formula::FormulaDoubleToken(pMat->GetDouble(nC, nR))); - else if (pMat->IsString(nC, nR)) - pToken.reset(new formula::FormulaStringToken(pMat->GetString(nC, nR))); + switch (value.nType) { + case SC_MATVAL_VALUE: + case SC_MATVAL_BOOLEAN: + pToken.reset(new formula::FormulaDoubleToken(value.fVal)); + break; + case SC_MATVAL_STRING: + pToken.reset(new formula::FormulaStringToken(value.aStr)); + break; + default: + // Don't cache empty cells. + break; + } if (pToken) // Don't mark this cell 'cached' here, for better performance. -- cgit