diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-03-03 13:31:42 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-03-14 17:08:28 +0100 |
commit | 3f3bcd74f0329a0a9a6913f9cffebd9d965bf93e (patch) | |
tree | 27db0642b7397bbc09e8459ea4ad4273116fe974 /source/pdf | |
parent | e8afed7205f32d776ba406b167b5097d728da5f6 (diff) | |
download | mupdf-3f3bcd74f0329a0a9a6913f9cffebd9d965bf93e.tar.xz |
Take pdf_obj argument to pdf_is_stream.
Diffstat (limited to 'source/pdf')
-rw-r--r-- | source/pdf/pdf-annot-edit.c | 4 | ||||
-rw-r--r-- | source/pdf/pdf-annot.c | 4 | ||||
-rw-r--r-- | source/pdf/pdf-appearance.c | 2 | ||||
-rw-r--r-- | source/pdf/pdf-field.c | 2 | ||||
-rw-r--r-- | source/pdf/pdf-parse.c | 2 | ||||
-rw-r--r-- | source/pdf/pdf-stream.c | 11 | ||||
-rw-r--r-- | source/pdf/pdf-type3.c | 2 | ||||
-rw-r--r-- | source/pdf/pdf-unicode.c | 2 | ||||
-rw-r--r-- | source/pdf/pdf-write.c | 8 |
9 files changed, 22 insertions, 15 deletions
diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c index 06b3495e..66704a2f 100644 --- a/source/pdf/pdf-annot-edit.c +++ b/source/pdf/pdf-annot-edit.c @@ -65,13 +65,13 @@ pdf_update_annot(fz_context *ctx, pdf_document *doc, pdf_annot *annot) n = pdf_dict_get(ctx, ap, PDF_NAME_N); /* normal state */ /* lookup current state in sub-dictionary */ - if (!pdf_is_stream(ctx, doc, pdf_to_num(ctx, n), pdf_to_gen(ctx, n))) + if (!pdf_is_stream(ctx, n)) n = pdf_dict_get(ctx, n, as); pdf_drop_xobject(ctx, annot->ap); annot->ap = NULL; - if (pdf_is_stream(ctx, doc, pdf_to_num(ctx, n), pdf_to_gen(ctx, n))) + if (pdf_is_stream(ctx, n)) { fz_try(ctx) { diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c index f8e6a770..5261bdb0 100644 --- a/source/pdf/pdf-annot.c +++ b/source/pdf/pdf-annot.c @@ -569,7 +569,7 @@ pdf_load_annots(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_obj *ann n = pdf_dict_get(ctx, ap, PDF_NAME_N); /* normal state */ /* lookup current state in sub-dictionary */ - if (!pdf_is_stream(ctx, doc, pdf_to_num(ctx, n), pdf_to_gen(ctx, n))) + if (!pdf_is_stream(ctx, n)) n = pdf_dict_get(ctx, n, as); pdf_to_rect(ctx, rect, &annot->rect); @@ -579,7 +579,7 @@ pdf_load_annots(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_obj *ann annot->annot_type = pdf_annot_obj_type(ctx, obj); annot->widget_type = annot->annot_type == FZ_ANNOT_WIDGET ? pdf_field_type(ctx, doc, obj) : PDF_WIDGET_TYPE_NOT_WIDGET; - if (pdf_is_stream(ctx, doc, pdf_to_num(ctx, n), pdf_to_gen(ctx, n))) + if (pdf_is_stream(ctx, n)) { annot->ap = pdf_load_xobject(ctx, doc, n); pdf_transform_annot(ctx, annot); diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c index 49de8cf9..6ddf3240 100644 --- a/source/pdf/pdf-appearance.c +++ b/source/pdf/pdf-appearance.c @@ -1597,7 +1597,7 @@ void pdf_set_annot_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *ann /* See if there is a current normal appearance */ ap_obj = pdf_dict_getl(ctx, obj, PDF_NAME_AP, PDF_NAME_N, NULL); - if (!pdf_is_stream(ctx, doc, pdf_to_num(ctx, ap_obj), pdf_to_gen(ctx, ap_obj))) + if (!pdf_is_stream(ctx, ap_obj)) ap_obj = NULL; if (ap_obj == NULL) diff --git a/source/pdf/pdf-field.c b/source/pdf/pdf-field.c index fc49d9dd..7e91cb1e 100644 --- a/source/pdf/pdf-field.c +++ b/source/pdf/pdf-field.c @@ -31,7 +31,7 @@ char *pdf_get_string_or_stream(fz_context *ctx, pdf_document *doc, pdf_obj *obj) len = pdf_to_str_len(ctx, obj); buf = pdf_to_str_buf(ctx, obj); } - else if (pdf_is_stream(ctx, doc, pdf_to_num(ctx, obj), pdf_to_gen(ctx, obj))) + else if (pdf_is_stream(ctx, obj)) { stmbuf = pdf_load_stream(ctx, doc, pdf_to_num(ctx, obj), pdf_to_gen(ctx, obj)); len = fz_buffer_storage(ctx, stmbuf, (unsigned char **)&buf); diff --git a/source/pdf/pdf-parse.c b/source/pdf/pdf-parse.c index 9d9af31d..3761e3ce 100644 --- a/source/pdf/pdf-parse.c +++ b/source/pdf/pdf-parse.c @@ -65,7 +65,7 @@ pdf_to_utf8(fz_context *ctx, pdf_document *doc, pdf_obj *src) srcptr = (unsigned char *) pdf_to_str_buf(ctx, src); srclen = pdf_to_str_len(ctx, src); } - else if (pdf_is_stream(ctx, doc, pdf_to_num(ctx, src), pdf_to_gen(ctx, src))) + else if (pdf_is_stream(ctx, src)) { stmbuf = pdf_load_stream(ctx, doc, pdf_to_num(ctx, src), pdf_to_gen(ctx, src)); srclen = fz_buffer_storage(ctx, stmbuf, (unsigned char **)&srcptr); diff --git a/source/pdf/pdf-stream.c b/source/pdf/pdf-stream.c index 4636a1a7..57167eda 100644 --- a/source/pdf/pdf-stream.c +++ b/source/pdf/pdf-stream.c @@ -4,7 +4,7 @@ * Check if an object is a stream or not. */ int -pdf_is_stream(fz_context *ctx, pdf_document *doc, int num, int gen) +pdf_obj_num_is_stream(fz_context *ctx, pdf_document *doc, int num, int gen) { pdf_xref_entry *entry; @@ -16,6 +16,13 @@ pdf_is_stream(fz_context *ctx, pdf_document *doc, int num, int gen) return entry->stm_ofs != 0 || entry->stm_buf; } +int +pdf_is_stream(fz_context *ctx, pdf_obj *obj) +{ + return pdf_obj_num_is_stream(ctx, pdf_get_indirect_document(ctx, obj), + pdf_to_num(ctx, obj), pdf_to_gen(ctx, obj)); +} + /* * Scan stream dictionary for an explicit /Crypt filter */ @@ -646,7 +653,7 @@ pdf_open_contents_stream(fz_context *ctx, pdf_document *doc, pdf_obj *obj) num = pdf_to_num(ctx, obj); gen = pdf_to_gen(ctx, obj); - if (pdf_is_stream(ctx, doc, num, gen)) + if (pdf_is_stream(ctx, obj)) return pdf_open_image_stream(ctx, doc, num, gen, num, gen, NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "pdf object stream missing (%d %d R)", num, gen); diff --git a/source/pdf/pdf-type3.c b/source/pdf/pdf-type3.c index 56128c9a..236ac6c4 100644 --- a/source/pdf/pdf-type3.c +++ b/source/pdf/pdf-type3.c @@ -158,7 +158,7 @@ pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *d if (estrings[i]) { obj = pdf_dict_gets(ctx, charprocs, estrings[i]); - if (pdf_is_stream(ctx, doc, pdf_to_num(ctx, obj), pdf_to_gen(ctx, obj))) + if (pdf_is_stream(ctx, obj)) { fontdesc->font->t3procs[i] = pdf_load_stream(ctx, doc, pdf_to_num(ctx, obj), pdf_to_gen(ctx, obj)); fontdesc->size += fontdesc->font->t3procs[i]->cap; diff --git a/source/pdf/pdf-unicode.c b/source/pdf/pdf-unicode.c index 7b04c02c..ca84341d 100644 --- a/source/pdf/pdf-unicode.c +++ b/source/pdf/pdf-unicode.c @@ -61,7 +61,7 @@ pdf_load_to_unicode(fz_context *ctx, pdf_document *doc, pdf_font_desc *font, { unsigned int cpt; - if (pdf_is_stream(ctx, doc, pdf_to_num(ctx, cmapstm), pdf_to_gen(ctx, cmapstm))) + if (pdf_is_stream(ctx, cmapstm)) { pdf_cmap *ucs_from_cpt = pdf_load_embedded_cmap(ctx, doc, cmapstm); font->to_unicode = pdf_remap_cmap(ctx, font->encoding, ucs_from_cpt); diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c index 62ea6c88..c8b18c55 100644 --- a/source/pdf/pdf-write.c +++ b/source/pdf/pdf-write.c @@ -534,7 +534,7 @@ static pdf_obj *markref(fz_context *ctx, pdf_document *doc, pdf_write_state *opt /* Bake in /Length in stream objects */ fz_try(ctx) { - if (pdf_is_stream(ctx, doc, num, gen)) + if (pdf_obj_num_is_stream(ctx, doc, num, gen)) { pdf_obj *len = pdf_dict_get(ctx, obj, PDF_NAME_Length); if (pdf_is_indirect(ctx, len)) @@ -656,8 +656,8 @@ static void removeduplicateobjs(fz_context *ctx, pdf_document *doc, pdf_write_st */ fz_try(ctx) { - streama = pdf_is_stream(ctx, doc, num, 0); - streamb = pdf_is_stream(ctx, doc, other, 0); + streama = pdf_obj_num_is_stream(ctx, doc, num, 0); + streamb = pdf_obj_num_is_stream(ctx, doc, other, 0); differ = streama || streamb; if (streama && streamb && opts->do_garbage >= 4) differ = 0; @@ -1792,7 +1792,7 @@ static void writeobject(fz_context *ctx, pdf_document *doc, pdf_write_state *opt } entry = pdf_get_xref_entry(ctx, doc, num); - if (!pdf_is_stream(ctx, doc, num, gen)) + if (!pdf_obj_num_is_stream(ctx, doc, num, gen)) { fz_printf(ctx, opts->out, "%d %d obj\n", num, gen); pdf_print_obj(ctx, opts->out, obj, opts->do_tight); |