[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - discovery.xml wsd/LOOLWSD.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Fri May 12 08:46:28 UTC 2017
discovery.xml | 18 ++++++++++++++++++
wsd/LOOLWSD.cpp | 25 ++++++++++++-------------
2 files changed, 30 insertions(+), 13 deletions(-)
New commits:
commit 80ce72fad7478297d0775b2bd73a92bd28fe9db6
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Thu May 11 14:05:28 2017 +0530
extend discovery.xml with pdf and image formats
Change-Id: I201eb276b4de29239c7dd99954abcc39e6027aff
Reviewed-on: https://gerrit.libreoffice.org/37430
Reviewed-by: pranavk <pranavk at collabora.co.uk>
Tested-by: pranavk <pranavk at collabora.co.uk>
(cherry picked from commit a15e32137fee0c1ea2f0918e0ac1a5c3f07227ba)
Reviewed-on: https://gerrit.libreoffice.org/37531
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/discovery.xml b/discovery.xml
index c8b87c5b..cb36c4af 100644
--- a/discovery.xml
+++ b/discovery.xml
@@ -305,5 +305,23 @@
<app name="application/vnd.sun.xml.report.chart">
<action name="edit" ext="odc"/>
</app>
+ <app name="image/png">
+ <action name="view" ext="png"/>
+ </app>
+ <app name="image/gif">
+ <action name="view" ext="gif"/>
+ </app>
+ <app name="image/tiff">
+ <action name="view" ext="tiff"/>
+ </app>
+ <app name="image/jpg">
+ <action name="view" ext="jpg"/>
+ </app>
+ <app name="image/jpeg">
+ <action name="view" ext="jpeg"/>
+ </app>
+ <app name="application/pdf">
+ <action name="view" ext="pdf"/>
+ </app>
</net-zone>
</wopi-discovery>
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index d9a9704c..74d46528 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1784,11 +1784,15 @@ private:
InputSource input(discPath);
DOMParser domParser;
AutoPtr<Poco::XML::Document> doc = domParser.parse(&input);
- // TODO. discovery.xml missing application/pdf
- Node* node = doc->getNodeByPath(nodePath);
- if (node && (node = node->parentNode()) && node->hasAttributes())
+ if (doc)
{
- return dynamic_cast<Element*>(node)->getAttribute("name");
+ Node* node = doc->getNodeByPath(nodePath);
+ if (node && node->parentNode())
+ {
+ Element* elem = dynamic_cast<Element*>(node->parentNode());
+ if (elem && elem->hasAttributes())
+ return elem->getAttribute("name");
+ }
}
return "application/octet-stream";
@@ -1976,16 +1980,11 @@ private:
LOG_INF("HTTP request for: " << filePath.toString());
if (filePath.isAbsolute() && File(filePath).exists())
{
- std::string contentType = getContentType(fileName);
- if (Poco::Path(fileName).getExtension() == "pdf")
- {
- contentType = "application/pdf";
- response.set("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
- }
-
+ // Instruct browsers to download the file, not display it
+ response.set("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
try
{
- HttpHelper::sendFile(socket, filePath.toString(), contentType, response);
+ HttpHelper::sendFile(socket, filePath.toString(), getContentType(fileName), response);
responded = true;
}
catch (const Exception& exc)
@@ -2073,7 +2072,7 @@ private:
docBroker->addCallback([docBroker, moveSocket, clientSession]()
{
- auto streamSocket = std::static_pointer_cast<StreamSocket>(moveSocket);
+ auto streamSocket = std::static_pointer_cast<StreamSocket>(moveSocket);
// Set the ClientSession to handle Socket events.
streamSocket->setHandler(clientSession);
More information about the Libreoffice-commits
mailing list