sc/inc/tokenarray.hxx | 1 + sc/source/core/tool/token.cxx | 34 ++++++++++++++++++++++++++++++++++ sc/source/filter/excel/excform.cxx | 10 ++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-)
New commits: commit 76610b00b67cf9c4600caed0f4d75d04e825f9d2 Author: László Németh <laszlo.nem...@collabora.com> Date: Fri Feb 13 00:06:32 2015 +0100 tdf#89281 fix performance regression of XLS import The fix for Bug 76611 caused ~20% performance loss in XLS import. With optional cloning of ScTokenArray of the shared XLS formulas depending on the need of address wrapping, it is possible to gain back near the original performance. Note: The original patch for Bug 76611 has already got an unit test, too (see wrapped-refs.xls), and that unit test works with this improved patch, too. Cherry picked from master: ba686b9bd2596811141e4028947334f10799c356 cleanup b18b5b7edf3d14ef5f0efe53e367f88a423088c4 first commit Change-Id: Ibfb59d1543ef9c4b8a075d5c4e37f77ab451aaa0 Reviewed-on: https://gerrit.libreoffice.org/14393 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Eike Rathke <er...@redhat.com> diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx index ad61ef3..412ecfe 100644 --- a/sc/inc/tokenarray.hxx +++ b/sc/inc/tokenarray.hxx @@ -239,6 +239,7 @@ public: OUString CreateString( sc::TokenStringContext& rCxt, const ScAddress& rPos ) const; void WrapReference( const ScAddress& rPos, SCCOL nMaxCol, SCROW nMaxRow ); + bool NeedsWrapReference( const ScAddress& rPos, SCCOL nMaxCol, SCROW nMaxRow ) const; #if DEBUG_FORMULA_COMPILER void Dump() const; diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index ee55b07..43e1963 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -4035,6 +4035,40 @@ void ScTokenArray::WrapReference( const ScAddress& rPos, SCCOL nMaxCol, SCROW nM } } +bool ScTokenArray::NeedsWrapReference( const ScAddress& rPos, SCCOL nMaxCol, SCROW nMaxRow ) const +{ + FormulaToken** p = pCode; + FormulaToken** pEnd = p + static_cast<size_t>(nLen); + for (; p != pEnd; ++p) + { + switch ((*p)->GetType()) + { + case svSingleRef: + { + formula::FormulaToken* pToken = *p; + ScSingleRefData& rRef = *pToken->GetSingleRef(); + ScAddress aAbs = rRef.toAbs(rPos); + if (aAbs.Col() > nMaxCol || aAbs.Row() > nMaxRow) + return true; + } + break; + case svDoubleRef: + { + formula::FormulaToken* pToken = *p; + ScComplexRefData& rRef = *pToken->GetDoubleRef(); + ScRange aAbs = rRef.toAbs(rPos); + if (aAbs.aStart.Col() > nMaxCol || aAbs.aStart.Row() > nMaxRow || + aAbs.aEnd.Col() > nMaxCol || aAbs.aEnd.Row() > nMaxRow) + return true; + } + break; + default: + ; + } + } + return false; +} + #if DEBUG_FORMULA_COMPILER void ScTokenArray::Dump() const diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx index 630997a..1df8fd9 100644 --- a/sc/source/filter/excel/excform.cxx +++ b/sc/source/filter/excel/excform.cxx @@ -124,8 +124,14 @@ void ImportExcel::Formula( const ScTokenArray* pSharedCode = pFormConv->GetSharedFormula(aRefPos); if (pSharedCode) { - ScFormulaCell* pCell = new ScFormulaCell(pD, aScPos, pSharedCode->Clone()); - pCell->GetCode()->WrapReference(aScPos, EXC_MAXCOL8, EXC_MAXROW8); + ScFormulaCell* pCell; + if (pSharedCode->NeedsWrapReference(aScPos, EXC_MAXCOL8, EXC_MAXROW8)) + { + pCell = new ScFormulaCell(pD, aScPos, pSharedCode->Clone()); + pCell->GetCode()->WrapReference(aScPos, EXC_MAXCOL8, EXC_MAXROW8); + } + else + pCell = new ScFormulaCell(pD, aScPos, *pSharedCode); rDoc.getDoc().EnsureTable(aScPos.Tab()); rDoc.setFormulaCell(aScPos, pCell); pCell->SetNeedNumberFormat(false);
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits