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,48 +1090,58 @@ ...@@ -1084,48 +1090,58 @@
this._initSocksJs(); this._initSocksJs();
}; };
DocsCoApi.prototype._initSocksJs = function() { // Авторизация (ее нужно делать после выставления состояния редактора view-mode)
var t = this; DocsCoApi.prototype.auth = function(isViewer) {
var sockjs = this.sockjs = new SockJS(this.sockjs_url, null, {debug: true}); this.isAuthInit = true;
this._isViewer = isViewer;
sockjs.onopen = function() { if (this._locks) {
if (t.reconnectTimeout) { this.ownedLockBlocks = [];
clearTimeout(t.reconnectTimeout);
t.attemptCount = 0;
}
t._state = ConnectionState.WaitAuth;
if (t._locks) {
t.ownedLockBlocks = [];
//If we already have locks //If we already have locks
for (var block in t._locks) if (t._locks.hasOwnProperty(block)) { for (var block in this._locks) if (this._locks.hasOwnProperty(block)) {
var lock = t._locks[block]; var lock = this._locks[block];
if (lock["state"] === 2) { if (lock["state"] === 2) {
//Our lock. //Our lock.
t.ownedLockBlocks.push(lock["blockValue"]); this.ownedLockBlocks.push(lock["blockValue"]);
} }
} }
t._locks = {}; this._locks = {};
} }
t._send({ this._send({
'type': 'auth', 'type': 'auth',
'docid': t._docid, 'docid': this._docid,
'documentCallbackUrl': t._documentCallbackUrl, 'documentCallbackUrl': this._documentCallbackUrl,
'token': t._token, 'token': this._token,
'user': { 'user': {
'id': t._user.asc_getId(), 'id': this._user.asc_getId(),
'name': t._user.asc_getUserName(), 'name': this._user.asc_getUserName(),
'indexUser': t._indexUser 'indexUser': this._indexUser
}, },
'editorType': t.editorType, 'editorType': this.editorType,
'lastOtherSaveTime': t.lastOtherSaveTime, 'lastOtherSaveTime': this.lastOtherSaveTime,
'block': t.ownedLockBlocks, 'block': this.ownedLockBlocks,
'sessionId': t._id, 'sessionId': this._id,
'documentFormatSave': t._documentFormatSave, 'documentFormatSave': this._documentFormatSave,
'isViewer': t._isViewer, 'isViewer': this._isViewer,
'version': asc_coAuthV 'version': asc_coAuthV
}); });
};
DocsCoApi.prototype._initSocksJs = function() {
var t = this;
var sockjs = this.sockjs = new SockJS(this.sockjs_url, null, {debug: true});
sockjs.onopen = function() {
if (t.reconnectTimeout) {
clearTimeout(t.reconnectTimeout);
t.attemptCount = 0;
}
t._state = ConnectionState.WaitAuth;
if (t.isAuthInit) {
t.auth(t._isViewer);
} else {
t.onFirstConnect();
}
}; };
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,16 +795,16 @@ asc_docs_api.prototype.asc_setDocInfo = function(c_DocInfo) ...@@ -795,16 +795,16 @@ 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; this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Open;
if (this.DocInfo.get_OfflineApp() === true) if (this.DocInfo.get_OfflineApp() === true) {
{
this.OfflineAppDocumentStartLoad(); this.OfflineAppDocumentStartLoad();
return; return;
} }
...@@ -812,22 +812,20 @@ asc_docs_api.prototype.LoadDocument = function() ...@@ -812,22 +812,20 @@ asc_docs_api.prototype.LoadDocument = function()
if (documentId) { if (documentId) {
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Open); this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Open);
var rData = { var rData = {
"id" : documentId, "id": documentId,
"userid" : documentUserId, "userid": documentUserId,
"format" : documentFormat, "format": documentFormat,
"vkey" : documentVKey, "vkey": documentVKey,
"editorid" : c_oEditorId.Presentation, "editorid": c_oEditorId.Presentation,
"c" : "open", "c": "open",
"url" : documentUrl, "url": documentUrl,
"title" : documentTitle, "title": documentTitle,
"embeddedfonts" : this.isUseEmbeddedCutFonts, "embeddedfonts": this.isUseEmbeddedCutFonts,
"viewmode" : this.isViewMode "viewmode": this.isViewMode
}; };
sendCommand2(this, null, rData); sendCommand2(this, null, rData);
} } else {
else
{
// ToDo убрать зависимость от this.FontLoader.fontFilesPath // ToDo убрать зависимость от this.FontLoader.fontFilesPath
documentUrl = this.FontLoader.fontFilesPath + "../PowerPoint/document/"; documentUrl = this.FontLoader.fontFilesPath + "../PowerPoint/document/";
this.DocInfo.put_OfflineApp(true); this.DocInfo.put_OfflineApp(true);
...@@ -4594,31 +4592,26 @@ asc_docs_api.prototype.SetDeviceInputHelperId = function(idKeyboard) ...@@ -4594,31 +4592,26 @@ 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.isViewMode = true;
this.ShowParaMarks = false; this.ShowParaMarks = false;
this.WordControl.m_bIsRuler = false; this.WordControl.m_bIsRuler = false;
this.WordControl.m_oDrawingDocument.ClearCachePages(); this.WordControl.m_oDrawingDocument.ClearCachePages();
this.WordControl.HideRulers(); this.WordControl.HideRulers();
if (null != this.WordControl.m_oLogicDocument) if (null != this.WordControl.m_oLogicDocument) {
this.WordControl.m_oLogicDocument.viewMode = true; this.WordControl.m_oLogicDocument.viewMode = true;
} }
else } else {
{ if (this.bInit_word_control === true && this.FontLoader.embedded_cut_manager.bIsCutFontsUse) {
if (this.bInit_word_control === true && this.FontLoader.embedded_cut_manager.bIsCutFontsUse)
{
this.isLoadNoCutFonts = true; this.isLoadNoCutFonts = true;
this.FontLoader.embedded_cut_manager.bIsCutFontsUse = false; this.FontLoader.embedded_cut_manager.bIsCutFontsUse = false;
this.FontLoader.LoadDocumentFonts(this.WordControl.m_oLogicDocument.Fonts, true); this.FontLoader.LoadDocumentFonts(this.WordControl.m_oLogicDocument.Fonts, true);
return; 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();
} }
...@@ -4630,9 +4623,10 @@ asc_docs_api.prototype.SetViewMode = function( isViewMode ) ...@@ -4630,9 +4623,10 @@ asc_docs_api.prototype.SetViewMode = function( isViewMode )
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,37 +825,35 @@ asc_docs_api.prototype.asc_setLocale = function(val) ...@@ -825,37 +825,35 @@ 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 // ToDo убрать зависимость от this.FontLoader.fontFilesPath
documentUrl = this.FontLoader.fontFilesPath + "../Word/document/"; documentUrl = this.FontLoader.fontFilesPath + "../Word/document/";
this.DocInfo.put_OfflineApp(true); this.DocInfo.put_OfflineApp(true);
...@@ -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,10 +6771,8 @@ asc_docs_api.prototype.add_SectionBreak = function(_Type) ...@@ -6776,10 +6771,8 @@ 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;
...@@ -6788,21 +6781,15 @@ asc_docs_api.prototype.SetViewMode = function( isViewMode ) ...@@ -6788,21 +6781,15 @@ asc_docs_api.prototype.SetViewMode = function( isViewMode )
//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 {
else
{
this.WordControl.HideRulers(); this.WordControl.HideRulers();
this.WordControl.OnScroll(); this.WordControl.OnScroll();
} }
} } else {
else if (this.bInit_word_control === true && this.FontLoader.embedded_cut_manager.bIsCutFontsUse) {
{
if (this.bInit_word_control === true && this.FontLoader.embedded_cut_manager.bIsCutFontsUse)
{
this.isLoadNoCutFonts = true; this.isLoadNoCutFonts = true;
this.FontLoader.embedded_cut_manager.bIsCutFontsUse = false; this.FontLoader.embedded_cut_manager.bIsCutFontsUse = false;
this.FontLoader.LoadDocumentFonts(this.WordControl.m_oLogicDocument.Fonts, true); this.FontLoader.LoadDocumentFonts(this.WordControl.m_oLogicDocument.Fonts, true);
......
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