[Libreoffice-commits] online.git: 2 commits - ios/Mobile
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Dec 10 20:42:36 UTC 2018
ios/Mobile/AppDelegate.h | 5 ++---
ios/Mobile/AppDelegate.mm | 14 +++++++++++---
ios/Mobile/Document.mm | 12 ++----------
ios/Mobile/TemplateCollectionViewController.h | 1 +
ios/Mobile/TemplateCollectionViewController.mm | 23 +++++++++++++++++------
5 files changed, 33 insertions(+), 22 deletions(-)
New commits:
commit 8f1ed481452d7a69204ce69c9f838402349839d5
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Mon Dec 10 19:48:15 2018 +0200
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Mon Dec 10 22:41:55 2018 +0200
Use the new LibreOfficeKit API to localise the template category headers
Change-Id: Icc91138cbe5de290103a746c8797e647259d5009
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);
commit c65f3e43a10f63aed735ee54b4ddab49a2679834
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Mon Dec 10 19:46:52 2018 +0200
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Mon Dec 10 22:41:55 2018 +0200
Fetch the locale already in the AppDelegate's didFinishLaunchingWithOptions
It will be needed by code that runs before the Document object is
created.
Change-Id: I5c4646e08c670b88b6d3a4d38450cc80e11ec402
diff --git a/ios/Mobile/AppDelegate.h b/ios/Mobile/AppDelegate.h
index b373e8759..cc6d4a629 100644
--- a/ios/Mobile/AppDelegate.h
+++ b/ios/Mobile/AppDelegate.h
@@ -8,14 +8,13 @@
#import <UIKit/UIKit.h>
-//#define LOK_USE_UNSTABLE_API
-//#import <LibreOfficeKit/LibreOfficeKit.h>
-
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
+extern NSString *app_locale;
+
// vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/ios/Mobile/AppDelegate.mm b/ios/Mobile/AppDelegate.mm
index 50d4b791d..99cf64d5c 100644
--- a/ios/Mobile/AppDelegate.mm
+++ b/ios/Mobile/AppDelegate.mm
@@ -24,9 +24,7 @@
static LOOLWSD *loolwsd = nullptr;
- at interface AppDelegate ()
-
- at end
+NSString *app_locale;
@implementation AppDelegate
@@ -35,6 +33,16 @@ static LOOLWSD *loolwsd = nullptr;
if (!trace)
trace = strdup("warning");
+ // Having LANG in the environment is expected to happen only when debugging from Xcode. When
+ // testing some language one doesn't know it might be risky to simply set one's iPad to that
+ // language, as it might be hard to find the way to set it back to a known language.
+
+ char *lang = std::getenv("LANG");
+ if (lang != nullptr)
+ app_locale = [NSString stringWithUTF8String:lang];
+ else
+ app_locale = [[NSLocale preferredLanguages] firstObject];
+
Log::initialize("Mobile", trace, false, false, {});
Util::setThreadName("main");
fakeSocketSetLoggingCallback([](const std::string& line)
diff --git a/ios/Mobile/Document.mm b/ios/Mobile/Document.mm
index 241e2cb3d..1a0ccdcde 100644
--- a/ios/Mobile/Document.mm
+++ b/ios/Mobile/Document.mm
@@ -51,22 +51,14 @@
fakeClientFd = fakeSocketSocket();
NSString *uri = [[self fileURL] absoluteString];
- // Having LANG in the environment is expected to happen only when debugging from Xcode
- char *lang = std::getenv("LANG");
- NSString *locale;
- if (lang != nullptr)
- locale = [NSString stringWithUTF8String:lang];
- else
- locale = [[NSLocale preferredLanguages] firstObject];
-
- comphelper::LibreOfficeKit::setLanguageTag(LanguageTag(OUString::fromUtf8(OString([locale UTF8String])), true));
+ 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],
[NSURLQueryItem queryItemWithName:@"closebutton" value:@"1"],
[NSURLQueryItem queryItemWithName:@"permission" value:@"edit"],
- [NSURLQueryItem queryItemWithName:@"lang" value:locale]
+ [NSURLQueryItem queryItemWithName:@"lang" value:app_locale]
];
NSURLRequest *request = [[NSURLRequest alloc]initWithURL:components.URL];
More information about the Libreoffice-commits
mailing list