[Libreoffice-commits] online.git: Branch 'libreoffice-6-4' - loleaflet/src wsd/ClientSession.cpp
Michael Meeks (via logerrit)
logerrit at kemper.freedesktop.org
Wed Nov 27 21:23:13 UTC 2019
loleaflet/src/control/Control.DownloadProgress.js | 2 -
loleaflet/src/layer/tile/TileLayer.js | 4 +-
loleaflet/src/map/Clipboard.js | 42 +++++++++++++++-------
wsd/ClientSession.cpp | 5 ++
4 files changed, 36 insertions(+), 17 deletions(-)
New commits:
commit a17bb5991ac81a903733aa6601e3a2aec94a8467
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Wed Nov 27 19:05:57 2019 +0000
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Wed Nov 27 21:22:50 2019 +0000
fix calc simple, single cell content copy; add origin to plain text.
Change-Id: I7a6b0c90a74f6e3a91a840bf77c0935a300321f2
diff --git a/loleaflet/src/control/Control.DownloadProgress.js b/loleaflet/src/control/Control.DownloadProgress.js
index 8df498997..2fce6a714 100644
--- a/loleaflet/src/control/Control.DownloadProgress.js
+++ b/loleaflet/src/control/Control.DownloadProgress.js
@@ -159,7 +159,7 @@ L.Control.DownloadProgress = L.Control.extend({
var idx = text.indexOf('<!DOCTYPE HTML');
if (idx > 0)
text = text.substring(idx, text.length);
- that._map._clip.setTextSelectionContent(text);
+ that._map._clip.setTextSelectionHTML(text);
};
// TODO: failure to parse ? ...
reader.readAsText(response);
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 1179fa383..21cc69935 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -597,7 +597,7 @@ L.TileLayer = L.GridLayer.extend({
this._onTextSelectionMsg(textMsg);
}
else if (textMsg.startsWith('textselectioncontent:')) {
- this._map._clip.setTextSelectionContent(textMsg.substr(22));
+ this._map._clip.setTextSelectionHTML(textMsg.substr(22));
}
else if (textMsg.startsWith('textselectionend:')) {
this._onTextSelectionEndMsg(textMsg);
@@ -730,7 +730,7 @@ L.TileLayer = L.GridLayer.extend({
// message is received from lowsd, *then* a 'celladdress' message.
var address = textMsg.substring(13);
if (!this._map['wopi'].DisableCopy) {
- this._map._clip.setTextSelectionContent(this._lastFormula);
+ this._map._clip.setTextSelectionText(this._lastFormula);
}
this._map.fire('celladdress', {address: address});
},
diff --git a/loleaflet/src/map/Clipboard.js b/loleaflet/src/map/Clipboard.js
index ea80b2469..2009edd14 100644
--- a/loleaflet/src/map/Clipboard.js
+++ b/loleaflet/src/map/Clipboard.js
@@ -109,21 +109,30 @@ L.Clipboard = L.Class.extend({
return text.indexOf(this._getHtmlStubMarker()) > 0;
},
+ // wrap some content with our stub magic
+ _originWrapBody: function(body, isStub) {
+ var encodedOrigin = encodeURIComponent(this.getMetaPath());
+ var text = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\n' +
+ '<html>\n' +
+ ' <head>\n';
+ if (isStub)
+ text += ' ' + this._getHtmlStubMarker() + '\n';
+ text += ' <meta http-equiv="content-type" content="text/html; charset=utf-8"/>\n' +
+ ' <meta name="origin" content="' + encodedOrigin + '"/>\n' +
+ ' </head>\n'
+ + body +
+ '</html>';
+ return text;
+ },
+
+ // what an empty clipboard has on it
_getStubHtml: function() {
var lang = 'en_US'; // FIXME: l10n
- var encodedOrigin = encodeURIComponent(this.getMetaPath());
- var stub = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\n' +
- '<html>\n' +
- ' <head>\n' +
- ' ' + this._getHtmlStubMarker() + '\n' +
- ' <meta http-equiv="content-type" content="text/html; charset=utf-8"/>\n' +
- ' <meta name="origin" content="' + encodedOrigin + '"/>\n' +
- ' </head>\n' +
+ return this._substProductName(this._originWrapBody(
' <body lang="' + lang + '" dir="ltr">\n' +
' <p>' + _('To paste outside %productName, please first click the \'download\' button') + '</p>\n' +
- ' </body>\n' +
- '</html>';
- return this._substProductName(stub);
+ ' </body>\n', true
+ ));
},
_getMetaOrigin: function (html) {
@@ -688,9 +697,16 @@ L.Clipboard = L.Class.extend({
},
// textselectioncontent: message
- setTextSelectionContent: function(text) {
+ setTextSelectionHTML: function(html) {
+ this._selectionType = 'text';
+ this._selectionContent = html;
+ },
+
+ // sets the selection to some (cell formula) text)
+ setTextSelectionText: function(text) {
this._selectionType = 'text';
- this._selectionContent = text;
+ this._selectionContent = this._originWrapBody(
+ '<body>' + text + '</body>');
},
// complexselection: message
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 5e3b23547..aae011db1 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -999,7 +999,10 @@ void ClientSession::postProcessCopyPayload(std::shared_ptr<Message> payload)
{
// Insert our meta origin if we can
payload->rewriteDataBody([=](std::vector<char>& data) {
- const size_t pos = Util::findInVector(data, "<meta name=\"generator\" content=\"");
+ size_t pos = Util::findInVector(data, "<meta name=\"generator\" content=\"");
+
+ if (pos == std::string::npos)
+ pos = Util::findInVector(data, "<meta http-equiv=\"content-type\" content=\"text/html;");
// cf. TileLayer.js /_dataTransferToDocument/
if (pos != std::string::npos) // assume text/html
More information about the Libreoffice-commits
mailing list