summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-07-17 20:13:07 +0200
committerAndras Timar <andras.timar@collabora.com>2017-07-31 12:03:54 +0200
commit63cbbd40b82e2f8180735a517ecb4ac6a97ee84d (patch)
tree4dade3a6df458d7c80a6a120b0b5e6475c61a6d6
parent141e090518b731aaf15e09da990d8a30a3429ffa (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/40086 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> (cherry picked from commit 6ff7de9c93e280cfe54a0ed660595c98d052ab11)
-rw-r--r--formula/source/core/api/FormulaCompiler.cxx28
1 files changed, 22 insertions, 6 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index 2a561d2182e3..d251dc7c17c2 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -2153,20 +2153,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();