summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/pdf/annot.h5
-rw-r--r--source/pdf/pdf-annot-edit.c3
-rw-r--r--source/pdf/pdf-annot.c26
3 files changed, 22 insertions, 12 deletions
diff --git a/include/mupdf/pdf/annot.h b/include/mupdf/pdf/annot.h
index e25ec5db..7daad6a0 100644
--- a/include/mupdf/pdf/annot.h
+++ b/include/mupdf/pdf/annot.h
@@ -137,4 +137,9 @@ fz_annot_type pdf_annot_obj_type(fz_context *ctx, pdf_obj *obj);
*/
pdf_annot *pdf_poll_changed_annot(fz_context *ctx, pdf_document *idoc, pdf_page *page);
+/*
+ pdf_new_annot: Internal function for creating a new pdf annotation.
+*/
+pdf_annot *pdf_new_annot(fz_context *ctx, pdf_page *page);
+
#endif
diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c
index 66704a2f..c8594be1 100644
--- a/source/pdf/pdf-annot-edit.c
+++ b/source/pdf/pdf-annot-edit.c
@@ -117,8 +117,7 @@ pdf_create_annot(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_annot_ty
/* Make printable as default */
pdf_dict_put_drop(ctx, annot_obj, PDF_NAME_F, pdf_new_int(ctx, doc, F_Print));
- annot = fz_malloc_struct(ctx, pdf_annot);
- annot->page = page;
+ annot = pdf_new_annot(ctx, page);
annot->rect = rect;
annot->pagerect = rect;
annot->ap = NULL;
diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c
index 5261bdb0..efae4cd3 100644
--- a/source/pdf/pdf-annot.c
+++ b/source/pdf/pdf-annot.c
@@ -481,6 +481,20 @@ fz_annot_type pdf_annot_obj_type(fz_context *ctx, pdf_obj *obj)
return -1;
}
+pdf_annot *pdf_new_annot(fz_context *ctx, pdf_page *page)
+{
+ pdf_annot *annot = fz_new_annot(ctx, sizeof(pdf_annot));
+
+ annot->super.drop_annot_imp = (fz_annot_drop_imp_fn*)pdf_drop_annot_imp;
+ annot->super.bound_annot = (fz_annot_bound_fn*)pdf_bound_annot;
+ annot->super.run_annot = (fz_annot_run_fn*)pdf_run_annot;
+ annot->super.next_annot = (fz_annot_next_fn*)pdf_next_annot;
+
+ annot->page = page;
+
+ return annot;
+}
+
void
pdf_load_annots(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_obj *annots)
{
@@ -507,17 +521,9 @@ pdf_load_annots(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_obj *ann
{
obj = pdf_array_get(ctx, annots, i);
- annot = fz_new_annot(ctx, sizeof(pdf_annot));
- annot->super.drop_annot_imp = (fz_annot_drop_imp_fn*)pdf_drop_annot_imp;
- annot->super.bound_annot = (fz_annot_bound_fn*)pdf_bound_annot;
- annot->super.run_annot = (fz_annot_run_fn*)pdf_run_annot;
- annot->super.next_annot = (fz_annot_next_fn*)pdf_next_annot;
-
- annot->page = page;
- annot->obj = pdf_keep_obj(ctx, obj);
- annot->next = NULL;
-
+ annot = pdf_new_annot(ctx, page);
*itr = annot;
+ annot->obj = pdf_keep_obj(ctx, obj);
itr = &annot->next;
}
}