Skip to content

Commit

Permalink
Merge pull request #2855 from ONLYOFFICE/feature/wopi-saveas
Browse files Browse the repository at this point in the history
Feature/wopi saveas
  • Loading branch information
JuliaRadzhabova authored Feb 21, 2024
2 parents 2586845 + 86f5fbc commit 444c46c
Show file tree
Hide file tree
Showing 20 changed files with 91 additions and 31 deletions.
7 changes: 6 additions & 1 deletion apps/api/wopi/editor-wopi.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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', {});
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion apps/documenteditor/embed/js/ApplicationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 3 additions & 1 deletion apps/documenteditor/main/app/controller/FormsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
},

Expand Down
5 changes: 3 additions & 2 deletions apps/documenteditor/main/app/controller/LeftMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -367,7 +368,7 @@ define([
}
} else {
this.isFromFileDownloadAs = needDownload;
this.api.asc_DownloadOrigin(needDownload);
this.api.asc_DownloadOrigin(options);
}
},

Expand Down
10 changes: 7 additions & 3 deletions apps/documenteditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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);
}
},

Expand Down
4 changes: 3 additions & 1 deletion apps/documenteditor/main/app/controller/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
6 changes: 4 additions & 2 deletions apps/documenteditor/mobile/src/controller/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
4 changes: 3 additions & 1 deletion apps/documenteditor/mobile/src/controller/Toolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
5 changes: 3 additions & 2 deletions apps/pdfeditor/main/app/controller/LeftMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -322,7 +323,7 @@ define([
}
} else {
this.isFromFileDownloadAs = needDownload;
this.api.asc_DownloadOrigin(needDownload);
this.api.asc_DownloadOrigin(options);
}
},

Expand Down
10 changes: 7 additions & 3 deletions apps/pdfeditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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);
}
},

Expand Down
9 changes: 7 additions & 2 deletions apps/pdfeditor/main/app/controller/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion apps/presentationeditor/embed/js/ApplicationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
5 changes: 4 additions & 1 deletion apps/presentationeditor/main/app/controller/LeftMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},

Expand Down
4 changes: 3 additions & 1 deletion apps/presentationeditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion apps/presentationeditor/mobile/src/controller/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
6 changes: 5 additions & 1 deletion apps/spreadsheeteditor/embed/js/ApplicationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 9 additions & 3 deletions apps/spreadsheeteditor/main/app/controller/LeftMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
Expand All @@ -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) {
Expand All @@ -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();
}
},
Expand Down
7 changes: 5 additions & 2 deletions apps/spreadsheeteditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion apps/spreadsheeteditor/mobile/src/controller/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit 444c46c

Please sign in to comment.