summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-01-05 14:02:35 +0300
committerEike Rathke <erack@redhat.com>2020-01-22 17:30:13 +0100
commit197aa7911d5be5464efd19feaf3370eea1c15ab1 (patch)
tree1aabdeb2ae2b5c09e3f93112cb5534d73132e483 /sc/source
parenta821d89646ef25428cf5992f86d8f31581313bdb (diff)
tdf#83779: convert TRUE/FALSE constants to functions TRUE()/FALSE()
This avoids problems with round-tripping Excel spreadsheets, where previously a formula like =IF(ISNA(A1)=FALSE;"a";"b") was imported as =IF(ISNA(A1)=0;"a";"b"), and when exported back, it didn't work in Excel, because boolean values had a distinct type in it. Change-Id: I672a631bfa1a4811349794f714293404c6b24381 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86238 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/tool/compiler.cxx22
1 files changed, 16 insertions, 6 deletions
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 769790de7fdb..66ce3d569f91 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3013,14 +3013,17 @@ bool ScCompiler::IsValue( const OUString& rSym )
return false; // some function name, not a constant
// Could be TRUE or FALSE constant.
+ OpCode eOpFunc = ocNone;
if (rSym.equalsIgnoreAsciiCase("TRUE"))
+ eOpFunc = ocTrue;
+ else if (rSym.equalsIgnoreAsciiCase("FALSE"))
+ eOpFunc = ocFalse;
+ if (eOpFunc != ocNone)
{
- maRawToken.SetDouble( 1.0 );
- return true;
- }
- if (rSym.equalsIgnoreAsciiCase("FALSE"))
- {
- maRawToken.SetDouble( 0.0 );
+ maRawToken.SetOpCode(eOpFunc);
+ // add missing trailing parentheses
+ maPendingOpCodes.push(ocOpen);
+ maPendingOpCodes.push(ocClose);
return true;
}
return false;
@@ -4168,6 +4171,13 @@ static bool lcl_UpperAsciiOrI18n( OUString& rUpper, const OUString& rOrg, Formul
bool ScCompiler::NextNewToken( bool bInArray )
{
+ if (!maPendingOpCodes.empty())
+ {
+ maRawToken.SetOpCode(maPendingOpCodes.front());
+ maPendingOpCodes.pop();
+ return true;
+ }
+
bool bAllowBooleans = bInArray;
sal_Int32 nSpaces = NextSymbol(bInArray);