summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2013-10-13 20:45:16 +0300
committerTor Lillqvist <tml@collabora.com>2013-10-13 23:17:38 +0300
commite9f260b38076ce56f131914cfb5ece242eb1225c (patch)
treedb04b616a00931ab15cee70975738191bbdafca1
parent2b1329663a2034bfd622d9227573421b10bdad15 (diff)
Minor refactoring of iOS code
Rename functions so that functions called by the UI layer for actions to happen in the LO layer and functions called by the LO layer for things to happen in the UI layer use different prefixes. Move declarations to the generic <touch/touch.h> and avoid iOS-specific types in the API. Change-Id: Ieb8979065e02a87c4a415c934163265f2790d011
-rw-r--r--cppuhelper/source/shlib.cxx2
-rw-r--r--desktop/source/app/sofficemain.cxx6
-rw-r--r--include/osl/detail/ios-bootstrap.h66
-rw-r--r--include/touch/touch.h48
-rw-r--r--ios/experimental/LibreOffice/LibreOffice/AppDelegate.m25
-rw-r--r--ios/experimental/LibreOffice/LibreOffice/View.h1
-rw-r--r--ios/experimental/LibreOffice/LibreOffice/View.m18
-rw-r--r--ios/experimental/LibreOffice/LibreOffice/ViewController.m2
-rw-r--r--ios/experimental/LibreOffice/LibreOffice/lo.mm3
-rw-r--r--vcl/ios/iosinst.cxx32
10 files changed, 83 insertions, 120 deletions
diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx
index e9e021f78152..73f880947a18 100644
--- a/cppuhelper/source/shlib.cxx
+++ b/cppuhelper/source/shlib.cxx
@@ -34,7 +34,7 @@
#endif
#ifdef IOS
-#include <osl/detail/ios-bootstrap.h>
+#include <osl/detail/component-mapping.h>
#endif
using namespace ::osl;
diff --git a/desktop/source/app/sofficemain.cxx b/desktop/source/app/sofficemain.cxx
index 03d2eab718af..7678e5b47ead 100644
--- a/desktop/source/app/sofficemain.cxx
+++ b/desktop/source/app/sofficemain.cxx
@@ -39,6 +39,10 @@
# define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOGTAG, __VA_ARGS__))
#endif
+#ifdef IOS
+#include <touch/touch.h>
+#endif
+
int SVMain();
extern "C" int DESKTOP_DLLPUBLIC soffice_main()
@@ -97,7 +101,7 @@ Java_org_libreoffice_android_AppSupport_runMain(JNIEnv* /* env */,
#else
extern "C"
void
-lo_runMain()
+touch_lo_runMain()
#endif
{
int nRet;
diff --git a/include/osl/detail/ios-bootstrap.h b/include/osl/detail/ios-bootstrap.h
deleted file mode 100644
index 0225c9ac38f8..000000000000
--- a/include/osl/detail/ios-bootstrap.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- Mode: C; 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/.
- */
-
-#ifndef IOS_BOOSTRAP_H
-#define IOS_BOOSTRAP_H
-
-#if defined(IOS)
-
-#include <premac.h>
-#include <CoreGraphics/CoreGraphics.h>
-#include <postmac.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <osl/detail/component-mapping.h>
-
-/* These functions are the interface between the upper GUI layers of a
- * LibreOffice-based iOS app and the lower "core" layers, used in cases
- * where the core parts need to call functions in the upper parts or
- * vice versa.
- *
- * Thus there are two classes of functions here:
- *
- * 1) Those to be implemented in the upper layer and called by the
- * lower layer
- *
- * 2) Those implmented in the lower layers to be called by the upper
- * layer, in cases where we don't want to include a bunch of the
- * "normal" LibreOffice C++ headers in an otherwise purely Objective-C
- * CocoaTouch-based source file. Of course it depends on the case
- * where that is wanted, and this all is work in progress.
- */
-
-/* 1) */
-
-typedef enum { DOWN, MOVE, UP} LOMouseButtonState;
-
-void lo_damaged(CGRect rect);
-
-/* 2) */
-
-void lo_runMain();
-void lo_set_view_size(int width, int height);
-void lo_render_windows(CGContextRef context, CGRect rect);
-void lo_tap(int x, int y);
-void lo_pan(int deltaX, int deltaY);
-void lo_zoom(int x, int y, float scale);
-void lo_mouse_drag(int x, int y, LOMouseButtonState state);
-void lo_keyboard_input(int c);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // IOS
-#endif // IOS_BOOTSTRAP_H
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/touch/touch.h b/include/touch/touch.h
index 05ae335ab920..ebe4b19b8084 100644
--- a/include/touch/touch.h
+++ b/include/touch/touch.h
@@ -18,24 +18,48 @@
#if !HAVE_FEATURE_DESKTOP
-// Functions to be implemented by the app-specifc upper or less
-// app-specific but platform-specific medium layer on touch-based
-// platforms. The same API is used on each such platform. There are
-// called from low level LibreOffice code. Note that these are just
-// declared here in this header in the "touch" module, the
-// per-platform implementations are elsewhere.
-
#ifdef __cplusplus
extern "C" {
#endif
-void lo_show_keyboard();
-void lo_hide_keyboard();
+// These functions are the interface between the upper GUI layers of a
+// LibreOffice-based app on a touch platform app and the lower "core"
+// layers, used in cases where the core parts need to call
+// functionality in the upper parts or vice versa.
+//
+// Thus there are two classes of functions here:
+//
+// 1) Those to be implemented in the upper layer and called by the
+// lower layer. Prefixed by touch_ui_. The same API is used on each
+// such platform. There are called from low level LibreOffice
+// code. Note that these are just declared here in a header for a
+// "touch" module, the per-platform implementations are elsewhere.
+
+void touch_ui_damaged(int minX, int minY, int width, int height);
+
+void touch_ui_show_keyboard();
+void touch_ui_hide_keyboard();
+
+// 2) Those implmented in the lower layers to be called by the upper
+// layer, in cases where we don't want to include a bunch of the
+// "normal" LibreOffice C++ headers in an otherwise purely Objective-C
+// CocoaTouch-based source file. Of course it depends on the case
+// where that is wanted, and this all is work in progress. Prefixed by
+// touch_lo_.
+
+void touch_lo_keyboard_did_hide();
+
+void touch_lo_runMain();
+void touch_lo_set_view_size(int width, int height);
+void touch_lo_render_windows(void *context, int minX, int minY, int width, int height);
+void touch_lo_tap(int x, int y);
+void touch_lo_pan(int deltaX, int deltaY);
+void touch_lo_zoom(int x, int y, float scale);
+void touch_lo_keyboard_input(int c);
-// Functions to be implemented in the medium platform-specific layer
-// to be called from the app-specific UI layer.
+typedef enum { DOWN, MOVE, UP} LOMouseButtonState;
-void lo_keyboard_did_hide();
+void touch_lo_mouse_drag(int x, int y, LOMouseButtonState state);
#ifdef __cplusplus
}
diff --git a/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m b/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m
index 7e3a0a900c57..dddf3acd458b 100644
--- a/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m
+++ b/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m
@@ -8,7 +8,6 @@
#import <UIKit/UIKit.h>
-#include <osl/detail/ios-bootstrap.h>
#include <touch/touch.h>
#import "AppDelegate.h"
@@ -69,9 +68,9 @@ static View *theView;
NSLog(@"statusBarOrientation: %ld", (long) [[UIApplication sharedApplication] statusBarOrientation]);
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
- lo_set_view_size(applicationFrame.size.height, applicationFrame.size.width);
+ touch_lo_set_view_size(applicationFrame.size.height, applicationFrame.size.width);
else
- lo_set_view_size(applicationFrame.size.width, applicationFrame.size.height);
+ touch_lo_set_view_size(applicationFrame.size.width, applicationFrame.size.height);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil];
@@ -90,7 +89,7 @@ static View *theView;
@autoreleasepool {
lo_initialize();
- lo_runMain();
+ touch_lo_runMain();
}
}
@@ -100,7 +99,7 @@ static View *theView;
assert(textView == theView->textView);
for (NSUInteger i = 0; i < [text length]; i++)
- lo_keyboard_input([text characterAtIndex: i]);
+ touch_lo_keyboard_input([text characterAtIndex: i]);
return NO;
}
@@ -142,9 +141,9 @@ static View *theView;
NSLog(@"statusBarOrientation: %ld", (long) [[UIApplication sharedApplication] statusBarOrientation]);
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
- lo_set_view_size(applicationFrame.size.height, applicationFrame.size.width);
+ touch_lo_set_view_size(applicationFrame.size.height, applicationFrame.size.width);
else
- lo_set_view_size(applicationFrame.size.width, applicationFrame.size.height);
+ touch_lo_set_view_size(applicationFrame.size.width, applicationFrame.size.height);
}
- (void)keyboardWillShow:(NSNotification *)note
@@ -167,7 +166,7 @@ static View *theView;
NSLog(@"keyboardDidHide");
- lo_keyboard_did_hide();
+ touch_lo_keyboard_did_hide();
}
@end
@@ -176,23 +175,23 @@ static View *theView;
// CocoaTouch activity to happen on the GUI thread. Use
// dispatch_async() consistently.
-void lo_damaged(CGRect rect)
+void touch_ui_damaged(int minX, int minY, int width, int height)
{
- (void) rect;
+ CGRect rect = CGRectMake(minX, minY, width, height);
dispatch_async(dispatch_get_main_queue(), ^{
[theView setNeedsDisplayInRect:rect];
});
- // NSLog(@"lo_damaged: %dx%d@(%d,%d)", (int)rect.size.width, (int)rect.size.height, (int)rect.origin.x, (int)rect.origin.y);
+ // NSLog(@"lo_damaged: %dx%d@(%d,%d)", width, height, minX, minY);
}
-void lo_show_keyboard()
+void touch_ui_show_keyboard()
{
dispatch_async(dispatch_get_main_queue(), ^{
[theView->textView becomeFirstResponder];
});
}
-void lo_hide_keyboard()
+void touch_ui_hide_keyboard()
{
dispatch_async(dispatch_get_main_queue(), ^{
[theView->textView resignFirstResponder];
diff --git a/ios/experimental/LibreOffice/LibreOffice/View.h b/ios/experimental/LibreOffice/LibreOffice/View.h
index 7fd47d1250c1..f036c488c338 100644
--- a/ios/experimental/LibreOffice/LibreOffice/View.h
+++ b/ios/experimental/LibreOffice/LibreOffice/View.h
@@ -19,7 +19,6 @@
- (void)panGesture:(UIPanGestureRecognizer *)gestureRecognizer;
- (void)longPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer;
-
@end
// vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/ios/experimental/LibreOffice/LibreOffice/View.m b/ios/experimental/LibreOffice/LibreOffice/View.m
index 99d57e97cc49..baab0a6d29d0 100644
--- a/ios/experimental/LibreOffice/LibreOffice/View.m
+++ b/ios/experimental/LibreOffice/LibreOffice/View.m
@@ -8,7 +8,7 @@
#import "View.h"
-#include <osl/detail/ios-bootstrap.h>
+#include <touch/touch.h>
@implementation View
@@ -40,10 +40,10 @@
CGContextScaleCTM(context, 1, -1);
break;
}
- lo_render_windows(context, rect);
+ touch_lo_render_windows(context, rect.origin.y, rect.origin.y, rect.size.width, rect.size.height);
CGContextRestoreGState(context);
- // NSLog(@"drawRect: lo_render_windows took %f s", [[NSDate date] timeIntervalSinceDate: startDate]);
+ // NSLog(@"drawRect: touch_lo_render_windows took %f s", [[NSDate date] timeIntervalSinceDate: startDate]);
}
- (void)tapGesture:(UITapGestureRecognizer *)gestureRecognizer
@@ -53,7 +53,7 @@
NSLog(@"tapGesture: at: (%d,%d)", (int)location.x, (int)location.y);
- lo_tap(location.x, location.y);
+ touch_lo_tap(location.x, location.y);
[self->textView becomeFirstResponder];
} else {
@@ -73,7 +73,7 @@
NSLog(@"panGesture: pan (delta): (%d,%d)", deltaX, deltaY);
- lo_pan(deltaX, deltaY);
+ touch_lo_pan(deltaX, deltaY);
}
previousX = translation.x;
@@ -87,11 +87,11 @@
NSLog(@"pinchGesture: pinch: (%f) cords (%d,%d)", (float)scale, (int)location.x, (int)location.y );
- lo_zoom((int)location.x, (int)location.y, (float)scale);
+ touch_lo_zoom((int)location.x, (int)location.y, (float)scale);
// to reset the gesture scaling
if (gestureRecognizer.state==UIGestureRecognizerStateEnded) {
- lo_zoom(1, 1, 0.0f);
+ touch_lo_zoom(1, 1, 0.0f);
}
}
@@ -104,8 +104,8 @@
NSLog(@"longPressGesture: state %d cords (%d,%d)",state ,(int)point.x,(int)point.y);
if (state == UIGestureRecognizerStateEnded) {
- lo_tap(point.x, point.y);
- lo_tap(point.x, point.y);
+ touch_lo_tap(point.x, point.y);
+ touch_lo_tap(point.x, point.y);
}
}
diff --git a/ios/experimental/LibreOffice/LibreOffice/ViewController.m b/ios/experimental/LibreOffice/LibreOffice/ViewController.m
index a7977af92d5a..a79c6007c6b9 100644
--- a/ios/experimental/LibreOffice/LibreOffice/ViewController.m
+++ b/ios/experimental/LibreOffice/LibreOffice/ViewController.m
@@ -9,7 +9,7 @@
#import "ViewController.h"
-#include <osl/detail/ios-bootstrap.h>
+#include <touch/touch.h>
#import "lo.h"
diff --git a/ios/experimental/LibreOffice/LibreOffice/lo.mm b/ios/experimental/LibreOffice/LibreOffice/lo.mm
index f65c532f70c6..d1c0f2dead58 100644
--- a/ios/experimental/LibreOffice/LibreOffice/lo.mm
+++ b/ios/experimental/LibreOffice/LibreOffice/lo.mm
@@ -12,8 +12,9 @@
#import <UIKit/UIKit.h>
#include <postmac.h>
-#include <osl/detail/ios-bootstrap.h>
+#include <osl/detail/component-mapping.h>
#include <osl/process.h>
+#include <touch/touch.h>
extern "C" {
extern void * analysis_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
diff --git a/vcl/ios/iosinst.cxx b/vcl/ios/iosinst.cxx
index 3605288f026e..7b4bcd2db879 100644
--- a/vcl/ios/iosinst.cxx
+++ b/vcl/ios/iosinst.cxx
@@ -21,14 +21,14 @@
#include <UIKit/UIKit.h>
#include <postmac.h>
-#include <osl/detail/ios-bootstrap.h>
+#include <basebmp/scanlineformats.hxx>
+#include <vcl/msgbox.hxx>
+#include <touch/touch.h>
+
#include "ios/iosinst.hxx"
#include "headless/svpdummies.hxx"
#include "generic/gendata.hxx"
-#include <basebmp/scanlineformats.hxx>
-#include <vcl/msgbox.hxx>
-
// Horrible hack
static int viewWidth = 1, viewHeight = 1;
@@ -43,7 +43,7 @@ public:
void IosSalInstance::damaged( IosSalFrame */* frame */,
const basegfx::B2IBox& rDamageRect )
{
- lo_damaged( CGRectMake( rDamageRect.getMinX(), rDamageRect.getMinY(), rDamageRect.getWidth(), rDamageRect.getHeight() ));
+ touch_ui_damaged( rDamageRect.getMinX(), rDamageRect.getMinY(), rDamageRect.getWidth(), rDamageRect.getHeight() );
}
void IosSalInstance::GetWorkArea( Rectangle& rRect )
@@ -301,12 +301,12 @@ IMPL_LINK( IosSalInstance, DisplayConfigurationChanged, void*, )
(*it)->Show( sal_True, sal_False );
}
- lo_damaged( CGRectMake( 0, 0, viewWidth, viewHeight ) );
+ touch_ui_damaged( 0, 0, viewWidth, viewHeight );
return 0;
}
extern "C"
-void lo_set_view_size(int width, int height)
+void touch_lo_set_view_size(int width, int height)
{
int oldWidth = viewWidth;
@@ -382,8 +382,9 @@ IMPL_LINK( IosSalInstance, RenderWindows, RenderWindowsArg*, arg )
}
extern "C"
-void lo_render_windows( CGContextRef context, CGRect rect )
+void touch_lo_render_windows(void *context, int minX, int minY, int width, int height)
{
+ CGContextRef cgContext = (CGContextRef) context;
int rc;
IosSalInstance *pInstance = IosSalInstance::getInstance();
@@ -396,7 +397,8 @@ void lo_render_windows( CGContextRef context, CGRect rect )
return;
}
- IosSalInstance::RenderWindowsArg arg = { false, context, rect };
+ CGRect rect = CGRectMake(minX, minY, width, height);
+ IosSalInstance::RenderWindowsArg arg = { false, cgContext, rect };
Application::PostUserEvent( LINK( pInstance, IosSalInstance, RenderWindows), &arg );
while (!arg.done) {
@@ -409,7 +411,7 @@ void lo_render_windows( CGContextRef context, CGRect rect )
}
extern "C"
-void lo_tap(int x, int y)
+void touch_lo_tap(int x, int y)
{
SalFrame *pFocus = IosSalInstance::getInstance()->getFocusFrame();
if (pFocus) {
@@ -426,7 +428,7 @@ void lo_tap(int x, int y)
}
extern "C"
-void lo_mouse_drag(int x, int y, LOMouseButtonState state)
+void touch_lo_mouse_drag(int x, int y, LOMouseButtonState state)
{
SalFrame *pFocus = IosSalInstance::getInstance()->getFocusFrame();
@@ -454,7 +456,7 @@ void lo_mouse_drag(int x, int y, LOMouseButtonState state)
}
extern "C"
-void lo_pan(int deltaX, int deltaY)
+void touch_lo_pan(int deltaX, int deltaY)
{
SalFrame *pFocus = IosSalInstance::getInstance()->getFocusFrame();
if (pFocus) {
@@ -465,7 +467,7 @@ void lo_pan(int deltaX, int deltaY)
}
extern "C"
-void lo_zoom(int x, int y, float scale)
+void touch_lo_zoom(int x, int y, float scale)
{
SalFrame *pFocus = IosSalInstance::getInstance()->getFocusFrame();
if (pFocus) {
@@ -476,7 +478,7 @@ void lo_zoom(int x, int y, float scale)
}
extern "C"
-void lo_keyboard_input(int c)
+void touch_lo_keyboard_input(int c)
{
SalFrame *pFocus = IosSalInstance::getInstance()->getFocusFrame();
if (pFocus) {
@@ -487,7 +489,7 @@ void lo_keyboard_input(int c)
}
extern "C"
-void lo_keyboard_did_hide()
+void touch_lo_keyboard_did_hide()
{
// Tell LO it has lost "focus", which will cause it to stop
// displaying any text insertion cursor etc