help asked for Calc jump function with empty arguments

Eike Rathke erack at redhat.com
Sat Jan 31 09:34:56 PST 2015


Hi Winfried,

On Thursday, 2015-01-29 10:15:59 +0100, Winfried Donkers wrote:

> I am working on bug 88576, regarding IFERROR and IFNA not giving expected results when not all mandatory arguments are given.
> On checking their behaviour in various cases, I discovered that IFERROR, IFNA and IF do not handle empty arguments as they should be.
> With empty argument I mean e.g. -IFERROR(something;) of IF(statement;;argument).
> With IFERROR and IFNA these situation should return an empty value to be compatible with Excel.

AFAIK also Excel does not allow a null argument for IFERROR() second
parameter, but I'm not sure, I'd have to check.

> With IF, the behaviour is described in ODFF1.2.

Note that there seems to be a typo in the spec, IfFalse is mentioned
twice to be considered to be 0, the first (two consecutive ;; case)
probably should be IfTrue.

> My question is, where should this behaviour best be put in the code?
> In class FormulaCompiler, e.g. in FormulaCompiler::Factor(), in ScInterpreter::Interpret(), in the functions themselves (ScInterpreter::ScIf() and ScInterpreter::ScIfError() or somewhere else?

I think the right place would be ScInterpreter::Interpret() at the end
where the final result is obtained. There's a check

    if( pCur->GetOpCode() == ocPush )

and if not an error is set. An ocMissing here could be propagated
through to the ScFormulaResult, then

    bool isValue( formula::StackVar sv )

in sc/source/core/tool/formularesult.cxx would need to handle
formula::svMissing as well, the ScFormulaResult::GetDouble() already
returns 0.0 in such case.

> And as these functions are jump functions, how best to access/modify the stack or FormulaToken?

Don't ;-)
The code is already an ocMissing and the jumps are correct, just the
final result isn't.

  Eike

-- 
LibreOffice Calc developer. Number formatter stricken i18n transpositionizer.
GPG key "ID" 0x65632D3A - 2265 D7F3 A7B0 95CC 3918  630B 6A6C D5B7 6563 2D3A
Better use 64-bit 0x6A6CD5B765632D3A here is why: https://evil32.com/
Care about Free Software, support the FSFE https://fsfe.org/support/?erack
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20150131/5ed09640/attachment.sig>


More information about the LibreOffice mailing list