diff options
author | Paul Gardiner <paulg.artifex@glidos.net> | 2012-08-02 15:32:33 +0100 |
---|---|---|
committer | Paul Gardiner <paulg.artifex@glidos.net> | 2012-08-02 15:32:33 +0100 |
commit | 8068b7ba7ac0f103f4770736518fe7e545ceba30 (patch) | |
tree | 1a59b6679afa111bbf61c57d60c873824d977636 | |
parent | 201eeb77a65b25263daf8015746a0127692b87df (diff) | |
download | mupdf-8068b7ba7ac0f103f4770736518fe7e545ceba30.tar.xz |
Forms: add document dirty flag
-rw-r--r-- | fitz/doc_interactive.c | 5 | ||||
-rw-r--r-- | fitz/fitz.h | 6 | ||||
-rw-r--r-- | pdf/mupdf-internal.h | 2 | ||||
-rw-r--r-- | pdf/pdf_form.c | 9 | ||||
-rw-r--r-- | pdf/pdf_repair.c | 2 | ||||
-rw-r--r-- | pdf/pdf_write.c | 2 |
6 files changed, 26 insertions, 0 deletions
diff --git a/fitz/doc_interactive.c b/fitz/doc_interactive.c index d7bc954d..61f2f4f1 100644 --- a/fitz/doc_interactive.c +++ b/fitz/doc_interactive.c @@ -6,6 +6,11 @@ to indirect through function pointers. */ +int fz_has_unsaved_changes(fz_interactive *idoc) +{ + return pdf_has_unsaved_changes((pdf_document*)idoc); +} + int fz_pass_event(fz_interactive *idoc, fz_page *page, fz_ui_event *ui_event) { return pdf_pass_event((pdf_document*)idoc, (pdf_page*)page, ui_event); diff --git a/fitz/fitz.h b/fitz/fitz.h index 595dc2e4..6a9f7e0a 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -2410,6 +2410,12 @@ typedef struct fz_widget_s fz_widget; fz_interactive *fz_interact(fz_document *doc); /* + Determine whether changes have been made since the + document was opened or last saved. +*/ +int fz_has_unsaved_changes(fz_interactive *idoc); + +/* fz_pass_event: Pass a UI event to an interactive document. diff --git a/pdf/mupdf-internal.h b/pdf/mupdf-internal.h index 62747538..8422fce3 100644 --- a/pdf/mupdf-internal.h +++ b/pdf/mupdf-internal.h @@ -226,6 +226,7 @@ struct pdf_document_s pdf_js *js; int recalculating; + int dirty; }; pdf_document *pdf_open_document_no_run(fz_context *ctx, const char *filename); @@ -604,6 +605,7 @@ void pdf_remove_item(fz_context *ctx, fz_store_free_fn *free, pdf_obj *key); /* * PDF interaction interface */ +int pdf_has_unsaved_changes(pdf_document *doc); int pdf_pass_event(pdf_document *doc, pdf_page *page, fz_ui_event *ui_event); fz_rect *pdf_get_screen_update(pdf_document *doc); fz_widget *pdf_get_focussed_widget(pdf_document *doc); diff --git a/pdf/pdf_form.c b/pdf/pdf_form.c index d74316fa..d1ca8474 100644 --- a/pdf/pdf_form.c +++ b/pdf/pdf_form.c @@ -1387,6 +1387,8 @@ static void reset_field(pdf_document *doc, pdf_obj *obj) { fz_context *ctx = doc->ctx; + doc->dirty = 1; + switch (pdf_field_getType(doc, obj)) { case FZ_WIDGET_TYPE_RADIOBUTTON: @@ -1670,6 +1672,11 @@ static void toggle_check_box(pdf_document *doc, pdf_obj *obj) /* FIXME: should probably update the V entry in the field dictionary too */ } +int pdf_has_unsaved_changes(pdf_document *doc) +{ + return doc->dirty; +} + int pdf_pass_event(pdf_document *doc, pdf_page *page, fz_ui_event *ui_event) { pdf_annot *annot; @@ -1826,6 +1833,8 @@ static void recalculate(pdf_document *doc) void pdf_field_setValue(pdf_document *doc, pdf_obj *field, char *text) { + doc->dirty = 1; + update_text_field_value(doc->ctx, field, text); recalculate(doc); pdf_field_mark_dirty(doc->ctx, field); diff --git a/pdf/pdf_repair.c b/pdf/pdf_repair.c index 0874c2f8..bfbc581e 100644 --- a/pdf/pdf_repair.c +++ b/pdf/pdf_repair.c @@ -228,6 +228,8 @@ pdf_repair_xref(pdf_document *xref, pdf_lexbuf *buf) fz_var(info); fz_var(list); + xref->dirty = 1; + fz_seek(xref->file, 0, 0); fz_try(ctx) diff --git a/pdf/pdf_write.c b/pdf/pdf_write.c index 76f19748..9c5c5a53 100644 --- a/pdf/pdf_write.c +++ b/pdf/pdf_write.c @@ -2177,6 +2177,8 @@ void pdf_write_document(pdf_document *xref, char *filename, fz_write_options *fz } writexref(xref, &opts, 0, xref->len, !opts.do_linear, 0, opts.first_xref_offset); + + xref->dirty = 0; } fz_always(ctx) { |