summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-06-08 12:08:46 +0200
committerEike Rathke <erack@redhat.com>2016-06-08 12:13:24 +0200
commit86d8893c270dcca6b29a8b7dd15654089481af4d (patch)
treea9c8bdde55c837708024d2d2330f4c5131177a65 /sc
parent1ec01a340a063ef6d1b773e6a693c09234bd4f27 (diff)
use FormulaTypedDoubleToken in PushDouble() for temporary interim results
... and extract type information in PopDouble() Change-Id: Ib184a8d893bf1072d051a80259b44f6e28fc9271
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/inc/interpre.hxx2
-rw-r--r--sc/source/core/tool/interpr4.cxx21
2 files changed, 20 insertions, 3 deletions
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 5b1c2fe9ca18..629c6c0738e9 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -354,6 +354,8 @@ ScMatrixRef PopMatrix();
sc::RangeMatrix PopRangeMatrix();
void QueryMatrixType(ScMatrixRef& xMat, short& rRetTypeExpr, sal_uLong& rRetIndexExpr);
+formula::FormulaToken* CreateDoubleOrTypedToken( double fVal );
+
void PushDouble(double nVal);
void PushInt( int nVal );
void PushStringBuffer( const sal_Unicode* pString );
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index a9363a72930f..f846cefd41e7 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -812,7 +812,12 @@ double ScInterpreter::PopDouble()
nGlobalError = p->GetError();
break;
case svDouble:
- return p->GetDouble();
+ {
+ short nType = p->GetDoubleType();
+ if (nType && nType != css::util::NumberFormat::UNDEFINED)
+ nCurFmtType = nType;
+ return p->GetDouble();
+ }
case svEmptyCell:
case svMissing:
return 0.0;
@@ -1650,17 +1655,27 @@ void ScInterpreter::QueryMatrixType(ScMatrixRef& xMat, short& rRetTypeExpr, sal_
SetError( errUnknownStackVariable);
}
+formula::FormulaToken* ScInterpreter::CreateDoubleOrTypedToken( double fVal )
+{
+ // NumberFormat::NUMBER is the default untyped double.
+ if (nFuncFmtType && nFuncFmtType != css::util::NumberFormat::NUMBER &&
+ nFuncFmtType != css::util::NumberFormat::UNDEFINED)
+ return new FormulaTypedDoubleToken( fVal, nFuncFmtType);
+ else
+ return new FormulaDoubleToken( fVal);
+}
+
void ScInterpreter::PushDouble(double nVal)
{
TreatDoubleError( nVal );
if (!IfErrorPushError())
- PushTempTokenWithoutError( new FormulaDoubleToken( nVal ) );
+ PushTempTokenWithoutError( CreateDoubleOrTypedToken( nVal));
}
void ScInterpreter::PushInt(int nVal)
{
if (!IfErrorPushError())
- PushTempTokenWithoutError( new FormulaDoubleToken( nVal ) );
+ PushTempTokenWithoutError( CreateDoubleOrTypedToken( nVal));
}
void ScInterpreter::PushStringBuffer( const sal_Unicode* pString )