[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - bundled/include kit/ChildSession.cpp kit/KitHelper.hpp loleaflet/dist loleaflet/src tools/KitClient.cpp

Marco Cecchetti marco.cecchetti at collabora.com
Tue Mar 20 16:32:57 UTC 2018


 bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h |   10 ++
 kit/ChildSession.cpp                                 |    3 
 kit/KitHelper.hpp                                    |    2 
 loleaflet/dist/images/drop-down-button.svg           |    4 +
 loleaflet/dist/spreadsheet.css                       |   10 ++
 loleaflet/src/layer/marker/Icon.js                   |   15 ++--
 loleaflet/src/layer/tile/TileLayer.js                |   66 +++++++++++++++++++
 tools/KitClient.cpp                                  |    1 
 8 files changed, 105 insertions(+), 6 deletions(-)

New commits:
commit 2280a7e9d4a11a7d82e430f75cb272ad3f5167b1
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Mon Mar 19 14:08:10 2018 +0100

    calc: drop down button marker
    
    Change-Id: Ic069ad40e6749f43709760e7f4f0d96b39d5a4ce
    Reviewed-on: https://gerrit.libreoffice.org/51641
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>

diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h b/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
index ccbc3b96b..d1ac3b3d4 100644
--- a/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -568,6 +568,16 @@ typedef enum
      * - "close" - window is closed
      */
     LOK_CALLBACK_WINDOW = 36,
+
+    /**
+     * When for the current cell is defined a validity list we need to show
+     * a drop down button in the form of a marker.
+     *
+     * The payload format is: "x, y, visible" where x, y are the current
+     * cell cursor coordinates and visible is set to 0 or 1.
+     */
+    LOK_CALLBACK_VALIDITY_LIST_BUTTON = 37,
+
 }
 LibreOfficeKitCallbackType;
 
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 1613e2b30..8c1eab3e4 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -1539,6 +1539,9 @@ void ChildSession::loKitCallback(const int type, const std::string& payload)
     case LOK_CALLBACK_WINDOW:
         sendTextFrame("window: " + payload);
         break;
+    case LOK_CALLBACK_VALIDITY_LIST_BUTTON:
+        sendTextFrame("validitylistbutton: " + payload);
+        break;
     default:
         LOG_ERR("Unknown callback event (" << type << "): " << payload);
     }
diff --git a/kit/KitHelper.hpp b/kit/KitHelper.hpp
index 1cc6b7fb7..d386ea067 100644
--- a/kit/KitHelper.hpp
+++ b/kit/KitHelper.hpp
@@ -117,6 +117,8 @@ namespace LOKitHelper
             return "CELL_ADDRESS";
         case LOK_CALLBACK_WINDOW:
             return "WINDOW";
+        case LOK_CALLBACK_VALIDITY_LIST_BUTTON:
+            return "VALIDITY_LIST_BUTTON";
        }
 
         return std::to_string(type);
diff --git a/loleaflet/dist/images/drop-down-button.svg b/loleaflet/dist/images/drop-down-button.svg
new file mode 100644
index 000000000..f17c44443
--- /dev/null
+++ b/loleaflet/dist/images/drop-down-button.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="11px" height="11px">
+  <path style="fill:#2d2d2d" d="m 2.5011982,3.0013922 5.9508648,0 -2.8796134,5.9972113 z" />
+  <path style="fill:#2d2d2d;fill-rule:evenodd;" d="M 0,0 11,0 11,11 0,11 Z m 1,1 9,0 0,9 -9,0 z"/>
+</svg>
diff --git a/loleaflet/dist/spreadsheet.css b/loleaflet/dist/spreadsheet.css
index e97f60415..4385afa6b 100644
--- a/loleaflet/dist/spreadsheet.css
+++ b/loleaflet/dist/spreadsheet.css
@@ -190,3 +190,13 @@
 .spreadsheet-header-row-resize {
 	cursor: row-resize;
 	}
+
+.spreadsheet-drop-down-marker {
+	margin-left: 0px;
+	margin-top: 0px;
+	width: 18px;
+	height: 17px;
+	background-image: url('../images/drop-down-button.svg');
+	background-size: 100% 100%;
+	background-repeat: no-repeat;
+	}
diff --git a/loleaflet/src/layer/marker/Icon.js b/loleaflet/src/layer/marker/Icon.js
index 58d5fd3c1..856995b23 100644
--- a/loleaflet/src/layer/marker/Icon.js
+++ b/loleaflet/src/layer/marker/Icon.js
@@ -47,10 +47,10 @@ L.Icon = L.Class.extend({
 	},
 
 	_setIconStyles: function (img, name) {
-		var options = this.options,
-		    size = L.point(options[name + 'Size']),
-		    anchor = L.point(name === 'shadow' && options.shadowAnchor || options.iconAnchor ||
-		            size && size.divideBy(2, true));
+		var options = this.options;
+		var size = L.point(options[name + 'Size']);
+		var anchor = L.point(name === 'shadow' && options.shadowAnchor || options.iconAnchor ||
+		            size && size.x !== undefined && size.y !== undefined && size.divideBy(2, true));
 
 		img.className = 'leaflet-marker-' + name + ' ' + (options.className || '');
 
@@ -60,9 +60,12 @@ L.Icon = L.Class.extend({
 		}
 
 		if (size) {
-			img.style.width  = size.x + 'px';
-			img.style.height = size.y + 'px';
+			if (size.x !== undefined)
+				img.style.width  = size.x + 'px';
+			if (size.y !== undefined)
+				img.style.height = size.y + 'px';
 		}
+
 	},
 
 	_createImg: function (src, el) {
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 140f14993..de9351666 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -133,6 +133,14 @@ L.TileLayer = L.GridLayer.extend({
 			});
 		}, this));
 
