From 9b8e00c80be86f97d60b36ae8fc84b1440ce5f94 Mon Sep 17 00:00:00 2001
From: "Alexander.Trofimov" <Alexander.Trofimov@onlyoffice.com>
Date: Wed, 25 May 2016 11:38:18 +0300
Subject: [PATCH] fix bug 32501

---
 .../FormulaObjects/mathematicFunctions.js     | 10 ++++--
 .../FormulaObjects/statisticalFunctions.js    | 31 ++++++++++---------
 2 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/cell/model/FormulaObjects/mathematicFunctions.js b/cell/model/FormulaObjects/mathematicFunctions.js
index f32c650ba..196409178 100644
--- a/cell/model/FormulaObjects/mathematicFunctions.js
+++ b/cell/model/FormulaObjects/mathematicFunctions.js
@@ -3810,7 +3810,7 @@ function cSUBTOTAL() {
 
 cSUBTOTAL.prototype = Object.create( cBaseFunction.prototype )
 cSUBTOTAL.prototype.Calculate = function ( arg ) {
-	var arg0 = arg[0];
+	var f, arg0 = arg[0];
 
 	if ( arg0 instanceof cArea || arg0 instanceof cArea3D ) {
 		arg0 = arg0.cross( arguments[1].first );
@@ -3836,11 +3836,15 @@ cSUBTOTAL.prototype.Calculate = function ( arg ) {
 			break;
 		case cSubTotalFunctionType.includes.MAX:
 		case cSubTotalFunctionType.excludes.MAX:
-			this.value = (new AscCommonExcel.cMAX()).Calculate(arg.slice(1));
+			f = new AscCommonExcel.cMAX();
+			f.setArgumentsCount(arg.length - 1);
+			this.value = f.Calculate(arg.slice(1));
 			break;
 		case cSubTotalFunctionType.includes.MIN:
 		case cSubTotalFunctionType.excludes.MIN:
-			this.value = (new AscCommonExcel.cMIN()).Calculate(arg.slice(1));
+			f = new AscCommonExcel.cMIN();
+      f.setArgumentsCount(arg.length - 1);
+			this.value = f.Calculate(arg.slice(1));
 			break;
 		case cSubTotalFunctionType.includes.PRODUCT:
 		case cSubTotalFunctionType.excludes.PRODUCT:
diff --git a/cell/model/FormulaObjects/statisticalFunctions.js b/cell/model/FormulaObjects/statisticalFunctions.js
index 425d20495..4b732041d 100644
--- a/cell/model/FormulaObjects/statisticalFunctions.js
+++ b/cell/model/FormulaObjects/statisticalFunctions.js
@@ -5199,13 +5199,13 @@ function cTRIMMEAN() {
     cBaseFunction.call( this, "TRIMMEAN" );
 }
 
-cTRIMMEAN.prototype = Object.create( cBaseFunction.prototype )
+cTRIMMEAN.prototype = Object.create( cBaseFunction.prototype );
 
 function cTTEST() {
     cBaseFunction.call( this, "TTEST" );
 }
 
-cTTEST.prototype = Object.create( cBaseFunction.prototype )
+cTTEST.prototype = Object.create( cBaseFunction.prototype );
 
 function cVAR() {
 //    cBaseFunction.call( this, "VAR" );
@@ -5298,13 +5298,13 @@ cVAR.prototype.Calculate = function ( arg ) {
     }
     return this.value = _var( arr0 );
 
-}
+};
 cVAR.prototype.getInfo = function () {
     return {
         name:this.name,
         args:"( argument-list )"
     };
-}
+};
 
 function cVARA() {
 //    cBaseFunction.call( this, "VARA" );
@@ -5323,7 +5323,7 @@ function cVARA() {
 
 }
 
-cVARA.prototype = Object.create( cBaseFunction.prototype )
+cVARA.prototype = Object.create( cBaseFunction.prototype );
 cVARA.prototype.Calculate = function ( arg ) {
 
     function _var( x ) {
@@ -5412,13 +5412,13 @@ cVARA.prototype.Calculate = function ( arg ) {
 
     }
     return this.value = _var( arr0 );
-}
+};
 cVARA.prototype.getInfo = function () {
     return {
         name:this.name,
         args:"( argument-list )"
     };
-}
+};
 
 function cVARP() {
 //    cBaseFunction.call( this, "VARP" );
@@ -5507,13 +5507,13 @@ cVARP.prototype.Calculate = function ( arg ) {
 
     }
     return this.value = _var( arr0 );
-}
+};
 cVARP.prototype.getInfo = function () {
     return {
         name:this.name,
         args:"( argument-list )"
     };
-}
+};
 
 function cVARdotP() {
 //    cBaseFunction.call( this, "VARP" );
@@ -5532,14 +5532,14 @@ function cVARdotP() {
 
 }
 
-cVARdotP.prototype = Object.create( cBaseFunction.prototype )
+cVARdotP.prototype = Object.create( cBaseFunction.prototype );
 cVARdotP.prototype.Calculate = cVARP.prototype.Calculate;
 cVARdotP.prototype.getInfo = function () {
     return {
         name:this.name,
         args:"( argument-list )"
     };
-}
+};
 
 function cVARPA() {
 //    cBaseFunction.call( this, "VARPA" );
@@ -5558,7 +5558,7 @@ function cVARPA() {
 
 }
 
-cVARPA.prototype = Object.create( cBaseFunction.prototype )
+cVARPA.prototype = Object.create( cBaseFunction.prototype );
 cVARPA.prototype.Calculate = function ( arg ) {
 
     function _var( x ) {
@@ -5647,19 +5647,19 @@ cVARPA.prototype.Calculate = function ( arg ) {
 
     }
     return this.value = _var( arr0 );
-}
+};
 cVARPA.prototype.getInfo = function () {
     return {
         name:this.name,
         args:"( argument-list )"
     };
-}
+};
 
 function cWEIBULL() {
     cBaseFunction.call( this, "WEIBULL" );
 }
 
-cWEIBULL.prototype = Object.create( cBaseFunction.prototype )
+cWEIBULL.prototype = Object.create( cBaseFunction.prototype );
 
 function cZTEST() {
     cBaseFunction.call( this, "ZTEST" );
@@ -5681,4 +5681,5 @@ cZTEST.prototype = Object.create( cBaseFunction.prototype );
     window['AscCommonExcel'].cSTDEV = cSTDEV;
     window['AscCommonExcel'].cSTDEVP = cSTDEVP;
     window['AscCommonExcel'].cVAR = cVAR;
+    window['AscCommonExcel'].cVARP = cVARP;
 })(window);
-- 
2.30.9