[Libreoffice-commits] online.git: loleaflet/src

Dennis Francis (via logerrit) logerrit at kemper.freedesktop.org
Mon Jul 6 17:03:08 UTC 2020


 loleaflet/src/layer/tile/CalcTileLayer.js |   33 ++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

New commits:
commit 4a5df02d648d96c4fb54e7bcc0e3ee56c8f74447
Author:     Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Sat Jun 6 19:41:42 2020 +0530
Commit:     Dennis Francis <dennis.francis at collabora.com>
CommitDate: Mon Jul 6 19:02:49 2020 +0200

    handle text selection messages in print-twips properly
    
    Change-Id: Ieedfb48be9e8e5806e9e3e1c0d11ac5704985934
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98155
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Tested-by: Jenkins
    Reviewed-by: Dennis Francis <dennis.francis at collabora.com>

diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js
index 3b9548106..e87ecbb3e 100644
--- a/loleaflet/src/layer/tile/CalcTileLayer.js
+++ b/loleaflet/src/layer/tile/CalcTileLayer.js
@@ -796,6 +796,39 @@ L.CalcTileLayer = L.TileLayer.extend({
 		var refpoint = L.Point.parse(msgObj.refpoint);
 		refpoint = this.sheetGeometry.getTileTwipsPointFromPrint(refpoint);
 		return relrect.add(refpoint);
+	},
+
+	_getTextSelectionRectangles: function (textMsg) {
+
+		if (!this.options.printTwipsMsgsEnabled) {
+			return L.TileLayer.prototype._getTextSelectionRectangles.call(this, textMsg);
+		}
+
+		if (typeof textMsg !== 'string') {
+			console.error('invalid text selection message');
+			return [];
+		}
+
+		var refpointDelim = '::';
+		var delimIndex = textMsg.indexOf(refpointDelim);
+		if (delimIndex === -1) {
+			// No refpoint information available, treat it as cell-range selection rectangle.
+			var rangeRectArray = L.Bounds.parseArray(textMsg);
+			rangeRectArray = rangeRectArray.map(function (rect) {
+				return this._convertToTileTwipsSheetArea(rect);
+			}, this);
+			return rangeRectArray;
+		}
+
+		var refpoint = L.Point.parse(textMsg.substring(delimIndex + refpointDelim.length));
+		refpoint = this.sheetGeometry.getTileTwipsPointFromPrint(refpoint);
+
+		var rectArray = L.Bounds.parseArray(textMsg.substring(0, delimIndex));
+		rectArray.forEach(function (rect) {
+			rect._add(refpoint); // compute absolute coordinates and update in-place.
+		});
+
+		return rectArray;
 	}
 });
 


More information about the Libreoffice-commits mailing list