From 479387d2055da9f9075690eeaba02f73ec5b6176 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Wed, 22 Feb 2023 21:57:17 +0400 Subject: [PATCH] [DE mobile] Fix Bug 61340 --- apps/documenteditor/mobile/locale/en.json | 3 +- .../src/controller/settings/Download.jsx | 82 ++++++++++++------- 2 files changed, 54 insertions(+), 31 deletions(-) diff --git a/apps/documenteditor/mobile/locale/en.json b/apps/documenteditor/mobile/locale/en.json index 9891e1247d..0dbcb09a7e 100644 --- a/apps/documenteditor/mobile/locale/en.json +++ b/apps/documenteditor/mobile/locale/en.json @@ -566,7 +566,8 @@ "warnLicenseUsersExceeded": "You've reached the user limit for %1 editors. Contact your administrator to learn more.", "warnNoLicense": "You've reached the limit for simultaneous connections to %1 editors. This document will be opened for viewing only. Contact %1 sales team for personal upgrade terms.", "warnNoLicenseUsers": "You've reached the user limit for %1 editors. Contact %1 sales team for personal upgrade terms.", - "warnProcessRightsChange": "You don't have permission to edit this file." + "warnProcessRightsChange": "You don't have permission to edit this file.", + "warnDownloadAsPdf": "Your {0} will be converted to an editable format. This may take a while. The resulting document will be optimized to allow you to edit the text, so it might not look exactly like the original {0}, especially if the original file contained lots of graphics." }, "Settings": { "advDRMOptions": "Protected File", diff --git a/apps/documenteditor/mobile/src/controller/settings/Download.jsx b/apps/documenteditor/mobile/src/controller/settings/Download.jsx index 88c2a7fb31..a7c08c422c 100644 --- a/apps/documenteditor/mobile/src/controller/settings/Download.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/Download.jsx @@ -21,41 +21,63 @@ class DownloadController extends Component { onSaveFormat(format) { const api = Common.EditorApi.get(); + const storeDocumentInfo = this.props.storeDocumentInfo; + const dataDoc = storeDocumentInfo.dataDoc; + const fileType = dataDoc.fileType; const { t } = this.props; const _t = t("Settings", { returnObjects: true }); - if(format) { - this.closeModal(); - if (format == Asc.c_oAscFileType.TXT || format == Asc.c_oAscFileType.RTF) { - f7.dialog.create({ - title: _t.notcriticalErrorTitle, - text: (format === Asc.c_oAscFileType.TXT) ? _t.textDownloadTxt : _t.textDownloadRtf, - buttons: [ - { - text: _t.textCancel - }, - { - text: _t.textOk, - onClick: () => { - if (format == Asc.c_oAscFileType.TXT) { - const advOptions = api.asc_getAdvancedOptions(); - Common.Notifications.trigger('openEncoding', Asc.c_oAscAdvancedOptionsID.TXT, advOptions, 2, new Asc.asc_CDownloadOptions(format)); - } - else { - setTimeout(() => { - api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format)); - }, 400); + if(/^pdf|xps|oxps|djvu$/.test(fileType)) { + if(format) { + this.closeModal(); + + if (format == Asc.c_oAscFileType.TXT || format == Asc.c_oAscFileType.RTF) { + f7.dialog.create({ + title: _t.notcriticalErrorTitle, + text: (format === Asc.c_oAscFileType.TXT) ? _t.textDownloadTxt : _t.textDownloadRtf, + buttons: [ + { + text: _t.textCancel + }, + { + text: _t.textOk, + onClick: () => { + if (format == Asc.c_oAscFileType.TXT) { + const advOptions = api.asc_getAdvancedOptions(); + Common.Notifications.trigger('openEncoding', Asc.c_oAscAdvancedOptionsID.TXT, advOptions, 2, new Asc.asc_CDownloadOptions(format)); + } else { + setTimeout(() => { + api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format)); + }, 400); + } } } - } - ], - }).open(); - } - else { - setTimeout(() => { - api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format)); - }, 400); + ], + }).open(); + } else { + f7.dialog.create({ + title: _t.notcriticalErrorTitle, + text: t('Main.warnDownloadAsPdf').replaceAll('{0}', fileType.toUpperCase()), + buttons: [ + { + text: _t.textCancel + }, + { + text: _t.textOk, + onClick: () => { + const options = new Asc.asc_CDownloadOptions(format); + options.asc_setTextParams(new AscCommon.asc_CTextParams(Asc.c_oAscTextAssociation.PlainLine)); + api.asc_DownloadAs(options); + } + } + ], + }).open(); + } } + } else { + setTimeout(() => { + api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format)); + }, 400); } } @@ -66,7 +88,7 @@ class DownloadController extends Component { } } -const DownloadWithTranslation = inject("storeAppOptions")(observer(withTranslation()(DownloadController))); +const DownloadWithTranslation = inject("storeAppOptions", "storeDocumentInfo")(observer(withTranslation()(DownloadController))); const onAdvancedOptions = (type, _t, isDocReady, canRequestClose, isDRM) => { if ($$('.dlg-adv-options.modal-in').length > 0) return;