[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-7' - 4 commits - loleaflet/dist loleaflet/src

Pranav Kant pranavk at collabora.com
Fri Mar 18 15:47:21 UTC 2016


 loleaflet/dist/spreadsheet.css                |   25 ++++++++++++
 loleaflet/src/control/Control.ColumnHeader.js |   54 +++++++++++++++++++++++++-
 loleaflet/src/control/Control.RowHeader.js    |   36 ++++++++++++++++-
 3 files changed, 111 insertions(+), 4 deletions(-)

New commits:
commit 21a7c683cf3c16bc274ff1d2acf9f56656ee17c8
Author: Pranav Kant <pranavk at collabora.com>
Date:   Fri Mar 11 20:16:15 2016 +0530

    loleaflet: Column and row headers are selectable now
    
    ... with multi-select shift and ctrl key behavior like desktop
    calc version.
    
    Change-Id: I574037f984ee1844773b0fb8c90c5bb1c079188b

diff --git a/loleaflet/dist/spreadsheet.css b/loleaflet/dist/spreadsheet.css
index 6240514..23df317 100644
--- a/loleaflet/dist/spreadsheet.css
+++ b/loleaflet/dist/spreadsheet.css
@@ -41,6 +41,7 @@
 	border-right: 1px solid darkgrey;
 	border-bottom: 1px solid darkgrey;
 	background-color: lightgrey;
+	cursor: pointer;
 
 	position: absolute;
 	padding: 0px;
@@ -89,6 +90,18 @@
 	padding: 0px;
 	margin: 0px;
 	height: 100%;
+	cursor: pointer;
+
+	/* Make the text unselectable for all browsers */
+	-webkit-touch-callout: none;
+	-webkit-user-select: none;
+	-khtml-user-select: none;
+	-moz-user-select: none;
+	-ms-user-select: none;
+	}
+
+.spreadsheet-header-column:hover {
+	background-color: #DDD;
 	}
 
 .spreadsheet-header-rows-container {
@@ -125,4 +138,16 @@
 	padding: 0px;
 	margin: 0px;
 	height: 100%;
+	cursor: pointer;
+
+	/* Make the text unselectable for all browsers */
+	-webkit-touch-callout: none;
+	-webkit-user-select: none;
+	-khtml-user-select: none;
+	-moz-user-select: none;
+	-ms-user-select: none;
+	}
+
+.spreadsheet-header-row:hover {
+        background-color: #DDD;
 	}
diff --git a/loleaflet/src/control/Control.ColumnHeader.js b/loleaflet/src/control/Control.ColumnHeader.js
index 0091893..9a0cd16 100644
--- a/loleaflet/src/control/Control.ColumnHeader.js
+++ b/loleaflet/src/control/Control.ColumnHeader.js
@@ -2,6 +2,7 @@
 * Control.ColumnHeader
 */
 
