[Libreoffice-commits] online.git: 2 commits - loleaflet/src
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jun 29 18:34:55 UTC 2020
loleaflet/src/layer/marker/Annotation.js | 45 +++++++++++++++++++++++++------
1 file changed, 37 insertions(+), 8 deletions(-)
New commits:
commit 9db14f70a25b565ea1482ac5509e5842c2cbab91
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Jun 29 14:38:16 2020 +0200
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Jun 29 20:34:46 2020 +0200
Prevent crash when the annotation doesn't have the rectangle data
Change-Id: I04bc18f976bd7b2541418dda38b4c7809754dd4f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97411
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/loleaflet/src/layer/marker/Annotation.js b/loleaflet/src/layer/marker/Annotation.js
index 8d80aec57..35d7565bc 100644
--- a/loleaflet/src/layer/marker/Annotation.js
+++ b/loleaflet/src/layer/marker/Annotation.js
@@ -465,15 +465,17 @@ L.Annotation = L.Layer.extend({
});
this._map.addLayer(this._annotationMarker);
}
- var stringTwips = this._data.rectangle.match(/\d+/g);
- var topLeftTwips = new L.Point(parseInt(stringTwips[0]), parseInt(stringTwips[1]));
- var offset = new L.Point(parseInt(stringTwips[2]), parseInt(stringTwips[3]));
- var bottomRightTwips = topLeftTwips.add(offset);
- var bounds = new L.LatLngBounds(
- this._map._docLayer._twipsToLatLng(topLeftTwips, this._map.getZoom()),
- this._map._docLayer._twipsToLatLng(bottomRightTwips, this._map.getZoom()));
- this._annotationMarker.setLatLng(bounds.getSouthWest());
- this._annotationMarker.on('dragstart drag dragend', this._onMarkerDrag, this);
+ if (this._data.rectangle != null) {
+ var stringTwips = this._data.rectangle.match(/\d+/g);
+ var topLeftTwips = new L.Point(parseInt(stringTwips[0]), parseInt(stringTwips[1]));
+ var offset = new L.Point(parseInt(stringTwips[2]), parseInt(stringTwips[3]));
+ var bottomRightTwips = topLeftTwips.add(offset);
+ var bounds = new L.LatLngBounds(
+ this._map._docLayer._twipsToLatLng(topLeftTwips, this._map.getZoom()),
+ this._map._docLayer._twipsToLatLng(bottomRightTwips, this._map.getZoom()));
+ this._annotationMarker.setLatLng(bounds.getSouthWest());
+ this._annotationMarker.on('dragstart drag dragend', this._onMarkerDrag, this);
+ }
},
_onMarkerDrag: function(event) {
if (this._annotationMarker == null)
commit 8b133a76d3e6dd1cdd577328bdf3f377c9ed08ee
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Jun 29 14:30:32 2020 +0200
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Jun 29 20:34:36 2020 +0200
Send the new position of the annotation when the marker is moved
Change-Id: I5a81feb8308808e9221ed7f7f29ea7758d91c309
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97410
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/loleaflet/src/layer/marker/Annotation.js b/loleaflet/src/layer/marker/Annotation.js
index 730396ab9..8d80aec57 100644
--- a/loleaflet/src/layer/marker/Annotation.js
+++ b/loleaflet/src/layer/marker/Annotation.js
@@ -473,6 +473,33 @@ L.Annotation = L.Layer.extend({
this._map._docLayer._twipsToLatLng(topLeftTwips, this._map.getZoom()),
this._map._docLayer._twipsToLatLng(bottomRightTwips, this._map.getZoom()));
this._annotationMarker.setLatLng(bounds.getSouthWest());
+ this._annotationMarker.on('dragstart drag dragend', this._onMarkerDrag, this);
+ },
+ _onMarkerDrag: function(event) {
+ if (this._annotationMarker == null)
+ return;
+ if (event.type === 'dragend') {
+ var rect = this._annotationMarker._icon.getBoundingClientRect();
+ var pointTwip = this._map._docLayer._pixelsToTwips({x: rect.left, y: rect.top});
+ this._sendAnnotationPositionChange(pointTwip);
+ }
+ },
+ _sendAnnotationPositionChange: function(newPosition) {
+ var comment = {
+ Id: {
+ type: 'string',
+ value: this._data.id
+ },
+ PositionX: {
+ type: 'int32',
+ value: newPosition.x
+ },
+ PositionY: {
+ type: 'int32',
+ value: newPosition.y
+ }
+ };
+ this._map.sendUnoCommand('.uno:EditAnnotation', comment);
}
});
More information about the Libreoffice-commits
mailing list