summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2015-02-04 17:48:41 +0100
committerTor Lillqvist <tml@collabora.com>2015-02-04 18:07:30 +0100
commit4b269ecb7a699318b067eb64c464460b1783d3d2 (patch)
tree9e9cdc73ca84f48f64a400545e84023bad86d35e /ios
parentac8a2dee02032db2523888927f7973b219f3a9a9 (diff)
Use LibreOfficeKit in the TiledLibreOffice iOS demo app, too
For iOS, the pBuffer argument to LibreOfficeKitDocument::paintTile() is not a pixel buffer, but a CGContextRef. Thus we can keep the existing CGContext-oriented vcl code for iOS as is. I commented out the <touch/touch.h> -using code in sw, and it probably would be OK to just kill <touch/touch.h> and remove use and implementations of its API. I don't think they are used by our current Android or iOS code. This concludes the commits of the work I did at the post-FOSDEM hackfest and on the flight home. TiledLibreOffice now works as before, but uses LibreOfficeKit. Change-Id: Ibbde6e11d660561840eab6335f7fc0db6758173e
Diffstat (limited to 'ios')
-rw-r--r--ios/CustomTarget_TiledLibreOffice_app.mk13
-rw-r--r--ios/experimental/TiledLibreOffice/TiledLibreOffice.xcodeproj/project.pbxproj20
-rw-r--r--ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m53
-rw-r--r--ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.h5
-rw-r--r--ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m21
-rw-r--r--ios/experimental/TiledLibreOffice/TiledLibreOffice/View.h3
-rw-r--r--ios/experimental/TiledLibreOffice/TiledLibreOffice/View.m21
-rw-r--r--ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm5
8 files changed, 67 insertions, 74 deletions
diff --git a/ios/CustomTarget_TiledLibreOffice_app.mk b/ios/CustomTarget_TiledLibreOffice_app.mk
index d578d2300f93..f9f80285b233 100644
--- a/ios/CustomTarget_TiledLibreOffice_app.mk
+++ b/ios/CustomTarget_TiledLibreOffice_app.mk
@@ -50,14 +50,14 @@ TiledLibreOffice_setup:
# Resources #
rm -rf $(TiledLibreOffice_resource) 2>/dev/null
mkdir -p $(TiledLibreOffice_resource)
- mkdir -p $(TiledLibreOffice_resource)/ure
+ mkdir -p $(TiledLibreOffice_resource)/services
# copy rdb files
- cp $(INSTDIR)/program/types.rdb $(TiledLibreOffice_resource)
+ cp $(INSTDIR)/program/types.rdb $(TiledLibreOffice_resource)/udkapi.rdb
cp $(INSTDIR)/program/types/offapi.rdb $(TiledLibreOffice_resource)
cp $(INSTDIR)/program/types/oovbaapi.rdb $(TiledLibreOffice_resource)
- cp $(INSTDIR)/program/services/services.rdb $(TiledLibreOffice_resource)
- cp $(INSTDIR)/program/services.rdb $(TiledLibreOffice_resource)/ure
+ cp $(INSTDIR)/program/services/services.rdb $(TiledLibreOffice_resource)/services
+ cp $(INSTDIR)/program/services.rdb $(TiledLibreOffice_resource)
# copy .res files
# program/resource is hardcoded in tools/source/rc/resmgr.cxx. Sure,
@@ -93,7 +93,10 @@ TiledLibreOffice_setup:
echo '[Bootstrap]' > $$file; \
echo 'LO_LIB_DIR=file://$$APP_DATA_DIR/lib/' >> $$file; \
echo 'BRAND_BASE_DIR=file://$$APP_DATA_DIR' >> $$file; \
- echo 'CONFIGURATION_LAYERS=xcsxcu:$${BRAND_BASE_DIR}/share/registry res:$${BRAND_BASE_DIR}/registry' >> $$file;
+ echo 'CONFIGURATION_LAYERS=xcsxcu:$${BRAND_BASE_DIR}/share/registry res:$${BRAND_BASE_DIR}/registry' >> $$file; \
+ echo 'UNO_TYPES=file://$$APP_DATA_DIR/udkapi.rdb file://$$APP_DATA_DIR/offapi.rdb' >> $$file; \
+ echo 'UNO_SERVICES=file://$$APP_DATA_DIR/services.rdb file://$$APP_DATA_DIR/services/services.rdb' >> $$file; \
+ echo 'OSL_SOCKET_PATH=$$APP_DATA_DIR/cache' >> $$file
file=$(TiledLibreOffice_resource)/unorc; \
echo '[Bootstrap]' > $$file;
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice.xcodeproj/project.pbxproj b/ios/experimental/TiledLibreOffice/TiledLibreOffice.xcodeproj/project.pbxproj
index 1b418bb4d1c3..c5d9a6c21c10 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice.xcodeproj/project.pbxproj
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice.xcodeproj/project.pbxproj
@@ -24,7 +24,7 @@
BED2594118F6B89000C94C72 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BED2594018F6B89000C94C72 /* MobileCoreServices.framework */; };
BEEE02D11860ABDB00FBDE67 /* program in Resources */ = {isa = PBXBuildFile; fileRef = BEEE02CE1860ABB700FBDE67 /* program */; };
BEEE02D21860ABDB00FBDE67 /* share in Resources */ = {isa = PBXBuildFile; fileRef = BEEE02CF1860ABB700FBDE67 /* share */; };
- BEEE02D31860ABDB00FBDE67 /* ure in Resources */ = {isa = PBXBuildFile; fileRef = BEEE02D01860ABB700FBDE67 /* ure */; };
+ BEEE02D31860ABDB00FBDE67 /* services in Resources */ = {isa = PBXBuildFile; fileRef = BEEE02D01860ABB700FBDE67 /* services */; };
BEEEF9641860740400FBDE67 /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BEEEF9631860740400FBDE67 /* libiconv.dylib */; };
BEEEF9661860741400FBDE67 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BEEEF9651860741400FBDE67 /* libz.dylib */; };
BEEEF96A1860A25400FBDE67 /* test1.odt in Resources */ = {isa = PBXBuildFile; fileRef = BEEEF9691860A25400FBDE67 /* test1.odt */; };
@@ -33,7 +33,7 @@
BEEEFE031860A89100FBDE67 /* oovbaapi.rdb in Resources */ = {isa = PBXBuildFile; fileRef = BEEEF96F1860A82900FBDE67 /* oovbaapi.rdb */; };
BEEEFE041860A89100FBDE67 /* rc in Resources */ = {isa = PBXBuildFile; fileRef = BEEEF9AA1860A82900FBDE67 /* rc */; };
BEEEFE051860A89100FBDE67 /* services.rdb in Resources */ = {isa = PBXBuildFile; fileRef = BEEEF9AB1860A82900FBDE67 /* services.rdb */; };
- BEEEFE061860A89100FBDE67 /* types.rdb in Resources */ = {isa = PBXBuildFile; fileRef = BEEEFDFD1860A82C00FBDE67 /* types.rdb */; };
+ BEEEFE061860A89100FBDE67 /* udkapi.rdb in Resources */ = {isa = PBXBuildFile; fileRef = BEEEFDFD1860A82C00FBDE67 /* udkapi.rdb */; };
BEEEFE071860A89100FBDE67 /* unorc in Resources */ = {isa = PBXBuildFile; fileRef = BEEEFDFE1860A82C00FBDE67 /* unorc */; };
/* End PBXBuildFile section */
@@ -449,7 +449,7 @@
BE6DC92E19D9B5DD00AFB393 /* mutex.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = mutex.c; path = ../../../sal/osl/unx/mutex.c; sourceTree = "<group>"; };
BE6DC92F19D9B5DD00AFB393 /* nlsupport.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = nlsupport.c; path = ../../../sal/osl/unx/nlsupport.c; sourceTree = "<group>"; };
BE6DC93019D9B5DD00AFB393 /* osxlocale.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = osxlocale.cxx; path = ../../../sal/osl/unx/osxlocale.cxx; sourceTree = "<group>"; };
- BE6DC93119D9B5DD00AFB393 /* pipe.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = pipe.c; path = ../../../sal/osl/unx/pipe.c; sourceTree = "<group>"; };
+ BE6DC93119D9B5DD00AFB393 /* pipe.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = pipe.cxx; path = ../../../sal/osl/unx/pipe.cxx; sourceTree = "<group>"; };
BE6DC93219D9B5DD00AFB393 /* process_impl.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = process_impl.cxx; path = ../../../sal/osl/unx/process_impl.cxx; sourceTree = "<group>"; };
BE6DC93319D9B5DD00AFB393 /* process.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = process.cxx; path = ../../../sal/osl/unx/process.cxx; sourceTree = "<group>"; };
BE6DC93419D9B5DD00AFB393 /* profile.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = profile.cxx; path = ../../../sal/osl/unx/profile.cxx; sourceTree = "<group>"; };
@@ -898,7 +898,7 @@
BEDB0F08185B7537009A6F26 /* lo.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = lo.xcconfig; path = ../../../lo.xcconfig; sourceTree = "<group>"; };
BEEE02CE1860ABB700FBDE67 /* program */ = {isa = PBXFileReference; lastKnownFileType = folder; name = program; path = Resources/program; sourceTree = SOURCE_ROOT; };
BEEE02CF1860ABB700FBDE67 /* share */ = {isa = PBXFileReference; lastKnownFileType = folder; name = share; path = Resources/share; sourceTree = SOURCE_ROOT; };
- BEEE02D01860ABB700FBDE67 /* ure */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ure; path = Resources/ure; sourceTree = SOURCE_ROOT; };
+ BEEE02D01860ABB700FBDE67 /* services */ = {isa = PBXFileReference; lastKnownFileType = folder; name = services; path = Resources/services; sourceTree = SOURCE_ROOT; };
BEEEF9631860740400FBDE67 /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = usr/lib/libiconv.dylib; sourceTree = SDKROOT; };
BEEEF9651860741400FBDE67 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
BEEEF9691860A25400FBDE67 /* test1.odt */ = {isa = PBXFileReference; lastKnownFileType = file; name = test1.odt; path = ../../../../odk/examples/java/DocumentHandling/test/test1.odt; sourceTree = "<group>"; };
@@ -907,7 +907,7 @@
BEEEF96F1860A82900FBDE67 /* oovbaapi.rdb */ = {isa = PBXFileReference; lastKnownFileType = file; name = oovbaapi.rdb; path = Resources/oovbaapi.rdb; sourceTree = SOURCE_ROOT; };
BEEEF9AA1860A82900FBDE67 /* rc */ = {isa = PBXFileReference; lastKnownFileType = text; name = rc; path = Resources/rc; sourceTree = SOURCE_ROOT; };
BEEEF9AB1860A82900FBDE67 /* services.rdb */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = services.rdb; path = Resources/services.rdb; sourceTree = SOURCE_ROOT; };
- BEEEFDFD1860A82C00FBDE67 /* types.rdb */ = {isa = PBXFileReference; lastKnownFileType = file; name = types.rdb; path = Resources/types.rdb; sourceTree = SOURCE_ROOT; };
+ BEEEFDFD1860A82C00FBDE67 /* udkapi.rdb */ = {isa = PBXFileReference; lastKnownFileType = file; name = udkapi.rdb; path = Resources/udkapi.rdb; sourceTree = SOURCE_ROOT; };
BEEEFDFE1860A82C00FBDE67 /* unorc */ = {isa = PBXFileReference; lastKnownFileType = text; name = unorc; path = Resources/unorc; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
@@ -1539,7 +1539,7 @@
BE6DC92E19D9B5DD00AFB393 /* mutex.c */,
BE6DC92F19D9B5DD00AFB393 /* nlsupport.c */,
BE6DC93019D9B5DD00AFB393 /* osxlocale.cxx */,
- BE6DC93119D9B5DD00AFB393 /* pipe.c */,
+ BE6DC93119D9B5DD00AFB393 /* pipe.cxx */,
BE6DC93219D9B5DD00AFB393 /* process_impl.cxx */,
BE6DC93319D9B5DD00AFB393 /* process.cxx */,
BE6DC93419D9B5DD00AFB393 /* profile.cxx */,
@@ -2237,9 +2237,9 @@
BEEEF9AA1860A82900FBDE67 /* rc */,
BEEEF9AB1860A82900FBDE67 /* services.rdb */,
BEEE02CF1860ABB700FBDE67 /* share */,
- BEEEFDFD1860A82C00FBDE67 /* types.rdb */,
+ BEEEFDFD1860A82C00FBDE67 /* udkapi.rdb */,
BEEEFDFE1860A82C00FBDE67 /* unorc */,
- BEEE02D01860ABB700FBDE67 /* ure */,
+ BEEE02D01860ABB700FBDE67 /* services */,
BEEEF9691860A25400FBDE67 /* test1.odt */,
BE03BF9218F9A7CC00620DC7 /* icudt54l.dat */,
);
@@ -2308,9 +2308,9 @@
BEEEFE051860A89100FBDE67 /* services.rdb in Resources */,
BEEE02D21860ABDB00FBDE67 /* share in Resources */,
BE03BF9318F9A7CC00620DC7 /* icudt54l.dat in Resources */,
- BEEEFE061860A89100FBDE67 /* types.rdb in Resources */,
+ BEEEFE061860A89100FBDE67 /* udkapi.rdb in Resources */,
BEEEFE071860A89100FBDE67 /* unorc in Resources */,
- BEEE02D31860ABDB00FBDE67 /* ure in Resources */,
+ BEEE02D31860ABDB00FBDE67 /* services in Resources */,
BEEEF96A1860A25400FBDE67 /* test1.odt in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m b/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m
index 17fa4332114f..652496c32c9d 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m
@@ -6,7 +6,8 @@
// 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/.
-#include <touch/touch.h>
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKitInit.h>
#import "AppDelegate.h"
#import "DocumentTableViewController.h"
@@ -17,12 +18,14 @@
@interface AppDelegate ()
- (void)showDocumentList:(NSArray*)documents inFolder:(NSString*)folder;
-- (void)threadMainMethod:(NSString *)documentPath;
@end
@implementation AppDelegate
+static LibreOfficeKit* kit;
+static LibreOfficeKitDocument* document;
+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
@@ -72,16 +75,11 @@ const char *ptyl_test_encryption_pathname;
ptyl_test_encryption_pathname = [documentPath UTF8String];
- [[[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(documentPath);
- touch_lo_runMain();
- }
+ // kit = lok_init([[[NSBundle mainBundle] bundlePath] UTF8String]);
+ kit = lok_init(NULL);
+ document = kit->pClass->documentLoad(kit, [documentPath UTF8String]);
+ document->pClass->initializeForRendering(document);
+ vc.view = [[View alloc] initWithFrame:[self.window frame] kit:kit document:document];
}
- (void)showDocumentList:(NSArray*)documents inFolder:(NSString*)folder
@@ -133,35 +131,4 @@ const char *ptyl_test_encryption_pathname;
@end
-// dummies
-
-void touch_ui_selection_start(MLOSelectionKind kind,
- const void *documentHandle,
- MLORect *rectangles,
- int rectangleCount,
- void *preview)
-{
-}
-
-void touch_ui_selection_none()
-{
-}
-
-MLODialogResult touch_ui_dialog_modal(MLODialogKind kind, const char *message)
-{
- return MLODialogCancel;
-}
-
-void touch_ui_show_keyboard()
-{
-}
-
-void touch_ui_hide_keyboard()
-{
-}
-
-void touch_ui_damaged(int minX, int minY, int width, int height)
-{
-}
-
// vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.h b/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.h
index 2b228e6e1c30..d0d20c3506c6 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.h
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.h
@@ -8,9 +8,12 @@
#import <UIKit/UIKit.h>
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKit.h>
+
@interface TiledView : UIView
-- (id)initWithFrame:(CGRect)frame scale:(CGFloat)scale maxZoom:(int)maxZoom;
+- (id)initWithFrame:(CGRect)frame scale:(CGFloat)scale maxZoom:(int)maxZoom document:(LibreOfficeKitDocument*)document;
@end
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m b/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m
index 1b8b8c20e481..4092379400ad 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m
@@ -8,7 +8,8 @@
#include <CoreText/CoreText.h>
-#include <touch/touch.h>
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKit.h>
#import "View.h"
#import "TiledView.h"
@@ -31,6 +32,8 @@ static struct {
static int oldestTimestampIndex = 0;
static int nextTimestampIndex = 0;
+static LibreOfficeKitDocument* loDocument;
+
static void dropOldTimestamps(CFTimeInterval now)
{
// Drop too old timestamps
@@ -96,8 +99,10 @@ int DBG_DRAW_ROUNDS_MAX = INT_MAX;
[NSTimer scheduledTimerWithTimeInterval:DBG_DRAW_DELAY target:self selector:@selector(redraw) userInfo:nil repeats:NO];
}
-- (id)initWithFrame:(CGRect)frame scale:(CGFloat)scale maxZoom:(int)maxZoom
+- (id)initWithFrame:(CGRect)frame scale:(CGFloat)scale maxZoom:(int)maxZoom document:(LibreOfficeKitDocument*)document
{
+ loDocument = document;
+
self = [super initWithFrame:frame];
if (self) {
self.scale = scale;
@@ -157,7 +162,7 @@ extern const char *ptyl_test_encryption_pathname;
// CGSize tileSize = [catl tileSize];
CGSize tileSize = bb.size;
- // NSLog(@"bb:%.0fx%.0f@(%.0f,%.0f) zoomScale:%.0f tile:%.0fx%.0f at:(%.0f,%.0f) size:%.0fx%.0f", bb.size.width, bb.size.height, bb.origin.x, bb.origin.y, zoomScale, tileSize.width, tileSize.height, bb.origin.x/self.scale, bb.origin.y/self.scale, bb.size.width/self.scale, bb.size.height/self.scale);
+ NSLog(@"bb:%.0fx%.0f@(%.0f,%.0f) zoomScale:%.0f tile:%.0fx%.0f at:(%.0f,%.0f) size:%.0fx%.0f", bb.size.width, bb.size.height, bb.origin.x, bb.origin.y, [((View *) [self superview]) zoomScale], tileSize.width, tileSize.height, bb.origin.x/self.scale, bb.origin.y/self.scale, bb.size.width/self.scale, bb.size.height/self.scale);
// I don't really claim to fully understand all this. It did at
// first seem a bit weird to be passing in a "context width x
@@ -171,10 +176,12 @@ extern const char *ptyl_test_encryption_pathname;
if (!getenv("DRAW_ONLY_TILE") || tileMatches(getenv("DRAW_ONLY_TILE"), bb)) {
fprintf(stderr, "+++ rendering to context %p\n", ctx);
- touch_lo_draw_tile(ctx,
- tileSize.width, tileSize.height,
- CGPointMake(bb.origin.x/self.scale, bb.origin.y/self.scale),
- CGSizeMake(bb.size.width/self.scale, bb.size.height/self.scale));
+ int rowStride;
+ loDocument->pClass->paintTile(loDocument, (unsigned char *)ctx,
+ tileSize.width, tileSize.height,
+ &rowStride,
+ bb.origin.x/self.scale, bb.origin.y/self.scale,
+ bb.size.width/self.scale, bb.size.height/self.scale);
} else {
CGContextSetRGBFillColor(ctx, 1, 1, 1, 1);
CGContextFillRect(ctx, CGRectMake(0, 0, bb.size.width, bb.size.height));
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/View.h b/ios/experimental/TiledLibreOffice/TiledLibreOffice/View.h
index 041471d40071..c4269569966e 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/View.h
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/View.h
@@ -7,9 +7,12 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import <UIKit/UIKit.h>
+#import <LibreOfficeKit/LibreOfficeKit.h>
@interface View : UIScrollView <UIScrollViewDelegate>
+- (id)initWithFrame:(CGRect)frame kit:(LibreOfficeKit*)kit document:(LibreOfficeKitDocument*)document;
+
@property UILabel *tpsLabel;
@end
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/View.m b/ios/experimental/TiledLibreOffice/TiledLibreOffice/View.m
index 76ede6fdefd4..33690e1a53f7 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/View.m
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/View.m
@@ -6,7 +6,8 @@
// 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/.
-#include <touch/touch.h>
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKit.h>
#import "View.h"
#import "TiledView.h"
@@ -19,8 +20,13 @@
@implementation View
-- (id)initWithFrame:(CGRect)frame
+static LibreOfficeKit* loKit;
+static LibreOfficeKitDocument* loDocument;
+
+- (id)initWithFrame:(CGRect)frame kit:(LibreOfficeKit*)kit document:(LibreOfficeKitDocument*)document
{
+ loKit = kit;
+ loDocument = document;
self = [super initWithFrame:frame];
if (self) {
const int MAXZOOM = 8;
@@ -28,14 +34,15 @@
[self setMaximumZoomScale:MAXZOOM];
[self setDelegate:self];
- MLODpxSize docSize = touch_lo_get_content_size();
+ long docWidth, docHeight;
+ document->pClass->getDocumentSize(document, &docWidth, &docHeight);
- double widthScale = frame.size.width / docSize.width;
- double docAspectRatio = docSize.height / docSize.width;
+ double widthScale = frame.size.width / docWidth;
+ double docAspectRatio = docHeight / docWidth;
- // NSLog(@"View frame=%.0fx%.0f docSize=%.0fx%.0f scale=%.3f aspectRatio=%.3f", frame.size.width, frame.size.height, docSize.width, docSize.height, widthScale, docAspectRatio);
+ // NSLog(@"View frame=%.0fx%.0f docSize=%.0fx%.0f scale=%.3f aspectRatio=%.3f", frame.size.width, frame.size.height, docWidth, docHeight, widthScale, docAspectRatio);
- self.subView = [[TiledView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.width*docAspectRatio) scale:widthScale maxZoom:MAXZOOM];
+ self.subView = [[TiledView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.width*docAspectRatio) scale:widthScale maxZoom:MAXZOOM document:loDocument];
[self addSubview:self.subView];
UILabel *tpsLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 300, 40)];
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm b/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm
index de02cff3706b..f41593d97fd5 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm
@@ -15,7 +15,6 @@
#include <postmac.h>
#include <osl/process.h>
-#include <touch/touch.h>
#include <unicode/udata.h>
#include <unicode/ucnv.h>
@@ -43,6 +42,10 @@ static NSString *createPaths(NSString *base, NSString *appRootEscaped, NSArray *
return result;
}
+// Force reference to libreofficekit_hook
+extern "C" void *libreofficekit_hook(const char *);
+static __attribute__((used)) void *(*foop)(const char *) = libreofficekit_hook;
+
extern "C" void lo_initialize(NSString *documentPath)
{
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];