summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorWinfried Donkers <winfrieddonkers@libreoffice.org>2016-10-13 13:49:18 +0200
committerEike Rathke <erack@redhat.com>2016-10-14 15:23:57 +0000
commitcf43ff5262a111f9fbebe58d254b704ec057cbf6 (patch)
tree27031e4e71f7e7f3bfc49a053808e3758715b1a9 /sc
parentd4ddc8cb005887e4b2810006425cccf12937347f (diff)
tdf#102948 Make HYPGEOMDIST ODFF1.2 compliant.
Also reduce duplicate code. On Export to OOXML, HYPGEOMDIST is converted to HYPGEOM.DIST. Change-Id: I70a70ee6b5c542e272ef574073ebcd1924f31083 Reviewed-on: https://gerrit.libreoffice.org/29767 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/inc/interpre.hxx3
-rw-r--r--sc/source/core/tool/interpr3.cxx38
-rw-r--r--sc/source/core/tool/interpr4.cxx4
-rw-r--r--sc/source/ui/src/scfuncs.src10
4 files changed, 22 insertions, 33 deletions
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index fadd4747b106..47d5afdc5c13 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -866,8 +866,7 @@ void ScCombinA();
void ScPermut();
void ScPermutationA();
void ScB();
-void ScHypGeomDist();
-void ScHypGeomDist_MS();
+void ScHypGeomDist( int nMinParamCount );
void ScLogNormDist( int nMinParamCount );
void ScLogNormInv();
void ScTDist();
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 18f8e33c5dec..04b0343ba8de 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -1844,39 +1844,21 @@ static void lcl_PutFactorialElements( ::std::vector< double >& cn, double fLower
@see #i47296#
- */
-void ScInterpreter::ScHypGeomDist()
-{
- if ( !MustHaveParamCount( GetByte(), 4 ) )
- return;
-
- double N = ::rtl::math::approxFloor(GetDouble());
- double M = ::rtl::math::approxFloor(GetDouble());
- double n = ::rtl::math::approxFloor(GetDouble());
- double x = ::rtl::math::approxFloor(GetDouble());
-
- if( (x < 0.0) || (n < x) || (M < x) || (N < n) || (N < M) || (x < n - N + M) )
- {
- PushIllegalArgument();
- return;
- }
-
- PushDouble( GetHypGeomDist( x, n, M, N ) );
-}
-
-/** Calculates a value of the hypergeometric distribution (Excel 2010 function).
-
- This function has an extra argument bCumulative as compared to ScHypGeomDist(),
- which only calculates the non-cumulative distribution.
+ This function has an extra argument bCumulative,
+ which only calculates the non-cumulative distribution and
+ which is optional in Calc and mandatory with Excel's HYPGEOM.DIST()
@see fdo#71722
-*/
-void ScInterpreter::ScHypGeomDist_MS()
+ @see tdf#102948, make Calc function ODFF1.2-compliant
+
+ */
+void ScInterpreter::ScHypGeomDist( int nMinParamCount )
{
- if ( !MustHaveParamCount( GetByte(), 5 ) )
+ sal_uInt8 nParamCount = GetByte();
+ if ( !MustHaveParamCount( nParamCount, nMinParamCount, 5 ) )
return;
- bool bCumulative = GetBool();
+ bool bCumulative = ( nParamCount == 5 && GetBool() );
double N = ::rtl::math::approxFloor(GetDouble());
double M = ::rtl::math::approxFloor(GetDouble());
double n = ::rtl::math::approxFloor(GetDouble());
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 6f5c87e15bc6..11a8870a8f7b 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -4209,8 +4209,8 @@ StackVar ScInterpreter::Interpret()
case ocCombinA : ScCombinA(); break;
case ocPermut : ScPermut(); break;
case ocPermutationA : ScPermutationA(); break;
- case ocHypGeomDist : ScHypGeomDist(); break;
- case ocHypGeomDist_MS : ScHypGeomDist_MS(); break;
+ case ocHypGeomDist : ScHypGeomDist( 4 ); break;
+ case ocHypGeomDist_MS : ScHypGeomDist( 5 ); break;
case ocLogNormDist : ScLogNormDist( 1 ); break;
case ocLogNormDist_MS : ScLogNormDist( 4 ); break;
case ocTDist : ScTDist(); break;
diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src
index cb7b97848708..84dcc9bd1d1d 100644
--- a/sc/source/ui/src/scfuncs.src
+++ b/sc/source/ui/src/scfuncs.src
@@ -8346,7 +8346,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
0;
ID_FUNCTION_GRP_STATISTIC;
HID_FUNC_HYPGEOMVERT;
- 4; 0; 0; 0; 0;
+ 5; 0; 0; 0; 0; 1;
0;
};
String 2 // Name of Parameter 1
@@ -8381,6 +8381,14 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
{
Text [ en-US ] = "The population size." ;
};
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "Cumulative" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "Cumulated. TRUE calculates the cumulative distribution function, FALSE the probability mass function." ;
+ };
};
// -=*# Resource for function HYPGEOM.DIST #*=-
Resource SC_OPCODE_HYP_GEOM_DIST_MS