loleaflet/src/layer/AnnotationManager.js |   25 ++++++++++++++++---------
 loleaflet/src/layer/marker/Annotation.js |    1 -
 2 files changed, 16 insertions(+), 10 deletions(-)

New commits:
commit fa491a8444e21352c6b95791e9c56ea7eb03bf24
Author: Pranav Kant <pran...@collabora.co.uk>
Date:   Wed Feb 22 18:18:01 2017 +0530

    loleaflet: Add annotation whenever we receive a callback
    
    Without this, only views that add the annotation were showing the
    comment box, not others.
    
    Change-Id: Iee092c803c02c71d51f9ca4df9f6169a4e073578

diff --git a/loleaflet/src/layer/AnnotationManager.js 
b/loleaflet/src/layer/AnnotationManager.js
index a76e9f0..7ea8079 100644
--- a/loleaflet/src/layer/AnnotationManager.js
+++ b/loleaflet/src/layer/AnnotationManager.js
@@ -202,6 +202,11 @@ L.AnnotationManager = L.Class.extend({
                                added._updateContent();
                                this.layout();
                        }
+                       else { // annotation is added by some other view
+                               this._map.insertComment(obj.comment);
+                               this.unselect();
+                               this._map.focus();
+                       }
 
                } else if (obj.comment.action === 'Remove') {
                        if (this.getItem(obj.comment.id)) {
@@ -248,8 +253,9 @@ L.AnnotationManager = L.Class.extend({
        },
 
        _onAnnotationSave: function (e) {
+               var comment;
                if (e.annotation._data.id === 'new') {
-                       var comment = {
+                       comment = {
                                Text: {
                                        type: 'string',
                                        value: e.annotation._data.text
@@ -261,7 +267,7 @@ L.AnnotationManager = L.Class.extend({
                        };
                        this._map.sendUnoCommand('.uno:InsertAnnotation', 
comment);
                } else {
-                       var comment = {
+                       comment = {
                                Id: {
                                        type: 'string',
                                        value: e.annotation._data.id
@@ -280,14 +286,15 @@ L.AnnotationManager = L.Class.extend({
 
 
 L.Map.include({
-       insertComment: function() {
+       insertComment: function(comment) {
+               comment = !!comment ? comment : {};
                this._docLayer._annotations.add({
-                       text: '',
-                       textrange: '',
-                       author: this.getViewName(this._docLayer._viewId),
-                       dateTime: new Date().toDateString(),
-                       id: 'new',
-                       anchorPos:  
this._docLayer._latLngToTwips(this._docLayer._visibleCursor.getNorthWest())
+                       text: comment.text ? comment.text : '',
+                       textrange: comment.textrange ? comment.textrange : '',
+                       author: comment.author ? comment.author : 
this.getViewName(this._docLayer._viewId),
+                       dateTime: comment.dateTime ? comment.dateTime : new 
Date().toDateString(),
+                       id: comment.id ? comment.id : 'new', // 'new' only when 
added by us
+                       anchorPos: comment.anchorPos ? comment.anchorPos : 
this._docLayer._latLngToTwips(this._docLayer._visibleCursor.getNorthWest())
                });
        }
 });
diff --git a/loleaflet/src/layer/marker/Annotation.js 
b/loleaflet/src/layer/marker/Annotation.js
index 9ff0942..6e97c9a 100644
--- a/loleaflet/src/layer/marker/Annotation.js
+++ b/loleaflet/src/layer/marker/Annotation.js
@@ -155,4 +155,3 @@ L.Annotation = L.Layer.extend({
 L.annotation = function (latlng, data, options) {
        return new L.Annotation(latlng, data, options);
 };
-
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to