void pdf_drop_annots(fz_context *ctx, pdf_annot *annot) { while (annot) { pdf_annot *next = annot->next; fz_drop_annot(ctx, &annot->super); annot = next; } }
void pdf_delete_annot(fz_context *ctx, pdf_page *page, pdf_annot *annot) { pdf_document *doc = annot->page->doc; pdf_annot **annotptr; pdf_obj *annot_arr; int i; if (annot == NULL) return; /* Remove annot from page's list */ for (annotptr = &page->annots; *annotptr; annotptr = &(*annotptr)->next) { if (*annotptr == annot) break; } /* Check the passed annotation was of this page */ if (*annotptr == NULL) return; *annotptr = annot->next; /* If the removed annotation was the last in the list adjust the end pointer */ if (*annotptr == NULL) page->annot_tailp = annotptr; /* If the removed annotation has the focus, blur it. */ if (doc->focus == annot) { doc->focus = NULL; doc->focus_obj = NULL; } /* Remove the annot from the "Annots" array. */ annot_arr = pdf_dict_get(ctx, page->obj, PDF_NAME_Annots); i = pdf_array_find(ctx, annot_arr, annot->obj); if (i >= 0) pdf_array_delete(ctx, annot_arr, i); /* The garbage collection pass when saving will remove the annot object, * removing it here may break files if multiple pages use the same annot. */ /* And free it. */ fz_drop_annot(ctx, &annot->super); doc->dirty = 1; }