| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289 |
- // Copyright (C) 2004-2025 Artifex Software, Inc.
- //
- // This file is part of MuPDF.
- //
- // MuPDF is free software: you can redistribute it and/or modify it under the
- // terms of the GNU Affero General Public License as published by the Free
- // Software Foundation, either version 3 of the License, or (at your option)
- // any later version.
- //
- // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
- // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
- // details.
- //
- // You should have received a copy of the GNU Affero General Public License
- // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
- //
- // Alternative licensing terms are available from the licensor.
- // For commercial licensing, see <https://www.artifex.com/> or contact
- // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
- // CA 94129, USA, for further information.
- /* Annotation interface */
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_finalize)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation_safe(env, self);
- if (!ctx || !annot) return;
- (*env)->SetLongField(env, self, fid_PDFAnnotation_pointer, 0);
- pdf_drop_annot(ctx, annot);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_run)(JNIEnv *env, jobject self, jobject jdev, jobject jctm, jobject jcookie)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_device *dev = from_Device(env, jdev);
- fz_matrix ctm = from_Matrix(env, jctm);
- fz_cookie *cookie= from_Cookie(env, jcookie);
- NativeDeviceInfo *info;
- int err;
- if (!ctx || !annot) return;
- if (!dev) jni_throw_arg_void(env, "device must not be null");
- info = lockNativeDevice(env, jdev, &err);
- if (err)
- return;
- fz_try(ctx)
- pdf_run_annot(ctx, annot, dev, ctm, cookie);
- fz_always(ctx)
- unlockNativeDevice(env, info);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_toPixmap)(JNIEnv *env, jobject self, jobject jctm, jobject jcs, jboolean alpha)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_matrix ctm = from_Matrix(env, jctm);
- fz_colorspace *cs = from_ColorSpace(env, jcs);
- fz_pixmap *pixmap = NULL;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- pixmap = pdf_new_pixmap_from_annot(ctx, annot, ctm, cs, NULL, alpha);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return to_Pixmap_safe_own(ctx, env, pixmap);
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_getBounds)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_rect rect;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- rect = pdf_bound_annot(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return to_Rect_safe(ctx, env, rect);
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_toDisplayList)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_display_list *list = NULL;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- list = pdf_new_display_list_from_annot(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return to_DisplayList_safe_own(ctx, env, list);
- }
- JNIEXPORT jint JNICALL
- FUN(PDFAnnotation_getType)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jint type = 0;
- if (!ctx || !annot) return 0;
- fz_try(ctx)
- type = pdf_annot_type(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return type;
- }
- JNIEXPORT jint JNICALL
- FUN(PDFAnnotation_getFlags)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jint flags = 0;
- if (!ctx || !annot) return 0;
- fz_try(ctx)
- flags = pdf_annot_flags(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return flags;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setFlags)(JNIEnv *env, jobject self, jint flags)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_flags(ctx, annot, flags);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jstring JNICALL
- FUN(PDFAnnotation_getContents)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- const char *contents = NULL;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- contents = pdf_annot_contents(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return (*env)->NewStringUTF(env, contents);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setContents)(JNIEnv *env, jobject self, jstring jcontents)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- const char *contents = "";
- if (!ctx || !annot) return;
- if (jcontents)
- {
- contents = (*env)->GetStringUTFChars(env, jcontents, NULL);
- if (!contents) return;
- }
- fz_try(ctx)
- pdf_set_annot_contents(ctx, annot, contents);
- fz_always(ctx)
- if (contents)
- (*env)->ReleaseStringUTFChars(env, jcontents, contents);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jstring JNICALL
- FUN(PDFAnnotation_getAuthor)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- const char *author = NULL;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- author = pdf_annot_author(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return (*env)->NewStringUTF(env, author);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setAuthor)(JNIEnv *env, jobject self, jstring jauthor)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- const char *author = "";
- if (!ctx || !annot) return;
- if (jauthor)
- {
- author = (*env)->GetStringUTFChars(env, jauthor, NULL);
- if (!author) return;
- }
- fz_try(ctx)
- pdf_set_annot_author(ctx, annot, author);
- fz_always(ctx)
- if (author)
- (*env)->ReleaseStringUTFChars(env, jauthor, author);
- fz_catch(ctx)
- jni_rethrow_void(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 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_void(env, ctx);
- }
- JNIEXPORT jlong JNICALL
- FUN(PDFAnnotation_getCreationDateNative)(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_creation_date(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return t * 1000;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setCreationDate)(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_creation_date(ctx, annot, time / 1000);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_getRect)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_rect rect;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- rect = pdf_annot_rect(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return to_Rect_safe(ctx, env, rect);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setRect)(JNIEnv *env, jobject self, jobject jrect)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_rect rect = from_Rect(env, jrect);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_rect(ctx, annot, rect);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_getColor)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- int n;
- float color[4];
- jfloatArray arr;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- pdf_annot_color(ctx, annot, &n, color);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- arr = (*env)->NewFloatArray(env, n);
- if (!arr || (*env)->ExceptionCheck(env)) return NULL;
- (*env)->SetFloatArrayRegion(env, arr, 0, n, &color[0]);
- if ((*env)->ExceptionCheck(env)) return NULL;
- return arr;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setColor)(JNIEnv *env, jobject self, jobject jcolor)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- float color[4];
- int n = 0;
- if (!ctx || !annot) return;
- if (!from_jfloatArray(env, color, nelem(color), jcolor)) return;
- if (jcolor)
- n = (*env)->GetArrayLength(env, jcolor);
- fz_try(ctx)
- pdf_set_annot_color(ctx, annot, n, color);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_getInteriorColor)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- int n;
- float color[4];
- jfloatArray arr;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- pdf_annot_interior_color(ctx, annot, &n, color);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- arr = (*env)->NewFloatArray(env, n);
- if (!arr || (*env)->ExceptionCheck(env)) return NULL;
- (*env)->SetFloatArrayRegion(env, arr, 0, n, &color[0]);
- if ((*env)->ExceptionCheck(env)) return NULL;
- return arr;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setInteriorColor)(JNIEnv *env, jobject self, jobject jcolor)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- float color[4];
- int n = 0;
- if (!ctx || !annot) return;
- if (!from_jfloatArray(env, color, nelem(color), jcolor)) return;
- if (jcolor)
- n = (*env)->GetArrayLength(env, jcolor);
- fz_try(ctx)
- pdf_set_annot_interior_color(ctx, annot, n, color);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jfloat JNICALL
- FUN(PDFAnnotation_getOpacity)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jfloat opacity;
- if (!ctx || !annot) return 0.0f;
- fz_try(ctx)
- opacity = pdf_annot_opacity(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return opacity;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setOpacity)(JNIEnv *env, jobject self, jfloat opacity)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_opacity(ctx, annot, opacity);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jint JNICALL
- FUN(PDFAnnotation_getQuadPointCount)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- int n = 0;
- fz_try(ctx)
- n = pdf_annot_quad_point_count(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return n;
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_getQuadPoint)(JNIEnv *env, jobject self, jint i)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_quad q;
- fz_try(ctx)
- q = pdf_annot_quad_point(ctx, annot, i);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return to_Quad_safe(ctx, env, q);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_clearQuadPoints)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_try(ctx)
- pdf_clear_annot_quad_points(ctx, annot);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_addQuadPoint)(JNIEnv *env, jobject self, jobject qobj)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_quad q = from_Quad(env, qobj);
- fz_try(ctx)
- pdf_add_annot_quad_point(ctx, annot, q);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jint JNICALL
- FUN(PDFAnnotation_getVertexCount)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- int n = 0;
- fz_try(ctx)
- n = pdf_annot_vertex_count(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return n;
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_getVertex)(JNIEnv *env, jobject self, jint i)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_point v;
- fz_try(ctx)
- v = pdf_annot_vertex(ctx, annot, i);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return to_Point_safe(ctx, env, v);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_clearVertices)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_try(ctx)
- pdf_clear_annot_vertices(ctx, annot);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_addVertex)(JNIEnv *env, jobject self, float x, float y)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_try(ctx)
- pdf_add_annot_vertex(ctx, annot, fz_make_point(x, y));
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jint JNICALL
- FUN(PDFAnnotation_getInkListCount)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- int n = 0;
- fz_try(ctx)
- n = pdf_annot_ink_list_count(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return n;
- }
- JNIEXPORT jint JNICALL
- FUN(PDFAnnotation_getInkListStrokeCount)(JNIEnv *env, jobject self, jint i)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- int n = 0;
- fz_try(ctx)
- n = pdf_annot_ink_list_stroke_count(ctx, annot, i);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return n;
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_getInkListStrokeVertex)(JNIEnv *env, jobject self, jint i, jint k)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_point v;
- fz_try(ctx)
- v = pdf_annot_ink_list_stroke_vertex(ctx, annot, i, k);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return to_Point_safe(ctx, env, v);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_clearInkList)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_try(ctx)
- pdf_clear_annot_ink_list(ctx, annot);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_addInkListStroke)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_try(ctx)
- pdf_add_annot_ink_list_stroke(ctx, annot);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_addInkListStrokeVertex)(JNIEnv *env, jobject self, float x, float y)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_try(ctx)
- pdf_add_annot_ink_list_stroke_vertex(ctx, annot, fz_make_point(x, y));
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasCallout)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_callout(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jint JNICALL
- FUN(PDFAnnotation_getCalloutStyle)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- enum pdf_line_ending s = 0;
- fz_try(ctx)
- s = pdf_annot_callout_style(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return s;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setCalloutStyle)(JNIEnv *env, jobject self, jint s)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_try(ctx)
- pdf_set_annot_callout_style(ctx, annot, s);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_getCalloutPoint)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_point p;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- p = pdf_annot_callout_point(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return (*env)->NewObject(env, cls_Point, mid_Point_init, p.x, p.y);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setCalloutPoint)(JNIEnv *env, jobject self, jobject jp)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_point p;
- if (!ctx || !annot) return;
- if (!jp) jni_throw_arg_void(env, "point must not be null");
- p.x = (*env)->GetFloatField(env, jp, fid_Point_x);
- p.y = (*env)->GetFloatField(env, jp, fid_Point_y);
- fz_try(ctx)
- pdf_set_annot_callout_point(ctx, annot, p);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_getCalloutLine)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_point points[3] = { 0 };
- jobject jline = NULL;
- jobject jpoint = NULL;
- int i, n;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- pdf_annot_callout_line(ctx, annot, points, &n);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- if (n == 0)
- return NULL;
- jline = (*env)->NewObjectArray(env, n, cls_Point, NULL);
- if (!jline || (*env)->ExceptionCheck(env)) return NULL;
- for (i = 0; i < n; i++)
- {
- jpoint = (*env)->NewObject(env, cls_Point, mid_Point_init, points[i].x, points[i].y);
- if (!jpoint || (*env)->ExceptionCheck(env)) return NULL;
- (*env)->SetObjectArrayElement(env, jline, i, jpoint);
- if ((*env)->ExceptionCheck(env)) return NULL;
- (*env)->DeleteLocalRef(env, jpoint);
- }
- return jline;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setCalloutLineNative)(JNIEnv *env, jobject self, jint n, jobject ja, jobject jb, jobject jc)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_point line[3];
- if (!ctx || !annot) return;
- if (n >= 2 && !ja) jni_throw_arg_void(env, "points must not be null");
- if (n >= 2 && !jb) jni_throw_arg_void(env, "points must not be null");
- if (n >= 3 && !jc) jni_throw_arg_void(env, "points must not be null");
- if (n >= 2) {
- line[0].x = (*env)->GetFloatField(env, ja, fid_Point_x);
- line[0].y = (*env)->GetFloatField(env, ja, fid_Point_y);
- line[1].x = (*env)->GetFloatField(env, jb, fid_Point_x);
- line[1].y = (*env)->GetFloatField(env, jb, fid_Point_y);
- }
- if (n >= 3) {
- line[2].x = (*env)->GetFloatField(env, jc, fid_Point_x);
- line[2].y = (*env)->GetFloatField(env, jc, fid_Point_y);
- }
- fz_try(ctx)
- {
- if (n == 0 || n == 2 || n == 3)
- pdf_set_annot_callout_line(ctx, annot, line, n);
- }
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_eventEnter)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- {
- pdf_annot_event_enter(ctx, annot);
- pdf_set_annot_hot(ctx, annot, 1);
- }
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_eventExit)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- {
- pdf_annot_event_exit(ctx, annot);
- pdf_set_annot_hot(ctx, annot, 0);
- }
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_eventDown)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- {
- pdf_annot_event_down(ctx, annot);
- pdf_set_annot_active(ctx, annot, 1);
- }
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_eventUp)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- {
- if (pdf_annot_hot(ctx, annot) && pdf_annot_active(ctx, annot))
- pdf_annot_event_up(ctx, annot);
- pdf_set_annot_active(ctx, annot, 0);
- }
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_eventFocus)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_annot_event_focus(ctx, annot);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_eventBlur)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_annot_event_blur(ctx, annot);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_update)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean changed = JNI_FALSE;
- if (!ctx || !annot) return JNI_FALSE;
- fz_try(ctx)
- changed = pdf_update_annot(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return changed;
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_getIsOpen)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean open = JNI_FALSE;
- if (!ctx || !annot) return JNI_FALSE;
- fz_try(ctx)
- open = pdf_annot_is_open(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return open;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setIsOpen)(JNIEnv *env, jobject self, jboolean open)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_is_open(ctx, annot, open);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jstring JNICALL
- FUN(PDFAnnotation_getIcon)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- const char *name = NULL;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- name = pdf_annot_icon_name(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return (*env)->NewStringUTF(env, name);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setIcon)(JNIEnv *env, jobject self, jstring jname)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- const char *name = NULL;
- if (!ctx || !annot) return;
- if (!jname) jni_throw_arg_void(env, "icon name must not be null");
- name = (*env)->GetStringUTFChars(env, jname, NULL);
- if (!name) return;
- fz_try(ctx)
- pdf_set_annot_icon_name(ctx, annot, name);
- fz_always(ctx)
- if (name)
- (*env)->ReleaseStringUTFChars(env, jname, name);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jintArray JNICALL
- FUN(PDFAnnotation_getLineEndingStyles)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- enum pdf_line_ending s = 0, e = 0;
- int line_endings[2];
- jintArray jline_endings = NULL;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- pdf_annot_line_ending_styles(ctx, annot, &s, &e);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- line_endings[0] = s;
- line_endings[1] = e;
- jline_endings = (*env)->NewIntArray(env, 2);
- if (!jline_endings || (*env)->ExceptionCheck(env)) return NULL;
- (*env)->SetIntArrayRegion(env, jline_endings, 0, 2, &line_endings[0]);
- if ((*env)->ExceptionCheck(env)) return NULL;
- return jline_endings;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setLineEndingStyles)(JNIEnv *env, jobject self, jint start_style, jint end_style)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_line_ending_styles(ctx, annot, start_style, end_style);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_getObject)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return NULL;
- return to_PDFObject_safe(ctx, env, pdf_annot_obj(ctx, annot));
- }
- JNIEXPORT jint JNICALL
- FUN(PDFAnnotation_getLanguage)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- int lang;
- if (!ctx || !annot) return FZ_LANG_UNSET;
- fz_try(ctx)
- lang = pdf_annot_language(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return lang;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setLanguage)(JNIEnv *env, jobject self, jint lang)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_language(ctx, annot, lang);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasQuadding)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_quadding(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jint JNICALL
- FUN(PDFAnnotation_getQuadding)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- int quadding;
- if (!ctx || !annot) return 0;
- fz_try(ctx)
- quadding = pdf_annot_quadding(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return quadding;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setQuadding)(JNIEnv *env, jobject self, jint quadding)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_quadding(ctx, annot, quadding);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_getLine)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_point points[2] = { 0 };
- jobject jline = NULL;
- jobject jpoint = NULL;
- size_t i = 0;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- pdf_annot_line(ctx, annot, &points[0], &points[1]);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- jline = (*env)->NewObjectArray(env, nelem(points), cls_Point, NULL);
- if (!jline || (*env)->ExceptionCheck(env)) return NULL;
- for (i = 0; i < nelem(points); i++)
- {
- jpoint = (*env)->NewObject(env, cls_Point, mid_Point_init, points[i].x, points[i].y);
- if (!jpoint || (*env)->ExceptionCheck(env)) return NULL;
- (*env)->SetObjectArrayElement(env, jline, i, jpoint);
- if ((*env)->ExceptionCheck(env)) return NULL;
- (*env)->DeleteLocalRef(env, jpoint);
- }
- return jline;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setLine)(JNIEnv *env, jobject self, jobject ja, jobject jb)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_point a, b;
- if (!ctx || !annot) return;
- if (!ja || !jb) jni_throw_arg_void(env, "line points must not be null");
- a.x = (*env)->GetFloatField(env, ja, fid_Point_x);
- a.y = (*env)->GetFloatField(env, ja, fid_Point_y);
- b.x = (*env)->GetFloatField(env, jb, fid_Point_x);
- b.y = (*env)->GetFloatField(env, jb, fid_Point_y);
- fz_try(ctx)
- pdf_set_annot_line(ctx, annot, a, b);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasDefaultAppearance)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_default_appearance(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_getDefaultAppearance)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jobject jda = NULL;
- jobject jfont = NULL;
- jobject jcolor = NULL;
- const char *font = NULL;
- float color[4] = { 0 };
- float size = 0;
- int n = 0;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- pdf_annot_default_appearance(ctx, annot, &font, &size, &n, color);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- jfont = (*env)->NewStringUTF(env, font);
- if (!jfont || (*env)->ExceptionCheck(env)) return NULL;
- jcolor = (*env)->NewFloatArray(env, n);
- if (!jcolor || (*env)->ExceptionCheck(env)) return NULL;
- (*env)->SetFloatArrayRegion(env, jcolor, 0, n, color);
- if ((*env)->ExceptionCheck(env)) return NULL;
- jda = (*env)->NewObject(env, cls_DefaultAppearance, mid_DefaultAppearance_init);
- if (!jda) return NULL;
- (*env)->SetObjectField(env, jda, fid_DefaultAppearance_font, jfont);
- (*env)->SetFloatField(env, jda, fid_DefaultAppearance_size, size);
- (*env)->SetObjectField(env, jda, fid_DefaultAppearance_color, jcolor);
- return jda;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setDefaultAppearance)(JNIEnv *env, jobject self, jstring jfont, jfloat size, jobject jcolor)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- const char *font = NULL;
- float color[4] = { 0 };
- int n = 0;
- if (!ctx || !annot) return;
- if (!jfont) jni_throw_arg_void(env, "font must not be null");
- font = (*env)->GetStringUTFChars(env, jfont, NULL);
- if (!font) jni_throw_oom_void(env, "can not get characters in font name string");
- if (!from_jfloatArray(env, color, nelem(color), jcolor)) return;
- if (jcolor)
- n = (*env)->GetArrayLength(env, jcolor);
- fz_try(ctx)
- pdf_set_annot_default_appearance(ctx, annot, font, size, n, color);
- fz_always(ctx)
- (*env)->ReleaseStringUTFChars(env, jfont, font);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setNativeAppearance)(JNIEnv *env, jobject self, jstring jappearance, jstring jstate, jobject jctm, jobject jbbox, jobject jres, jobject jcontents)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- pdf_obj *res = from_PDFObject(env, jres);
- fz_matrix ctm = from_Matrix(env, jctm);
- fz_rect bbox = from_Rect(env, jbbox);
- fz_buffer *contents = from_Buffer(env, jcontents);
- const char *appearance = NULL;
- const char *state = NULL;
- if (!ctx || !annot) return;
- if (jappearance)
- {
- appearance = (*env)->GetStringUTFChars(env, jappearance, NULL);
- if (!appearance)
- jni_throw_oom_void(env, "can not get characters in appearance string");
- }
- if (jstate)
- {
- state = (*env)->GetStringUTFChars(env, jstate, NULL);
- if (!state)
- {
- (*env)->ReleaseStringUTFChars(env, jappearance, appearance);
- jni_throw_oom_void(env, "can not get characters in state string");
- }
- }
- fz_try(ctx)
- pdf_set_annot_appearance(ctx, annot, appearance, state, ctm, bbox, res, contents);
- fz_always(ctx)
- {
- if (jstate)
- (*env)->ReleaseStringUTFChars(env, jstate, state);
- if (jappearance)
- (*env)->ReleaseStringUTFChars(env, jappearance, appearance);
- }
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setNativeAppearanceImage)(JNIEnv *env, jobject self, jobject jimage)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_image *image = from_Image(env, jimage);
- if (!ctx || !annot || !image)
- return;
- fz_try(ctx)
- pdf_set_annot_stamp_image(ctx, annot, image);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setNativeAppearanceDisplayList)(JNIEnv *env, jobject self, jstring jappearance, jstring jstate, jobject jctm, jobject jlist)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_matrix ctm = from_Matrix(env, jctm);
- fz_display_list *list = from_DisplayList(env, jlist);
- const char *appearance = NULL;
- const char *state = NULL;
- if (!ctx || !annot) return;
- if (jappearance)
- {
- appearance = (*env)->GetStringUTFChars(env, jappearance, NULL);
- if (!appearance)
- jni_throw_oom_void(env, "can not get characters in appearance string");
- }
- if (jstate)
- {
- state = (*env)->GetStringUTFChars(env, jstate, NULL);
- if (!state)
- {
- (*env)->ReleaseStringUTFChars(env, jappearance, appearance);
- jni_throw_oom_void(env, "can not get characters in state string");
- }
- }
- fz_try(ctx)
- pdf_set_annot_appearance_from_display_list(ctx, annot, appearance, state, ctm, list);
- fz_always(ctx)
- {
- if (jstate)
- (*env)->ReleaseStringUTFChars(env, jstate, state);
- if (jappearance)
- (*env)->ReleaseStringUTFChars(env, jappearance, appearance);
- }
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasInteriorColor)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_interior_color(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasAuthor)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_author(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasLineEndingStyles)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_line_ending_styles(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasQuadPoints)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_quad_points(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasVertices)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_vertices(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasInkList)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_ink_list(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasIcon)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_icon_name(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasOpen)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_open(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasLine)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_line(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setFileSpec)(JNIEnv *env, jobject self, jobject jfs)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- pdf_obj *fs = from_PDFObject(env, jfs);
- fz_try(ctx)
- pdf_set_annot_filespec(ctx, annot, fs);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_getFileSpec)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- pdf_obj *fs = NULL;
- fz_try(ctx)
- fs = pdf_annot_filespec(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return to_PDFObject_safe(ctx, env, fs);
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasBorder)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_border(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jint JNICALL
- FUN(PDFAnnotation_getBorderStyle)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- enum pdf_border_style style = PDF_BORDER_STYLE_SOLID;
- if (!ctx || !annot) return 0;
- fz_try(ctx)
- style = pdf_annot_border_style(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return style;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setBorderStyle)(JNIEnv *env, jobject self, jint style)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_try(ctx)
- pdf_set_annot_border_style(ctx, annot, style);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jfloat JNICALL
- FUN(PDFAnnotation_getBorderWidth)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- float width;
- if (!ctx || !annot) return 0;
- fz_try(ctx)
- width = pdf_annot_border_width(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return width;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setBorderWidth)(JNIEnv *env, jobject self, jfloat width)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_try(ctx)
- pdf_set_annot_border_width(ctx, annot, width);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jint JNICALL
- FUN(PDFAnnotation_getBorderDashCount)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- int count;
- if (!ctx || !annot) return 0;
- fz_try(ctx)
- count = pdf_annot_border_dash_count(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return count;
- }
- JNIEXPORT jfloat JNICALL
- FUN(PDFAnnotation_getBorderDashItem)(JNIEnv *env, jobject self, jint i)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- int length;
- if (!ctx || !annot) return 0;
- fz_try(ctx)
- length = pdf_annot_border_dash_item(ctx, annot, i);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return length;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_clearBorderDash)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_clear_annot_border_dash(ctx, annot);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_addBorderDashItem)(JNIEnv *env, jobject self, jfloat length)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_add_annot_border_dash_item(ctx, annot, length);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasBorderEffect)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_border_effect(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jint JNICALL
- FUN(PDFAnnotation_getBorderEffect)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jint effect = PDF_BORDER_EFFECT_NONE;
- fz_try(ctx)
- effect = pdf_annot_border_effect(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return effect;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setBorderEffect)(JNIEnv *env, jobject self, jint effect)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_try(ctx)
- pdf_set_annot_border_effect(ctx, annot, effect);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jfloat JNICALL
- FUN(PDFAnnotation_getBorderEffectIntensity)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jfloat intensity = PDF_BORDER_EFFECT_NONE;
- fz_try(ctx)
- intensity = pdf_annot_border_effect_intensity(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return intensity;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setBorderEffectIntensity)(JNIEnv *env, jobject self, jfloat intensity)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_try(ctx)
- pdf_set_annot_border_effect_intensity(ctx, annot, intensity);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasFileSpec)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_filespec(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setHiddenForEditing)(JNIEnv *env, jobject self, jboolean hidden)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation_safe(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_hidden_for_editing(ctx, annot, hidden);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_getHiddenForEditing)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation_safe(env, self);
- jboolean hidden = JNI_FALSE;
- if (!ctx || !annot) return JNI_FALSE;
- fz_try(ctx)
- hidden = pdf_annot_hidden_for_editing(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return hidden;
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_applyRedaction)(JNIEnv *env, jobject self, jboolean blackBoxes, jint imageMethod, jint lineArt, jint text)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation_safe(env, self);
- pdf_redact_options opts = { blackBoxes, imageMethod, lineArt, text };
- jboolean redacted = JNI_FALSE;
- if (!ctx || !annot) return JNI_FALSE;
- fz_try(ctx)
- redacted = pdf_apply_redaction(ctx, annot, &opts);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return redacted;
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasRect)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_rect(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasIntent)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_intent(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jint JNICALL
- FUN(PDFAnnotation_getIntent)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- enum pdf_intent intent = PDF_ANNOT_IT_DEFAULT;
- if (!ctx || !annot) return PDF_ANNOT_IT_DEFAULT;
- fz_try(ctx)
- intent = pdf_annot_intent(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return intent;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setIntent)(JNIEnv *env, jobject self, jint intent)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_intent(ctx, annot, intent);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasPopup)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_popup(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_getPopup)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_rect rect;
- if (!ctx || !annot) return JNI_FALSE;
- fz_try(ctx)
- rect = pdf_annot_popup(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return to_Rect_safe(ctx, env, rect);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setPopup)(JNIEnv *env, jobject self, jobject jrect)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_rect rect = from_Rect(env, jrect);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_popup(ctx, annot, rect);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jfloat JNICALL
- FUN(PDFAnnotation_getLineLeader)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jfloat v;
- if (!ctx || !annot) return 0;
- fz_try(ctx)
- v = pdf_annot_line_leader(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return v;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setLineLeader)(JNIEnv *env, jobject self, jfloat length)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_line_leader(ctx, annot, length);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jfloat JNICALL
- FUN(PDFAnnotation_getLineLeaderExtension)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jfloat v;
- if (!ctx || !annot) return 0;
- fz_try(ctx)
- v = pdf_annot_line_leader_extension(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return v;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setLineLeaderExtension)(JNIEnv *env, jobject self, jfloat extension)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_line_leader_extension(ctx, annot, extension);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jfloat JNICALL
- FUN(PDFAnnotation_getLineLeaderOffset)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jfloat v;
- if (!ctx || !annot) return 0;
- fz_try(ctx)
- v = pdf_annot_line_leader_offset(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return v;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setLineLeaderOffset)(JNIEnv *env, jobject self, jfloat offset)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_line_leader_offset(ctx, annot, offset);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_getLineCaption)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean v;
- if (!ctx || !annot) return JNI_FALSE;
- fz_try(ctx)
- v = pdf_annot_line_caption(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return v;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setLineCaption)(JNIEnv *env, jobject self, jboolean caption)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_line_caption(ctx, annot, caption);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_getLineCaptionOffset)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_point offset;;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- offset = pdf_annot_line_caption_offset(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return to_Point_safe(ctx, env, offset);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setLeaderLines)(JNIEnv *env, jobject self, jobject joffset)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_point offset = from_Point(env, joffset);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_line_caption_offset(ctx, annot, offset);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_requestSynthesis)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_annot_request_synthesis(ctx, annot);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_requestResynthesis)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_annot_request_resynthesis(ctx, annot);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_getHot)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean hot = JNI_FALSE;
- if (!ctx || !annot) return JNI_FALSE;
- fz_try(ctx)
- hot = pdf_annot_hot(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return hot;
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setHot)(JNIEnv *env, jobject self, jboolean hot)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_hot(ctx, annot, hot);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_process)(JNIEnv *env, jobject self, jobject jproc)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- pdf_processor *proc = make_pdf_processor(env, ctx, jproc);
- if (!ctx || !annot) return;
- if (!proc) jni_throw_arg_void(env, "processor must not be null");
- fz_try(ctx)
- {
- pdf_processor_push_resources(ctx, proc, pdf_page_resources(ctx, pdf_annot_page(ctx, annot)));
- pdf_process_annot(ctx, proc, annot, NULL);
- pdf_close_processor(ctx, proc);
- }
- fz_always(ctx)
- {
- pdf_processor_pop_resources(ctx, proc);
- pdf_drop_processor(ctx, proc);
- }
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasRichContents)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- if (!ctx || !annot) return JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_rich_contents(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jstring JNICALL
- FUN(PDFAnnotation_getRichContents)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- const char *contents = NULL;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- contents = pdf_annot_rich_contents(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return to_String_safe(ctx, env, contents);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setRichContents)(JNIEnv *env, jobject self, jstring jplaintext, jstring jrichtext)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- const char *plaintext = NULL;
- const char *richtext = NULL;
- if (!ctx || !annot) return;
- if (jplaintext)
- {
- plaintext = (*env)->GetStringUTFChars(env, jplaintext, NULL);
- if (!plaintext) return;
- }
- if (jrichtext)
- {
- richtext = (*env)->GetStringUTFChars(env, jrichtext, NULL);
- if (!richtext)
- {
- if (plaintext)
- (*env)->ReleaseStringUTFChars(env, jplaintext, plaintext);
- return;
- }
- }
- fz_try(ctx)
- pdf_set_annot_rich_contents(ctx, annot, plaintext, richtext);
- fz_always(ctx)
- {
- if (richtext)
- (*env)->ReleaseStringUTFChars(env, jrichtext, richtext);
- if (plaintext)
- (*env)->ReleaseStringUTFChars(env, jplaintext, plaintext);
- }
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jboolean JNICALL
- FUN(PDFAnnotation_hasRichDefaults)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- jboolean has = JNI_FALSE;
- if (!ctx || !annot) return JNI_FALSE;
- fz_try(ctx)
- has = pdf_annot_has_rich_defaults(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return has;
- }
- JNIEXPORT jstring JNICALL
- FUN(PDFAnnotation_getRichDefaults)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- const char *defaults = NULL;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- defaults = pdf_annot_rich_defaults(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return to_String_safe(ctx, env, defaults);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setRichDefault)(JNIEnv *env, jobject self, jstring jstyle)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- const char *style = NULL;
- if (!ctx || !annot) return;
- if (jstyle)
- {
- style = (*env)->GetStringUTFChars(env, jstyle, NULL);
- if (!style) return;
- }
- fz_try(ctx)
- pdf_set_annot_rich_defaults(ctx, annot, style);
- fz_always(ctx)
- if (style)
- (*env)->ReleaseStringUTFChars(env, jstyle, style);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT jobject JNICALL
- FUN(PDFAnnotation_getStampImageObject)(JNIEnv *env, jobject self)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- pdf_obj *obj = NULL;
- if (!ctx || !annot) return NULL;
- fz_try(ctx)
- obj = pdf_annot_stamp_image_obj(ctx, annot);
- fz_catch(ctx)
- jni_rethrow(env, ctx);
- return to_PDFObject_safe(ctx, env, obj);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setStampImageObject)(JNIEnv *env, jobject self, jobject jobj)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- pdf_obj *obj = from_PDFObject(env, jobj);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_stamp_image_obj(ctx, annot, obj);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
- JNIEXPORT void JNICALL
- FUN(PDFAnnotation_setStampImage)(JNIEnv *env, jobject self, jobject jimg)
- {
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
- fz_image *img = from_Image(env, jimg);
- if (!ctx || !annot) return;
- fz_try(ctx)
- pdf_set_annot_stamp_image(ctx, annot, img);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
- }
|