[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4' - ios/Mobile

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Mar 4 14:39:56 UTC 2019


 ios/Mobile/TemplateCollectionViewController.h  |    1 +
 ios/Mobile/TemplateCollectionViewController.mm |   23 +++++++++++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)

New commits:
commit 05a43e42ebbc5805ae24a46aca137dd69ed7d1b4
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Mon Dec 10 19:48:15 2018 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Mon Mar 4 15:39:39 2019 +0100

    Use the new LibreOfficeKit API to localise the template category headers
    
    Change-Id: Icc91138cbe5de290103a746c8797e647259d5009
    Reviewed-on: https://gerrit.libreoffice.org/68320
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/ios/Mobile/TemplateCollectionViewController.h b/ios/Mobile/TemplateCollectionViewController.h
index 50861a599..0668de966 100644
--- a/ios/Mobile/TemplateCollectionViewController.h
+++ b/ios/Mobile/TemplateCollectionViewController.h
@@ -12,6 +12,7 @@
 
 @interface TemplateCollectionViewController : UICollectionViewController<UICollectionViewDataSource,UICollectionViewDelegateFlowLayout> {
     NSArray<NSURL*> *templates[3];
+    LibreOfficeKit *kit;
 }
 
 @property (copy) void (^ _Nullable importHandler)(NSURL * _Nullable, UIDocumentBrowserImportMode);
diff --git a/ios/Mobile/TemplateCollectionViewController.mm b/ios/Mobile/TemplateCollectionViewController.mm
index 94a922825..cdb6de60d 100644
--- a/ios/Mobile/TemplateCollectionViewController.mm
+++ b/ios/Mobile/TemplateCollectionViewController.mm
@@ -6,9 +6,12 @@
 // 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/.
 
+#import "svtools/strings.hrc"
+
 #import <LibreOfficeKit/LibreOfficeKit.h>
 #import <LibreOfficeKit/LibreOfficeKitInit.h>
 
+#import "AppDelegate.h"
 #import "TemplateCollectionViewController.h"
 #import "TemplateSectionHeaderView.h"
 
@@ -30,7 +33,9 @@ static NSString *mapTemplateExtensionToActual(NSString *templateName) {
 
 - (void)viewDidLoad {
 
-    // Here we should scan for available templates.
+    kit = lok_init_2(nullptr, nullptr);
+
+    // Scan for available templates.
 
     templates[0] = [[NSBundle mainBundle] URLsForResourcesWithExtension:@".ott" subdirectory:@"Templates"];
     templates[1] = [[NSBundle mainBundle] URLsForResourcesWithExtension:@".ots" subdirectory:@"Templates"];
@@ -88,12 +93,20 @@ static NSString *mapTemplateExtensionToActual(NSString *templateName) {
 
     TemplateSectionHeaderView *header = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"SectionHeaderView" forIndexPath:indexPath];
 
+    char *translatedHeader;
+
     if (index == 0)
-        header.title.text = @"Document";
+        translatedHeader = kit->pClass->translateGet(kit, STR_DESCRIPTION_FACTORY_WRITER, "svt", [app_locale UTF8String]);
     else if (index == 1)
-        header.title.text = @"Spreadsheet";
+        translatedHeader = kit->pClass->translateGet(kit, STR_DESCRIPTION_FACTORY_CALC, "svt", [app_locale UTF8String]);
     else if (index == 2)
-        header.title.text = @"Presentation";
+        translatedHeader = kit->pClass->translateGet(kit, STR_DESCRIPTION_FACTORY_IMPRESS, "svt", [app_locale UTF8String]);
+    else
+        abort();
+
+    header.title.text = [NSString stringWithUTF8String:translatedHeader];
+
+    free(translatedHeader);
 
     return header;
 }
@@ -107,12 +120,10 @@ static NSString *mapTemplateExtensionToActual(NSString *templateName) {
 
     // Load the template into LibreOffice core, save as the corresponding document type (with the
     // same basename), and then proceed to edit that.
-    LibreOfficeKit *kit = lok_init_2(nullptr, nullptr);
     kit->pClass->registerCallback(kit, [](int, const char *, void*){}, nullptr);
     LibreOfficeKitDocument *doc = kit->pClass->documentLoad(kit, [[selectedTemplate absoluteString] UTF8String]);
     doc->pClass->saveAs(doc, [[newURL absoluteString] UTF8String], nullptr, nullptr);
     doc->pClass->destroy(doc);
-    kit->pClass->destroy(kit);
 
     self.importHandler(newURL, UIDocumentBrowserImportModeMove);
 


More information about the Libreoffice-commits mailing list