Commit d1961821 authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov Committed by Alexander.Trofimov

fix: Bug 20008 - Не восстанавливается содержимое формулы после Undo удаления...

fix: Bug 20008 - Не восстанавливается содержимое формулы после Undo удаления строк, на которые ссылалась формула

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@49942 954022d7-b5bf-4e40-9824-e11837661b57
parent 182bb10a
...@@ -2246,8 +2246,6 @@ parserFormula.prototype = { ...@@ -2246,8 +2246,6 @@ parserFormula.prototype = {
setFormula:function ( formula ) { setFormula:function ( formula ) {
this.Formula = formula; this.Formula = formula;
this.cellId = _cellId;
this.ws = _ws;
this.value = null; this.value = null;
this.pCurrPos = 0; this.pCurrPos = 0;
this.elemArr = []; this.elemArr = [];
......
...@@ -31,6 +31,7 @@ var historyitem_Worksheet_CreateRow = 20; ...@@ -31,6 +31,7 @@ var historyitem_Worksheet_CreateRow = 20;
var historyitem_Worksheet_CreateCol = 21; var historyitem_Worksheet_CreateCol = 21;
var historyitem_Worksheet_CreateCell = 22; var historyitem_Worksheet_CreateCell = 22;
var historyitem_Worksheet_SetViewSettings = 23; var historyitem_Worksheet_SetViewSettings = 23;
var historyitem_Worksheet_RemoveCellFormula = 24;
var historyitem_RowCol_Fontname = 1; var historyitem_RowCol_Fontname = 1;
var historyitem_RowCol_Fontsize = 2; var historyitem_RowCol_Fontsize = 2;
......
...@@ -432,7 +432,7 @@ var UndoRedoDataTypes = new function() { ...@@ -432,7 +432,7 @@ var UndoRedoDataTypes = new function() {
}; };
}; };
function UndoRedoData_CellSimpleData(nRow, nCol, oOldVal, oNewVal){ function UndoRedoData_CellSimpleData(nRow, nCol, oOldVal, oNewVal, sFormula){
this.Properties = { this.Properties = {
Row: 0, Row: 0,
Col: 1, Col: 1,
...@@ -442,6 +442,7 @@ function UndoRedoData_CellSimpleData(nRow, nCol, oOldVal, oNewVal){ ...@@ -442,6 +442,7 @@ function UndoRedoData_CellSimpleData(nRow, nCol, oOldVal, oNewVal){
this.nCol = nCol; this.nCol = nCol;
this.oOldVal = oOldVal; this.oOldVal = oOldVal;
this.oNewVal = oNewVal; this.oNewVal = oNewVal;
this.sFormula = sFormula;
} }
UndoRedoData_CellSimpleData.prototype = { UndoRedoData_CellSimpleData.prototype = {
getType : function() getType : function()
...@@ -2964,6 +2965,24 @@ UndoRedoWoorksheet.prototype = { ...@@ -2964,6 +2965,24 @@ UndoRedoWoorksheet.prototype = {
else else
ws._removeCell(nRow, nCol); ws._removeCell(nRow, nCol);
} }
else if(historyitem_Worksheet_RemoveCellFormula == Type){
var nRow = Data.nRow;
var nCol = Data.nCol;
if(bUndo)
{
var sFormula = Data.sFormula
var cell = ws._getCell(nRow, nCol);
cell.setFormula(sFormula);
cell.formulaParsed.setFormula(sFormula);
if( !arrRecalc[ws.getId()] ){
arrRecalc[ws.getId()] = {};
}
arrRecalc[ws.getId()][cell.getName()] = cell.getName();
ws.workbook.needRecalc[ getVertexId(ws.getId(),cell.getName()) ] = [ ws.getId(),cell.getName() ];
if( ws.workbook.needRecalc.length < 0) ws.workbook.needRecalc.length = 0;
ws.workbook.needRecalc.length++;
}
}
else if(historyitem_Worksheet_ColProp == Type) else if(historyitem_Worksheet_ColProp == Type)
{ {
var index = Data.index; var index = Data.index;
......
...@@ -1110,17 +1110,15 @@ function unLockDraw(wb){ ...@@ -1110,17 +1110,15 @@ function unLockDraw(wb){
} }
} }
function buildRecalc(_wb){ function buildRecalc(_wb){
var wb = _wb, ws, ar; var ws;
if( lc > 1 ) return;
for( var id in arrRecalc ){ for( var id in arrRecalc ){
ws = wb.getWorksheetById(id); ws = _wb.getWorksheetById(id);
if (ws) { if (ws) {
ar = arrRecalc[id]; ws._BuildDependencies(arrRecalc[id]);
ws._BuildDependencies(ar);
} }
} }
recalc(wb) recalc(_wb)
} }
function searchCleenCacheArea(o1,o2){ function searchCleenCacheArea(o1,o2){
var o3 = {}; var o3 = {};
...@@ -1220,9 +1218,8 @@ function sortDependency(ws, ar){ ...@@ -1220,9 +1218,8 @@ function sortDependency(ws, ar){
} }
} }
function recalc(wb){ function recalc(wb){
var nR = wb.needRecalc, thas = wb, calculatedCells = new Object(), nRLength = nR.length, first = true,
var nR = wb.needRecalc, thas = wb, calculatedCells = {}, nRLength = nR.length, first = true, startActionOn = false, timerID, timeStart, timeEnd, timeCount = 0, timeoutID1, timeoutID2, sr = new Object();
startActionOn = false, timerID, timeStart, timeEnd, timeCount = 0, timeoutID1, timeoutID2, sr = {};
function R(){ function R(){
if( nR.length > 0 ){ if( nR.length > 0 ){
...@@ -1247,10 +1244,11 @@ function recalc(wb){ ...@@ -1247,10 +1244,11 @@ function recalc(wb){
sr2 = helpRecalc(dep1, nR, calculatedCells, thas); sr2 = helpRecalc(dep1, nR, calculatedCells, thas);
sr = searchCleenCacheArea(sr,searchCleenCacheArea(sr1,sr2)); sr = searchCleenCacheArea(sr,searchCleenCacheArea(sr1,sr2));
if( nR[id] ){ if ( nR[id] ) {
delete nR[id]; delete nR[id];
nR.length--; nR.length--;
} }
id = undefined;
} }
clearTimeout(timerID); clearTimeout(timerID);
timeEnd = (new Date()).getTime(); timeEnd = (new Date()).getTime();
...@@ -3217,6 +3215,22 @@ Woorksheet.prototype._removeCell=function(nRow, nCol, cell){ ...@@ -3217,6 +3215,22 @@ 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.getNodeByNodeId( getVertexId( this.Id, cell.getName() ) )
if ( node ) {
node = node.getSlaveEdges();
if ( node ) {
for ( var id in node ) {
if ( node[id].cell && node[id].cell.sFormula ){
History.Add(g_oUndoRedoWorksheet,
historyitem_Worksheet_RemoveCellFormula,
node[id].sheetId,
new Asc.Range(node[id].cell.oId.getCol0(), node[id].cell.oId.getRow0(), node[id].cell.oId.getCol0(), node[id].cell.oId.getRow0()),
new UndoRedoData_CellSimpleData(node[id].cell.oId.getRow0(), node[id].cell.oId.getCol0(), null, null, node[id].cell.sFormula));
}
}
}
}
if( !arrRecalc[this.getId()] ){ if( !arrRecalc[this.getId()] ){
arrRecalc[this.getId()] = {}; arrRecalc[this.getId()] = {};
} }
...@@ -3886,7 +3900,7 @@ Woorksheet.prototype.renameDependencyNodes = function(offset,oBBox,rec, noDelete ...@@ -3886,7 +3900,7 @@ Woorksheet.prototype.renameDependencyNodes = function(offset,oBBox,rec, noDelete
} }
} }
if ( false !== rec ) if ( false !== rec && lc <= 1 )
recalc(this.workbook); recalc(this.workbook);
} }
...@@ -4191,7 +4205,13 @@ Cell.prototype.setCellStyle=function(val){ ...@@ -4191,7 +4205,13 @@ Cell.prototype.setCellStyle=function(val){
this.oValue.cleanCache(); this.oValue.cleanCache();
}; };
Cell.prototype.setNumFormat=function(val){ Cell.prototype.setNumFormat=function(val){
var oRes = this.sm.setNumFormat(this, val); var oRes;
if( val == aStandartNumFormats[0] &&
this.formulaParsed && this.formulaParsed.value && this.formulaParsed.value.numFormat !== null &&
this.formulaParsed.value.numFormat !== undefined && aStandartNumFormats[this.formulaParsed.value.numFormat] )
oRes = this.sm.setNumFormat(this, aStandartNumFormats[this.formulaParsed.value.numFormat]);
else
oRes = this.sm.setNumFormat(this, val);
if(History.Is_On() && oRes.oldVal != oRes.newVal) if(History.Is_On() && oRes.oldVal != oRes.newVal)
History.Add(g_oUndoRedoCell, historyitem_Cell_Numformat, this.ws.getId(), new Asc.Range(0, this.oId.getRow0(), gc_nMaxCol0, this.oId.getRow0()), new UndoRedoData_CellSimpleData(this.oId.getRow0(), this.oId.getCol0(), oRes.oldVal, oRes.newVal)); History.Add(g_oUndoRedoCell, historyitem_Cell_Numformat, this.ws.getId(), new Asc.Range(0, this.oId.getRow0(), gc_nMaxCol0, this.oId.getRow0()), new UndoRedoData_CellSimpleData(this.oId.getRow0(), this.oId.getCol0(), oRes.oldVal, oRes.newVal));
this.bNeedCompileXfs = true; this.bNeedCompileXfs = true;
......
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