diff options
-rw-r--r-- | sc/inc/formulacell.hxx | 3 | ||||
-rw-r--r-- | sc/source/core/data/documentimport.cxx | 41 | ||||
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 25 |
3 files changed, 60 insertions, 9 deletions
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index 475bea34c9a2..98bfcba9fa75 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -289,6 +289,7 @@ public: bool IsEmptyDisplayedAsString(); bool IsValue(); // also true if formula::svEmptyCell bool IsValueNoError(); + bool IsValueNoError() const; bool IsHybridValueCell(); // for cells after import to deal with inherited number formats double GetValue(); svl::SharedString GetString(); @@ -371,6 +372,8 @@ public: /** Determines whether or not the result string contains more than one paragraph */ bool IsMultilineResult(); + bool NeedsInterpret() const; + void MaybeInterpret(); /** diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx index 29f912fa44f4..625b92f7aa62 100644 --- a/sc/source/core/data/documentimport.cxx +++ b/sc/source/core/data/documentimport.cxx @@ -513,12 +513,43 @@ public: // Fill with default values for non-empty cell segments. sc::CellTextAttr aDefault; - if (node.type == sc::element_type_numeric) + switch (node.type) { - aDefault.mnScriptType = mpImpl->mnScriptNumeric; - const ColAttr* p = mrDocImpl.getColAttr(mnTab, mnCol); - if (p && p->mbLatinNumFmtOnly) - aDefault.mnScriptType = SCRIPTTYPE_LATIN; + case sc::element_type_numeric: + { + aDefault.mnScriptType = mpImpl->mnScriptNumeric; + const ColAttr* p = mrDocImpl.getColAttr(mnTab, mnCol); + if (p && p->mbLatinNumFmtOnly) + aDefault.mnScriptType = SCRIPTTYPE_LATIN; + } + break; + case sc::element_type_formula: + { + const ColAttr* p = mrDocImpl.getColAttr(mnTab, mnCol); + if (p && p->mbLatinNumFmtOnly) + { + // We can assume latin script type if the block only + // contains formula cells with numeric results. + ScFormulaCell** pp = &sc::formula_block::at(*node.data, 0); + ScFormulaCell** ppEnd = pp + node.size; + bool bNumResOnly = true; + for (; pp != ppEnd; ++pp) + { + const ScFormulaCell& rCell = **pp; + if (!rCell.IsValueNoError()) + { + bNumResOnly = false; + break; + } + } + + if (bNumResOnly) + aDefault.mnScriptType = SCRIPTTYPE_LATIN; + } + } + break; + default: + ; } std::vector<sc::CellTextAttr> aDefaults(node.size, aDefault); diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 33f64e920b5a..c902788603ba 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -2218,15 +2218,20 @@ bool ScFormulaCell::IsMultilineResult() return false; } -void ScFormulaCell::MaybeInterpret() +bool ScFormulaCell::NeedsInterpret() const { if (mxGroup && mxGroup->meKernelState == sc::OpenCLKernelCompilationScheduled) - return; + return false; if (!IsDirtyOrInTableOpDirty()) - return; + return false; - if (pDocument->GetAutoCalc() || (cMatrixFlag != MM_NONE)) + return (pDocument->GetAutoCalc() || (cMatrixFlag != MM_NONE)); +} + +void ScFormulaCell::MaybeInterpret() +{ + if (NeedsInterpret()) Interpret(); } @@ -2271,6 +2276,18 @@ bool ScFormulaCell::IsValueNoError() return aResult.IsValueNoError(); } +bool ScFormulaCell::IsValueNoError() const +{ + if (NeedsInterpret()) + // false if the cell is dirty & needs to be interpreted. + return false; + + if (pCode->GetCodeError()) + return false; + + return aResult.IsValueNoError(); +} + bool ScFormulaCell::IsHybridValueCell() { return aResult.GetType() == formula::svHybridValueCell; |