[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3-0' - loleaflet/src
Marco Cecchetti
marco.cecchetti at collabora.com
Fri Dec 15 13:35:52 UTC 2017
loleaflet/src/control/Control.ColumnHeader.js | 11 ++----
loleaflet/src/control/Control.Header.js | 43 +++++++++-----------------
loleaflet/src/control/Control.RowHeader.js | 11 ++----
loleaflet/src/layer/tile/CalcTileLayer.js | 11 ++++--
loleaflet/src/layer/tile/TileLayer.js | 1
5 files changed, 32 insertions(+), 45 deletions(-)
New commits:
commit c17cf464740619d9b73200137b87de3b3ce715e7
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date: Wed Dec 13 23:20:30 2017 +0100
calc: use cursor position for change header highlight quickier
This patch fixes also a bug: when in edit mode the header for cell A1
are highlighted
Change-Id: If97d8d151f9d216362a9b1472c2b29fbec4f9b73
Reviewed-on: https://gerrit.libreoffice.org/46539
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/loleaflet/src/control/Control.ColumnHeader.js b/loleaflet/src/control/Control.ColumnHeader.js
index 65a8da8b..73bfc308 100644
--- a/loleaflet/src/control/Control.ColumnHeader.js
+++ b/loleaflet/src/control/Control.ColumnHeader.js
@@ -184,13 +184,10 @@ L.Control.ColumnHeader = L.Control.Header.extend({
},
_onUpdateCurrentColumn: function (e) {
- var x = e.min.x;
- var w = e.getSize().x;
- if (x !== -1) {
- x = this._twipsToPixels(x);
- w = this._twipsToPixels(w);
- }
- this.updateCurrent(this._data, x, w);
+ var x = e.curX - this._startHeaderIndex;
+ var w = this._twipsToPixels(e.width);
+ var slim = w <= 1;
+ this.updateCurrent(this._data, x, slim);
},
_updateColumnHeader: function () {
diff --git a/loleaflet/src/control/Control.Header.js b/loleaflet/src/control/Control.Header.js
index e77c7799..261b2958 100644
--- a/loleaflet/src/control/Control.Header.js
+++ b/loleaflet/src/control/Control.Header.js
@@ -213,42 +213,31 @@ L.Control.Header = L.Control.extend({
this._selection.end = itEnd;
},
- updateCurrent: function (data, start, size) {
+ updateCurrent: function (data, cursorPos, slim) {
if (!data || data.isEmpty())
return;
- if (start < 0) {
+ if (cursorPos < 0) {
this.unselect(data.get(this._current));
this._current = -1;
return;
}
- var x0 = 0, x1 = 0;
- var prevEntry = null;
- var entry = data.getFirst();
- var zeroSizeEntry = false;
- while (entry) {
- x0 = entry.pos - entry.size;
- x1 = entry.pos;
- if (x0 <= start && start < x1) {
- // we have a slim cursor because of a zero size entry ?
- zeroSizeEntry = size <= 1 && prevEntry && prevEntry.size === 0;
- // when a whole row (column) is selected the cell cursor is moved to the first column (row)
- // but this action should not cause to select/unselect anything, on the contrary we end up
- // with all column (row) header entries selected but the one where the cell cursor was
- // previously placed
- if (this._selection.start === -1 && this._selection.end === -1) {
- this.unselect(data.get(this._current));
- // no selection when the cell cursor is slim
- if (!zeroSizeEntry)
- this.select(entry);
- }
- this._current = zeroSizeEntry ? -1 : entry.index;
- break;
- }
- prevEntry = entry;
- entry = data.getNext();
+ var prevEntry = cursorPos > 0 ? data.get(cursorPos - 1) : null;
+ var zeroSizeEntry = slim && prevEntry && prevEntry.size === 0;
+
+ var entry = data.get(cursorPos);
+ if (this._selection.start === -1 && this._selection.end === -1) {
+ // when a whole row (column) is selected the cell cursor is moved to the first column (row)
+ // but this action should not cause to select/unselect anything, on the contrary we end up
+ // with all column (row) header entries selected but the one where the cell cursor was
+ // previously placed
+ this.unselect(data.get(this._current));
+ // no selection when the cell cursor is slim
+ if (entry && !zeroSizeEntry)
+ this.select(entry);
}
+ this._current = entry && !zeroSizeEntry ? entry.index : -1;
},
_mouseEventToCanvasPos: function(canvas, evt) {
diff --git a/loleaflet/src/control/Control.RowHeader.js b/loleaflet/src/control/Control.RowHeader.js
index d3e2371e..5e637527 100644
--- a/loleaflet/src/control/Control.RowHeader.js
+++ b/loleaflet/src/control/Control.RowHeader.js
@@ -175,13 +175,10 @@ L.Control.RowHeader = L.Control.Header.extend({
},
_onUpdateCurrentRow: function (e) {
- var y = e.min.y;
- var h = e.getSize().y;
- if (y !== -1) {
- y = this._twipsToPixels(y);
- h = this._twipsToPixels(h);
- }
- this.updateCurrent(this._data, y, h);
+ var y = e.curY - this._startHeaderIndex;
+ var h = this._twipsToPixels(e.height);
+ var slim = h <= 1;
+ this.updateCurrent(this._data, y, slim);
},
_updateRowHeader: function () {
diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js
index b15cd5bb..c628bfb8 100644
--- a/loleaflet/src/layer/tile/CalcTileLayer.js
+++ b/loleaflet/src/layer/tile/CalcTileLayer.js
@@ -355,13 +355,16 @@ L.CalcTileLayer = L.TileLayer.extend({
},
_onUpdateCurrentHeader: function() {
- var pos = new L.Point(-1, -1);
- var size = new L.Point(-1, -1);
+ var x = -1, y = -1;
+ if (this._cellCursorXY) {
+ x = this._cellCursorXY.x + 1;
+ y = this._cellCursorXY.y + 1;
+ }
+ var size = new L.Point(0, 0);
if (this._cellCursor && !this._isEmptyRectangle(this._cellCursor)) {
- pos = this._cellCursorTwips.min.add([1, 1]);
size = this._cellCursorTwips.getSize();
}
- this._map.fire('updatecurrentheader', new L.Bounds(pos, pos.add(size)));
+ this._map.fire('updatecurrentheader', {curX: x, curY: y, width: size.x, height: size.y});
},
_onUpdateSelectionHeader: function () {
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 2cfd27cb..de0091b5 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -659,6 +659,7 @@ L.TileLayer = L.GridLayer.extend({
if (textMsg.match('EMPTY')) {
this._cellCursorTwips = new L.Bounds(new L.Point(0, 0), new L.Point(0, 0));
this._cellCursor = L.LatLngBounds.createDefault();
+ this._cellCursorXY = new L.Point(-1, -1);
}
else {
var strTwips = textMsg.match(/\d+/g);
More information about the Libreoffice-commits
mailing list