[Libreoffice-commits] online.git: kit/ChildSession.cpp loleaflet/src

Tor Lillqvist (via logerrit) logerrit at kemper.freedesktop.org
Thu Aug 22 14:25:33 UTC 2019


 kit/ChildSession.cpp                     |   10 ++++++++++
 loleaflet/src/control/Control.Menubar.js |    6 ++++++
 loleaflet/src/control/Toolbar.js         |    3 ++-
 3 files changed, 18 insertions(+), 1 deletion(-)

New commits:
commit 634be102c71305f0f35fe86e980ccabb381ae766
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Aug 22 15:47:12 2019 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Thu Aug 22 16:25:14 2019 +0200

    tdf#126968: Implement "Save as PDF" in the iOS app
    
    For now, add an entry "Save as PDF" to the File menu in the iOS app.
    Handle in an iOS-specific way in ChildSession::downloadAs(). The PDF
    is saved in the app's document directory on the device. The name of
    the PDF is the basename of the document being edited with the "pdf"
    extension.
    
    Change-Id: Ib0059a86b03b978996eb4cadf230ba7f0abcba62
    Reviewed-on: https://gerrit.libreoffice.org/77961
    Reviewed-by: Tor Lillqvist <tml at collabora.com>
    Tested-by: Tor Lillqvist <tml at collabora.com>

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index fadbca1ea..6d7751fdc 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -879,6 +879,15 @@ bool ChildSession::downloadAs(const char* /*buffer*/, int /*length*/, const std:
         filterOptions += std::string(",Watermark=") + getWatermarkText() + std::string("WATERMARKEND");
     }
 
+#ifdef IOS
+    NSArray<NSString *> *pathComponents = [[NSURL URLWithString:[NSString stringWithUTF8String:getDocURL().c_str()]] pathComponents];
+    NSString *baseName = [[pathComponents lastObject] stringByDeletingPathExtension];
+    NSURL *documentDirectory = [NSFileManager.defaultManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask][0];
+    NSURL *pdfURL = [documentDirectory URLByAppendingPathComponent:[baseName stringByAppendingString:@".pdf"]];
+    getLOKitDocument()->saveAs([[pdfURL absoluteString] UTF8String],
+                               format.empty() ? nullptr : format.c_str(),
+                               filterOptions.empty() ? nullptr : filterOptions.c_str());
+#else
     // The file is removed upon downloading.
     const std::string tmpDir = FileUtil::createRandomDir(JAILED_DOCUMENT_ROOT);
     // Prevent user inputting anything funny here.
@@ -898,6 +907,7 @@ bool ChildSession::downloadAs(const char* /*buffer*/, int /*length*/, const std:
 
     sendTextFrame("downloadas: jail=" + _jailId + " dir=" + tmpDir + " name=" + name +
                   " port=" + std::to_string(ClientPortNumber) + " id=" + id);
+#endif
     return true;
 }
 
diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index 41120cfc2..c71fee473 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -27,6 +27,7 @@ L.Control.Menubar = L.Control.extend({
 					{name: _('Word 2003 Document (.doc)'), id: 'downloadas-doc', type: 'action'},
 					{name: _('Word Document (.docx)'), id: 'downloadas-docx', type: 'action'},
 					{name: _('Rich Text (.rtf)'), id: 'downloadas-rtf', type: 'action'}]},
+				{name: _('Save as PDF'), id: 'downloadas-pdf', mobileapp: true, type: 'action'},
 				{name: _('Sign document'), id: 'signdocument', type: 'action'},
 				{type: 'separator'},
 				{name: _('Close document'), id: 'closedocument', type: 'action'}
@@ -250,6 +251,7 @@ L.Control.Menubar = L.Control.extend({
 					{name: _('ODF presentation (.odp)'), id: 'downloadas-odp', type: 'action'},
 					{name: _('PowerPoint 2003 Presentation (.ppt)'), id: 'downloadas-ppt', type: 'action'},
 					{name: _('PowerPoint Presentation (.pptx)'), id: 'downloadas-pptx', type: 'action'}]},
+				{name: _('Save as PDF'), id: 'downloadas-pdf', mobileapp: true, type: 'action'},
 				{type: 'separator'},
 				{name: _('Close document'), id: 'closedocument', type: 'action'}
 			]},
@@ -338,6 +340,7 @@ L.Control.Menubar = L.Control.extend({
 					{name: _('ODF spreadsheet (.ods)'), id: 'downloadas-ods', type: 'action'},
 					{name: _('Excel 2003 Spreadsheet (.xls)'), id: 'downloadas-xls', type: 'action'},
 					{name: _('Excel Spreadsheet (.xlsx)'), id: 'downloadas-xlsx', type: 'action'}]},
+				{name: _('Save as PDF'), id: 'downloadas-pdf', mobileapp: true, type: 'action'},
 				{type: 'separator'},
 				{name: _('Close document'), id: 'closedocument', type: 'action'}
 			]},
@@ -996,6 +999,9 @@ L.Control.Menubar = L.Control.extend({
 				if (menu[i].mobileapp == false && window.ThisIsAMobileApp) {
 					continue;
 				}
+				if (menu[i].mobileapp == true && !window.ThisIsAMobileApp) {
+					continue;
+				}
 				var ulItem = L.DomUtil.create('ul', '', liItem);
 				var subitemList = this._createMenu(menu[i].menu);
 				if (!subitemList.length) {
diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js
index 06563be19..f4ffa86f3 100644
--- a/loleaflet/src/control/Toolbar.js
+++ b/loleaflet/src/control/Toolbar.js
@@ -72,7 +72,8 @@ L.Map.include({
 			options = '';
 		}
 
-		this.showBusy(_('Downloading...'), false);
+		if (!window.ThisIsAMobileApp)
+			this.showBusy(_('Downloading...'), false);
 		this._socket.sendMessage('downloadas ' +
 			'name=' + encodeURIComponent(name) + ' ' +
 			'id=' + id + ' ' +


More information about the Libreoffice-commits mailing list