diff options
author | Ryan Harrison <rharrison@chromium.org> | 2018-06-21 21:09:54 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-21 21:09:54 +0000 |
commit | c3cc2ab66d3d8f52dea8083abb6775115e17af7d (patch) | |
tree | 227eb764e7ee1f674f9ac992ec6620e4e57e2b01 /public/fpdf_formfill.h | |
parent | aaaf9877478d7add8a74b4db74d97ca19ce1c47e (diff) | |
download | pdfium-c3cc2ab66d3d8f52dea8083abb6775115e17af7d.tar.xz |
Clean up constant values for JS alert and beep
Define constant values in the public API for the valid values of alert
button type, alert icon type, and beep type. Replace various magic
numbers through out the code base using these values. Also replace the
XFA specific versions with an enum class that is guaranteed to have the
same values, instead of #defines that just happen to.
This CL does not attempt to add error checking on these values, since
it currently doesn't exist so adding it may cause regressions.
Change-Id: Ief3aee2a4ad419691c18fc1dba8b984ad222141b
Reviewed-on: https://pdfium-review.googlesource.com/35730
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'public/fpdf_formfill.h')
-rw-r--r-- | public/fpdf_formfill.h | 119 |
1 files changed, 66 insertions, 53 deletions
diff --git a/public/fpdf_formfill.h b/public/fpdf_formfill.h index dc7c54e5c0..915c07a134 100644 --- a/public/fpdf_formfill.h +++ b/public/fpdf_formfill.h @@ -22,6 +22,30 @@ typedef void* FPDF_FORMHANDLE; // of XFA spec #define FORMTYPE_COUNT 4 // The number of form types +#define JSPLATFORM_ALERT_BUTTON_OK 0 // OK button +#define JSPLATFORM_ALERT_BUTTON_OKCANCEL 1 // OK & Cancel buttons +#define JSPLATFORM_ALERT_BUTTON_YESNO 2 // Yes & No buttons +#define JSPLATFORM_ALERT_BUTTON_YESNOCANCEL 3 // Yes, No & Cancel buttons +#define JSPLATFORM_ALERT_BUTTON_DEFAULT JSPLATFORM_ALERT_BUTTON_OK + +#define JSPLATFORM_ALERT_ICON_ERROR 0 // Error +#define JSPLATFORM_ALERT_ICON_WARNING 1 // Warning +#define JSPLATFORM_ALERT_ICON_QUESTION 2 // Question +#define JSPLATFORM_ALERT_ICON_STATUS 3 // Status +#define JSPLATFORM_ALERT_ICON_ASTERISK 4 // Asterisk +#define JSPLATFORM_ALERT_ICON_DEFAULT JSPLATFORM_ALERT_ICON_ERROR + +#define JSPLATFORM_ALERT_RETURN_OK 1 // OK +#define JSPLATFORM_ALERT_RETURN_CANCEL 2 // Cancel +#define JSPLATFORM_ALERT_RETURN_NO 3 // No +#define JSPLATFORM_ALERT_RETURN_YES 4 // Yes + +#define JSPLATFORM_BEEP_ERROR 0 // Error +#define JSPLATFORM_BEEP_WARNING 1 // Warning +#define JSPLATFORM_BEEP_QUESTION 2 // Question +#define JSPLATFORM_BEEP_STATUS 3 // Status +#define JSPLATFORM_BEEP_DEFAULT 4 // Default + // Exported Functions #ifdef __cplusplus extern "C" { @@ -36,34 +60,25 @@ typedef struct _IPDF_JsPlatform { /* Version 1. */ /** - * Method: app_alert - * pop up a dialog to show warning or hint. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * Msg - A string containing the message to be displayed. - * Title - The title of the dialog. - * Type - The stype of button group. - * 0-OK(default); - * 1-OK,Cancel; - * 2-Yes,NO; - * 3-Yes, NO, Cancel. - * nIcon - The Icon type. - * 0-Error(default); - * 1-Warning; - * 2-Question; - * 3-Status. - * 4-Asterisk - * Return Value: - * The return value could be the folowing type: - * 1-OK; - * 2-Cancel; - * 3-NO; - * 4-Yes; - */ + * Method: app_alert + * pop up a dialog to show warning or hint. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * Msg - A string containing the message to be displayed. + * Title - The title of the dialog. + * Type - The type of button group, see + * JSPLATFORM_ALERT_BUTTON_* above. + * nIcon - The icon type, see see + * JSPLATFORM_ALERT_ICON_* above . + * + * Return Value: + * Option selected by user in dialogue, see see + * JSPLATFORM_ALERT_RETURN_* above. + */ int (*app_alert)(struct _IPDF_JsPlatform* pThis, FPDF_WIDESTRING Msg, FPDF_WIDESTRING Title, @@ -71,23 +86,20 @@ typedef struct _IPDF_JsPlatform { int Icon); /** - * Method: app_beep - * Causes the system to play a sound. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * nType - The sound type. - * 0 - Error - * 1 - Warning - * 2 - Question - * 3 - Status - * 4 - Default (default value) - * Return Value: - * None - */ + * Method: app_beep + * Causes the system to play a sound. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself + * nType - The sound type, see see JSPLATFORM_BEEP_TYPE_* + * above. + * + * Return Value: + * None + */ void (*app_beep)(struct _IPDF_JsPlatform* pThis, int nType); /** @@ -1553,14 +1565,15 @@ FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle); #endif // PDF_ENABLE_XFA #ifdef PDF_ENABLE_XFA -#define IS_XFA_FORMFIELD(type) \ - ((type == FPDF_FORMFIELD_XFA) || (type == FPDF_FORMFIELD_XFA_CHECKBOX) || \ - (type == FPDF_FORMFIELD_XFA_COMBOBOX) || \ - (type == FPDF_FORMFIELD_XFA_IMAGEFIELD) || \ - (type == FPDF_FORMFIELD_XFA_LISTBOX) || \ - (type == FPDF_FORMFIELD_XFA_PUSHBUTTON) || \ - (type == FPDF_FORMFIELD_XFA_SIGNATURE) || \ - (type == FPDF_FORMFIELD_XFA_TEXTFIELD)) +#define IS_XFA_FORMFIELD(type) \ + (((type) == FPDF_FORMFIELD_XFA) || \ + ((type) == FPDF_FORMFIELD_XFA_CHECKBOX) || \ + ((type) == FPDF_FORMFIELD_XFA_COMBOBOX) || \ + ((type) == FPDF_FORMFIELD_XFA_IMAGEFIELD) || \ + ((type) == FPDF_FORMFIELD_XFA_LISTBOX) || \ + ((type) == FPDF_FORMFIELD_XFA_PUSHBUTTON) || \ + ((type) == FPDF_FORMFIELD_XFA_SIGNATURE) || \ + ((type) == FPDF_FORMFIELD_XFA_TEXTFIELD)) #endif // PDF_ENABLE_XFA /** |