[Libreoffice-commits] core.git: Branch 'feature/calc-parallel' - sc/source
Dennis Francis
dennis.francis at collabora.co.uk
Fri Nov 17 08:42:08 UTC 2017
sc/source/core/tool/formulagroup.cxx | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
New commits:
commit 67d17c60529f41e422db4565dc5a136e02ec48ed
Author: Dennis Francis <dennis.francis at collabora.co.uk>
Date: Fri Nov 17 14:05:56 2017 +0530
Type check the tokens before reuse
If the exisiting token is of wrong type, create and use a fresh new
token instead.
Change-Id: I348b0972306497dfe7eae0655c9b93d5830cb740
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index e77554d89805..326392f6099e 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -206,13 +206,26 @@ public:
if ( !pTargetTok )
aCode2.AddString(rPool.intern(OUString(pStr)));
else
- pTargetTok->SetString(rPool.intern(OUString(pStr)));
+ {
+ if ( pTargetTok->GetType() == formula::svString )
+ pTargetTok->SetString(rPool.intern(OUString(pStr)));
+ else
+ {
+ formula::FormulaStringToken* pStrTok = new formula::FormulaStringToken(rPool.intern(OUString(pStr)));
+ aCode2.ReplaceToken(nTokIdx, pStrTok, formula::FormulaTokenArray::CODE_ONLY);
+ }
+ }
}
else if (rtl::math::isNan(fVal))
{
// Value of NaN represents an empty cell.
if ( !pTargetTok )
aCode2.AddToken(ScEmptyCellToken(false, false));
+ else if ( pTargetTok->GetType() != formula::svEmptyCell )
+ {
+ ScEmptyCellToken* pEmptyTok = new ScEmptyCellToken(false, false);
+ aCode2.ReplaceToken(nTokIdx, pEmptyTok, formula::FormulaTokenArray::CODE_ONLY);
+ }
}
else
{
@@ -220,7 +233,15 @@ public:
if ( !pTargetTok )
aCode2.AddDouble(fVal);
else
- pTargetTok->GetDoubleAsReference() = fVal;
+ {
+ if ( pTargetTok->GetType() == formula::svDouble )
+ pTargetTok->GetDoubleAsReference() = fVal;
+ else
+ {
+ formula::FormulaDoubleToken* pDoubleTok = new formula::FormulaDoubleToken( fVal );
+ aCode2.ReplaceToken(nTokIdx, pDoubleTok, formula::FormulaTokenArray::CODE_ONLY);
+ }
+ }
}
}
break;
More information about the Libreoffice-commits
mailing list