summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/pdf/annot.h4
-rw-r--r--include/mupdf/pdf/widget.h4
-rw-r--r--platform/x11/pdfapp.c2
-rw-r--r--source/pdf/pdf-annot-edit.c2
-rw-r--r--source/pdf/pdf-annot.c11
-rw-r--r--source/pdf/pdf-appearance.c2
-rw-r--r--source/pdf/pdf-form.c13
7 files changed, 13 insertions, 25 deletions
diff --git a/include/mupdf/pdf/annot.h b/include/mupdf/pdf/annot.h
index 1773efae..ea6b2caa 100644
--- a/include/mupdf/pdf/annot.h
+++ b/include/mupdf/pdf/annot.h
@@ -66,8 +66,6 @@ struct pdf_annot_s
int ap_iteration;
pdf_annot *next;
pdf_annot *next_changed;
- int annot_type;
- int widget_type;
};
fz_link_dest pdf_parse_link_dest(fz_context *ctx, pdf_document *doc, fz_link_kind kind, pdf_obj *dest);
@@ -143,8 +141,6 @@ pdf_obj *pdf_annot_irt(fz_context *ctx, pdf_annot *annot);
*/
void pdf_set_free_text_details(fz_context *ctx, pdf_document *doc, pdf_annot *annot, fz_point *pos, char *text, char *font_name, float font_size, float color[3]);
-fz_annot_type pdf_annot_obj_type(fz_context *ctx, pdf_obj *obj);
-
/*
pdf_poll_changed_annot: enumerate the changed annotations recorded
by a call to pdf_update_page.
diff --git a/include/mupdf/pdf/widget.h b/include/mupdf/pdf/widget.h
index c5ed339b..5f2c38af 100644
--- a/include/mupdf/pdf/widget.h
+++ b/include/mupdf/pdf/widget.h
@@ -55,12 +55,12 @@ pdf_widget *pdf_next_widget(fz_context *ctx, pdf_widget *previous);
pdf_widget *pdf_create_widget(fz_context *ctx, pdf_document *doc, pdf_page *page, int type, char *fieldname);
/*
- pdf_widget_get_type: find out the type of a widget.
+ pdf_widget_type: find out the type of a widget.
The type determines what widget subclass the widget
can safely be cast to.
*/
-int pdf_widget_get_type(fz_context *ctx, pdf_widget *widget);
+int pdf_widget_type(fz_context *ctx, pdf_widget *widget);
/*
pdf_bound_widget: get the bounding box of a widget.
diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c
index dae5da9a..431c9994 100644
--- a/platform/x11/pdfapp.c
+++ b/platform/x11/pdfapp.c
@@ -1606,7 +1606,7 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta
if (widget)
{
- switch (pdf_widget_get_type(ctx, widget))
+ switch (pdf_widget_type(ctx, widget))
{
case PDF_WIDGET_TYPE_TEXT:
{
diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c
index f4431414..95b41958 100644
--- a/source/pdf/pdf-annot-edit.c
+++ b/source/pdf/pdf-annot-edit.c
@@ -121,8 +121,6 @@ pdf_create_annot(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_annot_ty
annot = pdf_new_annot(ctx, page, &page_ctm, &inv_page_ctm);
annot->ap = NULL;
- annot->widget_type = PDF_WIDGET_TYPE_NOT_WIDGET;
- annot->annot_type = type;
/*
Both annotation object and annotation structure are now created.
diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c
index 00e5b983..b502730a 100644
--- a/source/pdf/pdf-annot.c
+++ b/source/pdf/pdf-annot.c
@@ -427,8 +427,9 @@ pdf_annot_transform(fz_context *ctx, pdf_annot *annot, fz_matrix *annot_ctm)
fz_pre_scale(fz_translate(annot_ctm, x, y), w, h);
}
-fz_annot_type pdf_annot_obj_type(fz_context *ctx, pdf_obj *obj)
+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;
@@ -584,8 +585,6 @@ pdf_load_annots(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_obj *ann
n = pdf_dict_get(ctx, n, as);
annot->ap = NULL;
- annot->annot_type = pdf_annot_obj_type(ctx, obj);
- annot->widget_type = annot->annot_type == FZ_ANNOT_WIDGET ? pdf_field_type(ctx, doc, obj) : PDF_WIDGET_TYPE_NOT_WIDGET;
if (pdf_is_stream(ctx, n))
{
@@ -644,9 +643,3 @@ pdf_bound_annot(fz_context *ctx, pdf_annot *annot, fz_rect *rect)
fz_transform_rect(rect, &annot->page_ctm);
return rect;
}
-
-fz_annot_type
-pdf_annot_type(fz_context *ctx, pdf_annot *annot)
-{
- return annot->annot_type;
-}
diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c
index 1e74fa15..d9e9e5a0 100644
--- a/source/pdf/pdf-appearance.c
+++ b/source/pdf/pdf-appearance.c
@@ -2435,7 +2435,7 @@ void pdf_update_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *annot)
pdf_obj *obj = annot->obj;
if (!pdf_dict_get(ctx, obj, PDF_NAME_AP) || pdf_obj_is_dirty(ctx, obj))
{
- fz_annot_type type = pdf_annot_obj_type(ctx, obj);
+ fz_annot_type type = pdf_annot_type(ctx, annot);
switch (type)
{
case FZ_ANNOT_WIDGET:
diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c
index 3e39409e..d29d7c41 100644
--- a/source/pdf/pdf-form.c
+++ b/source/pdf/pdf-form.c
@@ -643,7 +643,7 @@ int pdf_pass_event(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_ui_ev
if (annot)
{
- switch (annot->widget_type)
+ switch (pdf_widget_type(ctx, (pdf_widget*)annot))
{
case PDF_WIDGET_TYPE_RADIOBUTTON:
case PDF_WIDGET_TYPE_CHECKBOX:
@@ -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 && annot->widget_type == PDF_WIDGET_TYPE_NOT_WIDGET)
+ while (annot && pdf_annot_type(ctx, annot) != FZ_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 && annot->widget_type == PDF_WIDGET_TYPE_NOT_WIDGET)
+ while (annot && pdf_annot_type(ctx, annot) != FZ_ANNOT_WIDGET)
annot = annot->next;
return (pdf_widget *)annot;
@@ -777,7 +777,6 @@ pdf_widget *pdf_create_widget(fz_context *ctx, pdf_document *doc, pdf_page *page
{
pdf_set_field_type(ctx, doc, annot->obj, type);
pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_T, pdf_new_string(ctx, doc, fieldname, strlen(fieldname)));
- annot->widget_type = type;
if (type == PDF_WIDGET_TYPE_SIGNATURE)
{
@@ -813,10 +812,12 @@ pdf_widget *pdf_create_widget(fz_context *ctx, pdf_document *doc, pdf_page *page
return (pdf_widget *)annot;
}
-int pdf_widget_get_type(fz_context *ctx, pdf_widget *widget)
+int pdf_widget_type(fz_context *ctx, pdf_widget *widget)
{
pdf_annot *annot = (pdf_annot *)widget;
- return annot->widget_type;
+ if (pdf_annot_type(ctx, annot) == FZ_ANNOT_WIDGET)
+ return pdf_field_type(ctx, pdf_get_bound_document(ctx, annot->obj), annot->obj);
+ return PDF_WIDGET_TYPE_NOT_WIDGET;
}
static int set_text_field_value(fz_context *ctx, pdf_document *doc, pdf_obj *field, const char *text)