summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java (renamed from android/Bootstrap/src/org/libreoffice/android/LibreOfficeKit.java)77
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java44
-rw-r--r--sal/android/libreofficekit-jni.c45
-rwxr-xr-xsolenv/bin/native-code.py9
4 files changed, 71 insertions, 104 deletions
diff --git a/android/Bootstrap/src/org/libreoffice/android/LibreOfficeKit.java b/android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java
index 58d6c500a17f..c76c0fd7cbaa 100644
--- a/android/Bootstrap/src/org/libreoffice/android/LibreOfficeKit.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java
@@ -7,7 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-package org.libreoffice.android;
+package org.libreoffice.kit;
import android.app.Activity;
import android.content.pm.ApplicationInfo;
@@ -21,6 +21,8 @@ import java.util.Arrays;
// final because subclassing would be meaningless.
public final class LibreOfficeKit
{
+ private long handle;
+
// private constructor because instantiating would be meaningless
private LibreOfficeKit()
{
@@ -33,88 +35,59 @@ public final class LibreOfficeKit
// System.loadLibrary() and Android's JNI works only to such libraries, it
// seems.
- private static native boolean init(String dataDir,
- String cacheDir,
- String apkFile);
+ private static native boolean initializeNative(String dataDir, String cacheDir, String apkFile);
-/*
- // Wrapper for getpid()
- public static native int getpid();
+ public static native long getLibreOfficeKitHandle();
- // Wrapper for system()
- public static native void system(String cmdline);
-*/
// Wrapper for putenv()
public static native void putenv(String string);
-/*
- // A wrapper for InitVCL() in libvcl (svmain.cxx), called indirectly
- // through the lo-bootstrap library
- public static native void initVCL();
-
- // A wrapper for osl_setCommandArgs(). Before calling
- // osl_setCommandArgs(), argv[0] is prefixed with the parent directory of
- // where the lo-bootstrap library is.
- public static native void setCommandArgs(String[] argv);
-*/
+
// A method that starts a thread to redirect stdout and stderr writes to
// the Android logging mechanism, or stops the redirection.
- public static native void redirect_stdio(boolean state);
-/*
- // The DIB returned by css.awt.XBitmap.getDIB is in BGR_888 form, at least
- // for Writer documents. We need it in Android's Bitmap.Config.ARGB_888
- // format, which actually is RGBA_888, whee... At least in Android 4.0.3,
- // at least on my device. No idea if it is always like that or not, the
- // documentation sucks.
- public static native void twiddle_BGR_to_RGBA(byte[] source, int offset, int width, int height, ByteBuffer destination);
-
- public static native void force_full_alpha_array(byte[] array, int offset, int length);
-
- public static native void force_full_alpha_bb(ByteBuffer buffer, int offset, int length);
-
- public static native long new_byte_buffer_wrapper(ByteBuffer bbuffer);
+ public static native void redirectStdio(boolean state);
- public static native void delete_byte_buffer_wrapper(long bbw);
-*/
-
- static boolean init_done = false;
+ static boolean initializeDone = false;
// This init() method should be called from the upper Java level of
// LO-based apps.
public static synchronized void init(Activity activity)
{
- if (init_done)
+ if (initializeDone)
return;
String dataDir = null;
- ApplicationInfo ai = activity.getApplicationInfo();
- dataDir = ai.dataDir;
+ ApplicationInfo applicationInfo = activity.getApplicationInfo();
+ dataDir = applicationInfo.dataDir;
Log.i(TAG, String.format("Initializing LibreOfficeKit, dataDir=%s\n", dataDir));
- redirect_stdio(true);
+ redirectStdio(true);
+
+ String cacheDir = activity.getApplication().getCacheDir().getAbsolutePath();
+ String apkFile = activity.getApplication().getPackageResourcePath();
- if (!init(dataDir,
- activity.getApplication().getCacheDir().getAbsolutePath(),
- activity.getApplication().getPackageResourcePath()))
+ if (!initializeNative(dataDir, cacheDir, apkFile)) {
return;
+ }
// If we notice that a fonts.conf file was extracted, automatically
// set the FONTCONFIG_FILE env var.
- InputStream i;
+ InputStream inputStream = null;
try {
- i = activity.getAssets().open("unpack/etc/fonts/fonts.conf");
- }
- catch (java.io.IOException e) {
- i = null;
+ inputStream = activity.getAssets().open("unpack/etc/fonts/fonts.conf");
+ } catch (java.io.IOException exception) {
}
+
putenv("OOO_DISABLE_RECOVERY=1");
- if (i != null)
+
+ if (inputStream != null) {
putenv("FONTCONFIG_FILE=" + dataDir + "/etc/fonts/fonts.conf");
+ }
// TMPDIR is used by osl_getTempDirURL()
putenv("TMPDIR=" + activity.getCacheDir().getAbsolutePath());
- init_done = true;
+ initializeDone = true;
}
// Now with static loading we always have all native code in one native
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index a4ae79c5882b..2345aea1f58b 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -11,12 +11,16 @@ import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
+import android.os.Environment;
+import java.io.File;
import org.mozilla.gecko.gfx.GeckoSoftwareLayerClient;
import org.mozilla.gecko.gfx.LayerController;
import org.mozilla.gecko.gfx.LayerView;
-import org.libreoffice.android.LibreOfficeKit;
+import org.libreoffice.kit.LibreOfficeKit;
+import org.libreoffice.kit.Office;
+import org.libreoffice.kit.Document;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.lang.XMultiComponentFactory;
@@ -76,48 +80,30 @@ public class LibreOfficeMainActivity extends Activity {
try {
// enable debugging messages as the first thing
LibreOfficeKit.putenv("SAL_LOG=+WARN+INFO-INFO.legacy.osl");
-
LibreOfficeKit.init(this);
- setContentView(R.layout.activity_main);
-
- Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - onCreate");
-
- /*
- String input = "/assets/test1.odt";
-
- String[] argv = { "lo-document-loader", input };
-
- LibreOfficeKit.setCommandArgs(argv);
-
- Bootstrap.initVCL();
+ Log.w(LOGTAG, "LOK Handle:" + handle);
+ Office office = new Office(LibreOfficeKit.getLibreOfficeKitHandle());
- context = com.sun.star.comp.helper.Bootstrap.defaultBootstrap_InitialComponentContext();
+ File file = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
+ String input = file.getPath() + "/test.odt";
+ Document document = office.documentLoad(input);
+ if (document == null) {
+ Log.w(LOGTAG, "LOK Document error:" + office.getErrorNative());
+ }
- Log.i(LOGTAG, "context is" + (context!=null ? " not" : "") + " null");
-
- mcf = context.getServiceManager();
-
- Log.i(LOGTAG, "mcf is" + (mcf!=null ? " not" : "") + " null");
-
- Object desktop = mcf.createInstanceWithContext("com.sun.star.frame.Desktop", context);
- Log.i(LOGTAG, "desktop is" + (desktop!=null ? " not" : "") + " null");
-
- componentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktop);
- Log.i(LOGTAG, "componentLoader is" + (componentLoader!=null ? " not" : "") + " null");
- */
} catch (Exception e) {
e.printStackTrace(System.err);
- //finish();
+ finish();
}
setContentView(R.layout.activity_main);
+ Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - onCreate");
// setup gecko layout
mGeckoLayout = (RelativeLayout) findViewById(R.id.gecko_layout);
mMainLayout = (LinearLayout) findViewById(R.id.main_layout);
-
if (mLayerController == null) {
mLayerController = new LayerController(this);
diff --git a/sal/android/libreofficekit-jni.c b/sal/android/libreofficekit-jni.c
index 3dcf773e9cf1..4c9f20bff289 100644
--- a/sal/android/libreofficekit-jni.c
+++ b/sal/android/libreofficekit-jni.c
@@ -30,47 +30,40 @@
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "LibreOfficeKit", __VA_ARGS__))
/* These are valid / used in all apps. */
-extern const char *data_dir;
-extern const char *cache_dir;
-extern void *apk_file;
+extern const char* data_dir;
+extern const char* cache_dir;
+extern void* apk_file;
extern int apk_file_size;
extern void Java_org_libreoffice_android_Bootstrap_putenv(JNIEnv* env, jobject clazz, jstring string);
extern void Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env, jobject clazz, jboolean state);
-extern LibreOfficeKit *libreofficekit_hook(const char* install_path);
+extern LibreOfficeKit* libreofficekit_hook(const char* install_path);
-static LibreOfficeKit* pOffice;
+static LibreOfficeKit* gpOffice;
/// Call the same method from Bootstrap.
__attribute__ ((visibility("default")))
void
-Java_org_libreoffice_android_LibreOfficeKit_putenv(JNIEnv* env,
- jobject clazz,
- jstring string)
+Java_org_libreoffice_kit_LibreOfficeKit_putenv
+ (JNIEnv* env, jobject clazz, jstring string)
{
Java_org_libreoffice_android_Bootstrap_putenv(env, clazz, string);
}
/// Call the same method from Bootstrap.
__attribute__ ((visibility("default")))
-void
-Java_org_libreoffice_android_LibreOfficeKit_redirect_1stdio(JNIEnv* env,
- jobject clazz,
- jboolean state)
+void Java_org_libreoffice_kit_LibreOfficeKit_redirectStdio
+ (JNIEnv* env, jobject clazz, jboolean state)
{
Java_org_libreoffice_android_Bootstrap_redirect_1stdio(env, clazz, state);
}
/// Initialize the LibreOfficeKit.
__attribute__ ((visibility("default")))
-jboolean
-Java_org_libreoffice_android_LibreOfficeKit_init__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2
- (JNIEnv* env,
- jobject clazz,
- jstring dataDir,
- jstring cacheDir,
- jstring apkFile)
+jboolean Java_org_libreoffice_kit_LibreOfficeKit_initializeNative
+ (JNIEnv* env, jobject clazz,
+ jstring dataDir, jstring cacheDir, jstring apkFile)
{
struct stat st;
int fd;
@@ -131,8 +124,8 @@ Java_org_libreoffice_android_LibreOfficeKit_init__Ljava_lang_String_2Ljava_lang_
extract_files(UNPACK_TREE_GZ, UNPACK_TREE_GZ, 1);
// Initialize LibreOfficeKit
- pOffice = libreofficekit_hook(data_dir);
- if (!pOffice)
+ gpOffice = libreofficekit_hook(data_dir);
+ if (!gpOffice)
{
LOGE("libreofficekit_hook returned null");
return JNI_FALSE;
@@ -143,4 +136,14 @@ Java_org_libreoffice_android_LibreOfficeKit_init__Ljava_lang_String_2Ljava_lang_
return JNI_TRUE;
}
+__attribute__ ((visibility("default")))
+jlong Java_org_libreoffice_kit_LibreOfficeKit_getLibreOfficeKitHandle
+ (JNIEnv* env, jobject clazz)
+{
+ (void) env;
+ (void) clazz;
+
+ return (jlong) (intptr_t) gpOffice;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py
index 0de8ed3ce62d..4b3b87b843f7 100755
--- a/solenv/bin/native-code.py
+++ b/solenv/bin/native-code.py
@@ -230,8 +230,13 @@ if options.java:
extern void Java_org_libreoffice_android_AppSupport_renderVCL();
p = (void *) Java_org_libreoffice_android_AppSupport_renderVCL;
- extern void Java_org_libreoffice_android_LibreOfficeKit_init__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2();
- p = (void *) Java_org_libreoffice_android_LibreOfficeKit_init__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2;""")
+ extern void Java_org_libreoffice_kit_LibreOfficeKit_initializeNative();
+ p = (void *) Java_org_libreoffice_kit_LibreOfficeKit_initializeNative;
+
+ extern void Java_org_libreoffice_kit_Office_initialize();
+ p = (void *) Java_org_libreoffice_kit_Office_initialize;
+
+ """)
print ("""
return map;