Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / android / Bootstrap / src / org / libreoffice / kit / Office.java
blob25c838ffb2e4fb887158ce384cfeac8a84886275
1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 package org.libreoffice.kit;
12 import java.nio.ByteBuffer;
14 public class Office {
15 private ByteBuffer handle;
16 private MessageCallback messageCallback = null;
18 public Office(ByteBuffer handle) {
19 this.handle = handle;
20 bindMessageCallback();
23 /**
24 * Bind the signal callback in LOK.
26 private native void bindMessageCallback();
28 public native String getError();
30 private native ByteBuffer documentLoadNative(String url);
32 public Document documentLoad(String url) {
33 ByteBuffer documentHandle = documentLoadNative(url);
34 Document document = null;
35 if (documentHandle != null) {
36 document = new Document(documentHandle);
38 return document;
41 public native void destroy();
42 public native void destroyAndExit();
43 public native void setDocumentPassword(String url, String pwd);
44 public native void setOptionalFeatures(long options);
46 public void setMessageCallback(MessageCallback messageCallback) {
47 this.messageCallback = messageCallback;
50 /**
51 * Callback triggered through JNI to indicate that a new signal
52 * from LibreOfficeKit was retrieved.
54 private void messageRetrievedLOKit(int signalNumber, String payload) {
55 if (messageCallback != null) {
56 messageCallback.messageRetrieved(signalNumber, payload);
61 /**
62 * Callback to retrieve messages from LOK
64 public interface MessageCallback {
65 /**
66 * Invoked when a message is retrieved from LOK
67 * @param signalNumber - signal type / number
68 * @param payload - retrieved for the signal
70 void messageRetrieved(int signalNumber, String payload);