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 @@
"../Common/docscoapicommon.js",
"../Common/docscoapi.js",
"../Common/downloaderfiles.js",
"../Common/apiCommon.js",
"../Common/commonDefines.js",
"../Common/editorscommon.js",
"../Common/NumFormat.js",
......
function CAscEditorPermissions()
{
( /**
* @param {Window} window
* @param {undefined} undefined
*/
function (window, undefined) {
/*
* Import
* -----------------------------------------------------------------------------
*/
var asc = window["Asc"] ? window["Asc"] : (window["Asc"] = {});
var prot;
/**
* asc_CAscEditorPermissions
* -----------------------------------------------------------------------------
*
* @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;
......@@ -7,19 +38,43 @@ function CAscEditorPermissions()
this.canBranding = true;
this.isAutosaveEnable = true;
this.AutosaveMinInterval = 300;
}
CAscEditorPermissions.prototype.asc_getCanEdit = function(){ return this.canEdit; }
CAscEditorPermissions.prototype.asc_getCanDownload = function(){ return this.canDownload; }
CAscEditorPermissions.prototype.asc_getCanCoAuthoring = function(){ return this.canCoAuthoring; }
CAscEditorPermissions.prototype.asc_getCanReaderMode = function(){ return this.canReaderMode; }
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; }
}
return this;
}
asc_CAscEditorPermissions.prototype = {
constructor: asc_CAscEditorPermissions,
asc_getCanEdit: function(){ return this.canEdit; },
asc_getCanDownload: function(){ return this.canDownload; },
asc_getCanCoAuthoring: function(){ return this.canCoAuthoring; },
asc_getCanReaderMode: function(){ return this.canReaderMode; },
asc_getCanBranding: function(v){ return this.canBranding; },
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;
CAscEditorPermissions.prototype.asc_setCanEdit = function(v){ this.canEdit = v; }
CAscEditorPermissions.prototype.asc_setCanDownload = function(v){ this.canDownload = v; }
CAscEditorPermissions.prototype.asc_setCanCoAuthoring = function(v){ this.canCoAuthoring = v; }
CAscEditorPermissions.prototype.asc_setCanReaderMode = function(v){ this.canReaderMode = v; }
CAscEditorPermissions.prototype.asc_setCanBranding = function(v){ this.canBranding = v; }
CAscEditorPermissions.prototype.asc_setIsAutosaveEnable = function(v){ this.isAutosaveEnable = v; }
CAscEditorPermissions.prototype.asc_setAutosaveMinInterval = function(v){ this.AutosaveMinInterval = v; }
\ No newline at end of file
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";
var asc_CCollaborativeEditing = asc.CCollaborativeEditing;
var asc_CAdjustPrint = asc.asc_CAdjustPrint;
var asc_user = asc.asc_CUser;
var asc_CAscEditorPermissions = asc.asc_CAscEditorPermissions;
var prot;
......@@ -71,6 +72,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.cCharDelimiter = String.fromCharCode(5);
this.chartEditor = undefined;
this.documentOpenOptions = undefined; // Опции при открытии (пока только опции для CSV)
this.DocInfo = null;
// объекты, нужные для отправки в тулбар (шрифты, стили)
this.guiFonts = null; // Переменная для сохранения фонтов для облегченной версии (переход в edit mod)
......@@ -353,18 +355,24 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
t.FontLoader.fontFilesPath = fontsPath;
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) {
var t = this;
if(c_DocInfo){
this.documentId = c_DocInfo["Id"];
this.documentUrl = c_DocInfo["Url"];
this.documentTitle = c_DocInfo["Title"];
this.documentFormat = c_DocInfo["Format"];
this.documentVKey = c_DocInfo["VKey"];
this.documentOrigin = c_DocInfo["Origin"];
this.chartEditor = c_DocInfo["ChartEditor"];
this.documentOpenOptions = c_DocInfo["Options"];
this.asc_setDocInfo(c_DocInfo);
if(this.DocInfo){
this.documentId = this.DocInfo["Id"];
this.documentUrl = this.DocInfo["Url"];
this.documentTitle = this.DocInfo["Title"];
this.documentFormat = this.DocInfo["Format"];
this.documentVKey = this.DocInfo["VKey"];
this.documentOrigin = this.DocInfo["Origin"];
this.chartEditor = this.DocInfo["ChartEditor"];
this.documentOpenOptions = this.DocInfo["Options"];
var nIndex = -1;
if(this.documentTitle)
......@@ -376,8 +384,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
// Выставляем пользователя
this.User = new asc_user();
this.User.asc_setId(c_DocInfo["UserId"]);
this.User.asc_setUserName(c_DocInfo["UserName"]);
this.User.asc_setId(this.DocInfo["UserId"]);
this.User.asc_setUserName(this.DocInfo["UserName"]);
//Взято из редактора документов
var sProtocol = window.location.protocol;
......@@ -389,7 +397,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.documentOrigin = sHost;
}
if (c_DocInfo["OfflineApp"] && (true == c_DocInfo["OfflineApp"])) {
if (this.DocInfo["OfflineApp"] && (true == this.DocInfo["OfflineApp"])) {
this.isCoAuthoringEnable = false;
window['scriptBridge'] = {};
......@@ -418,6 +426,25 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
}
},
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
if (undefined != window['appBridge']) {
window['appBridge']['dummyCommandDownloadAs'] (); // TEST
......@@ -767,6 +794,10 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
var outputData = JSON.parse(incomeObject.data);
oThis._asc_downloadAs(outputData.format, callback, false, null, outputData.savekey);
break;
case "getsettings":
if(callback)
callback(incomeObject);
break;
case "err":
result = {returnCode: c_oAscError.Level.Critical, val:parseInt(incomeObject.data)};
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";
* asc_onRenameCellTextEnd (countCellsFind, countCellsReplace) - эвент об окончании замены текста в ячейках (мы не можем сразу прислать ответ)
* asc_onWorkbookLocked (result) - эвент залочена ли работа с листами или нет
* asc_onWorksheetLocked (index, result) - эвент залочен ли лист или нет
* asc_onGetEditorPermissions (permission) - эвент о правах редактора.
*/
asc_StartAction: function (type, id) {
......@@ -1082,6 +1114,20 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
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() {
//Загружаем скрипт с настройками, по окончанию инициализируем контрол для совместного редактирования
......@@ -2976,6 +3022,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
prot = spreadsheet_api.prototype;
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_LoadEmptyDocument"] = prot.asc_LoadEmptyDocument;
prot["asc_DownloadAs"] = prot.asc_DownloadAs;
......
......@@ -737,7 +737,8 @@ asc_docs_api.prototype.asc_getEditorPermissions = function()
}
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)
window.g_cAscCoAuthoringUrl = oSettings['g_cAscCoAuthoringUrl'];
window.g_cAscSpellCheckUrl = oSettings['g_cAscSpellCheckUrl'];
var oEditorPermissions = new CAscEditorPermissions();
oEditorPermissions.asc_setCanEdit(oSettings["canEdit"]);
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"]);
var asc_CAscEditorPermissions = window["Asc"].asc_CAscEditorPermissions;
var oEditorPermissions = new asc_CAscEditorPermissions(oSettings);
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