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

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 17 08:54:14 UTC 2020


 loleaflet/src/map/Clipboard.js |   59 +++++++++++++++++++++++++----------------
 1 file changed, 37 insertions(+), 22 deletions(-)

New commits:
commit 0133a73e0a72795d9d1f7ec906aa9be32195f032
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Thu Jul 16 10:47:05 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri Jul 17 10:54:07 2020 +0200

    clipboard: paste in dialog if open
    
    This fixes the issue where 'complex' content was copied
    and then when dialog was opened and user used Ctrl+V,
    internal paste into document was performed instead
    od pasting into dialog.
    
    Change-Id: I540a98484610916ff7c246f08a9772fbff40b3ec
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98877
    Tested-by: Jenkins
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/loleaflet/src/map/Clipboard.js b/loleaflet/src/map/Clipboard.js
index 918729601..53c62364e 100644
--- a/loleaflet/src/map/Clipboard.js
+++ b/loleaflet/src/map/Clipboard.js
@@ -336,7 +336,7 @@ L.Clipboard = L.Class.extend({
 		{
 			// Home from home: short-circuit internally.
 			console.log('short-circuit, internal paste');
-			this._map._socket.sendMessage('uno .uno:Paste');
+			this._doInternalPaste(this._map, usePasteKeyEvent);
 			return;
 		}
 
commit b233aa2ad3f8b1a21c8623b6b62f4ae36004adb9
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Thu Jul 16 10:29:39 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri Jul 17 10:53:54 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 <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/loleaflet/src/map/Clipboard.js b/loleaflet/src/map/Clipboard.js
index c596cd95a..918729601 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)
 		{


More information about the Libreoffice-commits mailing list