+/* global $ */
 L.Control.ColumnHeader = L.Control.extend({
 	onAdd: function (map) {
 		map.on('updatepermission', this._onUpdatePermission, this);
@@ -15,7 +16,8 @@ L.Control.ColumnHeader = L.Control.extend({
 		this._map.on('updateviewport', this.setViewPort, this);
 		this._map.on('viewrowcolumnheaders', this.viewRowColumnHeaders, this);
 		var docContainer = this._map.options.documentContainer;
-		L.DomUtil.create('div', 'spreadsheet-header-corner', docContainer.parentElement);
+		var cornerHeader = L.DomUtil.create('div', 'spreadsheet-header-corner', docContainer.parentElement);
+		L.DomEvent.addListener(cornerHeader, 'click', this._onCornerHeaderClick, this);
 		var headersContainer = L.DomUtil.create('div', 'spreadsheet-header-columns-container', docContainer.parentElement);
 		this._columns = L.DomUtil.create('div', 'spreadsheet-header-columns', headersContainer);
 
@@ -71,7 +73,50 @@ L.Control.ColumnHeader = L.Control.extend({
 			else {
 				L.DomUtil.setStyle(text, 'width', width);
 			}
+
+			L.DomEvent.addListener(text, 'click', this._onColumnHeaderClick, this);
+		}
+	},
+
+	_colAlphaToNumber: function(alpha) {
+		var res = 0;
+		var offset = 'A'.charCodeAt();
+		for (var i = 0; i < alpha.length; i++) {
+			var chr = alpha[alpha.length - i - 1];
+			res += (chr.charCodeAt() - offset + 1) * Math.pow(26, i);
 		}
+
+		return res;
+	},
+
+	_onColumnHeaderClick: function (e) {
+		var colAlpha = e.target.getAttribute('rel').split('spreadsheet-column-')[1];
+		var colNumber = this._colAlphaToNumber(colAlpha);
+
+		var modifier = 0;
+		if (e.shiftKey) {
+			modifier += this._map.keyboard.keyModifier.shift;
+		}
+		if (e.ctrlKey) {
+			modifier += this._map.keyboard.keyModifier.ctrl;
+		}
+
+		var command = {
+			Col: {
+				type: 'unsigned short',
+				value: parseInt(colNumber - 1)
+			},
+			Modifier: {
+				type: 'unsigned short',
+				value: modifier
+			}
+		};
+
+		this._map.sendUnoCommand('.uno:SelectColumn ', command);
+	},
+
+	_onCornerHeaderClick: function() {
+		this._map.sendUnoCommand('.uno:SelectAll');
 	},
 
 	_onUpdatePermission: function () {
diff --git a/loleaflet/src/control/Control.RowHeader.js b/loleaflet/src/control/Control.RowHeader.js
index b7a8e72..fff931a 100644
--- a/loleaflet/src/control/Control.RowHeader.js
+++ b/loleaflet/src/control/Control.RowHeader.js
@@ -2,6 +2,7 @@
  * L.Control.RowHeader
 */
 
+/* global $ */
 L.Control.RowHeader = L.Control.extend({
 	onAdd: function (map) {
 		map.on('updatepermission', this._onUpdatePermission, this);
@@ -70,7 +71,34 @@ L.Control.RowHeader = L.Control.extend({
 				L.DomUtil.setStyle(text, 'line-height', height);
 				L.DomUtil.setStyle(text, 'height', height);
 			}
+
+			L.DomEvent.addListener(text, 'click', this._onRowHeaderClick, this);
+		}
+	},
+
+	_onRowHeaderClick: function (e) {
+		var row = e.target.getAttribute('rel').split('spreadsheet-row-')[1];
+
+		var modifier = 0;
+		if (e.shiftKey) {
+			modifier += this._map.keyboard.keyModifier.shift;
 		}
+		if (e.ctrlKey) {
+			modifier += this._map.keyboard.keyModifier.ctrl;
+		}
+
+		var command = {
+			Row: {
+				type: 'long',
+				value: parseInt(row - 1)
+			},
+			Modifier: {
+				type: 'unsigned short',
+				value: modifier
+			}
+		};
+
+		this._map.sendUnoCommand('.uno:SelectRow ', command);
 	},
 
 	_onUpdatePermission: function () {
commit bfb8b61f083bc8a6e312a3842e0cc5ed7a3cfc9f
Author: Pranav Kant <pranavk at collabora.com>
Date:   Fri Mar 4 13:15:36 2016 +0530

    loleaflet: Fix JS errors
    
    Change-Id: I9740e0a223c43449ce9f40f91b8c90250d1b7560

diff --git a/loleaflet/src/control/Control.ColumnHeader.js b/loleaflet/src/control/Control.ColumnHeader.js
index eababcb..0091893 100644
--- a/loleaflet/src/control/Control.ColumnHeader.js
+++ b/loleaflet/src/control/Control.ColumnHeader.js
@@ -65,10 +65,12 @@ L.Control.ColumnHeader = L.Control.extend({
 			text.setAttribute('rel', 'spreadsheet-column-' + content); // for easy addressing
 			text.innerHTML = content;
 			width = Math.round(converter.call(context, twip).x) - 1 + 'px';
-			if (width === '-1px')
+			if (width === '-1px') {
 				L.DomUtil.setStyle(text, 'display', 'none');
-			else
+			}
+			else {
 				L.DomUtil.setStyle(text, 'width', width);
+			}
 		}
 	},
 
commit d7854df3bd638d51e7aa1d38f5b469680151c108
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Mar 1 11:54:40 2016 +0100

    ccu#1573 loleaflet: hide row headers of hidden rows
    
    This is the row equivalent of commit
    d14fccb67f558f4d0b4612befa70c768956e0e92 (hide column headers of hidden
    columns, 2016-02-26).

diff --git a/loleaflet/src/control/Control.RowHeader.js b/loleaflet/src/control/Control.RowHeader.js
index b69bc02..b7a8e72 100644
--- a/loleaflet/src/control/Control.RowHeader.js
+++ b/loleaflet/src/control/Control.RowHeader.js
@@ -64,8 +64,12 @@ L.Control.RowHeader = L.Control.extend({
 			text.setAttribute('rel', 'spreadsheet-row-' + content); // for easy addressing
 			text.innerHTML = content;
 			height = Math.round(converter.call(context, twip).y) - 1 + 'px';
-			L.DomUtil.setStyle(text, 'line-height', height);
-			L.DomUtil.setStyle(text, 'height', height);
+			if (height === '-1px') {
+				L.DomUtil.setStyle(text, 'display', 'none');
+			} else {
+				L.DomUtil.setStyle(text, 'line-height', height);
+				L.DomUtil.setStyle(text, 'height', height);
+			}
 		}
 	},
 
commit 6e49780fedc7718e1abc4f34ea71d3ae77ccbb38
Author: Andras Timar <andras.timar at collabora.com>
Date:   Fri Feb 26 15:31:18 2016 +0100

    hide column headers of hidden columns

diff --git a/loleaflet/src/control/Control.ColumnHeader.js b/loleaflet/src/control/Control.ColumnHeader.js
index ab640ce..eababcb 100644
--- a/loleaflet/src/control/Control.ColumnHeader.js
+++ b/loleaflet/src/control/Control.ColumnHeader.js
@@ -65,7 +65,10 @@ L.Control.ColumnHeader = L.Control.extend({
 			text.setAttribute('rel', 'spreadsheet-column-' + content); // for easy addressing
 			text.innerHTML = content;
 			width = Math.round(converter.call(context, twip).x) - 1 + 'px';
-			L.DomUtil.setStyle(text, 'width', width);
+			if (width === '-1px')
+				L.DomUtil.setStyle(text, 'display', 'none');
+			else
+				L.DomUtil.setStyle(text, 'width', width);
 		}
 	},
 


More information about the Libreoffice-commits mailing list