From c9d810dc037c35bc9c66060f166a7515a5a047f2 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 22 May 2020 15:04:55 +0300 Subject: [PATCH] [DE mobile][DE embedded] Add parameters to api customization: macros, plugins --- apps/documenteditor/embed/js/ApplicationController.js | 11 +++++++++++ apps/documenteditor/mobile/app/controller/Main.js | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/apps/documenteditor/embed/js/ApplicationController.js b/apps/documenteditor/embed/js/ApplicationController.js index dffc44187..0e7c5c288 100644 --- a/apps/documenteditor/embed/js/ApplicationController.js +++ b/apps/documenteditor/embed/js/ApplicationController.js @@ -100,6 +100,11 @@ DE.ApplicationController = new(function(){ docInfo.put_Token(docConfig.token); docInfo.put_Permissions(_permissions); + var enable = !config.customization || (config.customization.macros!==false); + docInfo.asc_putIsEnabledMacroses(!!enable); + enable = !config.customization || (config.customization.plugins!==false); + docInfo.asc_putIsEnabledPlugins(!!enable); + var type = /^(?:(pdf|djvu|xps))$/.exec(docConfig.fileType); if (type && typeof type[1] === 'string') { permissions.edit = permissions.review = false; @@ -107,6 +112,7 @@ DE.ApplicationController = new(function(){ if (api) { api.asc_registerCallback('asc_onGetEditorPermissions', onEditorPermissions); + api.asc_registerCallback('asc_onRunAutostartMacroses', onRunAutostartMacroses); api.asc_setDocInfo(docInfo); api.asc_getEditorPermissions(config.licenseUrl, config.customerId); api.asc_enableKeyEvents(true); @@ -481,6 +487,11 @@ DE.ApplicationController = new(function(){ if (api) api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.DOCX, true)); } + function onRunAutostartMacroses() { + if (!config.customization || (config.customization.macros!==false)) + if (api) api.asc_runAutostartMacroses(); + } + // Helpers // ------------------------- diff --git a/apps/documenteditor/mobile/app/controller/Main.js b/apps/documenteditor/mobile/app/controller/Main.js index 7de2d59fe..87e527121 100644 --- a/apps/documenteditor/mobile/app/controller/Main.js +++ b/apps/documenteditor/mobile/app/controller/Main.js @@ -255,6 +255,11 @@ define([ docInfo.put_Permissions(_permissions); docInfo.put_EncryptedInfo(this.editorConfig.encryptionKeys); + var enable = !this.editorConfig.customization || (this.editorConfig.customization.macros!==false); + docInfo.asc_putIsEnabledMacroses(!!enable); + enable = !this.editorConfig.customization || (this.editorConfig.customization.plugins!==false); + docInfo.asc_putIsEnabledPlugins(!!enable); + var type = /^(?:(pdf|djvu|xps))$/.exec(data.doc.fileType); if (type && typeof type[1] === 'string') { this.permissions.edit = this.permissions.review = false; @@ -263,6 +268,7 @@ define([ this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this)); this.api.asc_registerCallback('asc_onLicenseChanged', _.bind(this.onLicenseChanged, this)); + this.api.asc_registerCallback('asc_onRunAutostartMacroses', _.bind(this.onRunAutostartMacroses, this)); this.api.asc_setDocInfo(docInfo); this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId); @@ -1369,6 +1375,11 @@ define([ return false; }, + onRunAutostartMacroses: function() { + if (!this.editorConfig.customization || (this.editorConfig.customization.macros!==false)) + if (this.api) this.api.asc_runAutostartMacroses(); + }, + leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' to await the autosave of the document. Click \'Leave this Page\' to discard all the unsaved changes.', criticalErrorTitle: 'Error', notcriticalErrorTitle: 'Warning',