From 04019e3414c300f14c73fa1f3765f60b04d29763 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 21 Oct 2021 21:17:50 +0300 Subject: [PATCH] [DE] Fix opening oform files, disable filling forms for not-oform files. --- apps/api/documents/api.js | 14 +++++--------- .../embed/js/ApplicationController.js | 2 +- .../forms/app/controller/ApplicationController.js | 4 +++- apps/documenteditor/main/app/controller/Main.js | 7 ++++++- apps/documenteditor/mobile/src/controller/Main.jsx | 8 +++++++- apps/documenteditor/mobile/src/store/appOptions.js | 5 +++-- 6 files changed, 25 insertions(+), 15 deletions(-) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index 43cc786f3..8161860bf 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -876,17 +876,13 @@ path += app + "/"; if (config.document && typeof config.document.fileType === 'string' && config.document.fileType.toLowerCase() === 'oform') { - if (config.document.permissions) { - (config.document.permissions.fillForms===undefined) && (config.document.permissions.fillForms = (config.document.permissions.edit !== false)); - config.document.permissions.edit = config.document.permissions.review = config.document.permissions.comment = false; - } + var canFillForms = !config.document.permissions + ? true : (config.document.permissions.fillForms===undefined) + ? (config.document.permissions.edit !== false) : config.document.permissions.fillForms; path_type = (config.type === "mobile" || isSafari_mobile) - ? "mobile" : config.document.permissions && (config.document.permissions.fillForms === true) && (config.editorConfig.mode !== 'view') - ? "forms" : "embed"; + ? "mobile" : (config.type === "embedded" || !canFillForms || config.editorConfig.mode === 'view') + ? "embed" : "forms"; } else { - if (app==='documenteditor' && config.document && config.document.permissions && (config.document.permissions.edit === false) && (config.document.permissions.review !== true)) { - config.document.permissions.fillForms = false; - } path_type = (config.type === "mobile" || isSafari_mobile) ? "mobile" : (config.type === "embedded") ? "embed" : "main"; diff --git a/apps/documenteditor/embed/js/ApplicationController.js b/apps/documenteditor/embed/js/ApplicationController.js index 2879e3683..2238c2de6 100644 --- a/apps/documenteditor/embed/js/ApplicationController.js +++ b/apps/documenteditor/embed/js/ApplicationController.js @@ -597,7 +597,7 @@ DE.ApplicationController = new(function(){ function onEditorPermissions(params) { var licType = params.asc_getLicenseType(); appOptions.canLicense = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit); - appOptions.canFillForms = appOptions.canLicense && (permissions.fillForms===true) && (config.mode !== 'view'); + appOptions.canFillForms = false; // use forms editor for filling forms appOptions.canSubmitForms = appOptions.canLicense && (typeof (config.customization) == 'object') && !!config.customization.submitForm; appOptions.canBranding = params.asc_getCustomization(); appOptions.canBranding && setBranding(config.customization); diff --git a/apps/documenteditor/forms/app/controller/ApplicationController.js b/apps/documenteditor/forms/app/controller/ApplicationController.js index 3d6f4e898..25e84cd04 100644 --- a/apps/documenteditor/forms/app/controller/ApplicationController.js +++ b/apps/documenteditor/forms/app/controller/ApplicationController.js @@ -441,7 +441,9 @@ define([ this.appOptions.isBeta = params.asc_getIsBeta(); this.appOptions.canLicense = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit); this.appOptions.canSubmitForms = this.appOptions.canLicense && (typeof (this.editorConfig.customization) == 'object') && !!this.editorConfig.customization.submitForm; - this.appOptions.canFillForms = this.appOptions.canLicense && (this.permissions.fillForms===true) && (this.editorConfig.mode !== 'view'); + + var type = /^(?:(oform))$/.exec(this.document.fileType); // can fill forms only in oform format + this.appOptions.canFillForms = this.appOptions.canLicense && !!(type && typeof type[1] === 'string') && ((this.permissions.fillForms===undefined) ? (this.permissions.edit !== false) : this.permissions.fillForms) && (this.editorConfig.mode !== 'view'); this.api.asc_setViewMode(!this.appOptions.canFillForms); this.appOptions.canBranding = params.asc_getCustomization(); diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 6bf5a7146..13fd10f2c 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -482,6 +482,10 @@ define([ var type = data.doc ? /^(?:(docxf))$/.exec(data.doc.fileType) : false; this.appOptions.canFeatureForms = !!(type && typeof type[1] === 'string'); + type = data.doc ? /^(?:(oform))$/.exec(data.doc.fileType) : false; + if (type && typeof type[1] === 'string') + this.permissions.edit = this.permissions.review = this.permissions.comment = false; + 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)); @@ -1421,7 +1425,8 @@ define([ this.appOptions.canEditContentControl = (this.permissions.modifyContentControl!==false); this.appOptions.canHelp = !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.help===false); this.appOptions.canSubmitForms = false; // this.appOptions.canLicense && (typeof (this.editorConfig.customization) == 'object') && !!this.editorConfig.customization.submitForm; - this.appOptions.canFillForms = this.appOptions.canLicense && ((this.permissions.fillForms===undefined) ? this.appOptions.isEdit : this.permissions.fillForms) && (this.editorConfig.mode !== 'view'); + // use forms editor for filling forms mode + this.appOptions.canFillForms = false;// this.appOptions.canLicense && ((this.permissions.fillForms===undefined) ? this.appOptions.isEdit : this.permissions.fillForms) && (this.editorConfig.mode !== 'view'); this.appOptions.isRestrictedEdit = !this.appOptions.isEdit && (this.appOptions.canComments || this.appOptions.canFillForms); if (this.appOptions.isRestrictedEdit && this.appOptions.canComments && this.appOptions.canFillForms) // must be one restricted mode, priority for filling forms this.appOptions.canComments = false; diff --git a/apps/documenteditor/mobile/src/controller/Main.jsx b/apps/documenteditor/mobile/src/controller/Main.jsx index a10936f64..65df10d91 100644 --- a/apps/documenteditor/mobile/src/controller/Main.jsx +++ b/apps/documenteditor/mobile/src/controller/Main.jsx @@ -133,12 +133,18 @@ class MainController extends Component { enable = !this.editorConfig.customization || (this.editorConfig.customization.plugins !== false); docInfo.asc_putIsEnabledPlugins(!!enable); - const type = /^(?:(pdf|djvu|xps|oxps))$/.exec(data.doc.fileType); + let type = /^(?:(pdf|djvu|xps|oxps))$/.exec(data.doc.fileType); if (type && typeof type[1] === 'string') { this.permissions.edit = this.permissions.review = false; } } + let type = data.doc ? /^(?:(oform))$/.exec(data.doc.fileType) : false; + if (type && typeof type[1] === 'string') { + (this.permissions.fillForms===undefined) && (this.permissions.fillForms = (this.permissions.edit!==false)); + this.permissions.edit = this.permissions.review = this.permissions.comment = false; + } + this.api.asc_registerCallback('asc_onGetEditorPermissions', onEditorPermissions); this.api.asc_registerCallback('asc_onDocumentContentReady', onDocumentContentReady); this.api.asc_registerCallback('asc_onLicenseChanged', this.onLicenseChanged.bind(this)); diff --git a/apps/documenteditor/mobile/src/store/appOptions.js b/apps/documenteditor/mobile/src/store/appOptions.js index 3e0d1ac8d..caba8775d 100644 --- a/apps/documenteditor/mobile/src/store/appOptions.js +++ b/apps/documenteditor/mobile/src/store/appOptions.js @@ -118,13 +118,14 @@ export class storeAppOptions { this.canEditStyles = this.canLicense && this.canEdit; this.canPrint = (permissions.print !== false); this.fileKey = document.key; - this.canFillForms = this.canLicense && ((permissions.fillForms===undefined) ? this.isEdit : permissions.fillForms) && (this.config.mode !== 'view'); + let type = /^(?:(oform))$/.exec(document.fileType); // can fill forms only in oform format + this.canFillForms = this.canLicense && (!!type && typeof type[1] === 'string') && ((permissions.fillForms===undefined) ? this.isEdit : permissions.fillForms) && (this.config.mode !== 'view'); this.isRestrictedEdit = !this.isEdit && (this.canComments || this.canFillForms); if (this.isRestrictedEdit && this.canComments && this.canFillForms) // must be one restricted mode, priority for filling forms this.canComments = false; this.trialMode = params.asc_getLicenseMode(); - const type = /^(?:(pdf|djvu|xps|oxps))$/.exec(document.fileType); + type = /^(?:(pdf|djvu|xps|oxps))$/.exec(document.fileType); this.canDownloadOrigin = permissions.download !== false && (type && typeof type[1] === 'string'); this.canDownload = permissions.download !== false && (!type || typeof type[1] !== 'string'); this.canReader = (!type || typeof type[1] !== 'string');