void *pdf_find_item(fz_context *ctx, fz_store_drop_fn *drop, pdf_obj *key);
void pdf_remove_item(fz_context *ctx, fz_store_drop_fn *drop, pdf_obj *key);
void pdf_empty_store(fz_context *ctx, pdf_document *doc);
+void pdf_purge_locals_from_store(fz_context *ctx, pdf_document *doc);
/*
* Structures used for managing resource locations and avoiding multiple
if (doc->local_xref)
fz_write_printf(ctx, fz_stddbg(ctx), "pop and discard local_xref for annot\n");
#endif
+ pdf_purge_locals_from_store(ctx, doc);
--doc->local_xref_nesting;
assert(doc->local_xref_nesting == 0);
pdf_purge_local_font_resources(ctx, doc);
fz_throw(ctx, FZ_ERROR_GENERIC, "Can't undo/redo within an operation");
pdf_purge_local_font_resources(ctx, doc);
+ pdf_purge_locals_from_store(ctx, doc);
pdf_drop_local_xref(ctx, doc->local_xref);
doc->local_xref = NULL;
* to edit the document. This invalidates it, so
* throw it away. */
pdf_purge_local_font_resources(ctx, doc);
+ pdf_purge_locals_from_store(ctx, doc);
pdf_drop_local_xref(ctx, doc->local_xref);
doc->local_xref = NULL;
}
{
fz_filter_store(ctx, pdf_filter_store, doc, &pdf_obj_store_type);
}
+
+static int
+pdf_filter_locals(fz_context *ctx, void *doc_, void *key)
+{
+ pdf_document *doc = (pdf_document *)doc_;
+ pdf_obj *obj = (pdf_obj *)key;
+ pdf_document *key_doc = pdf_get_bound_document(ctx, obj);
+
+ return (doc == key_doc && pdf_is_local_object(ctx, doc, obj));
+}
+
+void pdf_purge_locals_from_store(fz_context *ctx, pdf_document *doc)
+{
+ fz_filter_store(ctx, pdf_filter_locals, doc, &pdf_obj_store_type);
+}
if (!pdf_is_indirect(ctx, obj))
return 0;
- if (xref == NULL || doc->local_xref_nesting == 0)
+ if (xref == NULL)
return 0; /* no local xref present */
num = pdf_to_num(ctx, obj);