From 6148f1f9c01c30153bb89ba64deb729f2a62f617 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 21 Feb 2024 16:50:07 +0300 Subject: [PATCH 1/2] Handle save copy for wopi --- .../documenteditor/embed/js/ApplicationController.js | 6 +++++- apps/documenteditor/main/app/controller/FormsTab.js | 4 +++- apps/documenteditor/main/app/controller/LeftMenu.js | 5 +++-- apps/documenteditor/main/app/controller/Main.js | 10 +++++++--- apps/documenteditor/main/app/controller/Toolbar.js | 4 +++- apps/documenteditor/mobile/src/controller/Main.jsx | 6 ++++-- .../documenteditor/mobile/src/controller/Toolbar.jsx | 4 +++- .../mobile/src/controller/settings/Settings.jsx | 4 +++- apps/pdfeditor/main/app/controller/LeftMenu.js | 5 +++-- apps/pdfeditor/main/app/controller/Main.js | 10 +++++++--- apps/pdfeditor/main/app/controller/Toolbar.js | 9 +++++++-- .../embed/js/ApplicationController.js | 6 +++++- .../main/app/controller/LeftMenu.js | 5 ++++- apps/presentationeditor/main/app/controller/Main.js | 4 +++- .../mobile/src/controller/Main.jsx | 4 +++- .../embed/js/ApplicationController.js | 6 +++++- .../main/app/controller/LeftMenu.js | 12 +++++++++--- apps/spreadsheeteditor/main/app/controller/Main.js | 7 +++++-- .../spreadsheeteditor/mobile/src/controller/Main.jsx | 4 +++- 19 files changed, 85 insertions(+), 30 deletions(-) diff --git a/apps/documenteditor/embed/js/ApplicationController.js b/apps/documenteditor/embed/js/ApplicationController.js index 71c4b5eeb2..6e29108ed2 100644 --- a/apps/documenteditor/embed/js/ApplicationController.js +++ b/apps/documenteditor/embed/js/ApplicationController.js @@ -869,7 +869,11 @@ DE.ApplicationController = new(function(){ Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny); return; } - if (api) api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.DOCX, true)); + if (api) { + var options = new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.DOCX, true); + options.asc_setIsSaveAs(true); + api.asc_DownloadAs(options); + } } function onRunAutostartMacroses() { diff --git a/apps/documenteditor/main/app/controller/FormsTab.js b/apps/documenteditor/main/app/controller/FormsTab.js index f7f5850134..87a4844dd9 100644 --- a/apps/documenteditor/main/app/controller/FormsTab.js +++ b/apps/documenteditor/main/app/controller/FormsTab.js @@ -354,7 +354,9 @@ define([ this.closeHelpTip('save', true); this.showRolesList(function() { this.isFromFormSaveAs = this.appConfig.canRequestSaveAs || !!this.appConfig.saveAsUrl; - this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF, this.isFromFormSaveAs)); + var options = new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF, this.isFromFormSaveAs); + options.asc_setIsSaveAs(this.isFromFormSaveAs); + this.api.asc_DownloadAs(options); }); }, diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 3da81f3ced..61cf5dbb97 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -315,9 +315,10 @@ define([ _saveAsFormat: function(menu, format, ext, textParams) { var needDownload = !!ext; + var options = new Asc.asc_CDownloadOptions(format, needDownload); + options.asc_setIsSaveAs(needDownload); if (menu) { - var options = new Asc.asc_CDownloadOptions(format, needDownload); options.asc_setTextParams(textParams); if (format == Asc.c_oAscFileType.TXT || format == Asc.c_oAscFileType.RTF) { Common.UI.warning({ @@ -367,7 +368,7 @@ define([ } } else { this.isFromFileDownloadAs = needDownload; - this.api.asc_DownloadOrigin(needDownload); + this.api.asc_DownloadOrigin(options); } }, diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 44be3ed71f..fed90e2716 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -629,7 +629,10 @@ define([ var type = /^(?:(pdf|djvu|xps|oxps))$/.exec(this.document.fileType); if (type && typeof type[1] === 'string') { if (!(format && (typeof format == 'string')) || type[1]===format.toLowerCase()) { - this.api.asc_DownloadOrigin(true); + var options = new Asc.asc_CDownloadOptions(); + options.asc_setIsDownloadEvent(true); + options.asc_setIsSaveAs(true); + this.api.asc_DownloadOrigin(options); return; } if (/^xps|oxps$/.test(this.document.fileType)) @@ -647,12 +650,13 @@ define([ } if ( !_format || _supported.indexOf(_format) < 0 ) _format = _defaultFormat; + var options = new Asc.asc_CDownloadOptions(_format, true); + options.asc_setIsSaveAs(true); if (_format) { - var options = new Asc.asc_CDownloadOptions(_format, true); textParams && options.asc_setTextParams(textParams); this.api.asc_DownloadAs(options); } else { - this.api.asc_DownloadOrigin(true); + this.api.asc_DownloadOrigin(options); } }, diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 40e2e1dcb9..0c931ad6d2 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -3552,7 +3552,9 @@ define([ callback: function(btn){ if (btn==='ok') { me.isFromFormSaveAs = config.canRequestSaveAs || !!config.saveAsUrl; - me.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF, me.isFromFormSaveAs)); + var options = new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF, me.isFromFormSaveAs); + options.asc_setIsSaveAs(me.isFromFormSaveAs); + me.api.asc_DownloadAs(options); } Common.NotificationCenter.trigger('edit:complete'); } diff --git a/apps/documenteditor/mobile/src/controller/Main.jsx b/apps/documenteditor/mobile/src/controller/Main.jsx index e49695c8e8..2f62f32683 100644 --- a/apps/documenteditor/mobile/src/controller/Main.jsx +++ b/apps/documenteditor/mobile/src/controller/Main.jsx @@ -1106,10 +1106,12 @@ class MainController extends Component { this._state.isFromGatewayDownloadAs = true; const type = /^(?:(pdf|djvu|xps|oxps))$/.exec(this.document.fileType); + let options = new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.DOCX, true); + options.asc_setIsSaveAs(true); if (type && typeof type[1] === 'string') { - this.api.asc_DownloadOrigin(true); + this.api.asc_DownloadOrigin(options); } else { - this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.DOCX, true)); + this.api.asc_DownloadAs(options); } } diff --git a/apps/documenteditor/mobile/src/controller/Toolbar.jsx b/apps/documenteditor/mobile/src/controller/Toolbar.jsx index 6eb2ac8380..d9d042ad33 100644 --- a/apps/documenteditor/mobile/src/controller/Toolbar.jsx +++ b/apps/documenteditor/mobile/src/controller/Toolbar.jsx @@ -367,7 +367,9 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview', 'sto api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF)); } else { const isFromBtnDownload = appOptions.canRequestSaveAs || !!appOptions.saveAsUrl; - api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF, isFromBtnDownload)); + let options = new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF, isFromBtnDownload); + options.asc_setIsSaveAs(isFromBtnDownload); + api.asc_DownloadAs(options); } } diff --git a/apps/documenteditor/mobile/src/controller/settings/Settings.jsx b/apps/documenteditor/mobile/src/controller/settings/Settings.jsx index 71264cb12e..cfef236370 100644 --- a/apps/documenteditor/mobile/src/controller/settings/Settings.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/Settings.jsx @@ -198,7 +198,9 @@ const SettingsController = props => { api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF)); } else { const isFromBtnDownload = appOptions.canRequestSaveAs || !!appOptions.saveAsUrl; - api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF, isFromBtnDownload)); + let options = new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF, isFromBtnDownload); + options.asc_setIsSaveAs(isFromBtnDownload); + api.asc_DownloadAs(options); } } diff --git a/apps/pdfeditor/main/app/controller/LeftMenu.js b/apps/pdfeditor/main/app/controller/LeftMenu.js index f0a727ae4e..2336f31944 100644 --- a/apps/pdfeditor/main/app/controller/LeftMenu.js +++ b/apps/pdfeditor/main/app/controller/LeftMenu.js @@ -271,9 +271,10 @@ define([ _saveAsFormat: function(menu, format, ext, textParams) { var needDownload = !!ext; + var options = new Asc.asc_CDownloadOptions(format, needDownload); + options.asc_setIsSaveAs(needDownload); if (menu) { - var options = new Asc.asc_CDownloadOptions(format, needDownload); options.asc_setTextParams(textParams); if (format == Asc.c_oAscFileType.TXT || format == Asc.c_oAscFileType.RTF) { Common.UI.warning({ @@ -322,7 +323,7 @@ define([ } } else { this.isFromFileDownloadAs = needDownload; - this.api.asc_DownloadOrigin(needDownload); + this.api.asc_DownloadOrigin(options); } }, diff --git a/apps/pdfeditor/main/app/controller/Main.js b/apps/pdfeditor/main/app/controller/Main.js index 41ebd889b0..520984376b 100644 --- a/apps/pdfeditor/main/app/controller/Main.js +++ b/apps/pdfeditor/main/app/controller/Main.js @@ -553,7 +553,10 @@ define([ ]; var type = /^(?:(pdf|djvu|xps|oxps))$/.exec(this.document.fileType); if (!(format && (typeof format == 'string')) || type[1]===format.toLowerCase()) { - this.api.asc_DownloadOrigin(true); + var options = new Asc.asc_CDownloadOptions(); + options.asc_setIsDownloadEvent(true); + options.asc_setIsSaveAs(true); + this.api.asc_DownloadOrigin(options); return; } if (/^xps|oxps$/.test(this.document.fileType)) @@ -563,12 +566,13 @@ define([ } if ( !_format || _supported.indexOf(_format) < 0 ) _format = _defaultFormat; + var options = new Asc.asc_CDownloadOptions(_format, true); + options.asc_setIsSaveAs(true); if (_format) { - var options = new Asc.asc_CDownloadOptions(_format, true); textParams && options.asc_setTextParams(textParams); this.api.asc_DownloadAs(options); } else { - this.api.asc_DownloadOrigin(true); + this.api.asc_DownloadOrigin(options); } }, diff --git a/apps/pdfeditor/main/app/controller/Toolbar.js b/apps/pdfeditor/main/app/controller/Toolbar.js index 2ae5ea4a29..66ae82eec1 100644 --- a/apps/pdfeditor/main/app/controller/Toolbar.js +++ b/apps/pdfeditor/main/app/controller/Toolbar.js @@ -424,7 +424,10 @@ define([ me.api.asc_DownloadAs(); else if (btn==='copy' || btn==='download') { me._state.isFromToolbarDownloadAs = (btn==='copy'); - me.api.asc_DownloadOrigin(btn==='copy'); + var options = new Asc.asc_CDownloadOptions(); + options.asc_setIsDownloadEvent(me._state.isFromToolbarDownloadAs); + options.asc_setIsSaveAs(me._state.isFromToolbarDownloadAs); + me.api.asc_DownloadOrigin(options); } Common.NotificationCenter.trigger('edit:complete', toolbar); } @@ -741,7 +744,9 @@ define([ this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF)); else { this._state.isFromToolbarDownloadAs = this.mode.canRequestSaveAs || !!this.mode.saveAsUrl; - this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF, this._state.isFromToolbarDownloadAs)); + var options = new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF, this._state.isFromToolbarDownloadAs); + options.asc_setIsSaveAs(this._state.isFromToolbarDownloadAs); + this.api.asc_DownloadAs(options); } } }, diff --git a/apps/presentationeditor/embed/js/ApplicationController.js b/apps/presentationeditor/embed/js/ApplicationController.js index 2f8a44153b..08afd5d0bf 100644 --- a/apps/presentationeditor/embed/js/ApplicationController.js +++ b/apps/presentationeditor/embed/js/ApplicationController.js @@ -721,7 +721,11 @@ PE.ApplicationController = new(function(){ Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny); return; } - if (api) api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PPTX, true)); + if (api) { + var options = new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PPTX, true); + options.asc_setIsSaveAs(true); + api.asc_DownloadAs(options); + } } function onRunAutostartMacroses() { diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index 00e464aacd..1e07462bed 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -292,7 +292,10 @@ define([ clickSaveCopyAsFormat: function(menu, format, ext) { this.isFromFileDownloadAs = ext; - this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format, true)); + var options = new Asc.asc_CDownloadOptions(format, true); + options.asc_setIsSaveAs(true); + this.api.asc_DownloadAs(options); + menu.hide(); }, diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index b702611255..5097e4ebd5 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -555,7 +555,9 @@ define([ if ( !_format || _supported.indexOf(_format) < 0 ) _format = Asc.c_oAscFileType.PPTX; - this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(_format, true)); + var options = new Asc.asc_CDownloadOptions(_format, true); + options.asc_setIsSaveAs(true); + this.api.asc_DownloadAs(options); }, onProcessMouse: function(data) { diff --git a/apps/presentationeditor/mobile/src/controller/Main.jsx b/apps/presentationeditor/mobile/src/controller/Main.jsx index 3bd8397618..699f13223e 100644 --- a/apps/presentationeditor/mobile/src/controller/Main.jsx +++ b/apps/presentationeditor/mobile/src/controller/Main.jsx @@ -961,7 +961,9 @@ class MainController extends Component { return; } this._state.isFromGatewayDownloadAs = true; - this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PPTX, true)); + var options = new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PPTX, true); + options.asc_setIsSaveAs(true); + this.api.asc_DownloadAs(options); } onRequestClose () { diff --git a/apps/spreadsheeteditor/embed/js/ApplicationController.js b/apps/spreadsheeteditor/embed/js/ApplicationController.js index 8590868ee9..ed00a3dc40 100644 --- a/apps/spreadsheeteditor/embed/js/ApplicationController.js +++ b/apps/spreadsheeteditor/embed/js/ApplicationController.js @@ -636,7 +636,11 @@ SSE.ApplicationController = new(function(){ Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny); return; } - api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.XLSX, true)); + if (api) { + var options = new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.XLSX, true); + options.asc_setIsSaveAs(true); + api.asc_DownloadAs(options); + } } function onApiMouseMove(array) { diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index d27609b2d9..9066d45c7d 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -382,7 +382,9 @@ define([ if (btn == 'ok') { me.showLostDataWarning(function () { me.isFromFileDownloadAs = ext; - Common.NotificationCenter.trigger('download:advanced', Asc.c_oAscAdvancedOptionsID.CSV, me.api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format, true)); + var options = new Asc.asc_CDownloadOptions(format, true); + options.asc_setIsSaveAs(true); + Common.NotificationCenter.trigger('download:advanced', Asc.c_oAscAdvancedOptionsID.CSV, me.api.asc_getAdvancedOptions(), 2, options); menu.hide(); }); } @@ -391,7 +393,9 @@ define([ } else me.showLostDataWarning(function () { me.isFromFileDownloadAs = ext; - Common.NotificationCenter.trigger('download:advanced', Asc.c_oAscAdvancedOptionsID.CSV, me.api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format, true)); + var options = new Asc.asc_CDownloadOptions(format, true); + options.asc_setIsSaveAs(true); + Common.NotificationCenter.trigger('download:advanced', Asc.c_oAscAdvancedOptionsID.CSV, me.api.asc_getAdvancedOptions(), 2, options); menu.hide(); }); } else if (format == Asc.c_oAscFileType.PDF || format == Asc.c_oAscFileType.PDFA) { @@ -400,7 +404,9 @@ define([ Common.NotificationCenter.trigger('download:settings', this.leftMenu, format, true); } else { this.isFromFileDownloadAs = ext; - this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format, true)); + var options = new Asc.asc_CDownloadOptions(format, true); + options.asc_setIsSaveAs(true); + this.api.asc_DownloadAs(options); menu.hide(); } }, diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 674e61ddee..1873f97d90 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -642,8 +642,11 @@ define([ _format = Asc.c_oAscFileType.XLSX; if (_format == Asc.c_oAscFileType.PDF || _format == Asc.c_oAscFileType.PDFA) Common.NotificationCenter.trigger('download:settings', this, _format, true); - else - this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(_format, true)); + else { + var options = new Asc.asc_CDownloadOptions(_format, true); + options.asc_setIsSaveAs(true); + this.api.asc_DownloadAs(options); + } }, onProcessMouse: function(data) { diff --git a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx index 2844029e93..9ca01233ad 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx @@ -1149,7 +1149,9 @@ class MainController extends Component { return; } this._state.isFromGatewayDownloadAs = true; - this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.XLSX, true)); + var options = new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.XLSX, true); + options.asc_setIsSaveAs(true); + this.api.asc_DownloadAs(options); } onRequestClose () { From 86f5fbcac0f935b4a271b7ac6b67c2182684aecf Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Wed, 21 Feb 2024 20:23:17 +0300 Subject: [PATCH 2/2] [wopi] Add SaveAs button for wopi; for bug 62643 --- apps/api/wopi/editor-wopi.ejs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/api/wopi/editor-wopi.ejs b/apps/api/wopi/editor-wopi.ejs index ab427dc66a..fc342779bf 100644 --- a/apps/api/wopi/editor-wopi.ejs +++ b/apps/api/wopi/editor-wopi.ejs @@ -219,6 +219,10 @@ div { window.open(fileInfo.HostEditUrl, "_blank"); }; + var onRequestSaveAs = function (event) { + //SaveAs work via PutRelativeFile server-server request + }; + var onRequestSharingSettings = function (event) { if (fileInfo.FileSharingPostMessage) _postMessage('UI_Sharing', {}); @@ -324,7 +328,8 @@ div { "events": { "onAppReady": onAppReady, "onDocumentStateChange": fileInfo.EditNotificationPostMessage ? onDocumentStateChange : undefined, - 'onRequestEditRights': fileInfo.EditModePostMessage || (fileInfo.HostEditUrl && !fileInfo.UserCanNotWriteRelative) ? onRequestEditRights : undefined, + 'onRequestEditRights': fileInfo.EditModePostMessage || fileInfo.HostEditUrl ? onRequestEditRights : undefined, + 'onRequestSaveAs': fileInfo.SupportsUpdate && !fileInfo.UserCanNotWriteRelative ? onRequestSaveAs : undefined, "onError": onError, "onRequestClose": fileInfo.ClosePostMessage || fileInfo.CloseUrl ? onRequestClose : undefined, "onRequestRename": fileInfo.SupportsRename && fileInfo.UserCanRename ? onRequestRename : undefined,