summaryrefslogtreecommitdiffstats
path: root/android/Bootstrap
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--android/Bootstrap/Makefile.shared117
-rw-r--r--android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java57
-rw-r--r--android/Bootstrap/src/org/libreoffice/kit/Document.java269
-rw-r--r--android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java111
-rw-r--r--android/Bootstrap/src/org/libreoffice/kit/Office.java72
-rw-r--r--android/Bootstrap/version.map9
6 files changed, 635 insertions, 0 deletions
diff --git a/android/Bootstrap/Makefile.shared b/android/Bootstrap/Makefile.shared
new file mode 100644
index 000000000..f9825b583
--- /dev/null
+++ b/android/Bootstrap/Makefile.shared
@@ -0,0 +1,117 @@
+#
+# Common Makefile pieces for building Java / Android apps.
+#
+
+#
+# BOOTSTRAPDIR needs to be set to this directory before starting this
+#
+
+# Probably would be best to just stop fooling around with the possibilities to
+# set various stuff with the -env command line parameters (and environment
+# variables?) and in a plethora of rc files, and hardcode construction of
+# *all* required pathnames based on the app installation location for Android
+# (and iOS), etc. We don't really win anything by having so many layers of
+# configurability on platforms like Android and iOS where apps based on LO
+# code are very much self-contained pre-packaged thingies.
+
+JNILIBSDIR=$(BUILDDIR)/android/jniLibs
+SODEST=$(JNILIBSDIR)/$(ANDROID_APP_ABI)
+OBJLOCAL=$(BUILDDIR)/android/obj/local/$(ANDROID_APP_ABI)
+
+#
+# Helpful rules ...
+#
+
+local.properties: $(BUILDDIR)/config_host.mk
+ echo sdk.dir=$(ANDROID_SDK_DIR) >local.properties
+
+#
+# Build / link the single .so for this app
+#
+
+ALL_STATIC_LIBS := $(shell $(SRCDIR)/bin/lo-all-static-libs)
+
+LIBS = \
+ -Wl,--start-group \
+ $(ALL_STATIC_LIBS) \
+ -Wl,--end-group
+
+NSSLIBS = freebl3 \
+ nspr4 \
+ nss3 \
+ nssckbi \
+ nssdbm3 \
+ nssutil3 \
+ plc4 \
+ plds4 \
+ smime3 \
+ softokn3 \
+ sqlite3 \
+ ssl3 \
+
+WHOLELIBS = \
+ -Wl,--whole-archive \
+ $(addprefix -l,$(strip \
+ $(if $(ENABLE_JAVA),juh) \
+ )) \
+ -Wl,--no-whole-archive
+
+
+$(OBJLOCAL)/liblo-native-code.so : native-code.cxx $(ALL_STATIC_LIBS)
+ @echo "Linking $@"
+ mkdir -p $(OBJLOCAL)
+ $(CXX) -fuse-ld=gold -Wl,--build-id=sha1 -Wl,--gc-sections -Wl,--version-script=../Bootstrap/version.map -Wl,--no-keep-files-mapped -Wl,--no-undefined -DANDROID -DDISABLE_DYNLOADING -shared -Wl,-soname,liblo-native-code.so -o $(OBJLOCAL)/liblo-native-code.so -I$(BUILDDIR)/config_host -I$(SRCDIR)/include native-code.cxx -L$(INSTDIR)/$(LIBO_LIB_FOLDER) $(WHOLELIBS) $(LIBS) -lc++_static -lc++abi $(if $(filter-out arm64-v8a x86_64,$(ANDROID_APP_ABI)),-landroid_support) $(if $(filter armeabi-v7a,$(ANDROID_APP_ABI)),-lunwind) $(addprefix -l,$(NSSLIBS)) -lGLESv2 -landroid -ljnigraphics -llog -lz
+
+$(SODEST)/liblo-native-code.so : $(OBJLOCAL)/liblo-native-code.so
+ mkdir -p $(SODEST)
+ $(STRIP) -o $(SODEST)/liblo-native-code.so $(OBJLOCAL)/liblo-native-code.so
+ #to keep some symbols, eg.: $(STRIP) -o $(SODEST)/liblo-native-code.so $(OBJLOCAL)/liblo-native-code.so -w -K 'Java*'
+
+$(SODEST)/nss-libraries :
+ mkdir -p $(SODEST)
+ $(foreach lib,$(NSSLIBS),$(STRIP) -o $(SODEST)/lib$(lib).so $(INSTDIR)/$(LIBO_LIB_FOLDER)/lib$(lib).so;)
+
+$(SODEST)/libc++_shared.so : $(ANDROID_NDK_DIR)/sources/cxx-stl/llvm-libc++/libs/$(ANDROID_APP_ABI)/libc++_shared.so
+ mkdir -p $(SODEST)
+ cp $< $@
+
+link-so: $(SODEST)/liblo-native-code.so $(SODEST)/nss-libraries $(SODEST)/libc++_shared.so
+
+# If you reinstall an app several times *on the emulator*, even if you
+# uninstall it between, disk space seems to leak that won't get recycled until
+# you stop and start... No idea if this holds for a device, too. (And you
+# can't "stop" a device anyway.)
+
+stop-start-cycle:
+ $(ANDROID_SDK_DIR)/platform-tools/adb shell stop && $(ANDROID_SDK_DIR)/platform-tools/adb shell start && sleep 10
+
+# build-host specific stuff (build paths and the like) to keep build.gradle static
+liboSettings.gradle: $(BUILDDIR)/config_build.mk $(BUILDDIR)/config_host.mk
+ @echo "creating $@"
+ ( \
+ echo "// created by Makefile.shared - your changes will be overridden" \
+ && echo "ext {" \
+ && echo " liboSrcRoot = '$(SRC_ROOT)'" \
+ && echo " liboJniLibsdir = '$(JNILIBSDIR)'" \
+ && echo " liboWorkdir = '$(WORKDIR)'" \
+ && echo " liboInstdir = '$(INSTDIR)'" \
+ && echo " liboEtcFolder = '$(LIBO_ETC_FOLDER)'" \
+ && echo " liboUreMiscFolder = '$(LIBO_URE_MISC_FOLDER)'" \
+ && echo " liboSharedResFolder = '$(LIBO_SHARE_RESOURCE_FOLDER)'" \
+ && echo " liboUREJavaFolder = '$(LIBO_URE_SHARE_JAVA_FOLDER)'" \
+ && echo " liboShareJavaFolder = '$(LIBO_SHARE_JAVA_FOLDER)'" \
+ && echo " liboExampleDocument = '$(if $(exampleDocument),$(exampleDocument),$(SRC_ROOT)/android/default-document/example.odt)'" \
+ && echo " liboVersionMajor = '$(LIBO_VERSION_MAJOR)'" \
+ && echo " liboVersionMinor = '$(LIBO_VERSION_MINOR)'" \
+ && echo " liboGitFullCommit = '$(shell cd $(SRCDIR) && git log -1 --format=%H)'" \
+ && echo "}" \
+ && echo "android {" \
+ && echo " ndkPath '$(ANDROID_NDK_DIR)'" \
+ && echo "}" \
+ && echo "android.defaultConfig {" \
+ && echo " applicationId '$(ANDROID_PACKAGE_NAME)'" \
+ && echo " archivesBaseName = 'LibreOfficeViewer'" \
+ && echo " versionCode project.hasProperty('cmdVersionCode') ? cmdVersionCode.toInteger() : $(if $(versionCode),$(versionCode),1)" \
+ && echo " versionName '$(LIBO_VERSION_MAJOR).$(LIBO_VERSION_MINOR).$(LIBO_VERSION_MICRO).$(LIBO_VERSION_PATCH)$(LIBO_VERSION_SUFFIX)$(LIBO_VERSION_SUFFIX_SUFFIX)/$(shell cd $(SRCDIR) && git log -1 --format=%h)/$(OOO_VENDOR)'" \
+ && echo "}" \
+ ) > $@
diff --git a/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java b/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java
new file mode 100644
index 000000000..99cb3a486
--- /dev/null
+++ b/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java
@@ -0,0 +1,57 @@
+/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
+ * 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/. */
+
+package org.libreoffice.kit;
+
+import java.nio.ByteBuffer;
+
+/**
+ * This is the common code for allocation and freeing of memory. For this direct ByteBuffer is used but
+ * in the past it was possible to use a JNI version of allocation because of a bug in old Android version.
+ */
+public final class DirectBufferAllocator {
+
+ private static final String LOGTAG = DirectBufferAllocator.class.getSimpleName();
+
+ private DirectBufferAllocator() {
+ }
+
+ public static ByteBuffer allocate(int size) {
+ ByteBuffer directBuffer = ByteBuffer.allocateDirect(size);
+ if (directBuffer == null) {
+ if (size <= 0) {
+ throw new IllegalArgumentException("Invalid allocation size: " + size);
+ } else {
+ throw new OutOfMemoryError("allocateDirectBuffer() returned null");
+ }
+ } else if (!directBuffer.isDirect()) {
+ throw new AssertionError("allocateDirectBuffer() did not return a direct buffer");
+ }
+
+ return directBuffer;
+ }
+
+ public static ByteBuffer free(ByteBuffer buffer) {
+ if (buffer == null) {
+ return null;
+ }
+
+ if (!buffer.isDirect()) {
+ throw new IllegalArgumentException("ByteBuffer must be direct");
+ }
+ // can't free buffer - leave this to the VM
+ return null;
+ }
+
+ public static ByteBuffer guardedAllocate(int size) {
+ ByteBuffer buffer = null;
+ try {
+ buffer = allocate(size);
+ } catch (OutOfMemoryError oomException) {
+ return null;
+ }
+ return buffer;
+ }
+}
diff --git a/android/Bootstrap/src/org/libreoffice/kit/Document.java b/android/Bootstrap/src/org/libreoffice/kit/Document.java
new file mode 100644
index 000000000..7d95268e2
--- /dev/null
+++ b/android/Bootstrap/src/org/libreoffice/kit/Document.java
@@ -0,0 +1,269 @@
+/* -*- Mode: Java; 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/.
+ */
+
+package org.libreoffice.kit;
+
+import java.nio.ByteBuffer;
+
+public class Document {
+ public static final int PART_MODE_SLIDE = 0;
+ public static final int PART_MODE_NOTES = 1;
+
+ /**
+ * Document types
+ */
+ public static final int DOCTYPE_TEXT = 0;
+ public static final int DOCTYPE_SPREADSHEET = 1;
+ public static final int DOCTYPE_PRESENTATION = 2;
+ public static final int DOCTYPE_DRAWING = 3;
+ public static final int DOCTYPE_OTHER = 4;
+
+ /**
+ * Mouse event types
+ */
+ public static final int MOUSE_EVENT_BUTTON_DOWN = 0;
+ public static final int MOUSE_EVENT_BUTTON_UP = 1;
+ public static final int MOUSE_EVENT_MOVE = 2;
+
+ /**
+ * Key event types
+ */
+ public static final int KEY_EVENT_PRESS = 0;
+ public static final int KEY_EVENT_RELEASE = 1;
+
+ /**
+ * State change types
+ */
+ public static final int BOLD = 0;
+ public static final int ITALIC = 1;
+ public static final int UNDERLINE = 2;
+ public static final int STRIKEOUT = 3;
+
+ public static final int ALIGN_LEFT= 4;
+ public static final int ALIGN_CENTER = 5;
+ public static final int ALIGN_RIGHT= 6;
+ public static final int ALIGN_JUSTIFY= 7;
+ public static final int NUMBERED_LIST= 8;
+ public static final int BULLET_LIST= 9;
+
+ /**
+ * Callback message types
+ * Refer to https://opengrok.libreoffice.org/xref/core/include/LibreOfficeKit/LibreOfficeKitEnums.h
+ * for more details about each callback.
+ */
+ public static final int CALLBACK_INVALIDATE_TILES = 0;
+ public static final int CALLBACK_INVALIDATE_VISIBLE_CURSOR = 1;
+ public static final int CALLBACK_TEXT_SELECTION = 2;
+ public static final int CALLBACK_TEXT_SELECTION_START = 3;
+ public static final int CALLBACK_TEXT_SELECTION_END = 4;
+ public static final int CALLBACK_CURSOR_VISIBLE = 5;
+ public static final int CALLBACK_GRAPHIC_SELECTION = 6;
+ public static final int CALLBACK_HYPERLINK_CLICKED = 7;
+ public static final int CALLBACK_STATE_CHANGED = 8;
+ public static final int CALLBACK_STATUS_INDICATOR_START = 9;
+ public static final int CALLBACK_STATUS_INDICATOR_SET_VALUE = 10;
+ public static final int CALLBACK_STATUS_INDICATOR_FINISH = 11;
+ public static final int CALLBACK_SEARCH_NOT_FOUND = 12;
+ public static final int CALLBACK_DOCUMENT_SIZE_CHANGED = 13;
+ public static final int CALLBACK_SET_PART = 14;
+ public static final int CALLBACK_SEARCH_RESULT_SELECTION = 15;
+ public static final int CALLBACK_UNO_COMMAND_RESULT = 16;
+ public static final int CALLBACK_CELL_CURSOR = 17;
+ public static final int CALLBACK_MOUSE_POINTER = 18;
+ public static final int CALLBACK_CELL_FORMULA = 19;
+ public static final int CALLBACK_DOCUMENT_PASSWORD = 20;
+ public static final int CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY = 21;
+ public static final int CALLBACK_ERROR = 22;
+ public static final int CALLBACK_CONTEXT_MENU = 23;
+ public static final int CALLBACK_INVALIDATE_VIEW_CURSOR = 24;
+ public static final int CALLBACK_TEXT_VIEW_SELECTION = 25;
+ public static final int CALLBACK_CELL_VIEW_CURSOR = 26;
+ public static final int CALLBACK_GRAPHIC_VIEW_SELECTION = 27;
+ public static final int CALLBACK_VIEW_CURSOR_VISIBLE = 28;
+ public static final int CALLBACK_VIEW_LOCK = 29;
+ public static final int CALLBACK_REDLINE_TABLE_SIZE_CHANGED = 30;
+ public static final int CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED = 31;
+ public static final int CALLBACK_COMMENT = 32;
+ public static final int CALLBACK_INVALIDATE_HEADER = 33;
+ public static final int CALLBACK_CELL_ADDRESS = 34;
+ public static final int CALLBACK_SC_FOLLOW_JUMP = 54;
+
+ /**
+ * Set text selection types
+ */
+ public static final int SET_TEXT_SELECTION_START = 0;
+ public static final int SET_TEXT_SELECTION_END = 1;
+ public static final int SET_TEXT_SELECTION_RESET = 2;
+
+ /**
+ * Set graphic selection types
+ */
+ public static final int SET_GRAPHIC_SELECTION_START = 0;
+ public static final int SET_GRAPHIC_SELECTION_END = 1;
+
+ /**
+ * Mouse button type
+ */
+ public static final int MOUSE_BUTTON_LEFT = 1;
+ public static final int MOUSE_BUTTON_MIDDLE = 2;
+ public static final int MOUSE_BUTTON_RIGHT = 4;
+
+ public static final int KEYBOARD_MODIFIER_NONE = 0x0000;
+ public static final int KEYBOARD_MODIFIER_SHIFT = 0x1000;
+ public static final int KEYBOARD_MODIFIER_MOD1 = 0x2000;
+ public static final int KEYBOARD_MODIFIER_MOD2 = 0x4000;
+ public static final int KEYBOARD_MODIFIER_MOD3 = 0x8000;
+
+ /** Optional features of LibreOfficeKit, in particular callbacks that block
+ * LibreOfficeKit until the corresponding reply is received, which would
+ * deadlock if the client does not support the feature.
+ */
+ public static final long LOK_FEATURE_DOCUMENT_PASSWORD = 1;
+ public static final long LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY = (1 << 1);
+ public static final long LOK_FEATURE_PART_IN_INVALIDATION_CALLBACK = (1 << 2);
+ public static final long LOK_FEATURE_NO_TILED_ANNOTATIONS = (1 << 3);
+
+ private final ByteBuffer handle;
+ private MessageCallback messageCallback = null;
+
+ public Document(ByteBuffer handle) {
+ this.handle = handle;
+ bindMessageCallback();
+ }
+
+ public void setMessageCallback(MessageCallback messageCallback) {
+ this.messageCallback = messageCallback;
+ }
+
+ /**
+ * Callback triggered through JNI to indicate that a new signal
+ * from LibreOfficeKit was retrieved.
+ */
+ private void messageRetrieved(int signalNumber, String payload) {
+ if (messageCallback != null) {
+ messageCallback.messageRetrieved(signalNumber, payload);
+ }
+ }
+
+ /**
+ * Bind the signal callback in LOK.
+ */
+ private native void bindMessageCallback();
+
+ public native void destroy();
+
+ public native int getPart();
+
+ public native void setPart(int partIndex);
+
+ public native int getParts();
+
+ public native String getPartName(int partIndex);
+
+ public native void setPartMode(int partMode);
+
+ public native String getPartPageRectangles();
+
+ public native long getDocumentHeight();
+
+ public native long getDocumentWidth();
+
+ private native int getDocumentTypeNative();
+
+ public native void setClientZoom(int nTilePixelWidth, int nTilePixelHeight, int nTileTwipWidth, int nTileTwipHeight);
+
+ public native void saveAs(String url, String format, String options);
+
+ private native void paintTileNative(ByteBuffer buffer, int canvasWidth, int canvasHeight, int tilePositionX, int tilePositionY, int tileWidth, int tileHeight);
+
+ public int getDocumentType() {
+ return getDocumentTypeNative();
+ }
+
+ public void paintTile(ByteBuffer buffer, int canvasWidth, int canvasHeight, int tilePositionX, int tilePositionY, int tileWidth, int tileHeight) {
+ paintTileNative(buffer, canvasWidth, canvasHeight, tilePositionX, tilePositionY, tileWidth, tileHeight);
+ }
+
+ public native void initializeForRendering();
+
+ /**
+ * Post a key event to LibreOffice.
+ * @param type - type of key event
+ * @param charCode - the Unicode character generated by this event or 0.
+ * @param keyCode - the integer code representing the key of the event (non-zero for control keys).
+ */
+ public native void postKeyEvent(int type, int charCode, int keyCode);
+
+ /**
+ * Post a mouse event to LOK
+ * @param type - mouse event type
+ * @param x - x coordinate
+ * @param y - y coordinate
+ * @param count - number of events
+ */
+ public native void postMouseEvent(int type, int x, int y, int count, int button, int modifier);
+
+ /**
+ * Post a .uno: command to LOK
+ * @param command - the command, like ".uno:Bold"
+ * @param arguments
+ */
+ public native void postUnoCommand(String command, String arguments, boolean notifyWhenFinished);
+
+ /**
+ * Change text selection.
+ * @param type - text selection type
+ * @param x - x coordinate
+ * @param y - y coordinate
+ */
+ public native void setTextSelection(int type, int x, int y);
+
+ /**
+ * Change graphic selection.
+ * @param type - graphic selection type
+ * @param x - x coordinate
+ * @param y - y coordinate
+ */
+ public native void setGraphicSelection(int type, int x, int y);
+
+ /**
+ * Get selected text
+ * @param mimeType
+ * @return
+ */
+ public native String getTextSelection(String mimeType);
+
+ /**
+ * paste
+ * @param mimeType
+ * @param data
+ * @return
+ */
+ public native boolean paste(String mimeType, String data);
+
+ /**
+ * Reset current (any kind of) selection.
+ */
+ public native void resetSelection();
+
+ public native String getCommandValues(String command);
+
+ /**
+ * Callback to retrieve messages from LOK
+ */
+ public interface MessageCallback {
+ /**
+ * Invoked when a message is retrieved from LOK
+ * @param signalNumber - signal type / number
+ * @param payload - retrieved for the signal
+ */
+ void messageRetrieved(int signalNumber, String payload);
+ }
+
+}
diff --git a/android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java b/android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java
new file mode 100644
index 000000000..f7597c29a
--- /dev/null
+++ b/android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java
@@ -0,0 +1,111 @@
+/* -*- Mode: Java; 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/.
+ */
+
+package org.libreoffice.kit;
+
+import android.app.Activity;
+import android.content.pm.ApplicationInfo;
+import android.content.res.AssetManager;
+import android.util.Log;
+
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+
+// Native methods in this class are all implemented in
+// sal/android/lo-bootstrap.c as the lo-bootstrap library is loaded with
+// System.loadLibrary() and Android's JNI works only to such libraries, it
+// seems.
+public final class LibreOfficeKit
+{
+ private static String LOGTAG = LibreOfficeKit.class.getSimpleName();
+ private static AssetManager mgr;
+
+ // private constructor because instantiating would be meaningless
+ private LibreOfficeKit() {
+ }
+
+ // Trigger library initialization - as this is done automatically by executing the "static" block, this method remains empty. However we need this to manually (at the right time) can force library initialization.
+ public static void initializeLibrary() {
+ }
+
+ // Trigger initialization on the JNI - LOKit side.
+ private static native boolean initializeNative(String dataDir, String cacheDir, String apkFile, AssetManager mgr);
+
+ public static native ByteBuffer getLibreOfficeKitHandle();
+
+ // Wrapper for putenv()
+ public static native void putenv(String string);
+
+ // 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 redirectStdio(boolean state);
+
+ 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 (initializeDone) {
+ return;
+ }
+
+ mgr = activity.getResources().getAssets();
+
+ ApplicationInfo applicationInfo = activity.getApplicationInfo();
+ String dataDir = applicationInfo.dataDir;
+ Log.i(LOGTAG, String.format("Initializing LibreOfficeKit, dataDir=%s\n", dataDir));
+
+ redirectStdio(true);
+
+ String cacheDir = activity.getApplication().getCacheDir().getAbsolutePath();
+ String apkFile = activity.getApplication().getPackageResourcePath();
+
+ if (!initializeNative(dataDir, cacheDir, apkFile, mgr)) {
+ Log.e(LOGTAG, "Initialize native failed!");
+ return;
+ }
+ initializeDone = true;
+ }
+
+ // Now with static loading we always have all native code in one native
+ // library which we always call liblo-native-code.so, regardless of the
+ // app. The library has already been unpacked into /data/data/<app
+ // name>/lib at installation time by the package manager.
+ static {
+ NativeLibLoader.load();
+ }
+}
+
+class NativeLibLoader {
+ private static boolean done = false;
+
+ protected static synchronized void load() {
+ if (done)
+ return;
+ System.loadLibrary("nspr4");
+ System.loadLibrary("plds4");
+ System.loadLibrary("plc4");
+ System.loadLibrary("nssutil3");
+ System.loadLibrary("freebl3");
+ System.loadLibrary("sqlite3");
+ System.loadLibrary("softokn3");
+ System.loadLibrary("nss3");
+ System.loadLibrary("nssckbi");
+ System.loadLibrary("nssdbm3");
+ System.loadLibrary("smime3");
+ System.loadLibrary("ssl3");
+
+ System.loadLibrary("c++_shared");
+ System.loadLibrary("lo-native-code");
+ done = true;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/android/Bootstrap/src/org/libreoffice/kit/Office.java b/android/Bootstrap/src/org/libreoffice/kit/Office.java
new file mode 100644
index 000000000..25c838ffb
--- /dev/null
+++ b/android/Bootstrap/src/org/libreoffice/kit/Office.java
@@ -0,0 +1,72 @@
+/* -*- Mode: Java; 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/.
+ */
+
+package org.libreoffice.kit;
+
+import java.nio.ByteBuffer;
+
+public class Office {
+ private ByteBuffer handle;
+ private MessageCallback messageCallback = null;
+
+ public Office(ByteBuffer handle) {
+ this.handle = handle;
+ bindMessageCallback();
+ }
+
+ /**
+ * Bind the signal callback in LOK.
+ */
+ private native void bindMessageCallback();
+
+ public native String getError();
+
+ private native ByteBuffer documentLoadNative(String url);
+
+ public Document documentLoad(String url) {
+ ByteBuffer documentHandle = documentLoadNative(url);
+ Document document = null;
+ if (documentHandle != null) {
+ document = new Document(documentHandle);
+ }
+ return document;
+ }
+
+ public native void destroy();
+ public native void destroyAndExit();
+ public native void setDocumentPassword(String url, String pwd);
+ public native void setOptionalFeatures(long options);
+
+ public void setMessageCallback(MessageCallback messageCallback) {
+ this.messageCallback = messageCallback;
+ }
+
+ /**
+ * Callback triggered through JNI to indicate that a new signal
+ * from LibreOfficeKit was retrieved.
+ */
+ private void messageRetrievedLOKit(int signalNumber, String payload) {
+ if (messageCallback != null) {
+ messageCallback.messageRetrieved(signalNumber, payload);
+ }
+
+ }
+
+ /**
+ * Callback to retrieve messages from LOK
+ */
+ public interface MessageCallback {
+ /**
+ * Invoked when a message is retrieved from LOK
+ * @param signalNumber - signal type / number
+ * @param payload - retrieved for the signal
+ */
+ void messageRetrieved(int signalNumber, String payload);
+ }
+}
diff --git a/android/Bootstrap/version.map b/android/Bootstrap/version.map
new file mode 100644
index 000000000..930e1e071
--- /dev/null
+++ b/android/Bootstrap/version.map
@@ -0,0 +1,9 @@
+dummy {
+ global:
+ Java_*;
+ JNI_OnLoad;
+ _ZTI*; _ZTS*; # weak RTTI symbols for C++ exceptions
+ libreofficekit_*;
+ local:
+ *;
+};