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

New commits:
commit 07986199adc26803aaaffcea40a64ba4d88768dc
Author:     Tor Lillqvist <t...@collabora.com>
AuthorDate: Fri Oct 11 12:18:27 2019 +0300
Commit:     Tor Lillqvist <t...@collabora.com>
CommitDate: Wed Oct 16 13:16:42 2019 +0200

    Just call lok_init_2() and LibreOfficeKit::setLanguageTag() once on iOS
    
    ... when the app starts.
    
    Change-Id: Icac4a9e1074fb6c5f3c9b5282e20a4513717a323
    Reviewed-on: https://gerrit.libreoffice.org/80881
    Reviewed-by: Tor Lillqvist <t...@collabora.com>
    Tested-by: Tor Lillqvist <t...@collabora.com>

diff --git a/ios/Mobile/AppDelegate.mm b/ios/Mobile/AppDelegate.mm
index 8b9badcc7..dbc02e66e 100644
--- a/ios/Mobile/AppDelegate.mm
+++ b/ios/Mobile/AppDelegate.mm
@@ -12,8 +12,13 @@
 #import <cstdlib>
 #import <cstring>
 
-#import <LibreOfficeKit/LibreOfficeKitInit.h>
+#import <LibreOfficeKit/LibreOfficeKit.hxx>
 
+#define LIBO_INTERNAL_ONLY
+#include <comphelper/lok.hxx>
+#include <i18nlangtag/languagetag.hxx>
+
+#import "ios.h"
 #import "AppDelegate.h"
 #import "DocumentBrowserViewController.h"
 #import "DocumentViewController.h"
@@ -197,6 +202,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 153fefb6f..b283d580a 100644
--- a/ios/Mobile/TemplateCollectionViewController.mm
+++ b/ios/Mobile/TemplateCollectionViewController.mm
@@ -6,14 +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>
-#include <i18nlangtag/languagetag.hxx>
-
 #import "svtools/strings.hrc"
 
 #import <LibreOfficeKit/LibreOfficeKitInit.h>
 
+#import "ios.h"
 #import "AppDelegate.h"
 #import "L10n.h"
 #import "TemplateCollectionViewController.h"
@@ -141,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 f73a5c5fb..a787855bd 100644
--- a/ios/ios.h
+++ b/ios/ios.h
@@ -12,4 +12,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 44c41d886..4c59b8d79 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2565,9 +2565,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);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to