summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-09-22 22:34:26 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-09-22 22:40:07 +0200
commit18c052d6d659001657ccf1ff0c7c7cff64658f44 (patch)
tree8340c1299ce2dbe849d37f238eb3c114ef3db47c /desktop
parent67ad72f574557cd8d235ceeba556b6884ecd99ed (diff)
LOKit: add "destroy" and "saveAs" to android JNI
Change-Id: I08542b736e49cb9262323e9fe6188b1976d47935
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/lokandroid.cxx50
1 files changed, 43 insertions, 7 deletions
diff --git a/desktop/source/lib/lokandroid.cxx b/desktop/source/lib/lokandroid.cxx
index 16e7217627a0..bc9a8b0b1274 100644
--- a/desktop/source/lib/lokandroid.cxx
+++ b/desktop/source/lib/lokandroid.cxx
@@ -41,6 +41,17 @@ void setHandle(JNIEnv* pEnv, jobject aObject, T* aType)
pEnv->SetLongField(aObject, getHandleField(pEnv, aObject), aHandle);
}
+const char* copyJavaString(JNIEnv* pEnv, jstring aJavaString)
+{
+ const char* pClone = NULL;
+
+ const char* pTemp = pEnv->GetStringUTFChars(aJavaString, NULL);
+ pClone = strdup(pTemp);
+ pEnv->ReleaseStringUTFChars(aJavaString, pTemp);
+
+ return pClone;
+}
+
extern "C" SAL_JNI_EXPORT jstring JNICALL Java_org_libreoffice_kit_Office_getError(JNIEnv* pEnv, jobject aObject)
{
LibreOfficeKit* pLibreOfficeKit = getHandle<LibreOfficeKit>(pEnv, aObject);
@@ -53,21 +64,29 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Office_initializ
pEnv->SetLongField(aObject, getHandleField(pEnv, aObject), aLokHandle);
}
-extern "C" SAL_JNI_EXPORT jlong JNICALL Java_org_libreoffice_kit_Office_documentLoadNative(JNIEnv* pEnv, jobject aObject, jstring documentPath)
+extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Office_destroy(JNIEnv* pEnv, jobject aObject)
{
- const char* aCloneDocumentPath;
-
- const char* aCharDocumentPath = pEnv->GetStringUTFChars(documentPath, NULL);
- aCloneDocumentPath = strdup(aCharDocumentPath);
- pEnv->ReleaseStringUTFChars(documentPath, aCharDocumentPath);
+ LibreOfficeKit* pLibreOfficeKit = getHandle<LibreOfficeKit>(pEnv, aObject);
+ pLibreOfficeKit->pClass->destroy(pLibreOfficeKit);
+}
+extern "C" SAL_JNI_EXPORT jlong JNICALL Java_org_libreoffice_kit_Office_documentLoadNative(JNIEnv* pEnv, jobject aObject, jstring documentPath)
+{
+ const char* aCloneDocumentPath = copyJavaString(pEnv, documentPath);
LibreOfficeKit* pLibreOfficeKit = getHandle<LibreOfficeKit>(pEnv, aObject);
LibreOfficeKitDocument* pDocument = pLibreOfficeKit->pClass->documentLoad(pLibreOfficeKit, aCloneDocumentPath);
- return (jlong) (intptr_t) pDocument;
+ return (jlong) pDocument;
}
/* Document */
+extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_destroy
+ (JNIEnv* pEnv, jobject aObject)
+{
+ LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
+ pDocument->pClass->destroy(pDocument);
+}
+
extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_setPart
(JNIEnv* pEnv, jobject aObject, jint aPart)
{
@@ -145,4 +164,21 @@ extern "C" SAL_JNI_EXPORT jlong JNICALL Java_org_libreoffice_kit_Document_getDoc
return nWidth;
}
+extern "C" SAL_JNI_EXPORT jint JNICALL Java_org_libreoffice_kit_Office_saveAs(JNIEnv* pEnv, jobject aObject, jstring sUrl, jstring sFormat, jstring sOptions)
+{
+ LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
+
+ const char* pUrl = pEnv->GetStringUTFChars(sUrl, NULL);
+ const char* pFormat = pEnv->GetStringUTFChars(sFormat, NULL);
+ const char* pOptions = pEnv->GetStringUTFChars(sOptions, NULL);
+
+ int result = pDocument->pClass->saveAs(pDocument, pUrl, pFormat, pOptions);
+
+ pEnv->ReleaseStringUTFChars(sUrl, pUrl);
+ pEnv->ReleaseStringUTFChars(sFormat, pFormat);
+ pEnv->ReleaseStringUTFChars(sOptions, pOptions);
+
+ return result;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */