discovery.xml | 18 ++++++++++++++++++ wsd/LOOLWSD.cpp | 25 ++++++++++++------------- 2 files changed, 30 insertions(+), 13 deletions(-)
New commits: commit 80ce72fad7478297d0775b2bd73a92bd28fe9db6 Author: Ashod Nakashian <ashod.nakash...@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 <pran...@collabora.co.uk> Tested-by: pranavk <pran...@collabora.co.uk> (cherry picked from commit a15e32137fee0c1ea2f0918e0ac1a5c3f07227ba) Reviewed-on: https://gerrit.libreoffice.org/37531 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@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); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits