loleaflet/src/layer/tile/CalcTileLayer.js |  118 +++++++++++++++++++++++++++++-
 loleaflet/src/layer/tile/GridLayer.js     |   28 ++++++-
 loleaflet/src/layer/tile/TileLayer.js     |    7 +
 loleaflet/src/map/Map.js                  |   13 +++
 4 files changed, 164 insertions(+), 2 deletions(-)

New commits:
commit 2bdd07a232e76652e4e4ae1afd4f1a9fd1c2c197
Author:     Dennis Francis <[email protected]>
AuthorDate: Tue Jul 7 12:08:13 2020 +0530
Commit:     Dennis Francis <[email protected]>
CommitDate: Wed Jul 8 16:48:44 2020 +0200

    add new methods to Map/GridLayer/TileLayer/CalcTileLayer...
    
    needed to implement split-panes feature in Calc.
    
    Change-Id: I8e221299e951e3c38ed74794573e44a5d3b9e8b2
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98329
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Tested-by: Jenkins
    Reviewed-by: Dennis Francis <[email protected]>

diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js 
b/loleaflet/src/layer/tile/CalcTileLayer.js
index 5c80d35f3..4ff7b51ba 100644
--- a/loleaflet/src/layer/tile/CalcTileLayer.js
+++ b/loleaflet/src/layer/tile/CalcTileLayer.js
@@ -835,7 +835,49 @@ L.CalcTileLayer = L.TileLayer.extend({
                });
 
                return rectArray;
