loleaflet/src/map/Clipboard.js | 57 +++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 21 deletions(-)
New commits: commit 4a0676f16f030bae7a39e02f5defd422d666b06f Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Thu Jul 16 10:29:39 2020 +0200 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Tue Jul 21 10:41:00 2020 +0200 clipboard: when disabled use only internal commands When external copy/paste is disabled: - always use internal copy/paste - don't ask user to use keyboard shortcut (it's possible to paste from menu) - content of a system clipboard is not modified at all Change-Id: I5645ad68bbf9364124ae721ea0e889d877a4ed23 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98876 Tested-by: Jenkins Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98941 Reviewed-by: Aron Budea <aron.bu...@collabora.com> diff --git a/loleaflet/src/map/Clipboard.js b/loleaflet/src/map/Clipboard.js index 3e03f973b..18678b389 100644 --- a/loleaflet/src/map/Clipboard.js +++ b/loleaflet/src/map/Clipboard.js @@ -139,16 +139,6 @@ L.Clipboard = L.Class.extend({ )); }, - // put in the clipboard if copy is disabled - _getCopyDisabledHtml: function() { - var lang = 'en_US'; // FIXME: l10n - return this._substProductName(this._originWrapBody( - ' <body lang="' + lang + '" dir="ltr">\n' + - ' <p></p>\n' + - ' </body>\n', false - )); - }, - _getMetaOrigin: function (html) { var match = '<meta name="origin" content="'; var start = html.indexOf(match); @@ -416,14 +406,7 @@ L.Clipboard = L.Class.extend({ this._doAsyncDownload('POST', this.getMetaURL(), formData, function() { console.log('Posted ' + content.size + ' bytes successfully'); - if (usePasteKeyEvent) { - // paste into dialog - var KEY_PASTE = 1299; - that._map._textInput._sendKeyEvent(0, KEY_PASTE); - } else { - // paste into document - that._map._socket.sendMessage('uno .uno:Paste'); - } + that._doInternalPaste(that._map, usePasteKeyEvent); }, function(progress) { return progress; } ); @@ -440,8 +423,6 @@ L.Clipboard = L.Class.extend({ _getHtmlForClipboard: function() { var text; - if (this._map['wopi'].DisableCopy) - return this._getCopyDisabledHtml(); if (this._selectionType === 'complex' || this._map._docLayer.hasGraphicSelection()) { @@ -641,6 +622,21 @@ L.Clipboard = L.Class.extend({ return false; } + if (this._map['wopi'].DisableCopy) { + // perform internal operations + + if (cmd === '.uno:Copy' || cmd === '.uno:Cut') { + this._map._socket.sendMessage('uno ' + cmd); + } else if (cmd === '.uno:Paste') { + var dummyEvent = {preventDefault: function() {}}; + this.paste(dummyEvent); + } else { + return false; + } + + return true; + } + if (cmd === '.uno:Copy') { this._execCopyCutPaste('copy'); } else if (cmd === '.uno:Cut') { @@ -656,7 +652,7 @@ L.Clipboard = L.Class.extend({ _doCopyCut: function(ev, unoName) { console.log(unoName); - var preventDefault = this.populateClipboard(ev); + var preventDefault = this._map['wopi'].DisableCopy === true ? true : this.populateClipboard(ev); this._map._socket.sendMessage('uno .uno:' + unoName); if (preventDefault) { ev.preventDefault(); @@ -664,6 +660,17 @@ L.Clipboard = L.Class.extend({ } }, + _doInternalPaste: function(map, usePasteKeyEvent) { + if (usePasteKeyEvent) { + // paste into dialog + var KEY_PASTE = 1299; + map._textInput._sendKeyEvent(0, KEY_PASTE); + } else { + // paste into document + map._socket.sendMessage('uno .uno:Paste'); + } + }, + cut: function(ev) { return this._doCopyCut(ev, 'Cut'); }, copy: function(ev) { return this._doCopyCut(ev, 'Copy'); }, @@ -681,6 +688,14 @@ L.Clipboard = L.Class.extend({ if (this._map._activeDialog) ev.usePasteKeyEvent = true; + if (this._map['wopi'].DisableCopy) + { + ev.preventDefault(); + this._doInternalPaste(this._map, ev.usePasteKeyEvent); + + return false; + } + var that = this; if (L.Browser.isInternetExplorer) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits