[Libreoffice-commits] online.git: 2 commits - kit/ChildSession.cpp loleaflet/css loleaflet/images loleaflet/src

Szymon Kłos (via logerrit) logerrit at kemper.freedesktop.org
Sat Sep 28 14:57:15 UTC 2019


 kit/ChildSession.cpp                     |    5 +
 loleaflet/css/toolbar.css                |    1 
 loleaflet/images/lc_functiondialog.svg   |    1 
 loleaflet/src/control/Control.Tabs.js    |    1 
 loleaflet/src/control/Control.Toolbar.js |    2 
 loleaflet/src/control/Parts.js           |    1 
 loleaflet/src/layer/tile/TileLayer.js    |   83 +++++++++++++++++++++++++++++++
 loleaflet/src/unocommands.js             |    1 
 8 files changed, 92 insertions(+), 3 deletions(-)

New commits:
commit d712d97e3c7ac84352001405dc5f1fa9ac5a3630
Author:     Szymon Kłos <eszkadev at gmail.com>
AuthorDate: Wed Oct 3 20:51:32 2018 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sat Sep 28 16:42:19 2019 +0200

    Draw reference marks for formulas
    
    (cherry picked from commit fd1b3b2a744388309fbbbcb73b2060183780109e)
    
    Change-Id: I3e361bd94cd6e0664e96494504064c2505c30774

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 1f4ea15a5..815a8c54d 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -2111,7 +2111,8 @@ void ChildSession::rememberEventsForInactiveUser(const int type, const std::stri
              type == LOK_CALLBACK_GRAPHIC_SELECTION ||
              type == LOK_CALLBACK_DOCUMENT_SIZE_CHANGED ||
              type == LOK_CALLBACK_INVALIDATE_HEADER ||
-             type == LOK_CALLBACK_CELL_ADDRESS)
+             type == LOK_CALLBACK_CELL_ADDRESS ||
+             type == LOK_CALLBACK_REFERENCE_MARKS)
     {
         std::unique_lock<std::mutex> lock(getLock());
         _stateRecorder.recordEvent(type, payload);
@@ -2400,7 +2401,7 @@ void ChildSession::loKitCallback(const int type, const std::string& payload)
         sendTextFrame("tableselected: " + payload);
         break;
     case LOK_CALLBACK_REFERENCE_MARKS:
-        // TODO
+        sendTextFrame("referencemarks: " + payload);
         break;
     case LOK_CALLBACK_JSDIALOG:
         sendTextFrame("jsdialog: " + payload);
diff --git a/loleaflet/src/control/Control.Tabs.js b/loleaflet/src/control/Control.Tabs.js
index 5855c584e..eac204c3b 100644
--- a/loleaflet/src/control/Control.Tabs.js
+++ b/loleaflet/src/control/Control.Tabs.js
@@ -165,6 +165,7 @@ L.Control.Tabs = L.Control.extend({
 	_setPart: function (e) {
 		var part =  e.target.id.match(/\d+/g)[0];
 		if (part !== null) {
+			this._map._docLayer._clearReferences();
 			this._map.setPart(parseInt(part), /*external:*/ false, /*calledFromSetPartHandler:*/ true);
 		}
 	}
diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js
index 95e5bc2a0..5acee51fb 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -19,6 +19,7 @@ L.Map.include({
 		}
 		else if (typeof (part) === 'number' && part >= 0 && part < docLayer._parts) {
 			docLayer._selectedPart = part;
+			docLayer._updateReferenceMarks();
 		}
 		else {
 			return;
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 08a8abafc..8a39c97b7 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -25,6 +25,24 @@ function hex2string(inData)
 	return hexified.join('');
 }
 
+function marksAreEqual(mark1, mark2)
+{
+	return mark1._bounds._northEast.lat == mark2._bounds._northEast.lat
+		&& mark1._bounds._northEast.lng == mark2._bounds._northEast.lng
+		&& mark1._bounds._southWest.lat == mark2._bounds._southWest.lat
+		&& mark1._bounds._southWest.lng == mark2._bounds._southWest.lng;
+}
+
+function hasMark(collection, mark)
+{
+	for (var i = 0; i < collection.length; i++) {
+		if (marksAreEqual(mark, collection[i])) {
+			return true;
+		}
+	}
+	return false;
+}
+
 L.TileLayer = L.GridLayer.extend({
 
 	options: {
@@ -179,8 +197,10 @@ L.TileLayer = L.GridLayer.extend({
 		this._initContainer();
 		this._getToolbarCommandsValues();
 		this._selections = new L.LayerGroup();
+		this._references = new L.LayerGroup();
 		if (this.options.permission !== 'readonly') {
 			map.addLayer(this._selections);
+			map.addLayer(this._references);
 		}
 
 		// This layergroup contains all the layers corresponding to other's view
@@ -415,6 +435,12 @@ L.TileLayer = L.GridLayer.extend({
 		else if (textMsg.startsWith('cellformula:')) {
 			this._onCellFormulaMsg(textMsg);
 		}
+		else if (textMsg.startsWith('referencemarks:')) {
+			this._onReferencesMsg(textMsg);
+		}
+		else if (textMsg.startsWith('referenceclear:')) {
+			this._clearReferences();
+		}
 		else if (textMsg.startsWith('hyperlinkclicked:')) {
 			this._onHyperlinkClickedMsg(textMsg);
 		}
@@ -1348,6 +1374,59 @@ L.TileLayer = L.GridLayer.extend({
 		this._onUpdateTextViewSelection(viewId);
 	},
 
+	_updateReferenceMarks: function() {
+		this._clearReferences();
+		for (var i = 0; i < this._referencesAll.length; i++) {
+			// Avoid doubed marks, add only marks for current sheet
+			if ((this._references == null || !hasMark(this._references.getLayers(), this._referencesAll[i].mark))
+				&& this._selectedPart === this._referencesAll[i].part) {
+				this._references.addLayer(this._referencesAll[i].mark);
+			}
+		}
+	},
+
+	_onReferencesMsg: function (textMsg) {
+		textMsg = textMsg.substr(textMsg.indexOf(' ') + 1);
+		var marks = JSON.parse(textMsg);
+		marks = marks.marks;
+		var references = [];
+		this._referencesAll = [];
+
+		for (var mark = 0; mark < marks.length; mark++) {
+			var strTwips = marks[mark].rectangle.match(/\d+/g);
+			var strColor = marks[mark].color;
+			var part = parseInt(marks[mark].part);
+
+			if (strTwips != null) {
+				var rectangles = [];
+				for (var i = 0; i < strTwips.length; i += 4) {
+					var topLeftTwips = new L.Point(parseInt(strTwips[i]), parseInt(strTwips[i + 1]));
+					var offset = new L.Point(parseInt(strTwips[i + 2]), parseInt(strTwips[i + 3]));
+					var topRightTwips = topLeftTwips.add(new L.Point(offset.x, 0));
+					var bottomLeftTwips = topLeftTwips.add(new L.Point(0, offset.y));
+					var bottomRightTwips = topLeftTwips.add(offset);
+					rectangles.push([bottomLeftTwips, bottomRightTwips, topLeftTwips, topRightTwips]);
+				}
+
+				var polygons = L.PolyUtil.rectanglesToPolygons(rectangles, this);
+				var reference = new L.Polygon(polygons, {
+					pointerEvents: 'none',
+					fillColor: '#' + strColor,
+					fillOpacity: 0.25,
+					weight: 2,
+					opacity: 0.25});
+
+				references.push({mark: reference, part: part});
+			}
+		}
+
+		for (i = 0; i < references.length; i++) {
+			this._referencesAll.push(references[i]);
+		}
+
+		this._updateReferenceMarks();
+	},
+
 	_onTextSelectionContentMsg: function (textMsg) {
 		this._selectionTextContent = textMsg.substr(22);
 		this._map._clipboardContainer.setValue(this._selectionTextContent);
@@ -1671,6 +1750,10 @@ L.TileLayer = L.GridLayer.extend({
 		return ret;
 	},
 
+	_clearReferences: function () {
+		this._references.clearLayers();
+	},
+
 	_postMouseEvent: function(type, x, y, count, buttons, modifier) {
 
 		this._sendClientZoom();
commit 9276ac2da166fda1bef383e570591c8bac831f42
Author:     Szymon Kłos <eszkadev at gmail.com>
AuthorDate: Wed Oct 3 20:54:31 2018 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sat Sep 28 16:40:15 2019 +0200

    Added formula dialog to the toolbar
    
    Change-Id: Ic7b6da86660824acefa02e203601d912aba7ba2e

diff --git a/loleaflet/css/toolbar.css b/loleaflet/css/toolbar.css
index fcf000081..b69c9bc23 100644
--- a/loleaflet/css/toolbar.css
+++ b/loleaflet/css/toolbar.css
@@ -586,6 +586,7 @@ button.leaflet-control-search-next
 .w2ui-icon.insertobjectchart{ background: url('images/lc_drawchart.svg') no-repeat center !important; }
 .w2ui-icon.autosum{ background: url('images/lc_autosum.svg') no-repeat center !important; }
 
+.w2ui-icon.functiondialog{ background: url('images/lc_functiondialog.svg') no-repeat center !important; }
 .w2ui-icon.accepttrackedchanges{ background: url('images/lc_accepttrackedchanges.svg') no-repeat center !important; }
 .w2ui-icon.cancel{ background: url('images/lc_cancel.svg') no-repeat center !important; }
 .w2ui-icon.color{ background: url('images/lc_color.svg') no-repeat center !important; }
diff --git a/loleaflet/images/lc_functiondialog.svg b/loleaflet/images/lc_functiondialog.svg
new file mode 100644
index 000000000..ef807006a
--- /dev/null
+++ b/loleaflet/images/lc_functiondialog.svg
@@ -0,0 +1 @@
+<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><g fill="#4d82b8"><path d="m8.4921985 9.429259-1.090909 9.199278-.6166 2.131246q-.166008.602047-.52174.915112-.355732.325105-.996048.325105h-1.221343l1.505928-12.570741-.936758-.180613q-.296443-.0602-.474309-.228778-.177865-.180614-.130434-.517761l.142292-1.240216h1.660079l.10672-.830826q.118577-1.0234791.533597-1.842263.426877-.8308248 1.07905-1.396749.664032-.5779651 1.517788-.8789885.853755-.3130645 1.8498025-.3130645.735178 0 1.434783.2167369l-.272728 1.5773632q-.05929.2769416-.332016.3371462-.272727.060205-.6166.060205-.486167 0-.889329.1204094-.4031615.1204094-.7114625.397351-.296442.2769415-.498024.7224564-.189723.4455147-.26087 1.0957249l-.08301.734498h2.7391315l-.260869 2.167368h-2.6561275z"/><path d="m15.644396 16.602206-2.053045-4.602214h2.27898q.245579 0 .353634.0705.108055.0705.18664.241692l1.119844 2.819737q.04911-.110775.108054-.21148.06877-.110775.147348-.22155l1.394894-2.346424q.127701-.1712.255403-.261834.
 127701-.09063.304518-.09063h2.259334l-3.231829 4.582073 2.269157 5.417924h-2.269157q-.255404 0-.392928-.140986-.137525-.140988-.21611-.322256l-1.257367-3.313192q-.04912.100705-.09823.18127-.04912.08057-.09823.161127l-1.827113 2.970795q-.127701.171199-.284872.322256-.157172.140986-.383105.140986h-2.210217l3.644402-5.397783z"/></g></svg>
\ No newline at end of file
diff --git a/loleaflet/src/control/Control.Toolbar.js b/loleaflet/src/control/Control.Toolbar.js
index 4be262f31..0776c8e61 100644
--- a/loleaflet/src/control/Control.Toolbar.js
+++ b/loleaflet/src/control/Control.Toolbar.js
@@ -900,7 +900,7 @@ function initNormalToolbar() {
 			{type: 'html',  id: 'left'},
 			{type: 'html', id: 'address', html: '<input id="addressInput" type="text">'},
 			{type: 'break'},
-			{type: 'button',  id: 'functiondialog', img: 'functiondialog', hint: _('Function Wizard'), uno: '.uno:FunctionDialog'},
+			{type: 'button',  id: 'functiondialog', img: 'functiondialog', hint: _UNO('.uno:FunctionDialog', '', true), uno: '.uno:FunctionDialog'},
 			{type: 'button',  id: 'sum',  img: 'autosum', hint: _('Sum')},
 			{type: 'button',  id: 'function',  img: 'equal', hint: _('Function')},
 			{type: 'button', hidden: true, id: 'cancelformula',  img: 'cancel', hint: _('Cancel')},
diff --git a/loleaflet/src/unocommands.js b/loleaflet/src/unocommands.js
index 6db9638dc..6622a9a9b 100644
--- a/loleaflet/src/unocommands.js
+++ b/loleaflet/src/unocommands.js
@@ -87,6 +87,7 @@ var unoCommandsArray = {
 	FormatTextMenu:{global:{menu:_('Te~xt'),},},
 	FormattingMarkMenu:{global:{menu:_('Formatting Mark'),},},
 	FullScreen:{global:{menu:_('F~ull Screen'),},},
+	FunctionDialog:{spreadsheet:{menu:_('~Function...'),},},
 	GoalSeekDialog:{spreadsheet:{menu:_('~Goal Seek...'),},},
 	Group:{global:{menu:_('~Group...'),},},
 	GroupOutlineMenu:{spreadsheet:{menu:_('~Group and Outline'),},},


More information about the Libreoffice-commits mailing list