From 9db14f70a25b565ea1482ac5509e5842c2cbab91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=C5=BE=20Vajngerl?= Date: Mon, 29 Jun 2020 14:38:16 +0200 Subject: [PATCH] Prevent crash when the annotation doesn't have the rectangle data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I04bc18f976bd7b2541418dda38b4c7809754dd4f Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97411 Tested-by: Jenkins Tested-by: Jenkins CollaboraOffice Reviewed-by: Tomaž Vajngerl --- loleaflet/src/layer/marker/Annotation.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) 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)