summaryrefslogtreecommitdiff
path: root/sc/source/core/data
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-08-12 21:51:33 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-08-12 21:52:28 -0400
commit7514df659bc12509880f7b74cd9a7820c96526fb (patch)
treea63eb3636758235048af0b78c0b32b57073e51a2 /sc/source/core/data
parent84c4c6a901a90dda1514071455db682a000b1934 (diff)
Compile token array only once per formula group.
Change-Id: I70694ee8834b1b2f2ebdfaa90582ccfb19db0210
Diffstat (limited to 'sc/source/core/data')
-rw-r--r--sc/source/core/data/formulacell.cxx41
1 files changed, 24 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);
}