3.0 source code
This commit is contained in:
@@ -1,62 +1,140 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
cFormulaFunction.Cube = {
|
||||
"groupName": "Cube",
|
||||
"CUBEKPIMEMBER": function () {
|
||||
var r = new cBaseFunction("CUBEKPIMEMBER");
|
||||
return r;
|
||||
},
|
||||
"CUBEMEMBER": function () {
|
||||
var r = new cBaseFunction("CUBEMEMBER");
|
||||
return r;
|
||||
},
|
||||
"CUBEMEMBERPROPERTY": function () {
|
||||
var r = new cBaseFunction("CUBEMEMBERPROPERTY");
|
||||
return r;
|
||||
},
|
||||
"CUBERANKEDMEMBER": function () {
|
||||
var r = new cBaseFunction("CUBERANKEDMEMBER");
|
||||
return r;
|
||||
},
|
||||
"CUBESET": function () {
|
||||
var r = new cBaseFunction("CUBESET");
|
||||
return r;
|
||||
},
|
||||
"CUBESETCOUNT": function () {
|
||||
var r = new cBaseFunction("CUBESETCOUNT");
|
||||
return r;
|
||||
},
|
||||
"CUBEVALUE": function () {
|
||||
var r = new cBaseFunction("CUBEVALUE");
|
||||
return r;
|
||||
}
|
||||
};
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
cFormulaFunction.Cube = {
|
||||
"groupName": "Cube",
|
||||
"CUBEKPIMEMBER": cCUBEKPIMEMBER,
|
||||
"CUBEMEMBER": cCUBEMEMBER,
|
||||
"CUBEMEMBERPROPERTY": cCUBEMEMBERPROPERTY,
|
||||
"CUBERANKEDMEMBER": cCUBERANKEDMEMBER,
|
||||
"CUBESET": cCUBESET,
|
||||
"CUBESETCOUNT": cCUBESETCOUNT,
|
||||
"CUBEVALUE": cCUBEVALUE
|
||||
};
|
||||
function cCUBEKPIMEMBER() {
|
||||
this.name = "CUBEKPIMEMBER";
|
||||
this.type = cElementType.func;
|
||||
this.value = null;
|
||||
this.argumentsMin = 0;
|
||||
this.argumentsCurrent = 0;
|
||||
this.argumentsMax = 255;
|
||||
this.formatType = {
|
||||
def: -1,
|
||||
noneFormat: -2
|
||||
};
|
||||
this.numFormat = this.formatType.def;
|
||||
}
|
||||
cCUBEKPIMEMBER.prototype = Object.create(cBaseFunction.prototype);
|
||||
function cCUBEMEMBER() {
|
||||
this.name = "CUBEMEMBER";
|
||||
this.type = cElementType.func;
|
||||
this.value = null;
|
||||
this.argumentsMin = 0;
|
||||
this.argumentsCurrent = 0;
|
||||
this.argumentsMax = 255;
|
||||
this.formatType = {
|
||||
def: -1,
|
||||
noneFormat: -2
|
||||
};
|
||||
this.numFormat = this.formatType.def;
|
||||
}
|
||||
cCUBEMEMBER.prototype = Object.create(cBaseFunction.prototype);
|
||||
function cCUBEMEMBERPROPERTY() {
|
||||
this.name = "CUBEMEMBERPROPERTY";
|
||||
this.type = cElementType.func;
|
||||
this.value = null;
|
||||
this.argumentsMin = 0;
|
||||
this.argumentsCurrent = 0;
|
||||
this.argumentsMax = 255;
|
||||
this.formatType = {
|
||||
def: -1,
|
||||
noneFormat: -2
|
||||
};
|
||||
this.numFormat = this.formatType.def;
|
||||
}
|
||||
cCUBEMEMBERPROPERTY.prototype = Object.create(cBaseFunction.prototype);
|
||||
function cCUBERANKEDMEMBER() {
|
||||
this.name = "CUBERANKEDMEMBER";
|
||||
this.type = cElementType.func;
|
||||
this.value = null;
|
||||
this.argumentsMin = 0;
|
||||
this.argumentsCurrent = 0;
|
||||
this.argumentsMax = 255;
|
||||
this.formatType = {
|
||||
def: -1,
|
||||
noneFormat: -2
|
||||
};
|
||||
this.numFormat = this.formatType.def;
|
||||
}
|
||||
cCUBERANKEDMEMBER.prototype = Object.create(cBaseFunction.prototype);
|
||||
function cCUBESET() {
|
||||
this.name = "CUBESET";
|
||||
this.type = cElementType.func;
|
||||
this.value = null;
|
||||
this.argumentsMin = 0;
|
||||
this.argumentsCurrent = 0;
|
||||
this.argumentsMax = 255;
|
||||
this.formatType = {
|
||||
def: -1,
|
||||
noneFormat: -2
|
||||
};
|
||||
this.numFormat = this.formatType.def;
|
||||
}
|
||||
cCUBESET.prototype = Object.create(cBaseFunction.prototype);
|
||||
function cCUBESETCOUNT() {
|
||||
this.name = "CUBESETCOUNT";
|
||||
this.type = cElementType.func;
|
||||
this.value = null;
|
||||
this.argumentsMin = 0;
|
||||
this.argumentsCurrent = 0;
|
||||
this.argumentsMax = 255;
|
||||
this.formatType = {
|
||||
def: -1,
|
||||
noneFormat: -2
|
||||
};
|
||||
this.numFormat = this.formatType.def;
|
||||
}
|
||||
cCUBESETCOUNT.prototype = Object.create(cBaseFunction.prototype);
|
||||
function cCUBEVALUE() {
|
||||
this.name = "CUBEVALUE";
|
||||
this.type = cElementType.func;
|
||||
this.value = null;
|
||||
this.argumentsMin = 0;
|
||||
this.argumentsCurrent = 0;
|
||||
this.argumentsMax = 255;
|
||||
this.formatType = {
|
||||
def: -1,
|
||||
noneFormat: -2
|
||||
};
|
||||
this.numFormat = this.formatType.def;
|
||||
}
|
||||
cCUBEVALUE.prototype = Object.create(cBaseFunction.prototype);
|
||||
@@ -1,82 +1,95 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
cFormulaFunction.Database = {
|
||||
"groupName": "Database",
|
||||
"DAVERAGE": function () {
|
||||
var r = new cBaseFunction("DAVERAGE");
|
||||
return r;
|
||||
},
|
||||
"DCOUNT": function () {
|
||||
var r = new cBaseFunction("DCOUNT");
|
||||
return r;
|
||||
},
|
||||
"DCOUNTA": function () {
|
||||
var r = new cBaseFunction("DCOUNTA");
|
||||
return r;
|
||||
},
|
||||
"DGET": function () {
|
||||
var r = new cBaseFunction("DGET");
|
||||
return r;
|
||||
},
|
||||
"DMAX": function () {
|
||||
var r = new cBaseFunction("DMAX");
|
||||
return r;
|
||||
},
|
||||
"DMIN": function () {
|
||||
var r = new cBaseFunction("DMIN");
|
||||
return r;
|
||||
},
|
||||
"DPRODUCT": function () {
|
||||
var r = new cBaseFunction("DPRODUCT");
|
||||
return r;
|
||||
},
|
||||
"DSTDEV": function () {
|
||||
var r = new cBaseFunction("DSTDEV");
|
||||
return r;
|
||||
},
|
||||
"DSTDEVP": function () {
|
||||
var r = new cBaseFunction("DSTDEVP");
|
||||
return r;
|
||||
},
|
||||
"DSUM": function () {
|
||||
var r = new cBaseFunction("DSUM");
|
||||
return r;
|
||||
},
|
||||
"DVAR": function () {
|
||||
var r = new cBaseFunction("DVAR");
|
||||
return r;
|
||||
},
|
||||
"DVARP": function () {
|
||||
var r = new cBaseFunction("DVARP");
|
||||
return r;
|
||||
}
|
||||
};
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
cFormulaFunction.Database = {
|
||||
"groupName": "Database",
|
||||
"DAVERAGE": cDAVERAGE,
|
||||
"DCOUNT": cDCOUNT,
|
||||
"DCOUNTA": cDCOUNTA,
|
||||
"DGET": cDGET,
|
||||
"DMAX": cDMAX,
|
||||
"DMIN": cDMIN,
|
||||
"DPRODUCT": cDPRODUCT,
|
||||
"DSTDEV": cDSTDEV,
|
||||
"DSTDEVP": cDSTDEVP,
|
||||
"DSUM": cDSUM,
|
||||
"DVAR": cDVAR,
|
||||
"DVARP": cDVARP
|
||||
};
|
||||
function cDAVERAGE() {
|
||||
cBaseFunction.call(this, "DAVERAGE");
|
||||
}
|
||||
cDAVERAGE.prototype = Object.create(cBaseFunction.prototype);
|
||||
function cDCOUNT() {
|
||||
cBaseFunction.call(this, "DCOUNT");
|
||||
}
|
||||
cDCOUNT.prototype = Object.create(cBaseFunction.prototype);
|
||||
function cDCOUNTA() {
|
||||
cBaseFunction.call(this, "DCOUNTA");
|
||||
}
|
||||
cDCOUNTA.prototype = Object.create(cBaseFunction.prototype);
|
||||
function cDGET() {
|
||||
cBaseFunction.call(this, "DGET");
|
||||
}
|
||||
cDGET.prototype = Object.create(cBaseFunction.prototype);
|
||||
function cDMAX() {
|
||||
cBaseFunction.call(this, "DMAX");
|
||||
}
|
||||
cDMAX.prototype = Object.create(cBaseFunction.prototype);
|
||||
function cDMIN() {
|
||||
cBaseFunction.call(this, "DMIN");
|
||||
}
|
||||
cDMIN.prototype = Object.create(cBaseFunction.prototype);
|
||||
function cDPRODUCT() {
|
||||
cBaseFunction.call(this, "DPRODUCT");
|
||||
}
|
||||
cDPRODUCT.prototype = Object.create(cBaseFunction.prototype);
|
||||
function cDSTDEV() {
|
||||
cBaseFunction.call(this, "DSTDEV");
|
||||
}
|
||||
cDSTDEV.prototype = Object.create(cBaseFunction.prototype);
|
||||
function cDSTDEVP() {
|
||||
cBaseFunction.call(this, "DSTDEVP");
|
||||
}
|
||||
cDSTDEVP.prototype = Object.create(cBaseFunction.prototype);
|
||||
function cDSUM() {
|
||||
cBaseFunction.call(this, "DSUM");
|
||||
}
|
||||
cDSUM.prototype = Object.create(cBaseFunction.prototype);
|
||||
function cDVAR() {
|
||||
cBaseFunction.call(this, "DVAR");
|
||||
}
|
||||
cDVAR.prototype = Object.create(cBaseFunction.prototype);
|
||||
function cDVARP() {
|
||||
cBaseFunction.call(this, "DVARP");
|
||||
}
|
||||
cDVARP.prototype = Object.create(cBaseFunction.prototype);
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,329 +1,387 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
cFormulaFunction.Logical = {
|
||||
"groupName": "Logical",
|
||||
"AND": function () {
|
||||
var r = new cBaseFunction("AND");
|
||||
r.setArgumentsMin(1);
|
||||
r.setArgumentsMax(255);
|
||||
r.Calculate = function (arg) {
|
||||
var argResult = null;
|
||||
for (var i = 0; i < arg.length; i++) {
|
||||
if (arg[i] instanceof cArea || arg[i] instanceof cArea3D) {
|
||||
var argArr = arg[i].getValue();
|
||||
for (var j = 0; j < argArr.length; j++) {
|
||||
if (argArr[j] instanceof cString || argArr[j] instanceof cEmpty) {
|
||||
continue;
|
||||
} else {
|
||||
if (argArr[j] instanceof cError) {
|
||||
return this.value = argArr[j];
|
||||
} else {
|
||||
if (argResult == null) {
|
||||
argResult = argArr[j].tocBool();
|
||||
} else {
|
||||
argResult = new cBool(argResult.value && argArr[j].tocBool().value);
|
||||
}
|
||||
if (argResult.value == false) {
|
||||
return this.value = new cBool(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (arg[i] instanceof cString) {
|
||||
return this.value = new cError(cErrorType.wrong_value_type);
|
||||
} else {
|
||||
if (arg[i] instanceof cError) {
|
||||
return this.value = arg[i];
|
||||
} else {
|
||||
if (arg[i] instanceof cArray) {
|
||||
var thas = this;
|
||||
arg[i].foreach(function (elem) {
|
||||
if (elem instanceof cError) {
|
||||
argResult = elem;
|
||||
return true;
|
||||
} else {
|
||||
if (elem instanceof cString || elem instanceof cEmpty) {
|
||||
return;
|
||||
} else {
|
||||
if (argResult == null) {
|
||||
argResult = elem.tocBool();
|
||||
} else {
|
||||
argResult = new cBool(argResult.value && elem.tocBool().value);
|
||||
}
|
||||
if (argResult.value == false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (argResult == null) {
|
||||
argResult = arg[i].tocBool();
|
||||
} else {
|
||||
argResult = new cBool(argResult.value && arg[i].tocBool().value);
|
||||
}
|
||||
if (argResult.value == false) {
|
||||
return this.value = new cBool(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (argResult == null) {
|
||||
return this.value = new cError(cErrorType.wrong_value_type);
|
||||
}
|
||||
return this.value = argResult;
|
||||
};
|
||||
r.getInfo = function () {
|
||||
return {
|
||||
name: this.name,
|
||||
args: "(logical1, logical2, ...)"
|
||||
};
|
||||
};
|
||||
return r;
|
||||
},
|
||||
"FALSE": function () {
|
||||
var r = new cBaseFunction("FALSE");
|
||||
r.setArgumentsMin(0);
|
||||
r.setArgumentsMax(0);
|
||||
r.Calculate = function () {
|
||||
return this.value = new cBool(false);
|
||||
};
|
||||
r.getInfo = function () {
|
||||
return {
|
||||
name: this.name,
|
||||
args: "()"
|
||||
};
|
||||
};
|
||||
return r;
|
||||
},
|
||||
"IF": function () {
|
||||
var r = new cBaseFunction("IF");
|
||||
r.setArgumentsMin(1);
|
||||
r.setArgumentsMax(3);
|
||||
r.Calculate = function (arg) {
|
||||
var arg0 = arg[0],
|
||||
arg1 = arg[1],
|
||||
arg2 = arg[2];
|
||||
if (arg0 instanceof cArray) {
|
||||
arg0 = arg0.getElement(0);
|
||||
}
|
||||
if (arg1 instanceof cArray) {
|
||||
arg1 = arg1.getElement(0);
|
||||
}
|
||||
if (arg2 instanceof cArray) {
|
||||
arg2 = arg2.getElement(0);
|
||||
}
|
||||
if (arg0 instanceof cError) {
|
||||
return this.value = arg0;
|
||||
} else {
|
||||
arg0 = arg0.tocBool();
|
||||
if (arg0 instanceof cString) {
|
||||
return this.value = new cError(cErrorType.wrong_value_type);
|
||||
} else {
|
||||
if (arg0.value) {
|
||||
return this.value = arg1 ? arg1 instanceof cEmpty ? new cNumber(0) : arg1 : new cBool(true);
|
||||
} else {
|
||||
return this.value = arg2 ? arg2 instanceof cEmpty ? new cNumber(0) : arg2 : new cBool(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
r.getInfo = function () {
|
||||
return {
|
||||
name: this.name,
|
||||
args: "(logical_test, value_if_true, value_if_false)"
|
||||
};
|
||||
};
|
||||
return r;
|
||||
},
|
||||
"IFERROR": function () {
|
||||
var r = new cBaseFunction("IFERROR");
|
||||
r.setArgumentsMin(2);
|
||||
r.setArgumentsMax(2);
|
||||
r.Calculate = function (arg) {
|
||||
var arg0 = arg[0];
|
||||
if (arg0 instanceof cArray) {
|
||||
arg0 = arg0.getElement(0);
|
||||
}
|
||||
if (arg0 instanceof cRef || arg0 instanceof cRef3D) {
|
||||
arg0 = arg0.getValue();
|
||||
}
|
||||
if (arg0 instanceof cArea || arg0 instanceof cArea3D) {
|
||||
arg0 = arg0.cross(arguments[1].first);
|
||||
}
|
||||
if (arg0 instanceof cError) {
|
||||
return this.value = arg[1] instanceof cArray ? arg[1].getElement(0) : arg[1];
|
||||
} else {
|
||||
return this.value = arg[0];
|
||||
}
|
||||
};
|
||||
r.getInfo = function () {
|
||||
return {
|
||||
name: this.name,
|
||||
args: "(value, value_if_error)"
|
||||
};
|
||||
};
|
||||
return r;
|
||||
},
|
||||
"NOT": function () {
|
||||
var r = new cBaseFunction("NOT");
|
||||
r.setArgumentsMin(1);
|
||||
r.setArgumentsMax(1);
|
||||
r.Calculate = function (arg) {
|
||||
var arg0 = arg[0];
|
||||
if (arg0 instanceof cArray) {
|
||||
arg0 = arg0.getElement(0);
|
||||
}
|
||||
if (arg0 instanceof cArea || arg0 instanceof cArea3D) {
|
||||
arg0 = arg0.cross(arguments[1].first);
|
||||
}
|
||||
if (arg0 instanceof cString) {
|
||||
var res = arg0.tocBool();
|
||||
if (res instanceof cString) {
|
||||
return this.value = new cError(cErrorType.wrong_value_type);
|
||||
} else {
|
||||
return this.value = new cBool(!res.value);
|
||||
}
|
||||
} else {
|
||||
if (arg0 instanceof cError) {
|
||||
return this.value = arg0;
|
||||
} else {
|
||||
return this.value = new cBool(!arg0.tocBool().value);
|
||||
}
|
||||
}
|
||||
};
|
||||
r.getInfo = function () {
|
||||
return {
|
||||
name: this.name,
|
||||
args: "(logical)"
|
||||
};
|
||||
};
|
||||
return r;
|
||||
},
|
||||
"OR": function () {
|
||||
var r = new cBaseFunction("OR");
|
||||
r.setArgumentsMin(1);
|
||||
r.setArgumentsMax(255);
|
||||
r.Calculate = function (arg) {
|
||||
var argResult = null;
|
||||
for (var i = 0; i < arg.length; i++) {
|
||||
if (arg[i] instanceof cArea || arg[i] instanceof cArea3D) {
|
||||
var argArr = arg[i].getValue();
|
||||
for (var j = 0; j < argArr.length; j++) {
|
||||
if (argArr[j] instanceof cString || argArr[j] instanceof cEmpty) {
|
||||
continue;
|
||||
} else {
|
||||
if (argArr[j] instanceof cError) {
|
||||
return this.value = argArr[j];
|
||||
} else {
|
||||
if (argResult == null) {
|
||||
argResult = argArr[j].tocBool();
|
||||
} else {
|
||||
argResult = new cBool(argResult.value || argArr[j].tocBool().value);
|
||||
}
|
||||
if (argResult.value === true) {
|
||||
return this.value = new cBool(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (arg[i] instanceof cString) {
|
||||
return this.value = new cError(cErrorType.wrong_value_type);
|
||||
} else {
|
||||
if (arg[i] instanceof cError) {
|
||||
return this.value = arg[i];
|
||||
} else {
|
||||
if (arg[i] instanceof cArray) {
|
||||
var thas = this;
|
||||
arg[i].foreach(function (elem) {
|
||||
if (elem instanceof cError) {
|
||||
argResult = elem;
|
||||
return true;
|
||||
} else {
|
||||
if (elem instanceof cString || elem instanceof cEmpty) {
|
||||
return;
|
||||
} else {
|
||||
if (argResult == null) {
|
||||
argResult = elem.tocBool();
|
||||
} else {
|
||||
argResult = new cBool(argResult.value || elem.tocBool().value);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (argResult == null) {
|
||||
argResult = arg[i].tocBool();
|
||||
} else {
|
||||
argResult = new cBool(argResult.value || arg[i].tocBool().value);
|
||||
}
|
||||
if (argResult.value === true) {
|
||||
return this.value = new cBool(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (argResult == null) {
|
||||
return this.value = new cError(cErrorType.wrong_value_type);
|
||||
}
|
||||
return this.value = argResult;
|
||||
};
|
||||
r.getInfo = function () {
|
||||
return {
|
||||
name: this.name,
|
||||
args: "(logical1, logical2, ...)"
|
||||
};
|
||||
};
|
||||
return r;
|
||||
},
|
||||
"TRUE": function () {
|
||||
var r = new cBaseFunction("TRUE");
|
||||
r.setArgumentsMin(0);
|
||||
r.setArgumentsMax(0);
|
||||
r.Calculate = function () {
|
||||
return this.value = new cBool(true);
|
||||
};
|
||||
r.getInfo = function () {
|
||||
return {
|
||||
name: this.name,
|
||||
args: "()"
|
||||
};
|
||||
};
|
||||
return r;
|
||||
}
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
cFormulaFunction.Logical = {
|
||||
"groupName": "Logical",
|
||||
"AND": cAND,
|
||||
"FALSE": cFALSE,
|
||||
"IF": cIF,
|
||||
"IFERROR": cIFERROR,
|
||||
"NOT": cNOT,
|
||||
"OR": cOR,
|
||||
"TRUE": cTRUE
|
||||
};
|
||||
function cAND() {
|
||||
this.name = "AND";
|
||||
this.type = cElementType.func;
|
||||
this.value = null;
|
||||
this.argumentsMin = 1;
|
||||
this.argumentsCurrent = 0;
|
||||
this.argumentsMax = 255;
|
||||
this.formatType = {
|
||||
def: -1,
|
||||
noneFormat: -2
|
||||
};
|
||||
this.numFormat = this.formatType.def;
|
||||
}
|
||||
cAND.prototype = Object.create(cBaseFunction.prototype);
|
||||
cAND.prototype.Calculate = function (arg) {
|
||||
var argResult = null;
|
||||
for (var i = 0; i < arg.length; i++) {
|
||||
if (arg[i] instanceof cArea || arg[i] instanceof cArea3D) {
|
||||
var argArr = arg[i].getValue();
|
||||
for (var j = 0; j < argArr.length; j++) {
|
||||
if (argArr[j] instanceof cError) {
|
||||
return this.value = argArr[j];
|
||||
} else {
|
||||
if (! (argArr[j] instanceof cString || argArr[j] instanceof cEmpty)) {
|
||||
if (argResult === null) {
|
||||
argResult = argArr[j].tocBool();
|
||||
} else {
|
||||
argResult = new cBool(argResult.value && argArr[j].tocBool().value);
|
||||
}
|
||||
if (argResult.value === false) {
|
||||
return this.value = new cBool(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (arg[i] instanceof cString) {
|
||||
return this.value = new cError(cErrorType.wrong_value_type);
|
||||
} else {
|
||||
if (arg[i] instanceof cError) {
|
||||
return this.value = arg[i];
|
||||
} else {
|
||||
if (arg[i] instanceof cArray) {
|
||||
arg[i].foreach(function (elem) {
|
||||
if (elem instanceof cError) {
|
||||
argResult = elem;
|
||||
return true;
|
||||
} else {
|
||||
if (elem instanceof cString || elem instanceof cEmpty) {
|
||||
return false;
|
||||
} else {
|
||||
if (argResult === null) {
|
||||
argResult = elem.tocBool();
|
||||
} else {
|
||||
argResult = new cBool(argResult.value && elem.tocBool().value);
|
||||
}
|
||||
if (argResult.value === false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (argResult === null) {
|
||||
argResult = arg[i].tocBool();
|
||||
} else {
|
||||
argResult = new cBool(argResult.value && arg[i].tocBool().value);
|
||||
}
|
||||
if (argResult.value === false) {
|
||||
return this.value = new cBool(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (argResult === null) {
|
||||
return this.value = new cError(cErrorType.wrong_value_type);
|
||||
}
|
||||
return this.value = argResult;
|
||||
};
|
||||
cAND.prototype.getInfo = function () {
|
||||
return {
|
||||
name: this.name,
|
||||
args: "(logical1, logical2, ...)"
|
||||
};
|
||||
};
|
||||
function cFALSE() {
|
||||
this.name = "FALSE";
|
||||
this.type = cElementType.func;
|
||||
this.value = null;
|
||||
this.argumentsMin = 0;
|
||||
this.argumentsCurrent = 0;
|
||||
this.argumentsMax = 0;
|
||||
this.formatType = {
|
||||
def: -1,
|
||||
noneFormat: -2
|
||||
};
|
||||
this.numFormat = this.formatType.def;
|
||||
}
|
||||
cFALSE.prototype = Object.create(cBaseFunction.prototype);
|
||||
cFALSE.prototype.Calculate = function () {
|
||||
return this.value = new cBool(false);
|
||||
};
|
||||
cFALSE.prototype.getInfo = function () {
|
||||
return {
|
||||
name: this.name,
|
||||
args: "()"
|
||||
};
|
||||
};
|
||||
function cIF() {
|
||||
this.name = "IF";
|
||||
this.type = cElementType.func;
|
||||
this.value = null;
|
||||
this.argumentsMin = 1;
|
||||
this.argumentsCurrent = 0;
|
||||
this.argumentsMax = 3;
|
||||
this.formatType = {
|
||||
def: -1,
|
||||
noneFormat: -2
|
||||
};
|
||||
this.numFormat = this.formatType.def;
|
||||
}
|
||||
cIF.prototype = Object.create(cBaseFunction.prototype);
|
||||
cIF.prototype.Calculate = function (arg) {
|
||||
var arg0 = arg[0],
|
||||
arg1 = arg[1],
|
||||
arg2 = arg[2];
|
||||
if (arg0 instanceof cArray) {
|
||||
arg0 = arg0.getElement(0);
|
||||
}
|
||||
if (arg1 instanceof cArray) {
|
||||
arg1 = arg1.getElement(0);
|
||||
}
|
||||
if (arg2 instanceof cArray) {
|
||||
arg2 = arg2.getElement(0);
|
||||
}
|
||||
if (arg0 instanceof cError) {
|
||||
return this.value = arg0;
|
||||
} else {
|
||||
arg0 = arg0.tocBool();
|
||||
if (arg0 instanceof cString) {
|
||||
return this.value = new cError(cErrorType.wrong_value_type);
|
||||
} else {
|
||||
if (arg0.value) {
|
||||
return this.value = arg1 ? arg1 instanceof cEmpty ? new cNumber(0) : arg1 : new cBool(true);
|
||||
} else {
|
||||
return this.value = arg2 ? arg2 instanceof cEmpty ? new cNumber(0) : arg2 : new cBool(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
cIF.prototype.getInfo = function () {
|
||||
return {
|
||||
name: this.name,
|
||||
args: "(logical_test, value_if_true, value_if_false)"
|
||||
};
|
||||
};
|
||||
function cIFERROR() {
|
||||
this.name = "IFERROR";
|
||||
this.type = cElementType.func;
|
||||
this.value = null;
|
||||
this.argumentsMin = 2;
|
||||
this.argumentsCurrent = 0;
|
||||
this.argumentsMax = 2;
|
||||
this.formatType = {
|
||||
def: -1,
|
||||
noneFormat: -2
|
||||
};
|
||||
this.numFormat = this.formatType.def;
|
||||
}
|
||||
cIFERROR.prototype = Object.create(cBaseFunction.prototype);
|
||||
cIFERROR.prototype.Calculate = function (arg) {
|
||||
var arg0 = arg[0];
|
||||
if (arg0 instanceof cArray) {
|
||||
arg0 = arg0.getElement(0);
|
||||
}
|
||||
if (arg0 instanceof cRef || arg0 instanceof cRef3D) {
|
||||
arg0 = arg0.getValue();
|
||||
}
|
||||
if (arg0 instanceof cArea || arg0 instanceof cArea3D) {
|
||||
arg0 = arg0.cross(arguments[1].first);
|
||||
}
|
||||
if (arg0 instanceof cError) {
|
||||
return this.value = arg[1] instanceof cArray ? arg[1].getElement(0) : arg[1];
|
||||
} else {
|
||||
return this.value = arg[0];
|
||||
}
|
||||
};
|
||||
cIFERROR.prototype.getInfo = function () {
|
||||
return {
|
||||
name: this.name,
|
||||
args: "(value, value_if_error)"
|
||||
};
|
||||
};
|
||||
function cNOT() {
|
||||
this.name = "NOT";
|
||||
this.type = cElementType.func;
|
||||
this.value = null;
|
||||
this.argumentsMin = 1;
|
||||
this.argumentsCurrent = 0;
|
||||
this.argumentsMax = 1;
|
||||
this.formatType = {
|
||||
def: -1,
|
||||
noneFormat: -2
|
||||
};
|
||||
this.numFormat = this.formatType.def;
|
||||
}
|
||||
cNOT.prototype = Object.create(cBaseFunction.prototype);
|
||||
cNOT.prototype.Calculate = function (arg) {
|
||||
var arg0 = arg[0];
|
||||
if (arg0 instanceof cArray) {
|
||||
arg0 = arg0.getElement(0);
|
||||
}
|
||||
if (arg0 instanceof cArea || arg0 instanceof cArea3D) {
|
||||
arg0 = arg0.cross(arguments[1].first);
|
||||
}
|
||||
if (arg0 instanceof cString) {
|
||||
var res = arg0.tocBool();
|
||||
if (res instanceof cString) {
|
||||
return this.value = new cError(cErrorType.wrong_value_type);
|
||||
} else {
|
||||
return this.value = new cBool(!res.value);
|
||||
}
|
||||
} else {
|
||||
if (arg0 instanceof cError) {
|
||||
return this.value = arg0;
|
||||
} else {
|
||||
return this.value = new cBool(!arg0.tocBool().value);
|
||||
}
|
||||
}
|
||||
};
|
||||
cNOT.prototype.getInfo = function () {
|
||||
return {
|
||||
name: this.name,
|
||||
args: "(logical)"
|
||||
};
|
||||
};
|
||||
function cOR() {
|
||||
this.name = "OR";
|
||||
this.type = cElementType.func;
|
||||
this.value = null;
|
||||
this.argumentsMin = 1;
|
||||
this.argumentsCurrent = 0;
|
||||
this.argumentsMax = 255;
|
||||
this.formatType = {
|
||||
def: -1,
|
||||
noneFormat: -2
|
||||
};
|
||||
this.numFormat = this.formatType.def;
|
||||
}
|
||||
cOR.prototype = Object.create(cBaseFunction.prototype);
|
||||
cOR.prototype.Calculate = function (arg) {
|
||||
var argResult = null;
|
||||
for (var i = 0; i < arg.length; i++) {
|
||||
if (arg[i] instanceof cArea || arg[i] instanceof cArea3D) {
|
||||
var argArr = arg[i].getValue();
|
||||
for (var j = 0; j < argArr.length; j++) {
|
||||
if (argArr[j] instanceof cError) {
|
||||
return this.value = argArr[j];
|
||||
} else {
|
||||
if (argArr[j] instanceof cString || argArr[j] instanceof cEmpty) {
|
||||
if (argResult === null) {
|
||||
argResult = argArr[j].tocBool();
|
||||
} else {
|
||||
argResult = new cBool(argResult.value || argArr[j].tocBool().value);
|
||||
}
|
||||
if (argResult.value === true) {
|
||||
return this.value = new cBool(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (arg[i] instanceof cString) {
|
||||
return this.value = new cError(cErrorType.wrong_value_type);
|
||||
} else {
|
||||
if (arg[i] instanceof cError) {
|
||||
return this.value = arg[i];
|
||||
} else {
|
||||
if (arg[i] instanceof cArray) {
|
||||
arg[i].foreach(function (elem) {
|
||||
if (elem instanceof cError) {
|
||||
argResult = elem;
|
||||
return true;
|
||||
} else {
|
||||
if (elem instanceof cString || elem instanceof cEmpty) {
|
||||
return false;
|
||||
} else {
|
||||
if (argResult === null) {
|
||||
argResult = elem.tocBool();
|
||||
} else {
|
||||
argResult = new cBool(argResult.value || elem.tocBool().value);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (argResult == null) {
|
||||
argResult = arg[i].tocBool();
|
||||
} else {
|
||||
argResult = new cBool(argResult.value || arg[i].tocBool().value);
|
||||
}
|
||||
if (argResult.value === true) {
|
||||
return this.value = new cBool(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (argResult == null) {
|
||||
return this.value = new cError(cErrorType.wrong_value_type);
|
||||
}
|
||||
return this.value = argResult;
|
||||
};
|
||||
cOR.prototype.getInfo = function () {
|
||||
return {
|
||||
name: this.name,
|
||||
args: "(logical1, logical2, ...)"
|
||||
};
|
||||
};
|
||||
function cTRUE() {
|
||||
this.name = "TRUE";
|
||||
this.type = cElementType.func;
|
||||
this.value = null;
|
||||
this.argumentsMin = 0;
|
||||
this.argumentsCurrent = 0;
|
||||
this.argumentsMax = 0;
|
||||
this.formatType = {
|
||||
def: -1,
|
||||
noneFormat: -2
|
||||
};
|
||||
this.numFormat = this.formatType.def;
|
||||
}
|
||||
cTRUE.prototype = Object.create(cBaseFunction.prototype);
|
||||
cTRUE.prototype.Calculate = function () {
|
||||
return this.value = new cBool(true);
|
||||
};
|
||||
cTRUE.prototype.getInfo = function () {
|
||||
return {
|
||||
name: this.name,
|
||||
args: "()"
|
||||
};
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user