[Libreoffice-commits] core.git: sc/qa sc/source
Winfried Donkers
winfrieddonkers at libreoffice.org
Mon Mar 6 16:03:49 UTC 2017
sc/qa/unit/data/functions/financial/fods/sln.fods | 20 ++++++++++++++++----
sc/source/core/tool/interpr2.cxx | 13 +++++++++----
2 files changed, 25 insertions(+), 8 deletions(-)
New commits:
commit 055c8cc676921176e2b9df76bd0e09bacab1d80b
Author: Winfried Donkers <winfrieddonkers at libreoffice.org>
Date: Fri Mar 3 16:48:38 2017 +0100
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 at libreoffice.org>
Reviewed-by: Eike Rathke <erack at redhat.com>
diff --git a/sc/qa/unit/data/functions/financial/fods/sln.fods b/sc/qa/unit/data/functions/financial/fods/sln.fods
index 88bad0e..05a85c3 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 a33aa33..a5dae57 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);
+ }
}
}
More information about the Libreoffice-commits
mailing list