-       }
+       },
+
+       getSnapDocPosX: function (docPosX, unit) {
+               if (!this.options.sheetGeometryDataEnabled) {
+                       return docPosX;
+               }
+
+               unit = unit || 'csspixels';
+
+               return this.sheetGeometry.getSnapDocPosX(docPosX, unit);
+       },
+
+       getSnapDocPosY: function (docPosY, unit) {
+               if (!this.options.sheetGeometryDataEnabled) {
+                       return docPosY;
+               }
+
+               unit = unit || 'csspixels';
+
+               return this.sheetGeometry.getSnapDocPosY(docPosY, unit);
+       },
+
+       getSplitPanesContext: function () {
+               if (!this.hasSplitPanesSupport()) {
+                       return undefined;
+               }
+
+               return this._splitPanesContext;
+       },
+
+       getMaxDocSize: function () {
+
+               if (this.sheetGeometry) {
+                       return this.sheetGeometry.getSize('csspixels');
+               }
+
+               return this._twipsToPixels(new L.Point(this._docWidthTwips, 
this._docHeightTwips));
+       },
+
+       getCursorPos: function () {
+               return this._twipsToPixels(this._cellCursorTwips.getTopLeft());
+       },
+
 });
 
 L.MessageStore = L.Class.extend({
@@ -1127,6 +1169,26 @@ L.SheetGeometry = L.Class.extend({
                return new L.Bounds(topLeft, topLeft.add(size));
        },
 
+       getCellFromPos: function (pos, unit) {
+               console.assert(pos instanceof L.Point);
+               return new L.Point(
+                       this._columns.getIndexFromPos(pos.x, unit),
+                       this._rows.getIndexFromPos(pos.y, unit)
+               );
+       },
+
+       // Returns the start position of the column containing posX in the 
specified unit.
+       // unit must be one of 'csspixels', 'devpixels', 'tiletwips', 
'printtwips'
+       getSnapDocPosX: function (posX, unit) {
+               return this._columns.getSnapPos(posX, unit);
+       },
+
+       // Returns the start position of the row containing posY in the 
specified unit.
+       // unit must be one of 'csspixels', 'devpixels', 'tiletwips', 
'printtwips'
+       getSnapDocPosY: function (posY, unit) {
+               return this._rows.getSnapPos(posY, unit);
+       },
+
        _testValidity: function (sheetGeomJSON, checkCompleteness) {
 
                if (!sheetGeomJSON.hasOwnProperty('commandName')) {
@@ -1592,6 +1654,60 @@ L.SheetDimension = L.Class.extend({
 
                return posSize.startpos + posSize.size;
        },
+
+       isUnitSupported: function (unitName) {
+               return (
+                       unitName === 'csspixels' ||
+                       unitName === 'devpixels' ||
+                       unitName === 'tiletwips' ||
+                       unitName === 'printtwips'
+               );
+       },
+
+       getSnapPos: function (pos, unit) {
+               console.assert(typeof pos === 'number', 'pos is not a number');
+               console.assert(this.isUnitSupported(unit), 'unit: ' + unit + ' 
is not supported');
+
+               var origUnit = unit;
+
+               if (unit === 'devpixels') {
+                       pos = (pos * this._twipsPerCSSPixel) / 
this._devPixelsPerCssPixel;
+                       unit = 'tiletwips';
+               }
+               else if (unit === 'csspixels') {
+                       pos = pos * this._twipsPerCSSPixel;
+                       unit = 'tiletwips';
+               }
+
+               console.assert(unit === 'tiletwips' || unit === 'printtwips', 
'wrong unit assumption');
+               var result = (unit === 'tiletwips') ?
+                       this._getSpanAndIndexFromTileTwipsPos(pos) :
+                       this._getSpanAndIndexFromPrintTwipsPos(pos);
+
+               return this._getElementDataAnyFromSpanByIndex(result.index, 
result.span, origUnit).startpos;
+       },
+
+       getIndexFromPos: function (pos, unit) {
+               console.assert(typeof pos === 'number', 'pos is not a number');
+               console.assert(this.isUnitSupported(unit), 'unit: ' + unit + ' 
is not supported');
+
+               if (unit === 'devpixels') {
+                       pos = (pos * this._twipsPerCSSPixel) / 
this._devPixelsPerCssPixel;
+                       unit = 'tiletwips';
+               }
+               else if (unit === 'csspixels') {
+                       pos = pos * this._twipsPerCSSPixel;
+                       unit = 'tiletwips';
+               }
+
+               console.assert(unit === 'tiletwips' || unit === 'printtwips', 
'wrong unit assumption');
+               var result = (unit === 'tiletwips') ?
+                       this._getSpanAndIndexFromTileTwipsPos(pos) :
+                       this._getSpanAndIndexFromPrintTwipsPos(pos);
+
+               return result.index;
+       },
+
 });
 
 L.SpanList = L.Class.extend({
diff --git a/loleaflet/src/layer/tile/GridLayer.js 
b/loleaflet/src/layer/tile/GridLayer.js
index 91dd404e8..08c3fc2ab 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -1303,7 +1303,33 @@ L.GridLayer = L.Layer.extend({
                        this._tilesPreFetcher = 
setInterval(L.bind(this._preFetchTiles, this), interval);
                        this._prefetchIdle = undefined;
                }, this), idleTime);
-       }
+       },
+
+       getMaxDocSize: function () {
+               return undefined;
+       },
+
+       getSnapDocPosX: function (docPosPixX) {
+               return docPosPixX;
+       },
+
+       getSnapDocPosY: function (docPosPixY) {
+               return docPosPixY;
+       },
+
+       hasSplitPanesSupport: function () {
+               return false;
+       },
+
+       getSplitPanesContext: function () {
+               return undefined;
+       },
+
+       updateHorizPaneSplitter: function () {
+       },
+
+       updateVertPaneSplitter: function () {
+       },
 });
 
 L.gridLayer = function (options) {
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index a53074498..73d2da8a5 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -3442,6 +3442,13 @@ L.TileLayer = L.GridLayer.extend({
                return L.Bounds.parseArray(textMsg);
        },
 
+       // Needed for the split-panes feature to determine the active 
split-pane.
+       // Needs to be implemented by the app specific TileLayer.
+       getCursorPos: function () {
+               console.error('No implementations available for getCursorPos!');
+               return new L.Point(0, 0);
+       },
+
        _debugGetTimeArray: function() {
                return {count: 0, ms: 0, best: Number.MAX_SAFE_INTEGER, worst: 
0, date: 0};
        },
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index c3ba4e260..b6027ffc4 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -1764,6 +1764,19 @@ L.Map = L.Evented.extend({
                        this.removeLayer(this.focusLayer);
                        this.focusLayer = null;
                }
+       },
+
+       getSplitPanesContext: function () {
+               if (this._splitPanesContext) {
+                       return this._splitPanesContext;
+               }
+
+               var docLayer = this._docLayer;
+               if (docLayer && typeof docLayer.getSplitPanesContext === 
'function') {
+                       this._splitPanesContext = 
docLayer.getSplitPanesContext();
+               }
+
+               return this._splitPanesContext;
        }
 });
 
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to