diff options
author | Tor Lillqvist <tml@collabora.com> | 2019-12-13 17:05:25 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-12-13 16:47:43 +0100 |
commit | a985664f713331f2a2c534b55f2318ef66d549e3 (patch) | |
tree | 6d99ae361c6dc2a63b52cb639b9c448e64588cd6 | |
parent | 31730de94731ad1aa8e55633129e80aded63ed62 (diff) |
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@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r-- | loleaflet/src/control/Control.Menubar.js | 2 | ||||
-rw-r--r-- | loleaflet/src/control/Toolbar.js | 2 | ||||
-rw-r--r-- | loleaflet/src/core/Socket.js | 3 | ||||
-rw-r--r-- | loleaflet/src/layer/tile/TileLayer.js | 24 | ||||
-rw-r--r-- | loleaflet/src/map/Map.js | 3 | ||||
-rw-r--r-- | loleaflet/src/map/handler/Map.Keyboard.js | 15 |
6 files changed, 36 insertions, 13 deletions
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') { |