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

Jan Holesovsky (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 17 19:34:29 UTC 2020


 loleaflet/src/layer/tile/CalcTileLayer.js   |   61 -------------------------
 loleaflet/src/layer/tile/CanvasTileLayer.js |   66 ++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 61 deletions(-)

New commits:
commit 3a93ada13f4030b20601ecd4a345b931bf670c0b
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Thu Sep 17 17:47:07 2020 +0200
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Sep 17 21:34:10 2020 +0200

    grid lines: Setup renderBackground only after _painter exists.
    
    This fixes setup of many cypress tests.
    
    Change-Id: I4eb626050d2d4202104ab01a6aa0b01248ae4eb5
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102965
    Tested-by: Jan Holesovsky <kendy at collabora.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js
index 54abd8731..439f0d8cd 100644
--- a/loleaflet/src/layer/tile/CalcTileLayer.js
+++ b/loleaflet/src/layer/tile/CalcTileLayer.js
@@ -739,67 +739,6 @@ L.CalcTileLayer = BaseTileLayer.extend({
 			converter: this._twipsToPixels,
 			context: this
 		});
-		var that = this;
-		this._painter.renderBackground = function(canvas, ctx)
-		{
-			if (this._layer._debug)
-				this._canvasCtx.fillStyle = 'rgba(255, 0, 0, 0.5)';
-			else
-				this._canvasCtx.fillStyle = 'white'; // FIXME: sheet bg color
-			this._canvasCtx.fillRect(0, 0, ctx.canvasSize.x, ctx.canvasSize.y);
-
-			if (that._debug)
-				canvas.strokeStyle = 'blue';
-			else // now fr some grid-lines ...
-				canvas.strokeStyle = '#c0c0c0';
-			canvas.lineWidth = 1.0;
-
-			canvas.beginPath();
-			for (var i = 0; i < ctx.paneBoundsList.length; ++i) {
-				// FIXME: de-duplicate before firing myself:
-
-				// co-ordinates of this pane in core document pixels
-				var paneBounds = that._cssBoundsToCore(ctx.paneBoundsList[i]);
-				// co-ordinates of the main-(bottom right) pane in core document pixels
-				var viewBounds = that._cssBoundsToCore(ctx.viewBounds);
-				// into real pixel-land ...
-				paneBounds.round();
-				viewBounds.round();
-
-				var paneOffset = paneBounds.getTopLeft(); // allocates
-				// Cute way to detect the in-canvas pixel offset of each pane
-				paneOffset.x = Math.min(paneOffset.x, viewBounds.min.x);
-				paneOffset.y = Math.min(paneOffset.y, viewBounds.min.y);
-
-				// when using the pinch to zoom, set additional translation based */
-				// on the pinch movement
-				if (that._map._animatingZoom) {
-					var centerOffset = this._map._getCenterOffset(this._map._animateToCenter);
-					paneOffset.x += Math.round(centerOffset.x);
-					paneOffset.y += Math.round(centerOffset.y);
-				}
-
-				// URGH -> zooming etc. (!?) ...
-				if (that.sheetGeometry._columns)
-					that.sheetGeometry._columns.forEachInCorePixelRange(
-						paneBounds.min.x, paneBounds.max.x,
-						function(pos) {
-							canvas.moveTo(pos - paneOffset.x - 0.5, paneBounds.min.y - paneOffset.y - 0.5);
-							canvas.lineTo(pos - paneOffset.x - 0.5, paneBounds.max.y - paneOffset.y - 0.5);
-							canvas.stroke();
-						});
-
-				if (that.sheetGeometry._rows)
-					that.sheetGeometry._rows.forEachInCorePixelRange(
-						paneBounds.min.y, paneBounds.max.y,
-						function(pos) {
-							canvas.moveTo(paneBounds.min.x - paneOffset.x - 0.5, pos - paneOffset.y - 0.5);
-							canvas.lineTo(paneBounds.max.x - paneOffset.x - 0.5, pos - paneOffset.y - 0.5);
-							canvas.stroke();
-						});
-			}
-			canvas.closePath();
-		};
 	},
 
 	_handleSheetGeometryDataMsg: function (jsonMsgObj) {
diff --git a/loleaflet/src/layer/tile/CanvasTileLayer.js b/loleaflet/src/layer/tile/CanvasTileLayer.js
index 3149ebb6c..4b0123ba2 100644
--- a/loleaflet/src/layer/tile/CanvasTileLayer.js
+++ b/loleaflet/src/layer/tile/CanvasTileLayer.js
@@ -376,6 +376,8 @@ L.CanvasTileLayer = L.TileLayer.extend({
 		this._map.on('resize zoomend', this._painter.update, this._painter);
 		this._map.on('splitposchanged', this._painter.update, this._painter);
 		this._map.on('move', this._syncTilePanePos, this);
+
+		this._map.on('viewrowcolumnheaders', this._updateRenderBackground, this);
 	},
 
 	_syncTilePanePos: function () {
@@ -386,6 +388,70 @@ L.CanvasTileLayer = L.TileLayer.extend({
 		}
 	},
 
+	_updateRenderBackground: function() {
+		var that = this;
+		this._painter.renderBackground = function(canvas, ctx)
+		{
+			if (this._layer._debug)
+				this._canvasCtx.fillStyle = 'rgba(255, 0, 0, 0.5)';
+			else
+				this._canvasCtx.fillStyle = 'white'; // FIXME: sheet bg color
+			this._canvasCtx.fillRect(0, 0, ctx.canvasSize.x, ctx.canvasSize.y);
+
+			if (that._debug)
+				canvas.strokeStyle = 'blue';
+			else // now fr some grid-lines ...
+				canvas.strokeStyle = '#c0c0c0';
+			canvas.lineWidth = 1.0;
+
+			canvas.beginPath();
+			for (var i = 0; i < ctx.paneBoundsList.length; ++i) {
+				// FIXME: de-duplicate before firing myself:
+
+				// co-ordinates of this pane in core document pixels
+				var paneBounds = that._cssBoundsToCore(ctx.paneBoundsList[i]);
+				// co-ordinates of the main-(bottom right) pane in core document pixels
+				var viewBounds = that._cssBoundsToCore(ctx.viewBounds);
+				// into real pixel-land ...
+				paneBounds.round();
+				viewBounds.round();
+
+				var paneOffset = paneBounds.getTopLeft(); // allocates
+				// Cute way to detect the in-canvas pixel offset of each pane
+				paneOffset.x = Math.min(paneOffset.x, viewBounds.min.x);
+				paneOffset.y = Math.min(paneOffset.y, viewBounds.min.y);
+
+				// when using the pinch to zoom, set additional translation based
+				// on the pinch movement
+				if (that._map._animatingZoom) {
+					var centerOffset = this._map._getCenterOffset(this._map._animateToCenter);
+					paneOffset.x += Math.round(centerOffset.x);
+					paneOffset.y += Math.round(centerOffset.y);
+				}
+
+				// URGH -> zooming etc. (!?) ...
+				if (that.sheetGeometry._columns)
+					that.sheetGeometry._columns.forEachInCorePixelRange(
+						paneBounds.min.x, paneBounds.max.x,
+						function(pos) {
+							canvas.moveTo(pos - paneOffset.x - 0.5, paneBounds.min.y - paneOffset.y - 0.5);
+							canvas.lineTo(pos - paneOffset.x - 0.5, paneBounds.max.y - paneOffset.y - 0.5);
+							canvas.stroke();
+						});
+
+				if (that.sheetGeometry._rows)
+					that.sheetGeometry._rows.forEachInCorePixelRange(
+						paneBounds.min.y, paneBounds.max.y,
+						function(pos) {
+							canvas.moveTo(paneBounds.min.x - paneOffset.x - 0.5, pos - paneOffset.y - 0.5);
+							canvas.lineTo(paneBounds.max.x - paneOffset.x - 0.5, pos - paneOffset.y - 0.5);
+							canvas.stroke();
+						});
+			}
+			canvas.closePath();
+		};
+	},
+
 	hasSplitPanesSupport: function () {
 		// Only enabled for Calc for now
 		// It may work without this.options.sheetGeometryDataEnabled but not tested.


More information about the Libreoffice-commits mailing list