loleaflet/src/layer/tile/CalcTileLayer.js | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
New commits: commit 4527f5587a8edc8fe2be87fb594f4b650dd42ad4 Author: Dennis Francis <dennis.fran...@collabora.com> AuthorDate: Thu May 28 07:02:09 2020 +0530 Commit: Dennis Francis <dennis.fran...@collabora.com> CommitDate: Mon Jul 6 18:53:39 2020 +0200 Use sheet-geometry data to prevent view area overflow... when zooming close to bottom/right of a sheet. The bug is due to the view centering logic on zoom without the knowledge of sheet area hard-limits and is present in online master without the calc-coordinates cleanup work. Change-Id: Ic3b9f2873c4a22365a87a08a2ff89d8584a16581 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98145 Tested-by: Jenkins Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Dennis Francis <dennis.fran...@collabora.com> diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js index f37caa6c5..0606a0831 100644 --- a/loleaflet/src/layer/tile/CalcTileLayer.js +++ b/loleaflet/src/layer/tile/CalcTileLayer.js @@ -441,11 +441,42 @@ L.CalcTileLayer = L.TileLayer.extend({ this.sheetGeometry.setTileGeometryData(this._tileWidthTwips, this._tileHeightTwips, this._tileSize, this._tilePixelScale); } + this._restrictDocumentSize(); this._replayPrintTwipsMsgs(); this.refreshViewData(); this._map._socket.sendMessage('commandvalues command=.uno:ViewAnnotationsPosition'); }, + _restrictDocumentSize: function () { + + if (!this.sheetGeometry) { + return; + } + + var maxDocSize = this.sheetGeometry.getSize('tiletwips'); + var newDocWidth = Math.min(maxDocSize.x, this._docWidthTwips); + var newDocHeight = Math.min(maxDocSize.y, this._docHeightTwips); + + var shouldRestrict = (newDocWidth !== this._docWidthTwips || + newDocHeight !== this._docHeightTwips); + + if (!shouldRestrict) { + return; + } + + var newWidthPx = newDocWidth / this._tileWidthTwips * this._tileSize; + var newHeightPx = newDocHeight / this._tileHeightTwips * this._tileSize; + + var topLeft = this._map.unproject(new L.Point(0, 0)); + var bottomRight = this._map.unproject(new L.Point(newWidthPx, newHeightPx)); + this._map.setMaxBounds(new L.LatLngBounds(topLeft, bottomRight)); + + this._docPixelSize = {x: newWidthPx, y: newHeightPx}; + this._docWidthTwips = newDocWidth; + this._docHeightTwips = newDocHeight; + this._map.fire('docsize', {x: newWidthPx, y: newHeightPx}); + }, + _onUpdateCurrentHeader: function() { this._map.fire('updatecurrentheader', this._getCursorPosSize()); }, @@ -995,6 +1026,13 @@ L.SheetGeometry = L.Class.extend({ return new L.Bounds(topLeft, bottomRight); }, + // Returns full sheet size as L.Point in the given unit. + // unit must be one of 'csspixels', 'devpixels', 'tiletwips', 'printtwips' + getSize: function (unit) { + return new L.Point(this._columns.getSize(unit), + this._rows.getSize(unit)); + }, + _testValidity: function (sheetGeomJSON, checkCompleteness) { if (!sheetGeomJSON.hasOwnProperty('commandName')) { @@ -1195,6 +1233,15 @@ L.SheetDimension = L.Class.extend({ return this._getElementDataFromSpanByIndex(index, span, useDevicePixels); }, + getElementDataAny: function (index, unitName) { + var span = this._visibleSizes.getSpanDataByIndex(index); + if (span === undefined) { + return undefined; + } + + return this._getElementDataAnyFromSpanByIndex(index, span, unitName); + }, + // returns element pos/size in css pixels by default. _getElementDataFromSpanByIndex: function (index, span, useDevicePixels) { return this._getElementDataAnyFromSpanByIndex(index, span, @@ -1371,6 +1418,15 @@ L.SheetDimension = L.Class.extend({ endpos: endPos }; }, + + getSize: function (unit) { + var posSize = this.getElementDataAny(this._maxIndex, unit); + if (!posSize) { + return undefined; + } + + return posSize.startpos + posSize.size; + }, }); L.SpanList = L.Class.extend({ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits