diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2017-06-03 21:27:33 -0700 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2017-06-03 21:27:33 -0700 |
commit | 7f0a9b9f4448f7f2e87313e9e147b631b687e81b (patch) | |
tree | 5259a54b29e55d19fe65d75ac35cbb56022e591c /platform/java/mupdf_native.c | |
parent | 876f1fe8aaa9b110b3211fedbe5decbd67cf8c45 (diff) | |
download | mupdf-7f0a9b9f4448f7f2e87313e9e147b631b687e81b.tar.xz |
Tweak pdf_graft_map API.
Passing a pdf_document to pdf_graft_object to specify the source
document is redundant, as if we need to know the document, it will
be pickled into the object we are copying.
Similarly, repeatedly having to pass the destination document
seems silly when we can just pickle it into the map too (and this
removes the possibility of people using a different destination
document part way through).
This leaves to simplifying the pdf_graft_object call, at the expense
of splitting it into 2 calls - one with a map, and one without.
Also, we can delay the creation of the mapping table until we are
first asked to copy an object that requires deep copying. This
avoids us ever having to manually pass in the source document.
This has knock-on effects in the java and javascript classes, but
with the advantage of being clearer in the end (IMHO).
Conflicts:
include/mupdf/pdf/document.h
Diffstat (limited to 'platform/java/mupdf_native.c')
-rw-r--r-- | platform/java/mupdf_native.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c index f485f4f5..a0a509bf 100644 --- a/platform/java/mupdf_native.c +++ b/platform/java/mupdf_native.c @@ -6396,19 +6396,17 @@ FUN(PDFDocument_newPDFGraftMap)(JNIEnv *env, jobject self) } JNIEXPORT jobject JNICALL -FUN(PDFDocument_graftObject)(JNIEnv *env, jobject self, jobject jsrc, jobject jobj, jobject jmap) +FUN(PDFDocument_graftObject)(JNIEnv *env, jobject self, jobject jobj) { fz_context *ctx = get_context(env); - pdf_document *dst = from_PDFDocument(env, self); - pdf_document *src = from_PDFDocument(env, jsrc); pdf_obj *obj = from_PDFObject(env, jobj); - pdf_graft_map *map = from_PDFGraftMap(env, jmap); + pdf_document *dst = from_PDFDocument(env, self); if (!ctx || !dst) return NULL; - if (!src) { jni_throw_arg(env, "source must not be null"); return NULL; } + if (!dst) { jni_throw_arg(env, "dst must not be null"); return NULL; } fz_try(ctx) - obj = pdf_graft_object(ctx, dst, src, obj, map); + obj = pdf_graft_object(ctx, dst, obj); fz_catch(ctx) { jni_rethrow(env, ctx); @@ -8101,6 +8099,27 @@ FUN(PDFGraftMap_finalize)(JNIEnv *env, jobject self) pdf_drop_graft_map(ctx, map); } +JNIEXPORT jobject JNICALL +FUN(PDFGraftMap_graftObject)(JNIEnv *env, jobject self, jobject jobj) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, jobj); + pdf_graft_map *map = from_PDFGraftMap(env, self); + + if (!ctx) return NULL; + if (!map) { jni_throw_arg(env, "map must not be null"); return NULL; } + + fz_try(ctx) + obj = pdf_graft_mapped_object(ctx, map, obj); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + return to_PDFObject_safe_own(ctx, env, self, obj); +} + /* PDFPage interface */ JNIEXPORT jobject JNICALL |