+		this._dropDownButton = L.marker(new L.LatLng(0, 0), {
+			icon: L.divIcon({
+				className: 'spreadsheet-drop-down-marker',
+				iconSize: null
+			}),
+			interactive: false
+		});
+
 		this._emptyTilesCount = 0;
 		this._msgQueue = [];
 		this._toolbarCommandValues = {};
@@ -477,6 +485,9 @@ L.TileLayer = L.GridLayer.extend({
 		else if (textMsg.startsWith('editor:')) {
 			this._updateEditor(textMsg);
 		}
+		else if (textMsg.startsWith('validitylistbutton:')) {
+			this._onValidityListButtonMsg(textMsg);
+		}
 	},
 
 	toggleTileDebugMode: function() {
@@ -1728,6 +1739,7 @@ L.TileLayer = L.GridLayer.extend({
 
 			if (this._cellCursorMarker) {
 				this._map.removeLayer(this._cellCursorMarker);
+				this._map.removeLayer(this._dropDownButton);
 			}
 			this._cellCursorMarker = L.rectangle(this._cellCursor, {
 				pointerEvents: 'none',
@@ -1739,10 +1751,64 @@ L.TileLayer = L.GridLayer.extend({
 				return;
 			}
 			this._map.addLayer(this._cellCursorMarker);
+
+			this._addDropDownMarker();
 		}
 		else if (this._cellCursorMarker) {
 			this._map.removeLayer(this._cellCursorMarker);
 		}
+		this._removeDropDownMarker();
+	},
+
+	_onValidityListButtonMsg: function(textMsg) {
+		var strXY = textMsg.match(/\d+/g);
+		var validatedCell = new L.Point(parseInt(strXY[0]), parseInt(strXY[1]));
+		var show = parseInt(strXY[2]) === 1;
+		if (show) {
+			if (this._validatedCellXY && !this._validatedCellXY.equals(validatedCell)) {
+				this._validatedCellXY = null;
+				this._removeDropDownMarker();
+			}
+			this._validatedCellXY = validatedCell;
+			this._addDropDownMarker();
+		}
+		else if (this._validatedCellXY && this._validatedCellXY.equals(validatedCell)) {
+			this._validatedCellXY = null;
+			this._removeDropDownMarker();
+		}
+	},
+
+	_addDropDownMarker: function () {
+		if (this._validatedCellXY && this._cellCursorXY && this._validatedCellXY.equals(this._cellCursorXY)) {
+			var pos = this._cellCursor.getNorthEast();
+			var cellCursorHeightPx = this._twipsToPixels(this._cellCursorTwips.getSize()).y;
+			var dropDownMarker = this._getDropDownMarker(cellCursorHeightPx);
+			dropDownMarker.setLatLng(pos);
+			this._map.addLayer(dropDownMarker);
+		}
+	},
+
+	_removeDropDownMarker: function () {
+		if (!this._validatedCellXY && this._dropDownButton)
+			this._map.removeLayer(this._dropDownButton);
+	},
+
+	_getDropDownMarker: function (height) {
+		if (height) {
+			var maxHeight = 27; // it matches the max height of the same control in core
+			var topMargin = 0;
+			if (height > maxHeight) {
+				topMargin = height - maxHeight;
+				height = maxHeight;
+			}
+			var icon =  L.divIcon({
+				className: 'spreadsheet-drop-down-marker',
+				iconSize: [undefined, height],
+				iconAnchor: [0, -topMargin]
+			});
+			this._dropDownButton.setIcon(icon);
+		}
+		return this._dropDownButton;
 	},
 
 	// Update text selection handlers.
diff --git a/tools/KitClient.cpp b/tools/KitClient.cpp
index 4357907c1..fd0531921 100644
--- a/tools/KitClient.cpp
+++ b/tools/KitClient.cpp
@@ -80,6 +80,7 @@ extern "C"
             CASE(CELL_ADDRESS);
             CASE(RULER_UPDATE);
             CASE(WINDOW);
+            CASE(VALIDITY_LIST_BUTTON);
 #undef CASE
         }
         std::cout << " payload: " << payload << std::endl;


More information about the Libreoffice-commits mailing list