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() { ...@@ -4883,6 +4883,17 @@ parserFormula.prototype.parseDiagramRef = function() {
return res; 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) { function parseNum(str) {
if (str.indexOf("x") > -1 || str == "" || str.match(/\s+/))//исключаем запись числа в 16-ричной форме из числа. if (str.indexOf("x") > -1 || str == "" || str.match(/\s+/))//исключаем запись числа в 16-ричной форме из числа.
{ {
......
...@@ -710,11 +710,10 @@ ...@@ -710,11 +710,10 @@
}; };
CellEditor.prototype.formulaIsOperator = function () { CellEditor.prototype.formulaIsOperator = function () {
var elem;
return this.isFormula() && return this.isFormula() &&
this._formula && (null !== (elem = this._formula.getElementByPos(this.cursorPos - 1)) && elem.type === cElementType.operator ||
( this._formula.f.length > 0 && this._formula.f[this._formula.f.length - 1].type == cElementType.operator || null === elem || this._formula.operand_expected);
this._formula.f.length == 0 ||
this._formula.operand_expected );
}; };
CellEditor.prototype.insertFormula = function ( functionName, isDefName ) { CellEditor.prototype.insertFormula = function ( functionName, isDefName ) {
......
...@@ -507,10 +507,12 @@ ...@@ -507,10 +507,12 @@
self.getWorksheet(self.model.getWorksheetIndexByName(ws)).addFormulaRange(range); self.getWorksheet(self.model.getWorksheetIndexByName(ws)).addFormulaRange(range);
} }
}, "existedRange": function(range, ws) { }, "existedRange": function(range, ws) {
if (!ws) { var editRangeSheet = ws ? self.model.getWorksheetIndexByName(ws) : self.copyActiveSheet;
if (-1 === editRangeSheet || editRangeSheet === self.wsActive) {
self.getWorksheet().activeFormulaRange(range); self.getWorksheet().activeFormulaRange(range);
} else { } else {
self.getWorksheet(self.model.getWorksheetIndexByName(ws)).activeFormulaRange(range); self.getWorksheet(editRangeSheet).removeFormulaRange(range);
self.getWorksheet().addFormulaRange(range);
} }
}, "updateUndoRedoChanged": function(bCanUndo, bCanRedo) { }, "updateUndoRedoChanged": function(bCanUndo, bCanRedo) {
self.handlers.trigger("asc_onCanUndoChanged", bCanUndo); self.handlers.trigger("asc_onCanUndoChanged", bCanUndo);
......
...@@ -11703,6 +11703,15 @@ ...@@ -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 () { 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