summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2013-03-20 09:07:52 +0200
committerTor Lillqvist <tml@iki.fi>2013-03-21 13:28:32 +0200
commit63dcca42cebd3cb6f020ec75c0d225e1d7232e1c (patch)
treef1b1442af9d7f6f4736ca9621389f6fcc78179e8 /ios
parent27388c9483b5e00b593ac126092c5bbb131492b0 (diff)
Re-work the vcl aspects of the iOS port
Don't try to use similar code as for OS X to manage windows, events etc. I.e. don't use UIKit in vcl to do that. Instead, just do as in the Android port, use the "headless" vcl backend. Do keep using CoreText, though, not FreeType & fontconfig. Start changing the iOS "Viewer" app to correspond to the Android "desktop" app (so it should be renamed). Work in progress since a long time, several crucial details still missing, but committing for now. Change-Id: Iac5fbf8def415e4d0d21e5200450a373420ad7ee
Diffstat (limited to 'ios')
-rw-r--r--ios/CustomTarget_Viewer_app.mk2
-rw-r--r--ios/Executable_Viewer.mk10
-rw-r--r--ios/experimental/Viewer/Viewer/LOViewerAppDelegate.h19
-rw-r--r--ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm31
-rw-r--r--ios/experimental/Viewer/Viewer/LOViewerWindow.h17
-rw-r--r--ios/experimental/Viewer/Viewer/LOViewerWindow.m26
-rw-r--r--ios/experimental/Viewer/Viewer/lo-viewer.h1
-rw-r--r--ios/experimental/Viewer/Viewer/lo-viewer.mm69
-rw-r--r--ios/experimental/Viewer/Viewer/main.mm1
9 files changed, 106 insertions, 70 deletions
diff --git a/ios/CustomTarget_Viewer_app.mk b/ios/CustomTarget_Viewer_app.mk
index 03daa6aa9008..cd79db17a2f0 100644
--- a/ios/CustomTarget_Viewer_app.mk
+++ b/ios/CustomTarget_Viewer_app.mk
@@ -114,7 +114,7 @@ $(SCRIPT_OUTPUT_FILE_0) : $(call gb_Executable_get_target,Viewer)
echo '[Bootstrap]' && \
echo 'InstallMode=<installmode>' && \
echo 'ProductKey=LibreOffice Viewer $(PRODUCTVERSION)' && \
- echo 'UserInstallation=file://$$APP_DATA_DIR' && \
+ echo 'UserInstallation=file://$$APP_DATA_DIR/../Library/Application%20Support' && \
: ) > $(appdir)/program/bootstraprc
#
# Is this really needed?
diff --git a/ios/Executable_Viewer.mk b/ios/Executable_Viewer.mk
index d52962127e72..edfc498b1b8e 100644
--- a/ios/Executable_Viewer.mk
+++ b/ios/Executable_Viewer.mk
@@ -27,6 +27,10 @@ $(eval $(call gb_Executable_add_objcxxobjects,Viewer,\
ios/experimental/Viewer/Viewer/main \
))
+$(eval $(call gb_Executable_add_objcobjects,Viewer,\
+ ios/experimental/Viewer/Viewer/LOViewerWindow \
+))
+
# The executables built for iOS link to all LO libs statically. The
# link command just uses the wildcard function to list all of them.
# Instead of tediously here declare dependencies on the transitive
@@ -41,4 +45,10 @@ $(eval $(call gb_Executable_use_libraries,Viewer,\
swui \
))
+# Mark the executable as depending on all libraries so that it gets
+# rebuilt if any library has been rebuilt. Avoids need for "make
+# ios.clean".
+
+$(call gb_LinkTarget_get_target,Executable/Viewer) : $(wildcard $(OUTDIR)/lib/lib*.a)
+
# vim: set ts=4 sw=4 et:
diff --git a/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.h b/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.h
index 7f4b724b94f8..c1737a01e342 100644
--- a/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.h
+++ b/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.h
@@ -1,16 +1,23 @@
+// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
//
-// LOViewerAppDelegate.h
-// Viewer
-//
-// Created by Tor Lillqvist on 2012-11-27.
-// Copyright (c) 2012 Tor Lillqvist. All rights reserved.
+// 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 "LOViewerWindow.h"
+
@interface LOViewerAppDelegate : UIResponder <UIApplicationDelegate>
+{
+ int nbytes;
+ char *pixelBuffer;
+ CGImageRef image;
+}
-@property (strong, nonatomic) UIWindow *window;
+@property (strong, nonatomic) LOViewerWindow *window;
- (void) threadMainMethod: (id) argument;
diff --git a/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm b/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm
index cc1e8d2f3c17..f9678c4f7393 100644
--- a/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm
+++ b/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm
@@ -5,16 +5,20 @@
// 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/.
-//
#include <stdlib.h>
#import <UIKit/UIKit.h>
+#include <osl/detail/ios-bootstrap.h>
+
#import "LOViewerAppDelegate.h"
+#import "LOViewerWindow.h"
#include "lo-viewer.h"
+static UIWindow *theWindow;
+
@implementation LOViewerAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
@@ -22,10 +26,25 @@
(void) application;
(void) launchOptions;
- self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+ CGRect bounds = [[UIScreen mainScreen] bounds];
+ self.window = [[LOViewerWindow alloc] initWithFrame:bounds];
+
+ theWindow = self.window;
self.window.backgroundColor = [UIColor whiteColor];
+ nbytes = bounds.size.width * bounds.size.height * 4;
+
+ pixelBuffer = (char *) malloc(nbytes);
+ memset(pixelBuffer, 0xFF, nbytes);
+
+ CGDataProviderRef provider = CGDataProviderCreateWithData( NULL, pixelBuffer, nbytes, NULL);
+ image = CGImageCreate(bounds.size.width, bounds.size.height, 8, 32, bounds.size.width*4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaFirst, provider, NULL, false, kCGRenderingIntentDefault);
+
+ self.window.bounds = bounds;
+ self.window.pixelBuffer = pixelBuffer;
+ self.window.image = image;
+
[self.window makeKeyAndVisible];
NSThread* thread = [[NSThread alloc] initWithTarget:self
@@ -41,9 +60,8 @@
(void) argument;
@autoreleasepool {
-
lo_initialize();
-
+ lo_runMain();
}
}
@@ -86,4 +104,9 @@
@end
+extern "C" void lo_damaged()
+{
+ [theWindow performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:YES];
+}
+
// vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/ios/experimental/Viewer/Viewer/LOViewerWindow.h b/ios/experimental/Viewer/Viewer/LOViewerWindow.h
new file mode 100644
index 000000000000..b8f509f98471
--- /dev/null
+++ b/ios/experimental/Viewer/Viewer/LOViewerWindow.h
@@ -0,0 +1,17 @@
+// -*- 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>
+
+@interface LOViewerWindow : UIWindow
+@property CGRect bounds;
+@property char *pixelBuffer;
+@property CGImageRef image;
+- (void)drawRect:(CGRect)rect;
+@end
diff --git a/ios/experimental/Viewer/Viewer/LOViewerWindow.m b/ios/experimental/Viewer/Viewer/LOViewerWindow.m
new file mode 100644
index 000000000000..1ce91033f384
--- /dev/null
+++ b/ios/experimental/Viewer/Viewer/LOViewerWindow.m
@@ -0,0 +1,26 @@
+// -*- 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 "LOViewerWindow.h"
+
+#include <osl/detail/ios-bootstrap.h>
+
+@implementation LOViewerWindow
+
+- (void)drawRect:(CGRect)rect
+{
+ (void) rect;
+
+ lo_render_windows([self pixelBuffer], [self bounds].size.width, [self bounds].size.height);
+
+ CGContextRef context = UIGraphicsGetCurrentContext();
+
+ CGContextDrawImage(context, [self bounds], [self image]);
+}
+
+@end
diff --git a/ios/experimental/Viewer/Viewer/lo-viewer.h b/ios/experimental/Viewer/Viewer/lo-viewer.h
index 1ce2031811a7..9d08e3a8b851 100644
--- a/ios/experimental/Viewer/Viewer/lo-viewer.h
+++ b/ios/experimental/Viewer/Viewer/lo-viewer.h
@@ -5,7 +5,6 @@
// 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/.
-//
#ifndef LO_VIEWER_H
#define LO_VIEWER_H
diff --git a/ios/experimental/Viewer/Viewer/lo-viewer.mm b/ios/experimental/Viewer/Viewer/lo-viewer.mm
index ff543fc9df6e..97669f14584e 100644
--- a/ios/experimental/Viewer/Viewer/lo-viewer.mm
+++ b/ios/experimental/Viewer/Viewer/lo-viewer.mm
@@ -5,7 +5,6 @@
// 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/.
-//
#include <stdlib.h>
@@ -72,6 +71,7 @@ extern "C" {
extern void * textfd_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * unoxml_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * unordf_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
+ extern void * uui_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * xmlfd_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * xmlsecurity_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * xo_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
@@ -108,6 +108,7 @@ lo_get_libmap(void)
{ "libsdlo.a", sd_component_getFactory },
{ "libsmdlo.a", smd_component_getFactory },
{ "libsmlo.a", sm_component_getFactory },
+ { "libspelllo.a", spell_component_getFactory },
{ "libsvgfilterlo.a", svgfilter_component_getFactory },
{ "libswdlo.a", swd_component_getFactory },
{ "libswlo.a", sw_component_getFactory },
@@ -115,6 +116,7 @@ lo_get_libmap(void)
{ "libtextfdlo.a", textfd_component_getFactory },
{ "libunordflo.a", unordf_component_getFactory },
{ "libunoxmllo.a", unoxml_component_getFactory },
+ { "libuuilo.a", uui_component_getFactory },
{ "libxmlfdlo.a", xmlfd_component_getFactory },
{ "libxmlsecurity.a", xmlsecurity_component_getFactory },
{ "libxoflo.a", xof_component_getFactory },
@@ -134,7 +136,8 @@ lo_initialize(void)
"placeholder-exe",
"-env:URE_INTERNAL_LIB_DIR=file:///",
"placeholder-uno-types",
- "placeholder-uno-services"
+ "placeholder-uno-services",
+ "placeholder-document"
};
const int argc = sizeof(argv)/sizeof(*argv);
@@ -154,8 +157,8 @@ lo_initialize(void)
uno_types = [uno_types stringByAppendingString: @" file://"];
uno_types = [uno_types stringByAppendingString: [app_root_escaped stringByAppendingPathComponent: @"offapi.rdb"]];
- assert(strcmp(argv[argc-2], "placeholder-uno-types") == 0);
- argv[argc-2] = [uno_types UTF8String];
+ assert(strcmp(argv[2], "placeholder-uno-types") == 0);
+ argv[2] = [uno_types UTF8String];
NSString *uno_services = @"-env:UNO_SERVICES=";
@@ -165,59 +168,11 @@ lo_initialize(void)
uno_services = [uno_services stringByAppendingString: @" file://"];
uno_services = [uno_services stringByAppendingString: [app_root_escaped stringByAppendingPathComponent: @"services.rdb"]];
- assert(strcmp(argv[argc-1], "placeholder-uno-services") == 0);
- argv[argc-1] = [uno_services UTF8String];
-
- osl_setCommandArgs(argc, (char **) argv);
-
- try {
-
- // Should start a background thread to do all this UNO
- // initialisation crap
-
- uno::Reference< uno::XComponentContext > xContext(::cppu::defaultBootstrap_InitialComponentContext());
-
- uno::Reference< lang::XMultiComponentFactory > xFactory( xContext->getServiceManager() );
-
- uno::Reference< lang::XMultiServiceFactory > xSM( xFactory, uno::UNO_QUERY_THROW );
-
- comphelper::setProcessServiceFactory( xSM );
+ assert(strcmp(argv[3], "placeholder-uno-services") == 0);
+ argv[3] = [uno_services UTF8String];
- InitVCL();
+ assert(strcmp(argv[4], "placeholder-document") == 0);
+ argv[4] = [[app_root_escaped stringByAppendingPathComponent: @"test1.odt"] UTF8String];
- // Yes, this code does of course not belong here. Once this
- // turns into something that actually displays something and
- // has a proper app lifecycle etc that willl be fixed. But for
- // now this is just a test, not supposed to work in any sane
- // way from a "user" POV, and it doesn't matter that we do
- // this here.
-
- uno::Reference< uno::XInterface > xDesktop =
- xFactory->createInstanceWithContext( "com.sun.star.frame.Desktop", xContext );
- uno::Reference< frame::XComponentLoader > xComponentLoader( xDesktop, uno::UNO_QUERY_THROW );
-
- uno::Reference< uno::XInterface > xToolkitService =
- xFactory->createInstanceWithContext( "com.sun.star.awt.Toolkit", xContext );
-
- uno::Reference< awt::XToolkitExperimental > xToolkit( xToolkitService, uno::UNO_QUERY_THROW );
-
- char *smallbb = new char[ SMALLSIZE*SMALLSIZE*4 ];
-
- uno::Reference< awt::XDevice > xDummyDevice = xToolkit->createScreenCompatibleDeviceUsingBuffer( SMALLSIZE, SMALLSIZE, 1, 1, 0, 0, (sal_Int64) (intptr_t) smallbb);
-
- uno::Sequence< beans::PropertyValue > loadProps(3);
-
- loadProps[0].Name = "Hidden";
- loadProps[0].Value <<= sal_True;
- loadProps[1].Name = "ReadOnly";
- loadProps[1].Value <<= sal_True;
- loadProps[2].Name = "Preview";
- loadProps[2].Value <<= sal_True;
-
- OUString test1_odt( OUString( "file://" ) + OUString::createFromAscii( [[app_root_escaped stringByAppendingPathComponent: @"test1.odt"] UTF8String] ));
- uno::Reference< lang::XComponent > xDoc = xComponentLoader->loadComponentFromURL ( test1_odt, "_blank", 0, loadProps );
- }
- catch ( uno::Exception e ) {
- SAL_WARN("Viewer", e.Message);
- }
+ osl_setCommandArgs(argc, (char **) argv);
}
diff --git a/ios/experimental/Viewer/Viewer/main.mm b/ios/experimental/Viewer/Viewer/main.mm
index 247c2dc6afca..401cda5a4c52 100644
--- a/ios/experimental/Viewer/Viewer/main.mm
+++ b/ios/experimental/Viewer/Viewer/main.mm
@@ -5,7 +5,6 @@
// 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>