[Libreoffice-commits] online.git: 2 commits - ios/ios.h ios/ios.mm ios/Mobile kit/Kit.cpp loleaflet/src

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Feb 22 19:09:53 UTC 2019


 ios/Mobile/DocumentViewController.h        |    3 +
 ios/Mobile/DocumentViewController.mm       |   56 +++++++++++++++++++++++++++++
 ios/ios.h                                  |    5 ++
 ios/ios.mm                                 |    3 +
 kit/Kit.cpp                                |    6 ++-
 loleaflet/src/map/handler/Map.SlideShow.js |    4 ++
 6 files changed, 75 insertions(+), 2 deletions(-)

New commits:
commit 4dc340972c54f52631ea0d2bfd3d7eaba2f04e6c
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Fri Feb 22 20:50:07 2019 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Fri Feb 22 21:01:54 2019 +0200

    tdf#122582: Add slideshow functionality
    
    Requires a couple of corresponding commits in core to its filter
    subdirectory.
    
    Change-Id: I3e6353752dd93e021fb6058fff5096f1d648d17e

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 9bc99c2f2..91c04fd75 100644
--- a/ios/ios.h
+++ b/ios/ios.h
@@ -7,6 +7,11 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include <memory>
+
+#include <LibreOfficeKit/LibreOfficeKit.hxx>
+
 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 239540ac9..754d6c3c4 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,5 +18,6 @@ extern "C" {
 }
 
 int loolwsd_server_socket_fd = -1;
+std::shared_ptr<lok::Document> lok_document;
 
 // vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 5de91056c..00bf5ec8a 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..a6d307aa5 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.postMobileMessage('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) {
commit 6567f50abfe3cf3af7e2ce30203270362ff5058a
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Feb 21 13:48:14 2019 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Fri Feb 22 21:01:54 2019 +0200

    Bin leftover declaration of now non-existent function
    
    Change-Id: I62af01bd68657fbce60e4df9df5d3b4a4701d5e0

diff --git a/ios/ios.h b/ios/ios.h
index 0109b0eda..9bc99c2f2 100644
--- a/ios/ios.h
+++ b/ios/ios.h
@@ -7,8 +7,6 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-extern const char *lo_ios_app_getCacheDir();
-
 extern int loolwsd_server_socket_fd;
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list