summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--formula/source/core/api/token.cxx16
-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
5 files changed, 38 insertions, 33 deletions
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index 7d5528c40c73..a9abdd0ef133 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -1111,10 +1111,12 @@ inline bool MissingConventionOOXML::isRewriteNeeded( OpCode eOp )
case ocPoissonDist:
case ocNormDist:
case ocLogNormDist:
+ case ocHypGeomDist:
case ocDBCount:
case ocDBCount2:
return true;
+
default:
return false;
}
@@ -1244,6 +1246,14 @@ void FormulaMissingContext::AddMoreArgs( FormulaTokenArray *pNewArr, const Missi
}
break;
+ case ocHypGeomDist:
+ if ( mnCurArg == 3 )
+ {
+ pNewArr->AddOpCode( ocSep );
+ pNewArr->AddDouble( 0.0 ); // 5th, Cumulative = false()
+ }
+ break;
+
case ocRound:
case ocRoundUp:
case ocRoundDown:
@@ -1515,6 +1525,12 @@ FormulaTokenArray * FormulaTokenArray::RewriteMissing( const MissingConvention &
( pCur->GetOpCode() == ocCeil ? ocCeil_Math : ocFloor_Math ) );
pNewArr->Add( pToken );
}
+ else if ( pCur->GetOpCode() == ocHypGeomDist &&
+ rConv.getConvention() == MissingConvention::FORMULA_MISSING_CONVENTION_OOXML )
+ {
+ FormulaToken *pToken = new FormulaToken( svByte, ocHypGeomDist_MS );
+ pNewArr->Add( pToken );
+ }
else
pNewArr->AddToken( *pCur );
}
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