comparison mupdf-source/platform/java/jni/pdfannotation.c @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 // Copyright (C) 2004-2025 Artifex Software, Inc.
2 //
3 // This file is part of MuPDF.
4 //
5 // MuPDF is free software: you can redistribute it and/or modify it under the
6 // terms of the GNU Affero General Public License as published by the Free
7 // Software Foundation, either version 3 of the License, or (at your option)
8 // any later version.
9 //
10 // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Affero General Public License
16 // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
17 //
18 // Alternative licensing terms are available from the licensor.
19 // For commercial licensing, see <https://www.artifex.com/> or contact
20 // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
21 // CA 94129, USA, for further information.
22
23 /* Annotation interface */
24
25 JNIEXPORT void JNICALL
26 FUN(PDFAnnotation_finalize)(JNIEnv *env, jobject self)
27 {
28 fz_context *ctx = get_context(env);
29 pdf_annot *annot = from_PDFAnnotation_safe(env, self);
30 if (!ctx || !annot) return;
31 (*env)->SetLongField(env, self, fid_PDFAnnotation_pointer, 0);
32 pdf_drop_annot(ctx, annot);
33 }
34
35 JNIEXPORT void JNICALL
36 FUN(PDFAnnotation_run)(JNIEnv *env, jobject self, jobject jdev, jobject jctm, jobject jcookie)
37 {
38 fz_context *ctx = get_context(env);
39 pdf_annot *annot = from_PDFAnnotation(env, self);
40 fz_device *dev = from_Device(env, jdev);
41 fz_matrix ctm = from_Matrix(env, jctm);
42 fz_cookie *cookie= from_Cookie(env, jcookie);
43 NativeDeviceInfo *info;
44 int err;
45
46 if (!ctx || !annot) return;
47 if (!dev) jni_throw_arg_void(env, "device must not be null");
48
49 info = lockNativeDevice(env, jdev, &err);
50 if (err)
51 return;
52 fz_try(ctx)
53 pdf_run_annot(ctx, annot, dev, ctm, cookie);
54 fz_always(ctx)
55 unlockNativeDevice(env, info);
56 fz_catch(ctx)
57 jni_rethrow_void(env, ctx);
58 }
59
60 JNIEXPORT jobject JNICALL
61 FUN(PDFAnnotation_toPixmap)(JNIEnv *env, jobject self, jobject jctm, jobject jcs, jboolean alpha)
62 {
63 fz_context *ctx = get_context(env);
64 pdf_annot *annot = from_PDFAnnotation(env, self);
65 fz_matrix ctm = from_Matrix(env, jctm);
66 fz_colorspace *cs = from_ColorSpace(env, jcs);
67 fz_pixmap *pixmap = NULL;
68
69 if (!ctx || !annot) return NULL;
70
71 fz_try(ctx)
72 pixmap = pdf_new_pixmap_from_annot(ctx, annot, ctm, cs, NULL, alpha);
73 fz_catch(ctx)
74 jni_rethrow(env, ctx);
75
76 return to_Pixmap_safe_own(ctx, env, pixmap);
77 }
78
79 JNIEXPORT jobject JNICALL
80 FUN(PDFAnnotation_getBounds)(JNIEnv *env, jobject self)
81 {
82 fz_context *ctx = get_context(env);
83 pdf_annot *annot = from_PDFAnnotation(env, self);
84 fz_rect rect;
85
86 if (!ctx || !annot) return NULL;
87
88 fz_try(ctx)
89 rect = pdf_bound_annot(ctx, annot);
90 fz_catch(ctx)
91 jni_rethrow(env, ctx);
92
93 return to_Rect_safe(ctx, env, rect);
94 }
95
96 JNIEXPORT jobject JNICALL
97 FUN(PDFAnnotation_toDisplayList)(JNIEnv *env, jobject self)
98 {
99 fz_context *ctx = get_context(env);
100 pdf_annot *annot = from_PDFAnnotation(env, self);
101 fz_display_list *list = NULL;
102
103 if (!ctx || !annot) return NULL;
104
105 fz_try(ctx)
106 list = pdf_new_display_list_from_annot(ctx, annot);
107 fz_catch(ctx)
108 jni_rethrow(env, ctx);
109
110 return to_DisplayList_safe_own(ctx, env, list);
111 }
112
113 JNIEXPORT jint JNICALL
114 FUN(PDFAnnotation_getType)(JNIEnv *env, jobject self)
115 {
116 fz_context *ctx = get_context(env);
117 pdf_annot *annot = from_PDFAnnotation(env, self);
118 jint type = 0;
119
120 if (!ctx || !annot) return 0;
121
122 fz_try(ctx)
123 type = pdf_annot_type(ctx, annot);
124 fz_catch(ctx)
125 jni_rethrow(env, ctx);
126
127 return type;
128 }
129
130 JNIEXPORT jint JNICALL
131 FUN(PDFAnnotation_getFlags)(JNIEnv *env, jobject self)
132 {
133 fz_context *ctx = get_context(env);
134 pdf_annot *annot = from_PDFAnnotation(env, self);
135 jint flags = 0;
136
137 if (!ctx || !annot) return 0;
138
139 fz_try(ctx)
140 flags = pdf_annot_flags(ctx, annot);
141 fz_catch(ctx)
142 jni_rethrow(env, ctx);
143
144 return flags;
145 }
146
147 JNIEXPORT void JNICALL
148 FUN(PDFAnnotation_setFlags)(JNIEnv *env, jobject self, jint flags)
149 {
150 fz_context *ctx = get_context(env);
151 pdf_annot *annot = from_PDFAnnotation(env, self);
152
153 if (!ctx || !annot) return;
154
155 fz_try(ctx)
156 pdf_set_annot_flags(ctx, annot, flags);
157 fz_catch(ctx)
158 jni_rethrow_void(env, ctx);
159 }
160
161 JNIEXPORT jstring JNICALL
162 FUN(PDFAnnotation_getContents)(JNIEnv *env, jobject self)
163 {
164 fz_context *ctx = get_context(env);
165 pdf_annot *annot = from_PDFAnnotation(env, self);
166 const char *contents = NULL;
167
168 if (!ctx || !annot) return NULL;
169
170 fz_try(ctx)
171 contents = pdf_annot_contents(ctx, annot);
172 fz_catch(ctx)
173 jni_rethrow(env, ctx);
174
175 return (*env)->NewStringUTF(env, contents);
176 }
177
178 JNIEXPORT void JNICALL
179 FUN(PDFAnnotation_setContents)(JNIEnv *env, jobject self, jstring jcontents)
180 {
181 fz_context *ctx = get_context(env);
182 pdf_annot *annot = from_PDFAnnotation(env, self);
183 const char *contents = "";
184
185 if (!ctx || !annot) return;
186 if (jcontents)
187 {
188 contents = (*env)->GetStringUTFChars(env, jcontents, NULL);
189 if (!contents) return;
190 }
191
192 fz_try(ctx)
193 pdf_set_annot_contents(ctx, annot, contents);
194 fz_always(ctx)
195 if (contents)
196 (*env)->ReleaseStringUTFChars(env, jcontents, contents);
197 fz_catch(ctx)
198 jni_rethrow_void(env, ctx);
199 }
200
201 JNIEXPORT jstring JNICALL
202 FUN(PDFAnnotation_getAuthor)(JNIEnv *env, jobject self)
203 {
204 fz_context *ctx = get_context(env);
205 pdf_annot *annot = from_PDFAnnotation(env, self);
206 const char *author = NULL;
207
208 if (!ctx || !annot) return NULL;
209
210 fz_try(ctx)
211 author = pdf_annot_author(ctx, annot);
212 fz_catch(ctx)
213 jni_rethrow(env, ctx);
214
215 return (*env)->NewStringUTF(env, author);
216 }
217
218 JNIEXPORT void JNICALL
219 FUN(PDFAnnotation_setAuthor)(JNIEnv *env, jobject self, jstring jauthor)
220 {
221 fz_context *ctx = get_context(env);
222 pdf_annot *annot = from_PDFAnnotation(env, self);
223 const char *author = "";
224
225 if (!ctx || !annot) return;
226 if (jauthor)
227 {
228 author = (*env)->GetStringUTFChars(env, jauthor, NULL);
229 if (!author) return;
230 }
231
232 fz_try(ctx)
233 pdf_set_annot_author(ctx, annot, author);
234 fz_always(ctx)
235 if (author)
236 (*env)->ReleaseStringUTFChars(env, jauthor, author);
237 fz_catch(ctx)
238 jni_rethrow_void(env, ctx);
239 }
240
241 JNIEXPORT jlong JNICALL
242 FUN(PDFAnnotation_getModificationDateNative)(JNIEnv *env, jobject self)
243 {
244 fz_context *ctx = get_context(env);
245 pdf_annot *annot = from_PDFAnnotation(env, self);
246 jlong t;
247
248 if (!ctx || !annot) return -1;
249
250 fz_try(ctx)
251 t = pdf_annot_modification_date(ctx, annot);
252 fz_catch(ctx)
253 jni_rethrow(env, ctx);
254
255 return t * 1000;
256 }
257
258 JNIEXPORT void JNICALL
259 FUN(PDFAnnotation_setModificationDate)(JNIEnv *env, jobject self, jlong time)
260 {
261 fz_context *ctx = get_context(env);
262 pdf_annot *annot = from_PDFAnnotation(env, self);
263
264 fz_try(ctx)
265 pdf_set_annot_modification_date(ctx, annot, time / 1000);
266 fz_catch(ctx)
267 jni_rethrow_void(env, ctx);
268 }
269
270 JNIEXPORT jlong JNICALL
271 FUN(PDFAnnotation_getCreationDateNative)(JNIEnv *env, jobject self)
272 {
273 fz_context *ctx = get_context(env);
274 pdf_annot *annot = from_PDFAnnotation(env, self);
275 jlong t;
276
277 if (!ctx || !annot) return -1;
278
279 fz_try(ctx)
280 t = pdf_annot_creation_date(ctx, annot);
281 fz_catch(ctx)
282 jni_rethrow(env, ctx);
283
284 return t * 1000;
285 }
286
287 JNIEXPORT void JNICALL
288 FUN(PDFAnnotation_setCreationDate)(JNIEnv *env, jobject self, jlong time)
289 {
290 fz_context *ctx = get_context(env);
291 pdf_annot *annot = from_PDFAnnotation(env, self);
292
293 fz_try(ctx)
294 pdf_set_annot_creation_date(ctx, annot, time / 1000);
295 fz_catch(ctx)
296 jni_rethrow_void(env, ctx);
297 }
298
299 JNIEXPORT jobject JNICALL
300 FUN(PDFAnnotation_getRect)(JNIEnv *env, jobject self)
301 {
302 fz_context *ctx = get_context(env);
303 pdf_annot *annot = from_PDFAnnotation(env, self);
304 fz_rect rect;
305
306 if (!ctx || !annot) return NULL;
307
308 fz_try(ctx)
309 rect = pdf_annot_rect(ctx, annot);
310 fz_catch(ctx)
311 jni_rethrow(env, ctx);
312
313 return to_Rect_safe(ctx, env, rect);
314 }
315
316 JNIEXPORT void JNICALL
317 FUN(PDFAnnotation_setRect)(JNIEnv *env, jobject self, jobject jrect)
318 {
319 fz_context *ctx = get_context(env);
320 pdf_annot *annot = from_PDFAnnotation(env, self);
321 fz_rect rect = from_Rect(env, jrect);
322
323 if (!ctx || !annot) return;
324
325 fz_try(ctx)
326 pdf_set_annot_rect(ctx, annot, rect);
327 fz_catch(ctx)
328 jni_rethrow_void(env, ctx);
329 }
330
331 JNIEXPORT jobject JNICALL
332 FUN(PDFAnnotation_getColor)(JNIEnv *env, jobject self)
333 {
334 fz_context *ctx = get_context(env);
335 pdf_annot *annot = from_PDFAnnotation(env, self);
336 int n;
337 float color[4];
338 jfloatArray arr;
339
340 if (!ctx || !annot) return NULL;
341
342 fz_try(ctx)
343 pdf_annot_color(ctx, annot, &n, color);
344 fz_catch(ctx)
345 jni_rethrow(env, ctx);
346
347 arr = (*env)->NewFloatArray(env, n);
348 if (!arr || (*env)->ExceptionCheck(env)) return NULL;
349
350 (*env)->SetFloatArrayRegion(env, arr, 0, n, &color[0]);
351 if ((*env)->ExceptionCheck(env)) return NULL;
352
353 return arr;
354 }
355
356 JNIEXPORT void JNICALL
357 FUN(PDFAnnotation_setColor)(JNIEnv *env, jobject self, jobject jcolor)
358 {
359 fz_context *ctx = get_context(env);
360 pdf_annot *annot = from_PDFAnnotation(env, self);
361 float color[4];
362 int n = 0;
363
364 if (!ctx || !annot) return;
365 if (!from_jfloatArray(env, color, nelem(color), jcolor)) return;
366 if (jcolor)
367 n = (*env)->GetArrayLength(env, jcolor);
368
369 fz_try(ctx)
370 pdf_set_annot_color(ctx, annot, n, color);
371 fz_catch(ctx)
372 jni_rethrow_void(env, ctx);
373 }
374
375 JNIEXPORT jobject JNICALL
376 FUN(PDFAnnotation_getInteriorColor)(JNIEnv *env, jobject self)
377 {
378 fz_context *ctx = get_context(env);
379 pdf_annot *annot = from_PDFAnnotation(env, self);
380 int n;
381 float color[4];
382 jfloatArray arr;
383
384 if (!ctx || !annot) return NULL;
385
386 fz_try(ctx)
387 pdf_annot_interior_color(ctx, annot, &n, color);
388 fz_catch(ctx)
389 jni_rethrow(env, ctx);
390
391 arr = (*env)->NewFloatArray(env, n);
392 if (!arr || (*env)->ExceptionCheck(env)) return NULL;
393
394 (*env)->SetFloatArrayRegion(env, arr, 0, n, &color[0]);
395 if ((*env)->ExceptionCheck(env)) return NULL;
396
397 return arr;
398 }
399
400 JNIEXPORT void JNICALL
401 FUN(PDFAnnotation_setInteriorColor)(JNIEnv *env, jobject self, jobject jcolor)
402 {
403 fz_context *ctx = get_context(env);
404 pdf_annot *annot = from_PDFAnnotation(env, self);
405 float color[4];
406 int n = 0;
407
408 if (!ctx || !annot) return;
409 if (!from_jfloatArray(env, color, nelem(color), jcolor)) return;
410 if (jcolor)
411 n = (*env)->GetArrayLength(env, jcolor);
412
413 fz_try(ctx)
414 pdf_set_annot_interior_color(ctx, annot, n, color);
415 fz_catch(ctx)
416 jni_rethrow_void(env, ctx);
417 }
418
419 JNIEXPORT jfloat JNICALL
420 FUN(PDFAnnotation_getOpacity)(JNIEnv *env, jobject self)
421 {
422 fz_context *ctx = get_context(env);
423 pdf_annot *annot = from_PDFAnnotation(env, self);
424 jfloat opacity;
425
426 if (!ctx || !annot) return 0.0f;
427
428 fz_try(ctx)
429 opacity = pdf_annot_opacity(ctx, annot);
430 fz_catch(ctx)
431 jni_rethrow(env, ctx);
432
433 return opacity;
434 }
435
436 JNIEXPORT void JNICALL
437 FUN(PDFAnnotation_setOpacity)(JNIEnv *env, jobject self, jfloat opacity)
438 {
439 fz_context *ctx = get_context(env);
440 pdf_annot *annot = from_PDFAnnotation(env, self);
441
442 if (!ctx || !annot) return;
443
444 fz_try(ctx)
445 pdf_set_annot_opacity(ctx, annot, opacity);
446 fz_catch(ctx)
447 jni_rethrow_void(env, ctx);
448 }
449
450 JNIEXPORT jint JNICALL
451 FUN(PDFAnnotation_getQuadPointCount)(JNIEnv *env, jobject self)
452 {
453 fz_context *ctx = get_context(env);
454 pdf_annot *annot = from_PDFAnnotation(env, self);
455 int n = 0;
456
457 fz_try(ctx)
458 n = pdf_annot_quad_point_count(ctx, annot);
459 fz_catch(ctx)
460 jni_rethrow(env, ctx);
461
462 return n;
463 }
464
465 JNIEXPORT jobject JNICALL
466 FUN(PDFAnnotation_getQuadPoint)(JNIEnv *env, jobject self, jint i)
467 {
468 fz_context *ctx = get_context(env);
469 pdf_annot *annot = from_PDFAnnotation(env, self);
470 fz_quad q;
471
472 fz_try(ctx)
473 q = pdf_annot_quad_point(ctx, annot, i);
474 fz_catch(ctx)
475 jni_rethrow(env, ctx);
476
477 return to_Quad_safe(ctx, env, q);
478 }
479
480 JNIEXPORT void JNICALL
481 FUN(PDFAnnotation_clearQuadPoints)(JNIEnv *env, jobject self)
482 {
483 fz_context *ctx = get_context(env);
484 pdf_annot *annot = from_PDFAnnotation(env, self);
485
486 fz_try(ctx)
487 pdf_clear_annot_quad_points(ctx, annot);
488 fz_catch(ctx)
489 jni_rethrow_void(env, ctx);
490 }
491
492 JNIEXPORT void JNICALL
493 FUN(PDFAnnotation_addQuadPoint)(JNIEnv *env, jobject self, jobject qobj)
494 {
495 fz_context *ctx = get_context(env);
496 pdf_annot *annot = from_PDFAnnotation(env, self);
497 fz_quad q = from_Quad(env, qobj);
498
499 fz_try(ctx)
500 pdf_add_annot_quad_point(ctx, annot, q);
501 fz_catch(ctx)
502 jni_rethrow_void(env, ctx);
503 }
504
505 JNIEXPORT jint JNICALL
506 FUN(PDFAnnotation_getVertexCount)(JNIEnv *env, jobject self)
507 {
508 fz_context *ctx = get_context(env);
509 pdf_annot *annot = from_PDFAnnotation(env, self);
510 int n = 0;
511
512 fz_try(ctx)
513 n = pdf_annot_vertex_count(ctx, annot);
514 fz_catch(ctx)
515 jni_rethrow(env, ctx);
516
517 return n;
518 }
519
520 JNIEXPORT jobject JNICALL
521 FUN(PDFAnnotation_getVertex)(JNIEnv *env, jobject self, jint i)
522 {
523 fz_context *ctx = get_context(env);
524 pdf_annot *annot = from_PDFAnnotation(env, self);
525 fz_point v;
526
527 fz_try(ctx)
528 v = pdf_annot_vertex(ctx, annot, i);
529 fz_catch(ctx)
530 jni_rethrow(env, ctx);
531
532 return to_Point_safe(ctx, env, v);
533 }
534
535 JNIEXPORT void JNICALL
536 FUN(PDFAnnotation_clearVertices)(JNIEnv *env, jobject self)
537 {
538 fz_context *ctx = get_context(env);
539 pdf_annot *annot = from_PDFAnnotation(env, self);
540
541 fz_try(ctx)
542 pdf_clear_annot_vertices(ctx, annot);
543 fz_catch(ctx)
544 jni_rethrow_void(env, ctx);
545 }
546
547 JNIEXPORT void JNICALL
548 FUN(PDFAnnotation_addVertex)(JNIEnv *env, jobject self, float x, float y)
549 {
550 fz_context *ctx = get_context(env);
551 pdf_annot *annot = from_PDFAnnotation(env, self);
552
553 fz_try(ctx)
554 pdf_add_annot_vertex(ctx, annot, fz_make_point(x, y));
555 fz_catch(ctx)
556 jni_rethrow_void(env, ctx);
557 }
558
559 JNIEXPORT jint JNICALL
560 FUN(PDFAnnotation_getInkListCount)(JNIEnv *env, jobject self)
561 {
562 fz_context *ctx = get_context(env);
563 pdf_annot *annot = from_PDFAnnotation(env, self);
564 int n = 0;
565
566 fz_try(ctx)
567 n = pdf_annot_ink_list_count(ctx, annot);
568 fz_catch(ctx)
569 jni_rethrow(env, ctx);
570
571 return n;
572 }
573
574 JNIEXPORT jint JNICALL
575 FUN(PDFAnnotation_getInkListStrokeCount)(JNIEnv *env, jobject self, jint i)
576 {
577 fz_context *ctx = get_context(env);
578 pdf_annot *annot = from_PDFAnnotation(env, self);
579 int n = 0;
580
581 fz_try(ctx)
582 n = pdf_annot_ink_list_stroke_count(ctx, annot, i);
583 fz_catch(ctx)
584 jni_rethrow(env, ctx);
585
586 return n;
587 }
588
589 JNIEXPORT jobject JNICALL
590 FUN(PDFAnnotation_getInkListStrokeVertex)(JNIEnv *env, jobject self, jint i, jint k)
591 {
592 fz_context *ctx = get_context(env);
593 pdf_annot *annot = from_PDFAnnotation(env, self);
594 fz_point v;
595
596 fz_try(ctx)
597 v = pdf_annot_ink_list_stroke_vertex(ctx, annot, i, k);
598 fz_catch(ctx)
599 jni_rethrow(env, ctx);
600
601 return to_Point_safe(ctx, env, v);
602 }
603
604 JNIEXPORT void JNICALL
605 FUN(PDFAnnotation_clearInkList)(JNIEnv *env, jobject self)
606 {
607 fz_context *ctx = get_context(env);
608 pdf_annot *annot = from_PDFAnnotation(env, self);
609
610 fz_try(ctx)
611 pdf_clear_annot_ink_list(ctx, annot);
612 fz_catch(ctx)
613 jni_rethrow_void(env, ctx);
614 }
615
616 JNIEXPORT void JNICALL
617 FUN(PDFAnnotation_addInkListStroke)(JNIEnv *env, jobject self)
618 {
619 fz_context *ctx = get_context(env);
620 pdf_annot *annot = from_PDFAnnotation(env, self);
621
622 fz_try(ctx)
623 pdf_add_annot_ink_list_stroke(ctx, annot);
624 fz_catch(ctx)
625 jni_rethrow_void(env, ctx);
626 }
627
628 JNIEXPORT void JNICALL
629 FUN(PDFAnnotation_addInkListStrokeVertex)(JNIEnv *env, jobject self, float x, float y)
630 {
631 fz_context *ctx = get_context(env);
632 pdf_annot *annot = from_PDFAnnotation(env, self);
633
634 fz_try(ctx)
635 pdf_add_annot_ink_list_stroke_vertex(ctx, annot, fz_make_point(x, y));
636 fz_catch(ctx)
637 jni_rethrow_void(env, ctx);
638 }
639
640 JNIEXPORT jboolean JNICALL
641 FUN(PDFAnnotation_hasCallout)(JNIEnv *env, jobject self)
642 {
643 fz_context *ctx = get_context(env);
644 pdf_annot *annot = from_PDFAnnotation(env, self);
645 jboolean has = JNI_FALSE;
646
647 fz_try(ctx)
648 has = pdf_annot_has_callout(ctx, annot);
649 fz_catch(ctx)
650 jni_rethrow(env, ctx);
651
652 return has;
653 }
654
655 JNIEXPORT jint JNICALL
656 FUN(PDFAnnotation_getCalloutStyle)(JNIEnv *env, jobject self)
657 {
658 fz_context *ctx = get_context(env);
659 pdf_annot *annot = from_PDFAnnotation(env, self);
660 enum pdf_line_ending s = 0;
661
662 fz_try(ctx)
663 s = pdf_annot_callout_style(ctx, annot);
664 fz_catch(ctx)
665 jni_rethrow(env, ctx);
666
667 return s;
668 }
669
670 JNIEXPORT void JNICALL
671 FUN(PDFAnnotation_setCalloutStyle)(JNIEnv *env, jobject self, jint s)
672 {
673 fz_context *ctx = get_context(env);
674 pdf_annot *annot = from_PDFAnnotation(env, self);
675 fz_try(ctx)
676 pdf_set_annot_callout_style(ctx, annot, s);
677 fz_catch(ctx)
678 jni_rethrow_void(env, ctx);
679 }
680
681 JNIEXPORT jobject JNICALL
682 FUN(PDFAnnotation_getCalloutPoint)(JNIEnv *env, jobject self)
683 {
684 fz_context *ctx = get_context(env);
685 pdf_annot *annot = from_PDFAnnotation(env, self);
686 fz_point p;
687
688 if (!ctx || !annot) return NULL;
689
690 fz_try(ctx)
691 p = pdf_annot_callout_point(ctx, annot);
692 fz_catch(ctx)
693 jni_rethrow(env, ctx);
694
695 return (*env)->NewObject(env, cls_Point, mid_Point_init, p.x, p.y);
696 }
697
698 JNIEXPORT void JNICALL
699 FUN(PDFAnnotation_setCalloutPoint)(JNIEnv *env, jobject self, jobject jp)
700 {
701 fz_context *ctx = get_context(env);
702 pdf_annot *annot = from_PDFAnnotation(env, self);
703 fz_point p;
704
705 if (!ctx || !annot) return;
706
707 if (!jp) jni_throw_arg_void(env, "point must not be null");
708
709 p.x = (*env)->GetFloatField(env, jp, fid_Point_x);
710 p.y = (*env)->GetFloatField(env, jp, fid_Point_y);
711
712 fz_try(ctx)
713 pdf_set_annot_callout_point(ctx, annot, p);
714 fz_catch(ctx)
715 jni_rethrow_void(env, ctx);
716 }
717
718 JNIEXPORT jobject JNICALL
719 FUN(PDFAnnotation_getCalloutLine)(JNIEnv *env, jobject self)
720 {
721 fz_context *ctx = get_context(env);
722 pdf_annot *annot = from_PDFAnnotation(env, self);
723 fz_point points[3] = { 0 };
724 jobject jline = NULL;
725 jobject jpoint = NULL;
726 int i, n;
727
728 if (!ctx || !annot) return NULL;
729
730 fz_try(ctx)
731 pdf_annot_callout_line(ctx, annot, points, &n);
732 fz_catch(ctx)
733 jni_rethrow(env, ctx);
734
735 if (n == 0)
736 return NULL;
737
738 jline = (*env)->NewObjectArray(env, n, cls_Point, NULL);
739 if (!jline || (*env)->ExceptionCheck(env)) return NULL;
740
741 for (i = 0; i < n; i++)
742 {
743 jpoint = (*env)->NewObject(env, cls_Point, mid_Point_init, points[i].x, points[i].y);
744 if (!jpoint || (*env)->ExceptionCheck(env)) return NULL;
745 (*env)->SetObjectArrayElement(env, jline, i, jpoint);
746 if ((*env)->ExceptionCheck(env)) return NULL;
747 (*env)->DeleteLocalRef(env, jpoint);
748 }
749
750 return jline;
751 }
752
753 JNIEXPORT void JNICALL
754 FUN(PDFAnnotation_setCalloutLineNative)(JNIEnv *env, jobject self, jint n, jobject ja, jobject jb, jobject jc)
755 {
756 fz_context *ctx = get_context(env);
757 pdf_annot *annot = from_PDFAnnotation(env, self);
758 fz_point line[3];
759
760 if (!ctx || !annot) return;
761
762 if (n >= 2 && !ja) jni_throw_arg_void(env, "points must not be null");
763 if (n >= 2 && !jb) jni_throw_arg_void(env, "points must not be null");
764 if (n >= 3 && !jc) jni_throw_arg_void(env, "points must not be null");
765
766 if (n >= 2) {
767 line[0].x = (*env)->GetFloatField(env, ja, fid_Point_x);
768 line[0].y = (*env)->GetFloatField(env, ja, fid_Point_y);
769 line[1].x = (*env)->GetFloatField(env, jb, fid_Point_x);
770 line[1].y = (*env)->GetFloatField(env, jb, fid_Point_y);
771 }
772 if (n >= 3) {
773 line[2].x = (*env)->GetFloatField(env, jc, fid_Point_x);
774 line[2].y = (*env)->GetFloatField(env, jc, fid_Point_y);
775 }
776
777 fz_try(ctx)
778 {
779 if (n == 0 || n == 2 || n == 3)
780 pdf_set_annot_callout_line(ctx, annot, line, n);
781 }
782 fz_catch(ctx)
783 jni_rethrow_void(env, ctx);
784 }
785
786 JNIEXPORT void JNICALL
787 FUN(PDFAnnotation_eventEnter)(JNIEnv *env, jobject self)
788 {
789 fz_context *ctx = get_context(env);
790 pdf_annot *annot = from_PDFAnnotation(env, self);
791
792 if (!ctx || !annot) return;
793
794 fz_try(ctx)
795 {
796 pdf_annot_event_enter(ctx, annot);
797 pdf_set_annot_hot(ctx, annot, 1);
798 }
799 fz_catch(ctx)
800 jni_rethrow_void(env, ctx);
801 }
802
803 JNIEXPORT void JNICALL
804 FUN(PDFAnnotation_eventExit)(JNIEnv *env, jobject self)
805 {
806 fz_context *ctx = get_context(env);
807 pdf_annot *annot = from_PDFAnnotation(env, self);
808
809 if (!ctx || !annot) return;
810
811 fz_try(ctx)
812 {
813 pdf_annot_event_exit(ctx, annot);
814 pdf_set_annot_hot(ctx, annot, 0);
815 }
816 fz_catch(ctx)
817 jni_rethrow_void(env, ctx);
818 }
819
820 JNIEXPORT void JNICALL
821 FUN(PDFAnnotation_eventDown)(JNIEnv *env, jobject self)
822 {
823 fz_context *ctx = get_context(env);
824 pdf_annot *annot = from_PDFAnnotation(env, self);
825
826 if (!ctx || !annot) return;
827
828 fz_try(ctx)
829 {
830 pdf_annot_event_down(ctx, annot);
831 pdf_set_annot_active(ctx, annot, 1);
832 }
833 fz_catch(ctx)
834 jni_rethrow_void(env, ctx);
835 }
836
837 JNIEXPORT void JNICALL
838 FUN(PDFAnnotation_eventUp)(JNIEnv *env, jobject self)
839 {
840 fz_context *ctx = get_context(env);
841 pdf_annot *annot = from_PDFAnnotation(env, self);
842
843 if (!ctx || !annot) return;
844
845 fz_try(ctx)
846 {
847 if (pdf_annot_hot(ctx, annot) && pdf_annot_active(ctx, annot))
848 pdf_annot_event_up(ctx, annot);
849 pdf_set_annot_active(ctx, annot, 0);
850 }
851 fz_catch(ctx)
852 jni_rethrow_void(env, ctx);
853 }
854
855 JNIEXPORT void JNICALL
856 FUN(PDFAnnotation_eventFocus)(JNIEnv *env, jobject self)
857 {
858 fz_context *ctx = get_context(env);
859 pdf_annot *annot = from_PDFAnnotation(env, self);
860
861 if (!ctx || !annot) return;
862
863 fz_try(ctx)
864 pdf_annot_event_focus(ctx, annot);
865 fz_catch(ctx)
866 jni_rethrow_void(env, ctx);
867 }
868
869 JNIEXPORT void JNICALL
870 FUN(PDFAnnotation_eventBlur)(JNIEnv *env, jobject self)
871 {
872 fz_context *ctx = get_context(env);
873 pdf_annot *annot = from_PDFAnnotation(env, self);
874
875 if (!ctx || !annot) return;
876
877 fz_try(ctx)
878 pdf_annot_event_blur(ctx, annot);
879 fz_catch(ctx)
880 jni_rethrow_void(env, ctx);
881 }
882
883 JNIEXPORT jboolean JNICALL
884 FUN(PDFAnnotation_update)(JNIEnv *env, jobject self)
885 {
886 fz_context *ctx = get_context(env);
887 pdf_annot *annot = from_PDFAnnotation(env, self);
888 jboolean changed = JNI_FALSE;
889
890 if (!ctx || !annot) return JNI_FALSE;
891
892 fz_try(ctx)
893 changed = pdf_update_annot(ctx, annot);
894 fz_catch(ctx)
895 jni_rethrow(env, ctx);
896
897 return changed;
898 }
899
900 JNIEXPORT jboolean JNICALL
901 FUN(PDFAnnotation_getIsOpen)(JNIEnv *env, jobject self)
902 {
903 fz_context *ctx = get_context(env);
904 pdf_annot *annot = from_PDFAnnotation(env, self);
905 jboolean open = JNI_FALSE;
906
907 if (!ctx || !annot) return JNI_FALSE;
908
909 fz_try(ctx)
910 open = pdf_annot_is_open(ctx, annot);
911 fz_catch(ctx)
912 jni_rethrow(env, ctx);
913
914 return open;
915 }
916
917 JNIEXPORT void JNICALL
918 FUN(PDFAnnotation_setIsOpen)(JNIEnv *env, jobject self, jboolean open)
919 {
920 fz_context *ctx = get_context(env);
921 pdf_annot *annot = from_PDFAnnotation(env, self);
922
923 if (!ctx || !annot) return;
924
925 fz_try(ctx)
926 pdf_set_annot_is_open(ctx, annot, open);
927 fz_catch(ctx)
928 jni_rethrow_void(env, ctx);
929 }
930
931 JNIEXPORT jstring JNICALL
932 FUN(PDFAnnotation_getIcon)(JNIEnv *env, jobject self)
933 {
934 fz_context *ctx = get_context(env);
935 pdf_annot *annot = from_PDFAnnotation(env, self);
936 const char *name = NULL;
937
938 if (!ctx || !annot) return NULL;
939
940 fz_try(ctx)
941 name = pdf_annot_icon_name(ctx, annot);
942 fz_catch(ctx)
943 jni_rethrow(env, ctx);
944
945 return (*env)->NewStringUTF(env, name);
946 }
947
948 JNIEXPORT void JNICALL
949 FUN(PDFAnnotation_setIcon)(JNIEnv *env, jobject self, jstring jname)
950 {
951 fz_context *ctx = get_context(env);
952 pdf_annot *annot = from_PDFAnnotation(env, self);
953 const char *name = NULL;
954
955 if (!ctx || !annot) return;
956 if (!jname) jni_throw_arg_void(env, "icon name must not be null");
957
958 name = (*env)->GetStringUTFChars(env, jname, NULL);
959 if (!name) return;
960
961 fz_try(ctx)
962 pdf_set_annot_icon_name(ctx, annot, name);
963 fz_always(ctx)
964 if (name)
965 (*env)->ReleaseStringUTFChars(env, jname, name);
966 fz_catch(ctx)
967 jni_rethrow_void(env, ctx);
968 }
969
970 JNIEXPORT jintArray JNICALL
971 FUN(PDFAnnotation_getLineEndingStyles)(JNIEnv *env, jobject self)
972 {
973 fz_context *ctx = get_context(env);
974 pdf_annot *annot = from_PDFAnnotation(env, self);
975 enum pdf_line_ending s = 0, e = 0;
976 int line_endings[2];
977 jintArray jline_endings = NULL;
978
979 if (!ctx || !annot) return NULL;
980
981 fz_try(ctx)
982 pdf_annot_line_ending_styles(ctx, annot, &s, &e);
983 fz_catch(ctx)
984 jni_rethrow(env, ctx);
985
986 line_endings[0] = s;
987 line_endings[1] = e;
988
989 jline_endings = (*env)->NewIntArray(env, 2);
990 if (!jline_endings || (*env)->ExceptionCheck(env)) return NULL;
991
992 (*env)->SetIntArrayRegion(env, jline_endings, 0, 2, &line_endings[0]);
993 if ((*env)->ExceptionCheck(env)) return NULL;
994
995 return jline_endings;
996 }
997
998 JNIEXPORT void JNICALL
999 FUN(PDFAnnotation_setLineEndingStyles)(JNIEnv *env, jobject self, jint start_style, jint end_style)
1000 {
1001 fz_context *ctx = get_context(env);
1002 pdf_annot *annot = from_PDFAnnotation(env, self);
1003
1004 if (!ctx || !annot) return;
1005
1006 fz_try(ctx)
1007 pdf_set_annot_line_ending_styles(ctx, annot, start_style, end_style);
1008 fz_catch(ctx)
1009 jni_rethrow_void(env, ctx);
1010 }
1011
1012 JNIEXPORT jobject JNICALL
1013 FUN(PDFAnnotation_getObject)(JNIEnv *env, jobject self)
1014 {
1015 fz_context *ctx = get_context(env);
1016 pdf_annot *annot = from_PDFAnnotation(env, self);
1017
1018 if (!ctx || !annot) return NULL;
1019
1020 return to_PDFObject_safe(ctx, env, pdf_annot_obj(ctx, annot));
1021 }
1022
1023 JNIEXPORT jint JNICALL
1024 FUN(PDFAnnotation_getLanguage)(JNIEnv *env, jobject self)
1025 {
1026 fz_context *ctx = get_context(env);
1027 pdf_annot *annot = from_PDFAnnotation(env, self);
1028 int lang;
1029
1030 if (!ctx || !annot) return FZ_LANG_UNSET;
1031
1032 fz_try(ctx)
1033 lang = pdf_annot_language(ctx, annot);
1034 fz_catch(ctx)
1035 jni_rethrow(env, ctx);
1036
1037 return lang;
1038 }
1039
1040 JNIEXPORT void JNICALL
1041 FUN(PDFAnnotation_setLanguage)(JNIEnv *env, jobject self, jint lang)
1042 {
1043 fz_context *ctx = get_context(env);
1044 pdf_annot *annot = from_PDFAnnotation(env, self);
1045
1046 if (!ctx || !annot) return;
1047
1048 fz_try(ctx)
1049 pdf_set_annot_language(ctx, annot, lang);
1050 fz_catch(ctx)
1051 jni_rethrow_void(env, ctx);
1052 }
1053
1054 JNIEXPORT jboolean JNICALL
1055 FUN(PDFAnnotation_hasQuadding)(JNIEnv *env, jobject self)
1056 {
1057 fz_context *ctx = get_context(env);
1058 pdf_annot *annot = from_PDFAnnotation(env, self);
1059 jboolean has = JNI_FALSE;
1060
1061 fz_try(ctx)
1062 has = pdf_annot_has_quadding(ctx, annot);
1063 fz_catch(ctx)
1064 jni_rethrow(env, ctx);
1065
1066 return has;
1067 }
1068
1069 JNIEXPORT jint JNICALL
1070 FUN(PDFAnnotation_getQuadding)(JNIEnv *env, jobject self)
1071 {
1072 fz_context *ctx = get_context(env);
1073 pdf_annot *annot = from_PDFAnnotation(env, self);
1074 int quadding;
1075
1076 if (!ctx || !annot) return 0;
1077
1078 fz_try(ctx)
1079 quadding = pdf_annot_quadding(ctx, annot);
1080 fz_catch(ctx)
1081 jni_rethrow(env, ctx);
1082
1083 return quadding;
1084 }
1085
1086 JNIEXPORT void JNICALL
1087 FUN(PDFAnnotation_setQuadding)(JNIEnv *env, jobject self, jint quadding)
1088 {
1089 fz_context *ctx = get_context(env);
1090 pdf_annot *annot = from_PDFAnnotation(env, self);
1091
1092 if (!ctx || !annot) return;
1093
1094 fz_try(ctx)
1095 pdf_set_annot_quadding(ctx, annot, quadding);
1096 fz_catch(ctx)
1097 jni_rethrow_void(env, ctx);
1098 }
1099
1100 JNIEXPORT jobject JNICALL
1101 FUN(PDFAnnotation_getLine)(JNIEnv *env, jobject self)
1102 {
1103 fz_context *ctx = get_context(env);
1104 pdf_annot *annot = from_PDFAnnotation(env, self);
1105 fz_point points[2] = { 0 };
1106 jobject jline = NULL;
1107 jobject jpoint = NULL;
1108 size_t i = 0;
1109
1110 if (!ctx || !annot) return NULL;
1111
1112 fz_try(ctx)
1113 pdf_annot_line(ctx, annot, &points[0], &points[1]);
1114 fz_catch(ctx)
1115 jni_rethrow(env, ctx);
1116
1117 jline = (*env)->NewObjectArray(env, nelem(points), cls_Point, NULL);
1118 if (!jline || (*env)->ExceptionCheck(env)) return NULL;
1119
1120 for (i = 0; i < nelem(points); i++)
1121 {
1122 jpoint = (*env)->NewObject(env, cls_Point, mid_Point_init, points[i].x, points[i].y);
1123 if (!jpoint || (*env)->ExceptionCheck(env)) return NULL;
1124 (*env)->SetObjectArrayElement(env, jline, i, jpoint);
1125 if ((*env)->ExceptionCheck(env)) return NULL;
1126 (*env)->DeleteLocalRef(env, jpoint);
1127 }
1128
1129 return jline;
1130 }
1131
1132 JNIEXPORT void JNICALL
1133 FUN(PDFAnnotation_setLine)(JNIEnv *env, jobject self, jobject ja, jobject jb)
1134 {
1135 fz_context *ctx = get_context(env);
1136 pdf_annot *annot = from_PDFAnnotation(env, self);
1137 fz_point a, b;
1138
1139 if (!ctx || !annot) return;
1140 if (!ja || !jb) jni_throw_arg_void(env, "line points must not be null");
1141
1142 a.x = (*env)->GetFloatField(env, ja, fid_Point_x);
1143 a.y = (*env)->GetFloatField(env, ja, fid_Point_y);
1144 b.x = (*env)->GetFloatField(env, jb, fid_Point_x);
1145 b.y = (*env)->GetFloatField(env, jb, fid_Point_y);
1146
1147 fz_try(ctx)
1148 pdf_set_annot_line(ctx, annot, a, b);
1149 fz_catch(ctx)
1150 jni_rethrow_void(env, ctx);
1151 }
1152
1153 JNIEXPORT jboolean JNICALL
1154 FUN(PDFAnnotation_hasDefaultAppearance)(JNIEnv *env, jobject self)
1155 {
1156 fz_context *ctx = get_context(env);
1157 pdf_annot *annot = from_PDFAnnotation(env, self);
1158 jboolean has = JNI_FALSE;
1159
1160 fz_try(ctx)
1161 has = pdf_annot_has_default_appearance(ctx, annot);
1162 fz_catch(ctx)
1163 jni_rethrow(env, ctx);
1164
1165 return has;
1166 }
1167
1168 JNIEXPORT jobject JNICALL
1169 FUN(PDFAnnotation_getDefaultAppearance)(JNIEnv *env, jobject self)
1170 {
1171 fz_context *ctx = get_context(env);
1172 pdf_annot *annot = from_PDFAnnotation(env, self);
1173 jobject jda = NULL;
1174 jobject jfont = NULL;
1175 jobject jcolor = NULL;
1176 const char *font = NULL;
1177 float color[4] = { 0 };
1178 float size = 0;
1179 int n = 0;
1180
1181 if (!ctx || !annot) return NULL;
1182
1183 fz_try(ctx)
1184 pdf_annot_default_appearance(ctx, annot, &font, &size, &n, color);
1185 fz_catch(ctx)
1186 jni_rethrow(env, ctx);
1187
1188 jfont = (*env)->NewStringUTF(env, font);
1189 if (!jfont || (*env)->ExceptionCheck(env)) return NULL;
1190
1191 jcolor = (*env)->NewFloatArray(env, n);
1192 if (!jcolor || (*env)->ExceptionCheck(env)) return NULL;
1193 (*env)->SetFloatArrayRegion(env, jcolor, 0, n, color);
1194 if ((*env)->ExceptionCheck(env)) return NULL;
1195
1196 jda = (*env)->NewObject(env, cls_DefaultAppearance, mid_DefaultAppearance_init);
1197 if (!jda) return NULL;
1198
1199 (*env)->SetObjectField(env, jda, fid_DefaultAppearance_font, jfont);
1200 (*env)->SetFloatField(env, jda, fid_DefaultAppearance_size, size);
1201 (*env)->SetObjectField(env, jda, fid_DefaultAppearance_color, jcolor);
1202
1203 return jda;
1204 }
1205
1206 JNIEXPORT void JNICALL
1207 FUN(PDFAnnotation_setDefaultAppearance)(JNIEnv *env, jobject self, jstring jfont, jfloat size, jobject jcolor)
1208 {
1209 fz_context *ctx = get_context(env);
1210 pdf_annot *annot = from_PDFAnnotation(env, self);
1211 const char *font = NULL;
1212 float color[4] = { 0 };
1213 int n = 0;
1214
1215 if (!ctx || !annot) return;
1216 if (!jfont) jni_throw_arg_void(env, "font must not be null");
1217
1218 font = (*env)->GetStringUTFChars(env, jfont, NULL);
1219 if (!font) jni_throw_oom_void(env, "can not get characters in font name string");
1220
1221 if (!from_jfloatArray(env, color, nelem(color), jcolor)) return;
1222 if (jcolor)
1223 n = (*env)->GetArrayLength(env, jcolor);
1224
1225 fz_try(ctx)
1226 pdf_set_annot_default_appearance(ctx, annot, font, size, n, color);
1227 fz_always(ctx)
1228 (*env)->ReleaseStringUTFChars(env, jfont, font);
1229 fz_catch(ctx)
1230 jni_rethrow_void(env, ctx);
1231 }
1232
1233 JNIEXPORT void JNICALL
1234 FUN(PDFAnnotation_setNativeAppearance)(JNIEnv *env, jobject self, jstring jappearance, jstring jstate, jobject jctm, jobject jbbox, jobject jres, jobject jcontents)
1235 {
1236 fz_context *ctx = get_context(env);
1237 pdf_annot *annot = from_PDFAnnotation(env, self);
1238 pdf_obj *res = from_PDFObject(env, jres);
1239 fz_matrix ctm = from_Matrix(env, jctm);
1240 fz_rect bbox = from_Rect(env, jbbox);
1241 fz_buffer *contents = from_Buffer(env, jcontents);
1242 const char *appearance = NULL;
1243 const char *state = NULL;
1244
1245 if (!ctx || !annot) return;
1246
1247 if (jappearance)
1248 {
1249 appearance = (*env)->GetStringUTFChars(env, jappearance, NULL);
1250 if (!appearance)
1251 jni_throw_oom_void(env, "can not get characters in appearance string");
1252 }
1253 if (jstate)
1254 {
1255 state = (*env)->GetStringUTFChars(env, jstate, NULL);
1256 if (!state)
1257 {
1258 (*env)->ReleaseStringUTFChars(env, jappearance, appearance);
1259 jni_throw_oom_void(env, "can not get characters in state string");
1260 }
1261 }
1262
1263 fz_try(ctx)
1264 pdf_set_annot_appearance(ctx, annot, appearance, state, ctm, bbox, res, contents);
1265 fz_always(ctx)
1266 {
1267 if (jstate)
1268 (*env)->ReleaseStringUTFChars(env, jstate, state);
1269 if (jappearance)
1270 (*env)->ReleaseStringUTFChars(env, jappearance, appearance);
1271 }
1272 fz_catch(ctx)
1273 jni_rethrow_void(env, ctx);
1274 }
1275
1276 JNIEXPORT void JNICALL
1277 FUN(PDFAnnotation_setNativeAppearanceImage)(JNIEnv *env, jobject self, jobject jimage)
1278 {
1279 fz_context *ctx = get_context(env);
1280 pdf_annot *annot = from_PDFAnnotation(env, self);
1281 fz_image *image = from_Image(env, jimage);
1282
1283 if (!ctx || !annot || !image)
1284 return;
1285
1286 fz_try(ctx)
1287 pdf_set_annot_stamp_image(ctx, annot, image);
1288 fz_catch(ctx)
1289 jni_rethrow_void(env, ctx);
1290 }
1291
1292 JNIEXPORT void JNICALL
1293 FUN(PDFAnnotation_setNativeAppearanceDisplayList)(JNIEnv *env, jobject self, jstring jappearance, jstring jstate, jobject jctm, jobject jlist)
1294 {
1295 fz_context *ctx = get_context(env);
1296 pdf_annot *annot = from_PDFAnnotation(env, self);
1297 fz_matrix ctm = from_Matrix(env, jctm);
1298 fz_display_list *list = from_DisplayList(env, jlist);
1299 const char *appearance = NULL;
1300 const char *state = NULL;
1301
1302 if (!ctx || !annot) return;
1303
1304 if (jappearance)
1305 {
1306 appearance = (*env)->GetStringUTFChars(env, jappearance, NULL);
1307 if (!appearance)
1308 jni_throw_oom_void(env, "can not get characters in appearance string");
1309 }
1310 if (jstate)
1311 {
1312 state = (*env)->GetStringUTFChars(env, jstate, NULL);
1313 if (!state)
1314 {
1315 (*env)->ReleaseStringUTFChars(env, jappearance, appearance);
1316 jni_throw_oom_void(env, "can not get characters in state string");
1317 }
1318 }
1319
1320 fz_try(ctx)
1321 pdf_set_annot_appearance_from_display_list(ctx, annot, appearance, state, ctm, list);
1322 fz_always(ctx)
1323 {
1324 if (jstate)
1325 (*env)->ReleaseStringUTFChars(env, jstate, state);
1326 if (jappearance)
1327 (*env)->ReleaseStringUTFChars(env, jappearance, appearance);
1328 }
1329 fz_catch(ctx)
1330 jni_rethrow_void(env, ctx);
1331 }
1332
1333 JNIEXPORT jboolean JNICALL
1334 FUN(PDFAnnotation_hasInteriorColor)(JNIEnv *env, jobject self)
1335 {
1336 fz_context *ctx = get_context(env);
1337 pdf_annot *annot = from_PDFAnnotation(env, self);
1338 jboolean has = JNI_FALSE;
1339
1340 fz_try(ctx)
1341 has = pdf_annot_has_interior_color(ctx, annot);
1342 fz_catch(ctx)
1343 jni_rethrow(env, ctx);
1344
1345 return has;
1346 }
1347
1348 JNIEXPORT jboolean JNICALL
1349 FUN(PDFAnnotation_hasAuthor)(JNIEnv *env, jobject self)
1350 {
1351 fz_context *ctx = get_context(env);
1352 pdf_annot *annot = from_PDFAnnotation(env, self);
1353 jboolean has = JNI_FALSE;
1354
1355 fz_try(ctx)
1356 has = pdf_annot_has_author(ctx, annot);
1357 fz_catch(ctx)
1358 jni_rethrow(env, ctx);
1359
1360 return has;
1361 }
1362
1363 JNIEXPORT jboolean JNICALL
1364 FUN(PDFAnnotation_hasLineEndingStyles)(JNIEnv *env, jobject self)
1365 {
1366 fz_context *ctx = get_context(env);
1367 pdf_annot *annot = from_PDFAnnotation(env, self);
1368 jboolean has = JNI_FALSE;
1369
1370 fz_try(ctx)
1371 has = pdf_annot_has_line_ending_styles(ctx, annot);
1372 fz_catch(ctx)
1373 jni_rethrow(env, ctx);
1374
1375 return has;
1376 }
1377
1378 JNIEXPORT jboolean JNICALL
1379 FUN(PDFAnnotation_hasQuadPoints)(JNIEnv *env, jobject self)
1380 {
1381 fz_context *ctx = get_context(env);
1382 pdf_annot *annot = from_PDFAnnotation(env, self);
1383 jboolean has = JNI_FALSE;
1384
1385 fz_try(ctx)
1386 has = pdf_annot_has_quad_points(ctx, annot);
1387 fz_catch(ctx)
1388 jni_rethrow(env, ctx);
1389
1390 return has;
1391 }
1392
1393 JNIEXPORT jboolean JNICALL
1394 FUN(PDFAnnotation_hasVertices)(JNIEnv *env, jobject self)
1395 {
1396 fz_context *ctx = get_context(env);
1397 pdf_annot *annot = from_PDFAnnotation(env, self);
1398 jboolean has = JNI_FALSE;
1399
1400 fz_try(ctx)
1401 has = pdf_annot_has_vertices(ctx, annot);
1402 fz_catch(ctx)
1403 jni_rethrow(env, ctx);
1404
1405 return has;
1406 }
1407
1408 JNIEXPORT jboolean JNICALL
1409 FUN(PDFAnnotation_hasInkList)(JNIEnv *env, jobject self)
1410 {
1411 fz_context *ctx = get_context(env);
1412 pdf_annot *annot = from_PDFAnnotation(env, self);
1413 jboolean has = JNI_FALSE;
1414
1415 fz_try(ctx)
1416 has = pdf_annot_has_ink_list(ctx, annot);
1417 fz_catch(ctx)
1418 jni_rethrow(env, ctx);
1419
1420 return has;
1421 }
1422
1423 JNIEXPORT jboolean JNICALL
1424 FUN(PDFAnnotation_hasIcon)(JNIEnv *env, jobject self)
1425 {
1426 fz_context *ctx = get_context(env);
1427 pdf_annot *annot = from_PDFAnnotation(env, self);
1428 jboolean has = JNI_FALSE;
1429
1430 fz_try(ctx)
1431 has = pdf_annot_has_icon_name(ctx, annot);
1432 fz_catch(ctx)
1433 jni_rethrow(env, ctx);
1434
1435 return has;
1436 }
1437
1438 JNIEXPORT jboolean JNICALL
1439 FUN(PDFAnnotation_hasOpen)(JNIEnv *env, jobject self)
1440 {
1441 fz_context *ctx = get_context(env);
1442 pdf_annot *annot = from_PDFAnnotation(env, self);
1443 jboolean has = JNI_FALSE;
1444
1445 fz_try(ctx)
1446 has = pdf_annot_has_open(ctx, annot);
1447 fz_catch(ctx)
1448 jni_rethrow(env, ctx);
1449
1450 return has;
1451 }
1452
1453 JNIEXPORT jboolean JNICALL
1454 FUN(PDFAnnotation_hasLine)(JNIEnv *env, jobject self)
1455 {
1456 fz_context *ctx = get_context(env);
1457 pdf_annot *annot = from_PDFAnnotation(env, self);
1458 jboolean has = JNI_FALSE;
1459
1460 fz_try(ctx)
1461 has = pdf_annot_has_line(ctx, annot);
1462 fz_catch(ctx)
1463 jni_rethrow(env, ctx);
1464
1465 return has;
1466 }
1467
1468 JNIEXPORT void JNICALL
1469 FUN(PDFAnnotation_setFilespec)(JNIEnv *env, jobject self, jobject jfs)
1470 {
1471 fz_context *ctx = get_context(env);
1472 pdf_annot *annot = from_PDFAnnotation(env, self);
1473 pdf_obj *fs = from_PDFObject(env, jfs);
1474
1475 fz_try(ctx)
1476 pdf_set_annot_filespec(ctx, annot, fs);
1477 fz_catch(ctx)
1478 jni_rethrow_void(env, ctx);
1479 }
1480
1481 JNIEXPORT jobject JNICALL
1482 FUN(PDFAnnotation_getFilespec)(JNIEnv *env, jobject self)
1483 {
1484 fz_context *ctx = get_context(env);
1485 pdf_annot *annot = from_PDFAnnotation(env, self);
1486 pdf_obj *fs = NULL;
1487
1488 fz_try(ctx)
1489 fs = pdf_annot_filespec(ctx, annot);
1490 fz_catch(ctx)
1491 jni_rethrow(env, ctx);
1492
1493 return to_PDFObject_safe(ctx, env, fs);
1494 }
1495
1496 JNIEXPORT jboolean JNICALL
1497 FUN(PDFAnnotation_hasBorder)(JNIEnv *env, jobject self)
1498 {
1499 fz_context *ctx = get_context(env);
1500 pdf_annot *annot = from_PDFAnnotation(env, self);
1501 jboolean has = JNI_FALSE;
1502
1503 fz_try(ctx)
1504 has = pdf_annot_has_border(ctx, annot);
1505 fz_catch(ctx)
1506 jni_rethrow(env, ctx);
1507
1508 return has;
1509 }
1510
1511 JNIEXPORT jint JNICALL
1512 FUN(PDFAnnotation_getBorderStyle)(JNIEnv *env, jobject self)
1513 {
1514 fz_context *ctx = get_context(env);
1515 pdf_annot *annot = from_PDFAnnotation(env, self);
1516 enum pdf_border_style style = PDF_BORDER_STYLE_SOLID;
1517
1518 if (!ctx || !annot) return 0;
1519
1520 fz_try(ctx)
1521 style = pdf_annot_border_style(ctx, annot);
1522 fz_catch(ctx)
1523 jni_rethrow(env, ctx);
1524
1525 return style;
1526 }
1527
1528 JNIEXPORT void JNICALL
1529 FUN(PDFAnnotation_setBorderStyle)(JNIEnv *env, jobject self, jint style)
1530 {
1531 fz_context *ctx = get_context(env);
1532 pdf_annot *annot = from_PDFAnnotation(env, self);
1533
1534 fz_try(ctx)
1535 pdf_set_annot_border_style(ctx, annot, style);
1536 fz_catch(ctx)
1537 jni_rethrow_void(env, ctx);
1538 }
1539
1540 JNIEXPORT jfloat JNICALL
1541 FUN(PDFAnnotation_getBorderWidth)(JNIEnv *env, jobject self)
1542 {
1543 fz_context *ctx = get_context(env);
1544 pdf_annot *annot = from_PDFAnnotation(env, self);
1545 float width;
1546
1547 if (!ctx || !annot) return 0;
1548
1549 fz_try(ctx)
1550 width = pdf_annot_border_width(ctx, annot);
1551 fz_catch(ctx)
1552 jni_rethrow(env, ctx);
1553
1554 return width;
1555 }
1556
1557 JNIEXPORT void JNICALL
1558 FUN(PDFAnnotation_setBorderWidth)(JNIEnv *env, jobject self, jfloat width)
1559 {
1560 fz_context *ctx = get_context(env);
1561 pdf_annot *annot = from_PDFAnnotation(env, self);
1562
1563 fz_try(ctx)
1564 pdf_set_annot_border_width(ctx, annot, width);
1565 fz_catch(ctx)
1566 jni_rethrow_void(env, ctx);
1567 }
1568
1569 JNIEXPORT jint JNICALL
1570 FUN(PDFAnnotation_getBorderDashCount)(JNIEnv *env, jobject self)
1571 {
1572 fz_context *ctx = get_context(env);
1573 pdf_annot *annot = from_PDFAnnotation(env, self);
1574 int count;
1575
1576 if (!ctx || !annot) return 0;
1577
1578 fz_try(ctx)
1579 count = pdf_annot_border_dash_count(ctx, annot);
1580 fz_catch(ctx)
1581 jni_rethrow(env, ctx);
1582
1583 return count;
1584 }
1585
1586 JNIEXPORT jfloat JNICALL
1587 FUN(PDFAnnotation_getBorderDashItem)(JNIEnv *env, jobject self, jint i)
1588 {
1589 fz_context *ctx = get_context(env);
1590 pdf_annot *annot = from_PDFAnnotation(env, self);
1591 int length;
1592
1593 if (!ctx || !annot) return 0;
1594
1595 fz_try(ctx)
1596 length = pdf_annot_border_dash_item(ctx, annot, i);
1597 fz_catch(ctx)
1598 jni_rethrow(env, ctx);
1599
1600 return length;
1601 }
1602
1603 JNIEXPORT void JNICALL
1604 FUN(PDFAnnotation_clearBorderDash)(JNIEnv *env, jobject self)
1605 {
1606 fz_context *ctx = get_context(env);
1607 pdf_annot *annot = from_PDFAnnotation(env, self);
1608
1609 if (!ctx || !annot) return;
1610
1611 fz_try(ctx)
1612 pdf_clear_annot_border_dash(ctx, annot);
1613 fz_catch(ctx)
1614 jni_rethrow_void(env, ctx);
1615 }
1616
1617 JNIEXPORT void JNICALL
1618 FUN(PDFAnnotation_addBorderDashItem)(JNIEnv *env, jobject self, jfloat length)
1619 {
1620 fz_context *ctx = get_context(env);
1621 pdf_annot *annot = from_PDFAnnotation(env, self);
1622
1623 if (!ctx || !annot) return;
1624
1625 fz_try(ctx)
1626 pdf_add_annot_border_dash_item(ctx, annot, length);
1627 fz_catch(ctx)
1628 jni_rethrow_void(env, ctx);
1629 }
1630
1631 JNIEXPORT jboolean JNICALL
1632 FUN(PDFAnnotation_hasBorderEffect)(JNIEnv *env, jobject self)
1633 {
1634 fz_context *ctx = get_context(env);
1635 pdf_annot *annot = from_PDFAnnotation(env, self);
1636 jboolean has = JNI_FALSE;
1637
1638 fz_try(ctx)
1639 has = pdf_annot_has_border_effect(ctx, annot);
1640 fz_catch(ctx)
1641 jni_rethrow(env, ctx);
1642
1643 return has;
1644 }
1645
1646 JNIEXPORT jint JNICALL
1647 FUN(PDFAnnotation_getBorderEffect)(JNIEnv *env, jobject self)
1648 {
1649 fz_context *ctx = get_context(env);
1650 pdf_annot *annot = from_PDFAnnotation(env, self);
1651 jint effect = PDF_BORDER_EFFECT_NONE;
1652
1653 fz_try(ctx)
1654 effect = pdf_annot_border_effect(ctx, annot);
1655 fz_catch(ctx)
1656 jni_rethrow(env, ctx);
1657
1658 return effect;
1659 }
1660
1661 JNIEXPORT void JNICALL
1662 FUN(PDFAnnotation_setBorderEffect)(JNIEnv *env, jobject self, jint effect)
1663 {
1664 fz_context *ctx = get_context(env);
1665 pdf_annot *annot = from_PDFAnnotation(env, self);
1666
1667 fz_try(ctx)
1668 pdf_set_annot_border_effect(ctx, annot, effect);
1669 fz_catch(ctx)
1670 jni_rethrow_void(env, ctx);
1671 }
1672
1673 JNIEXPORT jfloat JNICALL
1674 FUN(PDFAnnotation_getBorderEffectIntensity)(JNIEnv *env, jobject self)
1675 {
1676 fz_context *ctx = get_context(env);
1677 pdf_annot *annot = from_PDFAnnotation(env, self);
1678 jfloat intensity = PDF_BORDER_EFFECT_NONE;
1679
1680 fz_try(ctx)
1681 intensity = pdf_annot_border_effect_intensity(ctx, annot);
1682 fz_catch(ctx)
1683 jni_rethrow(env, ctx);
1684
1685 return intensity;
1686 }
1687
1688 JNIEXPORT void JNICALL
1689 FUN(PDFAnnotation_setBorderEffectIntensity)(JNIEnv *env, jobject self, jfloat intensity)
1690 {
1691 fz_context *ctx = get_context(env);
1692 pdf_annot *annot = from_PDFAnnotation(env, self);
1693
1694 fz_try(ctx)
1695 pdf_set_annot_border_effect_intensity(ctx, annot, intensity);
1696 fz_catch(ctx)
1697 jni_rethrow_void(env, ctx);
1698 }
1699
1700 JNIEXPORT jboolean JNICALL
1701 FUN(PDFAnnotation_hasFilespec)(JNIEnv *env, jobject self)
1702 {
1703 fz_context *ctx = get_context(env);
1704 pdf_annot *annot = from_PDFAnnotation(env, self);
1705 jboolean has = JNI_FALSE;
1706
1707 fz_try(ctx)
1708 has = pdf_annot_has_filespec(ctx, annot);
1709 fz_catch(ctx)
1710 jni_rethrow(env, ctx);
1711
1712 return has;
1713 }
1714
1715 JNIEXPORT void JNICALL
1716 FUN(PDFAnnotation_setHiddenForEditing)(JNIEnv *env, jobject self, jboolean hidden)
1717 {
1718 fz_context *ctx = get_context(env);
1719 pdf_annot *annot = from_PDFAnnotation_safe(env, self);
1720
1721 if (!ctx || !annot) return;
1722
1723 fz_try(ctx)
1724 pdf_set_annot_hidden_for_editing(ctx, annot, hidden);
1725 fz_catch(ctx)
1726 jni_rethrow_void(env, ctx);
1727 }
1728
1729 JNIEXPORT jboolean JNICALL
1730 FUN(PDFAnnotation_getHiddenForEditing)(JNIEnv *env, jobject self)
1731 {
1732 fz_context *ctx = get_context(env);
1733 pdf_annot *annot = from_PDFAnnotation_safe(env, self);
1734 jboolean hidden = JNI_FALSE;
1735
1736 if (!ctx || !annot) return JNI_FALSE;
1737
1738 fz_try(ctx)
1739 hidden = pdf_annot_hidden_for_editing(ctx, annot);
1740 fz_catch(ctx)
1741 jni_rethrow(env, ctx);
1742
1743 return hidden;
1744 }
1745
1746 JNIEXPORT jboolean JNICALL
1747 FUN(PDFAnnotation_applyRedaction)(JNIEnv *env, jobject self, jboolean blackBoxes, jint imageMethod, jint lineArt, jint text)
1748 {
1749 fz_context *ctx = get_context(env);
1750 pdf_annot *annot = from_PDFAnnotation_safe(env, self);
1751 pdf_redact_options opts = { blackBoxes, imageMethod, lineArt, text };
1752 jboolean redacted = JNI_FALSE;
1753
1754 if (!ctx || !annot) return JNI_FALSE;
1755
1756 fz_try(ctx)
1757 redacted = pdf_apply_redaction(ctx, annot, &opts);
1758 fz_catch(ctx)
1759 jni_rethrow(env, ctx);
1760
1761 return redacted;
1762 }
1763
1764 JNIEXPORT jboolean JNICALL
1765 FUN(PDFAnnotation_hasRect)(JNIEnv *env, jobject self)
1766 {
1767 fz_context *ctx = get_context(env);
1768 pdf_annot *annot = from_PDFAnnotation(env, self);
1769 jboolean has = JNI_FALSE;
1770
1771 fz_try(ctx)
1772 has = pdf_annot_has_rect(ctx, annot);
1773 fz_catch(ctx)
1774 jni_rethrow(env, ctx);
1775
1776 return has;
1777 }
1778
1779 JNIEXPORT jboolean JNICALL
1780 FUN(PDFAnnotation_hasIntent)(JNIEnv *env, jobject self)
1781 {
1782 fz_context *ctx = get_context(env);
1783 pdf_annot *annot = from_PDFAnnotation(env, self);
1784 jboolean has = JNI_FALSE;
1785
1786 fz_try(ctx)
1787 has = pdf_annot_has_intent(ctx, annot);
1788 fz_catch(ctx)
1789 jni_rethrow(env, ctx);
1790
1791 return has;
1792 }
1793
1794 JNIEXPORT jint JNICALL
1795 FUN(PDFAnnotation_getIntent)(JNIEnv *env, jobject self)
1796 {
1797 fz_context *ctx = get_context(env);
1798 pdf_annot *annot = from_PDFAnnotation(env, self);
1799 enum pdf_intent intent = PDF_ANNOT_IT_DEFAULT;
1800
1801 if (!ctx || !annot) return PDF_ANNOT_IT_DEFAULT;
1802
1803 fz_try(ctx)
1804 intent = pdf_annot_intent(ctx, annot);
1805 fz_catch(ctx)
1806 jni_rethrow(env, ctx);
1807
1808 return intent;
1809 }
1810
1811 JNIEXPORT void JNICALL
1812 FUN(PDFAnnotation_setIntent)(JNIEnv *env, jobject self, jint intent)
1813 {
1814 fz_context *ctx = get_context(env);
1815 pdf_annot *annot = from_PDFAnnotation(env, self);
1816
1817 if (!ctx || !annot) return;
1818
1819 fz_try(ctx)
1820 pdf_set_annot_intent(ctx, annot, intent);
1821 fz_catch(ctx)
1822 jni_rethrow_void(env, ctx);
1823 }
1824
1825 JNIEXPORT jboolean JNICALL
1826 FUN(PDFAnnotation_hasPopup)(JNIEnv *env, jobject self)
1827 {
1828 fz_context *ctx = get_context(env);
1829 pdf_annot *annot = from_PDFAnnotation(env, self);
1830 jboolean has = JNI_FALSE;
1831
1832 fz_try(ctx)
1833 has = pdf_annot_has_popup(ctx, annot);
1834 fz_catch(ctx)
1835 jni_rethrow(env, ctx);
1836
1837 return has;
1838 }
1839
1840 JNIEXPORT jobject JNICALL
1841 FUN(PDFAnnotation_getPopup)(JNIEnv *env, jobject self)
1842 {
1843 fz_context *ctx = get_context(env);
1844 pdf_annot *annot = from_PDFAnnotation(env, self);
1845 fz_rect rect;
1846
1847 if (!ctx || !annot) return JNI_FALSE;
1848
1849 fz_try(ctx)
1850 rect = pdf_annot_popup(ctx, annot);
1851 fz_catch(ctx)
1852 jni_rethrow(env, ctx);
1853
1854 return to_Rect_safe(ctx, env, rect);
1855 }
1856
1857 JNIEXPORT void JNICALL
1858 FUN(PDFAnnotation_setPopup)(JNIEnv *env, jobject self, jobject jrect)
1859 {
1860 fz_context *ctx = get_context(env);
1861 pdf_annot *annot = from_PDFAnnotation(env, self);
1862 fz_rect rect = from_Rect(env, jrect);
1863
1864 if (!ctx || !annot) return;
1865
1866 fz_try(ctx)
1867 pdf_set_annot_popup(ctx, annot, rect);
1868 fz_catch(ctx)
1869 jni_rethrow_void(env, ctx);
1870 }
1871
1872 JNIEXPORT jfloat JNICALL
1873 FUN(PDFAnnotation_getLineLeader)(JNIEnv *env, jobject self)
1874 {
1875 fz_context *ctx = get_context(env);
1876 pdf_annot *annot = from_PDFAnnotation(env, self);
1877 jfloat v;
1878
1879 if (!ctx || !annot) return 0;
1880
1881 fz_try(ctx)
1882 v = pdf_annot_line_leader(ctx, annot);
1883 fz_catch(ctx)
1884 jni_rethrow(env, ctx);
1885
1886 return v;
1887 }
1888
1889 JNIEXPORT void JNICALL
1890 FUN(PDFAnnotation_setLineLeader)(JNIEnv *env, jobject self, jfloat length)
1891 {
1892 fz_context *ctx = get_context(env);
1893 pdf_annot *annot = from_PDFAnnotation(env, self);
1894
1895 if (!ctx || !annot) return;
1896
1897 fz_try(ctx)
1898 pdf_set_annot_line_leader(ctx, annot, length);
1899 fz_catch(ctx)
1900 jni_rethrow_void(env, ctx);
1901 }
1902
1903
1904 JNIEXPORT jfloat JNICALL
1905 FUN(PDFAnnotation_getLineLeaderExtension)(JNIEnv *env, jobject self)
1906 {
1907 fz_context *ctx = get_context(env);
1908 pdf_annot *annot = from_PDFAnnotation(env, self);
1909 jfloat v;
1910
1911 if (!ctx || !annot) return 0;
1912
1913 fz_try(ctx)
1914 v = pdf_annot_line_leader_extension(ctx, annot);
1915 fz_catch(ctx)
1916 jni_rethrow(env, ctx);
1917
1918 return v;
1919 }
1920
1921 JNIEXPORT void JNICALL
1922 FUN(PDFAnnotation_setLineLeaderExtension)(JNIEnv *env, jobject self, jfloat extension)
1923 {
1924 fz_context *ctx = get_context(env);
1925 pdf_annot *annot = from_PDFAnnotation(env, self);
1926
1927 if (!ctx || !annot) return;
1928
1929 fz_try(ctx)
1930 pdf_set_annot_line_leader_extension(ctx, annot, extension);
1931 fz_catch(ctx)
1932 jni_rethrow_void(env, ctx);
1933 }
1934
1935 JNIEXPORT jfloat JNICALL
1936 FUN(PDFAnnotation_getLineLeaderOffset)(JNIEnv *env, jobject self)
1937 {
1938 fz_context *ctx = get_context(env);
1939 pdf_annot *annot = from_PDFAnnotation(env, self);
1940 jfloat v;
1941
1942 if (!ctx || !annot) return 0;
1943
1944 fz_try(ctx)
1945 v = pdf_annot_line_leader_offset(ctx, annot);
1946 fz_catch(ctx)
1947 jni_rethrow(env, ctx);
1948
1949 return v;
1950 }
1951
1952 JNIEXPORT void JNICALL
1953 FUN(PDFAnnotation_setLineLeaderOffset)(JNIEnv *env, jobject self, jfloat offset)
1954 {
1955 fz_context *ctx = get_context(env);
1956 pdf_annot *annot = from_PDFAnnotation(env, self);
1957
1958 if (!ctx || !annot) return;
1959
1960 fz_try(ctx)
1961 pdf_set_annot_line_leader_offset(ctx, annot, offset);
1962 fz_catch(ctx)
1963 jni_rethrow_void(env, ctx);
1964 }
1965
1966 JNIEXPORT jboolean JNICALL
1967 FUN(PDFAnnotation_getLineCaption)(JNIEnv *env, jobject self)
1968 {
1969 fz_context *ctx = get_context(env);
1970 pdf_annot *annot = from_PDFAnnotation(env, self);
1971 jboolean v;
1972
1973 if (!ctx || !annot) return JNI_FALSE;
1974
1975 fz_try(ctx)
1976 v = pdf_annot_line_caption(ctx, annot);
1977 fz_catch(ctx)
1978 jni_rethrow(env, ctx);
1979
1980 return v;
1981 }
1982
1983 JNIEXPORT void JNICALL
1984 FUN(PDFAnnotation_setLineCaption)(JNIEnv *env, jobject self, jboolean caption)
1985 {
1986 fz_context *ctx = get_context(env);
1987 pdf_annot *annot = from_PDFAnnotation(env, self);
1988
1989 if (!ctx || !annot) return;
1990
1991 fz_try(ctx)
1992 pdf_set_annot_line_caption(ctx, annot, caption);
1993 fz_catch(ctx)
1994 jni_rethrow_void(env, ctx);
1995 }
1996
1997 JNIEXPORT jobject JNICALL
1998 FUN(PDFAnnotation_getLineCaptionOffset)(JNIEnv *env, jobject self)
1999 {
2000 fz_context *ctx = get_context(env);
2001 pdf_annot *annot = from_PDFAnnotation(env, self);
2002 fz_point offset;;
2003
2004 if (!ctx || !annot) return NULL;
2005
2006 fz_try(ctx)
2007 offset = pdf_annot_line_caption_offset(ctx, annot);
2008 fz_catch(ctx)
2009 jni_rethrow(env, ctx);
2010
2011 return to_Point_safe(ctx, env, offset);
2012 }
2013
2014 JNIEXPORT void JNICALL
2015 FUN(PDFAnnotation_setLeaderLines)(JNIEnv *env, jobject self, jobject joffset)
2016 {
2017 fz_context *ctx = get_context(env);
2018 pdf_annot *annot = from_PDFAnnotation(env, self);
2019 fz_point offset = from_Point(env, joffset);
2020
2021 if (!ctx || !annot) return;
2022
2023 fz_try(ctx)
2024 pdf_set_annot_line_caption_offset(ctx, annot, offset);
2025 fz_catch(ctx)
2026 jni_rethrow_void(env, ctx);
2027 }
2028
2029 JNIEXPORT void JNICALL
2030 FUN(PDFAnnotation_requestSynthesis)(JNIEnv *env, jobject self)
2031 {
2032 fz_context *ctx = get_context(env);
2033 pdf_annot *annot = from_PDFAnnotation(env, self);
2034
2035 if (!ctx || !annot) return;
2036
2037 fz_try(ctx)
2038 pdf_annot_request_synthesis(ctx, annot);
2039 fz_catch(ctx)
2040 jni_rethrow_void(env, ctx);
2041 }
2042
2043 JNIEXPORT void JNICALL
2044 FUN(PDFAnnotation_requestResynthesis)(JNIEnv *env, jobject self)
2045 {
2046 fz_context *ctx = get_context(env);
2047 pdf_annot *annot = from_PDFAnnotation(env, self);
2048
2049 if (!ctx || !annot) return;
2050
2051 fz_try(ctx)
2052 pdf_annot_request_resynthesis(ctx, annot);
2053 fz_catch(ctx)
2054 jni_rethrow_void(env, ctx);
2055 }
2056
2057 JNIEXPORT jboolean JNICALL
2058 FUN(PDFAnnotation_getHot)(JNIEnv *env, jobject self)
2059 {
2060 fz_context *ctx = get_context(env);
2061 pdf_annot *annot = from_PDFAnnotation(env, self);
2062 jboolean hot = JNI_FALSE;
2063
2064 if (!ctx || !annot) return JNI_FALSE;
2065
2066 fz_try(ctx)
2067 hot = pdf_annot_hot(ctx, annot);
2068 fz_catch(ctx)
2069 jni_rethrow(env, ctx);
2070
2071 return hot;
2072 }
2073
2074 JNIEXPORT void JNICALL
2075 FUN(PDFAnnotation_setHot)(JNIEnv *env, jobject self, jboolean hot)
2076 {
2077 fz_context *ctx = get_context(env);
2078 pdf_annot *annot = from_PDFAnnotation(env, self);
2079
2080 if (!ctx || !annot) return;
2081
2082 fz_try(ctx)
2083 pdf_set_annot_hot(ctx, annot, hot);
2084 fz_catch(ctx)
2085 jni_rethrow_void(env, ctx);
2086 }
2087
2088 JNIEXPORT void JNICALL
2089 FUN(PDFAnnotation_process)(JNIEnv *env, jobject self, jobject jproc)
2090 {
2091 fz_context *ctx = get_context(env);
2092 pdf_annot *annot = from_PDFAnnotation(env, self);
2093 pdf_processor *proc = make_pdf_processor(env, ctx, jproc);
2094
2095 if (!ctx || !annot) return;
2096 if (!proc) jni_throw_arg_void(env, "processor must not be null");
2097
2098 fz_try(ctx)
2099 {
2100 pdf_processor_push_resources(ctx, proc, pdf_page_resources(ctx, pdf_annot_page(ctx, annot)));
2101 pdf_process_annot(ctx, proc, annot, NULL);
2102 pdf_close_processor(ctx, proc);
2103 }
2104 fz_always(ctx)
2105 {
2106 pdf_processor_pop_resources(ctx, proc);
2107 pdf_drop_processor(ctx, proc);
2108 }
2109 fz_catch(ctx)
2110 jni_rethrow_void(env, ctx);
2111 }
2112
2113 JNIEXPORT jboolean JNICALL
2114 FUN(PDFAnnotation_hasRichContents)(JNIEnv *env, jobject self)
2115 {
2116 fz_context *ctx = get_context(env);
2117 pdf_annot *annot = from_PDFAnnotation(env, self);
2118 jboolean has = JNI_FALSE;
2119
2120 if (!ctx || !annot) return JNI_FALSE;
2121
2122 fz_try(ctx)
2123 has = pdf_annot_has_rich_contents(ctx, annot);
2124 fz_catch(ctx)
2125 jni_rethrow(env, ctx);
2126
2127 return has;
2128 }
2129
2130 JNIEXPORT jstring JNICALL
2131 FUN(PDFAnnotation_getRichContents)(JNIEnv *env, jobject self)
2132 {
2133 fz_context *ctx = get_context(env);
2134 pdf_annot *annot = from_PDFAnnotation(env, self);
2135 const char *contents = NULL;
2136
2137 if (!ctx || !annot) return NULL;
2138
2139 fz_try(ctx)
2140 contents = pdf_annot_rich_contents(ctx, annot);
2141 fz_catch(ctx)
2142 jni_rethrow(env, ctx);
2143
2144 return to_String_safe(ctx, env, contents);
2145 }
2146
2147 JNIEXPORT void JNICALL
2148 FUN(PDFAnnotation_setRichContents)(JNIEnv *env, jobject self, jstring jplaintext, jstring jrichtext)
2149 {
2150 fz_context *ctx = get_context(env);
2151 pdf_annot *annot = from_PDFAnnotation(env, self);
2152 const char *plaintext = NULL;
2153 const char *richtext = NULL;
2154
2155 if (!ctx || !annot) return;
2156
2157 if (jplaintext)
2158 {
2159 plaintext = (*env)->GetStringUTFChars(env, jplaintext, NULL);
2160 if (!plaintext) return;
2161 }
2162 if (jrichtext)
2163 {
2164 richtext = (*env)->GetStringUTFChars(env, jrichtext, NULL);
2165 if (!richtext)
2166 {
2167 if (plaintext)
2168 (*env)->ReleaseStringUTFChars(env, jplaintext, plaintext);
2169 return;
2170 }
2171 }
2172
2173 fz_try(ctx)
2174 pdf_set_annot_rich_contents(ctx, annot, plaintext, richtext);
2175 fz_always(ctx)
2176 {
2177 if (richtext)
2178 (*env)->ReleaseStringUTFChars(env, jrichtext, richtext);
2179 if (plaintext)
2180 (*env)->ReleaseStringUTFChars(env, jplaintext, plaintext);
2181 }
2182 fz_catch(ctx)
2183 jni_rethrow_void(env, ctx);
2184 }
2185
2186 JNIEXPORT jboolean JNICALL
2187 FUN(PDFAnnotation_hasRichDefaults)(JNIEnv *env, jobject self)
2188 {
2189 fz_context *ctx = get_context(env);
2190 pdf_annot *annot = from_PDFAnnotation(env, self);
2191 jboolean has = JNI_FALSE;
2192
2193 if (!ctx || !annot) return JNI_FALSE;
2194
2195 fz_try(ctx)
2196 has = pdf_annot_has_rich_defaults(ctx, annot);
2197 fz_catch(ctx)
2198 jni_rethrow(env, ctx);
2199
2200 return has;
2201 }
2202
2203 JNIEXPORT jstring JNICALL
2204 FUN(PDFAnnotation_getRichDefaults)(JNIEnv *env, jobject self)
2205 {
2206 fz_context *ctx = get_context(env);
2207 pdf_annot *annot = from_PDFAnnotation(env, self);
2208 const char *defaults = NULL;
2209
2210 if (!ctx || !annot) return NULL;
2211
2212 fz_try(ctx)
2213 defaults = pdf_annot_rich_defaults(ctx, annot);
2214 fz_catch(ctx)
2215 jni_rethrow(env, ctx);
2216
2217 return to_String_safe(ctx, env, defaults);
2218 }
2219
2220 JNIEXPORT void JNICALL
2221 FUN(PDFAnnotation_setRichDefault)(JNIEnv *env, jobject self, jstring jstyle)
2222 {
2223 fz_context *ctx = get_context(env);
2224 pdf_annot *annot = from_PDFAnnotation(env, self);
2225 const char *style = NULL;
2226
2227 if (!ctx || !annot) return;
2228
2229 if (jstyle)
2230 {
2231 style = (*env)->GetStringUTFChars(env, jstyle, NULL);
2232 if (!style) return;
2233 }
2234
2235 fz_try(ctx)
2236 pdf_set_annot_rich_defaults(ctx, annot, style);
2237 fz_always(ctx)
2238 if (style)
2239 (*env)->ReleaseStringUTFChars(env, jstyle, style);
2240 fz_catch(ctx)
2241 jni_rethrow_void(env, ctx);
2242 }
2243
2244 JNIEXPORT jobject JNICALL
2245 FUN(PDFAnnotation_getStampImageObject)(JNIEnv *env, jobject self)
2246 {
2247 fz_context *ctx = get_context(env);
2248 pdf_annot *annot = from_PDFAnnotation(env, self);
2249 pdf_obj *obj = NULL;
2250
2251 if (!ctx || !annot) return NULL;
2252
2253 fz_try(ctx)
2254 obj = pdf_annot_stamp_image_obj(ctx, annot);
2255 fz_catch(ctx)
2256 jni_rethrow(env, ctx);
2257
2258 return to_PDFObject_safe(ctx, env, obj);
2259 }
2260
2261 JNIEXPORT void JNICALL
2262 FUN(PDFAnnotation_setStampImageObject)(JNIEnv *env, jobject self, jobject jobj)
2263 {
2264 fz_context *ctx = get_context(env);
2265 pdf_annot *annot = from_PDFAnnotation(env, self);
2266 pdf_obj *obj = from_PDFObject(env, jobj);
2267
2268 if (!ctx || !annot) return;
2269
2270 fz_try(ctx)
2271 pdf_set_annot_stamp_image_obj(ctx, annot, obj);
2272 fz_catch(ctx)
2273 jni_rethrow_void(env, ctx);
2274 }
2275
2276 JNIEXPORT void JNICALL
2277 FUN(PDFAnnotation_setStampImage)(JNIEnv *env, jobject self, jobject jimg)
2278 {
2279 fz_context *ctx = get_context(env);
2280 pdf_annot *annot = from_PDFAnnotation(env, self);
2281 fz_image *img = from_Image(env, jimg);
2282
2283 if (!ctx || !annot) return;
2284
2285 fz_try(ctx)
2286 pdf_set_annot_stamp_image(ctx, annot, img);
2287 fz_catch(ctx)
2288 jni_rethrow_void(env, ctx);
2289 }