summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-10-19 16:56:58 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-19 16:56:58 +0000
commit9ead811969b61d6a82b1f3fc634070fbc797d182 (patch)
tree3bbc04c3e864f028c651a0bfa2c9f209314b3f7f
parent1f120c74ea2e0217dbb8a825bc7d495da805fc50 (diff)
downloadpdfium-9ead811969b61d6a82b1f3fc634070fbc797d182.tar.xz
Add static asserts for FPDFDOC_AACTION_* constants.
These must match as we do an unchecked cast from int to the CPDF_AAction::AActionType enum. Tidy public header comments. Change-Id: Id4707a966dad6920b29f9fc8f4ab4e330d2658c3 Reviewed-on: https://pdfium-review.googlesource.com/c/44350 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
-rw-r--r--fpdfsdk/fpdf_formfill.cpp16
-rw-r--r--public/fpdf_formfill.h93
2 files changed, 62 insertions, 47 deletions
diff --git a/fpdfsdk/fpdf_formfill.cpp b/fpdfsdk/fpdf_formfill.cpp
index 4b23ce41b0..966ed097e9 100644
--- a/fpdfsdk/fpdf_formfill.cpp
+++ b/fpdfsdk/fpdf_formfill.cpp
@@ -141,6 +141,22 @@ static_assert(static_cast<int>(FormFieldType::kXFA_TextField) ==
static_assert(kFormFieldTypeCount == FPDF_FORMFIELD_COUNT,
"Number of form field types must match");
+static_assert(static_cast<int>(CPDF_AAction::CloseDocument) ==
+ FPDFDOC_AACTION_WC,
+ "CloseDocument action must match");
+static_assert(static_cast<int>(CPDF_AAction::SaveDocument) ==
+ FPDFDOC_AACTION_WS,
+ "SaveDocument action must match");
+static_assert(static_cast<int>(CPDF_AAction::DocumentSaved) ==
+ FPDFDOC_AACTION_DS,
+ "DocumentSaved action must match");
+static_assert(static_cast<int>(CPDF_AAction::PrintDocument) ==
+ FPDFDOC_AACTION_WP,
+ "PrintDocument action must match");
+static_assert(static_cast<int>(CPDF_AAction::DocumentPrinted) ==
+ FPDFDOC_AACTION_DP,
+ "DocumentPrinted action must match");
+
namespace {
CPDFSDK_InteractiveForm* FormHandleToInteractiveForm(FPDF_FORMHANDLE hHandle) {
diff --git a/public/fpdf_formfill.h b/public/fpdf_formfill.h
index ed7db273dc..78a41aa9ac 100644
--- a/public/fpdf_formfill.h
+++ b/public/fpdf_formfill.h
@@ -1175,60 +1175,59 @@ FPDF_EXPORT void FPDF_CALLCONV FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle);
FPDF_EXPORT void FPDF_CALLCONV
FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle);
-// additional actions type of document.
-#define FPDFDOC_AACTION_WC \
- 0x10 // WC, before closing document, JavaScript action.
-#define FPDFDOC_AACTION_WS \
- 0x11 // WS, before saving document, JavaScript action.
-#define FPDFDOC_AACTION_DS 0x12 // DS, after saving document, JavaScript
- // action.
-#define FPDFDOC_AACTION_WP \
- 0x13 // WP, before printing document, JavaScript action.
-#define FPDFDOC_AACTION_DP \
- 0x14 // DP, after printing document, JavaScript action.
+// Additional actions type of document:
+// WC, before closing document, JavaScript action.
+// WS, before saving document, JavaScript action.
+// DS, after saving document, JavaScript action.
+// WP, before printing document, JavaScript action.
+// DP, after printing document, JavaScript action.
+#define FPDFDOC_AACTION_WC 0x10
+#define FPDFDOC_AACTION_WS 0x11
+#define FPDFDOC_AACTION_DS 0x12
+#define FPDFDOC_AACTION_WP 0x13
+#define FPDFDOC_AACTION_DP 0x14
/**
-* Function: FORM_DoDocumentAAction
-* This method is required for performing the document's
-*additional-action.
-* Parameters:
-* hHandle - Handle to the form fill module. Returned by
-*FPDFDOC_InitFormFillEnvironment.
-* aaType - The type of the additional-actions which defined
-*above.
-* Return Value:
-* NONE
-* Comments:
-* This method will do nothing if there is no document
-*additional-action corresponding to the specified aaType.
-**/
-
+ * Function: FORM_DoDocumentAAction
+ * This method is required for performing the document's
+ * additional-action.
+ * Parameters:
+ * hHandle - Handle to the form fill module. Returned by
+ * FPDFDOC_InitFormFillEnvironment.
+ * aaType - The type of the additional-actions which defined
+ * above.
+ * Return Value:
+ * NONE
+ * Comments:
+ * This method will do nothing if there is no document
+ * additional-action corresponding to the specified aaType.
+ **/
FPDF_EXPORT void FPDF_CALLCONV FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle,
int aaType);
-// Additional-action types of page object
-#define FPDFPAGE_AACTION_OPEN \
- 0 // /O -- An action to be performed when the page is opened
-#define FPDFPAGE_AACTION_CLOSE \
- 1 // /C -- An action to be performed when the page is closed
+// Additional-action types of page object:
+// OPEN (/O) -- An action to be performed when the page is opened
+// CLOSE (/C) -- An action to be performed when the page is closed
+#define FPDFPAGE_AACTION_OPEN 0
+#define FPDFPAGE_AACTION_CLOSE 1
/**
-* Function: FORM_DoPageAAction
-* This method is required for performing the page object's
-*additional-action when opened or closed.
-* Parameters:
-* page - Handle to the page. Returned by FPDF_LoadPage
-*function.
-* hHandle - Handle to the form fill module. Returned by
-*FPDFDOC_InitFormFillEnvironment.
-* aaType - The type of the page object's additional-actions
-*which defined above.
-* Return Value:
-* NONE
-* Comments:
-* This method will do nothing if no additional-action corresponding to
-*the specified aaType exists.
-**/
+ * Function: FORM_DoPageAAction
+ * This method is required for performing the page object's
+ * additional-action when opened or closed.
+ * Parameters:
+ * page - Handle to the page. Returned by FPDF_LoadPage
+ * function.
+ * hHandle - Handle to the form fill module. Returned by
+ * FPDFDOC_InitFormFillEnvironment.
+ * aaType - The type of the page object's additional-actions
+ * which defined above.
+ * Return Value:
+ * NONE
+ * Comments:
+ * This method will do nothing if no additional-action corresponding
+ * to the specified aaType exists.
+ **/
FPDF_EXPORT void FPDF_CALLCONV FORM_DoPageAAction(FPDF_PAGE page,
FPDF_FORMHANDLE hHandle,
int aaType);