[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-1-9' - 3 commits - loleaflet/dist loleaflet/reference.html loleaflet/src

Pranav Kant pranavk at collabora.co.uk
Tue Nov 15 13:51:27 UTC 2016


 loleaflet/dist/toolbar/toolbar.js     |   25 +++++++------
 loleaflet/reference.html              |   17 ++++++---
 loleaflet/src/core/Socket.js          |   16 ++------
 loleaflet/src/layer/tile/TileLayer.js |    1 
 loleaflet/src/map/handler/Map.WOPI.js |   61 ++++++++++++++++++++++++++++++++++
 5 files changed, 91 insertions(+), 29 deletions(-)

New commits:
commit 7723b99534c183847f273206cd251cf260f0749d
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Nov 15 18:16:08 2016 +0530

    tdf#103641: Hide redundant break after save too
    
    ... if save button is hidden. This is not the case in master
    as we have additional element, Textwrap, there.

diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index 3938375..0d39374 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -323,7 +323,7 @@ $(function () {
 		items: [
 			{type: 'html', id: 'left'},
 			{type: 'button',  id: 'save', img: 'save', hint: _('Save'), uno: 'Save'},
-			{type: 'break'},
+			{type: 'break', id: 'savebreak'},
 			{type: 'button',  id: 'undo',  img: 'undo', hint: _('Undo'), uno: 'Undo'},
 			{type: 'button',  id: 'redo',  img: 'redo', hint: _('Redo'), uno: 'Redo'},
 			{type: 'button',  id: 'repair', img: 'repair', hint: _('Document repair')},
@@ -713,6 +713,7 @@ function onFormulaBarBlur() {
 map.on('wopiprops', function(e) {
 	if (e.HideSaveOption) {
 		w2ui['toolbar-up'].hide('save');
+		w2ui['toolbar-up'].hide('savebreak');
 	}
 });
 
commit e29e5fb8ad5c1ceba2496802542b11e62316b0d6
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Nov 15 13:58:25 2016 +0530

    tdf#103641: Fix save button visible for presentation
    
    Additionally, change the variable name for presentation-toolbar
    to avoid any future confusion.
    
    Also, put the code hiding the save button in onRefresh event so that
    save button doesn't show up in the UI as soon as we get the wopi
    properties object from the server.
    
    Change-Id: Ib168010c509f55a69aae9752e11321d319f59e99

diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index 970537f..3938375 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -710,6 +710,12 @@ function onFormulaBarBlur() {
 	}, 250);
 }
 
+map.on('wopiprops', function(e) {
+	if (e.HideSaveOption) {
+		w2ui['toolbar-up'].hide('save');
+	}
+});
+
 map.on('doclayerinit', function () {
 	var toolbar = w2ui['toolbar-up'];
 	var docType = map.getDocType();
@@ -717,12 +723,12 @@ map.on('doclayerinit', function () {
 		if (docType === 'presentation') {
 			toolbar.hide('annotation');
 
-			toolbar = w2ui['presentation-toolbar'];
-			toolbar.show('presentation');
-			toolbar.show('presentationbreak');
-			toolbar.show('insertpage');
-			toolbar.show('duplicatepage');
-			toolbar.show('deletepage');
+			var presentationToolbar = w2ui['presentation-toolbar'];
+			presentationToolbar.show('presentation');
+			presentationToolbar.show('presentationbreak');
+			presentationToolbar.show('insertpage');
+			presentationToolbar.show('duplicatepage');
+			presentationToolbar.show('deletepage');
 		}
 		else if (docType === 'drawing') {
 			toolbar.hide('annotation');
@@ -735,10 +741,6 @@ map.on('doclayerinit', function () {
 		}
 	}
 
-	if (map['wopi'].HideSaveOption) {
-		toolbar.hide('save');
-	}
-
 	var statusbar = w2ui['toolbar-down'];
 	switch (docType) {
 	case 'spreadsheet':
commit b3b707529b54b83c28a03d593fb2de65fadecaf6
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Nov 15 13:48:18 2016 +0530

    tdf#103641: Split App_LoadedStatus - Frame_Ready, Document_Loaded
    
    Post App_LoadingStatus with 'Status' field as Frame_Ready when
    we are ready to show the UI.
    
    Post Document_Loaded when document is completely loaded after
    which loleaflet is ready to respond to more document specific
    queries through post message API.
    
    Change-Id: I60a4e9b75e115c748fcee8d449bc8c2d4ffa34a9
    (cherry picked from commit d8a202bf1cc2a4cc343833348f08dcfdadbdd409)

diff --git a/loleaflet/reference.html b/loleaflet/reference.html
index 529728a..e8bb801 100644
--- a/loleaflet/reference.html
+++ b/loleaflet/reference.html
@@ -2769,12 +2769,17 @@ Editor to WOPI host
 	<tr>
 		<td><code><b>App_LoadingStatus</b></code></td>
 		<td><code>
-		    <nobr>DocumentLoadedTime: <Number></nobr>
-		</code></td>
-		<td>When loleaflet frame is completely ready. Host can start
-		sending other messages using post message API.
-		DocumentLoadedTime is timestamp when frame is
-		ready/loaded.</td>
+		    <nobr>Status: <String></nobr>
+		    <nobr>DocumentLoadedTime: <Timestamp></nobr>
+		</code></td>
+		<td>If Status is Frame_Ready, loleaflet frame is loaded and UI
+		can be shown. <br/>
+		When Status is Document_Loaded, document has been completely
+		loaded and host can also start sending document-specific query
+		messages using post message API such as Get_Views,
+		Get_Export_Formats etc. DocumentLoadedTime is specified
+		only in this case.
+		</td>
 	</tr>
 </table>
 WOPI host to editor
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index d504ba6..e8b342b 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -180,18 +180,7 @@ L.Socket = L.Class.extend({
 		else if (textMsg.startsWith('wopi: ')) {
 			// Handle WOPI related messages
 			var wopiInfo = JSON.parse(textMsg.substring(textMsg.indexOf('{')));
-			// Store postmessageorigin property in our WOPI handler, if it exists
-			if (this._map['wopi'] && !!wopiInfo['PostMessageOrigin']) {
-				this._map['wopi'].PostMessageOrigin = wopiInfo['PostMessageOrigin'];
-				this._map['wopi'].DocumentLoadedTime = Date.now();
-				// Tell the host that we are ready now
-				this._map.fire('postMessage', {msgId: 'App_LoadingStatus', args: {'DocumentLoadedTime': this._map['wopi'].DocumentLoadedTime}});
-			}
-
-			this._map['wopi'].HidePrintOption = !!wopiInfo['HidePrintOption'];
-			this._map['wopi'].HideSaveOption = !!wopiInfo['HideSaveOption'];
-			this._map['wopi'].HideExportOption = !!wopiInfo['HideExportOption'];
-
+			this._map.fire('wopiprops', wopiInfo);
 			return;
 		}
 		else if (textMsg.startsWith('close: ')) {
@@ -412,6 +401,9 @@ L.Socket = L.Class.extend({
 		}
 
 		this._map.fire('error', {msg: _('Well, this is embarrassing, we cannot connect to your document. Please try again.'), cmd: 'socket', kind: 'closed', id: 4});
+
+		// Reset wopi's app loaded so that reconnecting again informs outerframe about initialization again
+		this._map['wopi'].resetAppLoaded();
 	},
 
 	parseServerCmd: function (msg) {
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index c167b28..1a3849e 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -804,6 +804,7 @@ L.TileLayer = L.GridLayer.extend({
 	_onViewInfoMsg: function(textMsg) {
 		textMsg = textMsg.substring('viewinfo: '.length);
 		var viewInfo = JSON.parse(textMsg);
+		this._map.fire('viewinfo', viewInfo);
 
 		// A new view
 		var viewIds = [];
diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js
index 1281baf..9019079 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -11,20 +11,81 @@ L.Map.WOPI = L.Handler.extend({
 	HideSaveOption: false,
 	HideExportOption: false,
 
+	_appLoadedConditions: {
+		doclayerinit: false,
+		updatepermission: false,
+		viewinfo: false /* Whether view information has already arrived */
+	},
+
+	_appLoaded: false,
+
 	initialize: function(map) {
 		this._map = map;
 	},
 
 	addHooks: function() {
 		this._map.on('postMessage', this._postMessage, this);
+
+		// init messages
+		this._map.on('doclayerinit', this._postLoaded, this);
+		this._map.on('updatepermission', this._postLoaded, this);
+		// This indicates that 'viewinfo' message has already arrived
+		this._map.on('viewinfo', this._postLoaded, this);
+
+		this._map.on('wopiprops', this._setWopiProps, this);
 		L.DomEvent.on(window, 'message', this._postMessageListener, this);
 	},
 
 	removeHooks: function() {
 		this._map.off('postMessage', this._postMessage, this);
+
+		// init messages
+		this._map.off('doclayerinit', this._postLoaded, this);
+		this._map.off('updatepermission', this._postLoaded, this);
+		this._map.off('viewinfo', this._postLoaded, this);
+
+		this._map.off('wopiprops', this._setWopiProps, this);
 		L.DomEvent.off(window, 'message', this._postMessageListener, this);
 	},
 
+	_setWopiProps: function(wopiInfo) {
+		// Store postmessageorigin property, if it exists
+		if (!!wopiInfo['PostMessageOrigin']) {
+			this.PostMessageOrigin = wopiInfo['PostMessageOrigin'];
+		}
+
+		this.HidePrintOption = !!wopiInfo['HidePrintOption'];
+		this.HideSaveOption = !!wopiInfo['HideSaveOption'];
+		this.HideExportOption = !!wopiInfo['HideExportOption'];
+
+		this._map.fire('postMessage', {msgId: 'App_LoadingStatus', args: {Status: 'Frame_Ready'}});
+	},
+
+	resetAppLoaded: function() {
+		this._appLoaded = false;
+		for (var key in this._appLoadedConditions) {
+			this._appLoadedConditions[key] = false;
+		}
+	},
+
+	_postLoaded: function(e) {
+		if (this._appLoaded) {
+			return;
+		}
+
+		if (e.type === 'doclayerinit') {
+			this.DocumentLoadedTime = Date.now();
+		}
+		this._appLoadedConditions[e.type] = true;
+		for (var key in this._appLoadedConditions) {
+			if (!this._appLoadedConditions[key])
+				return;
+		}
+
+		this._appLoaded = true;
+		this._map.fire('postMessage', {msgId: 'App_LoadingStatus', args: {Status: 'Document_Loaded', DocumentLoadedTime: this.DocumentLoadedTime}});
+	},
+
 	_postMessageListener: function(e) {
 		if (!window.WOPIPostmessageReady) {
 			return;


More information about the Libreoffice-commits mailing list