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