[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - 2 commits - loleaflet/reference.html loleaflet/src wsd/DocumentBroker.cpp wsd/Storage.cpp wsd/Storage.hpp
Pranav Kant
pranavk at collabora.co.uk
Wed Oct 4 03:30:28 UTC 2017
loleaflet/reference.html | 22 +++++++++++++++++++++-
loleaflet/src/control/Control.Menubar.js | 8 ++++++++
loleaflet/src/core/Socket.js | 9 +++++++++
loleaflet/src/map/handler/Map.WOPI.js | 15 +++++++++++++--
wsd/DocumentBroker.cpp | 1 +
wsd/Storage.cpp | 4 +++-
wsd/Storage.hpp | 4 ++++
7 files changed, 59 insertions(+), 4 deletions(-)
New commits:
commit 36670bcffa1113f1839fdd5e0dbca253171a95ed
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Tue Oct 3 20:36:02 2017 +0530
Show save-as option based on CheckFileInfo params
If UserCanNotWriteRelative is mentioned in the CheckFileInfo response.
Change-Id: I33d2e21159b3e18ae88fd72f404f2d1d1d9b64e5
(cherry picked from commit df034096c1033137a0b5de4267585b8d5e20ad65)
diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index 1a9abc2e..8744585d 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -187,6 +187,7 @@ L.Control.Menubar = L.Control.extend({
presentation: [
{name: _('File'), id: 'file', type: 'menu', menu: [
{name: _('Save'), id: 'save', type: 'action'},
+ {name: _('Save As'), id: 'saveas', type: 'action'},
{name: _('Print'), id: 'print', type: 'action'},
{name: _('See revision history'), id: 'rev-history', type: 'action'},
{name: _('Download as'), id: 'downloadas', type: 'menu', menu: [
@@ -251,6 +252,7 @@ L.Control.Menubar = L.Control.extend({
spreadsheet: [
{name: _('File'), id: 'file', type: 'menu', menu: [
{name: _('Save'), id: 'save', type: 'action'},
+ {name: _('Save As'), id: 'saveas', type: 'action'},
{name: _('Print'), id: 'print', type: 'action'},
{name: _('See revision history'), id: 'rev-history', type: 'action'},
{name: _('Download as'), id:'downloadas', type: 'menu', menu: [
@@ -771,6 +773,9 @@ L.Control.Menubar = L.Control.extend({
if (menu[i].id === 'save' && this._map['wopi'].HideSaveOption)
continue;
+ if (menu[i].id === 'saveas' && this._map['wopi'].UserCanNotWriteRelative)
+ continue;
+
if (menu[i].id && menu[i].id.startsWith('fullscreen-presentation') && this._map['wopi'].HideExportOption)
continue;
diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js
index a7bbcb8c..8aa364c1 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -16,6 +16,7 @@ L.Map.WOPI = L.Handler.extend({
DisableExport: false,
DisableCopy: false,
DisableInactiveMessages: false,
+ UserCanNotWriteRelative: true,
_appLoadedConditions: {
doclayerinit: false,
@@ -67,6 +68,7 @@ L.Map.WOPI = L.Handler.extend({
this.DisableExport = !!wopiInfo['DisableExport'];
this.DisableCopy = !!wopiInfo['DisableCopy'];
this.DisableInactiveMessages = !!wopiInfo['DisableInactiveMessages'];
+ this.UserCanNotWriteRelative = !!wopiInfo['UserCanNotWriteRelative'];
this._map.fire('postMessage', {msgId: 'App_LoadingStatus', args: {Status: 'Frame_Ready'}});
},
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 945e9f89..85042585 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -445,6 +445,7 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s
wopiInfo->set("DisableExport", wopifileinfo->_disableExport);
wopiInfo->set("DisableCopy", wopifileinfo->_disableCopy);
wopiInfo->set("DisableInactiveMessages", wopifileinfo->_disableInactiveMessages);
+ wopiInfo->set("UserCanNotWriteRelative", wopifileinfo->_userCanNotWriteRelative);
std::ostringstream ossWopiInfo;
wopiInfo->stringify(ossWopiInfo);
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 4d2ce0c5..14482b0c 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -552,6 +552,7 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Au
bool disableCopy = false;
bool disableInactiveMessages = false;
std::string lastModifiedTime;
+ bool userCanNotWriteRelative = true;
LOG_DBG("WOPI::CheckFileInfo returned: " << resMsg << ". Call duration: " << callDuration.count() << "s");
Poco::JSON::Object::Ptr object;
@@ -575,6 +576,7 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Au
getWOPIValue(object, "DisableCopy", disableCopy);
getWOPIValue(object, "DisableInactiveMessages", disableInactiveMessages);
getWOPIValue(object, "LastModifiedTime", lastModifiedTime);
+ getWOPIValue(object, "UserCanNotWriteRelative", userCanNotWriteRelative);
}
else
{
@@ -585,7 +587,7 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Au
const Poco::Timestamp modifiedTime = iso8601ToTimestamp(lastModifiedTime);
_fileInfo = FileInfo({filename, ownerId, modifiedTime, size});
- return std::unique_ptr<WopiStorage::WOPIFileInfo>(new WOPIFileInfo({userId, userName, userExtraInfo, watermarkText, canWrite, postMessageOrigin, hidePrintOption, hideSaveOption, hideExportOption, enableOwnerTermination, disablePrint, disableExport, disableCopy, disableInactiveMessages, callDuration}));
+ return std::unique_ptr<WopiStorage::WOPIFileInfo>(new WOPIFileInfo({userId, userName, userExtraInfo, watermarkText, canWrite, postMessageOrigin, hidePrintOption, hideSaveOption, hideExportOption, enableOwnerTermination, disablePrint, disableExport, disableCopy, disableInactiveMessages, userCanNotWriteRelative, callDuration}));
}
/// uri format: http://server/<...>/wopi*/files/<id>/content
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index 12462b47..57fc9ad4 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -223,6 +223,7 @@ public:
const bool disableExport,
const bool disableCopy,
const bool disableInactiveMessages,
+ const bool userCanNotWriteRelative,
const std::chrono::duration<double> callDuration)
: _userid(userid),
_username(username),
@@ -237,6 +238,7 @@ public:
_disableExport(disableExport),
_disableCopy(disableCopy),
_disableInactiveMessages(disableInactiveMessages),
+ _userCanNotWriteRelative(userCanNotWriteRelative),
_callDuration(callDuration)
{
_userExtraInfo = userExtraInfo;
@@ -270,6 +272,8 @@ public:
bool _disableCopy;
/// If WOPI host has allowed the loleaflet to show texts on the overlay informing about inactivity, or if the integration is handling that.
bool _disableInactiveMessages;
+ /// If set to false, users can access the save-as functionality
+ bool _userCanNotWriteRelative;
/// Time it took to call WOPI's CheckFileInfo
std::chrono::duration<double> _callDuration;
};
commit b5c6a84d383a1f596d8b8bec63577ca3bde163a6
Author: Aditya Dewan <iit2015097 at iiita.ac.in>
Date: Thu Aug 10 04:32:03 2017 +0530
'Save As' feature in the UI
(partially cherry picked from commit c3711a4375ec15a25b47cd62c8137f57145dbef5)
Change-Id: Ic4c80f4c4b54944143682c25a5878c1336787b27
Reviewed-on: https://gerrit.libreoffice.org/40946
Reviewed-by: pranavk <pranavk at collabora.co.uk>
Tested-by: pranavk <pranavk at collabora.co.uk>
diff --git a/loleaflet/reference.html b/loleaflet/reference.html
index ddb9a47a..f87fa773 100644
--- a/loleaflet/reference.html
+++ b/loleaflet/reference.html
@@ -2849,7 +2849,6 @@ Editor to WOPI host
export of the document.
</td>
</tr>
-
</table>
<h3 id="loleaflet-postmessage-sessions">Session Management</h3>
@@ -2914,6 +2913,18 @@ WOPI host to editor
</td>
</tr>
<tr>
+ <td><code><b>Action_SaveAs</b></code></td>
+ <td><code>
+ <nobr>Name: <String></nobr>
+ <nobr>Path: <String></nobr>
+ </code></td>
+ <td>Creates copy of the document with given Name.<br/>
+ <code>Name</code> is the requested name for the new file.<br/>
+ <code>Path</code> is the relative path in the WOPI host file system where the
+ user wants the new file to be saved.<br/>
+ </td>
+ </tr>
+ <tr>
<td><code><b>Action_Print</b></code></td>
<td><code>
</code></td>
@@ -3036,6 +3047,15 @@ Editor to WOPI host
via <code>Insert_Button</code> API above is clicked.
</td>
</tr>
+ <tr>
+ <td><code><b>UI_SaveAs</b></code></td>
+ <td></td>
+ <td>
+ Requests WOPI host to create appropriate UI, so that the user can choose
+ path and File name for creating a copy of the current file.
+ Response to this query is sent via <code>Action_SaveAs</code> message.
+ </td>
+ </tr>
</table>
<h2 id="marker">Marker</h2>
diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index 6c7afaac..1a9abc2e 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -16,6 +16,7 @@ L.Control.Menubar = L.Control.extend({
text: [
{name: _('File'), id: 'file', type: 'menu', menu: [
{name: _('Save'), id: 'save', type: 'action'},
+ {name: _('Save As'), id: 'saveas', type: 'action'},
{name: _('Print'), id: 'print', type: 'action'},
{name: _('See revision history'), id: 'rev-history', type: 'action'},
{name: _('Download as'), id: 'downloadas', type: 'menu', menu: [
@@ -491,6 +492,8 @@ L.Control.Menubar = L.Control.extend({
var id = $(item).data('id');
if (id === 'save') {
map.save(true, true);
+ } else if (id === 'saveas') {
+ map.fire('postMessage', {msgId: 'UI_SaveAs'});
} else if (id === 'print') {
map.print();
} else if (id.startsWith('downloadas-')) {
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 5e6b3819..e3c549b8 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -458,6 +458,9 @@ L.Socket = L.Class.extend({
return;
}
+ else if (textMsg.startsWith('error:') && command.errorCmd === 'saveas') {
+ this._map.hideBusy();
+ }
else if (textMsg.startsWith('error:') && command.errorCmd === 'load') {
this.close();
@@ -555,6 +558,12 @@ L.Socket = L.Class.extend({
', last: ' + (command.rendercount - this._map._docLayer._debugRenderCount));
this._map._docLayer._debugRenderCount = command.rendercount;
}
+ else if (textMsg.startsWith('saveas:')) {
+ textMsg = (textMsg.substring(7)).trim();
+ // var url = textMsg.substring(0, textMsg.indexOf(' '));
+ // var fileName = textMsg.substring(textMsg.indexOf(' '));
+ /// redirect or not?
+ }
else if (textMsg.startsWith('statusindicator:')) {
//FIXME: We should get statusindicator when saving too, no?
this._map.showBusy(_('Connecting...'), false);
diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js
index acc999b8..a7bbcb8c 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -208,11 +208,21 @@ L.Map.WOPI = L.Handler.extend({
this._postMessage({msgId: 'Get_Export_Formats_Resp', args: exportFormatsResp});
}
+ else if (msg.MessageId === 'Action_SaveAs') {
+ /* TODO
+ if (msg.Values) {
+ if (msg.Values.name === null || msg.Values.name === undefined) {
+ msg.Values.name = '';
+ }
+ this.showBusy(_('Creating copy...'), false);
+ map.saveAs(msg.Values.name, msg.Values.path);
+ }
+ */
+ }
},
_postMessage: function(e) {
if (!this.enabled) { return; }
-
var msgId = e.msgId;
var values = e.args || {};
if (!!this.PostMessageOrigin && window.parent !== window.self) {
@@ -229,7 +239,6 @@ L.Map.WOPI = L.Handler.extend({
'SendTime': Date.now(),
'Values': values
};
-
window.parent.postMessage(JSON.stringify(msg), this.PostMessageOrigin);
}
}
More information about the Libreoffice-commits
mailing list