[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter' - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Mon Jun 24 18:36:27 PDT 2013
sc/inc/formularesult.hxx | 2 +
sc/source/core/data/formulacell.cxx | 10 -------
sc/source/core/tool/formularesult.cxx | 45 ++++++++++++++++++++++++++++++++--
3 files changed, 46 insertions(+), 11 deletions(-)
New commits:
commit 097468f0754c49f335d779000861cc181b9a7f24
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Jun 24 21:33:40 2013 -0400
Avoid redundant calls to GetCellResultType().
Change-Id: I105b9f555037b1750af6aaff6fc10d2301afde7c
diff --git a/sc/inc/formularesult.hxx b/sc/inc/formularesult.hxx
index 4e6fd39..e215daf 100644
--- a/sc/inc/formularesult.hxx
+++ b/sc/inc/formularesult.hxx
@@ -134,6 +134,8 @@ public:
one paragraph */
bool IsMultiline() const;
+ bool GetErrorOrDouble( sal_uInt16& rErr, double& rVal ) const;
+
/** Get error code if set or GetCellResultType() is formula::svError or svUnknown,
else 0. */
sal_uInt16 GetResultError() const;
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 01f7488..48af974 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1957,15 +1957,7 @@ bool ScFormulaCell::GetErrorOrValue( sal_uInt16& rErr, double& rVal )
if (rErr)
return true;
- rErr = aResult.GetResultError();
- if (rErr)
- return true;
-
- if (!aResult.IsValue())
- return false;
-
- rVal = aResult.GetDouble();
- return true;
+ return aResult.GetErrorOrDouble(rErr, rVal);
}
bool ScFormulaCell::HasOneReference( ScRange& r ) const
diff --git a/sc/source/core/tool/formularesult.cxx b/sc/source/core/tool/formularesult.cxx
index e0ca0be..d15a33d 100644
--- a/sc/source/core/tool/formularesult.cxx
+++ b/sc/source/core/tool/formularesult.cxx
@@ -249,13 +249,21 @@ bool ScFormulaResult::IsEmptyDisplayedAsString() const
return false;
}
-bool ScFormulaResult::IsValue() const
+namespace {
+
+inline bool isValue( formula::StackVar sv )
{
- formula::StackVar sv = GetCellResultType();
return sv == formula::svDouble || sv == formula::svError
|| sv == formula::svEmptyCell || sv == formula::svHybridValueCell;
}
+}
+
+bool ScFormulaResult::IsValue() const
+{
+ return isValue(GetCellResultType());
+}
+
bool ScFormulaResult::IsMultiline() const
{
if (meMultiline == MULTILINE_UNKNOWN)
@@ -269,6 +277,39 @@ bool ScFormulaResult::IsMultiline() const
return meMultiline == MULTILINE_TRUE;
}
+bool ScFormulaResult::GetErrorOrDouble( sal_uInt16& rErr, double& rVal ) const
+{
+ if (mnError)
+ {
+ rErr = mnError;
+ return true;
+ }
+
+ formula::StackVar sv = GetCellResultType();
+ if (sv == formula::svError)
+ {
+ if (GetType() == formula::svMatrixCell)
+ {
+ // don't need to test for mpToken here, GetType() already did it
+ rErr = static_cast<const ScMatrixCellResultToken*>(mpToken)->
+ GetUpperLeftToken()->GetError();
+ }
+ else if (mpToken)
+ {
+ rErr = mpToken->GetError();
+ }
+ }
+
+ if (rErr)
+ return true;
+
+ if (!isValue(sv))
+ return false;
+
+ rVal = GetDouble();
+ return true;
+}
+
sal_uInt16 ScFormulaResult::GetResultError() const
{
if (mnError)
More information about the Libreoffice-commits
mailing list