Save As: Reload the newly created document after the Save As.

Change-Id: Ibf979cce4fea13a31ece089394dab296158a159b
Reviewed-on: https://gerrit.libreoffice.org/44283
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
This commit is contained in:
Jan Holesovsky 2017-11-03 19:00:58 +01:00
parent 513ffe36c1
commit 2355f2792f
3 changed files with 34 additions and 4 deletions

View file

@ -85,6 +85,9 @@ L.Map.include({
},
saveAs: function (url, format, options) {
if (url === undefined || url == null) {
return;
}
if (format === undefined || format === null) {
format = '';
}
@ -94,7 +97,7 @@ L.Map.include({
this.showBusy(_('Saving...'), false);
this._socket.sendMessage('saveas ' +
'url=' + url + ' ' +
'url=wopi:' + encodeURIComponent(url) + ' ' +
'format=' + format + ' ' +
'options=' + options);
},

View file

@ -122,6 +122,12 @@ L.Socket = L.Class.extend({
this.socket.send(msg);
},
_getParameterByName: function(url, name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'), results = regex.exec(url);
return results === null ? '' : results[1].replace(/\+/g, ' ');
},
_onSocketOpen: function () {
console.debug('_onSocketOpen:');
this._map._serverRecycling = false;
@ -563,8 +569,29 @@ L.Socket = L.Class.extend({
}
else if (textMsg.startsWith('saveas:')) {
this._map.hideBusy();
// var url = command.url; // WOPI url - if needed at some stage
// var name = command.name; TODO dialog that the file was saved as "name"
if (command !== undefined && command.url !== undefined && command.url !== '') {
this.close();
var url = command.url;
var accessToken = this._getParameterByName(url, 'access_token');
var accessTokenTtl = this._getParameterByName(url, 'access_token_ttl');
if (accessToken !== undefined) {
if (accessTokenTtl === undefined) {
accessTokenTtl = 0;
}
this._map.options.docParams = { 'access_token': accessToken, 'access_token_ttl': accessTokenTtl };
}
else {
this._map.options.docParams = {};
}
// setup for loading the new document, and trigger the load
var docUrl = url.split('?')[0];
this._map.options.doc = docUrl;
this._map.options.wopiSrc = encodeURIComponent(docUrl);
this._map.loadDocument();
}
// var name = command.name; - ignored, we get the new name via the wopi's BaseFileName
}
else if (textMsg.startsWith('statusindicator:')) {
//FIXME: We should get statusindicator when saving too, no?

View file

@ -226,7 +226,7 @@ L.Map.WOPI = L.Handler.extend({
if (msg.Values) {
if (msg.Values.Filename !== null && msg.Values.Filename !== undefined) {
this._map.showBusy(_('Creating copy...'), false);
map.saveAs('wopi:' + msg.Values.Filename);
map.saveAs(msg.Values.Filename);
}
}
}