[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-7' - loleaflet/src

Jan Holesovsky kendy at collabora.com
Fri Jan 22 07:27:41 PST 2016


 loleaflet/src/layer/tile/TileLayer.js |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

New commits:
commit 937a35f5dc7d6173b6a7950083bb777687923086
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Jan 22 16:26:46 2016 +0100

    loleaflet: Implement rich copy / paste inside the document.

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index d1544aa..22d8306 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1010,6 +1010,10 @@ L.TileLayer = L.GridLayer.extend({
 		e.preventDefault();
 		if (this._selectionTextContent) {
 			L.Compatibility.clipboardSet(e, this._selectionTextContent);
+
+			// remember the copied text, for rich copy/paste inside a document
+			this._selectionTextHash = this._selectionTextContent;
+			this._map._socket.sendMessage('uno .uno:Copy');
 		}
 	},
 
@@ -1018,6 +1022,9 @@ L.TileLayer = L.GridLayer.extend({
 		e.preventDefault();
 		if (this._selectionTextContent) {
 			L.Compatibility.clipboardSet(e, this._selectionTextContent);
+
+			// remember the copied text, for rich copy/paste inside a document
+			this._selectionTextHash = this._selectionTextContent;
 			this._map._socket.sendMessage('uno .uno:Cut');
 		}
 	},
@@ -1027,7 +1034,14 @@ L.TileLayer = L.GridLayer.extend({
 		e.preventDefault();
 		var pasteString = L.Compatibility.clipboardGet(e);
 		if (pasteString) {
-			this._map._socket.sendMessage('paste mimetype=text/plain;charset=utf-8\n' + pasteString);
+			if (pasteString === this._selectionTextHash) {
+				// content of the clipboard did not change, we can do rich
+				// paste
+				this._map._socket.sendMessage('uno .uno:Paste');
+			}
+			else {
+				this._map._socket.sendMessage('paste mimetype=text/plain;charset=utf-8\n' + pasteString);
+			}
 		}
 	},
 


More information about the Libreoffice-commits mailing list