[Libreoffice-commits] online.git: loleaflet/src
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Wed Oct 2 12:38:21 UTC 2019
loleaflet/src/layer/tile/TileLayer.TableOverlay.js | 6 +++++-
loleaflet/src/layer/tile/TileLayer.js | 12 ++++++++++--
loleaflet/src/layer/vector/SVGGroup.js | 9 ++++++++-
loleaflet/src/map/handler/Map.TouchGesture.js | 16 ++++++++++++++--
4 files changed, 37 insertions(+), 6 deletions(-)
New commits:
commit b6dd960b50581927476baa6a667a836675d78817
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: Wed Oct 2 14:37:54 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>
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 0d1668489..24f681416 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -2058,12 +2058,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;
}
@@ -2129,6 +2131,7 @@ L.TileLayer = L.GridLayer.extend({
}
this._map.sendUnoCommand('.uno:TransformDialog ', param);
this._graphicMarker.isDragged = false;
+ this._graphicMarker.setVisible(false);
}
},
@@ -2142,6 +2145,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)
@@ -2283,6 +2287,7 @@ L.TileLayer = L.GridLayer.extend({
}
this._graphicMarker.isDragged = false;
+ this._graphicMarker.setVisible(false);
this._graphicMarker.dragHorizDir = undefined;
this._graphicMarker.dragVertDir = undefined;
}
@@ -2291,6 +2296,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();
@@ -2310,6 +2316,7 @@ L.TileLayer = L.GridLayer.extend({
};
this._map.sendUnoCommand('.uno:TransformDialog ', param);
this._graphicMarker.isDragged = false;
+ this._graphicMarker.setVisible(false);
}
},
@@ -2515,9 +2522,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);
@@ -2532,6 +2539,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 132426d44..26cac2c8b 100644
--- a/loleaflet/src/layer/vector/SVGGroup.js
+++ b/loleaflet/src/layer/vector/SVGGroup.js
@@ -22,7 +22,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 be2d3813f..e4b4686f9 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) {
@@ -152,7 +153,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 if (this._map._docLayer._cellCursor && funcWizardRangeBounds && funcWizardRangeBounds.contains(latlng)) {
@@ -299,6 +303,8 @@ L.Map.TouchGesture = L.Handler.extend({
if (this._state === L.Map.TouchGesture.MARKER) {
this._map._fireDOMEvent(this._marker, point, 'mousedown');
+ } 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.GRAPHIC) {
var mouseEvent = this._map._docLayer._createNewMouseEvent('mousedown', point);
this._map._docLayer._graphicMarker._onDragStart(mouseEvent);
@@ -323,6 +329,9 @@ L.Map.TouchGesture = L.Handler.extend({
var mouseEvent = this._map._docLayer._createNewMouseEvent('mousemove', point);
this._map._docLayer._graphicMarker._onDrag(mouseEvent);
this._moving = true;
+ } else if (this._state === L.Map.TouchGesture.TABLE) {
+ this._map._docLayer._postMouseEvent('move', mousePos.x, mousePos.y, 1, 1, 0);
+ this._moving = true;
} else if (this._state === L.Map.TouchGesture.CURSOR) {
this._map._docLayer._postMouseEvent('move', mousePos.x, mousePos.y, 1, 1, 0);
} else {
@@ -344,6 +353,9 @@ L.Map.TouchGesture = L.Handler.extend({
var mouseEvent = this._map._docLayer._createNewMouseEvent('mouseup', point);
this._map._docLayer._graphicMarker._onDragEnd(mouseEvent);
this._moving = false;
+ } else if (this._state === L.Map.TouchGesture.TABLE) {
+ this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
+ this._moving = false;
} else if (this._state === L.Map.TouchGesture.CURSOR) {
this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
} else {
More information about the Libreoffice-commits
mailing list