diff options
author | Eike Rathke <erack@redhat.com> | 2017-07-17 20:13:07 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-07-21 06:22:06 +0200 |
commit | 6f75cd76215045837697699e7dfcd7b0a40467f4 (patch) | |
tree | 7a40b72464c885a9b714203f09286264018a26c7 | |
parent | 3c4b67ac73aae4f44938c296d1a54ff68c6e2ae8 (diff) |
Resolves: tdf#104186 spaces between function name and ( not allowed in OOXML
(cherry picked from commit 7232980be6a4d67ed28a21b74ef3544cacb29d6a)
Conflicts:
formula/source/core/api/FormulaCompiler.cxx
Backported.
Change-Id: I6f6fcdab24a426d0f62052fa2d31f4098d1d893a
Reviewed-on: https://gerrit.libreoffice.org/40085
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r-- | formula/source/core/api/FormulaCompiler.cxx | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index 037d2fb745b0..0b4b85d0ac60 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -2135,20 +2135,36 @@ const FormulaToken* FormulaCompiler::CreateStringFromToken( OUStringBuffer& rBuf if( eOp == ocSpaces ) { - bool bIntersectionOp = mxSymbols->isODFF(); - if (bIntersectionOp) + bool bWriteSpaces = true; + if (mxSymbols->isODFF()) { const FormulaToken* p = pArr->PeekPrevNoSpaces(); - bIntersectionOp = (p && p->GetOpCode() == ocColRowName); + bool bIntersectionOp = (p && p->GetOpCode() == ocColRowName); if (bIntersectionOp) { p = pArr->PeekNextNoSpaces(); bIntersectionOp = (p && p->GetOpCode() == ocColRowName); } + if (bIntersectionOp) + { + rBuffer.append( "!!"); + bWriteSpaces = false; + } } - if (bIntersectionOp) - rBuffer.append( "!!"); - else + else if (mxSymbols->isOOXML()) + { + // ECMA-376-1:2016 18.17.2 Syntax states "that no space characters + // shall separate a function-name from the left parenthesis (() + // that follows it." and Excel even chokes on it. + const FormulaToken* p = pArr->PeekPrevNoSpaces(); + if (p && p->isFunction()) + { + p = pArr->PeekNextNoSpaces(); + if (p && p->GetOpCode() == ocOpen) + bWriteSpaces = false; + } + } + if (bWriteSpaces) { // most times it's just one blank sal_uInt8 n = t->GetByte(); |