diff --git a/cell/model/DataValidation.js b/cell/model/DataValidation.js index 2875391184..5a0ac4a907 100644 --- a/cell/model/DataValidation.js +++ b/cell/model/DataValidation.js @@ -76,43 +76,20 @@ GreaterThanOrEqual: 7 }; - var EFormulaType = { - None: 0, - Whole: 1, - Decimal: 2, - Formula: 3 - }; + function checkIntegerType(val) { + return val && AscCommonExcel.cElementType.number === val.type; + } function CDataFormula(value) { this.text = value; this._formula = null; - this.type = EFormulaType.None; } - CDataFormula.prototype._init = function (vt, ws) { + CDataFormula.prototype._init = function (ws) { if (this._formula || !this.text) { return; } - var value = null; - if (vt !== EDataValidationType.Custom && vt !== EDataValidationType.List) { - value = Number(this.text); - if (!isNaN(value)) { - if (vt !== EDataValidationType.Decimal && vt !== EDataValidationType.Time) { - if (Number.isInteger(value)) { - this.type = EFormulaType.Whole; - this._formula = value; - return; - } - } else { - this.type = EFormulaType.Decimal; - this._formula = value; - return; - } - } - } - - this.type = EFormulaType.Formula; this._formula = new AscCommonExcel.parserFormula(this.text, this, ws); this._formula.parse(); this._formula.buildDependencies(); @@ -122,13 +99,11 @@ this.text = eventData.assemble; } }; - CDataFormula.prototype.getValue = function(vt, ws, returnRaw) { - this._init(vt, ws); - if (EFormulaType.Formula === this.type) { - var res = this._formula.calculate(); - return returnRaw ? this._formula.simplifyRefType(res).getValue() : res; - } - return this._formula; + CDataFormula.prototype.getValue = function(ws, returnRaw) { + this._init(ws); + var activeCell = ws.selectionRange.activeCell; + var res = this._formula.calculate(null, new Asc.Range(activeCell.col, activeCell.row, activeCell.col, activeCell.row)); + return returnRaw ? this._formula.simplifyRefType(res) : res; }; function CDataValidation() { @@ -155,10 +130,10 @@ CDataValidation.prototype._init = function (ws) { if (this.formula1) { - this.formula1._init(this.type, ws); + this.formula1._init(ws); } if (this.formula2) { - this.formula2._init(this.type, ws); + this.formula2._init(ws); } }; CDataValidation.prototype.clone = function() { @@ -208,25 +183,24 @@ if (EDataValidationType.List === this.type) { var list = this._getListValues(ws); - var values = list[0]; - if (!values) { + var aValue = list[0]; + if (!aValue) { return false; } - var datas = list[1]; - if (datas) { - for (var i = 0; i < datas.length; ++i) { - + var aData = list[1]; + if (aData) { + for (var i = 0; i < aData.length; ++i) { + if (aData[i].isEqualCell(cell)) { + return true; + } } } else { - return -1 !== datas.indexOf(val); - } - for (var i = 0; i < datas.length; ++i) { - if (datas[i].isEqualCell(cell)) { - return true; - } + return -1 !== aValue.indexOf(val); } } else if (EDataValidationType.Custom === this.type) { - return true; + var v = this.formula1 && this.formula1.getValue(ws, true); + v = v && v.tocBool(); + return !!(v && AscCommonExcel.cElementType.bool === v.type && v.toBool()); } else { if (EDataValidationType.TextLength === this.type) { val = val.length; @@ -241,16 +215,20 @@ } } - var res = false; + var v1 = this.formula1 && this.formula1.getValue(ws, true); + var v2 = this.formula2 && this.formula2.getValue(ws, true); + if (!checkIntegerType(v1)) { + return false; + } + v1 = v1.toNumber(); - var v1 = this.formula1 && this.formula1.getValue(this.type, ws, true); - var v2 = this.formula2 && this.formula2.getValue(this.type, ws, true); + var res = false; switch (this.operator) { case EDataValidationOperator.Between: - res = v1 <= val && val <= v2; + res = checkIntegerType(v2) && v1 <= val && val <= v2.toNumber(); break; case EDataValidationOperator.NotBetween: - res = !(v1 <= val && val <= v2); + res = checkIntegerType(v2) && !(v1 <= val && val <= v2.toNumber()); break; case EDataValidationOperator.Equal: res = v1 === val; @@ -277,7 +255,7 @@ }; CDataValidation.prototype._getListValues = function (ws) { var aValue, aData; - var list = this.formula1 && this.formula1.getValue(this.type, ws, false); + var list = this.formula1 && this.formula1.getValue(ws, false); if (list && AscCommonExcel.cElementType.error !== list.type) { if (AscCommonExcel.cElementType.string === list.type) { aValue = list.getValue().split(AscCommon.FormulaSeparators.functionArgumentSeparatorDef); diff --git a/cell/model/FormulaObjects/parserFormula.js b/cell/model/FormulaObjects/parserFormula.js index 484c06a2f7..49510e5f16 100644 --- a/cell/model/FormulaObjects/parserFormula.js +++ b/cell/model/FormulaObjects/parserFormula.js @@ -6334,7 +6334,7 @@ function parserFormula( formula, parent, _ws ) { opt_bbox = new Asc.Range(0, 0, 0, 0); } - var elemArr = [], _tmp, numFormat = cNumFormatFirstCell, currentElement = null, bIsSpecialFunction, argumentsCount, defNameCalcArr, defNameArgCount = 0, t = this; + var elemArr = [], _tmp, numFormat = cNumFormatFirstCell, currentElement = null, bIsSpecialFunction, argumentsCount, defNameCalcArr, defNameArgCount = 0; for (var i = 0; i < this.outStack.length; i++) { currentElement = this.outStack[i]; if (currentElement.name === "(") { @@ -6462,7 +6462,6 @@ function parserFormula( formula, parent, _ws ) { if (this.parent && this.parent.onFormulaEvent) { this.parent.onFormulaEvent(AscCommon.c_oNotifyParentType.EndCalculate); } - this.calculateDefName = null; }; /* Для обратной сборки функции иногда необходимо поменять ссылки на ячейки */ diff --git a/common/Scrolls/mobileTouchManagerBase.js b/common/Scrolls/mobileTouchManagerBase.js index 3e0121db86..3a9cb660a0 100644 --- a/common/Scrolls/mobileTouchManagerBase.js +++ b/common/Scrolls/mobileTouchManagerBase.js @@ -272,7 +272,6 @@ var selectionBounds = this.LogicDocument.GetSelectionBounds(); var eps = 0.0001; if (selectionBounds && selectionBounds.Start && selectionBounds.End && - (Math.abs(selectionBounds.Start.X - selectionBounds.End.X) > eps) && (Math.abs(selectionBounds.Start.W) > eps) && (Math.abs(selectionBounds.End.W) > eps)) { diff --git a/common/libfont/map.js b/common/libfont/map.js index c3fa5b5776..c62c307134 100644 --- a/common/libfont/map.js +++ b/common/libfont/map.js @@ -1165,6 +1165,10 @@ CFontSelect.prototype = if ( sReqName == this.m_wsFontName ) return 0; + // check equals, inst + if (sReqName.replace(/[\s-,]/g, '').toLowerCase() == this.m_wsFontName.replace(/[\s-,]/g, '').toLowerCase()) + return 100; + if (-1 != sReqName.indexOf(this.m_wsFontName) || -1 != this.m_wsFontName.indexOf(sReqName)) { if (g_fontApplication.g_fontDictionary.CheckLikeFonts(this.m_wsFontName, sReqName))