diff options
author | Winfried Donkers <winfrieddonkers@libreoffice.org> | 2017-03-03 16:48:38 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-03-06 16:03:15 +0000 |
commit | 055c8cc676921176e2b9df76bd0e09bacab1d80b (patch) | |
tree | bbd9be149fa0807a3ed16f710d01af9a9f03f789 /sc | |
parent | ccd030e61fa43c472b85b184882e87f4fab2faf2 (diff) |
Check for divide by zero in Calc function SLN.
Plus use correct prefixes for variable names.
Change-Id: Ia60117bec22eb305cb351a2e5fa0e757b4897139
Reviewed-on: https://gerrit.libreoffice.org/34872
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/data/functions/financial/fods/sln.fods | 20 | ||||
-rw-r--r-- | sc/source/core/tool/interpr2.cxx | 13 |
2 files changed, 25 insertions, 8 deletions
diff --git a/sc/qa/unit/data/functions/financial/fods/sln.fods b/sc/qa/unit/data/functions/financial/fods/sln.fods index 88bad0ec6cb1..05a85c3f9b80 100644 --- a/sc/qa/unit/data/functions/financial/fods/sln.fods +++ b/sc/qa/unit/data/functions/financial/fods/sln.fods @@ -2526,10 +2526,22 @@ <table:table-cell table:number-columns-repeated="9"/> </table:table-row> <table:table-row table:style-name="ro6"> - <table:table-cell table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce23"/> - <table:table-cell table:style-name="ce26"/> - <table:table-cell table:number-columns-repeated="6"/> + <table:table-cell table:formula="of:=SLN(100;10;0)" office:value-type="string" office:string-value="" calcext:value-type="error"> + <text:p>Err:502</text:p> + </table:table-cell> + <table:table-cell table:formula="of:#ERR502!" office:value-type="string" office:string-value="" calcext:value-type="error"> + <text:p>Err:502</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce71" table:formula="of:=ORG.OPENOFFICE.ERRORTYPE([.A12])=502" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A12])" office:value-type="string" office:string-value="=SLN(100,10,0)" calcext:value-type="string"> + <text:p>=SLN(100,10,0)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>prevent #div/0! Error</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="5"/> <table:table-cell table:style-name="ce38"/> <table:table-cell table:number-columns-repeated="9"/> </table:table-row> diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index a33aa336917c..a5dae57722fe 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -1895,10 +1895,15 @@ void ScInterpreter::ScSLN() nFuncFmtType = css::util::NumberFormat::CURRENCY; if ( MustHaveParamCount( GetByte(), 3 ) ) { - double nTimeLength = GetDouble(); - double nRest = GetDouble(); - double nValue = GetDouble(); - PushDouble((nValue - nRest) / nTimeLength); + double fTimeLength = GetDouble(); + if ( fTimeLength == 0.0 ) + PushIllegalArgument(); + else + { + double fRest = GetDouble(); + double fValue = GetDouble(); + PushDouble((fValue - fRest) / fTimeLength); + } } } |