summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-appearance.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-09-22 16:00:21 +0200
committerTor Andersson <tor.andersson@artifex.com>2016-10-07 17:22:58 +0200
commit8e244f7e2add3606283c0c797d75067fd01ad740 (patch)
tree1d3d70646b637792865c0b14be37127eb5eef250 /source/pdf/pdf-appearance.c
parent170f35a5802ec7093b00fb2e39bbde3756516f15 (diff)
downloadmupdf-8e244f7e2add3606283c0c797d75067fd01ad740.tar.xz
Remove separate tmp/deleted/changed annotation lists.
Use a flag in the pdf_annot struct instead. Don't pass pdf_document to annotation edit functions.
Diffstat (limited to 'source/pdf/pdf-appearance.c')
-rw-r--r--source/pdf/pdf-appearance.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c
index f22c97c8..5982ca88 100644
--- a/source/pdf/pdf-appearance.c
+++ b/source/pdf/pdf-appearance.c
@@ -2527,3 +2527,54 @@ void pdf_update_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *annot)
pdf_clean_obj(ctx, obj);
}
}
+
+void
+pdf_update_annot(fz_context *ctx, pdf_annot *annot)
+{
+ pdf_document *doc = annot->page->doc;
+ pdf_obj *obj, *ap, *as, *n;
+
+ if (doc->update_appearance)
+ doc->update_appearance(ctx, doc, annot);
+
+ obj = annot->obj;
+
+ ap = pdf_dict_get(ctx, obj, PDF_NAME_AP);
+ as = pdf_dict_get(ctx, obj, PDF_NAME_AS);
+
+ if (pdf_is_dict(ctx, ap))
+ {
+ pdf_hotspot *hp = &doc->hotspot;
+
+ n = NULL;
+
+ if (hp->num == pdf_to_num(ctx, obj) && (hp->state & HOTSPOT_POINTER_DOWN))
+ {
+ n = pdf_dict_get(ctx, ap, PDF_NAME_D); /* down state */
+ }
+
+ if (n == NULL)
+ n = pdf_dict_get(ctx, ap, PDF_NAME_N); /* normal state */
+
+ /* lookup current state in sub-dictionary */
+ 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, n))
+ {
+ fz_try(ctx)
+ {
+ annot->ap = pdf_load_xobject(ctx, doc, n);
+ annot->ap_iteration = annot->ap->iteration;
+ }
+ fz_catch(ctx)
+ {
+ fz_rethrow_if(ctx, FZ_ERROR_TRYLATER);
+ fz_warn(ctx, "ignoring broken annotation");
+ }
+ }
+ }
+}