From c3cc2ab66d3d8f52dea8083abb6775115e17af7d Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Thu, 21 Jun 2018 21:09:54 +0000 Subject: 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 Reviewed-by: dsinclair --- xfa/fxfa/parser/cxfa_node.cpp | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'xfa/fxfa/parser/cxfa_node.cpp') 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(AlertIcon::kWarning), + static_cast(AlertButton::kOK)); return; } - if (pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning, - XFA_MB_YesNo) == XFA_IDYes) { + if (pAppProvider->MsgBox(wsScriptMsg, wsTitle, + static_cast(AlertIcon::kWarning), + static_cast(AlertButton::kYesNo)) == + static_cast(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(AlertIcon::kError), + static_cast(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(AlertIcon::kError), + static_cast(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(AlertIcon::kWarning), + static_cast(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(AlertIcon::kWarning), + static_cast(AlertButton::kYesNo)) == + static_cast(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(AlertIcon::kStatus), + static_cast(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(AlertIcon::kWarning), + static_cast(AlertButton::kYesNo)) == + static_cast(AlertReturn::kYes)) { SetFlag(XFA_NodeFlag_UserInteractive); } return XFA_EVENTERROR_Error; -- cgit v1.2.3