[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4' - ios/ios.h ios/ios.mm ios/Mobile kit/Kit.cpp

Tor Lillqvist (via logerrit) logerrit at kemper.freedesktop.org
Fri Oct 11 09:28:25 UTC 2019


 ios/Mobile/AppDelegate.mm                      |   10 +++++++++-
 ios/Mobile/Document.mm                         |    2 --
 ios/Mobile/TemplateCollectionViewController.mm |    8 +-------
 ios/ios.h                                      |    2 ++
 ios/ios.mm                                     |    1 +
 kit/Kit.cpp                                    |    6 ++++++
 6 files changed, 19 insertions(+), 10 deletions(-)

New commits:
commit ca3cc947c34311ad92be6a5c1ed10f3c7738626f
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Fri Oct 11 12:18:27 2019 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Fri Oct 11 12:27:13 2019 +0300

    Just call lok_init_2() and LibreOfficeKit::setLanguageTag() once on iOS
    
    ... when the app starts.
    
    Change-Id: Icac4a9e1074fb6c5f3c9b5282e20a4513717a323

diff --git a/ios/Mobile/AppDelegate.mm b/ios/Mobile/AppDelegate.mm
index f90c3bd61..0e9cbc716 100644
--- a/ios/Mobile/AppDelegate.mm
+++ b/ios/Mobile/AppDelegate.mm
@@ -12,8 +12,12 @@
 #import <cstdlib>
 #import <cstring>
 
-#import <LibreOfficeKit/LibreOfficeKitInit.h>
+#import <LibreOfficeKit/LibreOfficeKit.hxx>
 
+#define LIBO_INTERNAL_ONLY
+#include <comphelper/lok.hxx>
+
+#import "ios.h"
 #import "AppDelegate.h"
 #import "DocumentBrowserViewController.h"
 #import "DocumentViewController.h"
@@ -196,6 +200,10 @@ static void updateTemplates(NSData *data, NSURLResponse *response)
     else
         app_locale = [[NSLocale preferredLanguages] firstObject];
 
+    lo_kit = lok_init_2(nullptr, nullptr);
+
+    comphelper::LibreOfficeKit::setLanguageTag(LanguageTag(OUString::fromUtf8(OString([app_locale UTF8String])), true));
+
     // Look for the setting indicating the URL for a file containing a list of URLs for template
     // documents to download. If set, start a task to download it, and then to download the listed
     // templates.
diff --git a/ios/Mobile/Document.mm b/ios/Mobile/Document.mm
index 2d0d12187..3dba318d4 100644
--- a/ios/Mobile/Document.mm
+++ b/ios/Mobile/Document.mm
@@ -57,8 +57,6 @@
     fakeClientFd = fakeSocketSocket();
     NSString *uri = [[self fileURL] absoluteString];
 
-    comphelper::LibreOfficeKit::setLanguageTag(LanguageTag(OUString::fromUtf8(OString([app_locale UTF8String])), true));
-
     NSURL *url = [[NSBundle mainBundle] URLForResource:@"loleaflet" withExtension:@"html"];
     NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];
     components.queryItems = @[ [NSURLQueryItem queryItemWithName:@"file_path" value:uri],
diff --git a/ios/Mobile/TemplateCollectionViewController.mm b/ios/Mobile/TemplateCollectionViewController.mm
index ae8187f42..b283d580a 100644
--- a/ios/Mobile/TemplateCollectionViewController.mm
+++ b/ios/Mobile/TemplateCollectionViewController.mm
@@ -6,13 +6,11 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-#define LIBO_INTERNAL_ONLY
-#include <comphelper/lok.hxx>
-
 #import "svtools/strings.hrc"
 
 #import <LibreOfficeKit/LibreOfficeKitInit.h>
 
+#import "ios.h"
 #import "AppDelegate.h"
 #import "L10n.h"
 #import "TemplateCollectionViewController.h"
@@ -140,10 +138,6 @@ static NSString *mapTemplateExtensionToActual(NSString *templateName) {
     NSURL *cacheDirectory = [NSFileManager.defaultManager URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask][0];
     NSURL *newURL = [cacheDirectory URLByAppendingPathComponent:mapTemplateExtensionToActual(selectedTemplate.lastPathComponent)
                                                     isDirectory:NO];
-    LibreOfficeKit *lo_kit = lok_init_2(nullptr, nullptr);
-
-    comphelper::LibreOfficeKit::setLanguageTag(LanguageTag(OUString::fromUtf8(OString([app_locale UTF8String])), true));
-
     // Load the template into LibreOffice core, save as the corresponding document type (with the
     // same basename), and then proceed to edit that.
 
diff --git a/ios/ios.h b/ios/ios.h
index 8d4e8c8bf..b5918fac3 100644
--- a/ios/ios.h
+++ b/ios/ios.h
@@ -13,4 +13,6 @@ extern int loolwsd_server_socket_fd;
 
 extern lok::Document *lok_document;
 
+extern LibreOfficeKit *lo_kit;
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ios/ios.mm b/ios/ios.mm
index 17860c854..d31e62862 100644
--- a/ios/ios.mm
+++ b/ios/ios.mm
@@ -19,5 +19,6 @@ extern "C" {
 
 int loolwsd_server_socket_fd = -1;
 lok::Document *lok_document;
+LibreOfficeKit *lo_kit;
 
 // vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 5355d1050..9fda917e4 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2704,9 +2704,15 @@ void lokit_main(
         Poco::URI userInstallationURI("file", LO_PATH);
         LibreOfficeKit *kit = lok_init_2(LO_PATH "/program", userInstallationURI.toString().c_str());
 #else
+
+#ifdef IOS // In the iOS app we call lok_init_2() just once, when the app starts
+        static LibreOfficeKit *kit = lo_kit;
+#else
         static LibreOfficeKit *kit = lok_init_2(nullptr, nullptr);
 #endif
 
+#endif
+
         assert(kit);
 
         static std::shared_ptr<lok::Office> loKit = std::make_shared<lok::Office>(kit);


More information about the Libreoffice-commits mailing list