summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfxfa
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fpdfxfa')
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_context.cpp64
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp6
2 files changed, 24 insertions, 46 deletions
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;
}