Commit 79d2ba84 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

правка в DependencyGraph для удаления листа, sort, promote, вводе.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@53712 954022d7-b5bf-4e40-9824-e11837661b57
parent 64c04f0f
...@@ -2881,7 +2881,7 @@ parserFormula.prototype = { ...@@ -2881,7 +2881,7 @@ parserFormula.prototype = {
} }
else if(node instanceof cArea3D) else if(node instanceof cArea3D)
{ {
if( node.wsFrom == node.wsTo && wsId == node.wsFrom.getId() && cellId == node._cells) if( node.wsFrom == node.wsTo && wsId == node.wsFrom && cellId == node._cells)
this.outStack[i] = new cError( cErrorType.bad_reference ); this.outStack[i] = new cError( cErrorType.bad_reference );
} }
} }
......
...@@ -133,6 +133,21 @@ DependencyGraph.prototype = { ...@@ -133,6 +133,21 @@ DependencyGraph.prototype = {
} }
} }
} }
}
var nodesSheetArea = this.nodesArea[sheetId];
if ( nodesSheetArea ) {
var aNodes = nodesSheetArea.getAll();
for ( var i = 0, length = aNodes.length; i < length; i++ ) {
var node = aNodes[i].data;
var n = node.getSlaveEdges();
if ( n ) {
arr.push( node );
for ( var id2 in n ) {
n[id2].weightNode++;
// arr.push(n[id2]);
}
}
}
} }
return arr; return arr;
}, },
...@@ -220,6 +235,7 @@ DependencyGraph.prototype = { ...@@ -220,6 +235,7 @@ DependencyGraph.prototype = {
var toDelete = null == to; var toDelete = null == to;
var toAdd = null == from; var toAdd = null == from;
var wsId = node.sheetId; var wsId = node.sheetId;
var sOldCellId = node.cellId;
if(toAdd) if(toAdd)
{ {
this.nodesId[node.nodeId] = node; this.nodesId[node.nodeId] = node;
...@@ -243,7 +259,6 @@ DependencyGraph.prototype = { ...@@ -243,7 +259,6 @@ DependencyGraph.prototype = {
} }
else { else {
var sOldnodeId = node.nodeId; var sOldnodeId = node.nodeId;
var sOldCellId = node.cellId;
if((from.r1 == to.r1 && from.c1 == to.c1) || (from.r2 == to.r2 && from.c2 == to.c2)) if((from.r1 == to.r1 && from.c1 == to.c1) || (from.r2 == to.r2 && from.c2 == to.c2))
node.moveStretch(to); node.moveStretch(to);
else else
...@@ -258,11 +273,12 @@ DependencyGraph.prototype = { ...@@ -258,11 +273,12 @@ DependencyGraph.prototype = {
var cwf = this.wb.cwf[wsId]; var cwf = this.wb.cwf[wsId];
if(cwf) if(cwf)
{ {
var cell = node.returnCell();
if ( cell && cell.formulaParsed ) {
if(!toAdd) if(!toAdd)
delete cwf.cells[sOldCellId]; delete cwf.cells[sOldCellId];
if ( !toDelete ) if(!toDelete)
{
var cell = node.returnCell();
if ( cell && cell.formulaParsed )
cwf.cells[node.cellId] = node.cellId; cwf.cells[node.cellId] = node.cellId;
} }
} }
...@@ -468,31 +484,12 @@ DependencyGraph.prototype = { ...@@ -468,31 +484,12 @@ DependencyGraph.prototype = {
h( m, rc ); h( m, rc );
}, },
removeNodeBySheetId:function ( sheetId ) { removeNodeBySheetId:function ( sheetId ) {
var arr = false; var nodesSheetArea = this.nodesArea[sheetId];
// this.wb.needRecalc = []; if(nodesSheetArea)
// this.wb.needRecalc.length = 0; nodesSheetArea.removeAll();
var nodesSheet = nodes[sheetId]; var nodesSheetCell = this.nodesCell[sheetId];
if ( nodesSheet ) { if(nodesSheetCell)
var aNodes = nodesSheet.getAll(); nodesSheetCell.removeAll();
for ( var i = 0, length = aNodes.length; i < length; i++ ) {
var node = aNodes[i].data;
var se = node.getSlaveEdges();
for ( var id2 in se ) {
if ( se[id2].sheetId != sheetId ) {
if ( !arr ) arr = true;
// this.wb.needRecalc[id2] = [se[id2].sheetId,se[id2].cellId];
// this.wb.needRecalc.length++;
// arr.push(se[id2]);
}
}
node.deleteAllMasterEdges();
node.deleteAllSlaveEdges();
delete nodesId[node.nodeId];
this.nodeslength--;
}
nodesSheet.removeAll();
}
return arr;
}, },
getNodeDependence:function ( aElems ) { getNodeDependence:function ( aElems ) {
var oRes = {oMasterNodes:{}, oMasterAreaNodes:{}, oWeightMap:{}}; var oRes = {oMasterNodes:{}, oMasterAreaNodes:{}, oWeightMap:{}};
...@@ -1295,37 +1292,31 @@ Workbook.prototype.removeWorksheet=function(nIndex, outputParams){ ...@@ -1295,37 +1292,31 @@ Workbook.prototype.removeWorksheet=function(nIndex, outputParams){
return -1; return -1;
var nNewActive = this.nActive; var nNewActive = this.nActive;
var removedSheet = this.aWorksheets.splice(nIndex, 1); var removedSheets = this.aWorksheets.splice(nIndex, 1);
if(removedSheet.length > 0) if(removedSheets.length > 0)
{ {
var removedSheet = removedSheets[0];
var removedSheetId = removedSheet.getId();
History.TurnOff(); History.TurnOff();
//по всем удаленным листам пробегаемся и удаляем из workbook.cwf (cwf - cells with forluma) элементы с названием соответствующего листа. //по всем удаленным листам пробегаемся и удаляем из workbook.cwf (cwf - cells with forluma) элементы с названием соответствующего листа.
var _cwf; var _cwf = this.cwf[removedSheet.getId()];
for(var i=0; i<removedSheet.length;i++){ delete this.cwf[removedSheet.getId()];
var name = removedSheet[i]; delete this.aWorksheetsById[removedSheet.getId()];
_cwf = this.cwf[name.getId()];
this.cwf[name.getId()] = null;
delete this.cwf[name.getId()];
delete this.aWorksheetsById[name.getId()];
}
lockDraw(this); lockDraw(this);
var a = this.dependencyFormulas.getNodeBySheetId(removedSheet[0].getId()); var a = this.dependencyFormulas.getNodeBySheetId(removedSheet.getId());
for(var i=0;i<a.length;i++){ for(var i=0;i<a.length;i++){
var se = a[i].getSlaveEdges(); var node = a[i];
var se = node.getSlaveEdges();
if(se){ if(se){
for(var id in se){ for(var id in se){
if( se[id].sheetId != removedSheet[0].getId() ){ var slave = se[id];
var _ws = this.getWorksheetById(se[id].sheetId), f = _ws.getCell2(se[id].cellId).getCells()[0].sFormula, cID = se[id].cellId; if( slave.sheetId != removedSheetId )
addToArrRecalc(this, _ws.getId(), cID); slave.setRefError(removedSheetId, node.cellId);
// this.needRecalc[ getVertexId(_ws.getId(),cID) ] = [ _ws.getId(),cID ];
// if( this.needRecalc.length < 0) this.needRecalc.length = 0;
// this.needRecalc.length++;
}
} }
} }
} }
this.dependencyFormulas.removeNodeBySheetId(name.getId()); this.dependencyFormulas.removeNodeBySheetId(removedSheet.getId());
var bFind = false; var bFind = false;
if(nNewActive < this.aWorksheets.length) if(nNewActive < this.aWorksheets.length)
{ {
...@@ -1348,11 +1339,10 @@ Workbook.prototype.removeWorksheet=function(nIndex, outputParams){ ...@@ -1348,11 +1339,10 @@ Workbook.prototype.removeWorksheet=function(nIndex, outputParams){
} }
History.TurnOn(); History.TurnOn();
History.Create_NewPoint(); History.Create_NewPoint();
var oRemovedSheet = removedSheet[0]; History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_SheetRemove, null, null, new UndoRedoData_SheetRemove(nIndex, removedSheetId, removedSheet, _cwf));
History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_SheetRemove, null, null, new UndoRedoData_SheetRemove(nIndex, oRemovedSheet.getId(), oRemovedSheet, _cwf));
if(null != outputParams) if(null != outputParams)
{ {
outputParams.sheet = oRemovedSheet; outputParams.sheet = removedSheet;
outputParams.cwf = _cwf; outputParams.cwf = _cwf;
} }
this._updateWorksheetIndexes(); this._updateWorksheetIndexes();
...@@ -2801,8 +2791,6 @@ Woorksheet.prototype._removeCell=function(nRow, nCol, cell){ ...@@ -2801,8 +2791,6 @@ Woorksheet.prototype._removeCell=function(nRow, nCol, cell){
if(cell.formulaParsed) if(cell.formulaParsed)
this.wb.dependencyFormulas.deleteMasterNodes2( this.getId(), cell.getName() ); this.wb.dependencyFormulas.deleteMasterNodes2( this.getId(), cell.getName() );
// this.helperRebuildFormulas(cell,cell.getName(),cell.getName());
// addToArrRecalc(this.workbook, this.getId(), cell.getName()); // addToArrRecalc(this.workbook, this.getId(), cell.getName());
// if( this.workbook.dependencyFormulas.getNode(this.getId(),this.getName()) && !this.workbook.needRecalc[ getVertexId(this.getId(),cell.getName()) ] ){ // if( this.workbook.dependencyFormulas.getNode(this.getId(),this.getName()) && !this.workbook.needRecalc[ getVertexId(this.getId(),cell.getName()) ] ){
// this.workbook.needRecalc[ getVertexId(this.getId(),cell.getName()) ] = [ this.getId(),cell.getName() ]; // this.workbook.needRecalc[ getVertexId(this.getId(),cell.getName()) ] = [ this.getId(),cell.getName() ];
...@@ -2927,9 +2915,6 @@ Woorksheet.prototype._moveCellHor=function(nRow, nCol, dif){ ...@@ -2927,9 +2915,6 @@ Woorksheet.prototype._moveCellHor=function(nRow, nCol, dif){
var row = this._getRow(nRow); var row = this._getRow(nRow);
row.c[nCol + dif] = cell; row.c[nCol + dif] = cell;
delete row.c[nCol]; delete row.c[nCol];
this.helperRebuildFormulas(cell,lastName,cell.getName());
} }
}; };
Woorksheet.prototype._moveCellVer=function(nRow, nCol, dif){ Woorksheet.prototype._moveCellVer=function(nRow, nCol, dif){
...@@ -2944,8 +2929,6 @@ Woorksheet.prototype._moveCellVer=function(nRow, nCol, dif){ ...@@ -2944,8 +2929,6 @@ Woorksheet.prototype._moveCellVer=function(nRow, nCol, dif){
oTargetRow.c[nCol] = cell; oTargetRow.c[nCol] = cell;
if(oCurRow.isEmpty()) if(oCurRow.isEmpty())
delete this.aGCells[nRow]; delete this.aGCells[nRow];
this.helperRebuildFormulas(cell,lastName,cell.getName());
} }
}; };
Woorksheet.prototype._prepareMoveRangeGetCleanRanges=function(oBBoxFrom, oBBoxTo){ Woorksheet.prototype._prepareMoveRangeGetCleanRanges=function(oBBoxFrom, oBBoxTo){
...@@ -3093,7 +3076,6 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo, copyRange){ ...@@ -3093,7 +3076,6 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo, copyRange){
row.c[j] = oTempCell; row.c[j] = oTempCell;
if ( oTempCell.sFormula ) { if ( oTempCell.sFormula ) {
this.workbook.cwf[this.Id].cells[oTempCell.getName()] = oTempCell.getName();
if(copyRange){ if(copyRange){
oTempCell.formulaParsed = new parserFormula( oTempCell.sFormula, oTempCell.oId.getID(), this ); oTempCell.formulaParsed = new parserFormula( oTempCell.sFormula, oTempCell.oId.getID(), this );
oTempCell.formulaParsed.parse(); oTempCell.formulaParsed.parse();
...@@ -3454,12 +3436,6 @@ Woorksheet.prototype._ReBuildFormulas=function(cellRange){ ...@@ -3454,12 +3436,6 @@ Woorksheet.prototype._ReBuildFormulas=function(cellRange){
Woorksheet.prototype.renameDependencyNodes = function(offset, oBBox, rec, noDelete){ Woorksheet.prototype.renameDependencyNodes = function(offset, oBBox, rec, noDelete){
this.workbook.dependencyFormulas.checkOffset(oBBox, offset, this.Id, noDelete); this.workbook.dependencyFormulas.checkOffset(oBBox, offset, this.Id, noDelete);
} }
Woorksheet.prototype.helperRebuildFormulas = function(cell,lastName){
if( cell.sFormula ){
this.workbook.cwf[this.Id].cells[lastName] = null;
delete this.workbook.cwf[this.Id].cells[lastName];
}
}
Woorksheet.prototype.getAllCol = function(){ Woorksheet.prototype.getAllCol = function(){
if(null == this.oAllCol) if(null == this.oAllCol)
this.oAllCol = new Col(this, g_nAllColIndex); this.oAllCol = new Col(this, g_nAllColIndex);
...@@ -3666,20 +3642,9 @@ Cell.prototype.setValue=function(val,callback){ ...@@ -3666,20 +3642,9 @@ Cell.prototype.setValue=function(val,callback){
this.oValue.clean(); this.oValue.clean();
var sheetId = this.ws.getId(); var sheetId = this.ws.getId();
if (this.sFormula) if (this.sFormula)
{
wb.dependencyFormulas.deleteMasterNodes2( ws.Id, this.oId.getID() ); wb.dependencyFormulas.deleteMasterNodes2( ws.Id, this.oId.getID() );
} if( !(null != val && val[0] != "=" || true == numFormat.isTextFormat()))
if( null != val && val[0] != "=" || true == numFormat.isTextFormat()){
if (this.sFormula){
if ( this.oId.getID() in wb.cwf[ws.Id].cells){
delete wb.cwf[ws.Id].cells[this.oId.getID()];
}
}
}
else{
wb.cwf[ws.Id].cells[this.oId.getID()] = this.oId.getID();
addToArrRecalc(this.ws.workbook, this.ws.getId(), this.oId.getID()); addToArrRecalc(this.ws.workbook, this.ws.getId(), this.oId.getID());
}
wb.needRecalc.nodes[getVertexId(sheetId,this.oId.getID())] = [sheetId, this.oId.getID()]; wb.needRecalc.nodes[getVertexId(sheetId,this.oId.getID())] = [sheetId, this.oId.getID()];
wb.needRecalc.length++; wb.needRecalc.length++;
...@@ -3722,11 +3687,8 @@ Cell.prototype.setValue2=function(array){ ...@@ -3722,11 +3687,8 @@ Cell.prototype.setValue2=function(array){
var ws = this.ws; var ws = this.ws;
var wb = this.ws.workbook; var wb = this.ws.workbook;
var sheetId = this.ws.getId(); var sheetId = this.ws.getId();
if (this.sFormula){ if (this.sFormula)
var node = wb.dependencyFormulas.deleteMasterNodes2( ws.Id, this.oId.getID(), true ); wb.dependencyFormulas.deleteMasterNodes2( ws.Id, this.oId.getID(), true );
if ( this.oId.getID() in wb.cwf[ws.Id].cells)
delete wb.cwf[ws.Id].cells[this.oId.getID()];
}
this.sFormula = null; this.sFormula = null;
this.oValue.clean(); this.oValue.clean();
this.setFormulaCA(false); this.setFormulaCA(false);
...@@ -6762,6 +6724,16 @@ Range.prototype._sortByArray=function(oBBox, aSortData, bUndo){ ...@@ -6762,6 +6724,16 @@ Range.prototype._sortByArray=function(oBBox, aSortData, bUndo){
} }
} }
} }
var aNodes = this.worksheet.workbook.dependencyFormulas.getInRange( this.worksheet.Id, new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2) );
if(aNodes && aNodes.length > 0)
{
for(var i = 0, length = aNodes.length; i < length; ++i)
{
var node = aNodes[i];
this.worksheet.workbook.needRecalc.nodes[ node.nodeId ] = [ node.sheetId, node.cellId ];
this.worksheet.workbook.needRecalc.length++;
}
}
if (this.worksheet.workbook.isNeedCacheClean) if (this.worksheet.workbook.isNeedCacheClean)
sortDependency(this.worksheet.workbook); sortDependency(this.worksheet.workbook);
...@@ -7158,15 +7130,21 @@ Range.prototype.promote=function(bCtrl, bVertical, nIndex){ ...@@ -7158,15 +7130,21 @@ Range.prototype.promote=function(bCtrl, bVertical, nIndex){
var _p_ = new parserFormula(oFromCell.sFormula,oCopyCell.getName(),this.worksheet); var _p_ = new parserFormula(oFromCell.sFormula,oCopyCell.getName(),this.worksheet);
if( _p_.parse() ){ if( _p_.parse() ){
assemb = _p_.changeOffset(oCopyCell.getOffset2(oFromCell.getName())).assemble(); assemb = _p_.changeOffset(oCopyCell.getOffset2(oFromCell.getName())).assemble();
var sCopyCellName = oCopyCell.getName(); oCopyCell.setValue("="+assemb);
oCopyCell.setFormula(assemb); }
addToArrRecalc(this.worksheet.workbook, this.worksheet.getId(), sCopyCellName); }
this.worksheet.workbook.needRecalc.nodes[ getVertexId(this.worksheet.getId(),sCopyCellName) ] = [ this.worksheet.getId(),sCopyCellName ];
this.worksheet.workbook.needRecalc.length++;
} }
} }
} }
} }
var aNodes = this.worksheet.workbook.dependencyFormulas.getInRange( this.worksheet.Id, oPromoteAscRange );
if(aNodes && aNodes.length > 0)
{
for(var i = 0, length = aNodes.length; i < length; ++i)
{
var node = aNodes[i];
this.worksheet.workbook.needRecalc.nodes[ node.nodeId ] = [ node.sheetId, node.cellId ];
this.worksheet.workbook.needRecalc.length++;
} }
} }
//добавляем замерженые области //добавляем замерженые области
......
...@@ -3878,7 +3878,8 @@ RangeDataManager.prototype = { ...@@ -3878,7 +3878,8 @@ RangeDataManager.prototype = {
}, },
removeAll : function() removeAll : function()
{ {
//todo fChange this.remove(new Asc.Range(0, 0, gc_nMaxCol0, gc_nMaxRow0));
//todo
this.oIntervalTreeRB = new IntervalTreeRB(); this.oIntervalTreeRB = new IntervalTreeRB();
}, },
shiftGet : function(bbox, bHor) shiftGet : function(bbox, bHor)
...@@ -4141,6 +4142,15 @@ CellArea.prototype = { ...@@ -4141,6 +4142,15 @@ CellArea.prototype = {
} }
return aRes; return aRes;
}, },
remove : function(bbox)
{
var aElems = this.get(bbox);
for(var i = 0, length = aElems.length; i < length; ++i)
{
var elem = aElems[i];
this.removeElement(elem);
}
},
removeElement : function(elem) removeElement : function(elem)
{ {
var rowElem = this.rows.getElem(elem.bbox.r1); var rowElem = this.rows.getElem(elem.bbox.r1);
...@@ -4156,6 +4166,12 @@ CellArea.prototype = { ...@@ -4156,6 +4166,12 @@ CellArea.prototype = {
} }
} }
}, },
removeAll : function()
{
this.remove(new Asc.Range(0, 0, gc_nMaxCol0, gc_nMaxRow0));
//todo
this.oIntervalTreeRB = new IntervalTreeRB();
},
shiftGet : function(bbox, bHor) shiftGet : function(bbox, bHor)
{ {
var bboxGet = shiftGetBBox(bbox, bHor); var bboxGet = shiftGetBBox(bbox, bHor);
......
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