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
// 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
// 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
// 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
// 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
native-code.cxx: $(SRCDIR)/solenv/bin/native-code.py
$< -g core -g writer > $@
$< -j -g core -g writer > $@
copy-stuff:
# 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.LayerView;
import org.libreoffice.android.Bootstrap;
import org.libreoffice.android.LibreOfficeKit;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.lang.XMultiComponentFactory;
@ -74,18 +74,19 @@ public class LibreOfficeMainActivity extends Activity {
super.onCreate(savedInstanceState);
try {
Bootstrap.setup(this);
Bootstrap.putenv("SAL_LOG=+WARN+INFO-INFO.legacy.osl");
LibreOfficeKit.init(this);
LibreOfficeKit.putenv("SAL_LOG=+WARN+INFO-INFO.legacy.osl");
setContentView(R.layout.activity_main);
Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - onCreate");
/*
String input = "/assets/test1.odt";
String[] argv = { "lo-document-loader", input };
Bootstrap.setCommandArgs(argv);
LibreOfficeKit.setCommandArgs(argv);
Bootstrap.initVCL();
@ -102,7 +103,7 @@ public class LibreOfficeMainActivity extends Activity {
componentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktop);
Log.i(LOGTAG, "componentLoader is" + (componentLoader!=null ? " not" : "") + " null");
*/
} catch (Exception e) {
e.printStackTrace(System.err);
//finish();
@ -143,3 +144,5 @@ public class LibreOfficeMainActivity extends Activity {
return mLayerController;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -24,7 +24,9 @@
#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__))
/* These are valid / used in all apps. */
@ -34,9 +36,13 @@ extern void *apk_file;
extern int apk_file_size;
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 LibreOfficeKit *libreofficekit_hook(const char* install_path);
static LibreOfficeKit* pOffice;
/// Call the same method from Bootstrap.
__attribute__ ((visibility("default")))
void
@ -49,12 +55,12 @@ Java_org_libreoffice_android_LibreOfficeKit_putenv(JNIEnv* env,
/// Call the same method from Bootstrap.
__attribute__ ((visibility("default")))
jboolean
void
Java_org_libreoffice_android_LibreOfficeKit_redirect_1stdio(JNIEnv* env,
jobject clazz,
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.
@ -119,10 +125,25 @@ Java_org_libreoffice_android_LibreOfficeKit_init__Ljava_lang_String_2Ljava_lang_
(*env)->ReleaseStringUTFChars(env, apkFile, apkFilePath);
if (!setup_cdir())
{
LOGE("setup_cdir failed");
return JNI_FALSE;
}
if (!setup_assets_tree())
{
LOGE("setup_assets_tree failed");
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;
}

View File

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

View File

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