loleaflet/dist/loleaflet.html |2 +
loleaflet/dist/toolbar.css| 25 ++
loleaflet/dist/toolbar/toolbar.js | 37 ++
loleaflet/src/map/handler/Map.WOPI.js |2 +
wsd/DocumentBroker.cpp|1
5 files changed, 67 insertions(+)
New commits:
commit 41dfc1ab2c4006c5c38dfa10550e218442154e54
Author: Jan Holesovsky
Date: Tue Oct 31 17:58:58 2017 +0100
Save As: UI for changing the document name.
Change-Id: I23aba95ff0f8d867b021ba3cf0a6bc5eb4754f9d
Reviewed-on: https://gerrit.libreoffice.org/44282
Reviewed-by: Andras Timar
Tested-by: Andras Timar
diff --git a/loleaflet/dist/loleaflet.html b/loleaflet/dist/loleaflet.html
index 13e60e54..5d3ccd8a 100644
--- a/loleaflet/dist/loleaflet.html
+++ b/loleaflet/dist/loleaflet.html
@@ -53,6 +53,8 @@
+
+
diff --git a/loleaflet/dist/toolbar.css b/loleaflet/dist/toolbar.css
index 0b65e88f..6564ae95 100644
--- a/loleaflet/dist/toolbar.css
+++ b/loleaflet/dist/toolbar.css
@@ -72,6 +72,31 @@
width: 700px;
}
+#document-name-input {
+position: fixed;
+z-index: 1050;
+right: 35px;
+top: 2px;
+width: 200px;
+font-size: 16px;
+//font-weight: bold;
+border: 1px solid transparent;
+background-color: transparent;
+}
+
+#document-name-input.editable:focus {
+border: 1px solid #bb;
+background-color: white;
+}
+
+#document-name-input.editable:hover {
+border: 1px solid #bb;
+background-color: white;
+background-image: url('../images/lc_editdoc.svg');
+background-position: right;
+background-repeat: no-repeat;
+}
+
#closebuttonwrapper {
position: fixed;
z-index: 1050;
diff --git a/loleaflet/dist/toolbar/toolbar.js
b/loleaflet/dist/toolbar/toolbar.js
index ea7e567b..1e1a89f5 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -774,6 +774,27 @@ function onSearchKeyPress(e) {
}
}
+function documentNameConfirm() {
+ var value = $('#document-name-input').val();
+ if (value !== null && value != '') {
+ map.saveAs(value);
+ }
+ map._onGotFocus();
+}
+
+function documentNameCancel() {
+ $('#document-name-input').val(map['wopi'].BaseFileName);
+ map._onGotFocus();
+}
+
+function onDocumentNameKeyPress(e) {
+ if (e.keyCode === 13) { // Enter key
+ documentNameConfirm();
+ } else if (e.keyCode === 27) { // Escape key
+ documentNameCancel();
+ }
+}
+
function sortFontSizes() {
var oldVal = $('.fontsizes-select').val();
var selectList = $('.fontsizes-select option');
@@ -963,6 +984,22 @@ map.on('wopiprops', function(e) {
evt.preventDefault();
});
}
+ if (e.BaseFileName !== null) {
+ // set the document name into the name field
+ $('#document-name-input').val(e.BaseFileName);
+ }
+ if (e.UserCanNotWriteRelative === false) {
+ // Save As allowed
+ $('#document-name-input').prop('disabled', false);
+ $('#document-name-input').addClass('editable');
+ $('#document-name-input').on('keypress',
onDocumentNameKeyPress);
+ $('#document-name-input').on('focus', function() {
map._onLostFocus(); /* hide the caret in the main document */ });
+ $('#document-name-input').on('blur', documentNameCancel);
+ } else {
+ $('#document-name-input').prop('disabled', true);
+ $('#document-name-input').removeClass('editable');
+ $('#document-name-input').off('keypress',
onDocumentNameKeyPress);
+ }
});
map.on('doclayerinit', function () {
diff --git a/loleaflet/src/map/handler/Map.WOPI.js
b/loleaflet/src/map/handler/Map.WOPI.js
index e2a3840d..f06e30fc 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -8,6 +8,7 @@ L.Map.WOPI = L.Handler.extend({
// So use '*' because we still needs to send 'close' message to the
parent frame which
// wouldn't be possible otherwise.
PostMessageOrigin: '*',
+ BaseFileName: '',
DocumentLoadedTime: false,
HidePrintOption: false,
HideSaveOption: false,
@@ -61,6 +62,7 @@ L.Map.WOPI = L.Handler.extend({
this.PostMessageOrigin = wopiInfo['PostMessageOrigin'];
}
+ this.BaseFileName = wopiInfo['BaseFileName'];
this.HidePrintOption = !!wopiInfo['HidePrintOption'];
this.HideSaveOption = !!wopiInfo['HideSaveOption'];
this.HideExportOption = !!wopiInfo['HideExportOption'];
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 966c3184..a6a91c1a 100644
---