Commit 599e6ca1 authored by GoshaZotov's avatar GoshaZotov

_checkArguments -> _prepareArguments(return obj)

parent 3f2fc7cb
...@@ -628,7 +628,8 @@ ...@@ -628,7 +628,8 @@
cBASE.prototype.argumentsMax = 3; cBASE.prototype.argumentsMax = 3;
cBASE.prototype.isXLFN = true; cBASE.prototype.isXLFN = true;
cBASE.prototype.Calculate = function (arg) { cBASE.prototype.Calculate = function (arg) {
var argClone = this._checkArguments(arg, arguments[1]); var oArguments = this._prepareArguments(arg, arguments[1]);
var argClone = oArguments.args;
argClone[0] = argClone[0].tocNumber(); argClone[0] = argClone[0].tocNumber();
argClone[1] = argClone[1].tocNumber(); argClone[1] = argClone[1].tocNumber();
...@@ -661,7 +662,7 @@ ...@@ -661,7 +662,7 @@
return new cString(str); return new cString(str);
} }
return this.value = this._findArrayInNumberArguments(argClone, base_math); return this.value = this._findArrayInNumberArguments(oArguments, base_math);
}; };
cBASE.prototype.getInfo = function () { cBASE.prototype.getInfo = function () {
return { return {
...@@ -786,7 +787,8 @@ ...@@ -786,7 +787,8 @@
cCEILING_MATH.prototype.argumentsMax = 3; cCEILING_MATH.prototype.argumentsMax = 3;
cCEILING_MATH.prototype.isXLFN = true; cCEILING_MATH.prototype.isXLFN = true;
cCEILING_MATH.prototype.Calculate = function (arg) { cCEILING_MATH.prototype.Calculate = function (arg) {
var argClone = this._checkArguments(arg, arguments[1]); var oArguments = this._prepareArguments(arg, arguments[1]);
var argClone = oArguments.args;
argClone[0] = argClone[0].tocNumber(); argClone[0] = argClone[0].tocNumber();
if(!argClone[1]){ if(!argClone[1]){
...@@ -818,7 +820,7 @@ ...@@ -818,7 +820,7 @@
} }
} }
return this.value = this._findArrayInNumberArguments(argClone, floor_math); return this.value = this._findArrayInNumberArguments(oArguments, floor_math);
}; };
cCEILING_MATH.prototype.getInfo = function () { cCEILING_MATH.prototype.getInfo = function () {
return { return {
...@@ -842,7 +844,8 @@ ...@@ -842,7 +844,8 @@
cCEILING_PRECISE.prototype.argumentsMax = 2; cCEILING_PRECISE.prototype.argumentsMax = 2;
cCEILING_PRECISE.prototype.isXLFN = true; cCEILING_PRECISE.prototype.isXLFN = true;
cCEILING_PRECISE.prototype.Calculate = function (arg) { cCEILING_PRECISE.prototype.Calculate = function (arg) {
var argClone = this._checkArguments(arg, arguments[1]); var oArguments = this._prepareArguments(arg, arguments[1]);
var argClone = oArguments.args;
argClone[0] = argClone[0].tocNumber(); argClone[0] = argClone[0].tocNumber();
argClone[1] = argClone[1] ? argClone[1].tocNumber() : new cNumber(1); argClone[1] = argClone[1] ? argClone[1].tocNumber() : new cNumber(1);
...@@ -864,7 +867,7 @@ ...@@ -864,7 +867,7 @@
return new cNumber(Math.ceil(quotient) * absSignificance); return new cNumber(Math.ceil(quotient) * absSignificance);
} }
return this.value = this._findArrayInNumberArguments(argClone, floorHelper); return this.value = this._findArrayInNumberArguments(oArguments, floorHelper);
}; };
cCEILING_PRECISE.prototype.getInfo = function () { cCEILING_PRECISE.prototype.getInfo = function () {
return { return {
...@@ -979,7 +982,8 @@ ...@@ -979,7 +982,8 @@
cCOMBINA.prototype.argumentsMax = 2; cCOMBINA.prototype.argumentsMax = 2;
cCOMBINA.prototype.isXLFN = true; cCOMBINA.prototype.isXLFN = true;
cCOMBINA.prototype.Calculate = function (arg) { cCOMBINA.prototype.Calculate = function (arg) {
var argClone = this._checkArguments(arg, arguments[1]); var oArguments = this._prepareArguments(arg, arguments[1]);
var argClone = oArguments.args;
argClone[0] = argClone[0].tocNumber(); argClone[0] = argClone[0].tocNumber();
argClone[1] = argClone[1].tocNumber(); argClone[1] = argClone[1].tocNumber();
...@@ -1002,7 +1006,7 @@ ...@@ -1002,7 +1006,7 @@
return new cNumber(Math.binomCoeff(a + b - 1, b)); return new cNumber(Math.binomCoeff(a + b - 1, b));
} }
return this.value = this._findArrayInNumberArguments(argClone, combinaCalculate); return this.value = this._findArrayInNumberArguments(oArguments, combinaCalculate);
}; };
cCOMBINA.prototype.getInfo = function () { cCOMBINA.prototype.getInfo = function () {
return { return {
...@@ -1342,7 +1346,8 @@ ...@@ -1342,7 +1346,8 @@
cDECIMAL.prototype.argumentsMax = 2; cDECIMAL.prototype.argumentsMax = 2;
cDECIMAL.prototype.isXLFN = true; cDECIMAL.prototype.isXLFN = true;
cDECIMAL.prototype.Calculate = function (arg) { cDECIMAL.prototype.Calculate = function (arg) {
var argClone = this._checkArguments(arg, arguments[1]); var oArguments = this._prepareArguments(arg, arguments[1]);
var argClone = oArguments.args;
argClone[0] = argClone[0].tocString(); argClone[0] = argClone[0].tocString();
argClone[1] = argClone[1].tocNumber(); argClone[1] = argClone[1].tocNumber();
...@@ -1400,7 +1405,7 @@ ...@@ -1400,7 +1405,7 @@
return isNaN(fVal) ? new cError(cErrorType.not_numeric) : new cNumber(fVal); return isNaN(fVal) ? new cError(cErrorType.not_numeric) : new cNumber(fVal);
} }
return this.value = this._findArrayInNumberArguments(argClone, decimal_calculate, true); return this.value = this._findArrayInNumberArguments(oArguments, decimal_calculate, true);
}; };
cDECIMAL.prototype.getInfo = function () { cDECIMAL.prototype.getInfo = function () {
return { return {
...@@ -1813,7 +1818,8 @@ ...@@ -1813,7 +1818,8 @@
cFLOOR_PRECISE.prototype.argumentsMax = 2; cFLOOR_PRECISE.prototype.argumentsMax = 2;
cFLOOR_PRECISE.prototype.isXLFN = true; cFLOOR_PRECISE.prototype.isXLFN = true;
cFLOOR_PRECISE.prototype.Calculate = function (arg) { cFLOOR_PRECISE.prototype.Calculate = function (arg) {
var argClone = this._checkArguments(arg, arguments[1]); var oArguments = this._prepareArguments(arg, arguments[1]);
var argClone = oArguments.args;
argClone[0] = argClone[0].tocNumber(); argClone[0] = argClone[0].tocNumber();
argClone[1] = argClone[1] ? argClone[1].tocNumber() : new cNumber(1); argClone[1] = argClone[1] ? argClone[1].tocNumber() : new cNumber(1);
...@@ -1835,7 +1841,7 @@ ...@@ -1835,7 +1841,7 @@
return new cNumber(Math.floor(quotient) * absSignificance); return new cNumber(Math.floor(quotient) * absSignificance);
} }
return this.value = this._findArrayInNumberArguments(argClone, floorHelper); return this.value = this._findArrayInNumberArguments(oArguments, floorHelper);
}; };
cFLOOR_PRECISE.prototype.getInfo = function () { cFLOOR_PRECISE.prototype.getInfo = function () {
return { return {
...@@ -1859,7 +1865,8 @@ ...@@ -1859,7 +1865,8 @@
cFLOOR_MATH.prototype.argumentsMax = 3; cFLOOR_MATH.prototype.argumentsMax = 3;
cFLOOR_MATH.prototype.isXLFN = true; cFLOOR_MATH.prototype.isXLFN = true;
cFLOOR_MATH.prototype.Calculate = function (arg) { cFLOOR_MATH.prototype.Calculate = function (arg) {
var argClone = this._checkArguments(arg, arguments[1]); var oArguments = this._prepareArguments(arg, arguments[1]);
var argClone = oArguments.args;
argClone[0] = argClone[0].tocNumber(); argClone[0] = argClone[0].tocNumber();
if(!argClone[1]){ if(!argClone[1]){
...@@ -1891,7 +1898,7 @@ ...@@ -1891,7 +1898,7 @@
} }
} }
return this.value = this._findArrayInNumberArguments(argClone, floor_math); return this.value = this._findArrayInNumberArguments(oArguments, floor_math);
}; };
cFLOOR_MATH.prototype.getInfo = function () { cFLOOR_MATH.prototype.getInfo = function () {
return { return {
...@@ -2063,7 +2070,8 @@ ...@@ -2063,7 +2070,8 @@
cISO_CEILING.prototype.argumentsMax = 2; cISO_CEILING.prototype.argumentsMax = 2;
//cISO_CEILING.prototype.isXLFN = true; //cISO_CEILING.prototype.isXLFN = true;
cISO_CEILING.prototype.Calculate = function (arg) { cISO_CEILING.prototype.Calculate = function (arg) {
var argClone = this._checkArguments(arg, arguments[1]); var oArguments = this._prepareArguments(arg, arguments[1]);
var argClone = oArguments.args;
argClone[0] = argClone[0].tocNumber(); argClone[0] = argClone[0].tocNumber();
argClone[1] = argClone[1] ? argClone[1].tocNumber() : new cNumber(1); argClone[1] = argClone[1] ? argClone[1].tocNumber() : new cNumber(1);
...@@ -2085,7 +2093,7 @@ ...@@ -2085,7 +2093,7 @@
return new cNumber(Math.ceil(quotient) * absSignificance); return new cNumber(Math.ceil(quotient) * absSignificance);
} }
return this.value = this._findArrayInNumberArguments(argClone, floorHelper); return this.value = this._findArrayInNumberArguments(oArguments, floorHelper);
}; };
cISO_CEILING.prototype.getInfo = function () { cISO_CEILING.prototype.getInfo = function () {
return { return {
......
...@@ -2293,7 +2293,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -2293,7 +2293,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
this.value = null; this.value = null;
this.argumentsCurrent = 0; this.argumentsCurrent = 0;
this.findArgArrayIndex = null;
// this.isXLFN = rx_sFuncPref.test(this.name); // this.isXLFN = rx_sFuncPref.test(this.name);
} }
...@@ -2371,8 +2370,10 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -2371,8 +2370,10 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
cBaseFunction.prototype.checkArguments = function () { cBaseFunction.prototype.checkArguments = function () {
return this.argumentsMin <= this.argumentsCurrent && this.argumentsCurrent <= this.argumentsMax; return this.argumentsMin <= this.argumentsCurrent && this.argumentsCurrent <= this.argumentsMax;
}; };
cBaseFunction.prototype._findArrayInNumberArguments = function (inputArguments, calculateFunc, dNotCheckNumberType){ cBaseFunction.prototype._findArrayInNumberArguments = function (oArguments, calculateFunc, dNotCheckNumberType){
var argsArray = []; var argsArray = [];
var inputArguments = oArguments.args;
var findArgArrayIndex = oArguments.indexArr;
var parseArray = function(array){ var parseArray = function(array){
array.foreach(function (elem, r, c) { array.foreach(function (elem, r, c) {
...@@ -2401,14 +2402,10 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -2401,14 +2402,10 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
return array; return array;
}; };
if(null !== this.findArgArrayIndex){ if(null !== findArgArrayIndex){
return parseArray(inputArguments[this.findArgArrayIndex]); return parseArray(inputArguments[findArgArrayIndex]);
}
else{
for(var i = 0; i < inputArguments.length; i++){
if(cElementType.array === inputArguments[i].type){
return parseArray(inputArguments[i]);
}else{ }else{
for(var i = 0; i < inputArguments.length; i++){
if(cElementType.string === inputArguments[i].type && !dNotCheckNumberType){ if(cElementType.string === inputArguments[i].type && !dNotCheckNumberType){
return new cError(cErrorType.wrong_value_type); return new cError(cErrorType.wrong_value_type);
}else{ }else{
...@@ -2416,28 +2413,27 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -2416,28 +2413,27 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
} }
} }
} }
}
return calculateFunc(argsArray); return calculateFunc(argsArray);
}; };
cBaseFunction.prototype._checkArguments = function (args, arg1) { cBaseFunction.prototype._prepareArguments = function (args, arg1) {
var newArgs = []; var newArgs = [];
var indexArr = null;
this.findArgArrayIndex = null;
for(var i = 0; i < args.length; i++){ for(var i = 0; i < args.length; i++){
var arg = args[i]; var arg = args[i];
if (cElementType.cellsRange === arg.type || cElementType.cellsRange3D === arg.type) { if (cElementType.cellsRange === arg.type || cElementType.cellsRange3D === arg.type) {
newArgs[i] = arg.cross(arg1); newArgs[i] = arg.cross(arg1);
}else if(cElementType.array === arg.type){ }else if(cElementType.array === arg.type){
this.findArgArrayIndex = i; indexArr = i;
newArgs[i] = arg; newArgs[i] = arg;
}else{ }else{
newArgs[i] = arg; newArgs[i] = arg;
} }
} }
return newArgs; return {args: newArgs, indexArr: indexArr};
}; };
cBaseFunction.prototype._checkErrorArg = function (argArray) { cBaseFunction.prototype._checkErrorArg = function (argArray) {
for (var i = 0; i < argArray.length; i++) { for (var i = 0; i < argArray.length; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment