[Libreoffice-commits] online.git: loleaflet/src

Henry Castro hcastro at collabora.com
Wed Aug 17 13:14:01 UTC 2016


 loleaflet/src/control/Control.ColumnHeader.js |   20 +++++++++++++++++++
 loleaflet/src/control/Control.Header.js       |   16 +++++++++++++--
 loleaflet/src/control/Control.RowHeader.js    |   27 ++++++++++++++++++++++++++
 loleaflet/src/layer/tile/CalcTileLayer.js     |    3 ++
 4 files changed, 64 insertions(+), 2 deletions(-)

New commits:
commit 2757adc3c69ce345a9ba8a82166d75665b7e1ef1
Author: Henry Castro <hcastro at collabora.com>
Date:   Wed Aug 17 09:11:18 2016 -0400

    loleaflet: add dblclick row/column to process optimal height/width

diff --git a/loleaflet/src/control/Control.ColumnHeader.js b/loleaflet/src/control/Control.ColumnHeader.js
index ba928eb..88a5b9f 100644
--- a/loleaflet/src/control/Control.ColumnHeader.js
+++ b/loleaflet/src/control/Control.ColumnHeader.js
@@ -226,6 +226,26 @@ L.Control.ColumnHeader = L.Control.Header.extend({
 		this._map.removeLayer(this._vertLine);
 	},
 
+	onDragClick: function (item, clicks, e) {
+		this._map.removeLayer(this._vertLine);
+
+		if (clicks === 2) {
+			var command = {
+				Col: {
+					type: 'unsigned short',
+					value: item.column - 1
+				},
+				Modifier: {
+					type: 'unsigned short',
+					value: 0
+				}
+			};
+
+			this._map.sendUnoCommand('.uno:SelectColumn ', command);
+			this._map.sendUnoCommand('.uno:SetOptimalColumnWidthDirect');
+		}
+	},
+
 	_onUpdatePermission: function (e) {
 		if (this._map.getDocType() !== 'spreadsheet') {
 			return;
diff --git a/loleaflet/src/control/Control.Header.js b/loleaflet/src/control/Control.Header.js
index 3a56fc5..cbd8b53 100644
--- a/loleaflet/src/control/Control.Header.js
+++ b/loleaflet/src/control/Control.Header.js
@@ -7,6 +7,10 @@ L.Control.Header = L.Control.extend({
 		cursor: 'col-resize'
 	},
 
+	initialize: function () {
+		this._clicks = 0;
+	},
+
 	mouseInit: function (element) {
 		L.DomEvent.on(element, 'mousedown', this._onMouseDown, this);
 	},
@@ -61,12 +65,20 @@ L.Control.Header = L.Control.extend({
 		L.DomUtil.enableImageDrag();
 		L.DomUtil.enableTextSelection();
 
-		this.onDragEnd(this._item, this._start, this._offset, e);
+		if (this._dragging) {
+			this.onDragEnd(this._item, this._start, this._offset, e);
+			this._clicks = 0;
+		} else {
+			this.onDragClick(this._item, ++this._clicks, e);
+			setTimeout(L.bind(this.initialize, this), 200);
+		}
+
 		this._target = this._cursor = this._item = this._start = this._offset = null;
 		this._dragging = false;
 	},
 
 	onDragStart: function () {},
 	onDragMove: function () {},
-	onDragEnd: function () {}
+	onDragEnd: function () {},
+	onDragClick: function () {}
 });
diff --git a/loleaflet/src/control/Control.RowHeader.js b/loleaflet/src/control/Control.RowHeader.js
index c4ced20..53bc3a5 100644
--- a/loleaflet/src/control/Control.RowHeader.js
+++ b/loleaflet/src/control/Control.RowHeader.js
@@ -208,6 +208,33 @@ L.Control.RowHeader = L.Control.Header.extend({
 		this._map.removeLayer(this._horzLine);
 	},
 
+	onDragClick: function (item, clicks, e) {
+		this._map.removeLayer(this._horzLine);
+
+		if (clicks === 2) {
+			var command = {
+				Row: {
+					type: 'long',
+					value: item.row - 1
+				},
+				Modifier: {
+					type: 'unsigned short',
+					value: 0
+				}
+			};
+
+			var extra = {
+				aExtraHeight: {
+					type: 'unsigned short',
+					value: this._map._docLayer.STD_EXTRA_WIDTH
+				}
+			};
+
+			this._map.sendUnoCommand('.uno:SelectRow', command);
+			this._map.sendUnoCommand('.uno:SetOptimalRowHeight', extra);
+		}
+	},
+
 	_onUpdatePermission: function (e) {
 		if (this._map.getDocType() !== 'spreadsheet') {
 			return;
diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js
index 2641a12..1a23681 100644
--- a/loleaflet/src/layer/tile/CalcTileLayer.js
+++ b/loleaflet/src/layer/tile/CalcTileLayer.js
@@ -3,6 +3,9 @@
  */
 
 L.CalcTileLayer = L.TileLayer.extend({
+	STD_EXTRA_WIDTH: 113, /* 2mm extra for optimal width,
+                              * 0.1986cm with TeX points,
+                              * 0.1993cm with PS points. */
 
 	beforeAdd: function (map) {
 		map._addZoomLimit(this);


More information about the Libreoffice-commits mailing list