loleaflet/src/layer/AnnotationManager.js |   25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

New commits:
commit 015f2974a53e8fcdeaa400a345e7e68ed0072f9f
Author: Henry Castro <hcas...@collabora.com>
Date:   Tue May 30 15:59:00 2017 -0400

    loleaflet: merge comments and redlines items
    
    Comments and Redlines were mutually exclusive, but a document
    can contain both.
    
    Change-Id: Idb13f0c0e1216edc6bed3291c0c486b45ad74b56
    Reviewed-on: https://gerrit.libreoffice.org/38235
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>
    Tested-by: Jan Holesovsky <ke...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/46448

diff --git a/loleaflet/src/layer/AnnotationManager.js 
b/loleaflet/src/layer/AnnotationManager.js
index 7b1cdf4e..c3e9b9a2 100644
--- a/loleaflet/src/layer/AnnotationManager.js
+++ b/loleaflet/src/layer/AnnotationManager.js
@@ -27,21 +27,28 @@ L.AnnotationManager = L.Class.extend({
 
        // Remove only text comments from the document (excluding change 
tracking comments)
        clear: function () {
-               for (var key in this._items) {
-                       if (!this._items[key].trackchange) {
-                               this._map.removeLayer(this._items[key]);
+               var it = 0;
+               while (it < this._items.length) {
+                       if (!this._items[it].trackchange) {
+                               this._map.removeLayer(this._items[it]);
+                               this._items.splice(it, 1);
+                       } else {
+                               it++;
                        }
                }
-               this._items = [];
                this._selected = null;
                this._map.removeLayer(this._arrow);
        },
 
        // Remove only change tracking comments from the document
        clearChanges: function() {
-               for (var key in this._items) {
-                       if (this._items[key].trackchange) {
-                               this._map.removeLayer(this._items[key]);
+               var it = 0;
+               while (it < this._items.length) {
+                       if (this._items[it].trackchange) {
+                               this._map.removeLayer(this._items[it]);
+                               this._items.splice(it, 1);
+                       } else {
+                               it++;
                        }
                }
        },
@@ -121,7 +128,7 @@ L.AnnotationManager = L.Class.extend({
                var comment;
                this.clear();
                // items contains redlines
-               var ordered = !this._items.length > 0;
+               var ordered = !this._items.length;
                for (var index in comments) {
                        comment = comments[index];
                        this.adjustComment(comment);
@@ -145,7 +152,7 @@ L.AnnotationManager = L.Class.extend({
                var changecomment;
                this.clearChanges();
                // items contains comments
-               var ordered = !this._items.length > 0;
+               var ordered = !this._items.length;
                for (var idx in redlines) {
                        changecomment = redlines[idx];
                        if (!this.adjustRedLine(changecomment)) {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to