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 /xfa/fxfa/parser | |
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 'xfa/fxfa/parser')
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.cpp | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 00ea7b7a1b..86644694ca 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -2046,11 +2046,15 @@ void CXFA_Node::ProcessScriptTestValidate(CXFA_FFDocView* docView, wsScriptMsg = GetValidateMessage(false, bVersionFlag); if (bVersionFlag) { - pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning, XFA_MB_OK); + pAppProvider->MsgBox(wsScriptMsg, wsTitle, + static_cast<uint32_t>(AlertIcon::kWarning), + static_cast<uint32_t>(AlertButton::kOK)); return; } - if (pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning, - XFA_MB_YesNo) == XFA_IDYes) { + if (pAppProvider->MsgBox(wsScriptMsg, wsTitle, + static_cast<uint32_t>(AlertIcon::kWarning), + static_cast<uint32_t>(AlertButton::kYesNo)) == + static_cast<uint32_t>(AlertReturn::kYes)) { SetFlag(XFA_NodeFlag_UserInteractive); } return; @@ -2058,7 +2062,9 @@ void CXFA_Node::ProcessScriptTestValidate(CXFA_FFDocView* docView, if (wsScriptMsg.IsEmpty()) wsScriptMsg = GetValidateMessage(true, bVersionFlag); - pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK); + pAppProvider->MsgBox(wsScriptMsg, wsTitle, + static_cast<uint32_t>(AlertIcon::kError), + static_cast<uint32_t>(AlertButton::kOK)); } int32_t CXFA_Node::ProcessFormatTestValidate(CXFA_FFDocView* docView, @@ -2087,7 +2093,9 @@ int32_t CXFA_Node::ProcessFormatTestValidate(CXFA_FFDocView* docView, if (validate->GetFormatTest() == XFA_AttributeEnum::Error) { if (wsFormatMsg.IsEmpty()) wsFormatMsg = GetValidateMessage(true, bVersionFlag); - pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK); + pAppProvider->MsgBox(wsFormatMsg, wsTitle, + static_cast<uint32_t>(AlertIcon::kError), + static_cast<uint32_t>(AlertButton::kOK)); return XFA_EVENTERROR_Success; } if (IsUserInteractive()) @@ -2096,12 +2104,15 @@ int32_t CXFA_Node::ProcessFormatTestValidate(CXFA_FFDocView* docView, wsFormatMsg = GetValidateMessage(false, bVersionFlag); if (bVersionFlag) { - pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning, - XFA_MB_OK); + pAppProvider->MsgBox(wsFormatMsg, wsTitle, + static_cast<uint32_t>(AlertIcon::kWarning), + static_cast<uint32_t>(AlertButton::kOK)); return XFA_EVENTERROR_Success; } - if (pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning, - XFA_MB_YesNo) == XFA_IDYes) { + if (pAppProvider->MsgBox(wsFormatMsg, wsTitle, + static_cast<uint32_t>(AlertIcon::kWarning), + static_cast<uint32_t>(AlertButton::kYesNo)) == + static_cast<uint32_t>(AlertReturn::kYes)) { SetFlag(XFA_NodeFlag_UserInteractive); } return XFA_EVENTERROR_Success; @@ -2153,7 +2164,9 @@ int32_t CXFA_Node::ProcessNullTestValidate(CXFA_FFDocView* docView, wsNullMsg = WideString::Format(L"%ls cannot be blank.", wsCaptionName.c_str()); } - pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK); + pAppProvider->MsgBox(wsNullMsg, wsTitle, + static_cast<uint32_t>(AlertIcon::kStatus), + static_cast<uint32_t>(AlertButton::kOK)); return XFA_EVENTERROR_Error; } case XFA_AttributeEnum::Warning: { @@ -2167,8 +2180,10 @@ int32_t CXFA_Node::ProcessNullTestValidate(CXFA_FFDocView* docView, L"Ignore.", wsCaptionName.c_str(), wsCaptionName.c_str()); } - if (pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Warning, - XFA_MB_YesNo) == XFA_IDYes) { + if (pAppProvider->MsgBox(wsNullMsg, wsTitle, + static_cast<uint32_t>(AlertIcon::kWarning), + static_cast<uint32_t>(AlertButton::kYesNo)) == + static_cast<uint32_t>(AlertReturn::kYes)) { SetFlag(XFA_NodeFlag_UserInteractive); } return XFA_EVENTERROR_Error; |