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

fix #32043

cell editor crashes when edit formula on another sheet
parent 0f76dd3f
......@@ -4883,6 +4883,17 @@ parserFormula.prototype.parseDiagramRef = function() {
return res;
};
parserFormula.prototype.getElementByPos = function(pos) {
var curPos = 0;
for (var i = 0; i < this.f.length; ++i) {
curPos += this.f[i].toString().length;
if (curPos >= pos) {
return this.f[i];
}
}
return null;
};
function parseNum(str) {
if (str.indexOf("x") > -1 || str == "" || str.match(/\s+/))//исключаем запись числа в 16-ричной форме из числа.
{
......
......@@ -710,11 +710,10 @@
};
CellEditor.prototype.formulaIsOperator = function () {
var elem;
return this.isFormula() &&
this._formula &&
( this._formula.f.length > 0 && this._formula.f[this._formula.f.length - 1].type == cElementType.operator ||
this._formula.f.length == 0 ||
this._formula.operand_expected );
(null !== (elem = this._formula.getElementByPos(this.cursorPos - 1)) && elem.type === cElementType.operator ||
null === elem || this._formula.operand_expected);
};
CellEditor.prototype.insertFormula = function ( functionName, isDefName ) {
......
......@@ -507,11 +507,13 @@
self.getWorksheet(self.model.getWorksheetIndexByName(ws)).addFormulaRange(range);
}
}, "existedRange": function(range, ws) {
if (!ws) {
self.getWorksheet().activeFormulaRange(range);
} else {
self.getWorksheet(self.model.getWorksheetIndexByName(ws)).activeFormulaRange(range);
}
var editRangeSheet = ws ? self.model.getWorksheetIndexByName(ws) : self.copyActiveSheet;
if (-1 === editRangeSheet || editRangeSheet === self.wsActive) {
self.getWorksheet().activeFormulaRange(range);
} else {
self.getWorksheet(editRangeSheet).removeFormulaRange(range);
self.getWorksheet().addFormulaRange(range);
}
}, "updateUndoRedoChanged": function(bCanUndo, bCanRedo) {
self.handlers.trigger("asc_onCanUndoChanged", bCanUndo);
self.handlers.trigger("asc_onCanRedoChanged", bCanRedo);
......
......@@ -11703,6 +11703,15 @@
}
}
};
WorksheetView.prototype.removeFormulaRange = function(range) {
this.arrActiveFormulaRangesPosition = -1;
for (var i = 0; i < this.arrActiveFormulaRanges.length; ++i) {
if (this.arrActiveFormulaRanges[i].isEqual(range)) {
this.arrActiveFormulaRanges.splice(i, 1);
return;
}
}
};
WorksheetView.prototype.cleanFormulaRanges = function () {
// Очищаем массив ячеек для текущей формулы
......
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