[Libreoffice-commits] online.git: discovery.xml wsd/LOOLWSD.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Fri May 12 04:49:51 UTC 2017


 discovery.xml   |   18 ++++++++++++++++++
 wsd/LOOLWSD.cpp |   25 ++++++++++++-------------
 2 files changed, 30 insertions(+), 13 deletions(-)

New commits:
commit a15e32137fee0c1ea2f0918e0ac1a5c3f07227ba
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>

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 99208078..fb4c5829 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1812,11 +1812,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";
@@ -2004,16 +2008,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)
@@ -2101,7 +2100,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