Kaydet (Commit) a3ccf3ea authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

lok JNI: no "handle" in funcs & don't wrap some native funcs

Change-Id: If783fecd80a0de05e94c76e23572b567d151bb06
üst 246cb7e0
......@@ -15,43 +15,23 @@ public class Document {
private final long handle;
private native void setPartNative(long handle, int part);
private native int getNumberOfPartsNative(long handle);
private native int getDocumentTypeNative(long handle);
private native void paintTileNative(long handle, ByteBuffer buffer, int canvasWidth, int canvasHeight, int tilePositionX, int tilePositionY, int tileWidth, int tileHeight);
private native long getDocumentHeightNative(long handle);
private native long getDocumentWidthNative(long handle);
public native void setPart(int part);
public native int getNumberOfParts();
public native long getDocumentHeight();
public native long getDocumentWidth();
private native int getDocumentTypeNative();
private native void paintTileNative(ByteBuffer buffer, int canvasWidth, int canvasHeight, int tilePositionX, int tilePositionY, int tileWidth, int tileHeight);
public Document(long handle) {
this.handle = handle;
}
public boolean saveAs(String url) {
return false;
}
public int getDocumentType() {
return getDocumentTypeNative(handle);
}
public int getNumberOfParts() {
return getNumberOfPartsNative(handle);
}
public void setPart(int part) {
setPartNative(handle, part);
return getDocumentTypeNative();
}
public void paintTile(ByteBuffer buffer, int canvasWidth, int canvasHeight, int tilePositionX, int tilePositionY, int tileWidth, int tileHeight) {
paintTileNative(handle, buffer, canvasWidth, canvasHeight, tilePositionX, tilePositionY, tileWidth, tileHeight);
}
public long getDocumentWidth() {
return getDocumentWidthNative(handle);
paintTileNative(buffer, canvasWidth, canvasHeight, tilePositionX, tilePositionY, tileWidth, tileHeight);
}
public long getDocumentHeight() {
return getDocumentHeightNative(handle);
}
}
......@@ -19,15 +19,15 @@ public class Office {
this.handle = handle;
}
public native String getErrorNative();
public native String getError();
private native long documentLoadNative(String url);
public Document documentLoad(String url) {
long handle = documentLoadNative(url);
long documentHandle = documentLoadNative(url);
Document document = null;
if (handle > 0) {
document = new Document(handle);
if (documentHandle > 0) {
document = new Document(documentHandle);
}
return document;
}
......
......@@ -19,8 +19,6 @@
#include <LibreOfficeKit/LibreOfficeKit.h>
// #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "LibreOfficeKit", __VA_ARGS__))
/* LibreOfficeKit */
jfieldID getHandleField(JNIEnv* pEnv, jobject aObject)
......@@ -70,14 +68,14 @@ extern "C" SAL_JNI_EXPORT jlong JNICALL Java_org_libreoffice_kit_Office_document
}
/* Document */
extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_setPartNative
extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_setPart
(JNIEnv* pEnv, jobject aObject, jint aPart)
{
LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
pDocument->pClass->setPart(pDocument, aPart);
}
extern "C" SAL_JNI_EXPORT jint JNICALL Java_org_libreoffice_kit_Document_getNumberOfPartsNative
extern "C" SAL_JNI_EXPORT jint JNICALL Java_org_libreoffice_kit_Document_getNumberOfParts
(JNIEnv* pEnv, jobject aObject)
{
LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
......@@ -99,13 +97,12 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_paintTi
LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
unsigned char* buffer = (unsigned char*) pEnv->GetDirectBufferAddress(aByteBuffer);
// jlong capacity = pEnv->GetDirectBufferCapacity(aByteBuffer);
int nStride = 0;
pDocument->pClass->paintTile(pDocument, buffer, nCanvasWidth, nCanvasHeight, &nStride, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
(void) nStride;
}
extern "C" SAL_JNI_EXPORT jlong JNICALL Java_org_libreoffice_kit_Document_getDocumentHeightNative
extern "C" SAL_JNI_EXPORT jlong JNICALL Java_org_libreoffice_kit_Document_getDocumentHeight
(JNIEnv* pEnv, jobject aObject)
{
LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
......@@ -115,7 +112,7 @@ extern "C" SAL_JNI_EXPORT jlong JNICALL Java_org_libreoffice_kit_Document_getDoc
return nHeight;
}
extern "C" SAL_JNI_EXPORT jlong JNICALL Java_org_libreoffice_kit_Document_getDocumentWidthNative
extern "C" SAL_JNI_EXPORT jlong JNICALL Java_org_libreoffice_kit_Document_getDocumentWidth
(JNIEnv* pEnv, jobject aObject)
{
LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment