[Libreoffice-commits] online.git: loleaflet/src wsd/LOOLWSD.cpp
Jan Holesovsky
kendy at collabora.com
Fri May 5 16:24:53 UTC 2017
loleaflet/src/control/Control.Menubar.js | 5 +++--
wsd/LOOLWSD.cpp | 12 ++++++++----
2 files changed, 11 insertions(+), 6 deletions(-)
New commits:
commit 1c13d5523f71b1b49ae37533d95b507934253baf
Author: Jan Holesovsky <kendy at collabora.com>
Date: Fri May 5 18:23:20 2017 +0200
Implement File -> Download As -> Plain text (.txt).
Change-Id: I446f73a3110312cbaab1ce1053aee854b421e71c
diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index 89048a3b..d77bd6a8 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -15,7 +15,8 @@ L.Control.Menubar = L.Control.extend({
{name: _('PDF Document (.pdf)'), id: 'downloadas-pdf', type: 'action'},
{name: _('ODF text document (.odt)'), id: 'downloadas-odt', type: 'action'},
{name: _('Microsoft Word 2003 (.doc)'), id: 'downloadas-doc', type: 'action'},
- {name: _('Microsoft Word (.docx)'), id: 'downloadas-docx', type: 'action'}]}]
+ {name: _('Microsoft Word (.docx)'), id: 'downloadas-docx', type: 'action'},
+ {name: _('Plain text (.txt)'), id: 'downloadas-txt', type: 'action'}]}]
},
{name: _('Edit'), type: 'menu', menu: [
{name: _('Repair'), id: 'repair', type: 'action'},
@@ -283,7 +284,7 @@ L.Control.Menubar = L.Control.extend({
allowedReadonlyMenus: ['file', 'downloadas', 'view', 'help'],
allowedViewModeActions: [
- 'downloadas-pdf', 'downloadas-odt', 'downloadas-doc', 'downloadas-docx', // file menu
+ 'downloadas-pdf', 'downloadas-odt', 'downloadas-doc', 'downloadas-docx', 'downloadas-txt', // file menu
'downloadas-odp', 'downloadas-ppt', 'downloadas-pptx', // file menu
'downloadas-ods', 'downloadas-xls', 'downloadas-xlsx', // file menu
'fullscreen', 'zoomin', 'zoomout', 'zoomreset', // view menu
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 89676207..82126289 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1793,7 +1793,13 @@ private:
static std::string getContentType(const std::string& fileName)
{
- const std::string nodePath = Poco::format("//[@ext='%s']", Poco::Path(fileName).getExtension());
+ const std::string extension = Poco::Path(fileName).getExtension();
+
+ // TODO discovery.xml missing application/pdf
+ if (extension == "pdf")
+ return "application/pdf";
+
+ const std::string nodePath = Poco::format("//[@ext='%s']", extension);
std::string discPath = Path(Application::instance().commandPath()).parent().toString() + "discovery.xml";
if (!File(discPath).exists())
{
@@ -1803,7 +1809,6 @@ 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())
{
@@ -1994,9 +1999,8 @@ private:
if (filePath.isAbsolute() && File(filePath).exists())
{
std::string contentType = getContentType(fileName);
- if (Poco::Path(fileName).getExtension() == "pdf")
+ if (contentType == "application/pdf" || contentType == "text/plain")
{
- contentType = "application/pdf";
response.set("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
}
More information about the Libreoffice-commits
mailing list