mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-04-07 14:09:12 +08:00
[se] Make workbook changes unique; For bug 76642
This commit is contained in:
10
cell/api.js
10
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) {
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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 = [];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user