From ca8f110730ad5aadbc80a450a46de62c4004cbd1 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 22 Sep 2016 14:01:31 +0200 Subject: Clean up annotation enum names. Put them in the PDF name space and separate words with underscores. Remove redundant namespace prefixes in java constants. Device.FLAG_MASK rather than Device.FZ_DEVFLAG_MASK. Use namespace for PDF annotation flag enum. --- source/pdf/pdf-annot-edit.c | 55 +++++++++++++++++++++++---------------------- source/pdf/pdf-annot.c | 50 ++++++++++++++++++++--------------------- source/pdf/pdf-appearance.c | 20 ++++++++--------- source/pdf/pdf-form.c | 26 ++++++++++----------- source/pdf/pdf-interpret.c | 6 ++--- 5 files changed, 79 insertions(+), 78 deletions(-) (limited to 'source') diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c index 9f7e74bd..32c3f353 100644 --- a/source/pdf/pdf-annot-edit.c +++ b/source/pdf/pdf-annot-edit.c @@ -6,31 +6,31 @@ static const char *annot_type_str(fz_annot_type type) { switch (type) { - case FZ_ANNOT_TEXT: return "Text"; - case FZ_ANNOT_LINK: return "Link"; - case FZ_ANNOT_FREETEXT: return "FreeText"; - case FZ_ANNOT_LINE: return "Line"; - case FZ_ANNOT_SQUARE: return "Square"; - case FZ_ANNOT_CIRCLE: return "Circle"; - case FZ_ANNOT_POLYGON: return "Polygon"; - case FZ_ANNOT_POLYLINE: return "PolyLine"; - case FZ_ANNOT_HIGHLIGHT: return "Highlight"; - case FZ_ANNOT_UNDERLINE: return "Underline"; - case FZ_ANNOT_SQUIGGLY: return "Squiggly"; - case FZ_ANNOT_STRIKEOUT: return "StrikeOut"; - case FZ_ANNOT_STAMP: return "Stamp"; - case FZ_ANNOT_CARET: return "Caret"; - case FZ_ANNOT_INK: return "Ink"; - case FZ_ANNOT_POPUP: return "Popup"; - case FZ_ANNOT_FILEATTACHMENT: return "FileAttachment"; - case FZ_ANNOT_SOUND: return "Sound"; - case FZ_ANNOT_MOVIE: return "Movie"; - case FZ_ANNOT_WIDGET: return "Widget"; - case FZ_ANNOT_SCREEN: return "Screen"; - case FZ_ANNOT_PRINTERMARK: return "PrinterMark"; - case FZ_ANNOT_TRAPNET: return "TrapNet"; - case FZ_ANNOT_WATERMARK: return "Watermark"; - case FZ_ANNOT_3D: return "3D"; + case PDF_ANNOT_TEXT: return "Text"; + case PDF_ANNOT_LINK: return "Link"; + case PDF_ANNOT_FREE_TEXT: return "FreeText"; + case PDF_ANNOT_LINE: return "Line"; + case PDF_ANNOT_SQUARE: return "Square"; + case PDF_ANNOT_CIRCLE: return "Circle"; + case PDF_ANNOT_POLYGON: return "Polygon"; + case PDF_ANNOT_POLY_LINE: return "PolyLine"; + case PDF_ANNOT_HIGHLIGHT: return "Highlight"; + case PDF_ANNOT_UNDERLINE: return "Underline"; + case PDF_ANNOT_SQUIGGLY: return "Squiggly"; + case PDF_ANNOT_STRIKE_OUT: return "StrikeOut"; + case PDF_ANNOT_STAMP: return "Stamp"; + case PDF_ANNOT_CARET: return "Caret"; + case PDF_ANNOT_INK: return "Ink"; + case PDF_ANNOT_POPUP: return "Popup"; + case PDF_ANNOT_FILE_ATTACHMENT: return "FileAttachment"; + case PDF_ANNOT_SOUND: return "Sound"; + case PDF_ANNOT_MOVIE: return "Movie"; + case PDF_ANNOT_WIDGET: return "Widget"; + case PDF_ANNOT_SCREEN: return "Screen"; + case PDF_ANNOT_PRINTER_MARK: return "PrinterMark"; + case PDF_ANNOT_TRAP_NET: return "TrapNet"; + case PDF_ANNOT_WATERMARK: return "Watermark"; + case PDF_ANNOT_3D: return "3D"; default: return ""; } } @@ -112,7 +112,7 @@ pdf_create_annot(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_annot_ty pdf_dict_put_drop(ctx, annot_obj, PDF_NAME_Rect, pdf_new_rect(ctx, doc, &rect)); /* Make printable as default */ - pdf_dict_put_drop(ctx, annot_obj, PDF_NAME_F, pdf_new_int(ctx, doc, F_Print)); + pdf_dict_put_drop(ctx, annot_obj, PDF_NAME_F, pdf_new_int(ctx, doc, PDF_ANNOT_IS_PRINT)); annot = pdf_new_annot(ctx, page); annot->ap = NULL; @@ -351,7 +351,7 @@ void pdf_set_text_annot_position(fz_context *ctx, pdf_document *doc, pdf_annot * pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_Rect, pdf_new_rect(ctx, doc, &rect)); flags = pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_F)); - flags |= (F_NoZoom|F_NoRotate); + flags |= (PDF_ANNOT_IS_NO_ZOOM|PDF_ANNOT_IS_NO_ROTATE); pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_F, pdf_new_int(ctx, doc, flags)); } @@ -372,6 +372,7 @@ const char *pdf_annot_author(fz_context *ctx, pdf_annot *annot) const char *pdf_annot_date(fz_context *ctx, pdf_annot *annot) { + // TODO: PDF_NAME_M return pdf_to_str_buf(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_CreationDate)); } diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c index acf81961..d1ca7de0 100644 --- a/source/pdf/pdf-annot.c +++ b/source/pdf/pdf-annot.c @@ -434,55 +434,55 @@ fz_annot_type pdf_annot_type(fz_context *ctx, pdf_annot *annot) pdf_obj *obj = annot->obj; pdf_obj *subtype = pdf_dict_get(ctx, obj, PDF_NAME_Subtype); if (pdf_name_eq(ctx, PDF_NAME_Text, subtype)) - return FZ_ANNOT_TEXT; + return PDF_ANNOT_TEXT; else if (pdf_name_eq(ctx, PDF_NAME_Link, subtype)) - return FZ_ANNOT_LINK; + return PDF_ANNOT_LINK; else if (pdf_name_eq(ctx, PDF_NAME_FreeText, subtype)) - return FZ_ANNOT_FREETEXT; + return PDF_ANNOT_FREE_TEXT; else if (pdf_name_eq(ctx, PDF_NAME_Line, subtype)) - return FZ_ANNOT_LINE; + return PDF_ANNOT_LINE; else if (pdf_name_eq(ctx, PDF_NAME_Square, subtype)) - return FZ_ANNOT_SQUARE; + return PDF_ANNOT_SQUARE; else if (pdf_name_eq(ctx, PDF_NAME_Circle, subtype)) - return FZ_ANNOT_CIRCLE; + return PDF_ANNOT_CIRCLE; else if (pdf_name_eq(ctx, PDF_NAME_Polygon, subtype)) - return FZ_ANNOT_POLYGON; + return PDF_ANNOT_POLYGON; else if (pdf_name_eq(ctx, PDF_NAME_PolyLine, subtype)) - return FZ_ANNOT_POLYLINE; + return PDF_ANNOT_POLY_LINE; else if (pdf_name_eq(ctx, PDF_NAME_Highlight, subtype)) - return FZ_ANNOT_HIGHLIGHT; + return PDF_ANNOT_HIGHLIGHT; else if (pdf_name_eq(ctx, PDF_NAME_Underline, subtype)) - return FZ_ANNOT_UNDERLINE; + return PDF_ANNOT_UNDERLINE; else if (pdf_name_eq(ctx, PDF_NAME_Squiggly, subtype)) - return FZ_ANNOT_SQUIGGLY; + return PDF_ANNOT_SQUIGGLY; else if (pdf_name_eq(ctx, PDF_NAME_StrikeOut, subtype)) - return FZ_ANNOT_STRIKEOUT; + return PDF_ANNOT_STRIKE_OUT; else if (pdf_name_eq(ctx, PDF_NAME_Stamp, subtype)) - return FZ_ANNOT_STAMP; + return PDF_ANNOT_STAMP; else if (pdf_name_eq(ctx, PDF_NAME_Caret, subtype)) - return FZ_ANNOT_CARET; + return PDF_ANNOT_CARET; else if (pdf_name_eq(ctx, PDF_NAME_Ink, subtype)) - return FZ_ANNOT_INK; + return PDF_ANNOT_INK; else if (pdf_name_eq(ctx, PDF_NAME_Popup, subtype)) - return FZ_ANNOT_POPUP; + return PDF_ANNOT_POPUP; else if (pdf_name_eq(ctx, PDF_NAME_FileAttachment, subtype)) - return FZ_ANNOT_FILEATTACHMENT; + return PDF_ANNOT_FILE_ATTACHMENT; else if (pdf_name_eq(ctx, PDF_NAME_Sound, subtype)) - return FZ_ANNOT_SOUND; + return PDF_ANNOT_SOUND; else if (pdf_name_eq(ctx, PDF_NAME_Movie, subtype)) - return FZ_ANNOT_MOVIE; + return PDF_ANNOT_MOVIE; else if (pdf_name_eq(ctx, PDF_NAME_Widget, subtype)) - return FZ_ANNOT_WIDGET; + return PDF_ANNOT_WIDGET; else if (pdf_name_eq(ctx, PDF_NAME_Screen, subtype)) - return FZ_ANNOT_SCREEN; + return PDF_ANNOT_SCREEN; else if (pdf_name_eq(ctx, PDF_NAME_PrinterMark, subtype)) - return FZ_ANNOT_PRINTERMARK; + return PDF_ANNOT_PRINTER_MARK; else if (pdf_name_eq(ctx, PDF_NAME_TrapNet, subtype)) - return FZ_ANNOT_TRAPNET; + return PDF_ANNOT_TRAP_NET; else if (pdf_name_eq(ctx, PDF_NAME_Watermark, subtype)) - return FZ_ANNOT_WATERMARK; + return PDF_ANNOT_WATERMARK; else if (pdf_name_eq(ctx, PDF_NAME_3D, subtype)) - return FZ_ANNOT_3D; + return PDF_ANNOT_3D; else return -1; } diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c index dadb04ce..f22c97c8 100644 --- a/source/pdf/pdf-appearance.c +++ b/source/pdf/pdf-appearance.c @@ -1534,7 +1534,7 @@ void pdf_update_text_markup_appearance(fz_context *ctx, pdf_document *doc, pdf_a switch (type) { - case FZ_ANNOT_HIGHLIGHT: + case PDF_ANNOT_HIGHLIGHT: color[0] = 1.0; color[1] = 1.0; color[2] = 0.0; @@ -1542,7 +1542,7 @@ void pdf_update_text_markup_appearance(fz_context *ctx, pdf_document *doc, pdf_a line_thickness = 1.0; line_height = 0.5; break; - case FZ_ANNOT_UNDERLINE: + case PDF_ANNOT_UNDERLINE: color[0] = 0.0; color[1] = 0.0; color[2] = 1.0; @@ -1550,7 +1550,7 @@ void pdf_update_text_markup_appearance(fz_context *ctx, pdf_document *doc, pdf_a line_thickness = LINE_THICKNESS; line_height = UNDERLINE_HEIGHT; break; - case FZ_ANNOT_STRIKEOUT: + case PDF_ANNOT_STRIKE_OUT: color[0] = 1.0; color[1] = 0.0; color[2] = 0.0; @@ -2458,7 +2458,7 @@ void pdf_update_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *annot) fz_annot_type type = pdf_annot_type(ctx, annot); switch (type) { - case FZ_ANNOT_WIDGET: + case PDF_ANNOT_WIDGET: switch (pdf_field_type(ctx, doc, obj)) { case PDF_WIDGET_TYPE_TEXT: @@ -2506,18 +2506,18 @@ void pdf_update_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *annot) break; } break; - case FZ_ANNOT_TEXT: + case PDF_ANNOT_TEXT: pdf_update_text_annot_appearance(ctx, doc, annot); break; - case FZ_ANNOT_FREETEXT: + case PDF_ANNOT_FREE_TEXT: pdf_update_free_text_annot_appearance(ctx, doc, annot); break; - case FZ_ANNOT_STRIKEOUT: - case FZ_ANNOT_UNDERLINE: - case FZ_ANNOT_HIGHLIGHT: + case PDF_ANNOT_STRIKE_OUT: + case PDF_ANNOT_UNDERLINE: + case PDF_ANNOT_HIGHLIGHT: pdf_update_text_markup_appearance(ctx, doc, annot, type); break; - case FZ_ANNOT_INK: + case PDF_ANNOT_INK: pdf_update_ink_appearance(ctx, doc, annot); break; default: diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c index 395703a9..045e1b86 100644 --- a/source/pdf/pdf-form.c +++ b/source/pdf/pdf-form.c @@ -600,7 +600,7 @@ int pdf_pass_event(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_ui_ev { int f = pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_F)); - if (f & (F_Hidden|F_NoView)) + if (f & (PDF_ANNOT_IS_HIDDEN|PDF_ANNOT_IS_NO_VIEW)) annot = NULL; } @@ -748,7 +748,7 @@ pdf_widget *pdf_first_widget(fz_context *ctx, pdf_document *doc, pdf_page *page) { pdf_annot *annot = page->annots; - while (annot && pdf_annot_type(ctx, annot) != FZ_ANNOT_WIDGET) + while (annot && pdf_annot_type(ctx, annot) != PDF_ANNOT_WIDGET) annot = annot->next; return (pdf_widget *)annot; @@ -761,7 +761,7 @@ pdf_widget *pdf_next_widget(fz_context *ctx, pdf_widget *previous) if (annot) annot = annot->next; - while (annot && pdf_annot_type(ctx, annot) != FZ_ANNOT_WIDGET) + while (annot && pdf_annot_type(ctx, annot) != PDF_ANNOT_WIDGET) annot = annot->next; return (pdf_widget *)annot; @@ -771,7 +771,7 @@ pdf_widget *pdf_create_widget(fz_context *ctx, pdf_document *doc, pdf_page *page { pdf_obj *form = NULL; int old_sigflags = pdf_to_int(ctx, pdf_dict_getp(ctx, pdf_trailer(ctx, doc), "Root/AcroForm/SigFlags")); - pdf_annot *annot = pdf_create_annot(ctx, doc, page, FZ_ANNOT_WIDGET); + pdf_annot *annot = pdf_create_annot(ctx, doc, page, PDF_ANNOT_WIDGET); fz_try(ctx) { @@ -815,7 +815,7 @@ pdf_widget *pdf_create_widget(fz_context *ctx, pdf_document *doc, pdf_page *page int pdf_widget_type(fz_context *ctx, pdf_widget *widget) { pdf_annot *annot = (pdf_annot *)widget; - if (pdf_annot_type(ctx, annot) == FZ_ANNOT_WIDGET) + if (pdf_annot_type(ctx, annot) == PDF_ANNOT_WIDGET) return pdf_field_type(ctx, pdf_get_bound_document(ctx, annot->obj), annot->obj); return PDF_WIDGET_TYPE_NOT_WIDGET; } @@ -1000,18 +1000,18 @@ int pdf_field_display(fz_context *ctx, pdf_document *doc, pdf_obj *field) f = pdf_to_int(ctx, pdf_dict_get(ctx, field, PDF_NAME_F)); - if (f & F_Hidden) + if (f & PDF_ANNOT_IS_HIDDEN) { res = Display_Hidden; } - else if (f & F_Print) + else if (f & PDF_ANNOT_IS_PRINT) { - if (f & F_NoView) + if (f & PDF_ANNOT_IS_NO_VIEW) res = Display_NoView; } else { - if (f & F_NoView) + if (f & PDF_ANNOT_IS_NO_VIEW) res = Display_Hidden; else res = Display_NoPrint; @@ -1070,20 +1070,20 @@ void pdf_field_set_display(fz_context *ctx, pdf_document *doc, pdf_obj *field, i if (!kids) { - int mask = (F_Hidden|F_Print|F_NoView); + int mask = (PDF_ANNOT_IS_HIDDEN|PDF_ANNOT_IS_PRINT|PDF_ANNOT_IS_NO_VIEW); int f = pdf_to_int(ctx, pdf_dict_get(ctx, field, PDF_NAME_F)) & ~mask; pdf_obj *fo = NULL; switch (d) { case Display_Visible: - f |= F_Print; + f |= PDF_ANNOT_IS_PRINT; break; case Display_Hidden: - f |= F_Hidden; + f |= PDF_ANNOT_IS_HIDDEN; break; case Display_NoView: - f |= (F_Print|F_NoView); + f |= (PDF_ANNOT_IS_PRINT|PDF_ANNOT_IS_NO_VIEW); break; case Display_NoPrint: break; diff --git a/source/pdf/pdf-interpret.c b/source/pdf/pdf-interpret.c index 00c4176c..0ae4844a 100644 --- a/source/pdf/pdf-interpret.c +++ b/source/pdf/pdf-interpret.c @@ -1254,14 +1254,14 @@ pdf_process_annot(fz_context *ctx, pdf_processor *proc, pdf_document *doc, pdf_p { int flags = pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_F)); - if (flags & (F_Invisible | F_Hidden)) + if (flags & (PDF_ANNOT_IS_INVISIBLE | PDF_ANNOT_IS_HIDDEN)) return; if (proc->event) { - if (!strcmp(proc->event, "Print") && !(flags & F_Print)) + if (!strcmp(proc->event, "Print") && !(flags & PDF_ANNOT_IS_PRINT)) return; - if (!strcmp(proc->event, "View") && (flags & F_NoView)) + if (!strcmp(proc->event, "View") && (flags & PDF_ANNOT_IS_NO_VIEW)) return; } -- cgit v1.2.3