android: Make use of LibreOfficeKit.

Now the LibreOfficeKit is used to actually attempt to bootstrap LibreOffice;
at the moment fails to do that.

Change-Id: I91220dbff783213bf7702e7213a5646859db4581
This commit is contained in:
Jan Holesovsky 2014-06-28 18:23:24 +02:00
parent 74ab9835f9
commit db89e5ff81
7 changed files with 55 additions and 28 deletions

View File

@ -60,7 +60,7 @@ public final class Bootstrap
// A method that starts a thread to redirect stdout and stderr writes to // A method that starts a thread to redirect stdout and stderr writes to
// the Android logging mechanism, or stops the redirection. // the Android logging mechanism, or stops the redirection.
public static native boolean redirect_stdio(boolean state); public static native void redirect_stdio(boolean state);
// The DIB returned by css.awt.XBitmap.getDIB is in BGR_888 form, at least // 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 // for Writer documents. We need it in Android's Bitmap.Config.ARGB_888

View File

@ -61,7 +61,7 @@ public final class LibreOfficeKit
*/ */
// A method that starts a thread to redirect stdout and stderr writes to // A method that starts a thread to redirect stdout and stderr writes to
// the Android logging mechanism, or stops the redirection. // the Android logging mechanism, or stops the redirection.
public static native boolean redirect_stdio(boolean state); public static native void redirect_stdio(boolean state);
/* /*
// The DIB returned by css.awt.XBitmap.getDIB is in BGR_888 form, at least // 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 // for Writer documents. We need it in Android's Bitmap.Config.ARGB_888

View File

@ -13,7 +13,7 @@ BOOTSTRAPDIR=../../Bootstrap
include $(BOOTSTRAPDIR)/Makefile.shared include $(BOOTSTRAPDIR)/Makefile.shared
native-code.cxx: $(SRCDIR)/solenv/bin/native-code.py native-code.cxx: $(SRCDIR)/solenv/bin/native-code.py
$< -g core -g writer > $@ $< -j -g core -g writer > $@
copy-stuff: copy-stuff:
# Then "assets". Let the directory structure under assets mimic # Then "assets". Let the directory structure under assets mimic

View File

@ -16,7 +16,7 @@ import org.mozilla.gecko.gfx.GeckoSoftwareLayerClient;
import org.mozilla.gecko.gfx.LayerController; import org.mozilla.gecko.gfx.LayerController;
import org.mozilla.gecko.gfx.LayerView; import org.mozilla.gecko.gfx.LayerView;
import org.libreoffice.android.Bootstrap; import org.libreoffice.android.LibreOfficeKit;
import com.sun.star.frame.XComponentLoader; import com.sun.star.frame.XComponentLoader;
import com.sun.star.lang.XMultiComponentFactory; import com.sun.star.lang.XMultiComponentFactory;
@ -74,18 +74,19 @@ public class LibreOfficeMainActivity extends Activity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
try { try {
Bootstrap.setup(this); LibreOfficeKit.init(this);
Bootstrap.putenv("SAL_LOG=+WARN+INFO-INFO.legacy.osl"); LibreOfficeKit.putenv("SAL_LOG=+WARN+INFO-INFO.legacy.osl");
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - onCreate"); Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - onCreate");
/*
String input = "/assets/test1.odt"; String input = "/assets/test1.odt";
String[] argv = { "lo-document-loader", input }; String[] argv = { "lo-document-loader", input };
Bootstrap.setCommandArgs(argv); LibreOfficeKit.setCommandArgs(argv);
Bootstrap.initVCL(); Bootstrap.initVCL();
@ -102,7 +103,7 @@ public class LibreOfficeMainActivity extends Activity {
componentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktop); componentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktop);
Log.i(LOGTAG, "componentLoader is" + (componentLoader!=null ? " not" : "") + " null"); Log.i(LOGTAG, "componentLoader is" + (componentLoader!=null ? " not" : "") + " null");
*/
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(System.err); e.printStackTrace(System.err);
//finish(); //finish();
@ -143,3 +144,5 @@ public class LibreOfficeMainActivity extends Activity {
return mLayerController; return mLayerController;
} }
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -24,7 +24,9 @@
#include <osl/detail/android-bootstrap.h> #include <osl/detail/android-bootstrap.h>
//#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "LibreOfficeKit", __VA_ARGS__)) #include <LibreOfficeKit/LibreOfficeKit.h>
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "LibreOfficeKit", __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "LibreOfficeKit", __VA_ARGS__)) #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "LibreOfficeKit", __VA_ARGS__))
/* These are valid / used in all apps. */ /* These are valid / used in all apps. */
@ -34,9 +36,13 @@ extern void *apk_file;
extern int apk_file_size; 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_putenv(JNIEnv* env, jobject clazz, jstring string);
extern jboolean Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env, jobject clazz, jboolean state); extern void Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env, jobject clazz, jboolean state);
extern void Java_org_libreoffice_android_Bootstrap_extract_1files(JNIEnv* env, jobject clazz); extern void Java_org_libreoffice_android_Bootstrap_extract_1files(JNIEnv* env, jobject clazz);
extern LibreOfficeKit *libreofficekit_hook(const char* install_path);
static LibreOfficeKit* pOffice;
/// Call the same method from Bootstrap. /// Call the same method from Bootstrap.
__attribute__ ((visibility("default"))) __attribute__ ((visibility("default")))
void void
@ -49,12 +55,12 @@ Java_org_libreoffice_android_LibreOfficeKit_putenv(JNIEnv* env,
/// Call the same method from Bootstrap. /// Call the same method from Bootstrap.
__attribute__ ((visibility("default"))) __attribute__ ((visibility("default")))
jboolean void
Java_org_libreoffice_android_LibreOfficeKit_redirect_1stdio(JNIEnv* env, Java_org_libreoffice_android_LibreOfficeKit_redirect_1stdio(JNIEnv* env,
jobject clazz, jobject clazz,
jboolean state) jboolean state)
{ {
return Java_org_libreoffice_android_Bootstrap_redirect_1stdio(env, clazz, state); Java_org_libreoffice_android_Bootstrap_redirect_1stdio(env, clazz, state);
} }
/// Call the same method from Bootstrap. /// Call the same method from Bootstrap.
@ -119,10 +125,25 @@ Java_org_libreoffice_android_LibreOfficeKit_init__Ljava_lang_String_2Ljava_lang_
(*env)->ReleaseStringUTFChars(env, apkFile, apkFilePath); (*env)->ReleaseStringUTFChars(env, apkFile, apkFilePath);
if (!setup_cdir()) if (!setup_cdir())
{
LOGE("setup_cdir failed");
return JNI_FALSE; return JNI_FALSE;
}
if (!setup_assets_tree()) if (!setup_assets_tree())
{
LOGE("setup_assets_tree failed");
return JNI_FALSE; return JNI_FALSE;
}
pOffice = libreofficekit_hook(data_dir);
if (!pOffice)
{
LOGE("libreofficekit_hook returned null");
return JNI_FALSE;
}
LOGI("LibreOfficeKit successfully initialized");
return JNI_TRUE; return JNI_TRUE;
} }

