Commit 3c5e7064 authored by Alexey.Golubev's avatar Alexey.Golubev Committed by Alexander.Trofimov

Получение настроек с сервера для редактора таблиц. Для редактора документов...

Получение настроек с сервера для редактора таблиц. Для редактора документов сделан рефакторинг, в связи с изменениями вв классе для передачи параметров.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@48773 954022d7-b5bf-4e40-9824-e11837661b57
parent 48655a28
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
"../Common/docscoapicommon.js", "../Common/docscoapicommon.js",
"../Common/docscoapi.js", "../Common/docscoapi.js",
"../Common/downloaderfiles.js", "../Common/downloaderfiles.js",
"../Common/apiCommon.js",
"../Common/commonDefines.js", "../Common/commonDefines.js",
"../Common/editorscommon.js", "../Common/editorscommon.js",
"../Common/NumFormat.js", "../Common/NumFormat.js",
......
function CAscEditorPermissions() ( /**
{ * @param {Window} window
this.canEdit = true; * @param {undefined} undefined
this.canDownload = true; */
this.canCoAuthoring = true; function (window, undefined) {
this.canReaderMode = true; /*
this.canBranding = true; * Import
this.isAutosaveEnable = true; * -----------------------------------------------------------------------------
this.AutosaveMinInterval = 300; */
} var asc = window["Asc"] ? window["Asc"] : (window["Asc"] = {});
CAscEditorPermissions.prototype.asc_getCanEdit = function(){ return this.canEdit; } var prot;
CAscEditorPermissions.prototype.asc_getCanDownload = function(){ return this.canDownload; }
CAscEditorPermissions.prototype.asc_getCanCoAuthoring = function(){ return this.canCoAuthoring; } /**
CAscEditorPermissions.prototype.asc_getCanReaderMode = function(){ return this.canReaderMode; } * asc_CAscEditorPermissions
CAscEditorPermissions.prototype.asc_getCanBranding = function(v){ return this.canBranding; } * -----------------------------------------------------------------------------
CAscEditorPermissions.prototype.asc_getIsAutosaveEnable = function(){ return this.isAutosaveEnable; } *
CAscEditorPermissions.prototype.asc_getAutosaveMinInterval = function(){ return this.AutosaveMinInterval; } * @constructor
* @memberOf Asc
*/
function asc_CAscEditorPermissions (settings) {
if ( !(this instanceof asc_CAscEditorPermissions) ) {
return new asc_CAscEditorPermissions();
}
if(settings) {
this.canEdit = settings["canEdit"];
this.canDownload = settings["canDownload"];
this.canCoAuthoring = settings["canCoAuthoring"];
this.canReaderMode = settings["canReaderMode"];
this.canBranding = settings["canBranding"];
this.isAutosaveEnable = settings["isAutosaveEnable"];
this.AutosaveMinInterval = settings["AutosaveMinInterval"];
}
else {
this.canEdit = true;
this.canDownload = true;
this.canCoAuthoring = true;
this.canReaderMode = true;
this.canBranding = true;
this.isAutosaveEnable = true;
this.AutosaveMinInterval = 300;
}
return this;
}
CAscEditorPermissions.prototype.asc_setCanEdit = function(v){ this.canEdit = v; } asc_CAscEditorPermissions.prototype = {
CAscEditorPermissions.prototype.asc_setCanDownload = function(v){ this.canDownload = v; } constructor: asc_CAscEditorPermissions,
CAscEditorPermissions.prototype.asc_setCanCoAuthoring = function(v){ this.canCoAuthoring = v; } asc_getCanEdit: function(){ return this.canEdit; },
CAscEditorPermissions.prototype.asc_setCanReaderMode = function(v){ this.canReaderMode = v; } asc_getCanDownload: function(){ return this.canDownload; },
CAscEditorPermissions.prototype.asc_setCanBranding = function(v){ this.canBranding = v; } asc_getCanCoAuthoring: function(){ return this.canCoAuthoring; },
CAscEditorPermissions.prototype.asc_setIsAutosaveEnable = function(v){ this.isAutosaveEnable = v; } asc_getCanReaderMode: function(){ return this.canReaderMode; },
CAscEditorPermissions.prototype.asc_setAutosaveMinInterval = function(v){ this.AutosaveMinInterval = v; } asc_getCanBranding: function(v){ return this.canBranding; },
\ No newline at end of file asc_getIsAutosaveEnable: function(){ return this.isAutosaveEnable; },
asc_getAutosaveMinInterval: function(){ return this.AutosaveMinInterval; },
asc_setCanEdit: function(v){ this.canEdit = v; },
asc_setCanDownload: function(v){ this.canDownload = v; },
asc_setCanCoAuthoring: function(v){ this.canCoAuthoring = v; },
asc_setCanReaderMode: function(v){ this.canReaderMode = v; },
asc_setCanBranding: function(v){ this.canBranding = v; },
asc_setIsAutosaveEnable: function(v){ this.isAutosaveEnable = v; },
asc_setAutosaveMinInterval: function(v){ this.AutosaveMinInterval = v; }
};
/*
* Export
* -----------------------------------------------------------------------------
*/
window["Asc"]["asc_CAscEditorPermissions"] =
window["Asc"].asc_CAscEditorPermissions = asc_CAscEditorPermissions;
prot = asc_CAscEditorPermissions.prototype;
prot["asc_getCanEdit"] = prot.asc_getCanEdit;
prot["asc_getCanDownload"] = prot.asc_getCanDownload;
prot["asc_getCanCoAuthoring"] = prot.asc_getCanCoAuthoring;
prot["asc_getCanReaderMode"] = prot.asc_getCanReaderMode;
prot["asc_getCanBranding"] = prot.asc_getCanBranding;
prot["asc_getIsAutosaveEnable"] = prot.asc_getIsAutosaveEnable;
prot["asc_getAutosaveMinInterval"] = prot.asc_getAutosaveMinInterval;
}
)(window);
\ No newline at end of file
...@@ -18,6 +18,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -18,6 +18,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
var asc_CCollaborativeEditing = asc.CCollaborativeEditing; var asc_CCollaborativeEditing = asc.CCollaborativeEditing;
var asc_CAdjustPrint = asc.asc_CAdjustPrint; var asc_CAdjustPrint = asc.asc_CAdjustPrint;
var asc_user = asc.asc_CUser; var asc_user = asc.asc_CUser;
var asc_CAscEditorPermissions = asc.asc_CAscEditorPermissions;
var prot; var prot;
...@@ -71,6 +72,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -71,6 +72,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.cCharDelimiter = String.fromCharCode(5); this.cCharDelimiter = String.fromCharCode(5);
this.chartEditor = undefined; this.chartEditor = undefined;
this.documentOpenOptions = undefined; // Опции при открытии (пока только опции для CSV) this.documentOpenOptions = undefined; // Опции при открытии (пока только опции для CSV)
this.DocInfo = null;
// объекты, нужные для отправки в тулбар (шрифты, стили) // объекты, нужные для отправки в тулбар (шрифты, стили)
this.guiFonts = null; // Переменная для сохранения фонтов для облегченной версии (переход в edit mod) this.guiFonts = null; // Переменная для сохранения фонтов для облегченной версии (переход в edit mod)
...@@ -353,18 +355,24 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -353,18 +355,24 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
t.FontLoader.fontFilesPath = fontsPath; t.FontLoader.fontFilesPath = fontsPath;
t.asc_registerCallback("loadFonts", function (fonts, callback){t._loadFonts(fonts, callback);}); t.asc_registerCallback("loadFonts", function (fonts, callback){t._loadFonts(fonts, callback);});
}, },
asc_setDocInfo: function (c_DocInfo) {
if(c_DocInfo)
this.DocInfo = c_DocInfo;
},
asc_LoadDocument: function (c_DocInfo) { asc_LoadDocument: function (c_DocInfo) {
var t = this; var t = this;
if(c_DocInfo){
this.documentId = c_DocInfo["Id"]; this.asc_setDocInfo(c_DocInfo);
this.documentUrl = c_DocInfo["Url"];
this.documentTitle = c_DocInfo["Title"]; if(this.DocInfo){
this.documentFormat = c_DocInfo["Format"]; this.documentId = this.DocInfo["Id"];
this.documentVKey = c_DocInfo["VKey"]; this.documentUrl = this.DocInfo["Url"];
this.documentOrigin = c_DocInfo["Origin"]; this.documentTitle = this.DocInfo["Title"];
this.chartEditor = c_DocInfo["ChartEditor"]; this.documentFormat = this.DocInfo["Format"];
this.documentOpenOptions = c_DocInfo["Options"]; this.documentVKey = this.DocInfo["VKey"];
this.documentOrigin = this.DocInfo["Origin"];
this.chartEditor = this.DocInfo["ChartEditor"];
this.documentOpenOptions = this.DocInfo["Options"];
var nIndex = -1; var nIndex = -1;
if(this.documentTitle) if(this.documentTitle)
...@@ -376,8 +384,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -376,8 +384,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
// Выставляем пользователя // Выставляем пользователя
this.User = new asc_user(); this.User = new asc_user();
this.User.asc_setId(c_DocInfo["UserId"]); this.User.asc_setId(this.DocInfo["UserId"]);
this.User.asc_setUserName(c_DocInfo["UserName"]); this.User.asc_setUserName(this.DocInfo["UserName"]);
//Взято из редактора документов //Взято из редактора документов
var sProtocol = window.location.protocol; var sProtocol = window.location.protocol;
...@@ -389,7 +397,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -389,7 +397,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.documentOrigin = sHost; this.documentOrigin = sHost;
} }
if (c_DocInfo["OfflineApp"] && (true == c_DocInfo["OfflineApp"])) { if (this.DocInfo["OfflineApp"] && (true == this.DocInfo["OfflineApp"])) {
this.isCoAuthoringEnable = false; this.isCoAuthoringEnable = false;
window['scriptBridge'] = {}; window['scriptBridge'] = {};
...@@ -417,7 +425,26 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -417,7 +425,26 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this._startOpenDocument({returnCode: 0, val:wb}); this._startOpenDocument({returnCode: 0, val:wb});
} }
}, },
asc_getEditorPermissions : function(){
if (this.DocInfo &&
this.DocInfo["Id"] &&
this.DocInfo["Url"])
{
var t = this;
var v = {};
v["c"] = "getsettings";
v["format"] = this.DocInfo["Format"];
v["vkey"] = this.DocInfo["VKey"];
v["editorid"] = c_oEditorId.Excel;
this._asc_sendCommand(function (response) {t._onGetEditorPermissions(response);}, JSON.stringify(v));
}
else
{
this.handlers.trigger("asc_onGetEditorPermissions", new asc_CAscEditorPermissions());
}
},
asc_DownloadAs : function(typeFile){//передаем число соответствующее своему формату. например c_oAscFileType.XLSX asc_DownloadAs : function(typeFile){//передаем число соответствующее своему формату. например c_oAscFileType.XLSX
if (undefined != window['appBridge']) { if (undefined != window['appBridge']) {
window['appBridge']['dummyCommandDownloadAs'] (); // TEST window['appBridge']['dummyCommandDownloadAs'] (); // TEST
...@@ -767,6 +794,10 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -767,6 +794,10 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
var outputData = JSON.parse(incomeObject.data); var outputData = JSON.parse(incomeObject.data);
oThis._asc_downloadAs(outputData.format, callback, false, null, outputData.savekey); oThis._asc_downloadAs(outputData.format, callback, false, null, outputData.savekey);
break; break;
case "getsettings":
if(callback)
callback(incomeObject);
break;
case "err": case "err":
result = {returnCode: c_oAscError.Level.Critical, val:parseInt(incomeObject.data)}; result = {returnCode: c_oAscError.Level.Critical, val:parseInt(incomeObject.data)};
oThis.handlers.trigger("asc_onError", _mapAscServerErrorToAscError(parseInt(incomeObject.data)), c_oAscError.Level.Critical); oThis.handlers.trigger("asc_onError", _mapAscServerErrorToAscError(parseInt(incomeObject.data)), c_oAscError.Level.Critical);
...@@ -932,6 +963,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -932,6 +963,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
* asc_onRenameCellTextEnd (countCellsFind, countCellsReplace) - эвент об окончании замены текста в ячейках (мы не можем сразу прислать ответ) * asc_onRenameCellTextEnd (countCellsFind, countCellsReplace) - эвент об окончании замены текста в ячейках (мы не можем сразу прислать ответ)
* asc_onWorkbookLocked (result) - эвент залочена ли работа с листами или нет * asc_onWorkbookLocked (result) - эвент залочена ли работа с листами или нет
* asc_onWorksheetLocked (index, result) - эвент залочен ли лист или нет * asc_onWorksheetLocked (index, result) - эвент залочен ли лист или нет
* asc_onGetEditorPermissions (permission) - эвент о правах редактора.
*/ */
asc_StartAction: function (type, id) { asc_StartAction: function (type, id) {
...@@ -1081,6 +1113,20 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -1081,6 +1113,20 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
if (window.USER_AGENT_SAFARI_MACOS) if (window.USER_AGENT_SAFARI_MACOS)
setInterval(SafariIntervalFocus, 10); setInterval(SafariIntervalFocus, 10);
}, },
_onGetEditorPermissions: function(response) {
if(null != response && "getsettings" == response.type){
var oSettings = JSON.parse(response.data);
//Set up coauthoring and spellcheker service
//window.g_cAscCoAuthoringUrl = oSettings['g_cAscCoAuthoringUrl'];
//window.g_cAscSpellCheckUrl = oSettings['g_cAscSpellCheckUrl'];
var oEditorPermissions = new asc_CAscEditorPermissions(oSettings);
this.handlers.trigger("asc_onGetEditorPermissions", oEditorPermissions);
}
},
// Стартуем соединение с сервером для совместного редактирования // Стартуем соединение с сервером для совместного редактирования
asyncServerIdStartLoaded: function() { asyncServerIdStartLoaded: function() {
...@@ -2976,6 +3022,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -2976,6 +3022,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
prot = spreadsheet_api.prototype; prot = spreadsheet_api.prototype;
prot["asc_Init"] = prot.asc_Init; prot["asc_Init"] = prot.asc_Init;
prot["asc_setDocInfo"] = prot.asc_setDocInfo;
prot["asc_getEditorPermissions"] = prot.asc_getEditorPermissions;
prot["asc_LoadDocument"] = prot.asc_LoadDocument; prot["asc_LoadDocument"] = prot.asc_LoadDocument;
prot["asc_LoadEmptyDocument"] = prot.asc_LoadEmptyDocument; prot["asc_LoadEmptyDocument"] = prot.asc_LoadEmptyDocument;
prot["asc_DownloadAs"] = prot.asc_DownloadAs; prot["asc_DownloadAs"] = prot.asc_DownloadAs;
......
...@@ -737,7 +737,8 @@ asc_docs_api.prototype.asc_getEditorPermissions = function() ...@@ -737,7 +737,8 @@ asc_docs_api.prototype.asc_getEditorPermissions = function()
} }
else else
{ {
editor.asc_fireCallback("asc_onGetEditorPermissions", new CAscEditorPermissions()); var asc_CAscEditorPermissions = window["Asc"].asc_CAscEditorPermissions;
editor.asc_fireCallback("asc_onGetEditorPermissions", new asc_CAscEditorPermissions());
} }
} }
...@@ -750,15 +751,8 @@ asc_docs_api.prototype.asc_getEditorPermissionsCallback = function(incomeObject) ...@@ -750,15 +751,8 @@ asc_docs_api.prototype.asc_getEditorPermissionsCallback = function(incomeObject)
window.g_cAscCoAuthoringUrl = oSettings['g_cAscCoAuthoringUrl']; window.g_cAscCoAuthoringUrl = oSettings['g_cAscCoAuthoringUrl'];
window.g_cAscSpellCheckUrl = oSettings['g_cAscSpellCheckUrl']; window.g_cAscSpellCheckUrl = oSettings['g_cAscSpellCheckUrl'];
var oEditorPermissions = new CAscEditorPermissions(); var asc_CAscEditorPermissions = window["Asc"].asc_CAscEditorPermissions;
oEditorPermissions.asc_setCanEdit(oSettings["canEdit"]); var oEditorPermissions = new asc_CAscEditorPermissions(oSettings);
oEditorPermissions.asc_setCanDownload(oSettings["canDownload"]);
oEditorPermissions.asc_setCanCoAuthoring(oSettings["canCoAuthoring"]);
oEditorPermissions.asc_setCanReaderMode(oSettings["canReaderMode"]);
oEditorPermissions.asc_setCanBranding(oSettings["canBranding"]);
oEditorPermissions.asc_setIsAutosaveEnable(oSettings["isAutosaveEnable"]);
oEditorPermissions.asc_setAutosaveMinInterval(oSettings["AutosaveMinInterval"]);
editor.asc_fireCallback("asc_onGetEditorPermissions", oEditorPermissions); editor.asc_fireCallback("asc_onGetEditorPermissions", oEditorPermissions);
} }
} }
......
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