[Libreoffice-commits] online.git: loleaflet/src
Szymon Kłos (via logerrit)
logerrit at kemper.freedesktop.org
Wed Nov 27 09:57:15 UTC 2019
loleaflet/src/layer/tile/TileLayer.js | 21 +++++++++++++++++----
loleaflet/src/map/handler/Map.StateChanges.js | 11 +++++++++--
2 files changed, 26 insertions(+), 6 deletions(-)
New commits:
commit d13164a80c1b49e3f79732b720a9918d7a413052
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Fri Nov 22 13:28:49 2019 +0100
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed Nov 27 10:56:57 2019 +0100
jsdialogs: parse SfxPoolItems JSON
Change-Id: I15fc16dbc74977a848d6cfbeea3facdbac286c22
Reviewed-on: https://gerrit.libreoffice.org/83857
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
Tested-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 707a4d601..25cf5ba5a 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1444,10 +1444,23 @@ L.TileLayer = L.GridLayer.extend({
_onStateChangedMsg: function (textMsg) {
textMsg = textMsg.substr(14);
- var index = textMsg.indexOf('=');
- var commandName = index !== -1 ? textMsg.substr(0, index) : '';
- var state = index !== -1 ? textMsg.substr(index + 1) : '';
- this._map.fire('commandstatechanged', {commandName : commandName, state : state});
+
+ var isPureJSON = textMsg.indexOf('=') === -1 && textMsg.indexOf('{') !== -1;
+ if (isPureJSON) {
+ var json = JSON.parse(textMsg);
+
+ for (var i = 0; i < json.items.length; i++) {
+ var item = json.items[i];
+ if (item.which && item.data) {
+ this._map.fire('commandstatechanged', {commandName: item.which, state: item.data});
+ }
+ }
+ } else {
+ var index = textMsg.indexOf('=');
+ var commandName = index !== -1 ? textMsg.substr(0, index) : '';
+ var state = index !== -1 ? textMsg.substr(index + 1) : '';
+ this._map.fire('commandstatechanged', {commandName : commandName, state : state});
+ }
},
_onUnoCommandResultMsg: function (textMsg) {
diff --git a/loleaflet/src/map/handler/Map.StateChanges.js b/loleaflet/src/map/handler/Map.StateChanges.js
index 060a48cfe..6afcd642c 100644
--- a/loleaflet/src/map/handler/Map.StateChanges.js
+++ b/loleaflet/src/map/handler/Map.StateChanges.js
@@ -28,8 +28,15 @@ L.Map.StateChangeHandler = L.Handler.extend({
_onStateChanged: function(e) {
var slideMasterPageItem = this._map['stateChangeHandler'].getItemValue('.uno:SlideMasterPage');
- var index = e.state.indexOf('{');
- var state = index !== -1 ? JSON.parse(e.state.substring(index)) : e.state;
+ var state;
+
+ if (typeof(e.state == 'object')) {
+ state = e.state;
+ } else if (typeof(e.state == 'string')) {
+ var index = e.state.indexOf('{');
+ state = index !== -1 ? JSON.parse(e.state.substring(index)) : e.state;
+ }
+
this._items[e.commandName] = state;
if (e.commandName === '.uno:CurrentTrackedChangeId') {
var redlineId = 'change-' + state;
More information about the Libreoffice-commits
mailing list