summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorWinfried Donkers <winfrieddonkers@libreoffice.org>2017-03-29 18:24:33 +0200
committerEike Rathke <erack@redhat.com>2017-05-05 01:34:46 +0200
commita7f1df962c1c6cb0e1d51d8a67f0190c64962544 (patch)
tree857e79e80217ca671b6e320a0c0da3930f06f716 /sc/source
parent9691f2652f157f375881aea3bf5e39d72a133e0f (diff)
tdf#106796 Make CHITEST and CHISQ.TEST comply with ODFF1.2 and improve
interoperability with Excel. Note: the functions now don't accept empty datasets, just like Excel. This is not fully compliant with ODFF1.2. A change request to make ODFF reflect this behaviour would be appropiate. Change-Id: I70225a4dc8e20a035d25af4290137714cda95624 Reviewed-on: https://gerrit.libreoffice.org/35864 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/tool/interpr3.cxx34
1 files changed, 25 insertions, 9 deletions
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 2ed998b836bb..950648694db6 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -2805,23 +2805,39 @@ void ScInterpreter::ScChiTest()
return;
}
double fChi = 0.0;
+ bool bEmpty = true;
for (SCSIZE i = 0; i < nC1; i++)
{
for (SCSIZE j = 0; j < nR1; j++)
{
- if (!pMat1->IsString(i,j) && !pMat2->IsString(i,j))
- {
- double fValX = pMat1->GetDouble(i,j);
- double fValE = pMat2->GetDouble(i,j);
- fChi += sc::divide( (fValX - fValE) * (fValX - fValE), fValE);
- }
- else
+ if (!(pMat1->IsEmpty(i,j) || pMat2->IsEmpty(i,j)))
{
- PushIllegalArgument();
- return;
+ bEmpty = false;
+ if (!pMat1->IsString(i,j) && !pMat2->IsString(i,j))
+ {
+ double fValX = pMat1->GetDouble(i,j);
+ double fValE = pMat2->GetDouble(i,j);
+ if ( fValE == 0.0 )
+ {
+ PushError(FormulaError::DivisionByZero);
+ return;
+ }
+ fChi += sc::divide( (fValX - fValE) * (fValX - fValE), fValE);
+ }
+ else
+ {
+ PushIllegalArgument();
+ return;
+ }
}
}
}
+ if ( bEmpty )
+ {
+ // not in ODFF1.2, but for interoperability with Excel
+ PushIllegalArgument();
+ return;
+ }
double fDF;
if (nC1 == 1 || nR1 == 1)
{