summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2016-11-10 18:15:22 +0530
committerPranav Kant <pranavk@collabora.co.uk>2016-11-10 22:03:17 +0530
commit5219baaab0691fa6d727d966d0376b75061331f6 (patch)
tree6d83e938662694229f8878c6cd9f55d2b209b171
parent9bfd5a512ed64fc705de118422a1319fa438cfb0 (diff)
tdf#103641: WOPI: Implement Action_Save, Action_Print, Action_Export
WOPI hosts can now send above mentioned messages to loleaflet so that loleaflet does stuff accordingly. Change-Id: I50e10a62c5b629bd12f7d9ce51bcd13cb13cdd8a
-rw-r--r--loleaflet/reference.html63
-rw-r--r--loleaflet/src/map/handler/Map.WOPI.js18
2 files changed, 80 insertions, 1 deletions
diff --git a/loleaflet/reference.html b/loleaflet/reference.html
index a07378f91..11ccb80d5 100644
--- a/loleaflet/reference.html
+++ b/loleaflet/reference.html
@@ -71,6 +71,7 @@
<ul>
<li><a href="#loleaflet-postmessage-initialization">Initialization</a></li>
<li><a href="#loleaflet-postmessage-sessions">Session Management</a></li>
+ <li><a href="#loleaflet-postmessage-actions">Actions</a></li>
</ul>
<h4>UI Layers</h4>
<ul>
@@ -2754,7 +2755,7 @@ The <code>id</code> property of ErrorEvent can have the following values:
SendTime is the timestamp returned by browsers' Date.now()
<h3 id="loleaflet-postmessage-initialization">Initialization</h3>
-
+Editor to WOPI host
<table data-id='postmessage-initialization'>
<tr>
<th>MessageId</th>
@@ -2774,7 +2775,24 @@ SendTime is the timestamp returned by browsers' Date.now()
</table>
<h3 id="loleaflet-postmessage-sessions">Session Management</h3>
+WOPI Host to Editor
+<table data-id='postmessage-sessions'>
+ <tr>
+ <th>MessageId</th>
+ <th>Values</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td><code><b>Get_Views</b></code></td>
+ <td><code>
+ </code></td>
+ <td>
+ Queries the editor for currently active views of the document. Response is returned in form of <code>Get_Views_Resp</code>
+ </td>
+ </tr>
+</table>
+Editor to WOPI Host
<table data-id='postmessage-sessions'>
<tr>
<th>MessageId</th>
@@ -2816,6 +2834,49 @@ SendTime is the timestamp returned by browsers' Date.now()
</tr>
</table>
+<h3 id="loleaflet-postmessage-actions">Actions</h3>
+WOPI host to editor
+<table data-id='postmessage-actions'>
+ <tr>
+ <th>MessageId</th>
+ <th>Values</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td><code><b>Action_Save</b></code></td>
+ <td><code>
+ <nobr>DontTerminateEdit: &lt;boolean&gt;</nobr>
+ <nobr>DontSaveIfUnmodified: &lt;boolean&gt;</nobr>
+ </code></td>
+ <td>Saves the document. DontTerminateEdit is relevant for spreadsheets where saving
+ a document can terminate the edit mode (text cursor dissappearing). Setting this to
+ true won't terminate the edit mode and can be used to save document without disrupting
+ user's editing session in spreadsheets.
+ DontSaveIfUnmodified prevents loolwsd to save the file back to storage if document is
+ unmodified (only cursor position changed etc.) but still saved. This can be helpful
+ to prevent creating unnecessary file revisions.
+ </td>
+ </tr>
+ <tr>
+ <td><code><b>Action_Print</b></code></td>
+ <td><code>
+ </code></td>
+ <td>
+ Prints the document.
+ </td>
+ </tr>
+ <tr>
+ <td><code><b>Action_Export</b></code></td>
+ <td><code>
+ <nobr>Format: &lt;String&gt;</nobr>
+ </code></td>
+ <td>
+ Downloads the document in format specified by <code>Format</code>.
+ </td>
+ </tr>
+</table>
+
+
<h2 id="marker">Marker</h2>
<p>Used to put markers on the map. Extends <a href="#layer">Layer</a>.</p>
diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js
index a8f061e1b..f144509e5 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -2,6 +2,7 @@
* L.WOPI contains WOPI related logic
*/
+/* global title */
L.Map.WOPI = L.Handler.extend({
PostMessageOrigin: false,
@@ -46,6 +47,23 @@ L.Map.WOPI = L.Handler.extend({
else if (msg.MessageId === 'Close_Session') {
this._map._socket.sendMessage('closedocument');
}
+ else if (msg.MessageId === 'Action_Save') {
+ var dontTerminateEdit = e.Values && e.Values['DontTerminateEdit'];
+ var dontSaveIfUnmodified = e.Values && e.Values['DontSaveIfUnmodified'];
+
+ this._map.save(dontTerminateEdit, dontSaveIfUnmodified);
+ }
+ else if (msg.MessageId === 'Action_Print') {
+ this._map.print();
+ }
+ else if (msg.MessageId === 'Action_Export') {
+ if (msg.Values) {
+ var format = msg.Values.Format;
+ var filename = title.substr(0, title.lastIndexOf('.')) || title;
+ filename = filename === '' ? 'document' : filename;
+ this._map.downloadAs(filename + '.' + format, format);
+ }
+ }
},
_postMessage: function(e) {