From efdc5dbc0894edbb3c3bfa1dc61dedaf0ee26a8e Mon Sep 17 00:00:00 2001 From: merttumer Date: Mon, 26 Aug 2019 14:12:08 +0300 Subject: [PATCH] tdf#126205: Fix file format conversion on rename input Change-Id: I342ed309dfc116389f91886f5e1fd7b6c49178ed Signed-off-by: merttumer Reviewed-on: https://gerrit.libreoffice.org/80137 Reviewed-by: Aron Budea Tested-by: Aron Budea --- loleaflet/src/control/Control.Toolbar.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/loleaflet/src/control/Control.Toolbar.js b/loleaflet/src/control/Control.Toolbar.js index 3c96c905a..3e6a970cb 100644 --- a/loleaflet/src/control/Control.Toolbar.js +++ b/loleaflet/src/control/Control.Toolbar.js @@ -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);