summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-07-17 20:13:07 +0200
committerEike Rathke <erack@redhat.com>2017-07-17 20:13:38 +0200
commit7232980be6a4d67ed28a21b74ef3544cacb29d6a (patch)
tree3d4fa5ae95da31b2b5871e8a36cbe5ea926bc994
parent2b530e4f3fa516ef1d1d3699174e6f15ffda5305 (diff)
Resolves: tdf#104186 spaces between function name and ( not allowed in OOXML
Change-Id: I6f6fcdab24a426d0f62052fa2d31f4098d1d893a
-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 389b2e719350..8fe5738b7417 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -2142,20 +2142,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 = maArrIterator.PeekPrevNoSpaces();
- bIntersectionOp = (p && p->GetOpCode() == ocColRowName);
+ bool bIntersectionOp = (p && p->GetOpCode() == ocColRowName);
if (bIntersectionOp)
{
p = maArrIterator.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 = maArrIterator.PeekPrevNoSpaces();
+ if (p && p->isFunction())
+ {
+ p = maArrIterator.PeekNextNoSpaces();
+ if (p && p->GetOpCode() == ocOpen)
+ bWriteSpaces = false;
+ }
+ }
+ if (bWriteSpaces)
{
// most times it's just one blank
sal_uInt8 n = t->GetByte();