Commit 053a42d4 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Добавил метод auth у DocsCoApi

Авторизацию теперь делаем на LoadDocument, иначе View-режим не выставляется
bug #30340


git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@64743 954022d7-b5bf-4e40-9824-e11837661b57
parent ad538b59
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
} }
} }
CDocsCoApi.prototype.init = function(user, docid, documentCallbackUrl, token, editorType, documentFormatSave, isViewer) { CDocsCoApi.prototype.init = function(user, docid, documentCallbackUrl, token, editorType, documentFormatSave) {
if (this._CoAuthoringApi && this._CoAuthoringApi.isRightURL()) { if (this._CoAuthoringApi && this._CoAuthoringApi.isRightURL()) {
var t = this; var t = this;
this._CoAuthoringApi.onAuthParticipantsChanged = function(e, count) { this._CoAuthoringApi.onAuthParticipantsChanged = function(e, count) {
...@@ -88,14 +88,21 @@ ...@@ -88,14 +88,21 @@
t.callback_OnFirstConnect(); t.callback_OnFirstConnect();
}; };
this._CoAuthoringApi.init(user, docid, documentCallbackUrl, token, editorType, documentFormatSave, isViewer); this._CoAuthoringApi.init(user, docid, documentCallbackUrl, token, editorType, documentFormatSave);
this._onlineWork = true; this._onlineWork = true;
} else { } else {
// Фиктивные вызовы // Фиктивные вызовы
this.onFirstConnect(); this.onFirstConnect();
}
};
CDocsCoApi.prototype.auth = function(isViewer) {
// Фиктивные вызовы
if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.auth(isViewer);
} else {
this.callback_OnSetIndexUser("123"); this.callback_OnSetIndexUser("123");
this.onFirstLoadChangesEnd(); this.onFirstLoadChangesEnd();
callback();
} }
}; };
...@@ -375,6 +382,7 @@ ...@@ -375,6 +382,7 @@
this._countEditUsers = 0; this._countEditUsers = 0;
this._countUsers = 0; this._countUsers = 0;
this.isAuthInit = false;
this._locks = {}; this._locks = {};
this._msgBuffer = []; this._msgBuffer = [];
this._lockCallbacks = {}; this._lockCallbacks = {};
...@@ -1059,10 +1067,9 @@ ...@@ -1059,10 +1067,9 @@
this._sendPrebuffered(); this._sendPrebuffered();
} }
//TODO: Add errors //TODO: Add errors
this.onFirstConnect();
}; };
DocsCoApi.prototype.init = function(user, docid, documentCallbackUrl, token, editorType, documentFormatSave, isViewer) { DocsCoApi.prototype.init = function(user, docid, documentCallbackUrl, token, editorType, documentFormatSave) {
this._user = user; this._user = user;
this._docid = docid; this._docid = docid;
this._documentCallbackUrl = documentCallbackUrl; this._documentCallbackUrl = documentCallbackUrl;
...@@ -1074,7 +1081,6 @@ ...@@ -1074,7 +1081,6 @@
this._isPresentation = c_oEditorId.Presentation === editorType; this._isPresentation = c_oEditorId.Presentation === editorType;
this._isAuth = false; this._isAuth = false;
this._documentFormatSave = documentFormatSave; this._documentFormatSave = documentFormatSave;
this._isViewer = isViewer;
this.bUserAlive = false; // Активность пользователя this.bUserAlive = false; // Активность пользователя
this.bSendUserAlive = false; // Отправлять ли активность пользователя this.bSendUserAlive = false; // Отправлять ли активность пользователя
...@@ -1084,6 +1090,42 @@ ...@@ -1084,6 +1090,42 @@
this._initSocksJs(); this._initSocksJs();
}; };
// Авторизация (ее нужно делать после выставления состояния редактора view-mode)
DocsCoApi.prototype.auth = function(isViewer) {
this.isAuthInit = true;
this._isViewer = isViewer;
if (this._locks) {
this.ownedLockBlocks = [];
//If we already have locks
for (var block in this._locks) if (this._locks.hasOwnProperty(block)) {
var lock = this._locks[block];
if (lock["state"] === 2) {
//Our lock.
this.ownedLockBlocks.push(lock["blockValue"]);
}
}
this._locks = {};
}
this._send({
'type': 'auth',
'docid': this._docid,
'documentCallbackUrl': this._documentCallbackUrl,
'token': this._token,
'user': {
'id': this._user.asc_getId(),
'name': this._user.asc_getUserName(),
'indexUser': this._indexUser
},
'editorType': this.editorType,
'lastOtherSaveTime': this.lastOtherSaveTime,
'block': this.ownedLockBlocks,
'sessionId': this._id,
'documentFormatSave': this._documentFormatSave,
'isViewer': this._isViewer,
'version': asc_coAuthV
});
};
DocsCoApi.prototype._initSocksJs = function() { DocsCoApi.prototype._initSocksJs = function() {
var t = this; var t = this;
var sockjs = this.sockjs = new SockJS(this.sockjs_url, null, {debug: true}); var sockjs = this.sockjs = new SockJS(this.sockjs_url, null, {debug: true});
...@@ -1095,37 +1137,11 @@ ...@@ -1095,37 +1137,11 @@
} }
t._state = ConnectionState.WaitAuth; t._state = ConnectionState.WaitAuth;
if (t._locks) { if (t.isAuthInit) {
t.ownedLockBlocks = []; t.auth(t._isViewer);
//If we already have locks } else {
for (var block in t._locks) if (t._locks.hasOwnProperty(block)) { t.onFirstConnect();
var lock = t._locks[block];
if (lock["state"] === 2) {
//Our lock.
t.ownedLockBlocks.push(lock["blockValue"]);
}
}
t._locks = {};
} }
t._send({
'type': 'auth',
'docid': t._docid,
'documentCallbackUrl': t._documentCallbackUrl,
'token': t._token,
'user': {
'id': t._user.asc_getId(),
'name': t._user.asc_getUserName(),
'indexUser': t._indexUser
},
'editorType': t.editorType,
'lastOtherSaveTime': t.lastOtherSaveTime,
'block': t.ownedLockBlocks,
'sessionId': t._id,
'documentFormatSave': t._documentFormatSave,
'isViewer': t._isViewer,
'version': asc_coAuthV
});
}; };
sockjs.onmessage = function(e) { sockjs.onmessage = function(e) {
//TODO: add checks and error handling //TODO: add checks and error handling
......
...@@ -501,12 +501,12 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -501,12 +501,12 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
} }
}; };
spreadsheet_api.prototype.asc_LoadDocument = function() { spreadsheet_api.prototype.asc_LoadDocument = function() {
var t = this; this.CoAuthoringApi.auth(this.asc_getViewerMode());
this.asc_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Open); this.asc_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Open);
if (!this.chartEditor) { if (!this.chartEditor) {
this._asc_open(function(response) { this._asc_open(function(response) {
t._startOpenDocument(response); this._startOpenDocument(response);
}); });
} }
}; };
...@@ -1719,7 +1719,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -1719,7 +1719,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
if (!(window["NATIVE_EDITOR_ENJINE"] || !this.documentId || !this.documentUrl)) { if (!(window["NATIVE_EDITOR_ENJINE"] || !this.documentId || !this.documentUrl)) {
this.CoAuthoringApi.set_url(null); this.CoAuthoringApi.set_url(null);
} }
this.CoAuthoringApi.init(t.User, t.documentId, t.documentCallbackUrl, 'fghhfgsjdgfjs', c_oEditorId.Spreadsheet, t.documentFormatSave, t.asc_getViewerMode()); this.CoAuthoringApi.init(t.User, t.documentId, t.documentCallbackUrl, 'fghhfgsjdgfjs', c_oEditorId.Spreadsheet, t.documentFormatSave);
}; };
spreadsheet_api.prototype._onSaveChanges = function(recalcIndexColumns, recalcIndexRows) { spreadsheet_api.prototype._onSaveChanges = function(recalcIndexColumns, recalcIndexRows) {
......
...@@ -795,48 +795,46 @@ asc_docs_api.prototype.asc_setDocInfo = function(c_DocInfo) ...@@ -795,48 +795,46 @@ asc_docs_api.prototype.asc_setDocInfo = function(c_DocInfo)
asc_docs_api.prototype.asc_setLocale = function(val) asc_docs_api.prototype.asc_setLocale = function(val)
{ {
}; };
asc_docs_api.prototype.LoadDocument = function() asc_docs_api.prototype.LoadDocument = function() {
{ this.CoAuthoringApi.auth(this.isViewMode);
this.WordControl.m_oDrawingDocument.m_bIsOpeningDocument = true;
this.WordControl.m_oDrawingDocument.m_bIsOpeningDocument = true;
// Меняем тип состояния (на открытие)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Open;
if (this.DocInfo.get_OfflineApp() === true) // Меняем тип состояния (на открытие)
{ this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Open;
this.OfflineAppDocumentStartLoad();
return;
}
if (documentId) { if (this.DocInfo.get_OfflineApp() === true) {
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Open); this.OfflineAppDocumentStartLoad();
var rData = { return;
"id" : documentId, }
"userid" : documentUserId,
"format" : documentFormat, if (documentId) {
"vkey" : documentVKey, this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Open);
"editorid" : c_oEditorId.Presentation, var rData = {
"c" : "open", "id": documentId,
"url" : documentUrl, "userid": documentUserId,
"title" : documentTitle, "format": documentFormat,
"embeddedfonts" : this.isUseEmbeddedCutFonts, "vkey": documentVKey,
"viewmode" : this.isViewMode "editorid": c_oEditorId.Presentation,
}; "c": "open",
"url": documentUrl,
sendCommand2(this, null, rData); "title": documentTitle,
} "embeddedfonts": this.isUseEmbeddedCutFonts,
else "viewmode": this.isViewMode
{ };
// ToDo убрать зависимость от this.FontLoader.fontFilesPath
documentUrl = this.FontLoader.fontFilesPath + "../PowerPoint/document/";
this.DocInfo.put_OfflineApp(true);
// For test create unique id sendCommand2(this, null, rData);
documentId = "test_presentation_id"; } else {
this.OfflineAppDocumentStartLoad(); // ToDo убрать зависимость от this.FontLoader.fontFilesPath
} documentUrl = this.FontLoader.fontFilesPath + "../PowerPoint/document/";
this.sync_zoomChangeCallback(this.WordControl.m_nZoomValue, this.WordControl.m_nZoomType); this.DocInfo.put_OfflineApp(true);
// For test create unique id
documentId = "test_presentation_id";
this.OfflineAppDocumentStartLoad();
}
this.sync_zoomChangeCallback(this.WordControl.m_nZoomValue, this.WordControl.m_nZoomType);
}; };
asc_docs_api.prototype.SetFontsPath = function(path) asc_docs_api.prototype.SetFontsPath = function(path)
...@@ -4594,45 +4592,41 @@ asc_docs_api.prototype.SetDeviceInputHelperId = function(idKeyboard) ...@@ -4594,45 +4592,41 @@ asc_docs_api.prototype.SetDeviceInputHelperId = function(idKeyboard)
} }
window.ID_KEYBOARD_AREA.focus(); window.ID_KEYBOARD_AREA.focus();
}; };
asc_docs_api.prototype.SetViewMode = function( isViewMode ) asc_docs_api.prototype.SetViewMode = function(isViewMode) {
{ if (isViewMode) {
if (isViewMode) this.isViewMode = true;
{ this.ShowParaMarks = false;
this.isViewMode = true; this.WordControl.m_bIsRuler = false;
this.ShowParaMarks = false; this.WordControl.m_oDrawingDocument.ClearCachePages();
this.WordControl.m_bIsRuler = false; this.WordControl.HideRulers();
this.WordControl.m_oDrawingDocument.ClearCachePages();
this.WordControl.HideRulers(); if (null != this.WordControl.m_oLogicDocument) {
this.WordControl.m_oLogicDocument.viewMode = true;
if (null != this.WordControl.m_oLogicDocument) }
this.WordControl.m_oLogicDocument.viewMode = true; } else {
if (this.bInit_word_control === true && this.FontLoader.embedded_cut_manager.bIsCutFontsUse) {
this.isLoadNoCutFonts = true;
this.FontLoader.embedded_cut_manager.bIsCutFontsUse = false;
this.FontLoader.LoadDocumentFonts(this.WordControl.m_oLogicDocument.Fonts, true);
return;
} }
else
{
if (this.bInit_word_control === true && this.FontLoader.embedded_cut_manager.bIsCutFontsUse)
{
this.isLoadNoCutFonts = true;
this.FontLoader.embedded_cut_manager.bIsCutFontsUse = false;
this.FontLoader.LoadDocumentFonts(this.WordControl.m_oLogicDocument.Fonts, true);
return;
}
if ( this.bInit_word_control === true ) if (this.bInit_word_control === true) {
{ CollaborativeEditing.Apply_Changes();
CollaborativeEditing.Apply_Changes(); CollaborativeEditing.Release_Locks();
CollaborativeEditing.Release_Locks(); }
}
this.isUseEmbeddedCutFonts = false; this.isUseEmbeddedCutFonts = false;
this.isViewMode = false; this.isViewMode = false;
this.WordControl.checkNeedRules(); this.WordControl.checkNeedRules();
this.WordControl.m_oDrawingDocument.ClearCachePages(); this.WordControl.m_oDrawingDocument.ClearCachePages();
this.WordControl.OnResize(true); this.WordControl.OnResize(true);
if (null != this.WordControl.m_oLogicDocument) if (null != this.WordControl.m_oLogicDocument) {
this.WordControl.m_oLogicDocument.viewMode = false; this.WordControl.m_oLogicDocument.viewMode = false;
} }
}
}; };
asc_docs_api.prototype.SetUseEmbeddedCutFonts = function(bUse) asc_docs_api.prototype.SetUseEmbeddedCutFonts = function(bUse)
......
...@@ -825,47 +825,45 @@ asc_docs_api.prototype.asc_setLocale = function(val) ...@@ -825,47 +825,45 @@ asc_docs_api.prototype.asc_setLocale = function(val)
{ {
this.InterfaceLocale = val; this.InterfaceLocale = val;
}; };
asc_docs_api.prototype.LoadDocument = function() asc_docs_api.prototype.LoadDocument = function() {
{ this.CoAuthoringApi.auth(this.isViewMode);
this.WordControl.m_oDrawingDocument.m_bIsOpeningDocument = true;
this.WordControl.m_oDrawingDocument.m_bIsOpeningDocument = true;
// Меняем тип состояния (на открытие)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Open; // Меняем тип состояния (на открытие)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Open;
if (this.DocInfo.get_OfflineApp() === true)
{ if (this.DocInfo.get_OfflineApp() === true) {
this.OfflineAppDocumentStartLoad(); this.OfflineAppDocumentStartLoad();
return; return;
} }
if(documentId){ if (documentId) {
var rData = { var rData = {
"c" : 'open', "c": 'open',
"id" : documentId, "id": documentId,
"userid" : documentUserId, "userid": documentUserId,
"format" : documentFormat, "format": documentFormat,
"vkey" : documentVKey, "vkey": documentVKey,
"editorid" : c_oEditorId.Word, "editorid": c_oEditorId.Word,
"url" : documentUrl, "url": documentUrl,
"title" : documentTitle, "title": documentTitle,
"embeddedfonts" : this.isUseEmbeddedCutFonts, "embeddedfonts": this.isUseEmbeddedCutFonts,
"viewmode" : this.isViewMode "viewmode": this.isViewMode
}; };
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Open); this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Open);
sendCommand2( this, null, rData ); sendCommand2(this, null, rData);
} } else {
else // ToDo убрать зависимость от this.FontLoader.fontFilesPath
{ documentUrl = this.FontLoader.fontFilesPath + "../Word/document/";
// ToDo убрать зависимость от this.FontLoader.fontFilesPath this.DocInfo.put_OfflineApp(true);
documentUrl = this.FontLoader.fontFilesPath + "../Word/document/";
this.DocInfo.put_OfflineApp(true);
// For test create unique id // For test create unique id
documentId = "test_document_id"; documentId = "test_document_id";
this.OfflineAppDocumentStartLoad(); this.OfflineAppDocumentStartLoad();
} }
this.sync_zoomChangeCallback(this.WordControl.m_nZoomValue, 0); this.sync_zoomChangeCallback(this.WordControl.m_nZoomValue, 0);
}; };
asc_docs_api.prototype.SetFontsPath = function(path) asc_docs_api.prototype.SetFontsPath = function(path)
...@@ -1495,10 +1493,7 @@ asc_docs_api.prototype._coAuthoringInit = function() ...@@ -1495,10 +1493,7 @@ asc_docs_api.prototype._coAuthoringInit = function()
if(!(window["NATIVE_EDITOR_ENJINE"] || !documentId)){ if(!(window["NATIVE_EDITOR_ENJINE"] || !documentId)){
this.CoAuthoringApi.set_url(null); this.CoAuthoringApi.set_url(null);
} }
this.CoAuthoringApi.init(this.User, documentId, documentCallbackUrl, 'fghhfgsjdgfjs', this.CoAuthoringApi.init(this.User, documentId, documentCallbackUrl, 'fghhfgsjdgfjs', c_oEditorId.Word, documentFormatSave);
c_oEditorId.Word, documentFormatSave, this.isViewMode);
// ToDo init other callbacks
}; };
// send chart message // send chart message
...@@ -6776,57 +6771,49 @@ asc_docs_api.prototype.add_SectionBreak = function(_Type) ...@@ -6776,57 +6771,49 @@ asc_docs_api.prototype.add_SectionBreak = function(_Type)
} }
}; };
asc_docs_api.prototype.SetViewMode = function( isViewMode ) asc_docs_api.prototype.SetViewMode = function(isViewMode) {
{ if (isViewMode) {
if (isViewMode) this.asc_SpellCheckDisconnect();
{
this.asc_SpellCheckDisconnect();
this.isViewMode = true; this.isViewMode = true;
this.ShowParaMarks = false; this.ShowParaMarks = false;
CollaborativeEditing.m_bGlobalLock = true; CollaborativeEditing.m_bGlobalLock = true;
//this.isShowTableEmptyLine = false; //this.isShowTableEmptyLine = false;
//this.WordControl.m_bIsRuler = true; //this.WordControl.m_bIsRuler = true;
if (null == this.WordControl.m_oDrawingDocument.m_oDocumentRenderer) if (null == this.WordControl.m_oDrawingDocument.m_oDocumentRenderer) {
{ this.WordControl.m_oDrawingDocument.ClearCachePages();
this.WordControl.m_oDrawingDocument.ClearCachePages(); this.WordControl.HideRulers();
this.WordControl.HideRulers(); } else {
} this.WordControl.HideRulers();
else this.WordControl.OnScroll();
{ }
this.WordControl.HideRulers(); } else {
this.WordControl.OnScroll(); if (this.bInit_word_control === true && this.FontLoader.embedded_cut_manager.bIsCutFontsUse) {
} this.isLoadNoCutFonts = true;
this.FontLoader.embedded_cut_manager.bIsCutFontsUse = false;
this.FontLoader.LoadDocumentFonts(this.WordControl.m_oLogicDocument.Fonts, true);
return;
} }
else
{
if (this.bInit_word_control === true && this.FontLoader.embedded_cut_manager.bIsCutFontsUse)
{
this.isLoadNoCutFonts = true;
this.FontLoader.embedded_cut_manager.bIsCutFontsUse = false;
this.FontLoader.LoadDocumentFonts(this.WordControl.m_oLogicDocument.Fonts, true);
return;
}
// быстрого перехода больше нет // быстрого перехода больше нет
/* /*
if ( this.bInit_word_control === true ) if ( this.bInit_word_control === true )
{ {
CollaborativeEditing.Apply_Changes(); CollaborativeEditing.Apply_Changes();
CollaborativeEditing.Release_Locks(); CollaborativeEditing.Release_Locks();
} }
*/ */
this.isUseEmbeddedCutFonts = false; this.isUseEmbeddedCutFonts = false;
this.isViewMode = false; this.isViewMode = false;
//this.WordControl.m_bIsRuler = true; //this.WordControl.m_bIsRuler = true;
this.WordControl.checkNeedRules(); this.WordControl.checkNeedRules();
this.WordControl.m_oDrawingDocument.ClearCachePages(); this.WordControl.m_oDrawingDocument.ClearCachePages();
this.WordControl.OnResize(true); this.WordControl.OnResize(true);
this.sync_InitEditorStyles2(); this.sync_InitEditorStyles2();
} }
}; };
asc_docs_api.prototype.SetUseEmbeddedCutFonts = function(bUse) asc_docs_api.prototype.SetUseEmbeddedCutFonts = function(bUse)
......
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