[DE] Fix opening oform files, disable filling forms for not-oform files.

This commit is contained in:
Julia Radzhabova 2021-10-21 21:17:50 +03:00
parent 031d71c7d2
commit 04019e3414
6 changed files with 25 additions and 15 deletions

View file

@ -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";

View file

@ -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);

View file

@ -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();

View file

@ -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;

View file

@ -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));

View file

@ -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');