[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4' - ios/Mobile loleaflet/src
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Mar 5 07:51:26 UTC 2019
ios/Mobile/DocumentViewController.mm | 27 +++++++++++++++++++++++++++
loleaflet/src/control/Toolbar.js | 8 ++++++--
2 files changed, 33 insertions(+), 2 deletions(-)
New commits:
commit f1508239b3f71e36e53aa305be5dfa7498dfec45
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Feb 26 17:44:00 2019 +0200
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Mar 5 09:50:59 2019 +0200
tdf#122584: Implement printing in the iOS app
I don't have an AirPrint printer so I couldn't verify that it actually
prints, but the system print dialog is displayed and shows a preview
correctly, so I am fairly sure it works.
Change-Id: I5e8a704386cd5053b8689dc63f26e545df323193
diff --git a/ios/Mobile/DocumentViewController.mm b/ios/Mobile/DocumentViewController.mm
index fa3d77648..b6c128b56 100644
--- a/ios/Mobile/DocumentViewController.mm
+++ b/ios/Mobile/DocumentViewController.mm
@@ -294,6 +294,32 @@
self.webView.hidden = false;
return;
+ } else if ([message.body isEqualToString:@"PRINT"]) {
+
+ // Create the PDF to print.
+
+ std::string printFile = Util::createRandomTmpDir() + "/print.pdf";
+ NSURL *printURL = [NSURL fileURLWithPath:[NSString stringWithUTF8String:printFile.c_str()] isDirectory:NO];
+ lok_document->saveAs([[printURL absoluteString] UTF8String], "pdf", nullptr);
+
+ UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
+ UIPrintInfo *printInfo = [UIPrintInfo printInfo];
+ printInfo.outputType = UIPrintInfoOutputGeneral;
+ printInfo.orientation = UIPrintInfoOrientationPortrait; // FIXME Check the document?
+ printInfo.jobName = @"Document"; // FIXME
+
+ pic.printInfo = printInfo;
+ pic.printingItem = printURL;
+
+ [pic presentFromRect:CGRectZero
+ inView:self.webView
+ animated:YES
+ completionHandler:^(UIPrintInteractionController *pic, BOOL completed, NSError *error) {
+ LOG_TRC("print completion handler gets " << (completed?"YES":"NO"));
+ std::remove(printFile.c_str());
+ }];
+
+ return;
}
const char *buf = [message.body UTF8String];
@@ -309,3 +335,4 @@
@end
// vim:set shiftwidth=4 softtabstop=4 expandtab:
+
diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js
index 7e871a0db..8f3820431 100644
--- a/loleaflet/src/control/Toolbar.js
+++ b/loleaflet/src/control/Toolbar.js
@@ -81,8 +81,12 @@ L.Map.include({
},
print: function () {
- this.showBusy(_('Downloading...'), false);
- this.downloadAs('print.pdf', 'pdf', null, 'print');
+ if (window.ThisIsTheiOSApp) {
+ window.webkit.messageHandlers.lool.postMessage('PRINT', '*');
+ } else {
+ this.showBusy(_('Downloading...'), false);
+ this.downloadAs('print.pdf', 'pdf', null, 'print');
+ }
},
saveAs: function (url, format, options) {
More information about the Libreoffice-commits
mailing list