View File

@ -42,11 +42,11 @@ struct engine {
}; };
/* These are valid / used in all apps. */ /* These are valid / used in all apps. */
static const char *data_dir; const char *data_dir;
static const char *cache_dir; const char *cache_dir;
static void *apk_file; void *apk_file;
static int apk_file_size; int apk_file_size;
static JavaVM *the_java_vm; JavaVM *the_java_vm;
/* Zip data structures */ /* Zip data structures */
@ -1019,7 +1019,7 @@ redirect_to_null(void)
} }
__attribute__ ((visibility("default"))) __attribute__ ((visibility("default")))
jboolean void
Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env, Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env,
jobject clazz, jobject clazz,
jboolean state) jboolean state)
@ -1031,22 +1031,22 @@ Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env,
(void) env; (void) env;
(void) clazz; (void) clazz;
if (state == current) if (state == current)
return current; return;
if (state == JNI_FALSE) { if (state == JNI_FALSE) {
if (!redirect_to_null()) if (!redirect_to_null())
return current; return;
} else { } else {
if (pipe(stdout_pipe) == -1) { if (pipe(stdout_pipe) == -1) {
LOGE("redirect_stdio: Could not create pipes: %s", strerror(errno)); LOGE("redirect_stdio: Could not create pipes: %s", strerror(errno));
return current; return;
} }
if (pipe(stderr_pipe) == -1) { if (pipe(stderr_pipe) == -1) {
LOGE("redirect_stdio: Could not create pipes: %s", strerror(errno)); LOGE("redirect_stdio: Could not create pipes: %s", strerror(errno));
close(stdout_pipe[0]); close(stdout_pipe[0]);
close(stdout_pipe[1]); close(stdout_pipe[1]);
return current; return;
} }
LOGI("redirect_stdio: stdout pipe: [%d,%d], stderr pipe: [%d,%d]", LOGI("redirect_stdio: stdout pipe: [%d,%d], stderr pipe: [%d,%d]",
stdout_pipe[0], stdout_pipe[1], stderr_pipe[0], stderr_pipe[1]); stdout_pipe[0], stdout_pipe[1], stderr_pipe[0], stderr_pipe[1]);
@ -1057,7 +1057,7 @@ Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env,
close(stdout_pipe[1]); close(stdout_pipe[1]);
close(stderr_pipe[0]); close(stderr_pipe[0]);
close(stderr_pipe[1]); close(stderr_pipe[1]);
return current; return;
} }
if (dup2(stderr_pipe[1], 2) == -1) { if (dup2(stderr_pipe[1], 2) == -1) {
@ -1070,7 +1070,7 @@ Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env,
close(stdout_pipe[1]); close(stdout_pipe[1]);
close(stderr_pipe[0]); close(stderr_pipe[0]);
close(stderr_pipe[1]); close(stderr_pipe[1]);
return current; return;
} }
close(stdout_pipe[1]); close(stdout_pipe[1]);
close(stderr_pipe[1]); close(stderr_pipe[1]);
@ -1082,11 +1082,11 @@ Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env,
redirect_to_null(); redirect_to_null();
close(stdout_pipe[0]); close(stdout_pipe[0]);
close(stderr_pipe[0]); close(stderr_pipe[0]);
return current; return;
} }
} }
current = state; current = state;
return current; return;
} }
__attribute__ ((visibility("default"))) __attribute__ ((visibility("default")))

View File

@ -228,7 +228,10 @@ if options.java:
volatile void *p = (void *) Java_org_libreoffice_android_AppSupport_runMain; volatile void *p = (void *) Java_org_libreoffice_android_AppSupport_runMain;
extern void Java_org_libreoffice_android_AppSupport_renderVCL(); extern void Java_org_libreoffice_android_AppSupport_renderVCL();
p = (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;""")
print (""" print ("""
return map; return map;