From c34492b21b805fbe8e810d42b5b424b6ca469e45 Mon Sep 17 00:00:00 2001 From: Marek Kasik Date: Mon, 15 Jun 2015 15:31:11 +0200 Subject: [PATCH 1/4] glib: Make available additional actions of widget annotations Add poppler_form_field_get_annot_additional_action() which returns the action that shall be performed when an additional action is triggered on annotation related to given field. --- glib/poppler-annot.h | 14 ++++++++ glib/poppler-form-field.cc | 75 ++++++++++++++++++++++++++++++++++++++++ glib/poppler-form-field.h | 86 ++++++++++++++++++++++++---------------------- glib/poppler-private.h | 12 +++++++ 4 files changed, 146 insertions(+), 41 deletions(-) diff --git a/glib/poppler-annot.h b/glib/poppler-annot.h index 441563e..3bacc0a 100644 --- a/glib/poppler-annot.h +++ b/glib/poppler-annot.h @@ -159,6 +159,20 @@ typedef enum POPPLER_ANNOT_FREE_TEXT_QUADDING_RIGHT_JUSTIFIED } PopplerAnnotFreeTextQuadding; +typedef enum +{ + POPPLER_ANNOT_ADDITIONAL_ACTION_CURSOR_ENTERING, + POPPLER_ANNOT_ADDITIONAL_ACTION_CURSOR_LEAVING, + POPPLER_ANNOT_ADDITIONAL_ACTION_MOUSE_PRESSED, + POPPLER_ANNOT_ADDITIONAL_ACTION_MOUSE_RELEASED, + POPPLER_ANNOT_ADDITIONAL_ACTION_FOCUS_IN, + POPPLER_ANNOT_ADDITIONAL_ACTION_FOCUS_OUT, + POPPLER_ANNOT_ADDITIONAL_ACTION_PAGE_OPENING, + POPPLER_ANNOT_ADDITIONAL_ACTION_PAGE_CLOSING, + POPPLER_ANNOT_ADDITIONAL_ACTION_PAGE_VISIBLE, + POPPLER_ANNOT_ADDITIONAL_ACTION_PAGE_INVISIBLE +} PopplerAnnotAdditionalActionType; + struct _PopplerAnnotCalloutLine { gboolean multiline; diff --git a/glib/poppler-form-field.cc b/glib/poppler-form-field.cc index 809ff61..1b67293 100644 --- a/glib/poppler-form-field.cc +++ b/glib/poppler-form-field.cc @@ -247,6 +247,81 @@ poppler_form_field_get_additional_action (PopplerFormField *field, return *action; } +/** + * poppler_form_field_get_annot_additional_action: + * @field: a #PopplerFormField + * @type: the type of additional action + * + * Retrieves the action (#PopplerAction) that shall be performed when + * an additional action is triggered on annotation related to @field , + * or %NULL. + * + * Return value: (transfer none): the action to perform. + * + * Since: 0.34 + */ +PopplerAction * +poppler_form_field_get_annot_additional_action (PopplerFormField *field, + PopplerAnnotAdditionalActionType type) +{ + Annot::AdditionalActionsType annot_action_type; + PopplerAction *action = NULL; + LinkAction *link_action; + + switch (type) + { + case POPPLER_ANNOT_ADDITIONAL_ACTION_CURSOR_ENTERING: + annot_action_type = Annot::actionCursorEntering; + action = field->cursor_entering_action; + break; + case POPPLER_ANNOT_ADDITIONAL_ACTION_CURSOR_LEAVING: + annot_action_type = Annot::actionCursorLeaving; + action = field->cursor_leaving_action; + break; + case POPPLER_ANNOT_ADDITIONAL_ACTION_MOUSE_PRESSED: + annot_action_type = Annot::actionMousePressed; + action = field->mouse_pressed_action; + break; + case POPPLER_ANNOT_ADDITIONAL_ACTION_MOUSE_RELEASED: + annot_action_type = Annot::actionMouseReleased; + action = field->mouse_released_action; + break; + case POPPLER_ANNOT_ADDITIONAL_ACTION_FOCUS_IN: + annot_action_type = Annot::actionFocusIn; + action = field->focus_in_action; + break; + case POPPLER_ANNOT_ADDITIONAL_ACTION_FOCUS_OUT: + annot_action_type = Annot::actionFocusOut; + action = field->focus_out_action; + break; + case POPPLER_ANNOT_ADDITIONAL_ACTION_PAGE_OPENING: + annot_action_type = Annot::actionPageOpening; + action = field->page_opening_action; + break; + case POPPLER_ANNOT_ADDITIONAL_ACTION_PAGE_CLOSING: + annot_action_type = Annot::actionPageClosing; + action = field->page_closing_action; + break; + case POPPLER_ANNOT_ADDITIONAL_ACTION_PAGE_VISIBLE: + annot_action_type = Annot::actionPageVisible; + action = field->page_visible_action; + break; + case POPPLER_ANNOT_ADDITIONAL_ACTION_PAGE_INVISIBLE: + annot_action_type = Annot::actionPageInvisible; + action = field->page_invisible_action; + break; + } + + if (action == NULL) + { + link_action = field->widget->getWidgetAnnotation ()->getAdditionalAction (annot_action_type); + if (link_action != NULL) + action = _poppler_action_new (NULL, link_action, NULL); + } + + return action; +} + /* Button Field */ /** * poppler_form_field_button_get_button_type: diff --git a/glib/poppler-form-field.h b/glib/poppler-form-field.h index 505fdc8..d69709a 100644 --- a/glib/poppler-form-field.h +++ b/glib/poppler-form-field.h @@ -23,6 +23,8 @@ #include #include "poppler.h" +#include "poppler-annot.h" + G_BEGIN_DECLS #define POPPLER_TYPE_FORM_FIELD (poppler_form_field_get_type ()) @@ -66,54 +68,56 @@ typedef enum POPPLER_ADDITIONAL_ACTION_CALCULATE_FIELD } PopplerAdditionalActionType; -GType poppler_form_field_get_type (void) G_GNUC_CONST; +GType poppler_form_field_get_type (void) G_GNUC_CONST; -PopplerFormFieldType poppler_form_field_get_field_type (PopplerFormField *field); -gint poppler_form_field_get_id (PopplerFormField *field); -gdouble poppler_form_field_get_font_size (PopplerFormField *field); -gboolean poppler_form_field_is_read_only (PopplerFormField *field); -gchar *poppler_form_field_get_partial_name (PopplerFormField *field); -gchar *poppler_form_field_get_mapping_name (PopplerFormField *field); -gchar *poppler_form_field_get_name (PopplerFormField *field); -PopplerAction *poppler_form_field_get_action (PopplerFormField *field); -PopplerAction *poppler_form_field_get_additional_action (PopplerFormField *field, PopplerAdditionalActionType type); +PopplerFormFieldType poppler_form_field_get_field_type (PopplerFormField *field); +gint poppler_form_field_get_id (PopplerFormField *field); +gdouble poppler_form_field_get_font_size (PopplerFormField *field); +gboolean poppler_form_field_is_read_only (PopplerFormField *field); +gchar *poppler_form_field_get_partial_name (PopplerFormField *field); +gchar *poppler_form_field_get_mapping_name (PopplerFormField *field); +gchar *poppler_form_field_get_name (PopplerFormField *field); +PopplerAction *poppler_form_field_get_action (PopplerFormField *field); +PopplerAction *poppler_form_field_get_additional_action (PopplerFormField *field, PopplerAdditionalActionType type); +PopplerAction *poppler_form_field_get_annot_additional_action (PopplerFormField *field, + PopplerAnnotAdditionalActionType type); /* 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); +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); /* Text Field */ -PopplerFormTextType poppler_form_field_text_get_text_type (PopplerFormField *field); -gchar *poppler_form_field_text_get_text (PopplerFormField *field); -void poppler_form_field_text_set_text (PopplerFormField *field, - const gchar *text); -gint poppler_form_field_text_get_max_len (PopplerFormField *field); -gboolean poppler_form_field_text_do_spell_check (PopplerFormField *field); -gboolean poppler_form_field_text_do_scroll (PopplerFormField *field); -gboolean poppler_form_field_text_is_rich_text (PopplerFormField *field); -gboolean poppler_form_field_text_is_password (PopplerFormField *field); +PopplerFormTextType poppler_form_field_text_get_text_type (PopplerFormField *field); +gchar *poppler_form_field_text_get_text (PopplerFormField *field); +void poppler_form_field_text_set_text (PopplerFormField *field, + const gchar *text); +gint poppler_form_field_text_get_max_len (PopplerFormField *field); +gboolean poppler_form_field_text_do_spell_check (PopplerFormField *field); +gboolean poppler_form_field_text_do_scroll (PopplerFormField *field); +gboolean poppler_form_field_text_is_rich_text (PopplerFormField *field); +gboolean poppler_form_field_text_is_password (PopplerFormField *field); /* Choice Field */ -PopplerFormChoiceType poppler_form_field_choice_get_choice_type (PopplerFormField *field); -gboolean poppler_form_field_choice_is_editable (PopplerFormField *field); -gboolean poppler_form_field_choice_can_select_multiple (PopplerFormField *field); -gboolean poppler_form_field_choice_do_spell_check (PopplerFormField *field); -gboolean poppler_form_field_choice_commit_on_change (PopplerFormField *field); -gint poppler_form_field_choice_get_n_items (PopplerFormField *field); -gchar *poppler_form_field_choice_get_item (PopplerFormField *field, - gint index); -gboolean poppler_form_field_choice_is_item_selected (PopplerFormField *field, - gint index); -void poppler_form_field_choice_select_item (PopplerFormField *field, - gint index); -void poppler_form_field_choice_unselect_all (PopplerFormField *field); -void poppler_form_field_choice_toggle_item (PopplerFormField *field, - gint index); -void poppler_form_field_choice_set_text (PopplerFormField *field, - const gchar *text); -gchar *poppler_form_field_choice_get_text (PopplerFormField *field); +PopplerFormChoiceType poppler_form_field_choice_get_choice_type (PopplerFormField *field); +gboolean poppler_form_field_choice_is_editable (PopplerFormField *field); +gboolean poppler_form_field_choice_can_select_multiple (PopplerFormField *field); +gboolean poppler_form_field_choice_do_spell_check (PopplerFormField *field); +gboolean poppler_form_field_choice_commit_on_change (PopplerFormField *field); +gint poppler_form_field_choice_get_n_items (PopplerFormField *field); +gchar *poppler_form_field_choice_get_item (PopplerFormField *field, + gint index); +gboolean poppler_form_field_choice_is_item_selected (PopplerFormField *field, + gint index); +void poppler_form_field_choice_select_item (PopplerFormField *field, + gint index); +void poppler_form_field_choice_unselect_all (PopplerFormField *field); +void poppler_form_field_choice_toggle_item (PopplerFormField *field, + gint index); +void poppler_form_field_choice_set_text (PopplerFormField *field, + const gchar *text); +gchar *poppler_form_field_choice_get_text (PopplerFormField *field); G_END_DECLS diff --git a/glib/poppler-private.h b/glib/poppler-private.h index 364ff2b..40601d9 100644 --- a/glib/poppler-private.h +++ b/glib/poppler-private.h @@ -75,6 +75,18 @@ struct _PopplerFormField PopplerAction *format_field_action; PopplerAction *validate_field_action; PopplerAction *calculate_field_action; + + /* Additional actions of corresponding Annot */ + PopplerAction *cursor_entering_action; + PopplerAction *cursor_leaving_action; + PopplerAction *mouse_pressed_action; + PopplerAction *mouse_released_action; + PopplerAction *focus_in_action; + PopplerAction *focus_out_action; + PopplerAction *page_opening_action; + PopplerAction *page_closing_action; + PopplerAction *page_visible_action; + PopplerAction *page_invisible_action; }; struct _PopplerAnnot -- 2.4.3