diff options
-rw-r--r-- | fitz/doc_interactive.c | 5 | ||||
-rw-r--r-- | fitz/fitz-internal.h | 5 | ||||
-rw-r--r-- | fitz/fitz.h | 34 | ||||
-rw-r--r-- | pdf/mupdf-internal.h | 3 | ||||
-rw-r--r-- | pdf/mupdf.h | 5 | ||||
-rw-r--r-- | pdf/pdf_annot.c | 71 | ||||
-rw-r--r-- | pdf/pdf_form.c | 8 |
7 files changed, 119 insertions, 12 deletions
diff --git a/fitz/doc_interactive.c b/fitz/doc_interactive.c index ea08577d..db9fce87 100644 --- a/fitz/doc_interactive.c +++ b/fitz/doc_interactive.c @@ -81,6 +81,11 @@ void fz_choice_widget_set_value(fz_interactive *idoc, fz_widget *tw, int n, char pdf_choice_widget_set_value((pdf_document *)idoc, tw, n, opts); } +fz_annot_type fz_get_annot_type(fz_annot *annot) +{ + return pdf_annot_type((pdf_annot *)annot); +} + fz_annot *fz_create_annot(fz_interactive *idoc, fz_page *page, fz_annot_type type) { return (fz_annot *)pdf_create_annot((pdf_document *)idoc, (pdf_page *)page, type); diff --git a/fitz/fitz-internal.h b/fitz/fitz-internal.h index 75283a49..0c801ed2 100644 --- a/fitz/fitz-internal.h +++ b/fitz/fitz-internal.h @@ -1193,11 +1193,6 @@ fz_pixmap *fz_render_stroked_glyph(fz_context *ctx, fz_font*, int, const fz_matr void fz_render_t3_glyph_direct(fz_context *ctx, fz_device *dev, fz_font *font, int gid, const fz_matrix *trm, void *gstate, int nestedDepth); void fz_prepare_t3_glyph(fz_context *ctx, fz_font *font, int gid, int nestedDepth); -typedef enum -{ - FZ_ANNOT_STRIKEOUT -} fz_annot_type; - /* fz_create_annot: create a new annotation of the specified type on the specified page. The returned pdf_annot structure is owned by the page diff --git a/fitz/fitz.h b/fitz/fitz.h index 156d271c..4c7022d4 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -2512,6 +2512,40 @@ fz_rect *fz_bound_page(fz_document *doc, fz_page *page, fz_rect *rect); */ typedef struct fz_annot_s fz_annot; +typedef enum +{ + FZ_ANNOT_TEXT, + FZ_ANNOT_LINK, + FZ_ANNOT_FREETEXT, + FZ_ANNOT_LINE, + FZ_ANNOT_SQUARE, + FZ_ANNOT_CIRCLE, + FZ_ANNOT_POLYGON, + FZ_ANNOT_POLYLINE, + FZ_ANNOT_HIGHLIGHT, + FZ_ANNOT_UNDERLINE, + FZ_ANNOT_SQUIGGLY, + FZ_ANNOT_STRIKEOUT, + FZ_ANNOT_STAMP, + FZ_ANNOT_CARET, + FZ_ANNOT_INK, + FZ_ANNOT_POPUP, + FZ_ANNOT_FILEATTACHMENT, + FZ_ANNOT_SOUND, + FZ_ANNOT_MOVIE, + FZ_ANNOT_WIDGET, + FZ_ANNOT_SCREEN, + FZ_ANNOT_PRINTERMARK, + FZ_ANNOT_TRAPNET, + FZ_ANNOT_WATERMARK, + FZ_ANNOT_3D +} fz_annot_type; + +/* + fz_get_annot_type: return the type of an annotation +*/ +fz_annot_type fz_get_annot_type(fz_annot *annot); + /* fz_first_annot: Return a pointer to the first annotation on a page. diff --git a/pdf/mupdf-internal.h b/pdf/mupdf-internal.h index 0c070206..0a468939 100644 --- a/pdf/mupdf-internal.h +++ b/pdf/mupdf-internal.h @@ -503,7 +503,8 @@ struct pdf_annot_s fz_matrix matrix; pdf_annot *next; pdf_annot *next_changed; - int type; + int annot_type; + int widget_type; }; fz_link_dest pdf_parse_link_dest(pdf_document *doc, pdf_obj *dest); diff --git a/pdf/mupdf.h b/pdf/mupdf.h index 83710b84..9dbafc91 100644 --- a/pdf/mupdf.h +++ b/pdf/mupdf.h @@ -272,6 +272,11 @@ pdf_annot *pdf_next_annot(pdf_document *doc, pdf_annot *annot); fz_rect *pdf_bound_annot(pdf_document *doc, pdf_annot *annot, fz_rect *rect); /* + pdf_annot_type: Return the type of an annotation +*/ +fz_annot_type pdf_annot_type(pdf_annot *annot); + +/* pdf_run_page: Interpret a loaded page and render it on a device. page: A page loaded by pdf_load_page. diff --git a/pdf/pdf_annot.c b/pdf/pdf_annot.c index 5b152592..7201045f 100644 --- a/pdf/pdf_annot.c +++ b/pdf/pdf_annot.c @@ -356,6 +356,63 @@ pdf_transform_annot(pdf_annot *annot) fz_pre_scale(fz_translate(&annot->matrix, x, y), w, h); } +static int annot_type(pdf_obj *obj) +{ + char *subtype = pdf_to_name(pdf_dict_gets(obj, "Subtype")); + if (!strcmp(subtype, "Text")) + return FZ_ANNOT_TEXT; + else if (!strcmp(subtype, "Link")) + return FZ_ANNOT_LINK; + else if (!strcmp(subtype, "FreeText")) + return FZ_ANNOT_FREETEXT; + else if (!strcmp(subtype, "Line")) + return FZ_ANNOT_LINE; + else if (!strcmp(subtype, "Square")) + return FZ_ANNOT_SQUARE; + else if (!strcmp(subtype, "Circle")) + return FZ_ANNOT_CIRCLE; + else if (!strcmp(subtype, "Polygon")) + return FZ_ANNOT_POLYGON; + else if (!strcmp(subtype, "PolyLine")) + return FZ_ANNOT_POLYLINE; + else if (!strcmp(subtype, "Highlight")) + return FZ_ANNOT_HIGHLIGHT; + else if (!strcmp(subtype, "Underline")) + return FZ_ANNOT_UNDERLINE; + else if (!strcmp(subtype, "Squiggly")) + return FZ_ANNOT_SQUIGGLY; + else if (!strcmp(subtype, "StrikeOut")) + return FZ_ANNOT_STRIKEOUT; + else if (!strcmp(subtype, "Stamp")) + return FZ_ANNOT_STAMP; + else if (!strcmp(subtype, "Caret")) + return FZ_ANNOT_CARET; + else if (!strcmp(subtype, "Ink")) + return FZ_ANNOT_INK; + else if (!strcmp(subtype, "Popup")) + return FZ_ANNOT_POPUP; + else if (!strcmp(subtype, "FileAttachment")) + return FZ_ANNOT_FILEATTACHMENT; + else if (!strcmp(subtype, "Sound")) + return FZ_ANNOT_SOUND; + else if (!strcmp(subtype, "Movie")) + return FZ_ANNOT_MOVIE; + else if (!strcmp(subtype, "Widget")) + return FZ_ANNOT_WIDGET; + else if (!strcmp(subtype, "Screen")) + return FZ_ANNOT_SCREEN; + else if (!strcmp(subtype, "PrinterMark")) + return FZ_ANNOT_PRINTERMARK; + else if (!strcmp(subtype, "TrapNet")) + return FZ_ANNOT_TRAPNET; + else if (!strcmp(subtype, "Watermark")) + return FZ_ANNOT_WATERMARK; + else if (!strcmp(subtype, "3D")) + return FZ_ANNOT_3D; + else + return -1; +} + pdf_annot * pdf_load_annots(pdf_document *xref, pdf_obj *annots, pdf_page *page) { @@ -419,7 +476,8 @@ pdf_load_annots(pdf_document *xref, pdf_obj *annots, pdf_page *page) annot->pagerect = annot->rect; fz_transform_rect(&annot->pagerect, &page->ctm); annot->ap = NULL; - annot->type = pdf_field_type(xref, obj); + annot->annot_type = annot_type(obj); + annot->widget_type = annot->annot_type == FZ_ANNOT_WIDGET ? pdf_field_type(xref, obj) : FZ_WIDGET_TYPE_NOT_WIDGET; if (pdf_is_stream(xref, pdf_to_num(n), pdf_to_gen(n))) { @@ -528,6 +586,12 @@ pdf_bound_annot(pdf_document *doc, pdf_annot *annot, fz_rect *rect) return rect; } +fz_annot_type +pdf_annot_type(pdf_annot *annot) +{ + return annot->annot_type; +} + pdf_annot * pdf_create_annot(pdf_document *doc, pdf_page *page, fz_annot_type type) { @@ -557,6 +621,8 @@ pdf_create_annot(pdf_document *doc, pdf_page *page, fz_annot_type type) case FZ_ANNOT_STRIKEOUT: type_str = "StrikeOut"; break; + default: + break; } pdf_dict_puts_drop(annot_obj, "Subtype", pdf_new_name(ctx, type_str)); @@ -568,7 +634,8 @@ pdf_create_annot(pdf_document *doc, pdf_page *page, fz_annot_type type) annot->rect = rect; annot->pagerect = rect; annot->ap = NULL; - annot->type = FZ_WIDGET_TYPE_NOT_WIDGET; + annot->widget_type = FZ_WIDGET_TYPE_NOT_WIDGET; + annot->annot_type = type; /* Both annotation object and annotation structure are now created. diff --git a/pdf/pdf_form.c b/pdf/pdf_form.c index c57608c0..eddf2326 100644 --- a/pdf/pdf_form.c +++ b/pdf/pdf_form.c @@ -2131,7 +2131,7 @@ int pdf_pass_event(pdf_document *doc, pdf_page *page, fz_ui_event *ui_event) if (annot) { - switch(annot->type) + switch(annot->widget_type) { case FZ_WIDGET_TYPE_RADIOBUTTON: case FZ_WIDGET_TYPE_CHECKBOX: @@ -2206,7 +2206,7 @@ fz_widget *pdf_first_widget(pdf_document *doc, pdf_page *page) { pdf_annot *annot = page->annots; - while (annot && annot->type == FZ_WIDGET_TYPE_NOT_WIDGET) + while (annot && annot->widget_type == FZ_WIDGET_TYPE_NOT_WIDGET) annot = annot->next; return (fz_widget *)annot; @@ -2219,7 +2219,7 @@ fz_widget *pdf_next_widget(fz_widget *previous) if (annot) annot = annot->next; - while (annot && annot->type == FZ_WIDGET_TYPE_NOT_WIDGET) + while (annot && annot->widget_type == FZ_WIDGET_TYPE_NOT_WIDGET) annot = annot->next; return (fz_widget *)annot; @@ -2228,7 +2228,7 @@ fz_widget *pdf_next_widget(fz_widget *previous) int fz_widget_get_type(fz_widget *widget) { pdf_annot *annot = (pdf_annot *)widget; - return annot->type; + return annot->widget_type; } char *pdf_field_value(pdf_document *doc, pdf_obj *field) |