diff options
author | Fred Ross-Perry <fred.ross-perry@artifex.com> | 2017-10-23 14:43:16 -0700 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2017-11-22 23:09:51 +0100 |
commit | b13d7c7d2609ae32cb8fd4931eee12084e7b77b3 (patch) | |
tree | efa4951f17d5b4616f3729a8bdd1353e6db8d6a1 /source | |
parent | c2d7be0947d2c7d730f84270149cf3c3c6180a55 (diff) | |
download | mupdf-b13d7c7d2609ae32cb8fd4931eee12084e7b77b3.tar.xz |
jni: Make sure to dirty annotation whenever it changes.
Diffstat (limited to 'source')
-rw-r--r-- | source/pdf/pdf-annot-edit.c | 20 | ||||
-rw-r--r-- | source/pdf/pdf-annot.c | 24 | ||||
-rw-r--r-- | source/pdf/pdf-appearance.c | 2 | ||||
-rw-r--r-- | source/pdf/pdf-form.c | 8 |
4 files changed, 40 insertions, 14 deletions
diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c index d0ad0915..20aeff11 100644 --- a/source/pdf/pdf-annot-edit.c +++ b/source/pdf/pdf-annot-edit.c @@ -232,7 +232,7 @@ pdf_set_annot_flags(fz_context *ctx, pdf_annot *annot, int flags) { pdf_document *doc = annot->page->doc; pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_F, pdf_new_int(ctx, doc, flags)); - annot->changed = 1; + pdf_dirty_annot(ctx, annot); } void @@ -256,7 +256,7 @@ pdf_set_annot_rect(fz_context *ctx, pdf_annot *annot, const fz_rect *rect) fz_transform_rect(&trect, &inv_page_ctm); pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_Rect, pdf_new_rect(ctx, doc, &trect)); - annot->changed = 1; + pdf_dirty_annot(ctx, annot); } const char * @@ -270,7 +270,7 @@ pdf_set_annot_contents(fz_context *ctx, pdf_annot *annot, const char *text) { pdf_document *doc = annot->page->doc; pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_Contents, pdf_new_string(ctx, doc, text, strlen(text))); - annot->changed = 1; + pdf_dirty_annot(ctx, annot); } static pdf_obj *open_subtypes[] = { @@ -300,6 +300,7 @@ pdf_set_annot_is_open(fz_context *ctx, pdf_annot *annot, int is_open) check_allowed_subtypes(ctx, annot, PDF_NAME_Open, open_subtypes); pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_Open, pdf_new_bool(ctx, doc, is_open)); + pdf_dirty_annot(ctx, annot); } static pdf_obj *icon_name_subtypes[] = { @@ -329,6 +330,7 @@ pdf_set_annot_icon_name(fz_context *ctx, pdf_annot *annot, const char *name) pdf_document *doc = annot->page->doc; check_allowed_subtypes(ctx, annot, PDF_NAME_Name, icon_name_subtypes); pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_Name, pdf_new_name(ctx, doc, name)); + pdf_dirty_annot(ctx, annot); } static int line_ending_value(fz_context *ctx, pdf_obj *line_ending) @@ -398,6 +400,7 @@ pdf_set_annot_line_ending_styles(fz_context *ctx, pdf_annot *annot, int start_st pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_LE, style); pdf_array_put_drop(ctx, style, 0, line_ending_name(ctx, start_style)); pdf_array_put_drop(ctx, style, 1, line_ending_name(ctx, end_style)); + pdf_dirty_annot(ctx, annot); } float @@ -428,8 +431,7 @@ pdf_set_annot_border(fz_context *ctx, pdf_annot *annot, float w) /* Remove border style and effect dictionaries so they won't interfere. */ pdf_dict_del(ctx, annot->obj, PDF_NAME_BS); pdf_dict_del(ctx, annot->obj, PDF_NAME_BE); - - annot->changed = 1; + pdf_dirty_annot(ctx, annot); } static void pdf_annot_color_imp(fz_context *ctx, pdf_annot *annot, pdf_obj *key, int *n, float color[4], pdf_obj **allowed) @@ -521,7 +523,7 @@ static void pdf_set_annot_color_imp(fz_context *ctx, pdf_annot *annot, pdf_obj * } pdf_dict_put_drop(ctx, annot->obj, key, arr); - annot->changed = 1; + pdf_dirty_annot(ctx, annot); } void @@ -630,7 +632,7 @@ pdf_set_annot_vertices(fz_context *ctx, pdf_annot *annot, int n, const float *v) pdf_array_push_drop(ctx, vertices, pdf_new_real(ctx, doc, point.y)); } pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_Vertices, vertices); - annot->changed = 1; + pdf_dirty_annot(ctx, annot); } static pdf_obj *quad_point_subtypes[] = { @@ -708,7 +710,7 @@ pdf_set_annot_quad_points(fz_context *ctx, pdf_annot *annot, int n, const float } } pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_QuadPoints, quad_points); - annot->changed = 1; + pdf_dirty_annot(ctx, annot); } static pdf_obj *ink_list_subtypes[] = { @@ -799,7 +801,7 @@ pdf_set_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, const int *coun pdf_array_push_drop(ctx, ink_list, stroke); } pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_InkList, ink_list); - annot->changed = 1; + pdf_dirty_annot(ctx, annot); } static void find_free_font_name(fz_context *ctx, pdf_obj *fdict, char *buf, int buf_size) diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c index 56681424..7046ff18 100644 --- a/source/pdf/pdf-annot.c +++ b/source/pdf/pdf-annot.c @@ -557,3 +557,27 @@ pdf_bound_annot(fz_context *ctx, pdf_annot *annot, fz_rect *rect) fz_transform_rect(rect, &page_ctm); return rect; } + +void +pdf_dirty_annot(fz_context *ctx, pdf_annot *annot) +{ + if (annot) + { + annot->dirty = 1; + if (annot->page && annot->page->doc) + annot->page->doc->dirty = 1; + } +} + +void +pdf_clean_annot(fz_context *ctx, pdf_annot *annot) +{ + if (annot) + annot->dirty = 0; +} + +int +pdf_annot_is_dirty(fz_context *ctx, pdf_annot *annot) +{ + return annot ? annot->dirty: 0; +} diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c index db99adae..70f684f4 100644 --- a/source/pdf/pdf-appearance.c +++ b/source/pdf/pdf-appearance.c @@ -1645,7 +1645,7 @@ void pdf_set_annot_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *ann pdf_drop_xobject(ctx, xobj); } - doc->dirty = 1; + pdf_dirty_annot(ctx, annot); } static fz_point * diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c index 09b8258e..95b0da54 100644 --- a/source/pdf/pdf-form.c +++ b/source/pdf/pdf-form.c @@ -643,11 +643,11 @@ void pdf_update_page(fz_context *ctx, pdf_page *page) { pdf_annot *annot; - /* Reset changed_annots to empty */ + /* Mark all dirty annots as clean */ for (annot = page->annots; annot; annot = annot->next) - annot->changed = 0; + pdf_clean_annot(ctx, annot); - /* Flag all changed annots */ + /* Flag all dirty annots */ for (annot = page->annots; annot; annot = annot->next) { pdf_xobject *ap = pdf_keep_xobject(ctx, annot->ap); @@ -657,7 +657,7 @@ void pdf_update_page(fz_context *ctx, pdf_page *page) { pdf_update_annot(ctx, annot); if ((ap != annot->ap || ap_iteration != annot->ap_iteration)) - annot->changed = 1; + pdf_dirty_annot(ctx, annot); } fz_always(ctx) pdf_drop_xobject(ctx, ap); |