From 0b77d1b1761f4bb64862ed38b2b8d6f152e9beaa Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 18 Jan 2018 18:54:20 +0200 Subject: [PATCH] Add handling of the SetCellColor proof-of-concept postMessage event When we receive such a message, we forward it to the corresponding Python script (from core's scripting/examples/python/SetCellColor.py). We also save the event's source so that we can send the return value of the script back to its window. [Later addition, when pushing upstream: This commit will be reverted at least partially by later commits. I didn't bother with squashing them all into one. So sue me. Also, it might be of interest to see in the commit log how my ideas for how to implement this stuff evolved.] Change-Id: I1f54a90000937d6c9b91fb15cdfde329223cf8db --- loleaflet/src/layer/tile/TileLayer.js | 9 +++++++++ loleaflet/src/map/handler/Map.WOPI.js | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index d6df423db..f9b73d8ca 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -1083,6 +1083,7 @@ L.TileLayer = L.GridLayer.extend({ }, _onUnoCommandResultMsg: function (textMsg) { + // console.log('_onUnoCommandResultMsg: "' + textMsg + '"'); textMsg = textMsg.substring(18); var obj = JSON.parse(textMsg); var commandName = obj.commandName; @@ -1096,6 +1097,14 @@ L.TileLayer = L.GridLayer.extend({ this._map.hideBusy(); this._map.fire('commandresult', {commandName: commandName, success: success, result: obj.result}); + if (this._map.SetCellColorSource != null) { + this._map.SetCellColorSource.postMessage(JSON.stringify({'MessageId': 'SetCellColor-Result', + 'SendTime': Date.now(), + 'Values': obj + }), + '*'); + this._map.SetCellColorSource = null; + } }, _onRulerUpdate: function (textMsg) { diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js index 6b4395f89..a68c41a7a 100644 --- a/loleaflet/src/map/handler/Map.WOPI.js +++ b/loleaflet/src/map/handler/Map.WOPI.js @@ -18,6 +18,7 @@ L.Map.WOPI = L.Handler.extend({ DisableCopy: false, DisableInactiveMessages: false, UserCanNotWriteRelative: true, + SetCellColorSource: null, _appLoadedConditions: { docloaded: false, @@ -244,6 +245,10 @@ L.Map.WOPI = L.Handler.extend({ this._map._socket.sendMessage('versionrestore prerestore'); } } + else if (msg.MessageId === 'SetCellColor') { + this._map.SetCellColorSource = e.source; + this._map.sendUnoCommand('vnd.sun.star.script:SetCellColor.py$SetCellColor?language=Python&location=share', msg.Values); + } }, _postMessage: function(e) {