diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2017-04-26 10:33:45 +0530 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2017-04-26 15:44:50 +0200 |
commit | ffdf137a94b79fc4638ef4496d44e6c79a1aabf1 (patch) | |
tree | 9c00352b09500a605f36788b949c4d9086d8c25a | |
parent | 25bb03c3a640cf95a4914ba6fbd6a676bcc76034 (diff) |
loleaflet: Warn here when unexpected data arrives
Hitting save, while there are redlines in the document, makes lo core send
redline information with empty textRange string. Further changes to the
document however brings in correct textRange rectangles back from the
core. Though ideally, it should be investigated why core is not able to
send correct redline text rectangles or why sending these redlines at
all while saving the document (not necessary unless some
attribute in redline changed), but no harm in having an additional check
here to filter unexpected messages received from server.
Change-Id: Ib709422e91cee6f141e4fea8ac923e88d7f65f50
(cherry picked from commit 91f824ae216bea0303798fe6d77977cd81d40979)
Reviewed-on: https://gerrit.libreoffice.org/36970
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r-- | loleaflet/src/layer/AnnotationManager.js | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/loleaflet/src/layer/AnnotationManager.js b/loleaflet/src/layer/AnnotationManager.js index 4b7143193..19dbb5bb6 100644 --- a/loleaflet/src/layer/AnnotationManager.js +++ b/loleaflet/src/layer/AnnotationManager.js @@ -70,6 +70,12 @@ L.AnnotationManager = L.Class.extend({ }, adjustRedLine: function(redline) { + // All sane values ? + if (!redline.textRange) { + console.warn('Redline received has invalid textRange'); + return false; + } + var rectangles, color, viewId; // transform change tracking index into an id redline.id = 'change-' + redline.index; @@ -90,6 +96,8 @@ L.AnnotationManager = L.Class.extend({ this.selectById(redline.id); }, this); } + + return true; }, // Fill normal comments in the documents @@ -112,7 +120,10 @@ L.AnnotationManager = L.Class.extend({ this.clearChanges(); for (var idx in redlines) { changecomment = redlines[idx]; - this.adjustRedLine(changecomment); + if (!this.adjustRedLine(changecomment)) { + // something wrong in this redline, skip this one + continue; + } this._items.push(L.annotation(this._map.options.maxBounds.getSouthEast(), changecomment).addTo(this._map)); } if (this._items.length > 0) { @@ -471,7 +482,10 @@ L.AnnotationManager = L.Class.extend({ var action = changetrack ? obj.redline.action : obj.comment.action; if (action === 'Add') { if (changetrack) { - this.adjustRedLine(obj.redline); + if (!this.adjustRedLine(obj.redline)) { + // something wrong in this redline + return; + } this.add(obj.redline); } else { this.adjustComment(obj.comment); @@ -502,7 +516,10 @@ L.AnnotationManager = L.Class.extend({ if (modified) { var modifiedObj; if (changetrack) { - this.adjustRedLine(obj.redline); + if (!this.adjustRedLine(obj.redline)) { + // something wrong in this redline + return; + } modifiedObj = obj.redline; } else { this.adjustComment(obj.comment); |