diff options
-rw-r--r-- | fpdfsdk/cpdfsdk_formfillenvironment.cpp | 5 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_formfillenvironment.h | 4 | ||||
-rw-r--r-- | fpdfsdk/fpdf_formfill.cpp | 45 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_context.cpp | 64 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 6 | ||||
-rw-r--r-- | fxjs/cjs_app.cpp | 10 | ||||
-rw-r--r-- | fxjs/cjs_publicmethods.cpp | 3 | ||||
-rw-r--r-- | fxjs/xfa/cjx_hostpseudomodel.cpp | 12 | ||||
-rw-r--r-- | public/fpdf_formfill.h | 119 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffdocview.cpp | 5 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_fffield.cpp | 9 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_fftextedit.cpp | 5 | ||||
-rw-r--r-- | xfa/fxfa/fxfa.h | 39 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.cpp | 39 |
14 files changed, 221 insertions, 144 deletions
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp index 29d88a7e60..b224fc75d0 100644 --- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp +++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp @@ -64,12 +64,13 @@ CPDFSDK_FormFillEnvironment::~CPDFSDK_FormFillEnvironment() { int CPDFSDK_FormFillEnvironment::JS_appAlert(const WideString& Msg, const WideString& Title, - uint32_t Type, - uint32_t Icon) { + int Type, + int Icon) { if (!m_pInfo || !m_pInfo->m_pJsPlatform || !m_pInfo->m_pJsPlatform->app_alert) { return -1; } + ByteString bsMsg = Msg.UTF16LE_Encode(); ByteString bsTitle = Title.UTF16LE_Encode(); return m_pInfo->m_pJsPlatform->app_alert( diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.h b/fpdfsdk/cpdfsdk_formfillenvironment.h index 5bce1ac93a..b0512485dd 100644 --- a/fpdfsdk/cpdfsdk_formfillenvironment.h +++ b/fpdfsdk/cpdfsdk_formfillenvironment.h @@ -165,8 +165,8 @@ class CPDFSDK_FormFillEnvironment int JS_appAlert(const WideString& Msg, const WideString& Title, - uint32_t Type, - uint32_t Icon); + int Type, + int Icon); int JS_appResponse(const WideString& Question, const WideString& Title, const WideString& Default, diff --git a/fpdfsdk/fpdf_formfill.cpp b/fpdfsdk/fpdf_formfill.cpp index 01bea1cf0a..792ced773f 100644 --- a/fpdfsdk/fpdf_formfill.cpp +++ b/fpdfsdk/fpdf_formfill.cpp @@ -33,6 +33,51 @@ #include "xfa/fxfa/cxfa_ffpageview.h" #include "xfa/fxfa/cxfa_ffwidget.h" +static_assert(static_cast<int>(AlertButton::kDefault) == + JSPLATFORM_ALERT_BUTTON_DEFAULT, + "Default alert button types must match"); +static_assert(static_cast<int>(AlertButton::kOK) == JSPLATFORM_ALERT_BUTTON_OK, + "OK alert button types must match"); +static_assert(static_cast<int>(AlertButton::kOKCancel) == + JSPLATFORM_ALERT_BUTTON_OKCANCEL, + "OKCancel alert button types must match"); +static_assert(static_cast<int>(AlertButton::kYesNo) == + JSPLATFORM_ALERT_BUTTON_YESNO, + "YesNo alert button types must match"); +static_assert(static_cast<int>(AlertButton::kYesNoCancel) == + JSPLATFORM_ALERT_BUTTON_YESNOCANCEL, + "YesNoCancel alert button types must match"); + +static_assert(static_cast<int>(AlertIcon::kDefault) == + JSPLATFORM_ALERT_ICON_DEFAULT, + "Default alert icon types must match"); +static_assert(static_cast<int>(AlertIcon::kError) == + JSPLATFORM_ALERT_ICON_ERROR, + "Error alert icon types must match"); +static_assert(static_cast<int>(AlertIcon::kWarning) == + JSPLATFORM_ALERT_ICON_WARNING, + "Warning alert icon types must match"); +static_assert(static_cast<int>(AlertIcon::kQuestion) == + JSPLATFORM_ALERT_ICON_QUESTION, + "Question alert icon types must match"); +static_assert(static_cast<int>(AlertIcon::kStatus) == + JSPLATFORM_ALERT_ICON_STATUS, + "Status alert icon types must match"); +static_assert(static_cast<int>(AlertIcon::kAsterisk) == + JSPLATFORM_ALERT_ICON_ASTERISK, + "Asterisk alert icon types must match"); + +static_assert(static_cast<int>(AlertReturn::kOK) == JSPLATFORM_ALERT_RETURN_OK, + "OK alert return types must match"); +static_assert(static_cast<int>(AlertReturn::kCancel) == + JSPLATFORM_ALERT_RETURN_CANCEL, + "Cancel alert return types must match"); +static_assert(static_cast<int>(AlertReturn::kNo) == JSPLATFORM_ALERT_RETURN_NO, + "No alert return types must match"); +static_assert(static_cast<int>(AlertReturn::kYes) == + JSPLATFORM_ALERT_RETURN_YES, + "Yes alert return types must match"); + static_assert(static_cast<int>(FormType::kNone) == FORMTYPE_NONE, "None form types must match"); static_assert(static_cast<int>(FormType::kAcroForm) == FORMTYPE_ACRO_FORM, diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp index 385bbe7074..d7b3bed849 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp @@ -36,6 +36,19 @@ extern void SetLastError(int err); extern int GetLastError(); #endif +#define IS_VALID_ALERT_BUTTON(type) \ + ((type) == JSPLATFORM_ALERT_BUTTON_OK || \ + (type) == JSPLATFORM_ALERT_BUTTON_OKCANCEL || \ + (type) == JSPLATFORM_ALERT_BUTTON_YESNO || \ + (type) == JSPLATFORM_ALERT_BUTTON_YESNOCANCEL) + +#define IS_VALID_ALERT_ICON(type) \ + ((type) == JSPLATFORM_ALERT_ICON_ERROR || \ + (type) == JSPLATFORM_ALERT_ICON_WARNING || \ + (type) == JSPLATFORM_ALERT_ICON_QUESTION || \ + (type) == JSPLATFORM_ALERT_ICON_STATUS || \ + (type) == JSPLATFORM_ALERT_ICON_ASTERISK) + CPDFXFA_Context::CPDFXFA_Context(CPDF_Document* pPDFDoc) : m_pPDFDoc(pPDFDoc), m_pXFAApp(pdfium::MakeUnique<CXFA_FFApp>(this)), @@ -247,50 +260,13 @@ int32_t CPDFXFA_Context::MsgBox(const WideString& wsMessage, if (!m_pFormFillEnv || m_nLoadStatus != FXFA_LOADSTATUS_LOADED) return -1; - uint32_t iconType = 0; - int iButtonType = 0; - switch (dwIconType) { - case XFA_MBICON_Error: - iconType |= 0; - break; - case XFA_MBICON_Warning: - iconType |= 1; - break; - case XFA_MBICON_Question: - iconType |= 2; - break; - case XFA_MBICON_Status: - iconType |= 3; - break; - } - switch (dwButtonType) { - case XFA_MB_OK: - iButtonType |= 0; - break; - case XFA_MB_OKCancel: - iButtonType |= 1; - break; - case XFA_MB_YesNo: - iButtonType |= 2; - break; - case XFA_MB_YesNoCancel: - iButtonType |= 3; - break; - } - int32_t iRet = - m_pFormFillEnv->JS_appAlert(wsMessage, wsTitle, iButtonType, iconType); - - switch (iRet) { - case 1: - return XFA_IDOK; - case 2: - return XFA_IDCancel; - case 3: - return XFA_IDNo; - case 4: - return XFA_IDYes; - } - return XFA_IDYes; + int iconType = IS_VALID_ALERT_ICON(dwIconType) + ? dwIconType + : JSPLATFORM_ALERT_ICON_DEFAULT; + int iButtonType = IS_VALID_ALERT_BUTTON(dwButtonType) + ? dwButtonType + : JSPLATFORM_ALERT_BUTTON_DEFAULT; + return m_pFormFillEnv->JS_appAlert(wsMessage, wsTitle, iButtonType, iconType); } WideString CPDFXFA_Context::Response(const WideString& wsQuestion, diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp index f3fe89c1e2..9d1ceacf02 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp @@ -656,7 +656,8 @@ bool CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() { return false; pFormFillEnv->JS_appAlert(WideString::FromLocal(IDS_XFA_Validate_Input), - L"", 0, 1); + L"", JSPLATFORM_ALERT_BUTTON_OK, + JSPLATFORM_ALERT_ICON_WARNING); return false; } pNode = it->MoveToNext(); @@ -909,7 +910,8 @@ bool CPDFXFA_DocEnvironment::SubmitInternal(CXFA_FFDoc* hDoc, WideString csURL = submit->GetSubmitTarget(); if (csURL.IsEmpty()) { pFormFillEnv->JS_appAlert(WideString::FromLocal("Submit cancelled."), L"", - 0, 4); + JSPLATFORM_ALERT_BUTTON_OK, + JSPLATFORM_ALERT_ICON_ASTERISK); return false; } diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp index 36a1212715..f52d7e9230 100644 --- a/fxjs/cjs_app.cpp +++ b/fxjs/cjs_app.cpp @@ -254,11 +254,11 @@ CJS_Return CJS_App::alert(CJS_Runtime* pRuntime, swMsg = pRuntime->ToWideString(newParams[0]); } - int iIcon = 0; + int iIcon = JSPLATFORM_ALERT_ICON_DEFAULT; if (IsTypeKnown(newParams[1])) iIcon = pRuntime->ToInt32(newParams[1]); - int iType = 0; + int iType = JSPLATFORM_ALERT_BUTTON_DEFAULT; if (IsTypeKnown(newParams[2])) iType = pRuntime->ToInt32(newParams[2]); @@ -282,7 +282,11 @@ CJS_Return CJS_App::beep(CJS_Runtime* pRuntime, if (params.size() != 1) return CJS_Return(JSMessage::kParamError); - pRuntime->GetFormFillEnv()->JS_appBeep(pRuntime->ToInt32(params[0])); + int type = JSPLATFORM_BEEP_DEFAULT; + if (IsTypeKnown(params[0])) + type = pRuntime->ToInt32(params[0]); + + pRuntime->GetFormFillEnv()->JS_appBeep(type); return CJS_Return(); } diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp index 58a54e5212..a86ece3461 100644 --- a/fxjs/cjs_publicmethods.cpp +++ b/fxjs/cjs_publicmethods.cpp @@ -82,7 +82,8 @@ T StrTrim(const T& str) { void AlertIfPossible(CJS_EventContext* pContext, const WideString& swMsg) { CPDFSDK_FormFillEnvironment* pFormFillEnv = pContext->GetFormFillEnv(); if (pFormFillEnv) - pFormFillEnv->JS_appAlert(swMsg, WideString(), 0, 3); + pFormFillEnv->JS_appAlert(swMsg, WideString(), JSPLATFORM_ALERT_BUTTON_OK, + JSPLATFORM_ALERT_ICON_STATUS); } #if _FX_OS_ != _FX_OS_ANDROID_ diff --git a/fxjs/xfa/cjx_hostpseudomodel.cpp b/fxjs/xfa/cjx_hostpseudomodel.cpp index 6dd160639a..37bc99ad47 100644 --- a/fxjs/xfa/cjx_hostpseudomodel.cpp +++ b/fxjs/xfa/cjx_hostpseudomodel.cpp @@ -502,18 +502,18 @@ CJS_Return CJX_HostPseudoModel::messageBox( if (params.size() >= 2) title = runtime->ToWideString(params[1]); - uint32_t messageType = XFA_MBICON_Error; + uint32_t messageType = static_cast<uint32_t>(AlertIcon::kDefault); if (params.size() >= 3) { messageType = runtime->ToInt32(params[2]); - if (messageType > XFA_MBICON_Status) - messageType = XFA_MBICON_Error; + if (messageType > static_cast<uint32_t>(AlertIcon::kStatus)) + messageType = static_cast<uint32_t>(AlertIcon::kDefault); } - uint32_t buttonType = XFA_MB_OK; + uint32_t buttonType = static_cast<uint32_t>(AlertButton::kDefault); if (params.size() >= 4) { buttonType = runtime->ToInt32(params[3]); - if (buttonType > XFA_MB_YesNoCancel) - buttonType = XFA_MB_OK; + if (buttonType > static_cast<uint32_t>(AlertButton::kYesNoCancel)) + buttonType = static_cast<uint32_t>(AlertButton::kDefault); } int32_t iValue = pNotify->GetAppProvider()->MsgBox(message, title, 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 /** diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp index 51277c91ae..400be36e76 100644 --- a/xfa/fxfa/cxfa_ffdocview.cpp +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -156,8 +156,9 @@ void CXFA_FFDocView::ShowNullTestMsg() { L"validation errors not reported.", iRemain); } - pAppProvider->MsgBox(wsMsg, pAppProvider->GetAppTitle(), XFA_MBICON_Status, - XFA_MB_OK); + pAppProvider->MsgBox(wsMsg, pAppProvider->GetAppTitle(), + static_cast<uint32_t>(AlertIcon::kStatus), + static_cast<uint32_t>(AlertButton::kOK)); } m_arrNullTestMsg.clear(); } diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp index f1b8cffa8f..fe53da1a46 100644 --- a/xfa/fxfa/cxfa_fffield.cpp +++ b/xfa/fxfa/cxfa_fffield.cpp @@ -665,8 +665,9 @@ int32_t CXFA_FFField::CalculateNode(CXFA_Node* pNode) { IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); if (pAppProvider) { pAppProvider->MsgBox(L"You are not allowed to modify this field.", - L"Calculate Override", XFA_MBICON_Warning, - XFA_MB_OK); + L"Calculate Override", + static_cast<uint32_t>(AlertIcon::kWarning), + static_cast<uint32_t>(AlertButton::kOK)); } return 0; } @@ -692,7 +693,9 @@ int32_t CXFA_FFField::CalculateNode(CXFA_Node* pNode) { wsMessage += L"Are you sure you want to modify this field?"; if (pAppProvider->MsgBox(wsMessage, L"Calculate Override", - XFA_MBICON_Warning, XFA_MB_YesNo) == XFA_IDYes) { + static_cast<uint32_t>(AlertIcon::kWarning), + static_cast<uint32_t>(AlertButton::kYesNo)) == + static_cast<uint32_t>(AlertReturn::kYes)) { pNode->SetFlag(XFA_NodeFlag_UserInteractive); return 1; } diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp index 81bc9b3816..e18b099401 100644 --- a/xfa/fxfa/cxfa_fftextedit.cpp +++ b/xfa/fxfa/cxfa_fftextedit.cpp @@ -205,8 +205,9 @@ void CXFA_FFTextEdit::ValidateNumberField(const WideString& wsText) { WideString wsSomField = GetNode()->GetSOMExpression(); pAppProvider->MsgBox(WideString::Format(L"%ls can not contain %ls", wsText.c_str(), wsSomField.c_str()), - pAppProvider->GetAppTitle(), XFA_MBICON_Error, - XFA_MB_OK); + pAppProvider->GetAppTitle(), + static_cast<uint32_t>(AlertIcon::kError), + static_cast<uint32_t>(AlertButton::kOK)); } bool CXFA_FFTextEdit::IsDataChanged() { diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h index 1b0c76f584..c1fdd2bcb7 100644 --- a/xfa/fxfa/fxfa.h +++ b/xfa/fxfa/fxfa.h @@ -23,18 +23,32 @@ class CXFA_Submit; class IFWL_AdapterTimerMgr; class IFX_SeekableReadStream; -#define XFA_MBICON_Error 0 -#define XFA_MBICON_Warning 1 -#define XFA_MBICON_Question 2 -#define XFA_MBICON_Status 3 -#define XFA_MB_OK 0 -#define XFA_MB_OKCancel 1 -#define XFA_MB_YesNo 2 -#define XFA_MB_YesNoCancel 3 -#define XFA_IDOK 1 -#define XFA_IDCancel 2 -#define XFA_IDNo 3 -#define XFA_IDYes 4 +// Note, values must match fpdf_formfill.h JSPLATFORM_ALERT_BUTTON_* flags. +enum class AlertButton { + kDefault = 0, + kOK = 0, + kOKCancel = 1, + kYesNo = 2, + kYesNoCancel = 3, +}; + +// Note, values must match fpdf_formfill.h JSPLATFORM_ALERT_ICON_* flags. +enum class AlertIcon { + kDefault = 0, + kError = 0, + kWarning = 1, + kQuestion = 2, + kStatus = 3, + kAsterisk = 4, +}; + +// Note, values must match fpdf_formfill.h JSPLATFORM_ALERT_RETURN_* flags. +enum class AlertReturn { + kOK = 1, + kCancel = 2, + kNo = 3, + kYes = 4, +}; // Note, values must match fpdf_formfill.h FORMTYPE_* flags. enum class FormType { @@ -50,6 +64,7 @@ enum class FormType { #define XFA_PRINTOPT_AsImage 0x00000008 #define XFA_PRINTOPT_ReverseOrder 0x00000010 #define XFA_PRINTOPT_PrintAnnot 0x00000020 + #define XFA_PAGEVIEWEVENT_PostAdded 1 #define XFA_PAGEVIEWEVENT_PostRemoved 3 #define XFA_PAGEVIEWEVENT_StopLayout 4 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; |