diff --git a/cell/api.js b/cell/api.js index b6f2b67fc2..0a1cce3f83 100644 --- a/cell/api.js +++ b/cell/api.js @@ -343,10 +343,12 @@ var editor; } }; - spreadsheet_api.prototype.initGlobalObjects = function(wbModel) { + spreadsheet_api.prototype.initGlobalObjects = function(wbModel, fileSize) { // global counters AscCommonExcel.UndoRedoClassTypes.Clean(); + // Use deterministic pseudo-random offset to make document changes unique (100 to fit in 1 byte) + AscCommonExcel.UndoRedoClassTypes.SetOffset((fileSize || 0) % 100); AscCommonExcel.g_oUndoRedoCell = new AscCommonExcel.UndoRedoCell(wbModel); AscCommonExcel.g_oUndoRedoWorksheet = new AscCommonExcel.UndoRedoWoorksheet(wbModel); AscCommonExcel.g_oUndoRedoWorkbook = new AscCommonExcel.UndoRedoWorkbook(wbModel); @@ -1849,13 +1851,13 @@ var editor; spreadsheet_api.prototype.OpenDocumentFromBin = function(url, gObject) { this.wbModel = new AscCommonExcel.Workbook(this.handlers, this, true); - this.initGlobalObjects(this.wbModel); + this.initGlobalObjects(this.wbModel, gObject.length); this.OpenDocumentFromBinNoInit(gObject); this._onEndOpen(); }; spreadsheet_api.prototype.OpenDocumentFromZip = function (data) { this.wbModel = new AscCommonExcel.Workbook(this.handlers, this, true); - this.initGlobalObjects(this.wbModel); + this.initGlobalObjects(this.wbModel, data.length); let res = this.OpenDocumentFromZipNoInit(data); this._onEndOpen(); return res; @@ -6684,7 +6686,7 @@ var editor; AscCommon.CurFileVersion = version; } this.wbModel = new AscCommonExcel.Workbook(this.handlers, this, true); - this.initGlobalObjects(this.wbModel); + this.initGlobalObjects(this.wbModel, base64File.length); this.isOpenOOXInBrowser = this["asc_isSupportFeature"]("ooxml") && AscCommon.checkOOXMLSignature(base64File); if (this.isOpenOOXInBrowser) { diff --git a/cell/model/Serialize.js b/cell/model/Serialize.js index e236a687a1..95f1947682 100644 --- a/cell/model/Serialize.js +++ b/cell/model/Serialize.js @@ -10495,12 +10495,6 @@ var oThis = this; if ( c_oSerWorksheetsTypes.Worksheet === type ) { - // Shift by deterministic pseudo-random offset to make document changes unique - if (AscCommon.g_oIdCounter.IsLoad()) { - for (let i = 0; i < length % 100; i++) { - AscCommon.g_oIdCounter.Get_NewId(); - } - } this.aMerged = []; this.aHyperlinks = []; var oNewWorksheet = new AscCommonExcel.Worksheet(this.wb, wb.aWorksheets.length); diff --git a/cell/model/UndoRedo.js b/cell/model/UndoRedo.js index b62024ce7d..96f33fbb65 100644 --- a/cell/model/UndoRedo.js +++ b/cell/model/UndoRedo.js @@ -2847,17 +2847,22 @@ function (window, undefined) { //для применения изменений var UndoRedoClassTypes = new function () { this.aTypes = []; + this.offset = 0; this.Add = function (fCreate) { var nRes = this.aTypes.length; this.aTypes.push(fCreate); - return nRes; + return nRes + this.offset; }; this.Create = function (nType) { - if (nType < this.aTypes.length) { - return this.aTypes[nType](); + const nTypeIndex = nType - this.offset; + if (0 <= nTypeIndex && nTypeIndex < this.aTypes.length) { + return this.aTypes[nTypeIndex](); } return null; }; + this.SetOffset = function (offset) { + this.offset = offset || 0; + }; this.Clean = function () { this.aTypes = []; };