[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - loleaflet/src

Pranav Kant pranavk at collabora.co.uk
Wed Apr 26 13:45:09 UTC 2017


 loleaflet/src/layer/AnnotationManager.js |   23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

New commits:
commit ffdf137a94b79fc4638ef4496d44e6c79a1aabf1
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Apr 26 10:33:45 2017 +0530

    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 at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/src/layer/AnnotationManager.js b/loleaflet/src/layer/AnnotationManager.js
index 4b714319..19dbb5bb 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);


More information about the Libreoffice-commits mailing list