diff options
Diffstat (limited to 'fpdfsdk')
-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 |
5 files changed, 74 insertions, 50 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; } |