diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2017-11-13 19:31:29 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2017-11-22 23:09:51 +0100 |
commit | 4bd83a37c63e9aff2938fed9192e815e9d0c1d66 (patch) | |
tree | c4da78e07ffd3f2e641fc1ca103d4c432966b329 /platform | |
parent | ed28a166dace50d1a555689b9d5353e62a1b1e69 (diff) | |
download | mupdf-4bd83a37c63e9aff2938fed9192e815e9d0c1d66.tar.xz |
jni/js: Add support for annotation modification dates.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/java/example/Viewer.java | 1 | ||||
-rw-r--r-- | platform/java/mupdf_native.c | 35 | ||||
-rw-r--r-- | platform/java/mupdf_native.h | 16 | ||||
-rw-r--r-- | platform/java/src/com/artifex/mupdf/fitz/PDFAnnotation.java | 10 |
4 files changed, 62 insertions, 0 deletions
diff --git a/platform/java/example/Viewer.java b/platform/java/example/Viewer.java index a559c218..e9a24eae 100644 --- a/platform/java/example/Viewer.java +++ b/platform/java/example/Viewer.java @@ -10,6 +10,7 @@ import java.io.File; import java.io.FilenameFilter; import java.lang.reflect.Field; import java.util.Vector; +import java.util.Date; public class Viewer extends Frame implements WindowListener, ActionListener, ItemListener, TextListener { diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c index 890bc6b1..eda01ed9 100644 --- a/platform/java/mupdf_native.c +++ b/platform/java/mupdf_native.c @@ -8300,6 +8300,41 @@ FUN(PDFAnnotation_setAuthor)(JNIEnv *env, jobject self, jstring jauthor) jni_rethrow(env, ctx); } +JNIEXPORT jlong JNICALL +FUN(PDFAnnotation_getModificationDateNative)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_annot *annot = from_PDFAnnotation(env, self); + jlong t; + + if (!ctx || !annot) return -1; + + fz_try(ctx) + t = pdf_annot_modification_date(ctx, annot); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return -1; + } + + return t * 1000; +} + +JNIEXPORT void JNICALL +FUN(PDFAnnotation_setModificationDate)(JNIEnv *env, jobject self, jlong time) +{ + fz_context *ctx = get_context(env); + pdf_annot *annot = from_PDFAnnotation(env, self); + + fz_try(ctx) + pdf_set_annot_modification_date(ctx, annot, time / 1000); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return; + } +} + JNIEXPORT jobject JNICALL FUN(PDFAnnotation_getRect)(JNIEnv *env, jobject self) { diff --git a/platform/java/mupdf_native.h b/platform/java/mupdf_native.h index dfc62d85..2065f93e 100644 --- a/platform/java/mupdf_native.h +++ b/platform/java/mupdf_native.h @@ -1522,6 +1522,22 @@ JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFAnnotation_setAuthor /* * Class: com_artifex_mupdf_fitz_PDFAnnotation + * Method: getModificationDateNative + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_com_artifex_mupdf_fitz_PDFAnnotation_getModificationDateNative + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFAnnotation + * Method: setModificationDate + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFAnnotation_setModificationDate + (JNIEnv *, jobject, jlong); + +/* + * Class: com_artifex_mupdf_fitz_PDFAnnotation * Method: getLineEndingStyles * Signature: ()[I */ diff --git a/platform/java/src/com/artifex/mupdf/fitz/PDFAnnotation.java b/platform/java/src/com/artifex/mupdf/fitz/PDFAnnotation.java index f836a601..52a433de 100644 --- a/platform/java/src/com/artifex/mupdf/fitz/PDFAnnotation.java +++ b/platform/java/src/com/artifex/mupdf/fitz/PDFAnnotation.java @@ -1,5 +1,7 @@ package com.artifex.mupdf.fitz; +import java.util.Date; + public class PDFAnnotation extends Annotation { static { @@ -62,6 +64,14 @@ public class PDFAnnotation extends Annotation public native void setInteriorColor(float[] color); public native String getAuthor(); public native void setAuthor(String author); + protected native long getModificationDateNative(); + protected native void setModificationDate(long time); + public Date getModificationDate() { + return new Date(getModificationDateNative()); + } + public void setModificationDate(Date date) { + setModificationDate(date.getTime()); + } public native int[] getLineEndingStyles(); public native void setLineEndingStyles(int startStyle, int endStyle); |