summaryrefslogtreecommitdiff
path: root/formula
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2018-02-20 17:42:03 +0100
committerEike Rathke <erack@redhat.com>2018-02-20 23:24:17 +0100
commita8d4d4b9edca48b8fb94dbb06d7dd1e689b07b98 (patch)
tree2afa06756b706cd7baf413fcdf55ce329369efe2 /formula
parent226697ae27ef451cad404256e83eef88262f16d1 (diff)
Resolves: tdf#115879 treat NOT as the 1-parameter function that it is
... instead of a low precedence unary operator with an odd behaviour. This wasn't documented nor specified but maybe needed for old(est) binary file format compatibility. Generate an error for anything else than a context of a function with one argument. There might be some corner cases of documents where some old usage leads to error now, of which some may have worked by accident, but some not as intended. Related, the internal not exposed (but available) NEG was classified similar as a unary operator but corectly handled as function at all places. Classified as an ordinary 1-parameter function as well. Change-Id: I3d84a6382243c8d64313e37346f81c857e71be95 Reviewed-on: https://gerrit.libreoffice.org/50055 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'formula')
-rw-r--r--formula/source/core/api/FormulaCompiler.cxx37
-rw-r--r--formula/source/core/api/token.cxx1
2 files changed, 6 insertions, 32 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index 1866fa53201b..a83cc129a93c 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -525,16 +525,7 @@ uno::Sequence< sheet::FormulaOpCodeMapEntry > FormulaCompiler::OpCodeMap::create
// regular unary operators
for (sal_uInt16 nOp = SC_OPCODE_START_UN_OP; nOp < SC_OPCODE_STOP_UN_OP && nOp < mnSymbols; ++nOp)
{
- switch (nOp)
- {
- // NOT and NEG in fact are functions but for legacy reasons
- // are sorted into unary operators for compiler interna.
- case SC_OPCODE_NOT :
- case SC_OPCODE_NEG :
- break; // nothing,
- default:
- lclPushOpCodeMapEntry( aVec, mpTable.get(), nOp );
- }
+ lclPushOpCodeMapEntry( aVec, mpTable.get(), nOp );
}
}
if ((nGroups & FormulaMapGroup::BINARY_OPERATORS) != 0)
@@ -568,9 +559,7 @@ uno::Sequence< sheet::FormulaOpCodeMapEntry > FormulaCompiler::OpCodeMap::create
SC_OPCODE_IF_NA,
SC_OPCODE_CHOOSE,
SC_OPCODE_AND,
- SC_OPCODE_OR,
- SC_OPCODE_NOT,
- SC_OPCODE_NEG
+ SC_OPCODE_OR
};
lclPushOpCodeMapEntries( aVec, mpTable.get(), aOpCodes, SAL_N_ELEMENTS(aOpCodes) );
// functions with 2 or more parameters.
@@ -1473,9 +1462,7 @@ void FormulaCompiler::Factor()
NextToken();
}
}
- // special cases NOT() and NEG()
- else if( eOp == ocNot || eOp == ocNeg
- || (SC_OPCODE_START_1_PAR <= eOp && eOp < SC_OPCODE_STOP_1_PAR) )
+ else if (SC_OPCODE_START_1_PAR <= eOp && eOp < SC_OPCODE_STOP_1_PAR)
{
if (eOp == ocIsoWeeknum && FormulaGrammar::isODFF( meGrammar ))
{
@@ -1551,7 +1538,7 @@ void FormulaCompiler::Factor()
}
else
{
- // standard handling of ocNot, ocNeg and 1-parameter opcodes
+ // standard handling of 1-parameter opcodes
pFacToken = mpToken;
eOp = NextToken();
if( nNumFmt == SvNumFormatType::UNDEFINED && eOp == ocNot )
@@ -1918,18 +1905,6 @@ void FormulaCompiler::CompareLine()
}
}
-void FormulaCompiler::NotLine()
-{
- CompareLine();
- while (mpToken->GetOpCode() == ocNot)
- {
- FormulaTokenRef p = mpToken;
- NextToken();
- CompareLine();
- PutCode(p);
- }
-}
-
OpCode FormulaCompiler::Expression()
{
static const short nRecursionMax = 42;
@@ -1939,13 +1914,13 @@ OpCode FormulaCompiler::Expression()
SetError( FormulaError::StackOverflow );
return ocStop; //! generate token instead?
}
- NotLine();
+ CompareLine();
while (mpToken->GetOpCode() == ocAnd || mpToken->GetOpCode() == ocOr)
{
FormulaTokenRef p = mpToken;
mpToken->SetByte( 2 ); // 2 parameters!
NextToken();
- NotLine();
+ CompareLine();
PutCode(p);
}
return mpToken->GetOpCode();
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index 13d6914392db..1d33b4d93571 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -92,7 +92,6 @@ bool FormulaToken::IsFunction() const
// FuncAutoPilot)
|| eOp == ocMacro || eOp == ocExternal // macros, AddIns
|| eOp == ocAnd || eOp == ocOr // former binary, now x parameters
- || eOp == ocNot || eOp == ocNeg // unary but function
|| (eOp >= ocInternalBegin && eOp <= ocInternalEnd) // internal
));
}