diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-12 21:51:33 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-12 21:52:28 -0400 |
commit | 7514df659bc12509880f7b74cd9a7820c96526fb (patch) | |
tree | a63eb3636758235048af0b78c0b32b57073e51a2 /sc/source | |
parent | 84c4c6a901a90dda1514071455db682a000b1934 (diff) |
Compile token array only once per formula group.
Change-Id: I70694ee8834b1b2f2ebdfaa90582ccfb19db0210
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 41 | ||||
-rw-r--r-- | sc/source/filter/excel/excform.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/oox/formulabuffer.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/orcus/interface.cxx | 2 |
4 files changed, 33 insertions, 17 deletions
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 1e120ee53bcd..f40e5a53bde5 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -387,7 +387,9 @@ ScFormulaCellGroup::ScFormulaCellGroup() : mpCode(NULL), mnStart(0), mnLength(0), + mnFormatType(NUMBERFORMAT_NUMBER), mbInvariant(false), + mbSubTotal(false), meCalcState(sc::GroupCalcEnabled) { } @@ -405,6 +407,26 @@ void ScFormulaCellGroup::setCode( const ScTokenArray& rCode ) mpCode->GenHash(); } +void ScFormulaCellGroup::compileCode( + ScDocument& rDoc, const ScAddress& rPos, FormulaGrammar::Grammar eGram ) +{ + if (!mpCode) + return; + + if (mpCode->GetLen() && !mpCode->GetCodeError() && !mpCode->GetCodeLen()) + { + ScCompiler aComp(&rDoc, rPos, *mpCode); + aComp.SetGrammar(eGram); + mbSubTotal = aComp.CompileTokenArray(); + mnFormatType = aComp.GetNumFormatType(); + } + else + { + mpCode->Reset(); + mbSubTotal = mpCode->GetNextOpCodeRPN(ocSubTotal) != NULL; + } +} + // ============================================================================ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, @@ -500,12 +522,12 @@ ScFormulaCell::ScFormulaCell( pNextTrack(0), nSeenInIteration(0), cMatrixFlag ( cInd ), - nFormatType ( NUMBERFORMAT_NUMBER ), + nFormatType(xGroup->mnFormatType), bDirty(false), bChanged( false ), bRunning( false ), bCompile( false ), - bSubTotal( false ), + bSubTotal(xGroup->mbSubTotal), bIsIterCell( false ), bInChangeTrack( false ), bTableOpDirty( false ), @@ -513,21 +535,6 @@ ScFormulaCell::ScFormulaCell( mbNeedsNumberFormat( false ), aPos( rPos ) { - // UPN-Array generation - if( pCode->GetLen() && !pCode->GetCodeError() && !pCode->GetCodeLen() ) - { - ScCompiler aComp( pDocument, aPos, *pCode); - aComp.SetGrammar(eTempGrammar); - bSubTotal = aComp.CompileTokenArray(); - nFormatType = aComp.GetNumFormatType(); - } - else - { - pCode->Reset(); - if ( pCode->GetNextOpCodeRPN( ocSubTotal ) ) - bSubTotal = true; - } - if (bSubTotal) pDocument->AddSubTotalCell(this); } diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx index e236dad91077..e9f5cf626327 100644 --- a/sc/source/filter/excel/excform.cxx +++ b/sc/source/filter/excel/excform.cxx @@ -118,6 +118,10 @@ void ImportExcel::Formula( if (!xGroup) return; + if (xGroup->mnStart == aScPos.Row()) + // Generate code for the top cell only. + xGroup->compileCode(*pD, aScPos, formula::FormulaGrammar::GRAM_DEFAULT); + ScFormulaCell* pCell = new ScFormulaCell(pD, aScPos, xGroup); pD->EnsureTable(aScPos.Tab()); bool bInserted = pD->SetGroupFormulaCell(aScPos, pCell); diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx index e4277c0b714d..dce36d7feaae 100644 --- a/sc/source/filter/oox/formulabuffer.cxx +++ b/sc/source/filter/oox/formulabuffer.cxx @@ -200,6 +200,9 @@ void FormulaBuffer::applySharedFormulas( sal_Int32 nTab ) ScAddress aPos; ScUnoConversion::FillScAddress(aPos, rAddr); + if (xGroup->mnStart == aPos.Row()) + // Generate code for the top cell only. + xGroup->compileCode(rDoc, aPos, formula::FormulaGrammar::GRAM_DEFAULT); ScFormulaCell* pCell = new ScFormulaCell(&rDoc, aPos, xGroup); bool bInserted = rDoc.SetGroupFormulaCell(aPos, pCell); diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index 495715f9644e..6c9512a2f360 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -387,6 +387,8 @@ void ScOrcusSheet::set_shared_formula( if (!xGroup) return; + // Generate code for the top cell only. + xGroup->compileCode(mrDoc.getDoc(), aPos, formula::FormulaGrammar::GRAM_DEFAULT); ScFormulaCell* pCell = new ScFormulaCell(&mrDoc.getDoc(), aPos, xGroup); mrDoc.setFormulaCell(aPos, pCell); cellInserted(); |