Commit 9a6607a3 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

Bug 24781 - Undo некорректно восстанавливает диапазон формулы после удаления...

Bug 24781 - Undo некорректно восстанавливает диапазон формулы после удаления строк, на которые ссылалась формула

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56807 954022d7-b5bf-4e40-9824-e11837661b57
parent 91f0e5a1
...@@ -3406,16 +3406,17 @@ parserFormula.prototype = { ...@@ -3406,16 +3406,17 @@ parserFormula.prototype = {
return this; return this;
}, },
setRefError:function ( wsId, cellId ) { setRefError: function (node) {
for ( var i = 0; i < this.outStack.length; i++ ) { for (var i = 0; i < this.outStack.length; i++) {
var node = this.outStack[i]; var elem = this.outStack[i];
if ( node instanceof cRef || node instanceof cArea || node instanceof cRef3D ) { if (elem instanceof cRef || elem instanceof cArea || elem instanceof cRef3D) {
if ( wsId == node.ws.getId() && cellId == node._cells ) if (node.sheetId == elem.ws.getId() && node.cellId == elem.node.cellId)
this.outStack[i] = new cError( cErrorType.bad_reference ); this.outStack[i] = new cError(cErrorType.bad_reference);
} }
else if ( node instanceof cArea3D ) { else if (elem instanceof cArea3D) {
if ( node.wsFrom == node.wsTo && wsId == node.wsFrom && cellId == node._cells ) //когда выставляется setRefError node не сдвигаются, поэтому node.cellId совпадает с elem._cells
this.outStack[i] = new cError( cErrorType.bad_reference ); if (elem.wsFrom == elem.wsTo && node.sheetId == elem.wsFrom && node.cellId == elem._cells)
this.outStack[i] = new cError(cErrorType.bad_reference);
} }
} }
}, },
...@@ -3424,109 +3425,45 @@ parserFormula.prototype = { ...@@ -3424,109 +3425,45 @@ parserFormula.prototype = {
offset - на сколько сдвигаем ячейку (offset = {offsetCol:intNumber, offsetRow:intNumber}) offset - на сколько сдвигаем ячейку (offset = {offsetCol:intNumber, offsetRow:intNumber})
cellId - какую ячейку сдвигаем cellId - какую ячейку сдвигаем
*/ */
shiftCells:function ( offset, oBBox, node, wsId, toDelete ) { shiftCells: function (node, from, to) {
for ( var i = 0; i < this.outStack.length; i++ ) { var sFromName = from.getName();
if ( this.outStack[i] instanceof cRef ) { for (var i = 0; i < this.outStack.length; i++) {
if ( this.ws.Id != wsId ) { var elem = this.outStack[i];
continue; if (elem instanceof cRef || elem instanceof cArea) {
} if (node.sheetId == elem.ws.getId() && node.cellId == elem.node.cellId) {
if ( toDelete ) { elem.value = elem._cells = node.cellId;
this.outStack[i] = new cError( cErrorType.bad_reference ); elem.range = node.getBBox().clone();
continue;
}
if ( node.cellId == this.outStack[i].node.cellId/*_cells.replace( /\$/ig, "" )*/ ) {
if ( this.outStack[i].isAbsolute ) {
this._changeOffsetHelper( this.outStack[i], offset );
}
else {
var r = this.outStack[i].getRange();
r.setOffset( offset );
var a = r.first.getID(),
b = r.last.getID();
if ( a != b )
this.outStack[i].value = this.outStack[i]._cells = a + ":" + b;
else this.outStack[i].value = this.outStack[i]._cells = a;
node.newCellId = this.outStack[i].value;
}
}
}
else if ( this.outStack[i] instanceof cRef3D ) {
if ( node.nodeId == this.outStack[i].node.nodeId /*_cells.replace( /\$/ig, "" ) && this.outStack[i].ws == node.sheetId*/ ) {
if ( toDelete ) {
this.outStack[i] = new cError( cErrorType.bad_reference );
continue;
}
if ( this.outStack[i].isAbsolute ) {
this._changeOffsetHelper( this.outStack[i], offset );
}
else {
var r = this.outStack[i].getRange();
r.setOffset( offset );
var a = r.first.getID(),
b = r.last.getID();
if ( a != b )
this.outStack[i].value = this.outStack[i]._cells = a + ":" + b;
else this.outStack[i].value = this.outStack[i]._cells = a;
node.newCellId = this.outStack[i].value;
}
} }
} }
else if ( this.outStack[i] instanceof cArea3D ) { else if (elem instanceof cRef3D) {
if (node.sheetId == elem.ws.getId() && node.cellId == elem.node.cellId) {
if ( this.outStack[i].wsFrom.Id == this.outStack[i].wsTo.Id == node.sheetId && node.cellId == this.outStack[i]._cells.replace( /\$/ig, "" ) ) { elem.value = elem._cells = node.cellId;
if ( this.outStack[i].isAbsolute ) {
this._changeOffsetHelper( this.outStack[i], offset );
}
else {
var r = this.outStack[i].getRange();
r[0].setOffset( offset );
this.outStack[i].value = this.outStack[i]._cells = r[0].getName();
node.newCellId = this.outStack[i].value;
}
} }
} }
else if ( this.outStack[i] instanceof cArea ) { else if (elem instanceof cArea3D) {
//node.cellId содержит уже сдвинутое значение
if ( this.ws.Id != wsId ) { if (elem.wsFrom == elem.wsTo && node.sheetId == elem.wsFrom && sFromName == elem._cells) {
continue; elem.value = elem._cells = node.cellId;
}
if ( toDelete ) {
this.outStack[i] = new cError( cErrorType.bad_reference );
continue;
}
if ( node.cellId == this.outStack[i].node.cellId /*_cells.replace( /\$/ig, "" )*/ ) {
if ( this.outStack[i].isAbsolute ) {
this._changeOffsetHelper( this.outStack[i], offset );
}
else {
var r = this.outStack[i].getRange();
r.setOffset( offset );
this.outStack[i].value = this.outStack[i]._cells = r.getName();
}
node.newCellId = this.outStack[i].value;
} }
} }
} }
}, },
stretchArea: function (node, bboxTo, sNewName) { stretchArea: function (node, from, to) {
//todo absolute var sFromName = from.getName();
for ( var i = 0; i < this.outStack.length; i++ ) { for (var i = 0; i < this.outStack.length; i++) {
var elem = this.outStack[i]; var elem = this.outStack[i];
if ( elem instanceof cArea ) { if (elem instanceof cArea) {
if ( elem._cells.replace( /\$/ig, "" ) == node.cellId ) { if (node.sheetId == elem.ws.getId() && node.cellId == elem.node.cellId) {
elem.value = elem._cells = sNewName; elem.value = elem._cells = node.cellId;
elem.range = bboxTo.clone(); elem.range = node.getBBox().clone();
} }
} }
else if (elem instanceof cArea3D) {
//node.cellId содержит уже сдвинутое значение
if (elem.wsFrom == elem.wsTo && node.sheetId == elem.wsFrom && sFromName == elem._cells)
elem.value = elem._cells = node.cellId;
}
} }
}, },
......
...@@ -2947,13 +2947,10 @@ UndoRedoWoorksheet.prototype = { ...@@ -2947,13 +2947,10 @@ UndoRedoWoorksheet.prototype = {
nCol = Data.nCol; nCol = Data.nCol;
if(bUndo) if(bUndo)
{ {
cell = ws._getCellNoEmpty(nRow, nCol); var oCellAddres = new CellAddress(nRow, nCol, 0);
if(cell) var node = ws.workbook.dependencyFormulas.addNode(ws.getId(), oCellAddres.getID());
{ if (node)
var node = ws.workbook.dependencyFormulas.getNode(ws.getId(), cell.getName()); node.setFormula(Data.sFormula, false, true);
if(node)
node.setFormula(Data.sFormula, false, true);
}
} }
} }
else if(historyitem_Worksheet_ColProp == Type) else if(historyitem_Worksheet_ColProp == Type)
......
This diff is collapsed.
...@@ -61,9 +61,9 @@ function shiftSort(a, b, bAsc, bRow) ...@@ -61,9 +61,9 @@ function shiftSort(a, b, bAsc, bRow)
if(null == a.to && null == b.to) if(null == a.to && null == b.to)
nRes = 0; nRes = 0;
else if(null == a.to) else if(null == a.to)
nRes = 1;
else if(null == b.to)
nRes = -1; nRes = -1;
else if(null == b.to)
nRes = 1;
} }
else else
{ {
......
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