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
This commit is contained in:
parent
f7f07f50bb
commit
0b77d1b176
2 changed files with 14 additions and 0 deletions
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue