Commit b9c29090 authored by konovalovsergey's avatar konovalovsergey

fix bug 19769

parent 657a1cce
......@@ -4938,13 +4938,13 @@ parserFormula.prototype.parse = function(local, digitDelim) {
};
/* Для обратной сборки функции иногда необходимо поменять ссылки на ячейки */
parserFormula.prototype.changeOffset = function (offset) {//offset = AscCommonExcel.CRangeOffset
parserFormula.prototype.changeOffset = function (offset, canResize) {//offset = AscCommonExcel.CRangeOffset
for (var i = 0; i < this.outStack.length; i++) {
this.changeOffsetElem(this.outStack[i], this.outStack, i, offset);
this.changeOffsetElem(this.outStack[i], this.outStack, i, offset, canResize);
}
return this;
};
parserFormula.prototype.changeOffsetElem = function(elem, container, index, offset) {//offset =
parserFormula.prototype.changeOffsetElem = function(elem, container, index, offset, canResize) {//offset =
// AscCommonExcel.CRangeOffset
var range, bbox = null, isErr = false;
if (cElementType.cell === elem.type || cElementType.cell3D === elem.type ||
......@@ -4959,7 +4959,7 @@ parserFormula.prototype.parse = function(local, digitDelim) {
bbox = elem.getBBox0();
}
if (bbox) {
if (bbox.setOffsetWithAbs(offset)) {
if (bbox.setOffsetWithAbs(offset, canResize)) {
isErr = false;
if (cElementType.cellsRange3D === elem.type) {
elem.bbox = bbox;
......
......@@ -4080,13 +4080,13 @@
row.c[j] = oTempCell;
if ( oTempCell.formulaParsed ) {
if(copyRange) {
oTempCell.formulaParsed.removeDependencies();
oTempCell.formulaParsed.changeOffset(offset);
oTempCell.formulaParsed.Formula = oTempCell.formulaParsed.assemble(true);
this.workbook.dependencyFormulas.addToBuildDependencyCell(oTempCell);
} else {
this.workbook.dependencyFormulas.addToChangedCell(oTempCell);
//todo rework after clone formulaParsed unparsed
oTempCell.formulaParsed.parse();
History.TurnOff();
oTempCell.changeOffset(offset, false, true);
History.TurnOn();
}
this.workbook.dependencyFormulas.addToBuildDependencyCell(oTempCell);
}
}
}
......@@ -4863,16 +4863,17 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
cell.removeHyperlink();
}
};
Cell.prototype.setFormula = function(formula, bHistoryUndo) {
Cell.prototype.setFormulaTemplate = function(bHistoryUndo, action) {
var DataOld = null;
var DataNew = null;
if (History.Is_On())
DataOld = this.getValueData();
this.removeDependencies();
this.oValue.clean();
this.formulaParsed = new parserFormula(formula, this, this.ws);
this.ws.workbook.dependencyFormulas.addToBuildDependencyCell(this);
if (this.formulaParsed) {
this.formulaParsed.removeDependencies();
}
action(this);
if (History.Is_On()) {
DataNew = this.getValueData();
......@@ -4882,6 +4883,19 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
}
};
Cell.prototype.setFormula = function(formula, bHistoryUndo) {
this.setFormulaTemplate(bHistoryUndo, function(cell){
cell.formulaParsed = new parserFormula(formula, cell, cell.ws);
cell.ws.workbook.dependencyFormulas.addToBuildDependencyCell(cell);
});
};
Cell.prototype.changeOffset = function(offset, canResize, bHistoryUndo) {
this.setFormulaTemplate(bHistoryUndo, function(cell){
cell.formulaParsed.changeOffset(offset, canResize);
cell.formulaParsed.Formula = cell.formulaParsed.assemble(true);
cell.formulaParsed.buildDependencies();
});
};
Cell.prototype.removeDependencies = function() {
//удаляем сторое значение
if (this.formulaParsed) {
......@@ -8005,8 +8019,8 @@ Range.prototype._foreachNoEmpty=function(action, excludeHiddenRows){
}
var oUndoRedoBBox = new UndoRedoData_BBox({r1:nRowFirst0, c1:nColFirst0, r2:nLastRow0, c2:nLastCol0});
oRes = new AscCommonExcel.UndoRedoData_SortData(oUndoRedoBBox, aSortData);
History.Add(AscCommonExcel.g_oUndoRedoWorksheet, AscCH.historyitem_Worksheet_Sort, this.worksheet.getId(), new Asc.Range(0, nRowFirst0, gc_nMaxCol0, nLastRow0), oRes);
this._sortByArray(oUndoRedoBBox, aSortData);
History.Add(AscCommonExcel.g_oUndoRedoWorksheet, AscCH.historyitem_Worksheet_Sort, this.worksheet.getId(), new Asc.Range(0, nRowFirst0, gc_nMaxCol0, nLastRow0), oRes);
}
this.worksheet.workbook.dependencyFormulas.unlockRecal();
return oRes;
......@@ -8079,15 +8093,14 @@ Range.prototype._foreachNoEmpty=function(action, excludeHiddenRows){
oTempCellsTo[nIndexTo] = rowTo.c[i];
if(null != oCurCell)
{
var lastName = oCurCell.getName();
if (oCurCell.formulaParsed) {
oCurCell.changeOffset({offsetCol: 0, offsetRow: shift}, true, true);
}
oCurCell.moveVer(shift);
rowTo.c[i] = oCurCell;
if (oCurCell.formulaParsed) {
History.TurnOff();
var _p_ = oCurCell.formulaParsed.clone(null, oCurCell, this);
var assemb = _p_.changeOffset({offsetCol: 0, offsetRow: shift}).assemble(true);
oCurCell.setFormula(assemb);
History.TurnOn();
if (oCurCell && oCurCell.getFormula()) {
//for #Ref
this.worksheet.workbook.dependencyFormulas.addToChangedCell(oCurCell);
}
}
else
......
......@@ -502,7 +502,7 @@
this.r1 = Math.min(this.r1, r);
this.r2 = Math.max(this.r2, r);
};
Range.prototype.setOffsetWithAbs = function(offset) {
Range.prototype.setOffsetWithAbs = function(offset, canResize) {
var temp;
var offsetRow = offset.offsetRow;
var offsetCol = offset.offsetCol;
......@@ -520,7 +520,9 @@
this.r1 += offsetRow;
if (this.r1 < 0) {
this.r1 = 0;
return false;
if (!canResize) {
return false;
}
}
if (this.r1 > gc_nMaxRow0) {
this.r1 = gc_nMaxRow0;
......@@ -531,7 +533,9 @@
this.c1 += offsetCol;
if (this.c1 < 0) {
this.c1 = 0;
return false;
if (!canResize) {
return false;
}
}
if (this.c1 > gc_nMaxCol0) {
this.c1 = gc_nMaxCol0;
......@@ -546,7 +550,9 @@
}
if (this.r2 > gc_nMaxRow0) {
this.r2 = gc_nMaxRow0;
return false;
if (!canResize) {
return false;
}
}
}
if (!isAbsCol2) {
......@@ -557,7 +563,9 @@
}
if (this.c2 > gc_nMaxCol0) {
this.c2 = gc_nMaxCol0;
return false;
if (!canResize) {
return false;
}
}
}
//switch abs flag
......@@ -805,7 +813,7 @@
Range.call(this, 0, 0, 0, 0);
}
}
Range3D.prototype = Object.create(Range.prototype);
Range3D.prototype = Object.create(Range.prototype);
Range3D.prototype.constructor = Range3D;
Range3D.prototype.isIntersect = function () {
var oRes = true;
......@@ -1107,7 +1115,7 @@
this._updateAdditionalData();
}
ActiveRange.prototype = Object.create(Range.prototype);
ActiveRange.prototype = Object.create(Range.prototype);
ActiveRange.prototype.constructor = ActiveRange;
ActiveRange.prototype.assign = function () {
Range.prototype.assign.apply(this, arguments);
......@@ -1239,7 +1247,7 @@
this.refType2 = referenceType.R;
}
FormulaRange.prototype = Object.create(Range.prototype);
FormulaRange.prototype = Object.create(Range.prototype);
FormulaRange.prototype.constructor = FormulaRange;
FormulaRange.prototype.clone = function () {
var oRes = new FormulaRange(Range.prototype.clone.apply(this, arguments));
......
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