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

Откладываем занесение needRecalc при изменении формул(при сдвиге, move, sort)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@53724 954022d7-b5bf-4e40-9824-e11837661b57
parent 6626638c
...@@ -678,9 +678,7 @@ Vertex.prototype = { ...@@ -678,9 +678,7 @@ Vertex.prototype = {
this.wb.dependencyFormulas.deleteMasterNodes2( wsId, cellId ); this.wb.dependencyFormulas.deleteMasterNodes2( wsId, cellId );
cell.formulaParsed.setRefError(wsId, cellId); cell.formulaParsed.setRefError(wsId, cellId);
cell.setFormula(cell.formulaParsed.assemble(), true); cell.setFormula(cell.formulaParsed.assemble(), true);
addToArrRecalc(this.wb, wsId, cellId); addToArrRecalc(wsId, cell);
this.wb.needRecalc.nodes[this.nodeId] = [this.sheetId, this.cellId ];
this.wb.needRecalc.length++;
} }
}, },
move : function(offset, wsId, toDelete) move : function(offset, wsId, toDelete)
...@@ -692,7 +690,7 @@ Vertex.prototype = { ...@@ -692,7 +690,7 @@ Vertex.prototype = {
if( cell && cell.formulaParsed ) if( cell && cell.formulaParsed )
{ {
this.wb.dependencyFormulas.deleteMasterNodes2(wsId, this.bbox.getName()); this.wb.dependencyFormulas.deleteMasterNodes2(wsId, this.bbox.getName());
addToArrRecalc(this.wb, wsId, sNewBBoxName); addToArrRecalc(wsId, cell);
} }
for( var _id in _sn ){ for( var _id in _sn ){
var slave = _sn[_id] var slave = _sn[_id]
...@@ -702,9 +700,7 @@ Vertex.prototype = { ...@@ -702,9 +700,7 @@ Vertex.prototype = {
this.wb.dependencyFormulas.deleteMasterNodes2( slave.sheetId, slave.cellId ); this.wb.dependencyFormulas.deleteMasterNodes2( slave.sheetId, slave.cellId );
cell.formulaParsed.shiftCells( offset, null, this, slave.sheetId, toDelete); cell.formulaParsed.shiftCells( offset, null, this, slave.sheetId, toDelete);
cell.setFormula(cell.formulaParsed.assemble(), true); cell.setFormula(cell.formulaParsed.assemble(), true);
addToArrRecalc(this.wb, slave.sheetId, slave.cellId); addToArrRecalc(slave.sheetId, cell);
this.wb.needRecalc.nodes[slave.nodeId] = [slave.sheetId, slave.cellId ];
this.wb.needRecalc.length++;
} }
} }
this.bbox = oNewBBox; this.bbox = oNewBBox;
...@@ -724,9 +720,7 @@ Vertex.prototype = { ...@@ -724,9 +720,7 @@ Vertex.prototype = {
this.wb.dependencyFormulas.deleteMasterNodes2( slave.sheetId, slave.cellId ); this.wb.dependencyFormulas.deleteMasterNodes2( slave.sheetId, slave.cellId );
cell.formulaParsed.stretchArea( this, sNewName ); cell.formulaParsed.stretchArea( this, sNewName );
cell.setFormula(cell.formulaParsed.assemble(), true); cell.setFormula(cell.formulaParsed.assemble(), true);
addToArrRecalc(this.wb, slave.sheetId, slave.cellId); addToArrRecalc(slave.sheetId, cell);
this.wb.needRecalc.nodes[slave.nodeId] = [slave.sheetId, slave.cellId ];
this.wb.needRecalc.length++;
} }
} }
this.bbox = bboxTo this.bbox = bboxTo
...@@ -846,14 +840,14 @@ function unLockDraw(wb){ ...@@ -846,14 +840,14 @@ function unLockDraw(wb){
arrRecalc = {}; arrRecalc = {};
} }
} }
function addToArrRecalc(wb, sheetId, cellId){ function addToArrRecalc(sheetId, cell){
var temp = arrRecalc[sheetId]; var temp = arrRecalc[sheetId];
if( !temp ) if( !temp )
{ {
temp = {}; temp = [];
arrRecalc[sheetId] = temp; arrRecalc[sheetId] = temp;
} }
temp[cellId] = cellId; temp.push(cell);
} }
function buildRecalc(_wb,notrec){ function buildRecalc(_wb,notrec){
var ws; var ws;
...@@ -861,7 +855,16 @@ function buildRecalc(_wb,notrec){ ...@@ -861,7 +855,16 @@ function buildRecalc(_wb,notrec){
for( var id in arrRecalc ){ for( var id in arrRecalc ){
ws = _wb.getWorksheetById(id); ws = _wb.getWorksheetById(id);
if (ws) { if (ws) {
ws._BuildDependencies(arrRecalc[id]); var temp = arrRecalc[id];
var _rec = {};
for(var i = 0, length = temp.length; i < length; ++i)
{
var cellId = temp[i].oId.getID();
_rec[cellId] = cellId;
_wb.needRecalc.nodes[getVertexId(id, cellId)] = [id, cellId ];
_wb.needRecalc.length++;
}
ws._BuildDependencies(_rec);
} }
} }
if(!notrec) if(!notrec)
...@@ -1252,7 +1255,7 @@ Workbook.prototype.replaceWorksheet=function(indexFrom, indexTo){ ...@@ -1252,7 +1255,7 @@ Workbook.prototype.replaceWorksheet=function(indexFrom, indexTo){
var _c = _ws.getCell2(cID).getCells()[0]; var _c = _ws.getCell2(cID).getCells()[0];
_c.setFormula(_c.formulaParsed.moveSheet(tempW).assemble());//Перестраиваем трехмерные ссылки в формуле. _c.setFormula(_c.formulaParsed.moveSheet(tempW).assemble());//Перестраиваем трехмерные ссылки в формуле.
this.dependencyFormulas.deleteMasterNodes(_ws.Id, cID); this.dependencyFormulas.deleteMasterNodes(_ws.Id, cID);
addToArrRecalc(this, _ws.getId(), cID); addToArrRecalc(_ws.getId(), _c);
// this.needRecalc[ getVertexId(_ws.getId(),cID) ] = [ _ws.getId(),cID ]; // this.needRecalc[ getVertexId(_ws.getId(),cID) ] = [ _ws.getId(),cID ];
// if( this.needRecalc.length < 0) this.needRecalc.length = 0; // if( this.needRecalc.length < 0) this.needRecalc.length = 0;
// this.needRecalc.length++; // this.needRecalc.length++;
...@@ -1260,7 +1263,7 @@ Workbook.prototype.replaceWorksheet=function(indexFrom, indexTo){ ...@@ -1260,7 +1263,7 @@ Workbook.prototype.replaceWorksheet=function(indexFrom, indexTo){
else if( f.indexOf(_ws.getName()) < 0 ){ else if( f.indexOf(_ws.getName()) < 0 ){
this.dependencyFormulas.deleteMasterNodes(_ws.Id, cID); this.dependencyFormulas.deleteMasterNodes(_ws.Id, cID);
_ws._BuildDependencies({id:cID}); _ws._BuildDependencies({id:cID});
addToArrRecalc(this, _ws.getId(), cID); addToArrRecalc(_ws.getId(), _c);
// this.needRecalc[ getVertexId(_ws.getId(),cID) ] = [ _ws.getId(),cID ]; // this.needRecalc[ getVertexId(_ws.getId(),cID) ] = [ _ws.getId(),cID ];
// if( this.needRecalc.length < 0) this.needRecalc.length = 0; // if( this.needRecalc.length < 0) this.needRecalc.length = 0;
// this.needRecalc.length++; // this.needRecalc.length++;
...@@ -3082,7 +3085,7 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo, copyRange){ ...@@ -3082,7 +3085,7 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo, copyRange){
oTempCell.formulaParsed = oTempCell.formulaParsed.changeOffset(offset); oTempCell.formulaParsed = oTempCell.formulaParsed.changeOffset(offset);
oTempCell.sFormula = oTempCell.formulaParsed.assemble(); oTempCell.sFormula = oTempCell.formulaParsed.assemble();
addToArrRecalc(this.workbook, this.getId(), oTempCell.getName()); addToArrRecalc(this.getId(), oTempCell);
} }
} }
} }
...@@ -3644,7 +3647,7 @@ Cell.prototype.setValue=function(val,callback){ ...@@ -3644,7 +3647,7 @@ Cell.prototype.setValue=function(val,callback){
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()))
addToArrRecalc(this.ws.workbook, this.ws.getId(), this.oId.getID()); addToArrRecalc(this.ws.getId(), this);
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++;
...@@ -6709,9 +6712,7 @@ Range.prototype._sortByArray=function(oBBox, aSortData, bUndo){ ...@@ -6709,9 +6712,7 @@ Range.prototype._sortByArray=function(oBBox, aSortData, bUndo){
var sNewName = oCurCell.getName(); var sNewName = oCurCell.getName();
oCurCell.setFormula(oCurCell.formulaParsed.changeOffset({offsetCol:0, offsetRow:shift}).assemble());//получаем новую формулу, путем сдвига входящих в нее ссылок на ячейки на offsetCol и offsetRow. не путать с shiftCells - меняет одну конкретную ячейку в формуле, changeOffset - меняет оффсет для всех входящих в формулу ячеек. oCurCell.setFormula(oCurCell.formulaParsed.changeOffset({offsetCol:0, offsetRow:shift}).assemble());//получаем новую формулу, путем сдвига входящих в нее ссылок на ячейки на offsetCol и offsetRow. не путать с shiftCells - меняет одну конкретную ячейку в формуле, changeOffset - меняет оффсет для всех входящих в формулу ячеек.
this.worksheet.workbook.dependencyFormulas.deleteMasterNodes2( this.worksheet.Id, lastName );//разрываем ссылки между старой ячейкой и ведущими ячейками для нее. this.worksheet.workbook.dependencyFormulas.deleteMasterNodes2( this.worksheet.Id, lastName );//разрываем ссылки между старой ячейкой и ведущими ячейками для нее.
addToArrRecalc(this.worksheet.workbook, this.worksheet.getId(), sNewName); addToArrRecalc(this.worksheet.getId(), oCurCell);
this.worksheet.workbook.needRecalc.nodes[ getVertexId(this.worksheet.getId(),sNewName) ] = [ this.worksheet.getId(),sNewName ];
this.worksheet.workbook.needRecalc.length++;
} }
} }
else else
......
...@@ -4058,7 +4058,7 @@ RangeDataManager.prototype = { ...@@ -4058,7 +4058,7 @@ RangeDataManager.prototype = {
if(null != item.to) if(null != item.to)
this.add(item.to, item.elem.data); this.add(item.to, item.elem.data);
} }
this.fChange = fOldChange;
}, },
move : function(from, to) move : function(from, to)
{ {
......
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