loleaflet/src/control/Control.AlertDialog.js | 13 -
loleaflet/src/layer/tile/TileLayer.js|5 -
wsd/LOOLWSD.cpp |6 +-
3 files changed, 9 insertions(+), 15 deletions(-)
New commits:
commit 309e53cba404301407ef5b1851c52090565fd7f2
Author: Pranav Kant
Date: Mon May 28 16:33:04 2018 +0530
loleaflet: Open pdf file in new tab instead of asking to download
new parameter to download POST requests, ?attachment=0 to instruct wsd
to not set the Content-Disposition header.
Change-Id: Id7694d940e1b4d616263ad720d29f1474164eb68
Reviewed-on: https://gerrit.libreoffice.org/54919
Reviewed-by: Jan Holesovsky
Tested-by: Jan Holesovsky
diff --git a/loleaflet/src/control/Control.AlertDialog.js
b/loleaflet/src/control/Control.AlertDialog.js
index 1d9b9e48c..a87b494f3 100644
--- a/loleaflet/src/control/Control.AlertDialog.js
+++ b/loleaflet/src/control/Control.AlertDialog.js
@@ -8,7 +8,6 @@ L.Control.AlertDialog = L.Control.extend({
// TODO: Better distinction between warnings and errors
map.on('error', this._onError, this);
map.on('warn', this._onError, this);
- map.on('print', this._onPrint, this);
},
_onError: function(e) {
@@ -33,18 +32,6 @@ L.Control.AlertDialog = L.Control.extend({
// Remember the current dialog ID to close it later.
vex.dialogID = vex.globalID - 1;
- },
-
- _onPrint: function (e) {
- var url = e.url;
- vex.dialog.confirm({
- message: _('Download PDF export?'),
- callback: L.bind(function (value) {
- if (value) {
- this._map._fileDownloader.src = url;
- }
- }, this)
- });
}
});
diff --git a/loleaflet/src/layer/tile/TileLayer.js
b/loleaflet/src/layer/tile/TileLayer.js
index 49aa853c6..ebf953302 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -560,7 +560,10 @@ L.TileLayer = L.GridLayer.extend({
if (command.id === 'print') {
if (L.Browser.gecko || L.Browser.edge ||
this._map.options.print === false) {
// the print dialog doesn't work well on firefox
- this._map.fire('print', {url: url});
+ // due to a pdf.js issue -
https://github.com/mozilla/pdf.js/issues/5397
+ // open the pdf file in a new tab so that that
user can print it directly in the browser's
+ // pdf viewer
+ window.open(url + '?attachment=0', '_blank');
}
else {
this._map.fire('filedownloadready', {url: url});
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 4831aea33..3b645fe8f 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2166,11 +2166,15 @@ private:
LOG_INF("HTTP request for: " << filePath.toString());
if (filePath.isAbsolute() && File(filePath).exists())
{
+int serveAsAttachment = 1;
+if (tokens.count() >= 7)
+getTokenInteger(tokens[6], "attachment",
serveAsAttachment);
+
// Instruct browsers to download the file, not display it
// with the exception of SVG where we need the browser to
// actually show it.
std::string contentType = getContentType(fileName);
-if (contentType != "image/svg+xml")
+if (serveAsAttachment != 0 && contentType != "image/svg+xml")
response.set("Content-Disposition", "attachment;
filename=\"" + fileName + "\"");
try
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits