diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | glib/poppler-form-field.cc | 18 | ||||
-rw-r--r-- | glib/poppler-form-field.h | 8 | ||||
-rw-r--r-- | glib/test-poppler-glib.c | 26 | ||||
-rw-r--r-- | poppler/Form.cc | 5 | ||||
-rw-r--r-- | poppler/Form.h | 2 |
6 files changed, 65 insertions, 3 deletions
@@ -1,5 +1,14 @@ 2007-07-07 Carlos Garcia Campos <carlosgc@gnome.org> + * poppler/Form.cc: + * poppler/Form.h: + * glib/poppler-form-field.cc: + * glib/poppler-form-field.h: + * glib/test-poppler-glib.c: Add a method to get the type of a Form + Field Button. + +2007-07-07 Carlos Garcia Campos <carlosgc@gnome.org> + * poppler/Form.cc: Fix a crash when setting state on buttons that don't have state. diff --git a/glib/poppler-form-field.cc b/glib/poppler-form-field.cc index 47a318a9..fde40253 100644 --- a/glib/poppler-form-field.cc +++ b/glib/poppler-form-field.cc @@ -120,6 +120,24 @@ poppler_form_field_is_read_only (PopplerFormField *field) } /* Button Field */ +PopplerFormButtonType +poppler_form_field_button_get_button_type (PopplerFormField *field) +{ + g_return_val_if_fail (field->widget->getType () == formButton, POPPLER_FORM_BUTTON_PUSH); + + switch (static_cast<FormWidgetButton*>(field->widget)->getButtonType ()) + { + case formButtonPush: + return POPPLER_FORM_BUTTON_PUSH; + case formButtonCheck: + return POPPLER_FORM_BUTTON_CHECK; + case formButtonRadio: + return POPPLER_FORM_BUTTON_RADIO; + default: + g_assert_not_reached (); + } +} + gboolean poppler_form_field_button_get_state (PopplerFormField *field) { diff --git a/glib/poppler-form-field.h b/glib/poppler-form-field.h index 01859a1f..c6b37914 100644 --- a/glib/poppler-form-field.h +++ b/glib/poppler-form-field.h @@ -40,6 +40,13 @@ typedef enum typedef enum { + POPPLER_FORM_BUTTON_PUSH, + POPPLER_FORM_BUTTON_CHECK, + POPPLER_FORM_BUTTON_RADIO +} PopplerFormButtonType; + +typedef enum +{ POPPLER_FORM_TEXT_NORMAL, POPPLER_FORM_TEXT_MULTILINE, POPPLER_FORM_TEXT_PASSWORD, @@ -60,6 +67,7 @@ gdouble poppler_form_field_get_font_size (PopplerFormFie gboolean poppler_form_field_is_read_only (PopplerFormField *field); /* Button Field */ +PopplerFormButtonType poppler_form_field_button_get_button_type (PopplerFormField *field); gboolean poppler_form_field_button_get_state (PopplerFormField *field); void poppler_form_field_button_set_state (PopplerFormField *field, gboolean state); diff --git a/glib/test-poppler-glib.c b/glib/test-poppler-glib.c index 47eeee1c..a5c95068 100644 --- a/glib/test-poppler-glib.c +++ b/glib/test-poppler-glib.c @@ -214,9 +214,29 @@ form_field_text_print (PopplerFormField *field) static void form_field_button_print (PopplerFormField *field) { - printf ("\t\tType:\tButton\n"); - printf ("\t\tState:\t%s\n", - poppler_form_field_button_get_state (field) ? "Active" : "Inactive"); + PopplerFormButtonType button_type; + const gchar *button_type_str; + + button_type = poppler_form_field_button_get_button_type (field); + + switch (button_type) + { + case POPPLER_FORM_BUTTON_PUSH: + button_type_str = "Push"; + break; + case POPPLER_FORM_BUTTON_CHECK: + button_type_str = "Check box"; + break; + case POPPLER_FORM_BUTTON_RADIO: + button_type_str = "Radio Button"; + break; + } + + printf ("\t\tType:\t\tButton\n"); + printf ("\t\tButton type:\t%s\n", button_type_str); + if (button_type != POPPLER_FORM_BUTTON_PUSH) + printf ("\t\tState:\t\t%s\n", + poppler_form_field_button_get_state (field) ? "Active" : "Inactive"); } static void diff --git a/poppler/Form.cc b/poppler/Form.cc index a7b95458..4cfaa190 100644 --- a/poppler/Form.cc +++ b/poppler/Form.cc @@ -151,6 +151,11 @@ FormWidgetButton::~FormWidgetButton () gfree(siblingsID); } +FormButtonType FormWidgetButton::getButtonType () const +{ + return parent->getButtonType (); +} + void FormWidgetButton::setState (GBool astate, GBool calledByParent) { //pushButtons don't have state diff --git a/poppler/Form.h b/poppler/Form.h index 1338877c..ded1788a 100644 --- a/poppler/Form.h +++ b/poppler/Form.h @@ -123,6 +123,8 @@ public: FormWidgetButton(XRef *xrefA, Object *dict, unsigned num, Ref ref, FormFieldButton *p); ~FormWidgetButton (); + FormButtonType getButtonType() const; + void setState (GBool state, GBool calledByParent=gFalse); GBool getState (); |