sc/source/core/tool/compiler.cxx | 48 +++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 14 deletions(-)
New commits: commit 237eb6d37a1c30c9c4907086f3dd895a2341d8ca Author: Winfried Donkers <winfrieddonk...@libreoffice.org> Date: Thu Feb 26 17:18:06 2015 +0100 tdf#40835 add backward compatibility for ODFF function FDIST. Change-Id: I611531e86363d6c2b4ccce1aa0f1a940693bc8d8 Reviewed-on: https://gerrit.libreoffice.org/14658 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Eike Rathke <er...@redhat.com> diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index f87a4b8..f192230 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -2450,8 +2450,9 @@ bool ScCompiler::IsOpCode( const OUString& rName, bool bInArray ) { "EASTERSUNDAY", ocEasterSunday }, // EASTERSUNDAY -> ORG.OPENOFFICE.EASTERSUNDAY { "ZGZ", ocZGZ }, // ZGZ -> RRI { "COLOR", ocColor }, // COLOR -> ORG.LIBREOFFICE.COLOR - { "GOALSEEK", ocBackSolver } // GOALSEEK -> ORG.OPENOFFICE.GOALSEEK - // Renamed new names, prepare to read future names: + { "GOALSEEK", ocBackSolver }, // GOALSEEK -> ORG.OPENOFFICE.GOALSEEK + // Renamed new names, prepare to read future names: + { "FDIST", ocFDist_LT }, // COM.MICROSOFT.F.DIST -> FDIST //{ "ORG.OPENOFFICE.XXX", ocXXX } // XXX -> ORG.OPENOFFICE.XXX }; static const size_t nOdffAliases = sizeof(aOdffAliases) / sizeof(aOdffAliases[0]); @@ -3732,10 +3733,10 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula ) OpCode eOp; short nSep; }; - // FunctionStack only used if PODF or OOXML! bool bPODF = FormulaGrammar::isPODF( meGrammar); + bool bODFF = FormulaGrammar::isODFF( meGrammar); bool bOOXML = FormulaGrammar::isOOXML( meGrammar); - bool bUseFunctionStack = (bPODF || bOOXML); + bool bUseFunctionStack = (bPODF || bOOXML || bODFF); const size_t nAlloc = 512; FunctionStack aFuncs[ nAlloc ]; FunctionStack* pFunctionStack = (bUseFunctionStack && static_cast<size_t>(rFormula.getLength()) > nAlloc ? @@ -3841,23 +3842,42 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula ) SetError(errCodeOverflow); break; } } - if (bOOXML) + // append arguments if neccessary + if ( eOp == ocClose ) { - // Append a parameter for CEILING, FLOOR and WEEKNUM, all 1.0 - // Function is already closed, parameter count is nSep+1 - size_t nFunc = nFunction + 1; - if (eOp == ocClose && ( - (pFunctionStack[ nFunc ].eOp == ocCeil && // 3rd Excel mode + if ( bOOXML ) + { + // Append a parameter for CEILING, FLOOR and WEEKNUM, all 1.0 + // Function is already closed, parameter count is nSep+1 + size_t nFunc = nFunction + 1; + if ((pFunctionStack[ nFunc ].eOp == ocCeil && // 3rd Excel mode pFunctionStack[ nFunc ].nSep == 1) || (pFunctionStack[ nFunc ].eOp == ocFloor && // 3rd Excel mode pFunctionStack[ nFunc ].nSep == 1) || (pFunctionStack[ nFunc ].eOp == ocWeek && // 2nd week start - pFunctionStack[ nFunc ].nSep == 0))) + pFunctionStack[ nFunc ].nSep == 0)) + { + if ( !static_cast<ScTokenArray*>(pArr)->Add( new FormulaToken( svSep, ocSep)) || + !static_cast<ScTokenArray*>(pArr)->Add( new FormulaDoubleToken( 1.0))) + { + SetError(errCodeOverflow); break; + } + } + } + else if ( bODFF ) { - if ( !static_cast<ScTokenArray*>(pArr)->Add( new FormulaToken( svSep, ocSep)) || - !static_cast<ScTokenArray*>(pArr)->Add( new FormulaDoubleToken( 1.0))) + // ensure backward compatibility for F.DIST: + // 4th argument (cumulative) in version 4.5 and up is optional (defaulting to true), + // but in version 4.4 and before it is required + size_t nFunc = nFunction + 1; + if ( (pFunctionStack[ nFunc ].eOp == ocFDist_LT && + pFunctionStack[ nFunc ].nSep == 2) ) { - SetError(errCodeOverflow); break; + if ( !static_cast<ScTokenArray*>(pArr)->Add( new FormulaToken( svSep, ocSep)) || + !static_cast<ScTokenArray*>(pArr)->Add( new FormulaDoubleToken( 1.0))) + { + SetError(errCodeOverflow); break; + } } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits