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)
......
...@@ -45,7 +45,8 @@ function DependencyGraph( wb ) { ...@@ -45,7 +45,8 @@ function DependencyGraph( wb ) {
this.nodesCell = null; this.nodesCell = null;
this.nodesArea = null; this.nodesArea = null;
this.nodeslength = null; this.nodeslength = null;
this.bSetRefError = false; this.bSetRefError = false;
this.oChangeNodeSlave = null;
this.clear(); this.clear();
} }
DependencyGraph.prototype = { DependencyGraph.prototype = {
...@@ -177,6 +178,7 @@ DependencyGraph.prototype = { ...@@ -177,6 +178,7 @@ DependencyGraph.prototype = {
deleteNodes : function(sheetId, bbox){ deleteNodes : function(sheetId, bbox){
var bSetRefErrorOld = this.bSetRefError; var bSetRefErrorOld = this.bSetRefError;
this.bSetRefError = true; this.bSetRefError = true;
this.oChangeNodeSlave = { toDelete: {}, toMove: {} };
var nodesSheetArea = this.nodesArea[sheetId]; var nodesSheetArea = this.nodesArea[sheetId];
var oGetRes; var oGetRes;
if(nodesSheetArea) if(nodesSheetArea)
...@@ -192,6 +194,7 @@ DependencyGraph.prototype = { ...@@ -192,6 +194,7 @@ DependencyGraph.prototype = {
for(var i = 0, length = oGetRes.length; i < length; ++i) for(var i = 0, length = oGetRes.length; i < length; ++i)
nodesSheetCell.removeElement(oGetRes[i]); nodesSheetCell.removeElement(oGetRes[i]);
} }
this.changeNodeEnd();
this.bSetRefError = bSetRefErrorOld; this.bSetRefError = bSetRefErrorOld;
}, },
deleteMasterNodes:function ( sheetId, cellId ) { deleteMasterNodes:function ( sheetId, cellId ) {
...@@ -212,6 +215,14 @@ DependencyGraph.prototype = { ...@@ -212,6 +215,14 @@ DependencyGraph.prototype = {
this.deleteNode(node); this.deleteNode(node);
return node; return node;
}, },
deleteMasterNodes3:function ( node ) {
var arr = node.deleteAllMasterEdges();
for (var i in arr) {
var nodeMaster = arr[i];
if (nodeMaster.refCount <= 0)
this.deleteNode(nodeMaster);
}
},
getSlaveNodes:function ( sheetId, cellId ) { getSlaveNodes:function ( sheetId, cellId ) {
//todo //todo
return null; return null;
...@@ -233,13 +244,67 @@ DependencyGraph.prototype = { ...@@ -233,13 +244,67 @@ DependencyGraph.prototype = {
var sShiftGetBBoxName = oShiftGetBBox.getName(); var sShiftGetBBoxName = oShiftGetBBox.getName();
this.wb.needRecalc.nodes[getVertexId(wsId, sShiftGetBBoxName)] = [wsId, sShiftGetBBoxName]; this.wb.needRecalc.nodes[getVertexId(wsId, sShiftGetBBoxName)] = [wsId, sShiftGetBBoxName];
this.wb.needRecalc.length++; this.wb.needRecalc.length++;
this.oChangeNodeSlave = { toDelete: {}, toMove: {}};
var nodesSheetArea = this.nodesArea[wsId]; var nodesSheetArea = this.nodesArea[wsId];
if(nodesSheetArea) if(nodesSheetArea)
nodesSheetArea.shift(BBox, !toDelete, bHor); nodesSheetArea.shift(BBox, !toDelete, bHor);
var nodesSheetCell = this.nodesCell[wsId]; var nodesSheetCell = this.nodesCell[wsId];
if(nodesSheetCell) if(nodesSheetCell)
nodesSheetCell.shift( BBox, !toDelete, bHor ); nodesSheetCell.shift( BBox, !toDelete, bHor );
this.changeNodeEnd();
this.bSetRefError = bSetRefErrorOld; this.bSetRefError = bSetRefErrorOld;
},
changeNodeProcessDelete: function (node, oFormulas, toDelete) {
//todo deleteAllSlaveEdges deleteMasterNodes
var oSlaves = node.deleteAllSlaveEdges();
if (this.bSetRefError) {
//выставляем #REF!
for (var i in oSlaves) {
var slave = oSlaves[i];
if (null == toDelete || slave != toDelete[slave.nodeId]) {
var formula = slave.setRefError(node);
if (null != formula) {
if (oFormulas)
oFormulas[slave.nodeId] = { node: slave, formula: formula };
else
slave.setFormula(formula, true, false);
}
}
}
}
this.deleteMasterNodes3(node);
},
changeNodeProcessMove: function (node, from, to, oFormulas, toDelete) {
if (null == toDelete || node != toDelete[node.nodeId])
node.moveOuter(from, to, oFormulas);
},
changeNodeEnd : function(){
var oChangeNodeSlave = this.oChangeNodeSlave;
//обнуляем, потому что в цикле можем опять попасть в _changeNode со старым this.oChangeNodeSlave
this.oChangeNodeSlave = null;
//накапливаем формулы, потому что когда мы меняем формулу мы удаляем masterNodes, а эти node могут быть необработаными и влиять на формулу(C2=A2+B2 -> C1=A1+B2)
var oFormulas = {};
for (var i in oChangeNodeSlave.toDelete) {
var elem = oChangeNodeSlave.toDelete[i];
this.changeNodeProcessDelete(elem.node, oFormulas, oChangeNodeSlave.toDelete);
}
for (var i in oChangeNodeSlave.toMove) {
var elem = oChangeNodeSlave.toMove[i];
this.changeNodeProcessMove(elem.node, elem.from, elem.to, oFormulas, oChangeNodeSlave.toDelete);
}
for (var i in oFormulas) {
var elem = oFormulas[i];
if (null == elem.formula) {
var node = elem.node;
var cell = node.returnCell();
if (cell && cell.formulaParsed) {
this.wb.dependencyFormulas.deleteMasterNodes2(node.sheetId, node.cellId);
addToArrRecalc(node.sheetId, cell);
}
}
else
elem.node.setFormula(elem.formula, true, false);
}
}, },
_changeNode : function(node, from, to) _changeNode : function(node, from, to)
{ {
...@@ -254,31 +319,25 @@ DependencyGraph.prototype = { ...@@ -254,31 +319,25 @@ DependencyGraph.prototype = {
} }
else if(toDelete) else if(toDelete)
{ {
var oSlaves = node.deleteAllSlaveEdges(); if (this.oChangeNodeSlave)
if(this.bSetRefError) this.oChangeNodeSlave.toDelete[node.nodeId] = { node: node, from: from, to: to };
{ else {
//выставляем #REF! this.changeNodeProcessDelete(node, null);
for(var i in oSlaves)
{
var slave = oSlaves[i];
slave.setRefError(wsId, node.cellId);
}
} }
this.deleteMasterNodes(node.sheetId, node.cellId);
delete this.nodesId[node.nodeId]; delete this.nodesId[node.nodeId];
this.nodeslength--; this.nodeslength--;
} }
else { else {
var sOldnodeId = node.nodeId; var sOldnodeId = node.nodeId;
if((from.r1 == to.r1 && from.c1 == to.c1) || (from.r2 == to.r2 && from.c2 == to.c2)) node.moveInner(to);
node.moveStretch(to); if (this.oChangeNodeSlave)
else this.oChangeNodeSlave.toMove[node.nodeId] = { node: node, from: from, to: to };
node.move({offsetCol: to.c1 - from.c1, offsetRow: to.r1 - from.r1}, wsId, toDelete); else
this.changeNodeProcessMove(node, from, to, null);
delete this.nodesId[sOldnodeId]; delete this.nodesId[sOldnodeId];
this.nodesId[node.nodeId] = node; this.nodesId[node.nodeId] = node;
} }
//важно что ячейки уже сдвинулись, поэтому до вызова returnCell нужно сделать node.move //важно что ячейки уже сдвинулись, поэтому до вызова returnCell нужно сделать node.move и сдвинуть ячейки в aGCells
if(!node.isArea) if(!node.isArea)
{ {
var cwf = this.wb.cwf[wsId]; var cwf = this.wb.cwf[wsId];
...@@ -322,12 +381,14 @@ DependencyGraph.prototype = { ...@@ -322,12 +381,14 @@ DependencyGraph.prototype = {
}, },
helper : function(BBoxFrom, oBBoxTo, wsId){ helper : function(BBoxFrom, oBBoxTo, wsId){
var oGetRes, node, nodesSheetCell = this.nodesCell[wsId], nodesSheetArea = this.nodesArea[wsId]; var oGetRes, node, nodesSheetCell = this.nodesCell[wsId], nodesSheetArea = this.nodesArea[wsId];
var offset = {offsetCol: oBBoxTo.c1 - BBoxFrom.c1, offsetRow: oBBoxTo.r1 - BBoxFrom.r1}; var offset = { offsetCol: oBBoxTo.c1 - BBoxFrom.c1, offsetRow: oBBoxTo.r1 - BBoxFrom.r1 };
this.oChangeNodeSlave = { toDelete: {}, toMove: {} };
var elem, bbox; var elem, bbox;
if(nodesSheetCell) if(nodesSheetCell)
oGetRes = nodesSheetCell.move(BBoxFrom, oBBoxTo); oGetRes = nodesSheetCell.move(BBoxFrom, oBBoxTo);
if(nodesSheetArea) if(nodesSheetArea)
oGetRes = nodesSheetArea.move(BBoxFrom, oBBoxTo); oGetRes = nodesSheetArea.move(BBoxFrom, oBBoxTo);
this.changeNodeEnd();
}, },
drawDep:function ( cellId, se ) { drawDep:function ( cellId, se ) {
// ToDo неиспользуемая функция, реализовать после выпуска // ToDo неиспользуемая функция, реализовать после выпуска
...@@ -492,13 +553,15 @@ DependencyGraph.prototype = { ...@@ -492,13 +553,15 @@ DependencyGraph.prototype = {
else else
h( m, rc ); h( m, rc );
}, },
removeNodeBySheetId:function ( sheetId ) { removeNodeBySheetId: function (sheetId) {
this.oChangeNodeSlave = { toDelete: {}, toMove: {} };
var nodesSheetArea = this.nodesArea[sheetId]; var nodesSheetArea = this.nodesArea[sheetId];
if(nodesSheetArea) if(nodesSheetArea)
nodesSheetArea.removeAll(); nodesSheetArea.removeAll();
var nodesSheetCell = this.nodesCell[sheetId]; var nodesSheetCell = this.nodesCell[sheetId];
if(nodesSheetCell) if(nodesSheetCell)
nodesSheetCell.removeAll(); nodesSheetCell.removeAll();
this.changeNodeEnd();
}, },
getNodeDependence:function ( aElems ) { getNodeDependence:function ( aElems ) {
var oRes = {oMasterNodes:{}, oMasterAreaNodes:{}, oWeightMap:{}}; var oRes = {oMasterNodes:{}, oMasterAreaNodes:{}, oWeightMap:{}};
...@@ -677,10 +740,10 @@ Vertex.prototype = { ...@@ -677,10 +740,10 @@ Vertex.prototype = {
}, },
setFormula : function(sFormula, bAddToHistory, bAddNeedRecalc) setFormula : function(sFormula, bAddToHistory, bAddNeedRecalc)
{ {
var cell = this.returnCell(); this.wb.dependencyFormulas.deleteMasterNodes2(this.sheetId, this.cellId);
if(null != sFormula) var cell = this.returnCell();
cell.setFormula(sFormula, bAddToHistory); if (null != sFormula)
this.wb.dependencyFormulas.deleteMasterNodes2( this.sheetId, this.cellId ); cell.setFormula(sFormula, bAddToHistory);
addToArrRecalc(this.sheetId, cell); addToArrRecalc(this.sheetId, cell);
if(bAddNeedRecalc) if(bAddNeedRecalc)
{ {
...@@ -690,56 +753,87 @@ Vertex.prototype = { ...@@ -690,56 +753,87 @@ Vertex.prototype = {
}, },
setRefError : function(wsId, cellId) setRefError : function(wsId, cellId)
{ {
var sRes = null;
var cell = this.returnCell(); var cell = this.returnCell();
if( cell && cell.formulaParsed ) if( cell && cell.formulaParsed )
{ {
cell.formulaParsed.setRefError(wsId, cellId); cell.formulaParsed.setRefError(wsId, cellId);
this.setFormula(cell.formulaParsed.assemble(), true, false); sRes = cell.formulaParsed.assemble(true);
} }
return sRes;
}, },
move : function(offset, wsId, toDelete) moveInner: function (bboxTo) {
{ //удаляем старые ссылки slave и master
var oNewBBox = new Asc.Range(this.bbox.c1 + offset.offsetCol, this.bbox.r1 + offset.offsetRow, this.bbox.c2 + offset.offsetCol, this.bbox.r2 + offset.offsetRow); for (var i in this.slaveEdges) {
var sNewBBoxName = oNewBBox.getName(); var slave = this.slaveEdges[i];
var _sn = this.getSlaveEdges(); slave.deleteMasterEdge(this);
var cell = this.returnCell(); }
if( cell && cell.formulaParsed ) for (var i in this.masterEdges) {
{ var master = this.masterEdges[i];
this.wb.dependencyFormulas.deleteMasterNodes2(wsId, this.bbox.getName()); master.deleteSlaveEdge(this);
addToArrRecalc(wsId, cell); }
} var sOldNodeId = this.nodeId;
for( var _id in _sn ){ this.bbox = bboxTo;
var slave = _sn[_id] this.cellId = bboxTo.getName();
cell = slave.returnCell(); this.nodeId = getVertexId(this.sheetId, this.cellId);
if( cell && cell.formulaParsed ) this.wb.needRecalc.nodes[this.nodeId] = [this.sheetId, this.cellId ];
{ this.wb.needRecalc.length++;
cell.formulaParsed.shiftCells( offset, null, this, slave.sheetId, toDelete); //добавляем новые slave и master
slave.setFormula(cell.formulaParsed.assemble(), true, false); for (var i in this.slaveEdges) {
} var slave = this.slaveEdges[i];
} slave.addMasterEdge(this);
this.bbox = oNewBBox; }
this.cellId = sNewBBoxName; for (var i in this.masterEdges) {
this.nodeId = getVertexId(this.sheetId, this.cellId); var master = this.masterEdges[i];
this.wb.needRecalc.nodes[this.nodeId] = [this.sheetId, this.cellId ]; master.addSlaveEdge(this);
this.wb.needRecalc.length++; }
}, },
moveStretch : function(bboxTo) moveOuter: function (from, to, oFormulas) {
{ if ((from.r1 == to.r1 && from.c1 == to.c1) || (from.r2 == to.r2 && from.c2 == to.c2)) {
var sNewName = bboxTo.getName(); var _sn = this.getSlaveEdges();
var _sn = this.getSlaveEdges(); for (var _id in _sn) {
for( var _id in _sn ){ var slave = _sn[_id];
var slave = _sn[_id]; var cell = slave.returnCell();
var cell = slave.returnCell(); if (cell && cell.formulaParsed) {
if( cell && cell.formulaParsed ){ cell.formulaParsed.stretchArea(this, from, to);
cell.formulaParsed.stretchArea( this, bboxTo, sNewName ); var formula = cell.formulaParsed.assemble();
slave.setFormula(cell.formulaParsed.assemble(), true, false); if (null != formula) {
} if (oFormulas)
} oFormulas[slave.nodeId] = { node: slave, formula: formula };
this.bbox = bboxTo; else
this.cellId = sNewName; slave.setFormula(formula, true, false);
this.nodeId = getVertexId(this.sheetId, this.cellId); }
this.wb.needRecalc.nodes[this.nodeId] = [this.sheetId, this.cellId ]; }
this.wb.needRecalc.length++; }
}
else {
if (oFormulas) {
if (null == oFormulas[this.nodeId])
oFormulas[this.nodeId] = { node: this, formula: null };
}
else {
var cell = this.returnCell();
if (cell && cell.formulaParsed) {
this.wb.dependencyFormulas.deleteMasterNodes2(this.sheetId, this.cellId);
addToArrRecalc(this.sheetId, cell);
}
}
var _sn = this.getSlaveEdges();
for (var _id in _sn) {
var slave = _sn[_id]
var cell = slave.returnCell();
if (cell && cell.formulaParsed) {
cell.formulaParsed.shiftCells(this, from, to);
var formula = cell.formulaParsed.assemble();
if (null != formula) {
if (oFormulas)
oFormulas[slave.nodeId] = { node: slave, formula: formula };
else
slave.setFormula(formula, true, false);
}
}
}
}
}, },
//добавляем ведущую ячейку. //добавляем ведущую ячейку.
addMasterEdge : function(node){ addMasterEdge : function(node){
...@@ -784,17 +878,21 @@ Vertex.prototype = { ...@@ -784,17 +878,21 @@ Vertex.prototype = {
}, },
//удаляем ребро между конкретной ведущей ячейки. //удаляем ребро между конкретной ведущей ячейки.
deleteMasterEdge : function(node){ deleteMasterEdge: function (node) {
this.masterEdges[node.nodeId] = null; if (this.masterEdges) {
delete this.masterEdges[node.nodeId]; this.masterEdges[node.nodeId] = null;
this.refCount--; delete this.masterEdges[node.nodeId];
this.refCount--;
}
}, },
//удаляем ребро между конкретной зависимой(ведомой) ячейки. //удаляем ребро между конкретной зависимой(ведомой) ячейки.
deleteSlaveEdge : function(node){ deleteSlaveEdge: function (node) {
this.slaveEdges[node.nodeId] = null; if (this.slaveEdges) {
delete this.slaveEdges[node.nodeId]; this.slaveEdges[node.nodeId] = null;
this.refCount--; delete this.slaveEdges[node.nodeId];
this.refCount--;
}
}, },
//очищаем все ребра по ведущим ячейкам. //очищаем все ребра по ведущим ячейкам.
...@@ -2228,6 +2326,8 @@ Woorksheet.prototype._removeRows=function(start, stop){ ...@@ -2228,6 +2326,8 @@ Woorksheet.prototype._removeRows=function(start, stop){
delete this.aGCells[nIndex]; delete this.aGCells[nIndex];
} }
} }
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_RemoveRows, this.getId(), new Asc.Range(0, start, gc_nMaxCol0, gc_nMaxRow0), new UndoRedoData_FromToRowCol(true, start, stop));
var oActualRange = {r1: start, c1: 0, r2: stop, c2: gc_nMaxCol0}; var oActualRange = {r1: start, c1: 0, r2: stop, c2: gc_nMaxCol0};
var res = this.renameDependencyNodes( {offsetRow:nDif,offsetCol:0}, oActualRange ); var res = this.renameDependencyNodes( {offsetRow:nDif,offsetCol:0}, oActualRange );
buildRecalc(this.workbook); buildRecalc(this.workbook);
...@@ -2236,7 +2336,6 @@ Woorksheet.prototype._removeRows=function(start, stop){ ...@@ -2236,7 +2336,6 @@ Woorksheet.prototype._removeRows=function(start, stop){
// for(var id in res) // for(var id in res)
// History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_RemoveCell, this.getId(), new Asc.Range(0, res[id].nRow, gc_nMaxCol0, res[id].nRow), new UndoRedoData_CellSimpleData(res[id].nRow, res[id].nCol, res[id].data, null)); // History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_RemoveCell, this.getId(), new Asc.Range(0, res[id].nRow, gc_nMaxCol0, res[id].nRow), new UndoRedoData_CellSimpleData(res[id].nRow, res[id].nCol, res[id].data, null));
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_RemoveRows, this.getId(), new Asc.Range(0, start, gc_nMaxCol0, gc_nMaxRow0), new UndoRedoData_FromToRowCol(true, start, stop));
return true; return true;
}; };
Woorksheet.prototype.insertRowsBefore=function(index, count){ Woorksheet.prototype.insertRowsBefore=function(index, count){
...@@ -2248,7 +2347,6 @@ Woorksheet.prototype._insertRowsBefore=function(index, count){ ...@@ -2248,7 +2347,6 @@ Woorksheet.prototype._insertRowsBefore=function(index, count){
var oActualRange = {r1: index, c1: 0, r2: index + count - 1, c2: gc_nMaxCol0}; var oActualRange = {r1: index, c1: 0, r2: index + count - 1, c2: gc_nMaxCol0};
History.Create_NewPoint(); History.Create_NewPoint();
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_AddRows, this.getId(), new Asc.Range(0, index, gc_nMaxCol0, gc_nMaxRow0), new UndoRedoData_FromToRowCol(true, index, index + count - 1)); History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_AddRows, this.getId(), new Asc.Range(0, index, gc_nMaxCol0, gc_nMaxRow0), new UndoRedoData_FromToRowCol(true, index, index + count - 1));
History.TurnOff();
//index 0 based //index 0 based
var aIndexes = []; var aIndexes = [];
for(var i in this.aGCells) for(var i in this.aGCells)
...@@ -2292,8 +2390,7 @@ Woorksheet.prototype._insertRowsBefore=function(index, count){ ...@@ -2292,8 +2390,7 @@ Woorksheet.prototype._insertRowsBefore=function(index, count){
// for(var id in res) // for(var id in res)
// History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_RemoveCell, this.getId(), new Asc.Range(0, res[id].nRow, gc_nMaxCol0, res[id].nRow), new UndoRedoData_CellSimpleData(res[id].nRow, res[id].nCol, res[id].data, null)); // History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_RemoveCell, this.getId(), new Asc.Range(0, res[id].nRow, gc_nMaxCol0, res[id].nRow), new UndoRedoData_CellSimpleData(res[id].nRow, res[id].nCol, res[id].data, null));
History.TurnOn();
return true; return true;
}; };
Woorksheet.prototype.insertRowsAfter=function(index, count){ Woorksheet.prototype.insertRowsAfter=function(index, count){
...@@ -2339,10 +2436,6 @@ Woorksheet.prototype._removeCols=function(start, stop){ ...@@ -2339,10 +2436,6 @@ Woorksheet.prototype._removeCols=function(start, stop){
} }
} }
} }
var oActualRange = {r1: 0, c1: start, r2: gc_nMaxRow0, c2: stop};
var res = this.renameDependencyNodes( {offsetRow:0,offsetCol:nDif}, oActualRange );
buildRecalc(this.workbook);
unLockDraw(this.workbook);
var oDefColPr = new UndoRedoData_ColProp(); var oDefColPr = new UndoRedoData_ColProp();
for(var i = start; i <= stop; ++i) for(var i = start; i <= stop; ++i)
...@@ -2363,11 +2456,17 @@ Woorksheet.prototype._removeCols=function(start, stop){ ...@@ -2363,11 +2456,17 @@ Woorksheet.prototype._removeCols=function(start, stop){
if(null != elem) if(null != elem)
elem.moveHor(nDif); elem.moveHor(nDif);
} }
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_RemoveCols, this.getId(), new Asc.Range(start, 0, gc_nMaxCol0, gc_nMaxRow0), new UndoRedoData_FromToRowCol(false, start, stop));
var oActualRange = { r1: 0, c1: start, r2: gc_nMaxRow0, c2: stop };
var res = this.renameDependencyNodes({ offsetRow: 0, offsetCol: nDif }, oActualRange);
buildRecalc(this.workbook);
unLockDraw(this.workbook);
// for(var id in res) // for(var id in res)
// History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_RemoveCell, this.getId(), new Asc.Range(0, res[id].nRow, gc_nMaxCol0, res[id].nRow), new UndoRedoData_CellSimpleData(res[id].nRow, res[id].nCol, res[id].data, null)); // History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_RemoveCell, this.getId(), new Asc.Range(0, res[id].nRow, gc_nMaxCol0, res[id].nRow), new UndoRedoData_CellSimpleData(res[id].nRow, res[id].nCol, res[id].data, null));
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_RemoveCols, this.getId(), new Asc.Range(start, 0, gc_nMaxCol0, gc_nMaxRow0), new UndoRedoData_FromToRowCol(false, start, stop));
return true; return true;
}; };
Woorksheet.prototype.insertColsBefore=function(index, count){ Woorksheet.prototype.insertColsBefore=function(index, count){
...@@ -2379,7 +2478,6 @@ Woorksheet.prototype._insertColsBefore=function(index, count){ ...@@ -2379,7 +2478,6 @@ Woorksheet.prototype._insertColsBefore=function(index, count){
var oActualRange = {r1: 0, c1: index, r2: gc_nMaxRow0, c2: index + count - 1}; var oActualRange = {r1: 0, c1: index, r2: gc_nMaxRow0, c2: index + count - 1};
History.Create_NewPoint(); History.Create_NewPoint();
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_AddCols, this.getId(), new Asc.Range(index, 0, gc_nMaxCol0, gc_nMaxRow0), new UndoRedoData_FromToRowCol(false, index, index + count - 1)); History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_AddCols, this.getId(), new Asc.Range(index, 0, gc_nMaxCol0, gc_nMaxRow0), new UndoRedoData_FromToRowCol(false, index, index + count - 1));
History.TurnOff();
//index 0 based //index 0 based
for(var i in this.aGCells) for(var i in this.aGCells)
{ {
...@@ -2433,7 +2531,6 @@ Woorksheet.prototype._insertColsBefore=function(index, count){ ...@@ -2433,7 +2531,6 @@ Woorksheet.prototype._insertColsBefore=function(index, count){
// for(var id in res) // for(var id in res)
// History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_RemoveCell, this.getId(), new Asc.Range(0, res[id].nRow, gc_nMaxCol0, res[id].nRow), new UndoRedoData_CellSimpleData(res[id].nRow, res[id].nCol, res[id].data, null)); // History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_RemoveCell, this.getId(), new Asc.Range(0, res[id].nRow, gc_nMaxCol0, res[id].nRow), new UndoRedoData_CellSimpleData(res[id].nRow, res[id].nCol, res[id].data, null));
History.TurnOn();
return true; return true;
}; };
Woorksheet.prototype.insertColsAfter=function(index, count){ Woorksheet.prototype.insertColsAfter=function(index, count){
......
...@@ -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