summaryrefslogtreecommitdiffstats
path: root/ios
diff options
context:
space:
mode:
Diffstat (limited to 'ios')
-rw-r--r--ios/experimental/TiledLibreOffice/TiledLibreOffice.xcodeproj/project.pbxproj6
-rw-r--r--ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.h2
-rw-r--r--ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m51
-rw-r--r--ios/experimental/TiledLibreOffice/TiledLibreOffice/DocumentTableViewController.h19
-rw-r--r--ios/experimental/TiledLibreOffice/TiledLibreOffice/DocumentTableViewController.m59
-rw-r--r--ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledLibreOffice-Info.plist2
-rw-r--r--ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.h4
-rw-r--r--ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm13
8 files changed, 141 insertions, 15 deletions
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice.xcodeproj/project.pbxproj b/ios/experimental/TiledLibreOffice/TiledLibreOffice.xcodeproj/project.pbxproj
index 0ffd267da557..e2153dd24d4b 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice.xcodeproj/project.pbxproj
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice.xcodeproj/project.pbxproj
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
+ BE55B06D18D87CC600950228 /* DocumentTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BE55B06C18D87CC600950228 /* DocumentTableViewController.m */; };
BE82BD7618218E2E00A447B5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE82BD7518218E2E00A447B5 /* Foundation.framework */; };
BE82BD7818218E2E00A447B5 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE82BD7718218E2E00A447B5 /* CoreGraphics.framework */; };
BE82BD7A18218E2E00A447B5 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE82BD7918218E2E00A447B5 /* UIKit.framework */; };
@@ -166,6 +167,8 @@
BE35B5A2188FFA88001B7439 /* unourl.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = unourl.cxx; path = ../../../cppuhelper/source/unourl.cxx; sourceTree = "<group>"; };
BE35B5A3188FFA88001B7439 /* weak.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = weak.cxx; path = ../../../cppuhelper/source/weak.cxx; sourceTree = "<group>"; };
BE35B5A71890520E001B7439 /* objface.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = objface.cxx; path = ../../../sfx2/source/control/objface.cxx; sourceTree = "<group>"; };
+ BE55B06B18D87CC600950228 /* DocumentTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentTableViewController.h; sourceTree = "<group>"; };
+ BE55B06C18D87CC600950228 /* DocumentTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DocumentTableViewController.m; sourceTree = "<group>"; };
BE7C277218D1DDF600C4908C /* acmplwrd.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = acmplwrd.cxx; path = ../../../sw/source/core/doc/acmplwrd.cxx; sourceTree = "<group>"; };
BE7C277318D1DDF600C4908C /* dbgoutsw.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = dbgoutsw.cxx; path = ../../../sw/source/core/doc/dbgoutsw.cxx; sourceTree = "<group>"; };
BE7C277418D1DDF600C4908C /* doc.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = doc.cxx; path = ../../../sw/source/core/doc/doc.cxx; sourceTree = "<group>"; };
@@ -802,6 +805,8 @@
BECAB371186054DE00F814F9 /* lo.mm */,
BE82BD8418218E2E00A447B5 /* AppDelegate.h */,
BE82BD8518218E2E00A447B5 /* AppDelegate.m */,
+ BE55B06B18D87CC600950228 /* DocumentTableViewController.h */,
+ BE55B06C18D87CC600950228 /* DocumentTableViewController.m */,
BE82BDAA182190E400A447B5 /* TiledView.h */,
BE82BDAB182190E400A447B5 /* TiledView.m */,
BE82BDAD1821A1D000A447B5 /* View.h */,
@@ -1236,6 +1241,7 @@
buildActionMask = 2147483647;
files = (
BECAB372186054DE00F814F9 /* lo.mm in Sources */,
+ BE55B06D18D87CC600950228 /* DocumentTableViewController.m in Sources */,
BE82BDAF1821A1D000A447B5 /* View.m in Sources */,
BE82BDAC182190E400A447B5 /* TiledView.m in Sources */,
BE82BD8C18218E2E00A447B5 /* ViewController.m in Sources */,
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.h b/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.h
index e128714fbc5a..3d27a8d4ff0e 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.h
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.h
@@ -12,7 +12,7 @@
@property (strong, nonatomic) UIWindow *window;
-- (void)threadMainMethod: (id) argument;
+- (void)startDisplaying:(NSString*)documentPath;
@end
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m b/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m
index 9b9e52516948..10e5d70204d0 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m
@@ -9,10 +9,18 @@
#include <touch/touch.h>
#import "AppDelegate.h"
+#import "DocumentTableViewController.h"
#import "View.h"
#import "ViewController.h"
#import "lo.h"
+@interface AppDelegate ()
+
+- (void)showDocumentList:(NSArray*)documents inFolder:(NSString*)folder;
+- (void)threadMainMethod:(NSString *)documentPath;
+
+@end
+
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
@@ -21,26 +29,55 @@
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
- ViewController *vc = [[ViewController alloc] init];
- self.window.rootViewController = vc;
+ NSFileManager *fileManager = [NSFileManager defaultManager];
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *documentsDirectory = [paths objectAtIndex:0];
- [[[NSThread alloc] initWithTarget:self selector:@selector(threadMainMethod:) object:nil] start];
+ NSDirectoryEnumerator *dirEnumerator = [fileManager enumeratorAtPath:documentsDirectory];
+ int nDocs = 0;
+ NSString *document;
+ NSMutableArray *documents = [[NSMutableArray alloc] init];
+ NSString *test1 = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent: @"test1.odt"];
+ [documents addObject:test1];
- vc.view = [[View alloc] initWithFrame:[self.window frame]];
+ while ((document = [dirEnumerator nextObject])) {
+ nDocs++;
+ [documents addObject:[documentsDirectory stringByAppendingPathComponent:document]];
+ }
+
+ if (nDocs == 0) {
+ [self startDisplaying:test1];
+ } else {
+ [documents sortUsingSelector:@selector(localizedStandardCompare:)];
+ [self showDocumentList:documents inFolder:documentsDirectory];
+ }
return YES;
}
-- (void)threadMainMethod:(id)argument
+- (void)startDisplaying:(NSString*)documentPath;
{
- (void) argument;
+ ViewController *vc = [[ViewController alloc] init];
+ self.window.rootViewController = vc;
+
+ [[[NSThread alloc] initWithTarget:self selector:@selector(threadMainMethod:) object:documentPath] start];
+ vc.view = [[View alloc] initWithFrame:[self.window frame]];
+}
+- (void)threadMainMethod:(NSString *)documentPath
+{
@autoreleasepool {
- lo_initialize();
+ lo_initialize(documentPath);
touch_lo_runMain();
}
}
+- (void)showDocumentList:(NSArray*)documents inFolder:(NSString*)folder
+{
+ UITableViewController *vc = [DocumentTableViewController createForDocuments:documents forAppDelegate:self];
+ self.window.rootViewController = vc;
+}
+
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/DocumentTableViewController.h b/ios/experimental/TiledLibreOffice/TiledLibreOffice/DocumentTableViewController.h
new file mode 100644
index 000000000000..ce5389ac71dc
--- /dev/null
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/DocumentTableViewController.h
@@ -0,0 +1,19 @@
+// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+//
+// This file is part of the LibreOffice project.
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// 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 <UIKit/UIKit.h>
+
+#import "AppDelegate.h"
+
+@interface DocumentTableViewController : UITableViewController
+
++ (id)createForDocuments:(NSArray*)documents forAppDelegate:(AppDelegate*)appDelegate;
+
+@end
+
+// vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/DocumentTableViewController.m b/ios/experimental/TiledLibreOffice/TiledLibreOffice/DocumentTableViewController.m
new file mode 100644
index 000000000000..27de342a0253
--- /dev/null
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/DocumentTableViewController.m
@@ -0,0 +1,59 @@
+// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+//
+// This file is part of the LibreOffice project.
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// 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 <UIKit/UIKit.h>
+
+#import "AppDelegate.h"
+#import "DocumentTableViewController.h"
+
+@interface DocumentTableViewController ()
+{
+ NSArray *documents;
+ AppDelegate *appDelegate;
+}
+@end
+
+@implementation DocumentTableViewController
+
++ (id)createForDocuments:(NSArray*)documents forAppDelegate:(AppDelegate*)appDelegate;
+{
+ DocumentTableViewController *result = [[DocumentTableViewController alloc] initWithStyle:UITableViewStylePlain];
+
+ result->documents = documents;
+ result->appDelegate = appDelegate;
+
+ return result;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ return [documents count];
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ static NSString *simpleTableIdentifier = @"SimpleTableCell";
+
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
+
+ if (cell == nil) {
+ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
+ }
+
+ cell.textLabel.text = [[documents objectAtIndex:indexPath.row] lastPathComponent];
+ return cell;
+}
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ [appDelegate startDisplaying:[documents objectAtIndex:indexPath.row]];
+}
+
+@end
+
+// vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledLibreOffice-Info.plist b/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledLibreOffice-Info.plist
index c20aa82d7467..4110a9cf10f2 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledLibreOffice-Info.plist
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledLibreOffice-Info.plist
@@ -28,6 +28,8 @@
<array>
<string>armv7</string>
</array>
+ <key>UIFileSharingEnabled</key>
+ <true/>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.h b/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.h
index 0997c84379cb..f22794d20c3b 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.h
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.h
@@ -6,11 +6,13 @@
// 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 <UIKit/UIKit.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-void lo_initialize(void);
+void lo_initialize(NSString *documentPath);
#ifdef __cplusplus
}
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm b/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm
index 09cdc95d7605..4f60d05e5c88 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm
@@ -38,19 +38,20 @@ static NSString *createPaths(NSString *base, NSString *appRootEscaped, NSArray *
return result;
}
-extern "C" void lo_initialize(void)
+extern "C" void lo_initialize(NSString *documentPath)
{
- NSString * bundlePath = [[NSBundle mainBundle] bundlePath];
- NSString * app_root_escaped = [bundlePath stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
- NSString * uno_types = createPaths(@"-env:UNO_TYPES=", app_root_escaped, @[@"offapi.rdb", @"oovbaapi.rdb", @"types.rdb"]);
- NSString * uno_services = createPaths(@"-env:UNO_SERVICES=", app_root_escaped, @[@"ure/services.rdb", @"services.rdb"]);
+ NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
+ NSString *app_root_escaped = [bundlePath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+ NSString *uno_types = createPaths(@"-env:UNO_TYPES=", app_root_escaped, @[@"offapi.rdb", @"oovbaapi.rdb", @"types.rdb"]);
+ NSString *uno_services = createPaths(@"-env:UNO_SERVICES=", app_root_escaped, @[@"ure/services.rdb", @"services.rdb"]);
const char *argv[] = {
[[[NSBundle mainBundle] executablePath] UTF8String],
"-env:URE_INTERNAL_LIB_DIR=file:///",
[uno_types UTF8String],
[uno_services UTF8String],
- [[@"file://" stringByAppendingString: [app_root_escaped stringByAppendingPathComponent: @"test1.odt"]] UTF8String]};
+ [[@"file://" stringByAppendingString: [documentPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] UTF8String]
+ };
const int argc = sizeof(argv)/sizeof(*argv);