loleaflet/src/control/Control.LokDialog.js |   14 ++++++++++
 loleaflet/src/control/Control.Scroll.js    |    3 ++
 loleaflet/src/layer/tile/TileLayer.js      |   38 ++++++++++++++++++++++++++++-
 3 files changed, 54 insertions(+), 1 deletion(-)

New commits:
commit 0a2b5c19c18cf5b5d6f1117d0b8c6bcd1ccf46d2
Author: Marco Cecchetti <marco.cecche...@collabora.com>
Date:   Tue Apr 3 12:36:24 2018 +0100

    calc: when expanding selection with shift-<cursor>, view never scrolls
    
    Change-Id: Iaea7b53a84210bcdfc180014a7d530b1455949c9
    Reviewed-on: https://gerrit.libreoffice.org/52639
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>
    Tested-by: Jan Holesovsky <ke...@collabora.com>

diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 22c3bc634..06a04f5d8 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1202,15 +1202,49 @@ L.TileLayer = L.GridLayer.extend({
                this._selectionTextContent = textMsg.substr(22);
        },
 
+       _updateScrollOnCellSelection: function (oldSelection, newSelection) {
+               if (this._map._docLayer._docType === 'spreadsheet' && 
oldSelection) {
+                       var mapBounds = this._map.getBounds();
+                       if (!mapBounds.contains(newSelection) && 
!newSelection.equals(oldSelection)) {
+                               var spacingX = 
Math.abs(this._cellCursor.getEast() - this._cellCursor.getWest()) / 4.0;
+                               var spacingY = 
Math.abs((this._cellCursor.getSouth() - this._cellCursor.getNorth())) / 2.0;
+
+                               var scrollX = 0, scrollY = 0;
+                               if (newSelection.getEast() > 
mapBounds.getEast() && newSelection.getEast() > oldSelection.getEast())
+                                       scrollX = newSelection.getEast() - 
mapBounds.getEast() + spacingX;
+                               else if (newSelection.getWest() < 
mapBounds.getWest() && newSelection.getWest() < oldSelection.getWest())
+                                       scrollX = newSelection.getWest() - 
mapBounds.getWest() - spacingX;
+                               if (newSelection.getNorth() > 
mapBounds.getNorth() && newSelection.getNorth() > oldSelection.getNorth())
+                                       scrollY = newSelection.getNorth() - 
mapBounds.getNorth() + spacingY;
+                               else if (newSelection.getSouth() < 
mapBounds.getSouth() && newSelection.getSouth() < oldSelection.getSouth())
+                                       scrollY = newSelection.getSouth() - 
mapBounds.getSouth() - spacingY;
+                               if (scrollX !== 0 || scrollY !== 0) {
+                                       var newCenter = mapBounds.getCenter();
+                                       newCenter.lng += scrollX;
+                                       newCenter.lat += scrollY;
+                                       var center = 
this._map.project(newCenter);
+                                       center = 
center.subtract(this._map.getSize().divideBy(2));
+                                       center.x = Math.round(center.x < 0 ? 0 
: center.x);
+                                       center.y = Math.round(center.y < 0 ? 0 
: center.y);
+                                       this._map.fire('scrollto', {x: 
center.x, y: center.y});
+                               }
+                       }
+               }
+       },
+
        _onTextSelectionEndMsg: function (textMsg) {
                var strTwips = textMsg.match(/\d+/g);
                if (strTwips != null && this._map._permission === 'edit') {
                        var topLeftTwips = new L.Point(parseInt(strTwips[0]), 
parseInt(strTwips[1]));
                        var offset = new L.Point(parseInt(strTwips[2]), 
parseInt(strTwips[3]));
                        var bottomRightTwips = topLeftTwips.add(offset);
+
+                       var oldSelection = this._textSelectionEnd;
                        this._textSelectionEnd = new L.LatLngBounds(
                                                
this._twipsToLatLng(topLeftTwips, this._map.getZoom()),
                                                
this._twipsToLatLng(bottomRightTwips, this._map.getZoom()));
+
+                       this._updateScrollOnCellSelection(oldSelection, 
this._textSelectionEnd);
                }
                else {
                        this._textSelectionEnd = null;
@@ -1223,14 +1257,16 @@ L.TileLayer = L.GridLayer.extend({
                        var topLeftTwips = new L.Point(parseInt(strTwips[0]), 
parseInt(strTwips[1]));
                        var offset = new L.Point(parseInt(strTwips[2]), 
parseInt(strTwips[3]));
                        var bottomRightTwips = topLeftTwips.add(offset);
+                       var oldSelection = this._textSelectionStart;
                        this._textSelectionStart = new L.LatLngBounds(
                                                
this._twipsToLatLng(topLeftTwips, this._map.getZoom()),
                                                
this._twipsToLatLng(bottomRightTwips, this._map.getZoom()));
+
+                       this._updateScrollOnCellSelection(oldSelection, 
this._textSelectionStart);
                }
                else {
                        this._textSelectionStart = null;
                }
-
        },
 
        _onDialogPaintMsg: function(textMsg, img) {
commit a96d6dc3e56150f0f8e2fe83e0a0ba626855bfb1
Author: Marco Cecchetti <marco.cecche...@collabora.com>
Date:   Sun Apr 8 13:02:38 2018 +0200

    calc: clicking outside a pop-up or a context menu doesn't close it
    
    Change-Id: I5fa43a702054f0cdc297251a4adaa2be953187a4
    Reviewed-on: https://gerrit.libreoffice.org/52618
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>
    Tested-by: Jan Holesovsky <ke...@collabora.com>

diff --git a/loleaflet/src/control/Control.LokDialog.js 
b/loleaflet/src/control/Control.LokDialog.js
index 743a14c0a..a3d255af5 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -12,6 +12,8 @@ L.Control.LokDialog = L.Control.extend({
                map.on('windowpaint', this._onDialogPaint, this);
                map.on('opendialog', this._openDialog, this);
                map.on('docloaded', this._docLoaded, this);
+               map.on('closepopup', this.onCloseCurrentPopUp, this);
+               L.DomEvent.on(document, 'mouseup', this.onCloseCurrentPopUp, 
this);
        },
 
        _dialogs: {},
@@ -230,6 +232,7 @@ L.Control.LokDialog = L.Control.extend({
        },
 
        _launchDialog: function(strDlgId, leftTwips, topTwips, width, height, 
title) {
+               this.onCloseCurrentPopUp();
                var dialogContainer = L.DomUtil.create('div', 'lokdialog', 
document.body);
                L.DomUtil.setStyle(dialogContainer, 'padding', '0px');
                L.DomUtil.setStyle(dialogContainer, 'margin', '0px');
@@ -290,6 +293,7 @@ L.Control.LokDialog = L.Control.extend({
                        this._map.lastActiveTime = Date.now();
                }, this);
                L.DomEvent.on(dialogCanvas, 'mousedown mouseup', function(e) {
+                       L.DomEvent.stopPropagation(e);
                        var buttons = 0;
                        buttons |= e.button === map['mouse'].JSButtons.left ? 
map['mouse'].LOButtons.left : 0;
                        buttons |= e.button === map['mouse'].JSButtons.middle ? 
map['mouse'].LOButtons.middle : 0;
@@ -318,6 +322,8 @@ L.Control.LokDialog = L.Control.extend({
                L.DomEvent.on(dlgInput, 'contextmenu', function() {
                        return false;
                });
+
+               this._currentId = this._toRawDlgId(strDlgId);
        },
 
        _postWindowCompositionEvent: function(winid, type, text) {
@@ -341,6 +347,14 @@ L.Control.LokDialog = L.Control.extend({
                $('#' + this._toDlgPrefix(dialogId)).remove();
                this._map.focus();
                delete this._dialogs[dialogId];
+               this._currentId = null;
+       },
+
+       onCloseCurrentPopUp: function() {
+               // for title-less dialog only (context menu, pop-up)
+               if (!this._currentId || !this._isOpen(this._currentId) || 
this._dialogs[this._currentId].title)
+                       return;
+               this._onDialogClose(this._currentId, true);
        },
 
        _paintDialog: function(dialogId, rectangle, imgData) {
diff --git a/loleaflet/src/control/Control.Scroll.js 
b/loleaflet/src/control/Control.Scroll.js
index b5e3b1efb..4973e109d 100644
--- a/loleaflet/src/control/Control.Scroll.js
+++ b/loleaflet/src/control/Control.Scroll.js
@@ -32,6 +32,9 @@ L.Control.Scroll = L.Control.extend({
                        scrollInertia: 0,
                        advanced:{autoExpandHorizontalScroll: true}, /* weird 
bug, it should be false */
                        callbacks:{
+                               onScrollStart: function() {
+                                       control._map.fire('closepopup');
+                               },
                                onScroll: function() {
                                        control._onScrollEnd(this);
                                        if (autoHideTimeout)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to