summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWinfried Donkers <winfrieddonkers@libreoffice.org>2016-09-21 17:00:38 +0200
committerEike Rathke <erack@redhat.com>2016-10-13 18:17:09 +0000
commit52c79bbd1b4c58124738b59214a3f2b111ff0191 (patch)
tree38411a2935cddd92534e506236d7eb7e9757614a
parent8974b0fafb18f9dd3f2c0e175a3255b80e4c249e (diff)
tdf#102328 Add constraint for argument X in Calc function GAMMA.DIST.
Change-Id: I5702cabac8f1e331072acfe25581569f3b7f64cc Reviewed-on: https://gerrit.libreoffice.org/29148 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/source/core/inc/interpre.hxx2
-rw-r--r--sc/source/core/tool/interpr3.cxx5
-rw-r--r--sc/source/core/tool/interpr4.cxx4
3 files changed, 6 insertions, 5 deletions
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index dbe0a3c76e78..fadd4747b106 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -856,7 +856,7 @@ void ScFisher();
void ScFisherInv();
void ScFact();
void ScNormDist( int nMinParamCount );
-void ScGammaDist( int nMinParamCount );
+void ScGammaDist( bool bODFF );
void ScGammaInv();
void ScExpDist();
void ScBinomDist();
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 9b074fa0519f..c877d72a3b27 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -2107,8 +2107,9 @@ double ScInterpreter::GetHypGeomDist( double x, double n, double M, double N )
return fFactor;
}
-void ScInterpreter::ScGammaDist( int nMinParamCount )
+void ScInterpreter::ScGammaDist( bool bODFF )
{
+ sal_uInt8 nMinParamCount = ( bODFF ? 3 : 4 );
sal_uInt8 nParamCount = GetByte();
if ( !MustHaveParamCount( nParamCount, nMinParamCount, 4 ) )
return;
@@ -2120,7 +2121,7 @@ void ScInterpreter::ScGammaDist( int nMinParamCount )
double fBeta = GetDouble(); // scale
double fAlpha = GetDouble(); // shape
double fX = GetDouble(); // x
- if (fAlpha <= 0.0 || fBeta <= 0.0)
+ if ((!bODFF && fX < 0) || fAlpha <= 0.0 || fBeta <= 0.0)
PushIllegalArgument();
else
{
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 475e4ada18ee..6f5c87e15bc6 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -4299,8 +4299,8 @@ StackVar ScInterpreter::Interpret()
case ocGammaLn :
case ocGammaLn_MS : ScLogGamma(); break;
case ocGamma : ScGamma(); break;
- case ocGammaDist : ScGammaDist( 3 ); break;
- case ocGammaDist_MS : ScGammaDist( 4 ); break;
+ case ocGammaDist : ScGammaDist( true ); break;
+ case ocGammaDist_MS : ScGammaDist( false ); break;
case ocGammaInv :
case ocGammaInv_MS : ScGammaInv(); break;
case ocChiTest :