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

Tor Lillqvist (via logerrit) logerrit at kemper.freedesktop.org
Fri Dec 13 15:48:03 UTC 2019


 loleaflet/src/control/Control.Menubar.js  |    2 +-
 loleaflet/src/control/Toolbar.js          |    2 +-
 loleaflet/src/core/Socket.js              |    3 ++-
 loleaflet/src/layer/tile/TileLayer.js     |   24 +++++++++++++++---------
 loleaflet/src/map/Map.js                  |    3 ++-
 loleaflet/src/map/handler/Map.Keyboard.js |   15 +++++++++++++++
 6 files changed, 36 insertions(+), 13 deletions(-)

New commits:
commit a985664f713331f2a2c534b55f2318ef66d549e3
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Fri Dec 13 17:05:25 2019 +0200
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Fri Dec 13 16:47:43 2019 +0100

    tdf#129328 Try to make Copy/Paste work sanely in the iOS app again
    
    We don't want any of the stuff in loleaflet/src/map/Clipboard.js to be
    involved at all. On iOS we have an interface to the system clipboard
    in core. Just use that. No need to keep any local cached clipboard in
    the Javascript. No "download" involved. Just let .uno:Cut etc do their
    job. Keep the _clip attribute property of the L.Map object undefined
    on iOS, and check if before trying to use it.
    
    As such I couldn't exactly reproduce the problem in the bug report,
    but hopefully this works.
    
    Change-Id: I2623221b87e729bb60e34f40ed42d5f499c4c25f
    Reviewed-on: https://gerrit.libreoffice.org/85124
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index 2b8af4510..d5d990095 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -1173,7 +1173,7 @@ L.Control.Menubar = L.Control.extend({
 			// Toggle between showing master page and closing it.
 			unoCommand = ($(item).hasClass('lo-menu-item-checked') ? '.uno:CloseMasterView' : '.uno:SlideMasterPage');
 		}
-		else if (this._map._clip.filterExecCopyPaste(unoCommand)) {
+		else if (this._map._clip && this._map._clip.filterExecCopyPaste(unoCommand)) {
 			return;
 		}
 
diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js
index 1a353ff67..1dd4b37f3 100644
--- a/loleaflet/src/control/Toolbar.js
+++ b/loleaflet/src/control/Toolbar.js
@@ -442,7 +442,7 @@ L.Map.include({
 		if (this.hyperlinkUnderCursor && this.hyperlinkUnderCursor.text && this.hyperlinkUnderCursor.link) {
 			text = this.hyperlinkUnderCursor.text;
 			link = this.hyperlinkUnderCursor.link;
-		} else if (this._clip._selectionType == 'text') {
+		} else if (this._clip && this._clip._selectionType == 'text') {
 			text = this.extractContent(this._clip._selectionContent);
 		}
 
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 38c175d57..706234980 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -311,7 +311,8 @@ L.Socket = L.Class.extend({
 		}
 		else if (textMsg.startsWith('clipboardkey: ')) {
 			var key = textMsg.substring('clipboardkey: '.length);
-			this._map._clip.setKey(key);
+			if (this._map._clip)
+				this._map._clip.setKey(key);
 		}
 		else if (textMsg.startsWith('perm:')) {
 			var perm = textMsg.substring('perm:'.length);
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 491d14731..af8a24fda 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -595,7 +595,8 @@ L.TileLayer = L.GridLayer.extend({
 			this._onTextSelectionMsg(textMsg);
 		}
 		else if (textMsg.startsWith('textselectioncontent:')) {
-			this._map._clip.setTextSelectionHTML(textMsg.substr(22));
+			if (this._map._clip)
+				this._map._clip.setTextSelectionHTML(textMsg.substr(22));
 		}
 		else if (textMsg.startsWith('textselectionend:')) {
 			this._onTextSelectionEndMsg(textMsg);
@@ -610,7 +611,8 @@ L.TileLayer = L.GridLayer.extend({
 			this._onCellAutoFillAreaMsg(textMsg);
 		}
 		else if (textMsg.startsWith('complexselection:')) {
-			this._map._clip.onComplexSelection(textMsg.substr('complexselection:'.length));
+			if (this._map._clip)
+				this._map._clip.onComplexSelection(textMsg.substr('complexselection:'.length));
 		}
 		else if (textMsg.startsWith('tile:')) {
 			this._onTileMsg(textMsg, img);
@@ -730,7 +732,7 @@ L.TileLayer = L.GridLayer.extend({
 		// When the user moves the focus to a different cell, a 'cellformula'
 		// message is received from lowsd, *then* a 'celladdress' message.
 		var address = textMsg.substring(13);
-		if (!this._map['wopi'].DisableCopy) {
+		if (this._map._clip && !this._map['wopi'].DisableCopy) {
 			this._map._clip.setTextSelectionText(this._lastFormula);
 		}
 		this._map.fire('celladdress', {address: address});
@@ -954,7 +956,8 @@ L.TileLayer = L.GridLayer.extend({
 		}
 
 		// Graphics are by default complex selections, unless Core tells us otherwise.
-		this._map._clip.onComplexSelection('');
+		if (this._map._clip)
+			this._map._clip.onComplexSelection('');
 		if (this._selectionContentRequest) {
 			clearTimeout(this._selectionContentRequest);
 		}
@@ -1947,7 +1950,8 @@ L.TileLayer = L.GridLayer.extend({
 		this._onUpdateGraphicSelection();
 		this._cellCursor = null;
 		this._onUpdateCellCursor();
-		this._map._clip.clearSelection();
+		if (this._map._clip)
+			this._map._clip.clearSelection();
 	},
 
 	containsSelection: function (latlng) {
@@ -3023,10 +3027,12 @@ L.TileLayer = L.GridLayer.extend({
 		e = e.originalEvent;
 		e.preventDefault();
 
-		// Always capture the html content separate as we may lose it when we
-		// pass the clipboard data to a different context (async calls, f.e.).
-		var htmlText = e.dataTransfer.getData('text/html');
-		this._map._clip.dataTransferToDocument(e.dataTransfer, /* preferInternal = */ false, htmlText);
+		if (this._map._clip) {
+			// Always capture the html content separate as we may lose it when we
+			// pass the clipboard data to a different context (async calls, f.e.).
+			var htmlText = e.dataTransfer.getData('text/html');
+			this._map._clip.dataTransferToDocument(e.dataTransfer, /* preferInternal = */ false, htmlText);
+		}
 	},
 
 	_onDragStart: function () {
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 8e9f98d45..ed03f6098 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -58,7 +58,8 @@ L.Map = L.Evented.extend({
 			this.options.documentContainer = L.DomUtil.get(this.options.documentContainer);
 		}
 
-		this._clip = L.clipboard(this);
+		if (!window.ThisIsTheiOSApp)
+			this._clip = L.clipboard(this);
 		this._initContainer(id);
 		this._initLayout();
 
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index 4c9e8e9b2..9eaf92784 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -474,6 +474,21 @@ L.Map.Keyboard = L.Handler.extend({
 			return false;
 		}
 
+		if (window.ThisIsTheiOSApp) {
+			if (e.key === 'c' || e.key === 'C') {
+				this._map._socket.sendMessage('uno .uno:Copy');
+				return true;
+			}
+			else if (e.key === 'v' || e.key === 'V') {
+				this._map._socket.sendMessage('uno .uno:Paste');
+				return true;
+			}
+			else if (e.key === 'x' || e.key === 'X') {
+				this._map._socket.sendMessage('uno .uno:Cut');
+				return true;
+			}
+		}
+
 		switch (e.keyCode) {
 		case 51: // 3
 			if (this._map.getDocType() === 'spreadsheet') {


More information about the Libreoffice-commits mailing list