Commit b0b6d9fe authored by Alexander.Trofimov's avatar Alexander.Trofimov

delete formatType from all functions

delete numFormat from all functions -> move to prototype
parent 59d8975a
This diff is collapsed.
......@@ -32,143 +32,100 @@
"use strict";
(
/**
* @param {Window} window
* @param {undefined} undefined
(/**
* @param {Window} window
* @param {undefined} undefined
*/
function (window, undefined) {
function (window, undefined) {
var cElementType = AscCommonExcel.cElementType;
var cBaseFunction = AscCommonExcel.cBaseFunction;
var cFormulaFunctionGroup = AscCommonExcel.cFormulaFunctionGroup;
cFormulaFunctionGroup['Cube'] = cFormulaFunctionGroup['Cube'] || [];
cFormulaFunctionGroup['Cube'].push(
cCUBEKPIMEMBER,
cCUBEMEMBER,
cCUBEMEMBERPROPERTY,
cCUBERANKEDMEMBER,
cCUBESET,
cCUBESETCOUNT,
cCUBEVALUE
);
function cCUBEKPIMEMBER() {
cFormulaFunctionGroup['Cube'].push(cCUBEKPIMEMBER, cCUBEMEMBER, cCUBEMEMBERPROPERTY, cCUBERANKEDMEMBER, cCUBESET,
cCUBESETCOUNT, cCUBEVALUE);
/** @constructor */
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 );
cCUBEKPIMEMBER.prototype = Object.create(cBaseFunction.prototype);
function cCUBEMEMBER() {
/** @constructor */
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);
cCUBEMEMBER.prototype = Object.create( cBaseFunction.prototype );
function cCUBEMEMBERPROPERTY() {
/** @constructor */
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 );
cCUBEMEMBERPROPERTY.prototype = Object.create(cBaseFunction.prototype);
function cCUBERANKEDMEMBER() {
/** @constructor */
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);
cCUBERANKEDMEMBER.prototype = Object.create( cBaseFunction.prototype );
function cCUBESET() {
/** @constructor */
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 );
cCUBESET.prototype = Object.create(cBaseFunction.prototype);
function cCUBESETCOUNT() {
/** @constructor */
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);
cCUBESETCOUNT.prototype = Object.create( cBaseFunction.prototype );
function cCUBEVALUE() {
/** @constructor */
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 );
cCUBEVALUE.prototype = Object.create(cBaseFunction.prototype);
})(window);
......@@ -32,100 +32,99 @@
"use strict";
(
/**
* @param {Window} window
* @param {undefined} undefined
*/
function (window, undefined) {
(/**
* @param {Window} window
* @param {undefined} undefined
*/
function (window, undefined) {
var cBaseFunction = AscCommonExcel.cBaseFunction;
var cFormulaFunctionGroup = AscCommonExcel.cFormulaFunctionGroup;
cFormulaFunctionGroup['Database'] = cFormulaFunctionGroup['Database'] || [];
cFormulaFunctionGroup['Database'].push(
cDAVERAGE,
cDCOUNT,
cDCOUNTA,
cDGET,
cDMAX,
cDMIN,
cDPRODUCT,
cDSTDEV,
cDSTDEVP,
cDSUM,
cDVAR,
cDVARP
);
cFormulaFunctionGroup['Database'].push(cDAVERAGE, cDCOUNT, cDCOUNTA, cDGET, cDMAX, cDMIN, cDPRODUCT, cDSTDEV,
cDSTDEVP, cDSUM, cDVAR, cDVARP);
function cDAVERAGE() {
cBaseFunction.call( this, "DAVERAGE" );
}
/** @constructor */
function cDAVERAGE() {
cBaseFunction.call(this, "DAVERAGE");
}
cDAVERAGE.prototype = Object.create( cBaseFunction.prototype );
cDAVERAGE.prototype = Object.create(cBaseFunction.prototype);
function cDCOUNT() {
cBaseFunction.call( this, "DCOUNT" );
}
/** @constructor */
function cDCOUNT() {
cBaseFunction.call(this, "DCOUNT");
}
cDCOUNT.prototype = Object.create( cBaseFunction.prototype );
cDCOUNT.prototype = Object.create(cBaseFunction.prototype);
function cDCOUNTA() {
cBaseFunction.call( this, "DCOUNTA" );
}
/** @constructor */
function cDCOUNTA() {
cBaseFunction.call(this, "DCOUNTA");
}
cDCOUNTA.prototype = Object.create( cBaseFunction.prototype );
cDCOUNTA.prototype = Object.create(cBaseFunction.prototype);
function cDGET() {
cBaseFunction.call( this, "DGET" );
}
/** @constructor */
function cDGET() {
cBaseFunction.call(this, "DGET");
}
cDGET.prototype = Object.create( cBaseFunction.prototype );
cDGET.prototype = Object.create(cBaseFunction.prototype);
function cDMAX() {
cBaseFunction.call( this, "DMAX" );
}
/** @constructor */
function cDMAX() {
cBaseFunction.call(this, "DMAX");
}
cDMAX.prototype = Object.create( cBaseFunction.prototype );
cDMAX.prototype = Object.create(cBaseFunction.prototype);
function cDMIN() {
cBaseFunction.call( this, "DMIN" );
}
/** @constructor */
function cDMIN() {
cBaseFunction.call(this, "DMIN");
}
cDMIN.prototype = Object.create( cBaseFunction.prototype );
cDMIN.prototype = Object.create(cBaseFunction.prototype);
function cDPRODUCT() {
cBaseFunction.call( this, "DPRODUCT" );
}
/** @constructor */
function cDPRODUCT() {
cBaseFunction.call(this, "DPRODUCT");
}
cDPRODUCT.prototype = Object.create( cBaseFunction.prototype );
cDPRODUCT.prototype = Object.create(cBaseFunction.prototype);
function cDSTDEV() {
cBaseFunction.call( this, "DSTDEV" );
}
/** @constructor */
function cDSTDEV() {
cBaseFunction.call(this, "DSTDEV");
}
cDSTDEV.prototype = Object.create( cBaseFunction.prototype );
cDSTDEV.prototype = Object.create(cBaseFunction.prototype);
function cDSTDEVP() {
cBaseFunction.call( this, "DSTDEVP" );
}
/** @constructor */
function cDSTDEVP() {
cBaseFunction.call(this, "DSTDEVP");
}
cDSTDEVP.prototype = Object.create( cBaseFunction.prototype );
cDSTDEVP.prototype = Object.create(cBaseFunction.prototype);
function cDSUM() {
cBaseFunction.call( this, "DSUM" );
}
/** @constructor */
function cDSUM() {
cBaseFunction.call(this, "DSUM");
}
cDSUM.prototype = Object.create( cBaseFunction.prototype );
cDSUM.prototype = Object.create(cBaseFunction.prototype);
function cDVAR() {
cBaseFunction.call( this, "DVAR" );
}
/** @constructor */
function cDVAR() {
cBaseFunction.call(this, "DVAR");
}
cDVAR.prototype = Object.create( cBaseFunction.prototype );
cDVAR.prototype = Object.create(cBaseFunction.prototype);
function cDVARP() {
cBaseFunction.call( this, "DVARP" );
}
/** @constructor */
function cDVARP() {
cBaseFunction.call(this, "DVARP");
}
cDVARP.prototype = Object.create( cBaseFunction.prototype );
cDVARP.prototype = Object.create(cBaseFunction.prototype);
})(window);
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -102,11 +102,6 @@
this.argumentsMin = 2;
this.argumentsCurrent = 0;
this.argumentsMax = 5;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cADDRESS.prototype = Object.create(cBaseFunction.prototype);
......@@ -231,11 +226,6 @@
this.argumentsMin = 2;
this.argumentsCurrent = 0;
this.argumentsMax = 30;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cCHOOSE.prototype = Object.create(cBaseFunction.prototype);
......@@ -275,11 +265,6 @@
this.argumentsMin = 0;
this.argumentsCurrent = 0;
this.argumentsMax = 1;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cCOLUMN.prototype = Object.create(cBaseFunction.prototype);
......@@ -311,11 +296,6 @@
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 1;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cCOLUMNS.prototype = Object.create(cBaseFunction.prototype);
......@@ -352,11 +332,6 @@
this.argumentsMin = 3;
this.argumentsCurrent = 0;
this.argumentsMax = 4;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cHLOOKUP.prototype = Object.create(cBaseFunction.prototype);
......@@ -473,11 +448,6 @@
this.argumentsMin = 2;
this.argumentsCurrent = 0;
this.argumentsMax = 4;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cINDEX.prototype = Object.create(cBaseFunction.prototype);
......@@ -560,11 +530,6 @@
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 2;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cINDIRECT.prototype = Object.create(cBaseFunction.prototype);
......@@ -640,11 +605,6 @@
this.argumentsMin = 2;
this.argumentsCurrent = 0;
this.argumentsMax = 3;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cLOOKUP.prototype = Object.create(cBaseFunction.prototype);
......@@ -791,11 +751,6 @@
this.argumentsMin = 2;
this.argumentsCurrent = 0;
this.argumentsMax = 3;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cMATCH.prototype = Object.create(cBaseFunction.prototype);
......@@ -902,11 +857,6 @@
this.argumentsMin = 3;
this.argumentsCurrent = 0;
this.argumentsMax = 5;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cOFFSET.prototype = Object.create(cBaseFunction.prototype);
......@@ -1008,11 +958,6 @@
this.argumentsMin = 0;
this.argumentsCurrent = 0;
this.argumentsMax = 1;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cROW.prototype = Object.create(cBaseFunction.prototype);
......@@ -1044,11 +989,6 @@
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 1;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cROWS.prototype = Object.create(cBaseFunction.prototype);
......@@ -1085,14 +1025,10 @@
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 1;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.noneFormat;
}
cTRANSPOSE.prototype = Object.create(cBaseFunction.prototype);
cTRANSPOSE.prototype.numFormat = AscCommonExcel.cNumFormatNone;
cTRANSPOSE.prototype.Calculate = function (arg) {
function TransposeMatrix(A) {
......@@ -1223,11 +1159,6 @@
this.argumentsMin = 3;
this.argumentsCurrent = 0;
this.argumentsMax = 4;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cVLOOKUP.prototype = Object.create(cBaseFunction.prototype);
......
......@@ -46,7 +46,6 @@ function (window, undefined) {
var FormulaSeparators = AscCommon.FormulaSeparators;
var parserHelp = AscCommon.parserHelp;
var g_oFormatParser = AscCommon.g_oFormatParser;
var g_oCellAddressUtils = AscCommon.g_oCellAddressUtils;
var CellAddress = AscCommon.CellAddress;
var c_oAscError = Asc.c_oAscError;
......@@ -2188,11 +2187,6 @@ cUndefined.prototype = Object.create( cBaseType.prototype );
this.isRightAssociative = false;
this.argumentsCurrent = (argumentCount !== undefined) ? argumentCount : 2;
this.value = null;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cBaseOperator.prototype.getArguments = function () {
......@@ -2241,13 +2235,10 @@ cUndefined.prototype = Object.create( cBaseType.prototype );
this.argumentsMin = argMin ? argMin : 0;
this.argumentsCurrent = 0;
this.argumentsMax = argMax ? argMax : 255;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
// this.isXLFN = rx_sFuncPref.test(this.name);
}
cBaseFunction.prototype.numFormat = AscCommonExcel.cNumFormatFirstCell;
cBaseFunction.prototype.Calculate = function () {
this.value = new cError(cErrorType.wrong_name);
return this.value;
......@@ -4762,7 +4753,7 @@ parserFormula.prototype.parse = function(local, digitDelim) {
}
};
parserFormula.prototype.calculate = function(opt_defName, opt_range) {
parserFormula.prototype.calculate = function (opt_defName, opt_range) {
if (this.isCalculate) {
this.value = new cError(cErrorType.bad_reference);
this._endCalculate();
......@@ -4790,7 +4781,7 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
if (currentElement.name == "(") {
continue;
}
if (currentElement.type == cElementType.operator || currentElement.type == cElementType.func) {
if (currentElement.type === cElementType.operator || currentElement.type === cElementType.func) {
if (elemArr.length < currentElement.getArguments()) {
elemArr = [];
this.value = new cError(cErrorType.unsupported_function);
......@@ -4802,16 +4793,16 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
arg.unshift(elemArr.pop());
}
_tmp = currentElement.Calculate(arg, rangeCell, opt_defName, this.ws.getId());
if (_tmp.numFormat !== undefined && _tmp.numFormat !== null) {
numFormat = _tmp.numFormat; //> numFormat ? _tmp.numFormat : numFormat;
} else if (numFormat < 0 || currentElement.numFormat < currentElement.formatType.def) {
if (null != _tmp.numFormat) {
numFormat = _tmp.numFormat;
} else if (0 > numFormat || AscCommonExcel.cNumFormatNone === currentElement.numFormat) {
numFormat = currentElement.numFormat;
}
elemArr.push(_tmp);
}
} else if (currentElement.type == cElementType.name || currentElement.type == cElementType.name3D) {
} else if (currentElement.type === cElementType.name || currentElement.type === cElementType.name3D) {
elemArr.push(currentElement.Calculate(arg, rangeCell));
} else if (currentElement.type == cElementType.table) {
} else if (currentElement.type === cElementType.table) {
elemArr.push(currentElement.toRef(rangeCell.getBBox0()));
} else {
elemArr.push(currentElement);
......@@ -4822,7 +4813,7 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
this._endCalculate();
return this.value;
};
};
parserFormula.prototype._endCalculate = function() {
if (this.parent && this.parent.onFormulaEvent) {
this.parent.onFormulaEvent(AscCommon.c_oNotifyParentType.EndCalculate);
......@@ -5605,6 +5596,8 @@ function rtl_math_erfc( x ) {
window['AscCommonExcel'].c_DateCorrectConst = c_Date1900Const;
window['AscCommonExcel'].c_sPerDay = c_sPerDay;
window['AscCommonExcel'].c_msPerDay = c_msPerDay;
window['AscCommonExcel'].cNumFormatFirstCell = -1;
window['AscCommonExcel'].cNumFormatNone = -2;
window['AscCommonExcel'].cNumber = cNumber;
window['AscCommonExcel'].cString = cString;
......
......@@ -5263,12 +5263,11 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
Cell.prototype._adjustCellFormat = function() {
if (this.formulaParsed && this.formulaParsed.value && this.formulaParsed.outStack) {
var valueCalc = this.formulaParsed.value;
if (valueCalc.numFormat !== undefined && valueCalc.numFormat >= 0) {
if (0 <= valueCalc.numFormat) {
if (aStandartNumFormatsId[this.getNumFormatStr()] == 0) {
this.setNumFormat(aStandartNumFormats[valueCalc.numFormat]);
}
}
else if (valueCalc.numFormat !== undefined && valueCalc.numFormat == -1) {
} else if (AscCommonExcel.cNumFormatFirstCell === valueCalc.numFormat) {
// ищет в формуле первый рэндж и устанавливает формат ячейки как формат первой ячейки в рэндже
for (var i = 0, length = this.formulaParsed.outStack.length; i < length; i++) {
var elem = this.formulaParsed.outStack[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