From 0abcccc4aab4d893ac2a0ef116ff1f0c006fbc30 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 6 Jul 2018 14:20:26 +0200 Subject: Rejig pdf_update_page and pdf_update_annot. The intent is for a user to iterate over the annotations on a page calling pdf_update_annot for each one. If this function returns true, then the annotation has changed since the last time it was called, and the user needs to re-render. pdf_update_page is a simple loop over the annotations on a page, for use if you only care about page level granularity. Users should no longer look at or change the pdf_annot.has_new_ap field. --- include/mupdf/pdf/annot.h | 36 +++++++++++++++++++++++++++++++++--- include/mupdf/pdf/document.h | 20 -------------------- 2 files changed, 33 insertions(+), 23 deletions(-) (limited to 'include') diff --git a/include/mupdf/pdf/annot.h b/include/mupdf/pdf/annot.h index 5a97c4d5..adaf51c6 100644 --- a/include/mupdf/pdf/annot.h +++ b/include/mupdf/pdf/annot.h @@ -134,7 +134,6 @@ fz_link *pdf_load_link_annots(fz_context *ctx, pdf_document *, pdf_obj *annots, fz_matrix pdf_annot_transform(fz_context *ctx, pdf_annot *annot); void pdf_load_annots(fz_context *ctx, pdf_page *page, pdf_obj *annots); -void pdf_update_annot(fz_context *ctx, pdf_annot *annot); void pdf_drop_annots(fz_context *ctx, pdf_annot *annot_list); /* @@ -261,10 +260,41 @@ void pdf_set_annot_default_appearance(fz_context *ctx, pdf_annot *annot, const c pdf_new_annot: Internal function for creating a new pdf annotation. */ pdf_annot *pdf_new_annot(fz_context *ctx, pdf_page *page, pdf_obj *obj); - -void pdf_update_appearance(fz_context *ctx, pdf_annot *annot); void pdf_dirty_annot(fz_context *ctx, pdf_annot *annot); +/* + Recreate the appearance stream for an annotation. +*/ +void pdf_update_appearance(fz_context *ctx, pdf_annot *annot); void pdf_update_signature_appearance(fz_context *ctx, pdf_annot *annot, const char *name, const char *text, const char *date); +/* + Regenerate any appearance streams that are out of date and check for + cases where a different appearance stream should be selected because of + state changes. + + Note that a call to pdf_pass_event for one page may lead to changes on + any other, so an app should call pdf_update_annot for every annotation + it currently displays. Also it is important that the pdf_annot object + is the one used to last render the annotation. If instead the app were + to drop the page or annotations and reload them then a call to + pdf_update_annot would not reliably be able to report all changed + annotations. + + Returns true if the annotation appearance has changed since the last time + pdf_update_annot was called or the annotation was first loaded. +*/ +int pdf_update_annot(fz_context *ctx, pdf_annot *annot); + +/* + Loop through all annotations on the page and update them. Return true + if any of them were changed (by either event or javascript actions, or + by annotation editing) and need re-rendering. + + If you need more granularity, loop through the annotations and call + pdf_update_annot for each one to detect changes on a per-annotation + basis. +*/ +int pdf_update_page(fz_context *ctx, pdf_page *page); + #endif diff --git a/include/mupdf/pdf/document.h b/include/mupdf/pdf/document.h index 24e3aaed..9e9121df 100644 --- a/include/mupdf/pdf/document.h +++ b/include/mupdf/pdf/document.h @@ -513,26 +513,6 @@ int pdf_add_portfolio_entry(fz_context *ctx, pdf_document *doc, */ void pdf_set_portfolio_entry_info(fz_context *ctx, pdf_document *doc, int entry, int schema_entry, pdf_obj *data); -/* - pdf_update_page: Update a page for the sake of changes caused by a call - to pdf_pass_event or annotation editing functions. - - pdf_update_page regenerates any appearance streams that are out of - date, checks for cases where different appearance streams should be - selected because of state changes, and records internally each - annotation that has changed appearance. - - Each annotation that has changed has its has_new_ap flag set to true. - - Note that a call to pdf_pass_event for one page may lead to changes on - any other, so an app should call pdf_update_page for every page it - currently displays. Also it is important that the pdf_page object is - the one used to last render the page. If instead the app were to drop - the page and reload it then a call to pdf_update_page would not - reliably be able to report all changed areas. -*/ -int pdf_update_page(fz_context *ctx, pdf_page *page); - /* Determine whether changes have been made since the document was opened or last saved. -- cgit v1.2.3