summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/pdf/field.h35
-rw-r--r--platform/gl/gl-form.c2
-rw-r--r--source/pdf/pdf-appearance.c4
-rw-r--r--source/pdf/pdf-field.c18
-rw-r--r--source/pdf/pdf-form.c11
5 files changed, 32 insertions, 38 deletions
diff --git a/include/mupdf/pdf/field.h b/include/mupdf/pdf/field.h
index 65d2af2e..6fdb55d6 100644
--- a/include/mupdf/pdf/field.h
+++ b/include/mupdf/pdf/field.h
@@ -4,33 +4,26 @@
/* Field flags */
enum
{
- /* Common to all field types */
- Ff_ReadOnly = 1 << (1-1),
- Ff_Required = 1 << (2-1),
- Ff_NoExport = 1 << (3-1),
+ /* All fields */
+ PDF_FIELD_IS_READ_ONLY = 1,
+ PDF_FIELD_IS_REQUIRED = 1 << 1,
+ PDF_FIELD_IS_NO_EXPORT = 1 << 2,
/* Text fields */
- Ff_Multiline = 1 << (13-1),
- Ff_Password = 1 << (14-1),
-
- Ff_FileSelect = 1 << (21-1),
- Ff_DoNotSpellCheck = 1 << (23-1),
- Ff_DoNotScroll = 1 << (24-1),
- Ff_Comb = 1 << (25-1),
- Ff_RichText = 1 << (26-1),
+ PDF_TX_FIELD_IS_MULTILINE = 1 << 12,
+ PDF_TX_FIELD_IS_PASSWORD = 1 << 13,
+ PDF_TX_FIELD_IS_COMB = 1 << 24,
/* Button fields */
- Ff_NoToggleToOff = 1 << (15-1),
- Ff_Radio = 1 << (16-1),
- Ff_Pushbutton = 1 << (17-1),
- Ff_RadioInUnison = 1 << (26-1),
+ PDF_BTN_FIELD_IS_NO_TOGGLE_TO_OFF = 1 << 14,
+ PDF_BTN_FIELD_IS_RADIO = 1 << 15,
+ PDF_BTN_FIELD_IS_PUSHBUTTON = 1 << 16,
/* Choice fields */
- Ff_Combo = 1 << (18-1),
- Ff_Edit = 1 << (19-1),
- Ff_Sort = 1 << (20-1),
- Ff_MultiSelect = 1 << (22-1),
- Ff_CommitOnSelCHange = 1 << (27-1),
+ PDF_CH_FIELD_IS_COMBO = 1 << 17,
+ PDF_CH_FIELD_IS_EDIT = 1 << 18,
+ PDF_CH_FIELD_IS_SORT = 1 << 19,
+ PDF_CH_FIELD_IS_MULTI_SELECT = 1 << 21,
};
int pdf_get_field_flags(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
diff --git a/platform/gl/gl-form.c b/platform/gl/gl-form.c
index e42581ba..e09faa16 100644
--- a/platform/gl/gl-form.c
+++ b/platform/gl/gl-form.c
@@ -104,7 +104,7 @@ void do_widget_panel(void)
ui_input_init(&input, value);
fz_free(ctx, value);
}
- if (ui_input(&input, 0, (ff & Ff_Multiline) ? 5 : 1) >= UI_INPUT_EDIT)
+ if (ui_input(&input, 0, (ff & PDF_TX_FIELD_IS_MULTILINE) ? 5 : 1) >= UI_INPUT_EDIT)
{
pdf_field_set_value(ctx, selected_annot->page->doc, selected_annot->obj, input.text);
if (pdf_update_page(ctx, selected_annot->page))
diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c
index fb5b8343..84c899cd 100644
--- a/source/pdf/pdf-appearance.c
+++ b/source/pdf/pdf-appearance.c
@@ -1045,12 +1045,12 @@ pdf_write_tx_widget_appearance(fz_context *ctx, pdf_annot *annot, fz_buffer *buf
b = 0;
}
- if (ff & Ff_Comb)
+ if (ff & PDF_TX_FIELD_IS_COMB)
{
int maxlen = pdf_to_int(ctx, pdf_dict_get_inheritable(ctx, annot->obj, PDF_NAME(MaxLen)));
write_variable_text(ctx, annot, buf, res, text, font, size, color, q, w, h, 0, 0, 0, maxlen);
}
- else if (ff & Ff_Multiline)
+ else if (ff & PDF_TX_FIELD_IS_MULTILINE)
write_variable_text(ctx, annot, buf, res, text, font, size, color, q, w, h, b*2+2, b*2, 1, 0);
else
write_variable_text(ctx, annot, buf, res, text, font, size, color, q, w, h, b*2+2, b*2, 0, 0);
diff --git a/source/pdf/pdf-field.c b/source/pdf/pdf-field.c
index 3bb0acc3..cc5ebf40 100644
--- a/source/pdf/pdf-field.c
+++ b/source/pdf/pdf-field.c
@@ -25,9 +25,9 @@ int pdf_field_type(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
if (pdf_name_eq(ctx, type, PDF_NAME(Btn)))
{
- if (flags & Ff_Pushbutton)
+ if (flags & PDF_BTN_FIELD_IS_PUSHBUTTON)
return PDF_WIDGET_TYPE_PUSHBUTTON;
- else if (flags & Ff_Radio)
+ else if (flags & PDF_BTN_FIELD_IS_RADIO)
return PDF_WIDGET_TYPE_RADIOBUTTON;
else
return PDF_WIDGET_TYPE_CHECKBOX;
@@ -36,7 +36,7 @@ int pdf_field_type(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
return PDF_WIDGET_TYPE_TEXT;
else if (pdf_name_eq(ctx, type, PDF_NAME(Ch)))
{
- if (flags & Ff_Combo)
+ if (flags & PDF_CH_FIELD_IS_COMBO)
return PDF_WIDGET_TYPE_COMBOBOX;
else
return PDF_WIDGET_TYPE_LISTBOX;
@@ -57,27 +57,27 @@ void pdf_set_field_type(fz_context *ctx, pdf_document *doc, pdf_obj *obj, int ty
{
case PDF_WIDGET_TYPE_PUSHBUTTON:
typename = PDF_NAME(Btn);
- setbits = Ff_Pushbutton;
+ setbits = PDF_BTN_FIELD_IS_PUSHBUTTON;
break;
case PDF_WIDGET_TYPE_CHECKBOX:
typename = PDF_NAME(Btn);
- clearbits = Ff_Pushbutton;
- setbits = Ff_Radio;
+ clearbits = PDF_BTN_FIELD_IS_PUSHBUTTON;
+ setbits = PDF_BTN_FIELD_IS_RADIO;
break;
case PDF_WIDGET_TYPE_RADIOBUTTON:
typename = PDF_NAME(Btn);
- clearbits = (Ff_Pushbutton|Ff_Radio);
+ clearbits = (PDF_BTN_FIELD_IS_PUSHBUTTON|PDF_BTN_FIELD_IS_RADIO);
break;
case PDF_WIDGET_TYPE_TEXT:
typename = PDF_NAME(Tx);
break;
case PDF_WIDGET_TYPE_LISTBOX:
typename = PDF_NAME(Ch);
- clearbits = Ff_Combo;
+ clearbits = PDF_CH_FIELD_IS_COMBO;
break;
case PDF_WIDGET_TYPE_COMBOBOX:
typename = PDF_NAME(Ch);
- setbits = Ff_Combo;
+ setbits = PDF_CH_FIELD_IS_COMBO;
break;
case PDF_WIDGET_TYPE_SIGNATURE:
typename = PDF_NAME(Sig);
diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c
index 8797e780..224e8017 100644
--- a/source/pdf/pdf-form.c
+++ b/source/pdf/pdf-form.c
@@ -21,8 +21,8 @@ enum
static int pdf_field_dirties_document(fz_context *ctx, pdf_document *doc, pdf_obj *field)
{
int ff = pdf_get_field_flags(ctx, doc, field);
- if (ff & Ff_NoExport) return 0;
- if (ff & Ff_ReadOnly) return 0;
+ if (ff & PDF_FIELD_IS_NO_EXPORT) return 0;
+ if (ff & PDF_FIELD_IS_READ_ONLY) return 0;
return 1;
}
@@ -454,7 +454,8 @@ static void toggle_check_box(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
{
pdf_obj *as = pdf_dict_get(ctx, obj, PDF_NAME(AS));
int ff = pdf_get_field_flags(ctx, doc, obj);
- int radio = ((ff & (Ff_Pushbutton|Ff_Radio)) == Ff_Radio);
+ int button_mask = PDF_BTN_FIELD_IS_RADIO | PDF_BTN_FIELD_IS_PUSHBUTTON;
+ int radio = ((ff & button_mask) == PDF_BTN_FIELD_IS_RADIO);
char *val = NULL;
pdf_obj *grp = radio ? pdf_dict_get(ctx, obj, PDF_NAME(Parent)) : find_head_of_field_group(ctx, obj);
@@ -465,7 +466,7 @@ static void toggle_check_box(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
{
/* "as" neither missing nor set to Off. Set it to Off, unless
* this is a non-toggle-off radio button. */
- if ((ff & (Ff_Pushbutton|Ff_NoToggleToOff|Ff_Radio)) != (Ff_NoToggleToOff|Ff_Radio))
+ if (radio && !(ff & PDF_BTN_FIELD_IS_NO_TOGGLE_TO_OFF))
{
check_off(ctx, doc, obj);
val = "Off";
@@ -1138,7 +1139,7 @@ int pdf_choice_widget_is_multiselect(fz_context *ctx, pdf_document *doc, pdf_wid
{
case PDF_WIDGET_TYPE_LISTBOX:
case PDF_WIDGET_TYPE_COMBOBOX:
- return (pdf_get_field_flags(ctx, doc, annot->obj) & Ff_MultiSelect) != 0;
+ return (pdf_get_field_flags(ctx, doc, annot->obj) & PDF_CH_FIELD_IS_MULTI_SELECT) != 0;
default:
return 0;
}