[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4' - 3 commits - loleaflet/src
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Wed Oct 2 22:11:58 UTC 2019
loleaflet/src/layer/tile/TileLayer.TableOverlay.js | 30 +++++----------------
loleaflet/src/layer/tile/TileLayer.js | 30 +++++++++++++++++++--
loleaflet/src/layer/vector/SVGGroup.js | 9 +++++-
loleaflet/src/map/handler/Map.TouchGesture.js | 27 +++++++++++++-----
4 files changed, 63 insertions(+), 33 deletions(-)
New commits:
commit 7b4d40920a17c61468065ef68c3be30a5abc804e
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed Oct 2 14:20:47 2019 +0200
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Thu Oct 3 00:11:41 2019 +0200
tdf#125565 make it possible to select cells in a table
Change-Id: If7f6b2cb3f2e8c6bf08b55c7a52ef6e96d388abe
Reviewed-on: https://gerrit.libreoffice.org/80035
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
(cherry picked from commit b6dd960b50581927476baa6a667a836675d78817)
Reviewed-on: https://gerrit.libreoffice.org/80037
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
diff --git a/loleaflet/src/layer/tile/TileLayer.TableOverlay.js b/loleaflet/src/layer/tile/TileLayer.TableOverlay.js
index 978a3ebc5..25e8f93e7 100644
--- a/loleaflet/src/layer/tile/TileLayer.TableOverlay.js
+++ b/loleaflet/src/layer/tile/TileLayer.TableOverlay.js
@@ -18,6 +18,9 @@ L.TileLayer.include({
var point = this._latLngToTwips(this._map.unproject(new L.Point(pixel, 0)));
return point.x;
},
+ hasTableSelection: function () {
+ return this._currentTableData.rows != null || this._currentTableData.columns != null;
+ },
_initMoveMarkers: function () {
this._tableMoveMarker = L.marker(new L.LatLng(0, 0), {
icon: L.divIcon({
@@ -207,7 +210,6 @@ L.TileLayer.include({
textMsg = textMsg.substring('tableselected:'.length + 1);
var message = JSON.parse(textMsg);
this._currentTableData = message;
- this._hasTableSelection = this._currentTableData.rows != null || this._currentTableData.columns != null;
this._updateTableMarkers();
this._map.on('zoomend', L.bind(this._onZoomForTableMarkers, this));
},
@@ -335,6 +337,8 @@ L.TileLayer.include({
},
_onTableMoveMarkerDrag: function (event) {
var mouseEvent;
+ if (this._graphicMarker == null)
+ return;
if (event.type == 'dragstart') {
mouseEvent = this._createNewMouseEvent('mousedown', event.originalEvent);
this._graphicMarker._onDragStart(mouseEvent);
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index e0a599e3a..2d324784e 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1934,12 +1934,14 @@ L.TileLayer = L.GridLayer.extend({
var aPos = this._latLngToTwips(e.pos);
if (e.type === 'graphicmovestart') {
this._graphicMarker.isDragged = true;
+ this._graphicMarker.setVisible(true);
this._graphicMarker._startPos = aPos;
}
else if (e.type === 'graphicmoveend' && this._graphicMarker._startPos) {
var deltaPos = aPos.subtract(this._graphicMarker._startPos);
if (deltaPos.x === 0 && deltaPos.y === 0) {
this._graphicMarker.isDragged = false;
+ this._graphicMarker.setVisible(false);
return;
}
@@ -2005,6 +2007,7 @@ L.TileLayer = L.GridLayer.extend({
}
this._map.sendUnoCommand('.uno:TransformDialog ', param);
this._graphicMarker.isDragged = false;
+ this._graphicMarker.setVisible(false);
}
},
@@ -2018,6 +2021,7 @@ L.TileLayer = L.GridLayer.extend({
if (e.type === 'scalestart') {
this._graphicMarker.isDragged = true;
+ this._graphicMarker.setVisible(true);
if (selMax.x - selMin.x < 2)
this._graphicMarker.dragHorizDir = 0; // overlapping handles
else if (Math.abs(selMin.x - aPos.x) < 2)
@@ -2159,6 +2163,7 @@ L.TileLayer = L.GridLayer.extend({
}
this._graphicMarker.isDragged = false;
+ this._graphicMarker.setVisible(false);
this._graphicMarker.dragHorizDir = undefined;
this._graphicMarker.dragVertDir = undefined;
}
@@ -2167,6 +2172,7 @@ L.TileLayer = L.GridLayer.extend({
_onGraphicRotate: function (e) {
if (e.type === 'rotatestart') {
this._graphicMarker.isDragged = true;
+ this._graphicMarker.setVisible(true);
}
else if (e.type === 'rotateend') {
var center = this._graphicSelectionTwips.getCenter();
@@ -2186,6 +2192,7 @@ L.TileLayer = L.GridLayer.extend({
};
this._map.sendUnoCommand('.uno:TransformDialog ', param);
this._graphicMarker.isDragged = false;
+ this._graphicMarker.setVisible(false);
}
},
@@ -2391,9 +2398,9 @@ L.TileLayer = L.GridLayer.extend({
this._graphicMarker.dragging.enable();
this._graphicMarker.transform.enable({
scaling: extraInfo.isResizable,
- rotation: extraInfo.isRotatable && !this._hasTableSelection,
+ rotation: extraInfo.isRotatable && !this.hasTableSelection(),
uniformScaling: !this._isGraphicAngleDivisibleBy90(),
- scaleSouthAndEastOnly: this._hasTableSelection});
+ scaleSouthAndEastOnly: this.hasTableSelection()});
if (extraInfo.dragInfo && extraInfo.dragInfo.svg) {
this._graphicMarker.removeEmbeddedSVG();
this._graphicMarker.addEmbeddedSVG(extraInfo.dragInfo.svg);
@@ -2408,6 +2415,7 @@ L.TileLayer = L.GridLayer.extend({
this._graphicMarker.transform.disable();
this._map.removeLayer(this._graphicMarker);
this._graphicMarker.isDragged = false;
+ this._graphicMarker.setVisible(false);
}
this._updateCursorAndOverlay();
},
diff --git a/loleaflet/src/layer/vector/SVGGroup.js b/loleaflet/src/layer/vector/SVGGroup.js
index d4af58cf0..23a1b256e 100644
--- a/loleaflet/src/layer/vector/SVGGroup.js
+++ b/loleaflet/src/layer/vector/SVGGroup.js
@@ -23,7 +23,14 @@ L.SVGGroup = L.Layer.extend({
this.on('dragstart scalestart rotatestart', this._showEmbeddedSVG, this);
this.on('dragend scaleend rotateend', this._hideEmbeddedSVG, this);
},
-
+ setVisible: function (visible) {
+ if (this._svg != null) {
+ if (visible)
+ this._svg.setAttribute('visibility', 'visible');
+ else
+ this._svg.setAttribute('visibility', 'hidden');
+ }
+ },
addEmbeddedSVG: function (svgString) {
var parser = new DOMParser();
var doc = parser.parseFromString(svgString, 'image/svg+xml');
diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js
index a526af3fa..d222d5a89 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -13,7 +13,8 @@ L.Map.TouchGesture = L.Handler.extend({
MAP: 1,
CURSOR: 2,
GRAPHIC: 4,
- MARKER: 8
+ MARKER: 8,
+ TABLE: 16
},
initialize: function (map) {
@@ -133,7 +134,10 @@ L.Map.TouchGesture = L.Handler.extend({
if (this._marker) {
this._state = L.Map.TouchGesture.MARKER;
} else if (this._map._docLayer._graphicMarker && this._map._docLayer._graphicMarker.getBounds().contains(latlng)) {
- this._state = L.Map.TouchGesture.GRAPHIC;
+ if (this._map._docLayer.hasTableSelection())
+ this._state = L.Map.TouchGesture.TABLE;
+ else
+ this._state = L.Map.TouchGesture.GRAPHIC;
} else if (this._map._docLayer._cellCursor && this._map._docLayer._cellCursor.contains(latlng)) {
this._state = L.Map.TouchGesture.CURSOR;
} else {
@@ -269,6 +273,8 @@ L.Map.TouchGesture = L.Handler.extend({
} else if (this._state === L.Map.TouchGesture.GRAPHIC) {
var mouseEvent = this._map._docLayer._createNewMouseEvent('mousedown', e.srcEvent);
this._map._docLayer._graphicMarker._onDragStart(mouseEvent);
+ } else if (this._state === L.Map.TouchGesture.TABLE) {
+ this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
} else if (this._state === L.Map.TouchGesture.CURSOR) {
this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
} else {
@@ -288,6 +294,8 @@ L.Map.TouchGesture = L.Handler.extend({
} else if (this._state === L.Map.TouchGesture.GRAPHIC) {
var mouseEvent = this._map._docLayer._createNewMouseEvent('mousemove', e.srcEvent);
this._map._docLayer._graphicMarker._onDrag(mouseEvent);
+ } else if (this._state === L.Map.TouchGesture.TABLE) {
+ this._map._docLayer._postMouseEvent('move', mousePos.x, mousePos.y, 1, 1, 0);
} else if (this._state === L.Map.TouchGesture.CURSOR) {
this._map._docLayer._postMouseEvent('move', mousePos.x, mousePos.y, 1, 1, 0);
} else {
@@ -307,6 +315,8 @@ L.Map.TouchGesture = L.Handler.extend({
} else if (this._state === L.Map.TouchGesture.GRAPHIC) {
var mouseEvent = this._map._docLayer._createNewMouseEvent('mouseup', e.srcEvent);
this._map._docLayer._graphicMarker._onDragEnd(mouseEvent);
+ } else if (this._state === L.Map.TouchGesture.TABLE) {
+ this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
} else if (this._state === L.Map.TouchGesture.CURSOR) {
this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
} else {
commit 140f0c870785df23c940b4066f78f647e2b24d6f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Sep 30 09:24:08 2019 +0200
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Thu Oct 3 00:11:34 2019 +0200
Convert the touch to mouse event when dragging graphic seelction
This is needed so the dragging code can correctly recognize the
event and set the variables or the preview won't be drawn during
dragging.
Change-Id: I9b92985f9557cf6d87db4f73507b961941e0a039
Reviewed-on: https://gerrit.libreoffice.org/79827
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
(cherry picked from commit 6b3eea91215a0e1d361db639dc9b4514a310cdbb)
Reviewed-on: https://gerrit.libreoffice.org/79828
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
diff --git a/loleaflet/src/layer/tile/TileLayer.TableOverlay.js b/loleaflet/src/layer/tile/TileLayer.TableOverlay.js
index 6a7cba29b..978a3ebc5 100644
--- a/loleaflet/src/layer/tile/TileLayer.TableOverlay.js
+++ b/loleaflet/src/layer/tile/TileLayer.TableOverlay.js
@@ -333,36 +333,18 @@ L.TileLayer.include({
if (e.originalEvent)
e.originalEvent.preventDefault();
},
- _createMouseEvent: function (type, inputEvent) {
- var event = inputEvent;
- if (inputEvent.type == 'touchstart' || inputEvent.type == 'touchmove') {
- event = inputEvent.touches[0];
- }
- else if (inputEvent.type == 'touchend') {
- event = inputEvent.changedTouches[0];
- }
-
- var newEvent = document.createEvent('MouseEvents');
- newEvent.initMouseEvent(
- type, true, true, window, 1,
- event.screenX, event.screenY,
- event.clientX, event.clientY,
- false, false, false, false, 0, null
- );
- return newEvent;
- },
_onTableMoveMarkerDrag: function (event) {
var mouseEvent;
if (event.type == 'dragstart') {
- mouseEvent = this._createMouseEvent('mousedown', event.originalEvent);
+ mouseEvent = this._createNewMouseEvent('mousedown', event.originalEvent);
this._graphicMarker._onDragStart(mouseEvent);
}
else if (event.type == 'drag') {
- mouseEvent = this._createMouseEvent('mousemove', event.originalEvent);
+ mouseEvent = this._createNewMouseEvent('mousemove', event.originalEvent);
this._graphicMarker._onDrag(mouseEvent);
}
else if (event.type == 'dragend') {
- mouseEvent = this._createMouseEvent('mouseup', event.originalEvent);
+ mouseEvent = this._createNewMouseEvent('mouseup', event.originalEvent);
this._graphicMarker._onDragEnd(mouseEvent);
}
}
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 309edf01f..e0a599e3a 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -322,6 +322,24 @@ L.TileLayer = L.GridLayer.extend({
map.fire('statusindicator', {statusType: 'loleafletloaded'});
},
+ _createNewMouseEvent: function (type, inputEvent) {
+ var event = inputEvent;
+ if (inputEvent.type == 'touchstart' || inputEvent.type == 'touchmove') {
+ event = inputEvent.touches[0];
+ }
+ else if (inputEvent.type == 'touchend') {
+ event = inputEvent.changedTouches[0];
+ }
+ var newEvent = document.createEvent('MouseEvents');
+ newEvent.initMouseEvent(
+ type, true, true, window, 1,
+ event.screenX, event.screenY,
+ event.clientX, event.clientY,
+ false, false, false, false, 0, null
+ );
+ return newEvent;
+ },
+
clearAnnotations: function() {
console.debug('Implemented in child classes');
},
diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js
index c6a69adc0..a526af3fa 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -267,7 +267,8 @@ L.Map.TouchGesture = L.Handler.extend({
if (this._state === L.Map.TouchGesture.MARKER) {
this._map._fireDOMEvent(this._marker, e.srcEvent, 'mousedown');
} else if (this._state === L.Map.TouchGesture.GRAPHIC) {
- this._map._docLayer._graphicMarker._onDragStart(e.srcEvent);
+ var mouseEvent = this._map._docLayer._createNewMouseEvent('mousedown', e.srcEvent);
+ this._map._docLayer._graphicMarker._onDragStart(mouseEvent);
} else if (this._state === L.Map.TouchGesture.CURSOR) {
this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
} else {
@@ -285,7 +286,8 @@ L.Map.TouchGesture = L.Handler.extend({
if (this._state === L.Map.TouchGesture.MARKER) {
this._map._fireDOMEvent(this._map, e.srcEvent, 'mousemove');
} else if (this._state === L.Map.TouchGesture.GRAPHIC) {
- this._map._docLayer._graphicMarker._onDrag(e.srcEvent);
+ var mouseEvent = this._map._docLayer._createNewMouseEvent('mousemove', e.srcEvent);
+ this._map._docLayer._graphicMarker._onDrag(mouseEvent);
} else if (this._state === L.Map.TouchGesture.CURSOR) {
this._map._docLayer._postMouseEvent('move', mousePos.x, mousePos.y, 1, 1, 0);
} else {
@@ -303,7 +305,8 @@ L.Map.TouchGesture = L.Handler.extend({
if (this._state === L.Map.TouchGesture.MARKER) {
this._map._fireDOMEvent(this._map, e.srcEvent, 'mouseup');
} else if (this._state === L.Map.TouchGesture.GRAPHIC) {
- this._map._docLayer._graphicMarker._onDragEnd(e.srcEvent);
+ var mouseEvent = this._map._docLayer._createNewMouseEvent('mouseup', e.srcEvent);
+ this._map._docLayer._graphicMarker._onDragEnd(mouseEvent);
} else if (this._state === L.Map.TouchGesture.CURSOR) {
this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
} else {
commit 09f2910d4c3e7844b07049673518c1b4bfbad284
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu Oct 3 00:04:51 2019 +0300
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Oct 2 23:50:17 2019 +0200
tdf#127881: Must call this._map.focus() unconditionally now with Hammer.js
Otherwise the keyboard does not show up after the sidebar has been visible.
Change-Id: Iff98ebc228688464cf9283aef694413f25631613
Reviewed-on: https://gerrit.libreoffice.org/80088
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Tor Lillqvist <tml at collabora.com>
diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js
index b9d2a5b39..c6a69adc0 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -203,9 +203,7 @@ L.Map.TouchGesture = L.Handler.extend({
this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
- if (!this._map.hasFocus()) {
- this._map.focus();
- }
+ this._map.focus();
},
_onDoubleTap: function (e) {
More information about the Libreoffice-commits
mailing list