[Libreoffice-commits] online.git: 2 commits - loleaflet/src loolwsd/LOOLSession.cpp loolwsd/LOOLSession.hpp loolwsd/protocol.txt
Miklos Vajna
vmiklos at collabora.co.uk
Tue Oct 27 11:16:55 UTC 2015
loleaflet/src/layer/tile/TileLayer.js | 7 +++++++
loleaflet/src/map/Map.js | 4 ++--
loolwsd/LOOLSession.cpp | 24 ++++++++++++++++++++++++
loolwsd/LOOLSession.hpp | 1 +
loolwsd/protocol.txt | 4 ++++
5 files changed, 38 insertions(+), 2 deletions(-)
New commits:
commit 3588a2c2600a83874dca57bdeb299823edb0d59e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Oct 27 12:16:33 2015 +0100
loleaflet: map JS paste to loolwsd paste message
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 5b1aad0..97b8714 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -105,6 +105,7 @@ L.TileLayer = L.GridLayer.extend({
this._viewReset();
map.on('drag resize zoomend', this._updateScrollOffset, this);
map.on('copy', this._onCopy, this);
+ map.on('paste', this._onPaste, this);
map.on('zoomend', this._onUpdateCursor, this);
map.on('zoomend', this._onUpdatePartPageRectangles, this);
map.on('dragstart', this._onDragStart, this);
@@ -757,6 +758,12 @@ L.TileLayer = L.GridLayer.extend({
}
},
+ _onPaste: function (e) {
+ e = e.originalEvent;
+ e.preventDefault();
+ L.Socket.sendMessage('paste mimetype=text/plain;charset=utf-8 data=' + e.clipboardData.getData('text/plain'));
+ },
+
_onDragStart: function () {
this._map.on('moveend', this._updateScrollOffset, this);
},
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index a0ced6d..f79ace4 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -574,7 +574,7 @@ L.Map = L.Evented.extend({
L.DomEvent[onOff](this._container, 'click dblclick mousedown mouseup ' +
'mouseover mouseout mousemove contextmenu keydown keypress keyup', this._handleDOMEvent, this);
- L.DomEvent[onOff](this._textArea, 'copy keydown keypress keyup', this._handleDOMEvent, this);
+ L.DomEvent[onOff](this._textArea, 'copy paste keydown keypress keyup', this._handleDOMEvent, this);
if (this.options.trackResize) {
L.DomEvent[onOff](this._resizeDetector.contentWindow, 'resize', this._onResize, this);
@@ -627,7 +627,7 @@ L.Map = L.Evented.extend({
var data = {
originalEvent: e
};
- if (e.type !== 'keypress' && e.type !== 'keyup' && e.type !== 'keydown' && e.type !== 'copy') {
+ if (e.type !== 'keypress' && e.type !== 'keyup' && e.type !== 'keydown' && e.type !== 'copy' && e.type !== 'paste') {
data.containerPoint = target instanceof L.Marker ?
this.latLngToContainerPoint(target.getLatLng()) : this.mouseEventToContainerPoint(e);
data.layerPoint = this.containerPointToLayerPoint(data.containerPoint);
commit cc24463f08239b1591ed892ed9655126b0de64dd
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Oct 27 10:40:40 2015 +0100
loolwsd: wrap lok::Document::paste()
diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index c46ec93..12c75f4 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -321,6 +321,7 @@ bool MasterProcessSession::handleInput(const char *buffer, int length)
tokens[0] != "downloadas" &&
tokens[0] != "getchildid" &&
tokens[0] != "gettextselection" &&
+ tokens[0] != "paste" &&
tokens[0] != "insertfile" &&
tokens[0] != "invalidatetiles" &&
tokens[0] != "key" &&
@@ -739,6 +740,7 @@ bool ChildProcessSession::handleInput(const char *buffer, int length)
assert(tokens[0] == "downloadas" ||
tokens[0] == "getchildid" ||
tokens[0] == "gettextselection" ||
+ tokens[0] == "paste" ||
tokens[0] == "insertfile" ||
tokens[0] == "key" ||
tokens[0] == "mouse" ||
@@ -764,6 +766,10 @@ bool ChildProcessSession::handleInput(const char *buffer, int length)
{
return getTextSelection(buffer, length, tokens);
}
+ else if (tokens[0] == "paste")
+ {
+ return paste(buffer, length, tokens);
+ }
else if (tokens[0] == "insertfile")
{
return insertFile(buffer, length, tokens);
@@ -1107,6 +1113,24 @@ bool ChildProcessSession::getTextSelection(const char* /*buffer*/, int /*length*
return true;
}
+bool ChildProcessSession::paste(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
+{
+ std::string mimeType;
+ std::string data;
+
+ if (tokens.count() < 3 || !getTokenString(tokens[1], "mimetype", mimeType) || !getTokenString(tokens[2], "data", data))
+ {
+ sendTextFrame("error: cmd=paste kind=syntax");
+ return false;
+ }
+
+ data = Poco::cat(std::string(" "), tokens.begin() + 2, tokens.end()).substr(strlen("data="));
+
+ _loKitDocument->pClass->paste(_loKitDocument, mimeType.c_str(), data.c_str(), std::strlen(data.c_str()));
+
+ return true;
+}
+
bool ChildProcessSession::insertFile(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
std::string name, type;
diff --git a/loolwsd/LOOLSession.hpp b/loolwsd/LOOLSession.hpp
index b8eb7e1..e84b5d1 100644
--- a/loolwsd/LOOLSession.hpp
+++ b/loolwsd/LOOLSession.hpp
@@ -187,6 +187,7 @@ public:
bool downloadAs(const char *buffer, int length, Poco::StringTokenizer& tokens);
bool getChildId();
bool getTextSelection(const char *buffer, int length, Poco::StringTokenizer& tokens);
+ bool paste(const char *buffer, int length, Poco::StringTokenizer& tokens);
bool insertFile(const char *buffer, int length, Poco::StringTokenizer& tokens);
bool keyEvent(const char *buffer, int length, Poco::StringTokenizer& tokens);
bool mouseEvent(const char *buffer, int length, Poco::StringTokenizer& tokens);
diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt
index e3ce9e4..085813a 100644
--- a/loolwsd/protocol.txt
+++ b/loolwsd/protocol.txt
@@ -31,6 +31,10 @@ gettextselection mimetype=<mimeType>
Request selection's content
+paste mimetype=<mimeType> data=<data>
+
+ Paste content at the current cursor position.
+
insertfile name=<name> type=<type>
Inserts the file with the name <name> into the document, we currently support type = 'graphic'
More information about the Libreoffice-commits
mailing list