diff options
Diffstat (limited to 'formula')
-rw-r--r-- | formula/inc/formula/FormulaCompiler.hxx | 2 | ||||
-rw-r--r-- | formula/source/core/api/FormulaCompiler.cxx | 86 |
2 files changed, 51 insertions, 37 deletions
diff --git a/formula/inc/formula/FormulaCompiler.hxx b/formula/inc/formula/FormulaCompiler.hxx index 1ccdf2d487..5b84beade4 100644 --- a/formula/inc/formula/FormulaCompiler.hxx +++ b/formula/inc/formula/FormulaCompiler.hxx @@ -220,6 +220,8 @@ public: void SetCompileForFAP( BOOL bVal ) { bCompileForFAP = bVal; bIgnoreErrors = bVal; } + static bool IsOpCodeVolatile( OpCode eOp ); + static BOOL DeQuote( String& rStr ); static const String& GetNativeSymbol( OpCode eOp ); diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index 3c87ce3855..739504435f 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -741,6 +741,30 @@ OpCode FormulaCompiler::GetEnglishOpCode( const String& rName ) const return bFound ? (*iLook).second : OpCode(ocNone); } +bool FormulaCompiler::IsOpCodeVolatile( OpCode eOp ) +{ + switch (eOp) + { + // no parameters: + case ocRandom: + case ocGetActDate: + case ocGetActTime: + // one parameter: + case ocFormula: + case ocInfo: + // more than one parameters: + // ocIndirect/ocIndirectXL otherwise would have to do + // StopListening and StartListening on a reference for every + // interpreted value. + case ocIndirect: + case ocIndirectXL: + // ocOffset results in indirect references. + case ocOffset: + return true; + } + return false; +} + // Remove quotes, escaped quotes are unescaped. BOOL FormulaCompiler::DeQuote( String& rStr ) { @@ -973,44 +997,32 @@ void FormulaCompiler::Factor() { if( nNumFmt == NUMBERFORMAT_UNDEFINED ) nNumFmt = lcl_GetRetFormat( eOp ); - // Functions that have to be always recalculated - switch( eOp ) + + if ( IsOpCodeVolatile(eOp) ) + pArr->SetRecalcModeAlways(); + else { - // no parameters: - case ocRandom: - case ocGetActDate: - case ocGetActTime: - // one parameter: - case ocFormula: - case ocInfo: - // more than one parameters: - // ocIndirect/ocIndirectXL otherwise would have to do - // StopListening and StartListening on a reference for every - // interpreted value. - case ocIndirect: - case ocIndirectXL: - // ocOffset results in indirect references. - case ocOffset: - pArr->SetRecalcModeAlways(); - break; - // Functions recalculated on every document load. - // Don't use SetRecalcModeOnLoad() which would override - // ModeAlways. - case ocConvert : - pArr->AddRecalcMode( RECALCMODE_ONLOAD ); - break; - // If the referred cell is moved the value changes. - case ocColumn : - case ocRow : - // ocCell needs recalc on move for some possible type values. - case ocCell : - pArr->SetRecalcModeOnRefMove(); - break; - case ocHyperLink : - pArr->SetHyperLink(TRUE); - break; - default: - ; // nothing + switch( eOp ) + { + // Functions recalculated on every document load. + // Don't use SetRecalcModeOnLoad() which would override + // ModeAlways. + case ocConvert : + pArr->AddRecalcMode( RECALCMODE_ONLOAD ); + break; + // If the referred cell is moved the value changes. + case ocColumn : + case ocRow : + // ocCell needs recalc on move for some possible type values. + case ocCell : + pArr->SetRecalcModeOnRefMove(); + break; + case ocHyperLink : + pArr->SetHyperLink(TRUE); + break; + default: + ; // nothing + } } if (SC_OPCODE_START_NO_PAR <= eOp && eOp < SC_OPCODE_STOP_NO_PAR) { |