Commit cbbd8cd6 authored by konovalovsergey's avatar konovalovsergey

Revert "fix bug 32828"

This reverts commit f83afbce.
parent 296fab4b
...@@ -896,9 +896,6 @@ CHistory.prototype.Get_DeleteIndex = function () { ...@@ -896,9 +896,6 @@ CHistory.prototype.Get_DeleteIndex = function () {
} }
} }
} }
if (DeleteIndex > 0 && this.workbook.undoRedoSheetView.IsChangedState()) {
DeleteIndex += 1;
}
return DeleteIndex; return DeleteIndex;
}; };
/** @returns {boolean} */ /** @returns {boolean} */
...@@ -923,15 +920,10 @@ CHistory.prototype.GetSerializeArray = function() ...@@ -923,15 +920,10 @@ CHistory.prototype.GetSerializeArray = function()
for(var j = 0, length2 = point.Items.length; j < length2; ++j) for(var j = 0, length2 = point.Items.length; j < length2; ++j)
{ {
var elem = point.Items[j]; var elem = point.Items[j];
if (!elem.LocalChange) { aPointChanges.push(new AscCommonExcel.UndoRedoItemSerializable(elem.Class, elem.Type, elem.SheetId, elem.Range, elem.Data, elem.LocalChange));
aPointChanges.push(new AscCommonExcel.UndoRedoItemSerializable(elem.Class, elem.Type, elem.SheetId, elem.Range, elem.Data, elem.LocalChange));
}
} }
aRes.push(aPointChanges); aRes.push(aPointChanges);
} }
if (aRes.length > 0 && this.workbook.undoRedoSheetView.IsChangedState()) {
aPointChanges.push(new AscCommonExcel.UndoRedoItemSerializable(this.workbook.undoRedoSheetView, null, null, null, null, false));
}
return aRes; return aRes;
}; };
//функция, которая перемещает последнее действие на первую позицию(в текущей точке) //функция, которая перемещает последнее действие на первую позицию(в текущей точке)
......
...@@ -3789,146 +3789,6 @@ UndoRedoAutoFilters.prototype = { ...@@ -3789,146 +3789,6 @@ UndoRedoAutoFilters.prototype = {
UndoRedoSparklines.prototype.UndoRedo = function (Type, Data, nSheetId, bUndo) { UndoRedoSparklines.prototype.UndoRedo = function (Type, Data, nSheetId, bUndo) {
}; };
function UndoRedoSheetView(wb) {
this.wb = wb;
this.lastState = null;
this.Id = AscCommon.g_oIdCounter.Get_NewId();
g_oTableId.Add(this, this.Id);
}
UndoRedoSheetView.prototype.Type = -1;
UndoRedoSheetView.prototype.Get_Id = function() {
return this.Id;
};
UndoRedoSheetView.prototype.SaveState = function() {
this.lastState = this._getState();
};
UndoRedoSheetView.prototype.IsChangedState = function() {
return true;
};
UndoRedoSheetView.prototype.Save_Changes = function(data, w) {
w.WriteLong(this.Type);
var diff = this._getDiffState(this.lastState, this._getState());
if (null != diff.active) {
w.WriteByte(0);
w.WriteString2(diff.active);
}
for (var sheetId in diff.sheets) {
var elem = diff.sheets[sheetId];
if (elem) {
w.WriteByte(1);
w.WriteString2(sheetId);
if (null != elem.zoom) {
w.WriteByte(2);
w.WriteLong(elem.zoom);
}
if (null != elem.select) {
w.WriteByte(3);
elem.select.WriteToBinary(w);
}
w.WriteByte(255);
}
}
w.WriteByte(255);
};
UndoRedoSheetView.prototype.Load_Changes = function(r) {
var state = {active: null, sheets: {}};
r.GetLong();
var type;
while ((type = r.GetByte()) !== 255) {
if (0 === type) {
state.active = r.GetString2();
} else if (1 === type) {
var sheetId = r.GetString2();
var ws = this.wb.getWorksheetById(sheetId);
var elem = {zoom: null, select: null};
var subType;
while ((subType = r.GetByte()) !== 255) {
if (2 == subType) {
elem.zoom = r.GetLong();
} else if (3 == subType) {
elem.select = new AscCommonExcel.SelectionRange(ws);
elem.select.ReadFromBinary(r);
}
}
state.sheets[sheetId] = elem;
}
}
this._setState(state);
};
UndoRedoSheetView.prototype._getState = function() {
var wsActive = this.wb.getActiveWs();
var res = {active: wsActive.getId(), sheets: {}};
for (var i = 0; i < this.wb.getWorksheetCount(); ++i) {
var ws = this.wb.getWorksheet(i);
res.sheets[ws.getId()] = {zoom: ws.sheetViews[0].zoomScale, select: ws.selectionRange.clone()};
}
return res;
};
UndoRedoSheetView.prototype._setState = function(state) {
var bApply = window["NATIVE_EDITOR_ENJINE"] || !this.wb.oApi.IsSendDocumentLoadCompleate;
if (bApply) {
if (null != state.active) {
var ws = this.wb.getWorksheetById(state.active);
if (ws) {
this.wb.setActive(ws.getIndex());
}
}
}
var sheetIdActive = this.wb.getActiveWs().getId();
for (var sheetId in state.sheets) {
if (bApply || sheetIdActive !== sheetId) {
var elem = state.sheets[sheetId];
var ws = this.wb.getWorksheetById(sheetId);
if (elem && ws) {
if (null != elem.zoom) {
ws.sheetViews[0].asc_setZoomScale(elem.zoom);
}
if (null != elem.select) {
ws.selectionRange = elem.select;
}
}
}
}
};
UndoRedoSheetView.prototype._getDiffState = function(stateBase, stateCur) {
if (!stateCur) {
return stateBase;
}
if (!stateBase) {
return stateCur;
}
//always write stateCur.active to set active
var res = {active: stateCur.active, sheets: {}};
for (var sheetId in stateCur.sheets) {
var elemCur = stateCur.sheets[sheetId];
var elemBase = stateBase.sheets[sheetId];
if (!elemCur) {
res.sheets[sheetId] = elemBase;
continue;
}
if (!elemBase) {
res.sheets[sheetId] = elemCur;
continue;
}
var bAdd = false;
var elemNew = {zoom: null, select: null};
if (elemBase.zoom !== elemCur.zoom) {
bAdd = true;
elemNew.zoom = elemCur.zoom;
}
if (!elemBase.select.isEqual2(elemCur.select)) {
bAdd = true;
elemNew.select = elemCur.select;
}
if (bAdd) {
res.sheets[sheetId] = elemNew;
}
}
return res;
};
//----------------------------------------------------------export---------------------------------------------------- //----------------------------------------------------------export----------------------------------------------------
window['AscCommonExcel'] = window['AscCommonExcel'] || {}; window['AscCommonExcel'] = window['AscCommonExcel'] || {};
window['AscCommonExcel'].UndoRedoItemSerializable = UndoRedoItemSerializable; window['AscCommonExcel'].UndoRedoItemSerializable = UndoRedoItemSerializable;
...@@ -3957,7 +3817,6 @@ UndoRedoAutoFilters.prototype = { ...@@ -3957,7 +3817,6 @@ UndoRedoAutoFilters.prototype = {
window['AscCommonExcel'].UndoRedoComment = UndoRedoComment; window['AscCommonExcel'].UndoRedoComment = UndoRedoComment;
window['AscCommonExcel'].UndoRedoAutoFilters = UndoRedoAutoFilters; window['AscCommonExcel'].UndoRedoAutoFilters = UndoRedoAutoFilters;
window['AscCommonExcel'].UndoRedoSparklines = UndoRedoSparklines; window['AscCommonExcel'].UndoRedoSparklines = UndoRedoSparklines;
window['AscCommonExcel'].UndoRedoSheetView = UndoRedoSheetView;
window['AscCommonExcel'].g_oUndoRedoWorkbook = null; window['AscCommonExcel'].g_oUndoRedoWorkbook = null;
window['AscCommonExcel'].g_oUndoRedoCell = null; window['AscCommonExcel'].g_oUndoRedoCell = null;
......
...@@ -1389,7 +1389,6 @@ ...@@ -1389,7 +1389,6 @@
this.maxDigitWidth = 0; this.maxDigitWidth = 0;
this.paddingPlusBorder = 0; this.paddingPlusBorder = 0;
this.undoRedoSheetView = null;
} }
Workbook.prototype.init=function(tableCustomFunc, bNoBuildDep, bSnapshot){ Workbook.prototype.init=function(tableCustomFunc, bNoBuildDep, bSnapshot){
if(this.nActive < 0) if(this.nActive < 0)
...@@ -1433,8 +1432,6 @@ ...@@ -1433,8 +1432,6 @@
if (bSnapshot) { if (bSnapshot) {
this.snapshot = this._getSnapshot(); this.snapshot = this._getSnapshot();
} }
this.undoRedoSheetView = new AscCommonExcel.UndoRedoSheetView(this);
this.undoRedoSheetView.SaveState();
}; };
Workbook.prototype.rebuildColors=function(){ Workbook.prototype.rebuildColors=function(){
AscCommonExcel.g_oColorManager.rebuildColors(); AscCommonExcel.g_oColorManager.rebuildColors();
...@@ -1884,7 +1881,6 @@ ...@@ -1884,7 +1881,6 @@
} }
} }
this.aCollaborativeActions = []; this.aCollaborativeActions = [];
this.undoRedoSheetView.SaveState();
this.snapshot = this._getSnapshot(); this.snapshot = this._getSnapshot();
} }
return aRes; return aRes;
......
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