Commit e3b18934 authored by GoshaZotov's avatar GoshaZotov

_checkCAreaArg -> _checkArguments

parent b695e918
...@@ -628,10 +628,7 @@ ...@@ -628,10 +628,7 @@
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 = []; var argClone = this._checkArguments(arg, arguments[1]);
argClone[0] = this._checkCAreaArg(arg[0], arguments[1]);
argClone[1] = this._checkCAreaArg(arg[1], arguments[1]);
argClone[2] = this._checkCAreaArg(arg[2], arguments[1]);
argClone[0] = argClone[0].tocNumber(); argClone[0] = argClone[0].tocNumber();
argClone[1] = argClone[1].tocNumber(); argClone[1] = argClone[1].tocNumber();
...@@ -789,10 +786,7 @@ ...@@ -789,10 +786,7 @@
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 = []; var argClone = this._checkArguments(arg, arguments[1]);
argClone[0] = this._checkCAreaArg(arg[0], arguments[1]);
argClone[1] = this._checkCAreaArg(arg[1], arguments[1]);
argClone[2] = this._checkCAreaArg(arg[2], arguments[1]);
argClone[0] = argClone[0].tocNumber(); argClone[0] = argClone[0].tocNumber();
if(!argClone[1]){ if(!argClone[1]){
...@@ -848,9 +842,7 @@ ...@@ -848,9 +842,7 @@
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 = []; var argClone = this._checkArguments(arg, arguments[1]);
argClone[0] = this._checkCAreaArg(arg[0], arguments[1]);
argClone[1] = this._checkCAreaArg(arg[1], arguments[1]);
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);
...@@ -987,9 +979,7 @@ ...@@ -987,9 +979,7 @@
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 = []; var argClone = this._checkArguments(arg, arguments[1]);
argClone[0] = this._checkCAreaArg(arg[0], arguments[1]);
argClone[1] = this._checkCAreaArg(arg[1], arguments[1]);
argClone[0] = argClone[0].tocNumber(); argClone[0] = argClone[0].tocNumber();
argClone[1] = argClone[1].tocNumber(); argClone[1] = argClone[1].tocNumber();
...@@ -1352,9 +1342,7 @@ ...@@ -1352,9 +1342,7 @@
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 = []; var argClone = this._checkArguments(arg, arguments[1]);
argClone[0] = this._checkCAreaArg(arg[0], arguments[1]);
argClone[1] = this._checkCAreaArg(arg[1], arguments[1]);
argClone[0] = argClone[0].tocString(); argClone[0] = argClone[0].tocString();
argClone[1] = argClone[1].tocNumber(); argClone[1] = argClone[1].tocNumber();
...@@ -1825,9 +1813,7 @@ ...@@ -1825,9 +1813,7 @@
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 = []; var argClone = this._checkArguments(arg, arguments[1]);
argClone[0] = this._checkCAreaArg(arg[0], arguments[1]);
argClone[1] = this._checkCAreaArg(arg[1], arguments[1]);
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);
...@@ -1873,10 +1859,7 @@ ...@@ -1873,10 +1859,7 @@
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 = []; var argClone = this._checkArguments(arg, arguments[1]);
argClone[0] = this._checkCAreaArg(arg[0], arguments[1]);
argClone[1] = this._checkCAreaArg(arg[1], arguments[1]);
argClone[2] = this._checkCAreaArg(arg[2], arguments[1]);
argClone[0] = argClone[0].tocNumber(); argClone[0] = argClone[0].tocNumber();
if(!argClone[1]){ if(!argClone[1]){
...@@ -2080,9 +2063,7 @@ ...@@ -2080,9 +2063,7 @@
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 = []; var argClone = this._checkArguments(arg, arguments[1]);
argClone[0] = this._checkCAreaArg(arg[0], arguments[1]);
argClone[1] = this._checkCAreaArg(arg[1], arguments[1]);
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);
......
...@@ -2292,6 +2292,8 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -2292,6 +2292,8 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
this.name = name; this.name = name;
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,48 +2373,71 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -2371,48 +2373,71 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
}; };
cBaseFunction.prototype._findArrayInNumberArguments = function (inputArguments, calculateFunc, dNotCheckNumberType){ cBaseFunction.prototype._findArrayInNumberArguments = function (inputArguments, calculateFunc, dNotCheckNumberType){
var argsArray = []; var argsArray = [];
for(var i = 0; i < inputArguments.length; i++){
if(cElementType.array === inputArguments[i].type){
inputArguments[i].foreach(function (elem, r, c) {
var arg;
argsArray = [];
for(var j = 0; j < inputArguments.length; j++){
if(i === j){
arg = elem;
}else if(cElementType.array === inputArguments[j].type){
arg = inputArguments[j].getElementRowCol(r, c);
}else{
arg = inputArguments[j];
}
if(arg && ((dNotCheckNumberType) || (cElementType.number === arg.type && !dNotCheckNumberType))){ var parseArray = function(array){
argsArray[j] = arg.getValue(); array.foreach(function (elem, r, c) {
}else{
argsArray = null; var arg;
break; argsArray = [];
} for(var j = 0; j < inputArguments.length; j++){
if(i === j){
arg = elem;
}else if(cElementType.array === inputArguments[j].type){
arg = inputArguments[j].getElementRowCol(r, c);
}else{
arg = inputArguments[j];
} }
this.array[r][c] = null === argsArray ? new cError(cErrorType.wrong_value_type) : calculateFunc(argsArray); if(arg && ((dNotCheckNumberType) || (cElementType.number === arg.type && !dNotCheckNumberType))){
}); argsArray[j] = arg.getValue();
return inputArguments[i]; }else{
}else{ argsArray = null;
if(cElementType.string === inputArguments[i].type && !dNotCheckNumberType){ break;
return new cError(cErrorType.wrong_value_type); }
}
this.array[r][c] = null === argsArray ? new cError(cErrorType.wrong_value_type) : calculateFunc(argsArray);
});
return array;
};
if(null !== this.findArgArrayIndex){
return parseArray(inputArguments[this.findArgArrayIndex]);
}
else{
for(var i = 0; i < inputArguments.length; i++){
if(cElementType.array === inputArguments[i].type){
return parseArray(inputArguments[i]);
}else{ }else{
argsArray[i] = inputArguments[i].getValue(); if(cElementType.string === inputArguments[i].type && !dNotCheckNumberType){
return new cError(cErrorType.wrong_value_type);
}else{
argsArray[i] = inputArguments[i].getValue();
}
} }
} }
} }
return calculateFunc(argsArray); return calculateFunc(argsArray);
}; };
cBaseFunction.prototype._checkCAreaArg = function (arg, arg1) { cBaseFunction.prototype._checkArguments = function (args, arg1) {
if (arg instanceof cArea || arg instanceof cArea3D) { var newArgs = [];
arg = arg.cross(arg1);
this.findArgArrayIndex = null;
for(var i = 0; i < args.length; i++){
var arg = args[i];
if (cElementType.cellsRange === arg.type || cElementType.cellsRange3D === arg.type) {
newArgs[i] = arg.cross(arg1);
}else if(cElementType.array === arg.type){
this.findArgArrayIndex = i;
newArgs[i] = arg;
}else{
newArgs[i] = arg;
}
} }
return arg;
return newArgs;
}; };
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