diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-07-02 01:12:27 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-07-02 13:19:33 -0400 |
commit | cd2594c7504318a88719c710f7e627b9dd72fa16 (patch) | |
tree | bb699137fbee7a9dddc483fedddbb8a957333f29 /sc | |
parent | 9d207f6fc479bf96db9fcde214f15f2ffb045001 (diff) |
COUNT should skip formula cells with error.
Change-Id: I829eaf309056403f77949526877888315a2ad720
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/formulacell.hxx | 1 | ||||
-rw-r--r-- | sc/inc/formularesult.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/column.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 9 | ||||
-rw-r--r-- | sc/source/core/tool/formularesult.cxx | 12 |
5 files changed, 25 insertions, 1 deletions
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index a63025caf1f2..52a14744d588 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -202,6 +202,7 @@ public: // display as empty string if formula::svEmptyCell result bool IsEmptyDisplayedAsString(); bool IsValue(); // also true if formula::svEmptyCell + bool IsValueNoError(); bool IsHybridValueCell(); // for cells after import to deal with inherited number formats double GetValue(); double GetValueAlways(); // ignore errors diff --git a/sc/inc/formularesult.hxx b/sc/inc/formularesult.hxx index 6736a10fc1cb..f1f7b5d60fac 100644 --- a/sc/inc/formularesult.hxx +++ b/sc/inc/formularesult.hxx @@ -128,6 +128,8 @@ public: details instead. */ bool IsValue() const; + bool IsValueNoError() const; + /** Determines whether or not the result is a string containing more than one paragraph */ bool IsMultiline() const; diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 64aae039a853..61f57abc0676 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -511,7 +511,7 @@ public: for (; it != itEnd; ++it) { ScFormulaCell& rCell = const_cast<ScFormulaCell&>(**it); - if (rCell.IsValue()) + if (rCell.IsValueNoError()) ++mnCount; } } diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 1e86cfc2d43e..a1297261efd2 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -1711,6 +1711,15 @@ bool ScFormulaCell::IsValue() return aResult.IsValue(); } +bool ScFormulaCell::IsValueNoError() +{ + MaybeInterpret(); + if (pCode->GetCodeError()) + return false; + + return aResult.IsValueNoError(); +} + bool ScFormulaCell::IsHybridValueCell() { return aResult.GetType() == formula::svHybridValueCell; diff --git a/sc/source/core/tool/formularesult.cxx b/sc/source/core/tool/formularesult.cxx index a20963bbde80..72944a04b782 100644 --- a/sc/source/core/tool/formularesult.cxx +++ b/sc/source/core/tool/formularesult.cxx @@ -265,6 +265,18 @@ bool ScFormulaResult::IsValue() const return isValue(GetCellResultType()); } +bool ScFormulaResult::IsValueNoError() const +{ + switch (GetCellResultType()) + { + case formula::svDouble: + case formula::svEmptyCell: + case formula::svHybridValueCell: + return true; + } + return false; +} + bool ScFormulaResult::IsMultiline() const { if (meMultiline == MULTILINE_UNKNOWN) |