diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2010-10-04 14:47:46 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2010-10-04 14:47:46 -0400 |
commit | cb884d1bdfa3b5b3920fdd41b40f166ad9d47e33 (patch) | |
tree | 8d968938b289641fabae9999d8734fc2ebe0c07b /sc | |
parent | ae7abbdc80acaab64d9cf942eac8c2309e97a24f (diff) |
Ported calc-formula-matrix-no-autocalc.diff from ooo-build.
This patch allows formula to be recalculated if it's during matrix
calculation even if the auto recalc flag is OFF. This is needed
when calculating a formula whose result is a matrix which previously
only calculated the top-left cell when the auto recalc was OFF.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/cell.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/cell.cxx | 12 | ||||
-rw-r--r-- | sc/source/core/data/cell2.cxx | 23 |
3 files changed, 20 insertions, 17 deletions
diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx index b4c5ebb44057..f9cce9e94ed2 100644 --- a/sc/inc/cell.hxx +++ b/sc/inc/cell.hxx @@ -538,6 +538,8 @@ public: /** Determines whether or not the result string contains more than one paragraph */ bool IsMultilineResult(); + + void MaybeInterpret(); }; // Iterator fuer Referenzen in einer Formelzelle diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx index d12439bbad4f..5fcb9ec90e9f 100644 --- a/sc/source/core/data/cell.cxx +++ b/sc/source/core/data/cell.cxx @@ -899,8 +899,7 @@ void ScFormulaCell::GetFormula( String& rFormula, const FormulaGrammar::Grammar void ScFormulaCell::GetResultDimensions( SCSIZE& rCols, SCSIZE& rRows ) { - if (IsDirtyOrInTableOpDirty() && pDocument->GetAutoCalc()) - Interpret(); + MaybeInterpret(); const ScMatrix* pMat = NULL; if (!pCode->GetCodeError() && aResult.GetType() == svMatrixCell && @@ -1969,6 +1968,15 @@ bool ScFormulaCell::IsMultilineResult() return false; } +void ScFormulaCell::MaybeInterpret() +{ + if (!IsDirtyOrInTableOpDirty()) + return; + + if (pDocument->GetAutoCalc() || (cMatrixFlag != MM_NONE)) + Interpret(); +} + EditTextObject* ScFormulaCell::CreateURLObject() { String aCellText; diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx index b3e3d2c3eed2..76149992f1b4 100644 --- a/sc/source/core/data/cell2.cxx +++ b/sc/source/core/data/cell2.cxx @@ -489,29 +489,25 @@ bool lcl_isReference(const FormulaToken& rToken) BOOL ScFormulaCell::IsEmpty() { - if (IsDirtyOrInTableOpDirty() && pDocument->GetAutoCalc()) - Interpret(); + MaybeInterpret(); return aResult.GetCellResultType() == formula::svEmptyCell; } BOOL ScFormulaCell::IsEmptyDisplayedAsString() { - if (IsDirtyOrInTableOpDirty() && pDocument->GetAutoCalc()) - Interpret(); + MaybeInterpret(); return aResult.IsEmptyDisplayedAsString(); } BOOL ScFormulaCell::IsValue() { - if (IsDirtyOrInTableOpDirty() && pDocument->GetAutoCalc()) - Interpret(); + MaybeInterpret(); return aResult.IsValue(); } double ScFormulaCell::GetValue() { - if (IsDirtyOrInTableOpDirty() && pDocument->GetAutoCalc()) - Interpret(); + MaybeInterpret(); if ((!pCode->GetCodeError() || pCode->GetCodeError() == errDoubleRef) && !aResult.GetResultError()) return aResult.GetDouble(); @@ -521,16 +517,13 @@ double ScFormulaCell::GetValue() double ScFormulaCell::GetValueAlways() { // for goal seek: return result value even if error code is set - - if (IsDirtyOrInTableOpDirty() && pDocument->GetAutoCalc()) - Interpret(); + MaybeInterpret(); return aResult.GetDouble(); } void ScFormulaCell::GetString( String& rString ) { - if (IsDirtyOrInTableOpDirty() && pDocument->GetAutoCalc()) - Interpret(); + MaybeInterpret(); if ((!pCode->GetCodeError() || pCode->GetCodeError() == errDoubleRef) && !aResult.GetResultError()) rString = aResult.GetString(); @@ -722,8 +715,8 @@ USHORT ScFormulaCell::GetMatrixEdge( ScAddress& rOrgPos ) USHORT ScFormulaCell::GetErrCode() { - if (IsDirtyOrInTableOpDirty() && pDocument->GetAutoCalc()) - Interpret(); + MaybeInterpret(); + /* FIXME: If ScTokenArray::SetCodeError() was really only for code errors * and not also abused for signaling other error conditions we could bail * out even before attempting to interpret broken code. */ |