Skip to content

Commit

Permalink
[se] Fix bug 62943
Browse files Browse the repository at this point in the history
  • Loading branch information
GoshaZotov authored and K0R0L committed Jun 8, 2023
1 parent 5b67438 commit 3528702
Showing 1 changed file with 35 additions and 47 deletions.
82 changes: 35 additions & 47 deletions cell/view/WorkbookView.js
Original file line number Diff line number Diff line change
Expand Up @@ -5410,7 +5410,6 @@
}

var t = this;

if ((oldObj && !oldObj._ws) || (newObj && !newObj._ws)) {
return;
}
Expand All @@ -5421,7 +5420,10 @@
return;
}

var doEdit = function() {
var callback = function(success) {
if (!success) {
return;
}
History.Create_NewPoint();
History.StartTransaction();

Expand All @@ -5446,65 +5448,45 @@

History.EndTransaction();

//t.handlers.trigger("asc_onEditDefName", oldName, newName);

//условие исключает второй вызов asc_onRefreshDefNameList(первый в unlockDefName)
if (!(t.collaborativeEditing.getCollaborativeEditing() && t.collaborativeEditing.getFast())) {
t.handlers.trigger("asc_onRefreshUserProtectedRangesList");
}
};


var callbackLockObj = function(res) {
if (res) {
let arrLocks = [];
if (wsFrom) {
arrLocks.push({id: lockId, ws: wsFrom});
} else if (wsTo) {
arrLocks.push({id: lockId, ws: wsTo});
}
t._isLockedUserProtectedRange(doEdit, arrLocks);
}
};

//когда меняем диапазон с одного листа на другой, два раза нужно лочить, вначале на одном листе, потом на другом
let wsFrom = oldObj ? oldObj._ws : null;
let wsTo = newObj ? newObj._ws : null;

let wsViewFrom;
let wsViewTo;
for (let i = 0; i < this.wsViews.length; i++) {
if (this.wsViews[i]) {
if (this.wsViews[i].model === wsFrom) {
wsViewFrom = this.wsViews[i];
}
if (this.wsViews[i].model === wsTo) {
wsViewTo = this.wsViews[i];
}
}
}

let lockId = oldObj ? oldObj.Id : newObj.Id;
let lockRangeFrom = oldObj ? oldObj.ref : null;
let lockRangeTo = newObj ? newObj.ref : null;

function callback (res) {
if (res) {
if (wsViewFrom && wsViewTo) {
wsViewTo._isLockedCells(lockRangeTo, null, callbackLockObj);
} else if (wsTo) {
callbackLockObj(true);
}
}
//object locks info
let aLocksInfo = [];
let aLockIds = [];
if (wsFrom && oldObj) {
aLockIds.push({id: oldObj.Id, ws: wsFrom});
}
if (wsTo && newObj) {
aLockIds.push({id: newObj.Id, ws: wsTo});
}
this._getLockedUserProtectedRange(aLockIds, aLocksInfo);

if (wsViewFrom) {
wsViewFrom._isLockedCells(lockRangeFrom, null, callback);
} else if (wsViewTo) {
wsViewTo._isLockedCells(lockRangeTo, null, callback);
} else {
callback(true);
//cells locks info
if (wsFrom && lockRangeFrom) {
aLocksInfo.push(this.collaborativeEditing.getLockInfo(AscCommonExcel.c_oAscLockTypeElem.Range,
null, wsFrom.getId(),
new AscCommonExcel.asc_CCollaborativeRange(lockRangeFrom.c1,
lockRangeFrom.r1, lockRangeFrom.c2, lockRangeFrom.r2)));
}
if (wsTo && lockRangeTo) {
aLocksInfo.push(this.collaborativeEditing.getLockInfo(AscCommonExcel.c_oAscLockTypeElem.Range,
null, wsTo.getId(),
new AscCommonExcel.asc_CCollaborativeRange(lockRangeTo.c1,
lockRangeTo.r1, lockRangeTo.c2, lockRangeTo.r2)));
}

this.collaborativeEditing.lock(aLocksInfo, callback);
};

WorkbookView.prototype.deleteUserProtectedRanges = function(arr) {
Expand Down Expand Up @@ -5557,14 +5539,20 @@

WorkbookView.prototype._isLockedUserProtectedRange = function (callback, aIds) {
let aLockInfo = [];
this._getLockedUserProtectedRange(aIds, aLockInfo);
this.collaborativeEditing.lock(aLockInfo, callback);
};

WorkbookView.prototype._getLockedUserProtectedRange = function (aIds, aLockInfo) {
if (!aIds && !aLockInfo) {
return;
}
let lockInfo;
for (let i = 0; i < aIds.length; i++) {
lockInfo = this.collaborativeEditing.getLockInfo(AscCommonExcel.c_oAscLockTypeElem.Object,
AscCommonExcel.c_oAscLockTypeElemSubType.UserProtectedRange, aIds[i].ws.getId(), aIds[i].id);
aLockInfo.push(lockInfo);
}

this.collaborativeEditing.lock(aLockInfo, callback);
};

WorkbookView.prototype.cleanCache = function() {
Expand Down

0 comments on commit 3528702

Please sign in to comment.