diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-08-17 16:44:50 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-08-17 16:44:50 +0000 |
commit | 20736f7f5884cf1e2827543c92b6e47f8282aeaf (patch) | |
tree | 9a0f3cbd9262d1676f70ab02c3fa5b4e0acaa03a /fxjs/cjs_field.cpp | |
parent | 21068062a038db72b5ee40512fe638acbdd17c3d (diff) | |
download | pdfium-20736f7f5884cf1e2827543c92b6e47f8282aeaf.tar.xz |
Introduce safer CJS_Return::Success() and Failure().
Avoid the possibility of ever re-introducing the issue noticed
last week.
Remove some redundant JSGetStringFromID() calls.
Change-Id: I56687c2191bd72e378f747083f34080e50cbe490
Reviewed-on: https://pdfium-review.googlesource.com/40490
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/cjs_field.cpp')
-rw-r--r-- | fxjs/cjs_field.cpp | 752 |
1 files changed, 378 insertions, 374 deletions
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp index a14e16828a..4e7baf4a62 100644 --- a/fxjs/cjs_field.cpp +++ b/fxjs/cjs_field.cpp @@ -670,32 +670,33 @@ CJS_Return CJS_Field::get_alignment(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); switch (pFormControl->GetControlAlignment()) { case 0: - return CJS_Return(pRuntime->NewString(L"left")); + return CJS_Return::Success(pRuntime->NewString(L"left")); case 1: - return CJS_Return(pRuntime->NewString(L"center")); + return CJS_Return::Success(pRuntime->NewString(L"center")); case 2: - return CJS_Return(pRuntime->NewString(L"right")); + return CJS_Return::Success(pRuntime->NewString(L"right")); } - return CJS_Return(pRuntime->NewString(L"")); + return CJS_Return::Success(pRuntime->NewString(L"")); } CJS_Return CJS_Field::set_alignment(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + + return CJS_Return::Success(); } CJS_Return CJS_Field::get_border_style(CJS_Runtime* pRuntime) { @@ -703,35 +704,33 @@ CJS_Return CJS_Field::get_border_style(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); - - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDFSDK_Widget* pWidget = GetWidget(m_pFormFillEnv.Get(), GetSmartFieldControl(pFormField)); if (!pWidget) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); switch (pWidget->GetBorderStyle()) { case BorderStyle::SOLID: - return CJS_Return(pRuntime->NewString(L"solid")); + return CJS_Return::Success(pRuntime->NewString(L"solid")); case BorderStyle::DASH: - return CJS_Return(pRuntime->NewString(L"dashed")); + return CJS_Return::Success(pRuntime->NewString(L"dashed")); case BorderStyle::BEVELED: - return CJS_Return(pRuntime->NewString(L"beveled")); + return CJS_Return::Success(pRuntime->NewString(L"beveled")); case BorderStyle::INSET: - return CJS_Return(pRuntime->NewString(L"inset")); + return CJS_Return::Success(pRuntime->NewString(L"inset")); case BorderStyle::UNDERLINE: - return CJS_Return(pRuntime->NewString(L"underline")); + return CJS_Return::Success(pRuntime->NewString(L"underline")); } - return CJS_Return(pRuntime->NewString(L"")); + return CJS_Return::Success(pRuntime->NewString(L"")); } CJS_Return CJS_Field::set_border_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); ByteString byte_str = pRuntime->ToWideString(vp).ToDefANSI(); if (m_bDelay) { @@ -740,7 +739,7 @@ CJS_Return CJS_Field::set_border_style(CJS_Runtime* pRuntime, SetBorderStyle(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, byte_str); } - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_button_align_x(CJS_Runtime* pRuntime) { @@ -748,29 +747,29 @@ CJS_Return CJS_Field::get_button_align_x(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDF_IconFit IconFit = pFormControl->GetIconFit(); float fLeft; float fBottom; IconFit.GetIconPosition(fLeft, fBottom); - return CJS_Return(pRuntime->NewNumber(static_cast<int32_t>(fLeft))); + return CJS_Return::Success(pRuntime->NewNumber(static_cast<int32_t>(fLeft))); } CJS_Return CJS_Field::set_button_align_x(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_button_align_y(CJS_Runtime* pRuntime) { @@ -778,14 +777,14 @@ CJS_Return CJS_Field::get_button_align_y(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDF_IconFit IconFit = pFormControl->GetIconFit(); @@ -793,15 +792,16 @@ CJS_Return CJS_Field::get_button_align_y(CJS_Runtime* pRuntime) { float fBottom; IconFit.GetIconPosition(fLeft, fBottom); - return CJS_Return(pRuntime->NewNumber(static_cast<int32_t>(fBottom))); + return CJS_Return::Success( + pRuntime->NewNumber(static_cast<int32_t>(fBottom))); } CJS_Return CJS_Field::set_button_align_y(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_button_fit_bounds(CJS_Runtime* pRuntime) { @@ -809,16 +809,16 @@ CJS_Return CJS_Field::get_button_fit_bounds(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return( + return CJS_Return::Success( pRuntime->NewBoolean(pFormControl->GetIconFit().GetFittingBounds())); } @@ -826,8 +826,8 @@ CJS_Return CJS_Field::set_button_fit_bounds(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_button_position(CJS_Runtime* pRuntime) { @@ -835,24 +835,25 @@ CJS_Return CJS_Field::get_button_position(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return(pRuntime->NewNumber(pFormControl->GetTextPosition())); + return CJS_Return::Success( + pRuntime->NewNumber(pFormControl->GetTextPosition())); } CJS_Return CJS_Field::set_button_position(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kBadObjectError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_button_scale_how(CJS_Runtime* pRuntime) { @@ -860,16 +861,16 @@ CJS_Return CJS_Field::get_button_scale_how(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return(pRuntime->NewBoolean( + return CJS_Return::Success(pRuntime->NewBoolean( pFormControl->GetIconFit().IsProportionalScale() ? 0 : 1)); } @@ -877,8 +878,8 @@ CJS_Return CJS_Field::set_button_scale_how(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_button_scale_when(CJS_Runtime* pRuntime) { @@ -886,40 +887,40 @@ CJS_Return CJS_Field::get_button_scale_when(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDF_IconFit IconFit = pFormControl->GetIconFit(); int ScaleM = IconFit.GetScaleMethod(); switch (ScaleM) { case CPDF_IconFit::Always: - return CJS_Return( + return CJS_Return::Success( pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Always))); case CPDF_IconFit::Bigger: - return CJS_Return( + return CJS_Return::Success( pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Bigger))); case CPDF_IconFit::Never: - return CJS_Return( + return CJS_Return::Success( pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Never))); case CPDF_IconFit::Smaller: - return CJS_Return( + return CJS_Return::Success( pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Smaller))); } - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::set_button_scale_when(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_calc_order_index(CJS_Runtime* pRuntime) { @@ -927,14 +928,14 @@ CJS_Return CJS_Field::get_calc_order_index(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (!IsComboBoxOrTextField(pFormField)) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm(); CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); - return CJS_Return(pRuntime->NewNumber(static_cast<int32_t>( + return CJS_Return::Success(pRuntime->NewNumber(static_cast<int32_t>( pInterForm->FindFieldInCalculationOrder(pFormField)))); } @@ -942,8 +943,8 @@ CJS_Return CJS_Field::set_calc_order_index(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_char_limit(CJS_Runtime* pRuntime) { @@ -951,11 +952,11 @@ CJS_Return CJS_Field::get_char_limit(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(JSMessage::kObjectTypeError); - return CJS_Return( + return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Return::Success( pRuntime->NewNumber(static_cast<int32_t>(pFormField->GetMaxLen()))); } @@ -963,8 +964,8 @@ CJS_Return CJS_Field::set_char_limit(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_comb(CJS_Runtime* pRuntime) { @@ -972,20 +973,20 @@ CJS_Return CJS_Field::get_comb(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); - return CJS_Return( + return CJS_Return::Success( pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_COMB))); } CJS_Return CJS_Field::set_comb(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_commit_on_sel_change(CJS_Runtime* pRuntime) { @@ -993,12 +994,12 @@ CJS_Return CJS_Field::get_commit_on_sel_change(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (!IsComboBoxOrListBox(pFormField)) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); - return CJS_Return(pRuntime->NewBoolean( + return CJS_Return::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE))); } @@ -1006,23 +1007,24 @@ CJS_Return CJS_Field::set_commit_on_sel_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_current_value_indices(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (!IsComboBoxOrListBox(pFormField)) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); int count = pFormField->CountSelectedItems(); if (count <= 0) - return CJS_Return(pRuntime->NewNumber(-1)); + return CJS_Return::Success(pRuntime->NewNumber(-1)); if (count == 1) - return CJS_Return(pRuntime->NewNumber(pFormField->GetSelectedIndex(0))); + return CJS_Return::Success( + pRuntime->NewNumber(pFormField->GetSelectedIndex(0))); v8::Local<v8::Array> SelArray = pRuntime->NewArray(); for (int i = 0; i < count; i++) { @@ -1030,14 +1032,14 @@ CJS_Return CJS_Field::get_current_value_indices(CJS_Runtime* pRuntime) { SelArray, i, pRuntime->NewNumber(pFormField->GetSelectedIndex(i))); } if (SelArray.IsEmpty()) - return CJS_Return(pRuntime->NewArray()); - return CJS_Return(SelArray); + return CJS_Return::Success(pRuntime->NewArray()); + return CJS_Return::Success(SelArray); } CJS_Return CJS_Field::set_current_value_indices(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); std::vector<uint32_t> array; if (vp->IsNumber()) { @@ -1056,16 +1058,16 @@ CJS_Return CJS_Field::set_current_value_indices(CJS_Runtime* pRuntime, SetCurrentValueIndices(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, array); } - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_default_style(CJS_Runtime* pRuntime) { - return CJS_Return(JSMessage::kNotSupportedError); + return CJS_Return::Failure(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::set_default_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(JSMessage::kNotSupportedError); + return CJS_Return::Failure(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::get_default_value(CJS_Runtime* pRuntime) { @@ -1073,14 +1075,14 @@ CJS_Return CJS_Field::get_default_value(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() == FormFieldType::kPushButton || pFormField->GetFieldType() == FormFieldType::kSignature) { - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); } - return CJS_Return( + return CJS_Return::Success( pRuntime->NewString(pFormField->GetDefaultValue().AsStringView())); } @@ -1088,8 +1090,8 @@ CJS_Return CJS_Field::set_default_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_do_not_scroll(CJS_Runtime* pRuntime) { @@ -1097,12 +1099,12 @@ CJS_Return CJS_Field::get_do_not_scroll(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); - return CJS_Return(pRuntime->NewBoolean( + return CJS_Return::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL))); } @@ -1110,8 +1112,8 @@ CJS_Return CJS_Field::set_do_not_scroll(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_do_not_spell_check(CJS_Runtime* pRuntime) { @@ -1119,12 +1121,12 @@ CJS_Return CJS_Field::get_do_not_spell_check(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (!IsComboBoxOrTextField(pFormField)) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); - return CJS_Return(pRuntime->NewBoolean( + return CJS_Return::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK))); } @@ -1132,8 +1134,8 @@ CJS_Return CJS_Field::set_do_not_spell_check(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } void CJS_Field::SetDelay(bool bDelay) { @@ -1146,45 +1148,45 @@ void CJS_Field::SetDelay(bool bDelay) { } CJS_Return CJS_Field::get_delay(CJS_Runtime* pRuntime) { - return CJS_Return(pRuntime->NewBoolean(m_bDelay)); + return CJS_Return::Success(pRuntime->NewBoolean(m_bDelay)); } CJS_Return CJS_Field::set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); SetDelay(pRuntime->ToBoolean(vp)); - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_display(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField)); if (!pWidget) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); uint32_t dwFlag = pWidget->GetFlags(); if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) - return CJS_Return(pRuntime->NewNumber(1)); + return CJS_Return::Success(pRuntime->NewNumber(1)); if (ANNOTFLAG_PRINT & dwFlag) { if (ANNOTFLAG_NOVIEW & dwFlag) - return CJS_Return(pRuntime->NewNumber(3)); - return CJS_Return(pRuntime->NewNumber(0)); + return CJS_Return::Success(pRuntime->NewNumber(3)); + return CJS_Return::Success(pRuntime->NewNumber(0)); } - return CJS_Return(pRuntime->NewNumber(2)); + return CJS_Return::Success(pRuntime->NewNumber(2)); } CJS_Return CJS_Field::set_display(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); if (m_bDelay) { AddDelay_Int(FP_DISPLAY, pRuntime->ToInt32(vp)); @@ -1192,43 +1194,43 @@ CJS_Return CJS_Field::set_display(CJS_Runtime* pRuntime, SetDisplay(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, pRuntime->ToInt32(vp)); } - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_doc(CJS_Runtime* pRuntime) { - return CJS_Return(m_pJSDoc->ToV8Object()); + return CJS_Return::Success(m_pJSDoc->ToV8Object()); } CJS_Return CJS_Field::set_doc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(JSMessage::kNotSupportedError); + return CJS_Return::Failure(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::get_editable(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kComboBox) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); - return CJS_Return( + return CJS_Return::Success( pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_EDIT))); } CJS_Return CJS_Field::set_editable(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_export_values(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (!IsCheckBoxOrRadioButton(pFormField)) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); v8::Local<v8::Array> ExportValuesArray = pRuntime->NewArray(); if (m_nFormControlIndex < 0) { @@ -1240,47 +1242,47 @@ CJS_Return CJS_Field::get_export_values(CJS_Runtime* pRuntime) { } } else { if (m_nFormControlIndex >= pFormField->CountControls()) - return CJS_Return(JSMessage::kValueError); + return CJS_Return::Failure(JSMessage::kValueError); CPDF_FormControl* pFormControl = pFormField->GetControl(m_nFormControlIndex); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); pRuntime->PutArrayElement( ExportValuesArray, 0, pRuntime->NewString(pFormControl->GetExportValue().AsStringView())); } - return CJS_Return(ExportValuesArray); + return CJS_Return::Success(ExportValuesArray); } CJS_Return CJS_Field::set_export_values(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (!IsCheckBoxOrRadioButton(pFormField)) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); if (vp.IsEmpty() || !vp->IsArray()) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_file_select(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); - return CJS_Return(pRuntime->NewBoolean( + return CJS_Return::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT))); } @@ -1288,25 +1290,25 @@ CJS_Return CJS_Field::set_file_select(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_fill_color(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); int iColorType; pFormControl->GetBackgroundColor(iColorType); @@ -1329,48 +1331,48 @@ CJS_Return CJS_Field::get_fill_color(CJS_Runtime* pRuntime) { pFormControl->GetOriginalBackgroundColor(2), pFormControl->GetOriginalBackgroundColor(3)); } else { - return CJS_Return(JSMessage::kValueError); + return CJS_Return::Failure(JSMessage::kValueError); } v8::Local<v8::Value> array = CJS_Color::ConvertPWLColorToArray(pRuntime, color); if (array.IsEmpty()) - return CJS_Return(pRuntime->NewArray()); - return CJS_Return(array); + return CJS_Return::Success(pRuntime->NewArray()); + return CJS_Return::Success(array); } CJS_Return CJS_Field::set_fill_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(); if (FieldArray.empty()) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); if (vp.IsEmpty() || !vp->IsArray()) - return CJS_Return(JSMessage::kBadObjectError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_hidden(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField)); if (!pWidget) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); uint32_t dwFlags = pWidget->GetFlags(); - return CJS_Return(pRuntime->NewBoolean(ANNOTFLAG_INVISIBLE & dwFlags || - ANNOTFLAG_HIDDEN & dwFlags)); + return CJS_Return::Success(pRuntime->NewBoolean( + ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags)); } CJS_Return CJS_Field::set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); if (m_bDelay) { AddDelay_Bool(FP_HIDDEN, pRuntime->ToBoolean(vp)); @@ -1378,7 +1380,7 @@ CJS_Return CJS_Field::set_hidden(CJS_Runtime* pRuntime, SetHidden(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, pRuntime->ToBoolean(vp)); } - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_highlight(CJS_Runtime* pRuntime) { @@ -1386,63 +1388,63 @@ CJS_Return CJS_Field::get_highlight(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); int eHM = pFormControl->GetHighlightingMode(); switch (eHM) { case CPDF_FormControl::None: - return CJS_Return(pRuntime->NewString(L"none")); + return CJS_Return::Success(pRuntime->NewString(L"none")); case CPDF_FormControl::Push: - return CJS_Return(pRuntime->NewString(L"push")); + return CJS_Return::Success(pRuntime->NewString(L"push")); case CPDF_FormControl::Invert: - return CJS_Return(pRuntime->NewString(L"invert")); + return CJS_Return::Success(pRuntime->NewString(L"invert")); case CPDF_FormControl::Outline: - return CJS_Return(pRuntime->NewString(L"outline")); + return CJS_Return::Success(pRuntime->NewString(L"outline")); case CPDF_FormControl::Toggle: - return CJS_Return(pRuntime->NewString(L"toggle")); + return CJS_Return::Success(pRuntime->NewString(L"toggle")); } - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::set_highlight(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_line_width(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); if (!pFormField->CountControls()) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(0)); if (!pWidget) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return(pRuntime->NewNumber(pWidget->GetBorderWidth())); + return CJS_Return::Success(pRuntime->NewNumber(pWidget->GetBorderWidth())); } CJS_Return CJS_Field::set_line_width(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); if (m_bDelay) { AddDelay_Int(FP_LINEWIDTH, pRuntime->ToInt32(vp)); @@ -1450,7 +1452,7 @@ CJS_Return CJS_Field::set_line_width(CJS_Runtime* pRuntime, SetLineWidth(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, pRuntime->ToInt32(vp)); } - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_multiline(CJS_Runtime* pRuntime) { @@ -1458,12 +1460,12 @@ CJS_Return CJS_Field::get_multiline(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); - return CJS_Return(pRuntime->NewBoolean( + return CJS_Return::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE))); } @@ -1471,20 +1473,20 @@ CJS_Return CJS_Field::set_multiline(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_multiple_selection(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kListBox) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); - return CJS_Return(pRuntime->NewBoolean( + return CJS_Return::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT))); } @@ -1492,69 +1494,69 @@ CJS_Return CJS_Field::set_multiple_selection(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_name(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(); if (FieldArray.empty()) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return(pRuntime->NewString(m_FieldName.AsStringView())); + return CJS_Return::Success(pRuntime->NewString(m_FieldName.AsStringView())); } CJS_Return CJS_Field::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(JSMessage::kNotSupportedError); + return CJS_Return::Failure(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::get_num_items(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (!IsComboBoxOrListBox(pFormField)) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); - return CJS_Return(pRuntime->NewNumber(pFormField->CountOptions())); + return CJS_Return::Success(pRuntime->NewNumber(pFormField->CountOptions())); } CJS_Return CJS_Field::set_num_items(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(JSMessage::kNotSupportedError); + return CJS_Return::Failure(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::get_page(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); std::vector<CPDFSDK_Annot::ObservedPtr> widgets; m_pFormFillEnv->GetInterForm()->GetWidgets(pFormField, &widgets); if (widgets.empty()) - return CJS_Return(pRuntime->NewNumber(-1)); + return CJS_Return::Success(pRuntime->NewNumber(-1)); v8::Local<v8::Array> PageArray = pRuntime->NewArray(); int i = 0; for (const auto& pObserved : widgets) { if (!pObserved) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); auto* pWidget = ToCPDFSDKWidget(pObserved.Get()); CPDFSDK_PageView* pPageView = pWidget->GetPageView(); if (!pPageView) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); pRuntime->PutArrayElement( PageArray, i, pRuntime->NewNumber(static_cast<int32_t>(pPageView->GetPageIndex()))); ++i; } - return CJS_Return(PageArray); + return CJS_Return::Success(PageArray); } CJS_Return CJS_Field::set_page(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); } CJS_Return CJS_Field::get_password(CJS_Runtime* pRuntime) { @@ -1562,12 +1564,12 @@ CJS_Return CJS_Field::get_password(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); - return CJS_Return(pRuntime->NewBoolean( + return CJS_Return::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD))); } @@ -1575,22 +1577,22 @@ CJS_Return CJS_Field::set_password(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_print(CJS_Runtime* pRuntime) { CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField)); if (!pWidget) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return( + return CJS_Return::Success( pRuntime->NewBoolean(!!(pWidget->GetFlags() & ANNOTFLAG_PRINT))); } @@ -1599,10 +1601,10 @@ CJS_Return CJS_Field::set_print(CJS_Runtime* pRuntime, CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); std::vector<CPDF_FormField*> FieldArray = GetFormFields(); if (FieldArray.empty()) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); for (CPDF_FormField* pFormField : FieldArray) { if (m_nFormControlIndex < 0) { @@ -1630,7 +1632,7 @@ CJS_Return CJS_Field::set_print(CJS_Runtime* pRuntime, } if (m_nFormControlIndex >= pFormField->CountControls()) - return CJS_Return(JSMessage::kValueError); + return CJS_Return::Failure(JSMessage::kValueError); if (CPDF_FormControl* pFormControl = pFormField->GetControl(m_nFormControlIndex)) { @@ -1650,18 +1652,18 @@ CJS_Return CJS_Field::set_print(CJS_Runtime* pRuntime, } } } - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_radios_in_unison(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kRadioButton) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); - return CJS_Return(pRuntime->NewBoolean( + return CJS_Return::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON))); } @@ -1669,18 +1671,18 @@ CJS_Return CJS_Field::set_radios_in_unison(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(); if (FieldArray.empty()) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_readonly(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return(pRuntime->NewBoolean( + return CJS_Return::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_READONLY))); } @@ -1688,22 +1690,22 @@ CJS_Return CJS_Field::set_readonly(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(); if (FieldArray.empty()) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_rect(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField)); if (!pWidget) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CFX_FloatRect crRect = pWidget->GetRect(); v8::Local<v8::Array> rcArray = pRuntime->NewArray(); @@ -1716,18 +1718,18 @@ CJS_Return CJS_Field::get_rect(CJS_Runtime* pRuntime) { pRuntime->PutArrayElement( rcArray, 3, pRuntime->NewNumber(static_cast<int32_t>(crRect.bottom))); - return CJS_Return(rcArray); + return CJS_Return::Success(rcArray); } CJS_Return CJS_Field::set_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); if (vp.IsEmpty() || !vp->IsArray()) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); v8::Local<v8::Array> rcArray = pRuntime->ToArray(vp); if (pRuntime->GetArrayLength(rcArray) < 4) - return CJS_Return(JSMessage::kValueError); + return CJS_Return::Failure(JSMessage::kValueError); float pArray[4]; pArray[0] = static_cast<float>( @@ -1745,18 +1747,18 @@ CJS_Return CJS_Field::set_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { } else { SetRect(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, crRect); } - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_required(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() == FormFieldType::kPushButton) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); - return CJS_Return(pRuntime->NewBoolean( + return CJS_Return::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED))); } @@ -1764,10 +1766,10 @@ CJS_Return CJS_Field::set_required(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(); if (FieldArray.empty()) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_rich_text(CJS_Runtime* pRuntime) { @@ -1775,12 +1777,12 @@ CJS_Return CJS_Field::get_rich_text(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); - return CJS_Return(pRuntime->NewBoolean( + return CJS_Return::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT))); } @@ -1788,17 +1790,17 @@ CJS_Return CJS_Field::set_rich_text(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_rich_value(CJS_Runtime* pRuntime) { - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::set_rich_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_rotation(CJS_Runtime* pRuntime) { @@ -1806,31 +1808,31 @@ CJS_Return CJS_Field::get_rotation(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return(pRuntime->NewNumber(pFormControl->GetRotation())); + return CJS_Return::Success(pRuntime->NewNumber(pFormControl->GetRotation())); } CJS_Return CJS_Field::set_rotation(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_stroke_color(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); int iColorType; pFormControl->GetBorderColor(iColorType); @@ -1851,23 +1853,23 @@ CJS_Return CJS_Field::get_stroke_color(CJS_Runtime* pRuntime) { pFormControl->GetOriginalBorderColor(2), pFormControl->GetOriginalBorderColor(3)); } else { - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); } v8::Local<v8::Value> array = CJS_Color::ConvertPWLColorToArray(pRuntime, color); if (array.IsEmpty()) - return CJS_Return(pRuntime->NewArray()); - return CJS_Return(array); + return CJS_Return::Success(pRuntime->NewArray()); + return CJS_Return::Success(array); } CJS_Return CJS_Field::set_stroke_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); if (vp.IsEmpty() || !vp->IsArray()) - return CJS_Return(JSMessage::kBadObjectError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_style(CJS_Runtime* pRuntime) { @@ -1875,14 +1877,14 @@ CJS_Return CJS_Field::get_style(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (!IsCheckBoxOrRadioButton(pFormField)) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); WideString csWCaption = pFormControl->GetNormalCaption(); ByteString csBCaption; @@ -1907,7 +1909,7 @@ CJS_Return CJS_Field::get_style(CJS_Runtime* pRuntime) { csBCaption = "check"; break; } - return CJS_Return(pRuntime->NewString( + return CJS_Return::Success(pRuntime->NewString( WideString::FromLocal(csBCaption.AsStringView()).AsStringView())); } @@ -1915,27 +1917,27 @@ CJS_Return CJS_Field::set_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_submit_name(CJS_Runtime* pRuntime) { - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::set_submit_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_text_color(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); Optional<CFX_Color::Type> iColorType; FX_ARGB color; @@ -1957,17 +1959,17 @@ CJS_Return CJS_Field::get_text_color(CJS_Runtime* pRuntime) { v8::Local<v8::Value> array = CJS_Color::ConvertPWLColorToArray(pRuntime, crRet); if (array.IsEmpty()) - return CJS_Return(pRuntime->NewArray()); - return CJS_Return(array); + return CJS_Return::Success(pRuntime->NewArray()); + return CJS_Return::Success(array); } CJS_Return CJS_Field::set_text_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); if (vp.IsEmpty() || !vp->IsArray()) - return CJS_Return(JSMessage::kBadObjectError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_text_font(CJS_Runtime* pRuntime) { @@ -1975,25 +1977,25 @@ CJS_Return CJS_Field::get_text_font(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); FormFieldType fieldType = pFormField->GetFieldType(); if (fieldType != FormFieldType::kPushButton && fieldType != FormFieldType::kComboBox && fieldType != FormFieldType::kListBox && fieldType != FormFieldType::kTextField) { - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); } CPDF_Font* pFont = pFormControl->GetDefaultControlFont(); if (!pFont) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return(pRuntime->NewString( + return CJS_Return::Success(pRuntime->NewString( WideString::FromLocal(pFont->GetBaseFont().AsStringView()) .AsStringView())); } @@ -2003,10 +2005,10 @@ CJS_Return CJS_Field::set_text_font(CJS_Runtime* pRuntime, ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); if (pRuntime->ToWideString(vp).ToDefANSI().IsEmpty()) - return CJS_Return(JSMessage::kValueError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_text_size(CJS_Runtime* pRuntime) { @@ -2014,55 +2016,55 @@ CJS_Return CJS_Field::get_text_size(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); float fFontSize; CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance(); FieldAppearance.GetFont(&fFontSize); - return CJS_Return(pRuntime->NewNumber(static_cast<int>(fFontSize))); + return CJS_Return::Success(pRuntime->NewNumber(static_cast<int>(fFontSize))); } CJS_Return CJS_Field::set_text_size(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_type(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); switch (pFormField->GetFieldType()) { case FormFieldType::kUnknown: - return CJS_Return(pRuntime->NewString(L"unknown")); + return CJS_Return::Success(pRuntime->NewString(L"unknown")); case FormFieldType::kPushButton: - return CJS_Return(pRuntime->NewString(L"button")); + return CJS_Return::Success(pRuntime->NewString(L"button")); case FormFieldType::kCheckBox: - return CJS_Return(pRuntime->NewString(L"checkbox")); + return CJS_Return::Success(pRuntime->NewString(L"checkbox")); case FormFieldType::kRadioButton: - return CJS_Return(pRuntime->NewString(L"radiobutton")); + return CJS_Return::Success(pRuntime->NewString(L"radiobutton")); case FormFieldType::kComboBox: - return CJS_Return(pRuntime->NewString(L"combobox")); + return CJS_Return::Success(pRuntime->NewString(L"combobox")); case FormFieldType::kListBox: - return CJS_Return(pRuntime->NewString(L"listbox")); + return CJS_Return::Success(pRuntime->NewString(L"listbox")); case FormFieldType::kTextField: - return CJS_Return(pRuntime->NewString(L"text")); + return CJS_Return::Success(pRuntime->NewString(L"text")); case FormFieldType::kSignature: - return CJS_Return(pRuntime->NewString(L"signature")); + return CJS_Return::Success(pRuntime->NewString(L"signature")); default: - return CJS_Return(pRuntime->NewString(L"unknown")); + return CJS_Return::Success(pRuntime->NewString(L"unknown")); } } CJS_Return CJS_Field::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(JSMessage::kNotSupportedError); + return CJS_Return::Failure(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::get_user_name(CJS_Runtime* pRuntime) { @@ -2070,9 +2072,9 @@ CJS_Return CJS_Field::get_user_name(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return( + return CJS_Return::Success( pRuntime->NewString(pFormField->GetAlternateName().AsStringView())); } @@ -2080,19 +2082,19 @@ CJS_Return CJS_Field::set_user_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); - return CJS_Return(); + return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_value(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); v8::Local<v8::Value> ret; switch (pFormField->GetFieldType()) { case FormFieldType::kPushButton: - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); case FormFieldType::kComboBox: case FormFieldType::kTextField: ret = pRuntime->NewString(pFormField->GetValue().AsStringView()); @@ -2138,13 +2140,13 @@ CJS_Return CJS_Field::get_value(CJS_Runtime* pRuntime) { ret = pRuntime->NewString(pFormField->GetValue().AsStringView()); break; } - return CJS_Return(pRuntime->MaybeCoerceToNumber(ret)); + return CJS_Return::Success(pRuntime->MaybeCoerceToNumber(ret)); } CJS_Return CJS_Field::set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); std::vector<WideString> strArray; if (!vp.IsEmpty() && vp->IsArray()) { @@ -2162,21 +2164,21 @@ CJS_Return CJS_Field::set_value(CJS_Runtime* pRuntime, } else { SetValue(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, strArray); } - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::get_value_as_string(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() == FormFieldType::kPushButton) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); if (pFormField->GetFieldType() == FormFieldType::kCheckBox) { if (!pFormField->CountControls()) - return CJS_Return(JSMessage::kBadObjectError); - return CJS_Return(pRuntime->NewString( + return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Return::Success(pRuntime->NewString( pFormField->GetControl(0)->IsChecked() ? L"Yes" : L"Off")); } @@ -2184,23 +2186,24 @@ CJS_Return CJS_Field::get_value_as_string(CJS_Runtime* pRuntime) { !(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)) { for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { if (pFormField->GetControl(i)->IsChecked()) { - return CJS_Return(pRuntime->NewString( + return CJS_Return::Success(pRuntime->NewString( pFormField->GetControl(i)->GetExportValue().AsStringView())); } } - return CJS_Return(pRuntime->NewString(L"Off")); + return CJS_Return::Success(pRuntime->NewString(L"Off")); } if (pFormField->GetFieldType() == FormFieldType::kListBox && (pFormField->CountSelectedItems() > 1)) { - return CJS_Return(pRuntime->NewString(L"")); + return CJS_Return::Success(pRuntime->NewString(L"")); } - return CJS_Return(pRuntime->NewString(pFormField->GetValue().AsStringView())); + return CJS_Return::Success( + pRuntime->NewString(pFormField->GetValue().AsStringView())); } CJS_Return CJS_Field::set_value_as_string(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(JSMessage::kNotSupportedError); + return CJS_Return::Failure(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::browseForFileToSubmit( @@ -2208,7 +2211,7 @@ CJS_Return CJS_Field::browseForFileToSubmit( const std::vector<v8::Local<v8::Value>>& params) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) && (pFormField->GetFieldType() == FormFieldType::kTextField)) { @@ -2217,9 +2220,9 @@ CJS_Return CJS_Field::browseForFileToSubmit( pFormField->SetValue(wsFileName, NotificationOption::kDoNotNotify); UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, true, true); } - return CJS_Return(); + return CJS_Return::Success(); } - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); } CJS_Return CJS_Field::buttonGetCaption( @@ -2232,28 +2235,28 @@ CJS_Return CJS_Field::buttonGetCaption( CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (nface == 0) { - return CJS_Return( + return CJS_Return::Success( pRuntime->NewString(pFormControl->GetNormalCaption().AsStringView())); } if (nface == 1) { - return CJS_Return( + return CJS_Return::Success( pRuntime->NewString(pFormControl->GetDownCaption().AsStringView())); } if (nface == 2) { - return CJS_Return( + return CJS_Return::Success( pRuntime->NewString(pFormControl->GetRolloverCaption().AsStringView())); } - return CJS_Return(JSMessage::kValueError); + return CJS_Return::Failure(JSMessage::kValueError); } CJS_Return CJS_Field::buttonGetIcon( @@ -2262,46 +2265,46 @@ CJS_Return CJS_Field::buttonGetIcon( if (params.size() >= 1) { int nFace = pRuntime->ToInt32(params[0]); if (nFace < 0 || nFace > 2) - return CJS_Return(JSMessage::kValueError); + return CJS_Return::Failure(JSMessage::kValueError); } CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject( CJS_Icon::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC); if (pObj.IsEmpty()) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); auto* pJS_Icon = static_cast<CJS_Icon*>(CFXJS_Engine::GetObjectPrivate(pObj)); - return pJS_Icon ? CJS_Return(pJS_Icon->ToV8Object()) - : CJS_Return(JSMessage::kBadObjectError); + return pJS_Icon ? CJS_Return::Success(pJS_Icon->ToV8Object()) + : CJS_Return::Failure(JSMessage::kBadObjectError); } CJS_Return CJS_Field::buttonImportIcon( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::buttonSetCaption( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(JSMessage::kNotSupportedError); + return CJS_Return::Failure(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::buttonSetIcon( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(JSMessage::kNotSupportedError); + return CJS_Return::Failure(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::checkThisBox( @@ -2309,10 +2312,10 @@ CJS_Return CJS_Field::checkThisBox( const std::vector<v8::Local<v8::Value>>& params) { int iSize = params.size(); if (iSize < 1) - return CJS_Return(JSMessage::kParamError); + return CJS_Return::Failure(JSMessage::kParamError); if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); int nWidget = pRuntime->ToInt32(params[0]); bool bCheckit = true; @@ -2321,52 +2324,53 @@ CJS_Return CJS_Field::checkThisBox( CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (!IsCheckBoxOrRadioButton(pFormField)) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); if (nWidget < 0 || nWidget >= pFormField->CountControls()) - return CJS_Return(JSMessage::kValueError); + return CJS_Return::Failure(JSMessage::kValueError); // TODO(weili): Check whether anything special needed for radio button. // (When pFormField->GetFieldType() == FormFieldType::kRadioButton.) pFormField->CheckControl(nWidget, bCheckit, NotificationOption::kNotify); UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, true, true); - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::clearItems( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::defaultIsChecked( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_bCanSet) - return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return::Failure(JSMessage::kReadOnlyError); int iSize = params.size(); if (iSize < 1) - return CJS_Return(JSMessage::kParamError); + return CJS_Return::Failure(JSMessage::kParamError); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); int nWidget = pRuntime->ToInt32(params[0]); if (nWidget < 0 || nWidget >= pFormField->CountControls()) - return CJS_Return(JSMessage::kValueError); + return CJS_Return::Failure(JSMessage::kValueError); - return CJS_Return(pRuntime->NewBoolean(IsCheckBoxOrRadioButton(pFormField))); + return CJS_Return::Success( + pRuntime->NewBoolean(IsCheckBoxOrRadioButton(pFormField))); } CJS_Return CJS_Field::deleteItemAt( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::getArray( @@ -2374,7 +2378,7 @@ CJS_Return CJS_Field::getArray( const std::vector<v8::Local<v8::Value>>& params) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(); if (FieldArray.empty()) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); std::vector<std::unique_ptr<WideString>> swSort; for (CPDF_FormField* pFormField : FieldArray) { @@ -2391,7 +2395,7 @@ CJS_Return CJS_Field::getArray( v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject( CJS_Field::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC); if (pObj.IsEmpty()) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); auto* pJSField = static_cast<CJS_Field*>(CFXJS_Engine::GetObjectPrivate(pObj)); @@ -2401,7 +2405,7 @@ CJS_Return CJS_Field::getArray( ? v8::Local<v8::Value>(pJSField->ToV8Object()) : v8::Local<v8::Value>()); } - return CJS_Return(FormFieldArray); + return CJS_Return::Success(FormFieldArray); } CJS_Return CJS_Field::getItemAt( @@ -2418,35 +2422,35 @@ CJS_Return CJS_Field::getItemAt( CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (!IsComboBoxOrListBox(pFormField)) - return CJS_Return(JSMessage::kObjectTypeError); + return CJS_Return::Failure(JSMessage::kObjectTypeError); if (nIdx == -1 || nIdx > pFormField->CountOptions()) nIdx = pFormField->CountOptions() - 1; if (!bExport) { - return CJS_Return( + return CJS_Return::Success( pRuntime->NewString(pFormField->GetOptionLabel(nIdx).AsStringView())); } WideString strval = pFormField->GetOptionValue(nIdx); if (strval.IsEmpty()) { - return CJS_Return( + return CJS_Return::Success( pRuntime->NewString(pFormField->GetOptionLabel(nIdx).AsStringView())); } - return CJS_Return(pRuntime->NewString(strval.AsStringView())); + return CJS_Return::Success(pRuntime->NewString(strval.AsStringView())); } CJS_Return CJS_Field::getLock(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(JSMessage::kNotSupportedError); + return CJS_Return::Failure(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::insertItemAt( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::isBoxChecked( @@ -2458,12 +2462,12 @@ CJS_Return CJS_Field::isBoxChecked( CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (nIndex < 0 || nIndex >= pFormField->CountControls()) - return CJS_Return(JSMessage::kValueError); + return CJS_Return::Failure(JSMessage::kValueError); - return CJS_Return( + return CJS_Return::Success( pRuntime->NewBoolean((IsCheckBoxOrRadioButton(pFormField) && pFormField->GetControl(nIndex)->IsChecked() != 0))); } @@ -2477,12 +2481,12 @@ CJS_Return CJS_Field::isDefaultChecked( CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (nIndex < 0 || nIndex >= pFormField->CountControls()) - return CJS_Return(JSMessage::kValueError); + return CJS_Return::Failure(JSMessage::kValueError); - return CJS_Return(pRuntime->NewBoolean( + return CJS_Return::Success(pRuntime->NewBoolean( (IsCheckBoxOrRadioButton(pFormField) && pFormField->GetControl(nIndex)->IsDefaultChecked() != 0))); } @@ -2490,7 +2494,7 @@ CJS_Return CJS_Field::isDefaultChecked( CJS_Return CJS_Field::setAction( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::setFocus( @@ -2498,11 +2502,11 @@ CJS_Return CJS_Field::setFocus( const std::vector<v8::Local<v8::Value>>& params) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); int32_t nCount = pFormField->CountControls(); if (nCount < 1) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDFSDK_Widget* pWidget = nullptr; @@ -2511,7 +2515,7 @@ CJS_Return CJS_Field::setFocus( } else { IPDF_Page* pPage = IPDFPageFromFPDFPage(m_pFormFillEnv->GetCurrentPage()); if (!pPage) - return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return::Failure(JSMessage::kBadObjectError); if (CPDFSDK_PageView* pCurPageView = m_pFormFillEnv->GetPageView(pPage, true)) { for (int32_t i = 0; i < nCount; i++) { @@ -2531,63 +2535,63 @@ CJS_Return CJS_Field::setFocus( m_pFormFillEnv->SetFocusAnnot(&pObserved); } - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::setItems( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::setLock(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(JSMessage::kNotSupportedError); + return CJS_Return::Failure(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::signatureGetModifications( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(JSMessage::kNotSupportedError); + return CJS_Return::Failure(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::signatureGetSeedValue( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(JSMessage::kNotSupportedError); + return CJS_Return::Failure(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::signatureInfo( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(JSMessage::kNotSupportedError); + return CJS_Return::Failure(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::signatureSetSeedValue( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(JSMessage::kNotSupportedError); + return CJS_Return::Failure(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::signatureSign( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(JSMessage::kNotSupportedError); + return CJS_Return::Failure(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::signatureValidate( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(JSMessage::kNotSupportedError); + return CJS_Return::Failure(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::get_source(CJS_Runtime* pRuntime) { - return CJS_Return(); + return CJS_Return::Success(); } CJS_Return CJS_Field::set_source(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(); + return CJS_Return::Success(); } void CJS_Field::AddDelay_Int(FIELD_PROP prop, int32_t n) { |