[Libreoffice-commits] online.git: 3 commits - loleaflet/src loolwsd/LOOLSession.cpp loolwsd/LOOLWSD.cpp loolwsd/protocol.txt
Mihai Varga
mihai.varga at collabora.com
Fri Oct 16 09:48:00 PDT 2015
loleaflet/src/control/Toolbar.js | 1
loleaflet/src/layer/tile/TileLayer.js | 2
loleaflet/src/map/handler/Map.Keyboard.js | 3 -
loleaflet/src/map/handler/Map.Mouse.js | 7 ---
loleaflet/src/map/handler/Map.SlideShow.js | 59 +++--------------------------
loolwsd/LOOLSession.cpp | 20 +++------
loolwsd/LOOLWSD.cpp | 12 +++--
loolwsd/protocol.txt | 3 -
8 files changed, 27 insertions(+), 80 deletions(-)
New commits:
commit 0ea00afb99b54f05425478967b0477803fb106e7
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Oct 16 19:45:57 2015 +0300
loolwsd: allow the specification of the mime type
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 528a64e..89bc579 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -220,8 +220,8 @@ public:
if(!(request.find("Upgrade") != request.end() && Poco::icompare(request["Upgrade"], "websocket") == 0))
{
- StringTokenizer tokens(request.getURI(), "/");
- if (tokens.count() == 2 && tokens[1] == "convert-to")
+ StringTokenizer tokens(request.getURI(), "/?");
+ if (tokens.count() >= 2 && tokens[1] == "convert-to")
{
std::vector<char> buffer;
ConvertToPartHandler handler(buffer);
@@ -239,7 +239,7 @@ public:
response.setContentLength(0);
response.send();
}
- else if (tokens.count() == 4)
+ else if (tokens.count() >= 4)
{
// The user might request a file to download
std::string dirPath = LOOLWSD::childRoot + "/" + tokens[1] + LOOLSession::jailDocumentURL + "/" + tokens[2];
@@ -249,7 +249,11 @@ public:
if (file.exists())
{
response.set("Access-Control-Allow-Origin", "*");
- response.sendFile(filePath, "application/octet-stream");
+ Poco::Net::HTMLForm form(request);
+ std::string mimeType = "application/octet-stream";
+ if (form.has("mime_type"))
+ mimeType = form.get("mime_type");
+ response.sendFile(filePath, mimeType);
File dir(dirPath);
dir.remove(true);
}
commit 9deebf4f87c772218018d84cf5666fa7883707d9
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Oct 16 19:27:57 2015 +0300
loleaflet: directly load the presentation in an iframe
We now export the presentation document to a single svg document which
can be loaded in an iframe and displayed in fullscreen
diff --git a/loleaflet/src/map/handler/Map.SlideShow.js b/loleaflet/src/map/handler/Map.SlideShow.js
index cbe38b1..e4ca979 100644
--- a/loleaflet/src/map/handler/Map.SlideShow.js
+++ b/loleaflet/src/map/handler/Map.SlideShow.js
@@ -23,26 +23,25 @@ L.Map.SlideShow = L.Handler.extend({
},
_onFullScreen: function (e) {
- this._container = L.DomUtil.create('div', '', this._map._container);
- this._slideShow = L.DomUtil.create('img', 'slide-show', this._container);
+ this._slideShow = L.DomUtil.create('iframe', '', this._map._container);
if (this._slideShow.requestFullscreen) {
- this._container.requestFullscreen();
+ this._slideShow.requestFullscreen();
}
else if (this._slideShow.msRequestFullscreen) {
- this._container.msRequestFullscreen();
+ this._slideShow.msRequestFullscreen();
}
else if (this._slideShow.mozRequestFullScreen) {
- this._container.mozRequestFullScreen();
+ this._slideShow.mozRequestFullScreen();
}
else if (this._slideShow.webkitRequestFullscreen) {
- this._container.webkitRequestFullscreen();
+ this._slideShow.webkitRequestFullscreen();
}
L.DomEvent['on'](document, 'fullscreenchange webkitfullscreenchange mozfullscreenchange msfullscreenchange',
this._onFullScreenChange, this);
this.fullscreen = true;
- this._getSlides();
+ L.Socket.sendMessage('downloadas name=slideshow.svg id=slideshow format=svg options=');
},
_onFullScreenChange: function (e) {
@@ -52,54 +51,12 @@ L.Map.SlideShow = L.Handler.extend({
document.mozFullScreen ||
document.msFullscreenElement;
if (!this.fullscreen) {
- L.DomUtil.remove(this._container);
- }
- },
-
- _getSlides: function () {
- this._currentSlide = 0;
- this._slides = [];
- for (var i = 0; i < this._map.getNumberOfParts(); i++) {
- // mark the i-th slide as not available yet
- this._slides.push(null);
- }
-
- for (var i = 0; i < this._map.getNumberOfParts(); i++) {
- L.Socket.sendMessage('downloadas name=' + i + '.svg id=slideshow ' +
- 'part=' + i + ' format=svg options=');
+ L.DomUtil.remove(this._slideShow);
}
},
_onSlideDownloadReady: function (e) {
- var xmlHttp = new XMLHttpRequest();
- var part = e.part;
- xmlHttp.onreadystatechange = L.bind(function () {
- if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
- var blob = new Blob([xmlHttp.response], {type: 'image/svg+xml'});
- var url = URL.createObjectURL(blob);
- this._slides[part] = url;
- if (part === this._currentSlide) {
- this._slideShow.src = url;
- }
- }
- }, this);
- xmlHttp.open('GET', e.url, true);
- xmlHttp.responseType = 'blob';
- xmlHttp.send();
- },
-
- _onUserInput: function (e) {
- if (e.type === 'mousedown' || (e.type === 'keydown' &&
- e.originalEvent.keyCode === 39)) {
- this._currentSlide = Math.min(this._currentSlide + 1, this._map.getNumberOfParts() - 1);
- }
- else if (e.type === 'keydown' && e.originalEvent.keyCode === 37) {
- this._currentSlide = Math.max(this._currentSlide - 1, 0);
- }
- else {
- return;
- }
- this._slideShow.src = this._slides[this._currentSlide];
+ this._slideShow.src = e.url + '?mime_type=image/svg%2Bxml';
}
});
commit d7ceedac5444512417f93a2c26da45029ba1ee98
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Oct 16 19:27:13 2015 +0300
drop 'part' from downloadas protocol as it is no longer needed
diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js
index 0e276f7..c319926 100644
--- a/loleaflet/src/control/Toolbar.js
+++ b/loleaflet/src/control/Toolbar.js
@@ -41,7 +41,6 @@ L.Map.include({
L.Socket.sendMessage('downloadas ' +
'name=' + name + ' ' +
'id=-1 ' + // not a special download
- 'part=-1 ' + // we don't want to export just a single part
'format=' + format + ' ' +
'options=' + options);
},
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index e9182e5..b16429f 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -287,7 +287,7 @@ L.TileLayer = L.GridLayer.extend({
}
}
else if (command.id === 'slideshow') {
- this._map.fire('slidedownloadready', {url: url, part: command.part});
+ this._map.fire('slidedownloadready', {url: url});
}
else {
this._map._fileDownloader.src = url;
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index b26f4f3..da463aa 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -181,7 +181,6 @@ L.Map.Keyboard = L.Handler.extend({
_onKeyDown: function (e) {
if (this._map.slideShow && this._map.slideShow.fullscreen) {
- this._map.slideShow._onUserInput(e);
return;
}
var docLayer = this._map._docLayer;
@@ -288,7 +287,7 @@ L.Map.Keyboard = L.Handler.extend({
L.Socket.sendMessage('uno .uno:LeftPara');
break;
case 80: // p
- L.Socket.sendMessage('downloadas name=print.pdf id=print part=-1 format=pdf options=');
+ L.Socket.sendMessage('downloadas name=print.pdf id=print format=pdf options=');
break;
case 82: // r
L.Socket.sendMessage('uno .uno:RightPara');
diff --git a/loleaflet/src/map/handler/Map.Mouse.js b/loleaflet/src/map/handler/Map.Mouse.js
index d5305cf..c0345a4 100644
--- a/loleaflet/src/map/handler/Map.Mouse.js
+++ b/loleaflet/src/map/handler/Map.Mouse.js
@@ -37,12 +37,7 @@ L.Map.Mouse = L.Handler.extend({
_onMouseEvent: function (e) {
var docLayer = this._map._docLayer;
- if (!docLayer) {
- // document not yet loaded
- return;
- }
- if (this._map.slideShow && this._map.slideShow.fullscreen) {
- this._map.slideShow._onUserInput(e);
+ if (!docLayer || (this._map.slideShow && this._map.slideShow.fullscreen)) {
return;
}
if (docLayer._graphicMarker && docLayer._graphicMarker.isDragged) {
diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index f83ab5d..3296139 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -999,22 +999,20 @@ void ChildProcessSession::sendTile(const char* /*buffer*/, int /*length*/, Strin
bool ChildProcessSession::downloadAs(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
std::string name, id, format, filterOptions;
- int part;
- if (tokens.count() < 6 ||
+ if (tokens.count() < 5 ||
!getTokenString(tokens[1], "name", name) ||
- !getTokenString(tokens[2], "id", id),
- !getTokenInteger(tokens[3], "part", part))
+ !getTokenString(tokens[2], "id", id))
{
sendTextFrame("error: cmd=downloadas kind=syntax");
return false;
}
- getTokenString(tokens[4], "format", format);
+ getTokenString(tokens[3], "format", format);
- if (getTokenString(tokens[5], "options", filterOptions)) {
- if (tokens.count() > 6) {
- filterOptions += Poco::cat(std::string(" "), tokens.begin() + 6, tokens.end());
+ if (getTokenString(tokens[4], "options", filterOptions)) {
+ if (tokens.count() > 5) {
+ filterOptions += Poco::cat(std::string(" "), tokens.begin() + 5, tokens.end());
}
}
@@ -1032,16 +1030,12 @@ bool ChildProcessSession::downloadAs(const char* /*buffer*/, int /*length*/, Str
} while (file->exists());
delete file;
- if (part != -1) {
- // we need this to export a slide to svg
- _loKitDocument->pClass->setPart(_loKitDocument, part);
- }
_loKitDocument->pClass->saveAs(_loKitDocument, url.c_str(),
format.size() == 0 ? NULL :format.c_str(),
filterOptions.size() == 0 ? NULL : filterOptions.c_str());
sendTextFrame("downloadas: jail=" + _childId + " dir=" + tmpDir + " name=" + name +
- " port=" + std::to_string(LOOLWSD::portNumber) + " id=" + id + " part=" + std::to_string(part));
+ " port=" + std::to_string(LOOLWSD::portNumber) + " id=" + id);
return true;
}
diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt
index dbe89fb..bc7c453 100644
--- a/loolwsd/protocol.txt
+++ b/loolwsd/protocol.txt
@@ -17,11 +17,10 @@ canceltiles
dropped and will not be handled. There is no guarantee of exactly
which tile: messages might still be sent back to the client.
-downloadas downloadas name=<fileName> id=<id> part=<part> format=<document format> options=<SkipImages, etc>
+downloadas downloadas name=<fileName> id=<id> format=<document format> options=<SkipImages, etc>
Exports the current document to the desired format and returns a download URL
The id identifies the request on the client.
- The part parameter is used to export a specific part, for example when we need to export a slide to svg
gettextselection mimetype=<mimeType>
More information about the Libreoffice-commits
mailing list