tdf#126205: Fix file format conversion on rename input

Change-Id: I342ed309dfc116389f91886f5e1fd7b6c49178ed
Signed-off-by: merttumer <mert.tumer@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/80137
Reviewed-by: Aron Budea <aron.budea@collabora.com>
Tested-by: Aron Budea <aron.budea@collabora.com>
This commit is contained in:
merttumer 2019-08-26 14:12:08 +03:00 committed by Aron Budea
parent e4f2145899
commit efdc5dbc08

View file

@ -1190,12 +1190,20 @@ function documentNameConfirm() {
var value = $('#document-name-input').val();
if (value !== null && value != '' && value != map['wopi'].BaseFileName) {
if (map['wopi'].UserCanRename && map['wopi'].SupportsRename) {
// file name must be without the extension
if (value.lastIndexOf('.') > 0)
value = value.substr(0, value.lastIndexOf('.'));
map.sendUnoCommand('.uno:Save');
map._RenameFile = value;
if (value.lastIndexOf('.') > 0) {
var fname = map['wopi'].BaseFileName;
var ext = fname.substr(fname.lastIndexOf('.')+1, fname.length);
// check format conversion
if (ext != value.substr(value.lastIndexOf('.')+1, value.length)) {
map.saveAs(value);
} else {
// same extension, just rename the file
// file name must be without the extension for rename
value = value.substr(0, value.lastIndexOf('.'));
map.sendUnoCommand('.uno:Save');
map._RenameFile = value;
}
}
} else {
// saveAs for rename
map.saveAs(value);