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 @@
}
}
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()) {
var t = this;
this._CoAuthoringApi.onAuthParticipantsChanged = function(e, count) {
......@@ -88,14 +88,21 @@
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;
} else {
// Фиктивные вызовы
this.onFirstConnect();
}
};
CDocsCoApi.prototype.auth = function(isViewer) {
// Фиктивные вызовы
if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.auth(isViewer);
} else {
this.callback_OnSetIndexUser("123");
this.onFirstLoadChangesEnd();
callback();
}
};
......@@ -375,6 +382,7 @@
this._countEditUsers = 0;
this._countUsers = 0;
this.isAuthInit = false;
this._locks = {};
this._msgBuffer = [];
this._lockCallbacks = {};
......@@ -1059,10 +1067,9 @@
this._sendPrebuffered();
}
//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._docid = docid;
this._documentCallbackUrl = documentCallbackUrl;
......@@ -1074,7 +1081,6 @@
this._isPresentation = c_oEditorId.Presentation === editorType;
this._isAuth = false;
this._documentFormatSave = documentFormatSave;
this._isViewer = isViewer;
this.bUserAlive = false; // Активность пользователя
this.bSendUserAlive = false; // Отправлять ли активность пользователя
......@@ -1084,6 +1090,42 @@
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() {
var t = this;
var sockjs = this.sockjs = new SockJS(this.sockjs_url, null, {debug: true});
......@@ -1095,37 +1137,11 @@
}
t._state = ConnectionState.WaitAuth;
if (t._locks) {
t.ownedLockBlocks = [];
//If we already have locks
for (var block in t._locks) if (t._locks.hasOwnProperty(block)) {
var lock = t._locks[block];
if (lock["state"] === 2) {
//Our lock.
t.ownedLockBlocks.push(lock["blockValue"]);
}
}
t._locks = {};
if (t.isAuthInit) {
t.auth(t._isViewer);
} else {
t.onFirstConnect();
}
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) {
//TODO: add checks and error handling
......
......@@ -501,12 +501,12 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
}
};
spreadsheet_api.prototype.asc_LoadDocument = function() {
var t = this;
this.CoAuthoringApi.auth(this.asc_getViewerMode());
this.asc_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Open);
if (!this.chartEditor) {
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";
if (!(window["NATIVE_EDITOR_ENJINE"] || !this.documentId || !this.documentUrl)) {
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) {
......
......@@ -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.LoadDocument = function()
{
this.WordControl.m_oDrawingDocument.m_bIsOpeningDocument = true;
asc_docs_api.prototype.LoadDocument = function() {
this.CoAuthoringApi.auth(this.isViewMode);
this.WordControl.m_oDrawingDocument.m_bIsOpeningDocument = true;
// Меняем тип состояния (на открытие)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Open;
if (this.DocInfo.get_OfflineApp() === true)
{
this.OfflineAppDocumentStartLoad();
return;
}
// Меняем тип состояния (на открытие)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Open;
if (documentId) {
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Open);
var rData = {
"id" : documentId,
"userid" : documentUserId,
"format" : documentFormat,
"vkey" : documentVKey,
"editorid" : c_oEditorId.Presentation,
"c" : "open",
"url" : documentUrl,
"title" : documentTitle,
"embeddedfonts" : this.isUseEmbeddedCutFonts,
"viewmode" : this.isViewMode
};
sendCommand2(this, null, rData);
}
else
{
// ToDo убрать зависимость от this.FontLoader.fontFilesPath
documentUrl = this.FontLoader.fontFilesPath + "../PowerPoint/document/";
this.DocInfo.put_OfflineApp(true);
if (this.DocInfo.get_OfflineApp() === true) {
this.OfflineAppDocumentStartLoad();
return;
}
if (documentId) {
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Open);
var rData = {
"id": documentId,
"userid": documentUserId,
"format": documentFormat,
"vkey": documentVKey,
"editorid": c_oEditorId.Presentation,
"c": "open",
"url": documentUrl,
"title": documentTitle,
"embeddedfonts": this.isUseEmbeddedCutFonts,
"viewmode": this.isViewMode
};
// For test create unique id
documentId = "test_presentation_id";
this.OfflineAppDocumentStartLoad();
}
this.sync_zoomChangeCallback(this.WordControl.m_nZoomValue, this.WordControl.m_nZoomType);
sendCommand2(this, null, rData);
} else {
// ToDo убрать зависимость от this.FontLoader.fontFilesPath
documentUrl = this.FontLoader.fontFilesPath + "../PowerPoint/document/";
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)
......@@ -4594,45 +4592,41 @@ asc_docs_api.prototype.SetDeviceInputHelperId = function(idKeyboard)
}
window.ID_KEYBOARD_AREA.focus();
};
asc_docs_api.prototype.SetViewMode = function( isViewMode )
{
if (isViewMode)
{
this.isViewMode = true;
this.ShowParaMarks = false;
this.WordControl.m_bIsRuler = false;
this.WordControl.m_oDrawingDocument.ClearCachePages();
this.WordControl.HideRulers();
if (null != this.WordControl.m_oLogicDocument)
this.WordControl.m_oLogicDocument.viewMode = true;
asc_docs_api.prototype.SetViewMode = function(isViewMode) {
if (isViewMode) {
this.isViewMode = true;
this.ShowParaMarks = false;
this.WordControl.m_bIsRuler = false;
this.WordControl.m_oDrawingDocument.ClearCachePages();
this.WordControl.HideRulers();
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 )
{
CollaborativeEditing.Apply_Changes();
CollaborativeEditing.Release_Locks();
}
if (this.bInit_word_control === true) {
CollaborativeEditing.Apply_Changes();
CollaborativeEditing.Release_Locks();
}
this.isUseEmbeddedCutFonts = false;
this.isUseEmbeddedCutFonts = false;
this.isViewMode = false;
this.WordControl.checkNeedRules();
this.WordControl.m_oDrawingDocument.ClearCachePages();
this.WordControl.OnResize(true);
this.isViewMode = false;
this.WordControl.checkNeedRules();
this.WordControl.m_oDrawingDocument.ClearCachePages();
this.WordControl.OnResize(true);
if (null != this.WordControl.m_oLogicDocument)
this.WordControl.m_oLogicDocument.viewMode = false;
if (null != this.WordControl.m_oLogicDocument) {
this.WordControl.m_oLogicDocument.viewMode = false;
}
}
};
asc_docs_api.prototype.SetUseEmbeddedCutFonts = function(bUse)
......
......@@ -825,47 +825,45 @@ asc_docs_api.prototype.asc_setLocale = function(val)
{
this.InterfaceLocale = val;
};
asc_docs_api.prototype.LoadDocument = function()
{
this.WordControl.m_oDrawingDocument.m_bIsOpeningDocument = true;
// Меняем тип состояния (на открытие)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Open;
if (this.DocInfo.get_OfflineApp() === true)
{
this.OfflineAppDocumentStartLoad();
return;
}
if(documentId){
var rData = {
"c" : 'open',
"id" : documentId,
"userid" : documentUserId,
"format" : documentFormat,
"vkey" : documentVKey,
"editorid" : c_oEditorId.Word,
"url" : documentUrl,
"title" : documentTitle,
"embeddedfonts" : this.isUseEmbeddedCutFonts,
"viewmode" : this.isViewMode
};
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Open);
sendCommand2( this, null, rData );
}
else
{
// ToDo убрать зависимость от this.FontLoader.fontFilesPath
documentUrl = this.FontLoader.fontFilesPath + "../Word/document/";
this.DocInfo.put_OfflineApp(true);
asc_docs_api.prototype.LoadDocument = function() {
this.CoAuthoringApi.auth(this.isViewMode);
this.WordControl.m_oDrawingDocument.m_bIsOpeningDocument = true;
// Меняем тип состояния (на открытие)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Open;
if (this.DocInfo.get_OfflineApp() === true) {
this.OfflineAppDocumentStartLoad();
return;
}
if (documentId) {
var rData = {
"c": 'open',
"id": documentId,
"userid": documentUserId,
"format": documentFormat,
"vkey": documentVKey,
"editorid": c_oEditorId.Word,
"url": documentUrl,
"title": documentTitle,
"embeddedfonts": this.isUseEmbeddedCutFonts,
"viewmode": this.isViewMode
};
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Open);
sendCommand2(this, null, rData);
} else {
// ToDo убрать зависимость от this.FontLoader.fontFilesPath
documentUrl = this.FontLoader.fontFilesPath + "../Word/document/";
this.DocInfo.put_OfflineApp(true);
// For test create unique id
documentId = "test_document_id";
this.OfflineAppDocumentStartLoad();
}
// For test create unique id
documentId = "test_document_id";
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)
......@@ -1495,10 +1493,7 @@ asc_docs_api.prototype._coAuthoringInit = function()
if(!(window["NATIVE_EDITOR_ENJINE"] || !documentId)){
this.CoAuthoringApi.set_url(null);
}
this.CoAuthoringApi.init(this.User, documentId, documentCallbackUrl, 'fghhfgsjdgfjs',
c_oEditorId.Word, documentFormatSave, this.isViewMode);
// ToDo init other callbacks
this.CoAuthoringApi.init(this.User, documentId, documentCallbackUrl, 'fghhfgsjdgfjs', c_oEditorId.Word, documentFormatSave);
};
// send chart message
......@@ -6776,57 +6771,49 @@ asc_docs_api.prototype.add_SectionBreak = function(_Type)
}
};
asc_docs_api.prototype.SetViewMode = function( isViewMode )
{
if (isViewMode)
{
this.asc_SpellCheckDisconnect();
asc_docs_api.prototype.SetViewMode = function(isViewMode) {
if (isViewMode) {
this.asc_SpellCheckDisconnect();
this.isViewMode = true;
this.ShowParaMarks = false;
CollaborativeEditing.m_bGlobalLock = true;
//this.isShowTableEmptyLine = false;
//this.WordControl.m_bIsRuler = true;
this.isViewMode = true;
this.ShowParaMarks = false;
CollaborativeEditing.m_bGlobalLock = true;
//this.isShowTableEmptyLine = false;
//this.WordControl.m_bIsRuler = true;
if (null == this.WordControl.m_oDrawingDocument.m_oDocumentRenderer)
{
this.WordControl.m_oDrawingDocument.ClearCachePages();
this.WordControl.HideRulers();
}
else
{
this.WordControl.HideRulers();
this.WordControl.OnScroll();
}
if (null == this.WordControl.m_oDrawingDocument.m_oDocumentRenderer) {
this.WordControl.m_oDrawingDocument.ClearCachePages();
this.WordControl.HideRulers();
} else {
this.WordControl.HideRulers();
this.WordControl.OnScroll();
}
} 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 )
{
CollaborativeEditing.Apply_Changes();
CollaborativeEditing.Release_Locks();
}
*/
// быстрого перехода больше нет
/*
if ( this.bInit_word_control === true )
{
CollaborativeEditing.Apply_Changes();
CollaborativeEditing.Release_Locks();
}
*/
this.isUseEmbeddedCutFonts = false;
this.isUseEmbeddedCutFonts = false;
this.isViewMode = false;
//this.WordControl.m_bIsRuler = true;
this.WordControl.checkNeedRules();
this.WordControl.m_oDrawingDocument.ClearCachePages();
this.WordControl.OnResize(true);
this.sync_InitEditorStyles2();
}
this.isViewMode = false;
//this.WordControl.m_bIsRuler = true;
this.WordControl.checkNeedRules();
this.WordControl.m_oDrawingDocument.ClearCachePages();
this.WordControl.OnResize(true);
this.sync_InitEditorStyles2();
}
};
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