diff options
Diffstat (limited to 'pdf/pdf_annot.c')
-rw-r--r-- | pdf/pdf_annot.c | 190 |
1 files changed, 95 insertions, 95 deletions
diff --git a/pdf/pdf_annot.c b/pdf/pdf_annot.c index ae03f2b6..28300c9b 100644 --- a/pdf/pdf_annot.c +++ b/pdf/pdf_annot.c @@ -1,46 +1,46 @@ -#include "fitz.h" -#include "mupdf.h" +#include "fitz-internal.h" +#include "mupdf-internal.h" -static fz_obj * -resolve_dest_rec(pdf_document *xref, fz_obj *dest, int depth) +static pdf_obj * +resolve_dest_rec(pdf_document *xref, pdf_obj *dest, int depth) { if (depth > 10) /* Arbitrary to avoid infinite recursion */ return NULL; - if (fz_is_name(dest) || fz_is_string(dest)) + if (pdf_is_name(dest) || pdf_is_string(dest)) { dest = pdf_lookup_dest(xref, dest); return resolve_dest_rec(xref, dest, depth+1); } - else if (fz_is_array(dest)) + else if (pdf_is_array(dest)) { return dest; } - else if (fz_is_dict(dest)) + else if (pdf_is_dict(dest)) { - dest = fz_dict_gets(dest, "D"); + dest = pdf_dict_gets(dest, "D"); return resolve_dest_rec(xref, dest, depth+1); } - else if (fz_is_indirect(dest)) + else if (pdf_is_indirect(dest)) return dest; return NULL; } -static fz_obj * -resolve_dest(pdf_document *xref, fz_obj *dest) +static pdf_obj * +resolve_dest(pdf_document *xref, pdf_obj *dest) { return resolve_dest_rec(xref, dest, 0); } fz_link_dest -pdf_parse_link_dest(pdf_document *xref, fz_obj *dest) +pdf_parse_link_dest(pdf_document *xref, pdf_obj *dest) { fz_link_dest ld; - fz_obj *obj; + pdf_obj *obj; int l_from_2 = 0; int b_from_3 = 0; @@ -51,16 +51,16 @@ pdf_parse_link_dest(pdf_document *xref, fz_obj *dest) int z_from_4 = 0; dest = resolve_dest(xref, dest); - if (dest == NULL || !fz_is_array(dest)) + if (dest == NULL || !pdf_is_array(dest)) { ld.kind = FZ_LINK_NONE; return ld; } - obj = fz_array_get(dest, 0); - if (fz_is_int(obj)) - ld.ld.gotor.page = fz_to_int(obj); + obj = pdf_array_get(dest, 0); + if (pdf_is_int(obj)) + ld.ld.gotor.page = pdf_to_int(obj); else - ld.ld.gotor.page = pdf_find_page_number(xref, obj); + ld.ld.gotor.page = pdf_lookup_page_number(xref, obj); ld.kind = FZ_LINK_GOTO; ld.ld.gotor.flags = 0; @@ -71,31 +71,31 @@ pdf_parse_link_dest(pdf_document *xref, fz_obj *dest) ld.ld.gotor.file_spec = NULL; ld.ld.gotor.new_window = 0; - obj = fz_array_get(dest, 1); - if (!fz_is_name(obj)) + obj = pdf_array_get(dest, 1); + if (!pdf_is_name(obj)) return ld; - if (!strcmp("XYZ", fz_to_name(obj))) + if (!strcmp("XYZ", pdf_to_name(obj))) { l_from_2 = t_from_3 = z_from_4 = 1; ld.ld.gotor.flags |= fz_link_flag_r_is_zoom; } - else if ((!strcmp("Fit", fz_to_name(obj))) || (!strcmp("FitB", fz_to_name(obj)))) + else if ((!strcmp("Fit", pdf_to_name(obj))) || (!strcmp("FitB", pdf_to_name(obj)))) { ld.ld.gotor.flags |= fz_link_flag_fit_h; ld.ld.gotor.flags |= fz_link_flag_fit_v; } - else if ((!strcmp("FitH", fz_to_name(obj))) || (!strcmp("FitBH", fz_to_name(obj)))) + else if ((!strcmp("FitH", pdf_to_name(obj))) || (!strcmp("FitBH", pdf_to_name(obj)))) { t_from_2 = 1; ld.ld.gotor.flags |= fz_link_flag_fit_h; } - else if ((!strcmp("FitV", fz_to_name(obj))) || (!strcmp("FitBV", fz_to_name(obj)))) + else if ((!strcmp("FitV", pdf_to_name(obj))) || (!strcmp("FitBV", pdf_to_name(obj)))) { l_from_2 = 1; ld.ld.gotor.flags |= fz_link_flag_fit_v; } - else if (!strcmp("FitR", fz_to_name(obj))) + else if (!strcmp("FitR", pdf_to_name(obj))) { l_from_2 = b_from_3 = r_from_4 = t_from_5 = 1; ld.ld.gotor.flags |= fz_link_flag_fit_h; @@ -104,77 +104,77 @@ pdf_parse_link_dest(pdf_document *xref, fz_obj *dest) if (l_from_2) { - obj = fz_array_get(dest, 2); - if (fz_is_int(obj)) + obj = pdf_array_get(dest, 2); + if (pdf_is_int(obj)) { ld.ld.gotor.flags |= fz_link_flag_l_valid; - ld.ld.gotor.lt.x = fz_to_int(obj); + ld.ld.gotor.lt.x = pdf_to_int(obj); } - else if (fz_is_real(obj)) + else if (pdf_is_real(obj)) { ld.ld.gotor.flags |= fz_link_flag_l_valid; - ld.ld.gotor.lt.x = fz_to_real(obj); + ld.ld.gotor.lt.x = pdf_to_real(obj); } } if (b_from_3) { - obj = fz_array_get(dest, 3); - if (fz_is_int(obj)) + obj = pdf_array_get(dest, 3); + if (pdf_is_int(obj)) { ld.ld.gotor.flags |= fz_link_flag_b_valid; - ld.ld.gotor.rb.y = fz_to_int(obj); + ld.ld.gotor.rb.y = pdf_to_int(obj); } - else if (fz_is_real(obj)) + else if (pdf_is_real(obj)) { ld.ld.gotor.flags |= fz_link_flag_b_valid; - ld.ld.gotor.rb.y = fz_to_real(obj); + ld.ld.gotor.rb.y = pdf_to_real(obj); } } if (r_from_4) { - obj = fz_array_get(dest, 4); - if (fz_is_int(obj)) + obj = pdf_array_get(dest, 4); + if (pdf_is_int(obj)) { ld.ld.gotor.flags |= fz_link_flag_r_valid; - ld.ld.gotor.rb.x = fz_to_int(obj); + ld.ld.gotor.rb.x = pdf_to_int(obj); } - else if (fz_is_real(obj)) + else if (pdf_is_real(obj)) { ld.ld.gotor.flags |= fz_link_flag_r_valid; - ld.ld.gotor.rb.x = fz_to_real(obj); + ld.ld.gotor.rb.x = pdf_to_real(obj); } } if (t_from_5 || t_from_3 || t_from_2) { if (t_from_5) - obj = fz_array_get(dest, 5); + obj = pdf_array_get(dest, 5); else if (t_from_3) - obj = fz_array_get(dest, 3); + obj = pdf_array_get(dest, 3); else - obj = fz_array_get(dest, 2); - if (fz_is_int(obj)) + obj = pdf_array_get(dest, 2); + if (pdf_is_int(obj)) { ld.ld.gotor.flags |= fz_link_flag_t_valid; - ld.ld.gotor.lt.y = fz_to_int(obj); + ld.ld.gotor.lt.y = pdf_to_int(obj); } - else if (fz_is_real(obj)) + else if (pdf_is_real(obj)) { ld.ld.gotor.flags |= fz_link_flag_t_valid; - ld.ld.gotor.lt.y = fz_to_real(obj); + ld.ld.gotor.lt.y = pdf_to_real(obj); } } if (z_from_4) { - obj = fz_array_get(dest, 4); - if (fz_is_int(obj)) + obj = pdf_array_get(dest, 4); + if (pdf_is_int(obj)) { ld.ld.gotor.flags |= fz_link_flag_r_valid; - ld.ld.gotor.rb.x = fz_to_int(obj); + ld.ld.gotor.rb.x = pdf_to_int(obj); } - else if (fz_is_real(obj)) + else if (pdf_is_real(obj)) { ld.ld.gotor.flags |= fz_link_flag_r_valid; - ld.ld.gotor.rb.x = fz_to_real(obj); + ld.ld.gotor.rb.x = pdf_to_real(obj); } } @@ -192,10 +192,10 @@ pdf_parse_link_dest(pdf_document *xref, fz_obj *dest) } fz_link_dest -pdf_parse_action(pdf_document *xref, fz_obj *action) +pdf_parse_action(pdf_document *xref, pdf_obj *action) { fz_link_dest ld; - fz_obj *obj, *dest; + pdf_obj *obj, *dest; fz_context *ctx = xref->ctx; ld.kind = FZ_LINK_NONE; @@ -203,53 +203,53 @@ pdf_parse_action(pdf_document *xref, fz_obj *action) if (!action) return ld; - obj = fz_dict_gets(action, "S"); - if (!strcmp(fz_to_name(obj), "GoTo")) + obj = pdf_dict_gets(action, "S"); + if (!strcmp(pdf_to_name(obj), "GoTo")) { - dest = fz_dict_gets(action, "D"); + dest = pdf_dict_gets(action, "D"); ld = pdf_parse_link_dest(xref, dest); } - else if (!strcmp(fz_to_name(obj), "URI")) + else if (!strcmp(pdf_to_name(obj), "URI")) { ld.kind = FZ_LINK_URI; - ld.ld.uri.is_map = fz_to_bool(fz_dict_gets(action, "IsMap")); - ld.ld.uri.uri = pdf_to_utf8(ctx, fz_dict_gets(action, "URI")); + ld.ld.uri.is_map = pdf_to_bool(pdf_dict_gets(action, "IsMap")); + ld.ld.uri.uri = pdf_to_utf8(ctx, pdf_dict_gets(action, "URI")); } - else if (!strcmp(fz_to_name(obj), "Launch")) + else if (!strcmp(pdf_to_name(obj), "Launch")) { ld.kind = FZ_LINK_LAUNCH; - ld.ld.launch.file_spec = pdf_to_utf8(ctx, fz_dict_gets(action, "F")); - ld.ld.launch.new_window = fz_to_int(fz_dict_gets(action, "NewWindow")); + ld.ld.launch.file_spec = pdf_to_utf8(ctx, pdf_dict_gets(action, "F")); + ld.ld.launch.new_window = pdf_to_int(pdf_dict_gets(action, "NewWindow")); } - else if (!strcmp(fz_to_name(obj), "Named")) + else if (!strcmp(pdf_to_name(obj), "Named")) { ld.kind = FZ_LINK_NAMED; - ld.ld.named.named = pdf_to_utf8(ctx, fz_dict_gets(action, "N")); + ld.ld.named.named = pdf_to_utf8(ctx, pdf_dict_gets(action, "N")); } - else if (!strcmp(fz_to_name(obj), "GoToR")) + else if (!strcmp(pdf_to_name(obj), "GoToR")) { - dest = fz_dict_gets(action, "D"); + dest = pdf_dict_gets(action, "D"); ld = pdf_parse_link_dest(xref, dest); ld.kind = FZ_LINK_GOTOR; - ld.ld.gotor.file_spec = pdf_to_utf8(ctx, fz_dict_gets(action, "F")); - ld.ld.gotor.new_window = fz_to_int(fz_dict_gets(action, "NewWindow")); + ld.ld.gotor.file_spec = pdf_to_utf8(ctx, pdf_dict_gets(action, "F")); + ld.ld.gotor.new_window = pdf_to_int(pdf_dict_gets(action, "NewWindow")); } return ld; } static fz_link * -pdf_load_link(pdf_document *xref, fz_obj *dict, fz_matrix page_ctm) +pdf_load_link(pdf_document *xref, pdf_obj *dict, fz_matrix page_ctm) { - fz_obj *dest = NULL; - fz_obj *action; - fz_obj *obj; + pdf_obj *dest = NULL; + pdf_obj *action; + pdf_obj *obj; fz_rect bbox; fz_context *ctx = xref->ctx; fz_link_dest ld; dest = NULL; - obj = fz_dict_gets(dict, "Rect"); + obj = pdf_dict_gets(dict, "Rect"); if (obj) bbox = pdf_to_rect(ctx, obj); else @@ -257,7 +257,7 @@ pdf_load_link(pdf_document *xref, fz_obj *dict, fz_matrix page_ctm) bbox = fz_transform_rect(page_ctm, bbox); - obj = fz_dict_gets(dict, "Dest"); + obj = pdf_dict_gets(dict, "Dest"); if (obj) { dest = resolve_dest(xref, obj); @@ -265,10 +265,10 @@ pdf_load_link(pdf_document *xref, fz_obj *dict, fz_matrix page_ctm) } else { - action = fz_dict_gets(dict, "A"); + action = pdf_dict_gets(dict, "A"); /* fall back to additional action button's down/up action */ if (!action) - action = fz_dict_getsa(fz_dict_gets(dict, "AA"), "U", "D"); + action = pdf_dict_getsa(pdf_dict_gets(dict, "AA"), "U", "D"); ld = pdf_parse_action(xref, action); } @@ -278,19 +278,19 @@ pdf_load_link(pdf_document *xref, fz_obj *dict, fz_matrix page_ctm) } fz_link * -pdf_load_link_annots(pdf_document *xref, fz_obj *annots, fz_matrix page_ctm) +pdf_load_link_annots(pdf_document *xref, pdf_obj *annots, fz_matrix page_ctm) { fz_link *link, *head, *tail; - fz_obj *obj; + pdf_obj *obj; int i, n; head = tail = NULL; link = NULL; - n = fz_array_len(annots); + n = pdf_array_len(annots); for (i = 0; i < n; i++) { - obj = fz_array_get(annots, i); + obj = pdf_array_get(annots, i); link = pdf_load_link(xref, obj, page_ctm); if (link) { @@ -318,7 +318,7 @@ pdf_free_annot(fz_context *ctx, pdf_annot *annot) if (annot->ap) pdf_drop_xobject(ctx, annot->ap); if (annot->obj) - fz_drop_obj(annot->obj); + pdf_drop_obj(annot->obj); fz_free(ctx, annot); annot = next; } @@ -349,10 +349,10 @@ pdf_transform_annot(pdf_annot *annot) } pdf_annot * -pdf_load_annots(pdf_document *xref, fz_obj *annots) +pdf_load_annots(pdf_document *xref, pdf_obj *annots) { pdf_annot *annot, *head, *tail; - fz_obj *obj, *ap, *as, *n, *rect; + pdf_obj *obj, *ap, *as, *n, *rect; pdf_xobject *form; int i, len; fz_context *ctx = xref->ctx; @@ -360,23 +360,23 @@ pdf_load_annots(pdf_document *xref, fz_obj *annots) head = tail = NULL; annot = NULL; - len = fz_array_len(annots); + len = pdf_array_len(annots); for (i = 0; i < len; i++) { - obj = fz_array_get(annots, i); + obj = pdf_array_get(annots, i); - rect = fz_dict_gets(obj, "Rect"); - ap = fz_dict_gets(obj, "AP"); - as = fz_dict_gets(obj, "AS"); - if (fz_is_dict(ap)) + rect = pdf_dict_gets(obj, "Rect"); + ap = pdf_dict_gets(obj, "AP"); + as = pdf_dict_gets(obj, "AS"); + if (pdf_is_dict(ap)) { - n = fz_dict_gets(ap, "N"); /* normal state */ + n = pdf_dict_gets(ap, "N"); /* normal state */ /* lookup current state in sub-dictionary */ - if (!pdf_is_stream(xref, fz_to_num(n), fz_to_gen(n))) - n = fz_dict_get(n, as); + if (!pdf_is_stream(xref, pdf_to_num(n), pdf_to_gen(n))) + n = pdf_dict_get(n, as); - if (pdf_is_stream(xref, fz_to_num(n), fz_to_gen(n))) + if (pdf_is_stream(xref, pdf_to_num(n), pdf_to_gen(n))) { fz_try(ctx) { @@ -389,7 +389,7 @@ pdf_load_annots(pdf_document *xref, fz_obj *annots) } annot = fz_malloc_struct(ctx, pdf_annot); - annot->obj = fz_keep_obj(obj); + annot->obj = pdf_keep_obj(obj); annot->rect = pdf_to_rect(ctx, rect); annot->ap = form; annot->next = NULL; |