Commit e3e1659f authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Пересчет lock-ов переделал для Excel (теперь это не хранится в базе данных).

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@59458 954022d7-b5bf-4e40-9824-e11837661b57
parent 866119f6
......@@ -26,6 +26,7 @@
this.onStartCoAuthoring = options.onStartCoAuthoring;
this.onEndCoAuthoring = options.onEndCoAuthoring;
this.onUnSaveLock = options.onUnSaveLock;
this.onRecalcLocks = options.onRecalcLocks;
}
}
......@@ -47,6 +48,7 @@
this._CoAuthoringApi.onStartCoAuthoring = function (e) {t.callback_OnStartCoAuthoring(e);};
this._CoAuthoringApi.onEndCoAuthoring = function (e) {t.callback_OnEndCoAuthoring(e);};
this._CoAuthoringApi.onUnSaveLock = function () {t.callback_OnUnSaveLock();};
this._CoAuthoringApi.onRecalcLocks = function (e) {t.callback_OnRecalcLocks(e);};
this._CoAuthoringApi.init(user, docid, token, callback, editorType, documentFormatSave, isViewer);
this._onlineWork = true;
......@@ -118,9 +120,9 @@
}
};
CDocsCoApi.prototype.saveChanges = function (arrayChanges, deleteIndex) {
CDocsCoApi.prototype.saveChanges = function (arrayChanges, deleteIndex, excelAdditionalInfo) {
if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.saveChanges(arrayChanges, null, deleteIndex);
this._CoAuthoringApi.saveChanges(arrayChanges, null, deleteIndex, excelAdditionalInfo);
}
};
......@@ -228,6 +230,11 @@
this.onUnSaveLock();
};
CDocsCoApi.prototype.callback_OnRecalcLocks = function (e) {
if (this.onRecalcLocks)
this.onRecalcLocks(e);
};
/** States
* -1 - reconnect state
* 0 - not initialized
......@@ -250,6 +257,7 @@
this.onFirstLoadChangesEnd = options.onFirstLoadChangesEnd;
this.onConnectionStateChanged = options.onConnectionStateChanged;
this.onUnSaveLock = options.onUnSaveLock;
this.onRecalcLocks = options.onRecalcLocks;
}
this._state = 0;
// Online-пользователи в документе
......@@ -282,6 +290,8 @@
this.lastOtherSaveTime = -1;
// Локальный индекс изменений
this.changesIndex = 0;
// Дополнительная информация для Excel
this.excelAdditionalInfo = null;
this._url = "";
......@@ -434,13 +444,14 @@
this.saveChanges(this.arrayChanges, this.currentIndex);
};
DocsCoApi.prototype.saveChanges = function (arrayChanges, currentIndex, deleteIndex) {
DocsCoApi.prototype.saveChanges = function (arrayChanges, currentIndex, deleteIndex, excelAdditionalInfo) {
if (null === currentIndex) {
this.deleteIndex = deleteIndex;
if (null != this.deleteIndex && -1 !== this.deleteIndex)
this.deleteIndex += this.changesIndex;
this.currentIndex = 0;
this.arrayChanges = arrayChanges;
this.excelAdditionalInfo = excelAdditionalInfo;
} else {
this.currentIndex = currentIndex;
}
......@@ -460,10 +471,11 @@
t._reSaveChanges();
}, this.errorTimeOut);
this._send({"type": "saveChanges", "changes": JSON.stringify(arrayChanges.slice(startIndex, endIndex)),
"startSaveChanges": (startIndex === 0), "endSaveChanges": (endIndex === arrayChanges.length),
"isCoAuthoring": this.isCoAuthoring, "isExcel": this._isExcel, "deleteIndex": this.deleteIndex,
"startIndex": startIndex});
this._send({'type': 'saveChanges', 'changes': JSON.stringify(arrayChanges.slice(startIndex, endIndex)),
'startSaveChanges': (startIndex === 0), 'endSaveChanges': (endIndex === arrayChanges.length),
'isCoAuthoring': this.isCoAuthoring, 'isExcel': this._isExcel, 'deleteIndex': this.deleteIndex,
'startIndex': startIndex,
'excelAdditionalInfo': this.excelAdditionalInfo ? JSON.stringify(this.excelAdditionalInfo) : null});
};
DocsCoApi.prototype.unLockDocument = function (isSave) {
......@@ -605,6 +617,8 @@
this.onLocksReleasedEnd();
}
this._updateChanges(data["changes"], data["changesIndex"], false);
if (this.onRecalcLocks)
this.onRecalcLocks(data["excelAdditionalInfo"]);
};
DocsCoApi.prototype._onStartCoAuthoring = function (isStartEvent) {
......
......@@ -1631,29 +1631,24 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
}
};
this.CoAuthoringApi.onSaveChanges = function (e, userId, bFirstLoad) {
// bSendEvent = false - это означает, что мы загружаем имеющиеся изменения при открытии
var bAddChanges = false;
var oRecalcIndexColumns = null, oRecalcIndexRows = null;
if (!e.hasOwnProperty("type")) {
t.collaborativeEditing.addChanges(e);
bAddChanges = true;
} else if (!bFirstLoad) {
if ("10" === e["type"]) {
if (!bFirstLoad && t.IsSendDocumentLoadCompleate)
t.syncCollaborativeChanges();
};
this.CoAuthoringApi.onRecalcLocks = function (excelAdditionalInfo) {
if (!excelAdditionalInfo)
return;
var tmpAdditionalInfo = JSON.parse(excelAdditionalInfo);
// Это мы получили recalcIndexColumns и recalcIndexRows
oRecalcIndexColumns = t.collaborativeEditing.addRecalcIndex('0', e['indexCols']);
oRecalcIndexRows = t.collaborativeEditing.addRecalcIndex('1', e['indexRows']);
}
}
var oRecalcIndexColumns = t.collaborativeEditing.addRecalcIndex('0', tmpAdditionalInfo['indexCols']);
var oRecalcIndexRows = t.collaborativeEditing.addRecalcIndex('1', tmpAdditionalInfo['indexRows']);
// Теперь нужно пересчитать индексы для lock-элементов
if (null !== oRecalcIndexColumns || null !== oRecalcIndexRows) {
t.collaborativeEditing._recalcLockArray(c_oAscLockTypes.kLockTypeMine, oRecalcIndexColumns, oRecalcIndexRows);
t.collaborativeEditing._recalcLockArray(c_oAscLockTypes.kLockTypeOther, oRecalcIndexColumns, oRecalcIndexRows);
}
// т.е. если bSendEvent не задан, то посылаем сообщение + если мы уже открыли документ
if (true === bAddChanges && !bFirstLoad && t.IsSendDocumentLoadCompleate)
t.syncCollaborativeChanges();
};
this.CoAuthoringApi.onFirstLoadChangesEnd = function () {
t.asyncServerIdEndLoaded();
......@@ -1715,13 +1710,14 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
spreadsheet_api.prototype._onSaveChanges = function (deleteIndex, recalcIndexColumns, recalcIndexRows) {
if (this.IsSendDocumentLoadCompleate) {
var arrChanges = this.wbModel.SerializeHistory();
var excelAdditionalInfo = null;
if (this.collaborativeEditing.getCollaborativeEditing()) {
// Пересчетные индексы добавляем только если мы не одни
if (recalcIndexColumns || recalcIndexRows)
arrChanges.push({"indexCols" : recalcIndexColumns, "indexRows" : recalcIndexRows, "type" : "10"});
excelAdditionalInfo = {"indexCols" : recalcIndexColumns, "indexRows" : recalcIndexRows};
}
if (0 < arrChanges.length || null !== deleteIndex)
this.CoAuthoringApi.saveChanges(arrChanges, deleteIndex);
if (0 < arrChanges.length || null !== deleteIndex || null !== excelAdditionalInfo)
this.CoAuthoringApi.saveChanges(arrChanges, deleteIndex, excelAdditionalInfo);
else
this.CoAuthoringApi.unLockDocument(true);
}
......
......@@ -4957,7 +4957,7 @@ var gUndoInsDelCellsFlag = true;
{
if(ref)
{
var clearRange = new Range(aWs, ref.r1, ref.c1, ref.r2, ref.c2)
var clearRange = new Range(aWs, ref.r1, ref.c1, ref.r2, ref.c2);
clearRange.setTableStyle(null);
}
......
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