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

правки в DependencyGraph при вводе и сдвиге

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@53628 954022d7-b5bf-4e40-9824-e11837661b57
parent 124572ea
...@@ -2775,7 +2775,13 @@ parserFormula.prototype = { ...@@ -2775,7 +2775,13 @@ parserFormula.prototype = {
} }
return this; return this;
}, },
setRefError : function(wsId, cellId){
for ( var i = 0; i < this.outStack.length; i++ ) {
var node = this.outStack[i];
if ( node instanceof cRef || node instanceof cArea || node instanceof cRef3D || node instanceof cArea3D )
this.outStack[i] = new cError( cErrorType.bad_reference );
}
},
/* /*
Для изменения ссылок на конкретную ячейку. Для изменения ссылок на конкретную ячейку.
offset - на сколько сдвигаем ячейку (offset = {offsetCol:intNumber, offsetRow:intNumber}) offset - на сколько сдвигаем ячейку (offset = {offsetCol:intNumber, offsetRow:intNumber})
......
...@@ -145,12 +145,23 @@ DependencyGraph.prototype = { ...@@ -145,12 +145,23 @@ DependencyGraph.prototype = {
} }
return arr; return arr;
}, },
deleteNode : function(n){ deleteNode : function(n, bSetRefError){
var node = this.nodesId[n.nodeId]; var node = this.nodesId[n.nodeId];
if( node ) if( node )
{ {
node.deleteAllMasterEdges(); var oSlaves = node.deleteAllSlaveEdges();
node.deleteAllSlaveEdges(); if(bSetRefError)
{
//выставляем #REF!
for(var i in oSlaves)
{
var slave = oSlaves[i];
slave.setRefError();
this.wb.needRecalc[slave.nodeId] = [slave.sheetId, slave.cellId ];
this.wb.needRecalc.length++;
}
}
this.deleteMasterNodes(node.sheetId, node.cellId);
if(node.isArea) if(node.isArea)
{ {
var nodesSheetArea = this.nodesArea[node.sheetId]; var nodesSheetArea = this.nodesArea[node.sheetId];
...@@ -161,10 +172,7 @@ DependencyGraph.prototype = { ...@@ -161,10 +172,7 @@ DependencyGraph.prototype = {
{ {
var nodesSheetCell = this.nodesCell[node.sheetId]; var nodesSheetCell = this.nodesCell[node.sheetId];
if(nodesSheetCell) if(nodesSheetCell)
{ nodesSheetCell.removeElement(new RangeDataManagerElem(node.getBBox(), node));
var bbox = node.getBBox();
nodesSheetCell.removeElement(new RangeDataManagerElem(bbox, node));
}
} }
delete this.nodesId[node.nodeId]; delete this.nodesId[node.nodeId];
this.nodeslength--; this.nodeslength--;
...@@ -181,6 +189,7 @@ DependencyGraph.prototype = { ...@@ -181,6 +189,7 @@ DependencyGraph.prototype = {
this.deleteNode(nodeMaster); this.deleteNode(nodeMaster);
} }
} }
return node;
}, },
getSlaveNodes : function(sheetId, cellId){ getSlaveNodes : function(sheetId, cellId){
//todo //todo
...@@ -228,15 +237,17 @@ DependencyGraph.prototype = { ...@@ -228,15 +237,17 @@ DependencyGraph.prototype = {
{ {
var toDelete = null == to; var toDelete = null == to;
if(toDelete) if(toDelete)
this.deleteNode(node); this.deleteNode(node, true);
else else
{ {
var sOldnodeId = node.nodeId; var sOldnodeId = node.nodeId;
var sOldCellId = node.cellId; var sOldCellId = node.cellId;
if(from.r1 == to.r1 && from.c1 == to.c1) if((from.r1 == to.r1 && from.c1 == to.c1) || (from.r2 == to.r2 && from.c2 == to.c2))
node.moveLast(offset, BBox, wsId, toDelete); {
else if(from.r2 == to.r2 && from.c2 == to.c2) node.moveStretch(to);
node.moveFirst(offset, BBox, wsId, toDelete); this.wb.needRecalc[node.nodeId] = [node.sheetId, node.cellId ];
this.wb.needRecalc.length++;
}
else else
node.move(offset, BBox, wsId, toDelete); node.move(offset, BBox, wsId, toDelete);
...@@ -676,8 +687,6 @@ function Vertex(sheetId, cellId, wb){ ...@@ -676,8 +687,6 @@ function Vertex(sheetId, cellId, wb){
//masterEdges содержит ячейки, от которых зависит текущая ячейка //masterEdges содержит ячейки, от которых зависит текущая ячейка
this.masterEdges = null; this.masterEdges = null;
this.helpMasterEdges = {};
//slaveEdges содержит ячейки, которые зависят от данной ячейки //slaveEdges содержит ячейки, которые зависят от данной ячейки
this.slaveEdges = null; this.slaveEdges = null;
...@@ -693,6 +702,15 @@ Vertex.prototype = { ...@@ -693,6 +702,15 @@ Vertex.prototype = {
{ {
return this.bbox; return this.bbox;
}, },
setRefError : function()
{
var cell = this.returnCell();
if( cell && cell.formulaParsed )
{
cell.formulaParsed.setRefError(this.sheetId, this.cellId);
cell.setFormula(cell.formulaParsed.assemble(), true);
}
},
move : function(offset, oBBox, wsId, toDelete) move : function(offset, oBBox, wsId, toDelete)
{ {
var _sn = this.getSlaveEdges(); var _sn = this.getSlaveEdges();
...@@ -702,33 +720,26 @@ Vertex.prototype = { ...@@ -702,33 +720,26 @@ Vertex.prototype = {
{ {
cellName = cell.getName(); cellName = cell.getName();
cell.formulaParsed.shiftCells( offset, oBBox, this, wsId, toDelete); cell.formulaParsed.shiftCells( offset, oBBox, this, wsId, toDelete);
cell.setFormula(cell.formulaParsed.assemble()); cell.setFormula(cell.formulaParsed.assemble(), true);
} }
} }
this.bbox = new Asc.Range(this.bbox.c1 + offset.offsetCol, this.bbox.r1 + offset.offsetRow, this.bbox.c2 + offset.offsetCol, this.bbox.r2 + offset.offsetRow); this.bbox = new Asc.Range(this.bbox.c1 + offset.offsetCol, this.bbox.r1 + offset.offsetRow, this.bbox.c2 + offset.offsetCol, this.bbox.r2 + offset.offsetRow);
this.cellId = this.bbox.getName(); this.cellId = this.bbox.getName();
this.nodeId = getVertexId(this.sheetId, this.cellId); this.nodeId = getVertexId(this.sheetId, this.cellId);
}, },
moveFirst : function(offset, oBBox, wsId, toDelete) moveStretch : function(bboxTo)
{ {
this.bbox = new Asc.Range(this.bbox.c1 + offset.offsetCol, this.bbox.r1 + offset.offsetRow, this.bbox.c2, this.bbox.r2); var sNewName = bboxTo.getName();
this.cellId = this.bbox.getName();
this.nodeId = getVertexId(this.sheetId, this.cellId);
},
moveLast : function(offset, oBBox, wsId, toDelete)
{
var oNewBBox = new Asc.Range(this.bbox.c1, this.bbox.r1, this.bbox.c2 + offset.offsetCol, this.bbox.r2 + offset.offsetRow);
var sNewName = oNewBBox.getName();
var _sn = this.getSlaveEdges(); var _sn = this.getSlaveEdges();
for( var _id in _sn ){ for( var _id in _sn ){
var cell = _sn[_id].returnCell(), cellName; var cell = _sn[_id].returnCell(), cellName;
if( cell && cell.formulaParsed ){ if( cell && cell.formulaParsed ){
cellName = cell.getName(); cellName = cell.getName();
cell.formulaParsed.stretchArea( this, sNewName ); cell.formulaParsed.stretchArea( this, sNewName );
cell.setFormula(cell.formulaParsed.assemble()); cell.setFormula(cell.formulaParsed.assemble(), true);
} }
} }
this.bbox = oNewBBox this.bbox = bboxTo
this.cellId = sNewName; this.cellId = sNewName;
this.nodeId = getVertexId(this.sheetId, this.cellId); this.nodeId = getVertexId(this.sheetId, this.cellId);
}, },
...@@ -740,10 +751,6 @@ Vertex.prototype = { ...@@ -740,10 +751,6 @@ Vertex.prototype = {
this.refCount ++; this.refCount ++;
}, },
addHelpMasterEdge : function(node){
this.helpMasterEdges[node.nodeId] = node;
},
//добавляем зависимую(ведомую) ячейку. //добавляем зависимую(ведомую) ячейку.
addSlaveEdge : function(node){ addSlaveEdge : function(node){
if( !this.slaveEdges ) if( !this.slaveEdges )
...@@ -756,10 +763,6 @@ Vertex.prototype = { ...@@ -756,10 +763,6 @@ Vertex.prototype = {
return this.masterEdges; return this.masterEdges;
}, },
getHelpMasterEdges : function(){
return this.helpMasterEdges;
},
getSlaveEdges : function(){ getSlaveEdges : function(){
return this.slaveEdges; return this.slaveEdges;
}, },
...@@ -784,10 +787,6 @@ Vertex.prototype = { ...@@ -784,10 +787,6 @@ Vertex.prototype = {
this.refCount--; this.refCount--;
}, },
deleteHelpMasterEdge : function(node){
delete this.helpMasterEdges[node.nodeId];
},
//удаляем ребро между конкретной зависимой(ведомой) ячейки. //удаляем ребро между конкретной зависимой(ведомой) ячейки.
deleteSlaveEdge : function(node){ deleteSlaveEdge : function(node){
this.slaveEdges[node.nodeId] = null; this.slaveEdges[node.nodeId] = null;
...@@ -812,13 +811,14 @@ Vertex.prototype = { ...@@ -812,13 +811,14 @@ Vertex.prototype = {
//очищаем все ребра по ведомым ячейкам. //очищаем все ребра по ведомым ячейкам.
deleteAllSlaveEdges : function(){ deleteAllSlaveEdges : function(){
var ret = []; var ret = {};
for( var id in this.slaveEdges ){ for( var id in this.slaveEdges ){
this.slaveEdges[id].deleteMasterEdge(this); var slaveEdge = this.slaveEdges[id];
slaveEdge.deleteMasterEdge(this);
this.slaveEdges[id] = null; this.slaveEdges[id] = null;
delete this.slaveEdges[id]; delete this.slaveEdges[id];
this.refCount--; this.refCount--;
ret.push(id); ret[id] = slaveEdge;
} }
this.slaveEdges = null; this.slaveEdges = null;
return ret; return ret;
...@@ -2893,25 +2893,6 @@ Woorksheet.prototype._removeCell=function(nRow, nCol, cell){ ...@@ -2893,25 +2893,6 @@ Woorksheet.prototype._removeCell=function(nRow, nCol, cell){
this.helperRebuildFormulas(cell,cell.getName(),cell.getName()); this.helperRebuildFormulas(cell,cell.getName(),cell.getName());
var node = this.workbook.dependencyFormulas.getNode2( this.Id, cell.getName() );
if ( node ) {
for ( var i = 0; i < node.length; i++ ) {
var n = node[i].getSlaveEdges();
if ( n ) {
for ( var id in n ) {
if ( n[id].cell && n[id].cell.sFormula ) {
History.Add( g_oUndoRedoWorksheet,
historyitem_Worksheet_RemoveCellFormula,
n[id].sheetId,
new Asc.Range( n[id].cell.oId.getCol0(), n[id].cell.oId.getRow0(), n[id].cell.oId.getCol0(), n[id].cell.oId.getRow0() ),
new UndoRedoData_CellSimpleData( n[id].cell.oId.getRow0(), n[id].cell.oId.getCol0(), null, null, n[id].cell.sFormula )
);
}
}
}
}
}
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() ];
...@@ -3560,83 +3541,6 @@ Woorksheet.prototype._ReBuildFormulas=function(cellRange){ ...@@ -3560,83 +3541,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);
return;
var c = {};
for ( var id in objForRebuldFormula.move ){
var n = objForRebuldFormula.move[id].node;
var _sn = n.getSlaveEdges2();
for( var _id in _sn ){
var cell = _sn[_id].returnCell(), cellName;
if( undefined == cell ) { continue; }
cellName = cell.getName();
if( cell.formulaParsed ){
cell.formulaParsed.shiftCells( objForRebuldFormula.move[id].offset, oBBox, n, this.Id, objForRebuldFormula.move[id].toDelete );
cell.setFormula(cell.formulaParsed.assemble());
c[cellName] = cell;
}
}
if( !n.isArea){
var cell = n.returnCell();
if( cell && cell.formulaParsed ){
c[cell.getName()] = cell;
}
}
}
for ( var id in objForRebuldFormula.stretch ){
var n = objForRebuldFormula.stretch[id].node;
var _sn = n.getSlaveEdges2();
if( _sn == null ){
if ( n.newCellId ){
n = this.workbook.dependencyFormulas.getNode(n.sheetId,n.newCellId)
_sn = n.getSlaveEdges2();
}
}
for( var _id in _sn ){
var cell = _sn[_id].returnCell(), cellName;
if( cell && cell.formulaParsed ){
cellName = cell.getName();
cell.formulaParsed.stretchArea( objForRebuldFormula.stretch[id].offset, oBBox, n, this.Id );
cell.setFormula(cell.formulaParsed.assemble());
c[cellName] = cell;
}
}
}
var id = null;
for ( id in objForRebuldFormula ){
if( id == "recalc" ) continue;
for(var _id in objForRebuldFormula[id] )
this.workbook.dependencyFormulas.deleteNode( objForRebuldFormula[id][_id].node );
}
for( var i in c ){
var ws = c[i].ws;
if( ws.getCell2(c[i].getName()).getCells()[0].formulaParsed ){
var n = c[i].getName();
c[i].formulaParsed.setCellId( n );
this.workbook.cwf[c[i].ws.Id].cells[n] = n;
c[i].formulaParsed.buildDependencies();
this.workbook.needRecalc[ getVertexId( c[i].ws.Id, n ) ] = [ c[i].ws.Id, n ];
this.workbook.needRecalc.length++;
}
c[i] = null;
delete c[i];
}
for( var id in objForRebuldFormula.recalc ){
var n = objForRebuldFormula.recalc[id];
var _sn = n.getSlaveEdges();
for( var _id in _sn ){
if( !_sn[_id].isArea ){
this.workbook.needRecalc[ _sn[_id].nodeId ] = [ _sn[_id].sheetId, _sn[_id].cellId ];
this.workbook.needRecalc.length++;
}
}
}
if ( false !== rec && lc <= 1 )
sortDependency(this.workbook);
} }
Woorksheet.prototype.helperRebuildFormulas = function(cell,lastName){ Woorksheet.prototype.helperRebuildFormulas = function(cell,lastName){
if( cell.sFormula ){ if( cell.sFormula ){
...@@ -3791,7 +3695,11 @@ Cell.prototype.getName=function(){ ...@@ -3791,7 +3695,11 @@ Cell.prototype.getName=function(){
Cell.prototype.cleanCache=function(){ Cell.prototype.cleanCache=function(){
this.oValue.cleanCache(); this.oValue.cleanCache();
} }
Cell.prototype.setFormula=function(val){ Cell.prototype.setFormula=function(val, bAddToHistory){
if(bAddToHistory)
{
History.Add( g_oUndoRedoWorksheet, historyitem_Worksheet_RemoveCellFormula, this.ws.getId(), new Asc.Range( this.oId.getCol0(), this.oId.getRow0(), this.oId.getCol0(), this.oId.getRow0() ), new UndoRedoData_CellSimpleData( this.oId.getRow0(), this.oId.getCol0(), null, null, this.sFormula ));
}
this.sFormula = val; this.sFormula = val;
this.oValue.cleanCache(); this.oValue.cleanCache();
} }
...@@ -3847,33 +3755,36 @@ Cell.prototype.setValue=function(val,callback){ ...@@ -3847,33 +3755,36 @@ Cell.prototype.setValue=function(val,callback){
var needRecalc = false; var needRecalc = false;
var ar = {}; var ar = {};
var sheetId = this.ws.getId(); var sheetId = this.ws.getId();
if (this.sFormula)
{
var node = wb.dependencyFormulas.deleteMasterNodes( ws.Id, this.oId.getID() );
if(node && node.refCount <= 0)
wb.dependencyFormulas.deleteNode(node);
}
if( null != val && val[0] != "=" || true == numFormat.isTextFormat()){ if( null != val && val[0] != "=" || true == numFormat.isTextFormat()){
if (this.sFormula){ if (this.sFormula){
if ( this.oId.getID() in wb.cwf[ws.Id].cells){ if ( this.oId.getID() in wb.cwf[ws.Id].cells){
wb.dependencyFormulas.deleteMasterNodes( ws.Id, this.oId.getID() );
delete wb.cwf[ws.Id].cells[this.oId.getID()]; delete wb.cwf[ws.Id].cells[this.oId.getID()];
} }
needRecalc = true; needRecalc = true;
ar[this.oId.getID()] = this.oId.getID();
wb.needRecalc[getVertexId(sheetId,this.oId.getID())] = [sheetId, this.oId.getID()];
wb.needRecalc.length++;
} }
else{ else{
if( wb.dependencyFormulas.nodeExistWithArea( ws.Id, this.oId.getID() ) ){ if( wb.dependencyFormulas.nodeExistWithArea( ws.Id, this.oId.getID() ) ){
needRecalc = true; needRecalc = true;
ar[this.oId.getID()] = this.oId.getID();
wb.needRecalc[getVertexId(sheetId,this.oId.getID())] = [sheetId, this.oId.getID()];
wb.needRecalc.length++;
} }
} }
} }
else{ else{
wb.dependencyFormulas.deleteMasterNodes( ws.Id, this.oId.getID() );
needRecalc = true;
wb.cwf[ws.Id].cells[this.oId.getID()] = this.oId.getID(); wb.cwf[ws.Id].cells[this.oId.getID()] = this.oId.getID();
ar[this.oId.getID()] = this.oId.getID(); if(this.ws.workbook.isNeedCacheClean)
addToArrRecalc(this.ws.workbook, this.ws.getId(), this.oId.getID()); ar[this.oId.getID()] = this.oId.getID();
wb.needRecalc[getVertexId(sheetId,this.oId.getID())] = [sheetId, this.oId.getID()]; else
addToArrRecalc(this.ws.workbook, this.ws.getId(), this.oId.getID());
needRecalc = true;
}
if(needRecalc)
{
wb.needRecalc[getVertexId(sheetId,this.oId.getID())] = [sheetId, this.oId.getID()];
wb.needRecalc.length++; wb.needRecalc.length++;
} }
this.sFormula = null; this.sFormula = null;
...@@ -3893,13 +3804,13 @@ Cell.prototype.setValue=function(val,callback){ ...@@ -3893,13 +3804,13 @@ Cell.prototype.setValue=function(val,callback){
ws._BuildDependencies(ar); ws._BuildDependencies(ar);
sortDependency(this.ws.workbook); sortDependency(this.ws.workbook);
} }
else if( this.ws.workbook.isNeedCacheClean == false ){ // else if( this.ws.workbook.isNeedCacheClean == false ){
if( ws.workbook.dependencyFormulas.nodeExistWithArea(this.ws.getId(),this.getName()) ){ // if( ws.workbook.dependencyFormulas.nodeExistWithArea(this.ws.getId(),this.getName()) ){
addToArrRecalc(this.ws.workbook, this.ws.getId(), this.oId.getID()); // addToArrRecalc(this.ws.workbook, this.ws.getId(), this.oId.getID());
wb.needRecalc[ getVertexId(this.ws.getId(),this.oId.getID()) ] = [ this.ws.getId(),this.oId.getID() ]; // wb.needRecalc[ getVertexId(this.ws.getId(),this.oId.getID()) ] = [ this.ws.getId(),this.oId.getID() ];
wb.needRecalc.length++; // wb.needRecalc.length++;
} // }
} // }
var DataNew = null; var DataNew = null;
if(History.Is_On()) if(History.Is_On())
DataNew = this.getValueData(); DataNew = this.getValueData();
...@@ -3923,24 +3834,18 @@ Cell.prototype.setValue2=function(array){ ...@@ -3923,24 +3834,18 @@ Cell.prototype.setValue2=function(array){
var ws = this.ws; var ws = this.ws;
var wb = this.ws.workbook; var wb = this.ws.workbook;
var needRecalc = false; var needRecalc = false;
var ar = [];
var sheetId = this.ws.getId(); var sheetId = this.ws.getId();
if (this.sFormula){ if (this.sFormula){
if ( this.oId.getID() in wb.cwf[ws.Id].cells){ var node = wb.dependencyFormulas.deleteMasterNodes( ws.Id, this.oId.getID(), true );
wb.dependencyFormulas.deleteMasterNodes( ws.Id, this.oId.getID() ); if(node && node.refCount <= 0)
wb.dependencyFormulas.deleteNode(node);
if ( this.oId.getID() in wb.cwf[ws.Id].cells)
delete wb.cwf[ws.Id].cells[this.oId.getID()]; delete wb.cwf[ws.Id].cells[this.oId.getID()];
}
needRecalc = true; needRecalc = true;
ar.push(this.oId.getID());
wb.needRecalc[getVertexId(sheetId,this.oId.getID())] = [sheetId, this.oId.getID()];
wb.needRecalc.length++;
} }
else{ else{
if( wb.dependencyFormulas.nodeExistWithArea( ws.Id, this.oId.getID() ) ){ if( wb.dependencyFormulas.nodeExistWithArea( ws.Id, this.oId.getID() ) ){
needRecalc = true; needRecalc = true;
ar.push(this.oId.getID());
wb.needRecalc[getVertexId(sheetId,this.oId.getID())] = [sheetId, this.oId.getID()];
wb.needRecalc.length++;
} }
} }
this.sFormula = null; this.sFormula = null;
...@@ -3948,10 +3853,12 @@ Cell.prototype.setValue2=function(array){ ...@@ -3948,10 +3853,12 @@ Cell.prototype.setValue2=function(array){
this.setFormulaCA(false); this.setFormulaCA(false);
this.oValue.setValue2(array); this.oValue.setValue2(array);
if (needRecalc){ if (needRecalc){
wb.needRecalc[getVertexId(sheetId,this.oId.getID())] = [sheetId, this.oId.getID()];
wb.needRecalc.length++;
/* /*
Если необходим пересчет, то по списку пересчитываемых ячеек сортируем граф зависимостей и пересчиываем в получившемся порядке. Плохим ячейкам с цикличискими ссылками выставляем ошибку "#REF!". Если необходим пересчет, то по списку пересчитываемых ячеек сортируем граф зависимостей и пересчиываем в получившемся порядке. Плохим ячейкам с цикличискими ссылками выставляем ошибку "#REF!".
*/ */
this.ws._BuildDependencies(ar); //this.ws._BuildDependencies(ar);
sortDependency(this.ws.workbook); sortDependency(this.ws.workbook);
} }
var DataNew = null; var DataNew = null;
......
...@@ -3367,7 +3367,7 @@ TreeRB.prototype = { ...@@ -3367,7 +3367,7 @@ TreeRB.prototype = {
_init : function(){ _init : function(){
this.nil = new TreeRBNode(); this.nil = new TreeRBNode();
this.nil.left = this.nil.right = this.nil.parent = this.nil; this.nil.left = this.nil.right = this.nil.parent = this.nil;
this.nil.key = Number.MIN_VALUE; this.nil.key = -Number.MAX_VALUE;
this.nil.red = 0; this.nil.red = 0;
this.nil.storedValue = null; this.nil.storedValue = null;
...@@ -3635,7 +3635,7 @@ TreeRB.prototype = { ...@@ -3635,7 +3635,7 @@ TreeRB.prototype = {
return oRes; return oRes;
}, },
getNodeAll : function(){ getNodeAll : function(){
return this.enumerate(Number.MIN_VALUE, Number.MAX_VALUE); return this.enumerate(-Number.MAX_VALUE, Number.MAX_VALUE);
} }
}; };
...@@ -3646,7 +3646,7 @@ Asc.extendClass(IntervalTreeRB, TreeRB); ...@@ -3646,7 +3646,7 @@ Asc.extendClass(IntervalTreeRB, TreeRB);
IntervalTreeRB.prototype._init = function (x) { IntervalTreeRB.prototype._init = function (x) {
this.nil = new IntervalTreeRBNode(); this.nil = new IntervalTreeRBNode();
this.nil.left = this.nil.right = this.nil.parent = this.nil; this.nil.left = this.nil.right = this.nil.parent = this.nil;
this.nil.key = this.nil.high = this.nil.maxHigh = Number.MIN_VALUE; this.nil.key = this.nil.high = this.nil.maxHigh = -Number.MAX_VALUE;
this.nil.minLow = Number.MAX_VALUE; this.nil.minLow = Number.MAX_VALUE;
this.nil.red = 0; this.nil.red = 0;
this.nil.storedValue = null; this.nil.storedValue = null;
...@@ -3654,7 +3654,7 @@ IntervalTreeRB.prototype._init = function (x) { ...@@ -3654,7 +3654,7 @@ IntervalTreeRB.prototype._init = function (x) {
this.root = new IntervalTreeRBNode(); this.root = new IntervalTreeRBNode();
this.root.left = this.nil.right = this.nil.parent = this.nil; this.root.left = this.nil.right = this.nil.parent = this.nil;
this.root.key = this.root.high = this.root.maxHigh = Number.MAX_VALUE; this.root.key = this.root.high = this.root.maxHigh = Number.MAX_VALUE;
this.root.minLow = Number.MIN_VALUE; this.root.minLow = -Number.MAX_VALUE;
this.root.red = 0; this.root.red = 0;
this.root.storedValue = null; this.root.storedValue = null;
}; };
...@@ -3666,7 +3666,7 @@ IntervalTreeRB.prototype._fixUpMaxHigh = function (x) { ...@@ -3666,7 +3666,7 @@ IntervalTreeRB.prototype._fixUpMaxHigh = function (x) {
} }
}; };
IntervalTreeRB.prototype._cleanMaxHigh = function (x) { IntervalTreeRB.prototype._cleanMaxHigh = function (x) {
x.maxHigh = Number.MIN_VALUE; x.maxHigh = -Number.MAX_VALUE;
x.minLow = Number.MAX_VALUE; x.minLow = Number.MAX_VALUE;
}; };
IntervalTreeRB.prototype._overlap = function (a1, a2, b1, b2) { IntervalTreeRB.prototype._overlap = function (a1, a2, b1, b2) {
...@@ -3840,8 +3840,40 @@ RangeDataManager.prototype = { ...@@ -3840,8 +3840,40 @@ RangeDataManager.prototype = {
var bboxGet = shiftGetBBox(bbox, bHor); var bboxGet = shiftGetBBox(bbox, bHor);
return {bbox: bboxGet, elems: this.get(bboxGet)}; return {bbox: bboxGet, elems: this.get(bboxGet)};
}, },
shiftSort : function(a, b, bAsc, bRow)
{
var nRes = 0;
if(null == a.to || null == b.to)
{
if(null == a.to && null == b.to)
nRes = 0;
else if(null == a.to)
nRes = 1;
else if(null == b.to)
nRes = -1;
}
else
{
if(bRow)
{
if(bAsc)
nRes = a.to.r1 - b.to.r1;
else
nRes = b.to.r1 - a.to.r1;
}
else
{
if(bAsc)
nRes = a.to.c1 - b.to.c1;
else
nRes = b.to.c1 - a.to.c1;
}
}
return nRes;
},
shift : function(bbox, bAdd, bHor, oGetRes) shift : function(bbox, bAdd, bHor, oGetRes)
{ {
var _this = this;
if(null == oGetRes) if(null == oGetRes)
oGetRes = this.shiftGet(bbox, bHor); oGetRes = this.shiftGet(bbox, bHor);
var aToChange = []; var aToChange = [];
...@@ -3943,16 +3975,16 @@ RangeDataManager.prototype = { ...@@ -3943,16 +3975,16 @@ RangeDataManager.prototype = {
if(bHor) if(bHor)
{ {
if(bAdd) if(bAdd)
aToChange.sort(function(a, b){return b.to.c1 - a.to.c1;}); aToChange.sort(function(a, b){return _this.shiftSort(a, b, false, false);});
else else
aToChange.sort(function(a, b){return a.to.c1 - b.to.c1;}); aToChange.sort(function(a, b){return _this.shiftSort(a, b, true, false);});
} }
else else
{ {
if(bAdd) if(bAdd)
aToChange.sort(function(a, b){return b.to.r1 - a.to.r1;}); aToChange.sort(function(a, b){return _this.shiftSort(a, b, false, true);});
else else
aToChange.sort(function(a, b){return a.to.r1 - b.to.r1;}); aToChange.sort(function(a, b){return _this.shiftSort(a, b, true, true);});
} }
for(var i = 0, length = aToChange.length; i < length; ++i) for(var i = 0, length = aToChange.length; i < length; ++i)
{ {
...@@ -4085,7 +4117,7 @@ CellArea.prototype = { ...@@ -4085,7 +4117,7 @@ CellArea.prototype = {
else else
{ {
var bboxAsc = Asc.Range(bbox.c1, bbox.r1, bbox.c2, bbox.r2); var bboxAsc = Asc.Range(bbox.c1, bbox.r1, bbox.c2, bbox.r2);
if(!bboxAsc.contains(elem.col, elem.row)) if(!bboxAsc.containsRange(elem.bbox))
{ {
to = elem.bbox.clone(); to = elem.bbox.clone();
if(bHor) if(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