Commit 3e588c29 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Добавил событие asc_onDocumentUpdateVersion - эвент о том, что файл собрался и...

Добавил событие asc_onDocumentUpdateVersion - эвент о том, что файл собрался и не может больше редактироваться
Баг http://bugzserver/show_bug.cgi?id=25052 и http://bugzserver/show_bug.cgi?id=25810

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57833 954022d7-b5bf-4e40-9824-e11837661b57
parent 9450fa97
...@@ -471,7 +471,7 @@ function CCollaborativeChanges() ...@@ -471,7 +471,7 @@ function CCollaborativeChanges()
function CCollaborativeEditing() function CCollaborativeEditing()
{ {
this.m_bUse = false; // началось ли совместное редактирование this.m_nUseType = 1; // 1 - 1 клиент и мы сохраняем историю, -1 - несколько клиентов, 0 - переход из -1 в 1
this.m_aUsers = []; // Список текущих пользователей, редактирующих данный документ this.m_aUsers = []; // Список текущих пользователей, редактирующих данный документ
this.m_aChanges = []; // Массив с изменениями других пользователей this.m_aChanges = []; // Массив с изменениями других пользователей
...@@ -505,7 +505,13 @@ function CCollaborativeEditing() ...@@ -505,7 +505,13 @@ function CCollaborativeEditing()
this.Start_CollaborationEditing = function() this.Start_CollaborationEditing = function()
{ {
this.m_bUse = true; this.m_nUseType = -1;
};
this.End_CollaborationEditing = function()
{
if ( this.m_nUseType <= 0 )
this.m_nUseType = 0;
}; };
this.Add_User = function(UserId) this.Add_User = function(UserId)
...@@ -546,6 +552,7 @@ function CCollaborativeEditing() ...@@ -546,6 +552,7 @@ function CCollaborativeEditing()
this.Add_Unlock2 = function(Lock) this.Add_Unlock2 = function(Lock)
{ {
this.m_aNeedUnlock2.push( Lock ); this.m_aNeedUnlock2.push( Lock );
editor._onUpdateDocumentCanSave();
}; };
this.Apply_OtherChanges = function() this.Apply_OtherChanges = function()
...@@ -632,7 +639,7 @@ function CCollaborativeEditing() ...@@ -632,7 +639,7 @@ function CCollaborativeEditing()
// Генерируем свои изменения // Генерируем свои изменения
var PointsCount = 0; var PointsCount = 0;
if ( true === m_bUse ) if ( this.m_nUseType <= 0 )
{ {
// (ненужные точки предварительно удаляем) // (ненужные точки предварительно удаляем)
History.Clear_Redo(); History.Clear_Redo();
...@@ -704,9 +711,26 @@ function CCollaborativeEditing() ...@@ -704,9 +711,26 @@ function CCollaborativeEditing()
editor.CoAuthoringApi.saveChanges(aChanges); editor.CoAuthoringApi.saveChanges(aChanges);
// Чистим Undo/Redo if ( -1 === this.m_nUseType )
if(this.m_bUse) {
// Чистим Undo/Redo только во время совместного редактирования
History.Clear();
History.SavedIndex = null;
}
else if ( 0 === this.m_nUseType )
{
// Чистим Undo/Redo только во время совместного редактирования
History.Clear(); History.Clear();
History.SavedIndex = null;
this.m_nUseType = 1;
}
else
{
// Обновляем точку последнего сохранения в истории
History.Reset_SavedIndex();
}
editor.WordControl.m_oLogicDocument.Document_UpdateInterfaceState(); editor.WordControl.m_oLogicDocument.Document_UpdateInterfaceState();
editor.WordControl.m_oLogicDocument.Document_UpdateUndoRedoState(); editor.WordControl.m_oLogicDocument.Document_UpdateUndoRedoState();
...@@ -886,7 +910,7 @@ function CCollaborativeEditing() ...@@ -886,7 +910,7 @@ function CCollaborativeEditing()
editor.CoAuthoringApi.askLock( aIds, this.OnCallback_AskLock ); editor.CoAuthoringApi.askLock( aIds, this.OnCallback_AskLock );
// Ставим глобальный лок, только во время совместного редактирования // Ставим глобальный лок, только во время совместного редактирования
if ( true === this.m_bUse ) if ( -1 === this.m_nUseType )
this.m_bGlobalLock = true; this.m_bGlobalLock = true;
else else
{ {
...@@ -1185,6 +1209,9 @@ function CCollaborativeEditing() ...@@ -1185,6 +1209,9 @@ function CCollaborativeEditing()
} }
}; };
this.getOwnLocksLength = function () {
return this.m_aNeedUnlock2.length;
};
} }
var CollaborativeEditing = new CCollaborativeEditing(); var CollaborativeEditing = new CCollaborativeEditing();
......
...@@ -5018,6 +5018,7 @@ CPresentation.prototype = ...@@ -5018,6 +5018,7 @@ CPresentation.prototype =
// дублирование евента. когда будет undo-redo - тогда // дублирование евента. когда будет undo-redo - тогда
// эти евенты начнут отличаться // эти евенты начнут отличаться
editor.asc_fireCallback("asc_onDocumentModifiedChanged"); editor.asc_fireCallback("asc_onDocumentModifiedChanged");
editor._onUpdateDocumentCanSave();
} }
else else
{ {
......
...@@ -117,6 +117,7 @@ function asc_docs_api(name) ...@@ -117,6 +117,7 @@ function asc_docs_api(name)
this.CoAuthoringApi = new CDocsCoApi(); this.CoAuthoringApi = new CDocsCoApi();
this.isCoAuthoringEnable = true; this.isCoAuthoringEnable = true;
this.CoAuthoringApi.isPowerPoint = true; this.CoAuthoringApi.isPowerPoint = true;
this.isDocumentCanSave = false; // Флаг, говорит о возможности сохранять документ (активна кнопка save или нет)
/**************************************/ /**************************************/
// AutoSave // AutoSave
this.autoSaveGap = 0; // Интервал автосохранения (0 - означает, что автосохранения нет) в милесекундах this.autoSaveGap = 0; // Интервал автосохранения (0 - означает, что автосохранения нет) в милесекундах
...@@ -602,12 +603,22 @@ asc_docs_api.prototype.SetCollaborativeMarksShowType = function(Type) ...@@ -602,12 +603,22 @@ asc_docs_api.prototype.SetCollaborativeMarksShowType = function(Type)
asc_docs_api.prototype.GetCollaborativeMarksShowType = function(Type) asc_docs_api.prototype.GetCollaborativeMarksShowType = function(Type)
{ {
return this.CollaborativeMarksShowType; return this.CollaborativeMarksShowType;
} };
asc_docs_api.prototype.Clear_CollaborativeMarks = function() asc_docs_api.prototype.Clear_CollaborativeMarks = function()
{ {
CollaborativeEditing.Clear_CollaborativeMarks(true); CollaborativeEditing.Clear_CollaborativeMarks(true);
} };
asc_docs_api.prototype._onUpdateDocumentCanSave = function () {
// Можно модифицировать это условие на более быстрое (менять самим состояние в аргументах, а не запрашивать каждый раз)
var tmp = this.isDocumentModified() || (0 >= CollaborativeEditing.m_nUseType &&
0 !== CollaborativeEditing.getOwnLocksLength());
if (tmp !== this.isDocumentCanSave) {
this.isDocumentCanSave = tmp;
this.asc_fireCallback('asc_onDocumentCanSaveChanged', this.isDocumentCanSave);
}
};
/////////////////////////////////////////// ///////////////////////////////////////////
asc_docs_api.prototype.SetUnchangedDocument = function() asc_docs_api.prototype.SetUnchangedDocument = function()
...@@ -616,7 +627,8 @@ asc_docs_api.prototype.SetUnchangedDocument = function() ...@@ -616,7 +627,8 @@ asc_docs_api.prototype.SetUnchangedDocument = function()
this.isDocumentModify = false; this.isDocumentModify = false;
this.asc_fireCallback("asc_onDocumentModifiedChanged"); this.asc_fireCallback("asc_onDocumentModifiedChanged");
} this._onUpdateDocumentCanSave();
};
asc_docs_api.prototype.isDocumentModified = function() asc_docs_api.prototype.isDocumentModified = function()
{ {
...@@ -625,13 +637,20 @@ asc_docs_api.prototype.isDocumentModified = function() ...@@ -625,13 +637,20 @@ asc_docs_api.prototype.isDocumentModified = function()
return true; return true;
} }
return this.isDocumentModify; return this.isDocumentModify;
} };
/**
* Эта функция возвращает true, если есть изменения или есть lock-и в документе
*/
asc_docs_api.prototype.asc_isDocumentCanSave = function () {
return this.isDocumentCanSave;
};
asc_docs_api.prototype.sync_BeginCatchSelectedElements = function() asc_docs_api.prototype.sync_BeginCatchSelectedElements = function()
{ {
if (0 != this.SelectedObjectsStack.length) if (0 != this.SelectedObjectsStack.length)
this.SelectedObjectsStack.splice(0, this.SelectedObjectsStack.length); this.SelectedObjectsStack.splice(0, this.SelectedObjectsStack.length);
} };
asc_docs_api.prototype.sync_EndCatchSelectedElements = function(options) asc_docs_api.prototype.sync_EndCatchSelectedElements = function(options)
{ {
// ToDo chartStyleManager уже нет, когда будут правиться презентации - поправить!!! // ToDo chartStyleManager уже нет, когда будут правиться презентации - поправить!!!
...@@ -1414,6 +1433,9 @@ asc_docs_api.prototype.asc_OnSaveEnd = function (isDocumentSaved) { ...@@ -1414,6 +1433,9 @@ asc_docs_api.prototype.asc_OnSaveEnd = function (isDocumentSaved) {
this.CoAuthoringApi.unSaveChanges(); this.CoAuthoringApi.unSaveChanges();
if (!isDocumentSaved) if (!isDocumentSaved)
this.CoAuthoringApi.disconnect(); this.CoAuthoringApi.disconnect();
// Обновляем состояние возможности сохранения документа
this._onUpdateDocumentCanSave();
}; };
asc_docs_api.prototype.processSavedFile = function(url, bInner){ asc_docs_api.prototype.processSavedFile = function(url, bInner){
if(bInner) if(bInner)
......
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