[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4' - ios/ios.h ios/ios.mm ios/Mobile kit/Kit.cpp loleaflet/src
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Mar 4 15:14:00 UTC 2019
ios/Mobile/DocumentViewController.h | 3 +
ios/Mobile/DocumentViewController.mm | 56 +++++++++++++++++++++++++++++
ios/ios.h | 6 +++
ios/ios.mm | 3 +
kit/Kit.cpp | 6 ++-
loleaflet/src/map/handler/Map.SlideShow.js | 4 ++
6 files changed, 77 insertions(+), 1 deletion(-)
New commits:
commit 8d1e926919bb6d38d933c6a685e2ea7ca80cd9af
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Fri Feb 22 20:50:07 2019 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Mon Mar 4 16:13:42 2019 +0100
tdf#122582: Add slideshow functionality
Requires a couple of corresponding commits in core to its filter
subdirectory.
Change-Id: I3e6353752dd93e021fb6058fff5096f1d648d17e
Reviewed-on: https://gerrit.libreoffice.org/68336
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/ios/Mobile/DocumentViewController.h b/ios/Mobile/DocumentViewController.h
index 61e317176..8f4d97b43 100644
--- a/ios/Mobile/DocumentViewController.h
+++ b/ios/Mobile/DocumentViewController.h
@@ -15,6 +15,9 @@
@property (strong) Document *document;
@property (strong) WKWebView *webView;
+ at property (strong) WKWebView *slideshowWebView;
+ at property std::string slideshowFile;
+ at property (strong) NSURL *slideshowURL;
@end
diff --git a/ios/Mobile/DocumentViewController.mm b/ios/Mobile/DocumentViewController.mm
index 2c07e2448..fa3d77648 100644
--- a/ios/Mobile/DocumentViewController.mm
+++ b/ios/Mobile/DocumentViewController.mm
@@ -8,6 +8,7 @@
#import "config.h"
+#import <cstdio>
#import <string>
#import <vector>
@@ -238,6 +239,61 @@
[self dismissDocumentViewController];
return;
+ } else if ([message.body isEqualToString:@"SLIDESHOW"]) {
+
+ // Create the SVG for the slideshow.
+
+ self.slideshowFile = Util::createRandomTmpDir() + "/slideshow.svg";
+ self.slideshowURL = [NSURL fileURLWithPath:[NSString stringWithUTF8String:self.slideshowFile.c_str()] isDirectory:NO];
+
+ lok_document->saveAs([[self.slideshowURL absoluteString] UTF8String], "svg", nullptr);
+
+ // Add a new full-screen WebView displaying the slideshow.
+
+ WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
+ WKUserContentController *userContentController = [[WKUserContentController alloc] init];
+
+ [userContentController addScriptMessageHandler:self name:@"lool"];
+
+ configuration.userContentController = userContentController;
+
+ self.slideshowWebView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration];
+
+ [self.slideshowWebView becomeFirstResponder];
+
+ self.slideshowWebView.contentMode = UIViewContentModeScaleAspectFit;
+ self.slideshowWebView.translatesAutoresizingMaskIntoConstraints = NO;
+ self.slideshowWebView.navigationDelegate = self;
+ self.slideshowWebView.UIDelegate = self;
+
+ self.webView.hidden = true;
+
+ [self.view addSubview:self.slideshowWebView];
+ [self.view bringSubviewToFront:self.slideshowWebView];
+
+
+ WKWebView *slideshowWebViewP = self.slideshowWebView;
+ NSDictionary *views = NSDictionaryOfVariableBindings(slideshowWebViewP);
+ [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[slideshowWebViewP(>=0)]-0-|"
+ options:0
+ metrics:nil
+ views:views]];
+ [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[slideshowWebViewP(>=0)]-0-|"
+ options:0
+ metrics:nil
+ views:views]];
+ [self.slideshowWebView loadRequest:[NSURLRequest requestWithURL:self.slideshowURL]];
+
+ return;
+ } else if ([message.body isEqualToString:@"EXITSLIDESHOW"]) {
+
+ std::remove(self.slideshowFile.c_str());
+
+ [self.slideshowWebView removeFromSuperview];
+ self.slideshowWebView = nil;
+ self.webView.hidden = false;
+
+ return;
}
const char *buf = [message.body UTF8String];
diff --git a/ios/ios.h b/ios/ios.h
index 0109b0eda..0be3d6343 100644
--- a/ios/ios.h
+++ b/ios/ios.h
@@ -7,8 +7,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <memory>
+
+#include <LibreOfficeKit/LibreOfficeKit.hxx>
+
extern const char *lo_ios_app_getCacheDir();
extern int loolwsd_server_socket_fd;
+extern std::shared_ptr<lok::Document> lok_document;
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ios/ios.mm b/ios/ios.mm
index 08ebb15cd..9d9e87e7a 100644
--- a/ios/ios.mm
+++ b/ios/ios.mm
@@ -8,6 +8,8 @@
#include <cstring>
+#include "ios.h"
+
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
@@ -16,6 +18,7 @@ extern "C" {
}
int loolwsd_server_socket_fd = -1;
+std::shared_ptr<lok::Document> lok_document;
const char* lo_ios_app_getCacheDir()
{
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 23df2bc9e..a41283ed2 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1675,7 +1675,11 @@ private:
Timestamp timestamp;
_loKitDocument.reset(_loKit->documentLoad(uri.c_str(), options.c_str()));
LOG_DBG("Returned lokit::documentLoad(" << uriAnonym << ") in " << (timestamp.elapsed() / 1000.) << "ms.");
-
+#ifdef IOS
+ // The iOS app (and the Android one) has max one document open at a time, so we can keep
+ // a pointer to it in a global.
+ lok_document = _loKitDocument;
+#endif
if (!_loKitDocument || !_loKitDocument->get())
{
LOG_ERR("Failed to load: " << uriAnonym << ", error: " << _loKit->getError());
diff --git a/loleaflet/src/map/handler/Map.SlideShow.js b/loleaflet/src/map/handler/Map.SlideShow.js
index 9390299ec..bb9488fb5 100644
--- a/loleaflet/src/map/handler/Map.SlideShow.js
+++ b/loleaflet/src/map/handler/Map.SlideShow.js
@@ -24,6 +24,10 @@ L.Map.SlideShow = L.Handler.extend({
},
_onFullScreen: function () {
+ if (window.ThisIsTheiOSApp) {
+ window.webkit.messageHandlers.lool.postMessage('SLIDESHOW', '*');
+ return;
+ }
this._slideShow = L.DomUtil.create('iframe', 'leaflet-slideshow', this._map._container);
this._slideShow.src = this._map.options.webserver + this._map.options.serviceRoot + '/loleaflet/dist/loading.html';
if (this._slideShow.requestFullscreen) {
More information about the Libreoffice-commits
mailing list