OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "fpdfsdk/javascript/Field.h" | 7 #include "fpdfsdk/javascript/Field.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 FX_BOOL Field::currentValueIndices(IJS_Context* cc, | 948 FX_BOOL Field::currentValueIndices(IJS_Context* cc, |
949 CJS_PropValue& vp, | 949 CJS_PropValue& vp, |
950 CFX_WideString& sError) { | 950 CFX_WideString& sError) { |
951 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 951 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
952 | 952 |
953 if (vp.IsSetting()) { | 953 if (vp.IsSetting()) { |
954 if (!m_bCanSet) | 954 if (!m_bCanSet) |
955 return FALSE; | 955 return FALSE; |
956 | 956 |
957 std::vector<uint32_t> array; | 957 std::vector<uint32_t> array; |
958 if (vp.GetType() == CJS_Value::VT_number) { | 958 if (vp.GetJSValue()->GetType() == CJS_Value::VT_number) { |
959 int iSelecting = 0; | 959 int iSelecting = 0; |
960 vp >> iSelecting; | 960 vp >> iSelecting; |
961 array.push_back(iSelecting); | 961 array.push_back(iSelecting); |
962 } else if (vp.IsArrayObject()) { | 962 } else if (vp.GetJSValue()->IsArrayObject()) { |
963 CJS_Array SelArray; | 963 CJS_Array SelArray; |
964 CJS_Value SelValue(pRuntime); | 964 CJS_Value SelValue(pRuntime); |
965 int iSelecting; | 965 int iSelecting; |
966 vp >> SelArray; | 966 vp >> SelArray; |
967 for (int i = 0, sz = SelArray.GetLength(); i < sz; i++) { | 967 for (int i = 0, sz = SelArray.GetLength(); i < sz; i++) { |
968 SelArray.GetElement(pRuntime->GetIsolate(), i, SelValue); | 968 SelArray.GetElement(pRuntime->GetIsolate(), i, SelValue); |
969 iSelecting = SelValue.ToInt(); | 969 iSelecting = SelValue.ToInt(pRuntime->GetIsolate()); |
970 array.push_back(iSelecting); | 970 array.push_back(iSelecting); |
971 } | 971 } |
972 } | 972 } |
973 | 973 |
974 if (m_bDelay) { | 974 if (m_bDelay) { |
975 AddDelay_WordArray(FP_CURRENTVALUEINDICES, array); | 975 AddDelay_WordArray(FP_CURRENTVALUEINDICES, array); |
976 } else { | 976 } else { |
977 Field::SetCurrentValueIndices(m_pDocument, m_FieldName, | 977 Field::SetCurrentValueIndices(m_pDocument, m_FieldName, |
978 m_nFormControlIndex, array); | 978 m_nFormControlIndex, array); |
979 } | 979 } |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1368 CPDF_FormField* pFormField = FieldArray[0]; | 1368 CPDF_FormField* pFormField = FieldArray[0]; |
1369 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && | 1369 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && |
1370 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) { | 1370 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) { |
1371 return FALSE; | 1371 return FALSE; |
1372 } | 1372 } |
1373 | 1373 |
1374 if (vp.IsSetting()) { | 1374 if (vp.IsSetting()) { |
1375 if (!m_bCanSet) | 1375 if (!m_bCanSet) |
1376 return FALSE; | 1376 return FALSE; |
1377 | 1377 |
1378 if (!vp.IsArrayObject()) | 1378 if (!vp.GetJSValue()->IsArrayObject()) |
1379 return FALSE; | 1379 return FALSE; |
1380 } else { | 1380 } else { |
1381 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 1381 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
1382 CJS_Array ExportValusArray; | 1382 CJS_Array ExportValusArray; |
1383 if (m_nFormControlIndex < 0) { | 1383 if (m_nFormControlIndex < 0) { |
1384 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 1384 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
1385 CPDF_FormControl* pFormControl = pFormField->GetControl(i); | 1385 CPDF_FormControl* pFormControl = pFormField->GetControl(i); |
1386 ExportValusArray.SetElement( | 1386 ExportValusArray.SetElement( |
1387 pRuntime->GetIsolate(), i, | 1387 pRuntime->GetIsolate(), i, |
1388 CJS_Value(pRuntime, pFormControl->GetExportValue().c_str())); | 1388 CJS_Value(pRuntime, pFormControl->GetExportValue().c_str())); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 1437 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
1438 CJS_Array crArray; | 1438 CJS_Array crArray; |
1439 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 1439 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1440 if (FieldArray.empty()) | 1440 if (FieldArray.empty()) |
1441 return FALSE; | 1441 return FALSE; |
1442 | 1442 |
1443 if (vp.IsSetting()) { | 1443 if (vp.IsSetting()) { |
1444 if (!m_bCanSet) | 1444 if (!m_bCanSet) |
1445 return FALSE; | 1445 return FALSE; |
1446 | 1446 |
1447 if (!vp.IsArrayObject()) | 1447 if (!vp.GetJSValue()->IsArrayObject()) |
1448 return FALSE; | 1448 return FALSE; |
1449 | 1449 |
1450 vp >> crArray; | 1450 vp >> crArray; |
1451 | 1451 |
1452 CPWL_Color color; | 1452 CPWL_Color color; |
1453 color::ConvertArrayToPWLColor(pRuntime, crArray, &color); | 1453 color::ConvertArrayToPWLColor(pRuntime, crArray, &color); |
1454 if (m_bDelay) { | 1454 if (m_bDelay) { |
1455 AddDelay_Color(FP_FILLCOLOR, color); | 1455 AddDelay_Color(FP_FILLCOLOR, color); |
1456 } else { | 1456 } else { |
1457 Field::SetFillColor(m_pDocument, m_FieldName, m_nFormControlIndex, color); | 1457 Field::SetFillColor(m_pDocument, m_FieldName, m_nFormControlIndex, color); |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2077 CFX_WideString& sError) { | 2077 CFX_WideString& sError) { |
2078 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 2078 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
2079 CJS_Value Upper_Leftx(pRuntime); | 2079 CJS_Value Upper_Leftx(pRuntime); |
2080 CJS_Value Upper_Lefty(pRuntime); | 2080 CJS_Value Upper_Lefty(pRuntime); |
2081 CJS_Value Lower_Rightx(pRuntime); | 2081 CJS_Value Lower_Rightx(pRuntime); |
2082 CJS_Value Lower_Righty(pRuntime); | 2082 CJS_Value Lower_Righty(pRuntime); |
2083 | 2083 |
2084 if (vp.IsSetting()) { | 2084 if (vp.IsSetting()) { |
2085 if (!m_bCanSet) | 2085 if (!m_bCanSet) |
2086 return FALSE; | 2086 return FALSE; |
2087 if (!vp.IsArrayObject()) | 2087 if (!vp.GetJSValue()->IsArrayObject()) |
2088 return FALSE; | 2088 return FALSE; |
2089 | 2089 |
2090 CJS_Array rcArray; | 2090 CJS_Array rcArray; |
2091 vp >> rcArray; | 2091 vp >> rcArray; |
2092 rcArray.GetElement(pRuntime->GetIsolate(), 0, Upper_Leftx); | 2092 rcArray.GetElement(pRuntime->GetIsolate(), 0, Upper_Leftx); |
2093 rcArray.GetElement(pRuntime->GetIsolate(), 1, Upper_Lefty); | 2093 rcArray.GetElement(pRuntime->GetIsolate(), 1, Upper_Lefty); |
2094 rcArray.GetElement(pRuntime->GetIsolate(), 2, Lower_Rightx); | 2094 rcArray.GetElement(pRuntime->GetIsolate(), 2, Lower_Rightx); |
2095 rcArray.GetElement(pRuntime->GetIsolate(), 3, Lower_Righty); | 2095 rcArray.GetElement(pRuntime->GetIsolate(), 3, Lower_Righty); |
2096 | 2096 |
2097 FX_FLOAT pArray[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | 2097 FX_FLOAT pArray[4] = {0.0f, 0.0f, 0.0f, 0.0f}; |
2098 pArray[0] = (FX_FLOAT)Upper_Leftx.ToInt(); | 2098 pArray[0] = |
2099 pArray[1] = (FX_FLOAT)Lower_Righty.ToInt(); | 2099 static_cast<FX_FLOAT>(Upper_Leftx.ToInt(pRuntime->GetIsolate())); |
2100 pArray[2] = (FX_FLOAT)Lower_Rightx.ToInt(); | 2100 pArray[1] = |
2101 pArray[3] = (FX_FLOAT)Upper_Lefty.ToInt(); | 2101 static_cast<FX_FLOAT>(Lower_Righty.ToInt(pRuntime->GetIsolate())); |
| 2102 pArray[2] = |
| 2103 static_cast<FX_FLOAT>(Lower_Rightx.ToInt(pRuntime->GetIsolate())); |
| 2104 pArray[3] = |
| 2105 static_cast<FX_FLOAT>(Upper_Lefty.ToInt(pRuntime->GetIsolate())); |
2102 | 2106 |
2103 CFX_FloatRect crRect(pArray); | 2107 CFX_FloatRect crRect(pArray); |
2104 if (m_bDelay) { | 2108 if (m_bDelay) { |
2105 AddDelay_Rect(FP_RECT, crRect); | 2109 AddDelay_Rect(FP_RECT, crRect); |
2106 } else { | 2110 } else { |
2107 Field::SetRect(m_pDocument, m_FieldName, m_nFormControlIndex, crRect); | 2111 Field::SetRect(m_pDocument, m_FieldName, m_nFormControlIndex, crRect); |
2108 } | 2112 } |
2109 } else { | 2113 } else { |
2110 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 2114 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2111 if (FieldArray.empty()) | 2115 if (FieldArray.empty()) |
2112 return FALSE; | 2116 return FALSE; |
2113 | 2117 |
2114 CPDF_FormField* pFormField = FieldArray[0]; | 2118 CPDF_FormField* pFormField = FieldArray[0]; |
2115 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 2119 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); |
2116 CPDFSDK_Widget* pWidget = | 2120 CPDFSDK_Widget* pWidget = |
2117 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); | 2121 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); |
2118 if (!pWidget) | 2122 if (!pWidget) |
2119 return FALSE; | 2123 return FALSE; |
2120 | 2124 |
2121 CFX_FloatRect crRect = pWidget->GetRect(); | 2125 CFX_FloatRect crRect = pWidget->GetRect(); |
2122 Upper_Leftx = (int32_t)crRect.left; | 2126 Upper_Leftx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.left)); |
2123 Upper_Lefty = (int32_t)crRect.top; | 2127 Upper_Lefty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.top)); |
2124 Lower_Rightx = (int32_t)crRect.right; | 2128 Lower_Rightx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.right)); |
2125 Lower_Righty = (int32_t)crRect.bottom; | 2129 Lower_Righty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom)); |
2126 | 2130 |
2127 CJS_Array rcArray; | 2131 CJS_Array rcArray; |
2128 rcArray.SetElement(pRuntime->GetIsolate(), 0, Upper_Leftx); | 2132 rcArray.SetElement(pRuntime->GetIsolate(), 0, Upper_Leftx); |
2129 rcArray.SetElement(pRuntime->GetIsolate(), 1, Upper_Lefty); | 2133 rcArray.SetElement(pRuntime->GetIsolate(), 1, Upper_Lefty); |
2130 rcArray.SetElement(pRuntime->GetIsolate(), 2, Lower_Rightx); | 2134 rcArray.SetElement(pRuntime->GetIsolate(), 2, Lower_Rightx); |
2131 rcArray.SetElement(pRuntime->GetIsolate(), 3, Lower_Righty); | 2135 rcArray.SetElement(pRuntime->GetIsolate(), 3, Lower_Righty); |
2132 vp << rcArray; | 2136 vp << rcArray; |
2133 } | 2137 } |
2134 return TRUE; | 2138 return TRUE; |
2135 } | 2139 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2302 FX_BOOL Field::strokeColor(IJS_Context* cc, | 2306 FX_BOOL Field::strokeColor(IJS_Context* cc, |
2303 CJS_PropValue& vp, | 2307 CJS_PropValue& vp, |
2304 CFX_WideString& sError) { | 2308 CFX_WideString& sError) { |
2305 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 2309 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
2306 CJS_Array crArray; | 2310 CJS_Array crArray; |
2307 | 2311 |
2308 if (vp.IsSetting()) { | 2312 if (vp.IsSetting()) { |
2309 if (!m_bCanSet) | 2313 if (!m_bCanSet) |
2310 return FALSE; | 2314 return FALSE; |
2311 | 2315 |
2312 if (!vp.IsArrayObject()) | 2316 if (!vp.GetJSValue()->IsArrayObject()) |
2313 return FALSE; | 2317 return FALSE; |
2314 | 2318 |
2315 vp >> crArray; | 2319 vp >> crArray; |
2316 | 2320 |
2317 CPWL_Color color; | 2321 CPWL_Color color; |
2318 color::ConvertArrayToPWLColor(pRuntime, crArray, &color); | 2322 color::ConvertArrayToPWLColor(pRuntime, crArray, &color); |
2319 | 2323 |
2320 if (m_bDelay) { | 2324 if (m_bDelay) { |
2321 AddDelay_Color(FP_STROKECOLOR, color); | 2325 AddDelay_Color(FP_STROKECOLOR, color); |
2322 } else { | 2326 } else { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2447 FX_BOOL Field::textColor(IJS_Context* cc, | 2451 FX_BOOL Field::textColor(IJS_Context* cc, |
2448 CJS_PropValue& vp, | 2452 CJS_PropValue& vp, |
2449 CFX_WideString& sError) { | 2453 CFX_WideString& sError) { |
2450 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 2454 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
2451 CJS_Array crArray; | 2455 CJS_Array crArray; |
2452 | 2456 |
2453 if (vp.IsSetting()) { | 2457 if (vp.IsSetting()) { |
2454 if (!m_bCanSet) | 2458 if (!m_bCanSet) |
2455 return FALSE; | 2459 return FALSE; |
2456 | 2460 |
2457 if (!vp.IsArrayObject()) | 2461 if (!vp.GetJSValue()->IsArrayObject()) |
2458 return FALSE; | 2462 return FALSE; |
2459 | 2463 |
2460 vp >> crArray; | 2464 vp >> crArray; |
2461 | 2465 |
2462 CPWL_Color color; | 2466 CPWL_Color color; |
2463 color::ConvertArrayToPWLColor(pRuntime, crArray, &color); | 2467 color::ConvertArrayToPWLColor(pRuntime, crArray, &color); |
2464 | 2468 |
2465 if (m_bDelay) { | 2469 if (m_bDelay) { |
2466 AddDelay_Color(FP_TEXTCOLOR, color); | 2470 AddDelay_Color(FP_TEXTCOLOR, color); |
2467 } else { | 2471 } else { |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2691 FX_BOOL Field::value(IJS_Context* cc, | 2695 FX_BOOL Field::value(IJS_Context* cc, |
2692 CJS_PropValue& vp, | 2696 CJS_PropValue& vp, |
2693 CFX_WideString& sError) { | 2697 CFX_WideString& sError) { |
2694 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 2698 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
2695 | 2699 |
2696 if (vp.IsSetting()) { | 2700 if (vp.IsSetting()) { |
2697 if (!m_bCanSet) | 2701 if (!m_bCanSet) |
2698 return FALSE; | 2702 return FALSE; |
2699 | 2703 |
2700 std::vector<CFX_WideString> strArray; | 2704 std::vector<CFX_WideString> strArray; |
2701 if (vp.IsArrayObject()) { | 2705 if (vp.GetJSValue()->IsArrayObject()) { |
2702 CJS_Array ValueArray; | 2706 CJS_Array ValueArray; |
2703 vp.ConvertToArray(ValueArray); | 2707 vp.GetJSValue()->ConvertToArray(pRuntime->GetIsolate(), ValueArray); |
2704 for (int i = 0, sz = ValueArray.GetLength(); i < sz; i++) { | 2708 for (int i = 0, sz = ValueArray.GetLength(); i < sz; i++) { |
2705 CJS_Value ElementValue(pRuntime); | 2709 CJS_Value ElementValue(pRuntime); |
2706 ValueArray.GetElement(pRuntime->GetIsolate(), i, ElementValue); | 2710 ValueArray.GetElement(pRuntime->GetIsolate(), i, ElementValue); |
2707 strArray.push_back(ElementValue.ToCFXWideString()); | 2711 strArray.push_back( |
| 2712 ElementValue.ToCFXWideString(pRuntime->GetIsolate())); |
2708 } | 2713 } |
2709 } else { | 2714 } else { |
2710 CFX_WideString swValue; | 2715 CFX_WideString swValue; |
2711 vp >> swValue; | 2716 vp >> swValue; |
2712 strArray.push_back(swValue); | 2717 strArray.push_back(swValue); |
2713 } | 2718 } |
2714 | 2719 |
2715 if (m_bDelay) { | 2720 if (m_bDelay) { |
2716 AddDelay_WideStringArray(FP_VALUE, strArray); | 2721 AddDelay_WideStringArray(FP_VALUE, strArray); |
2717 } else { | 2722 } else { |
(...skipping 12 matching lines...) Expand all Loading... |
2730 case FIELDTYPE_TEXTFIELD: { | 2735 case FIELDTYPE_TEXTFIELD: { |
2731 vp << pFormField->GetValue(); | 2736 vp << pFormField->GetValue(); |
2732 } break; | 2737 } break; |
2733 case FIELDTYPE_LISTBOX: { | 2738 case FIELDTYPE_LISTBOX: { |
2734 if (pFormField->CountSelectedItems() > 1) { | 2739 if (pFormField->CountSelectedItems() > 1) { |
2735 CJS_Array ValueArray; | 2740 CJS_Array ValueArray; |
2736 CJS_Value ElementValue(pRuntime); | 2741 CJS_Value ElementValue(pRuntime); |
2737 int iIndex; | 2742 int iIndex; |
2738 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { | 2743 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { |
2739 iIndex = pFormField->GetSelectedIndex(i); | 2744 iIndex = pFormField->GetSelectedIndex(i); |
2740 ElementValue = pFormField->GetOptionValue(iIndex).c_str(); | 2745 ElementValue = |
2741 if (FXSYS_wcslen(ElementValue.ToCFXWideString().c_str()) == 0) | 2746 CJS_Value(pRuntime, pFormField->GetOptionValue(iIndex).c_str()); |
2742 ElementValue = pFormField->GetOptionLabel(iIndex).c_str(); | 2747 if (FXSYS_wcslen( |
| 2748 ElementValue.ToCFXWideString(pRuntime->GetIsolate()) |
| 2749 .c_str()) == 0) { |
| 2750 ElementValue = CJS_Value( |
| 2751 pRuntime, pFormField->GetOptionLabel(iIndex).c_str()); |
| 2752 } |
2743 ValueArray.SetElement(pRuntime->GetIsolate(), i, ElementValue); | 2753 ValueArray.SetElement(pRuntime->GetIsolate(), i, ElementValue); |
2744 } | 2754 } |
2745 vp << ValueArray; | 2755 vp << ValueArray; |
2746 } else { | 2756 } else { |
2747 vp << pFormField->GetValue(); | 2757 vp << pFormField->GetValue(); |
2748 } | 2758 } |
2749 } break; | 2759 } break; |
2750 case FIELDTYPE_CHECKBOX: | 2760 case FIELDTYPE_CHECKBOX: |
2751 case FIELDTYPE_RADIOBUTTON: { | 2761 case FIELDTYPE_RADIOBUTTON: { |
2752 bool bFind = false; | 2762 bool bFind = false; |
2753 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 2763 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
2754 if (pFormField->GetControl(i)->IsChecked()) { | 2764 if (pFormField->GetControl(i)->IsChecked()) { |
2755 vp << pFormField->GetControl(i)->GetExportValue(); | 2765 vp << pFormField->GetControl(i)->GetExportValue(); |
2756 bFind = true; | 2766 bFind = true; |
2757 break; | 2767 break; |
2758 } | 2768 } |
2759 } | 2769 } |
2760 if (!bFind) | 2770 if (!bFind) |
2761 vp << L"Off"; | 2771 vp << L"Off"; |
2762 } break; | 2772 } break; |
2763 default: | 2773 default: |
2764 vp << pFormField->GetValue(); | 2774 vp << pFormField->GetValue(); |
2765 break; | 2775 break; |
2766 } | 2776 } |
2767 } | 2777 } |
2768 vp.MaybeCoerceToNumber(); | 2778 vp.GetJSValue()->MaybeCoerceToNumber(m_isolate); |
2769 return TRUE; | 2779 return TRUE; |
2770 } | 2780 } |
2771 | 2781 |
2772 void Field::SetValue(CPDFSDK_Document* pDocument, | 2782 void Field::SetValue(CPDFSDK_Document* pDocument, |
2773 const CFX_WideString& swFieldName, | 2783 const CFX_WideString& swFieldName, |
2774 int nControlIndex, | 2784 int nControlIndex, |
2775 const std::vector<CFX_WideString>& strArray) { | 2785 const std::vector<CFX_WideString>& strArray) { |
2776 ASSERT(pDocument); | 2786 ASSERT(pDocument); |
2777 if (strArray.empty()) | 2787 if (strArray.empty()) |
2778 return; | 2788 return; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2884 } | 2894 } |
2885 return TRUE; | 2895 return TRUE; |
2886 } | 2896 } |
2887 return FALSE; | 2897 return FALSE; |
2888 } | 2898 } |
2889 | 2899 |
2890 FX_BOOL Field::buttonGetCaption(IJS_Context* cc, | 2900 FX_BOOL Field::buttonGetCaption(IJS_Context* cc, |
2891 const std::vector<CJS_Value>& params, | 2901 const std::vector<CJS_Value>& params, |
2892 CJS_Value& vRet, | 2902 CJS_Value& vRet, |
2893 CFX_WideString& sError) { | 2903 CFX_WideString& sError) { |
| 2904 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 2905 |
2894 int nface = 0; | 2906 int nface = 0; |
2895 int iSize = params.size(); | 2907 int iSize = params.size(); |
2896 if (iSize >= 1) | 2908 if (iSize >= 1) |
2897 nface = params[0].ToInt(); | 2909 nface = params[0].ToInt(pRuntime->GetIsolate()); |
2898 | 2910 |
2899 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 2911 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2900 if (FieldArray.empty()) | 2912 if (FieldArray.empty()) |
2901 return FALSE; | 2913 return FALSE; |
2902 | 2914 |
2903 CPDF_FormField* pFormField = FieldArray[0]; | 2915 CPDF_FormField* pFormField = FieldArray[0]; |
2904 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | 2916 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
2905 return FALSE; | 2917 return FALSE; |
2906 | 2918 |
2907 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 2919 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
2908 if (!pFormControl) | 2920 if (!pFormControl) |
2909 return FALSE; | 2921 return FALSE; |
2910 | 2922 |
2911 if (nface == 0) | 2923 if (nface == 0) |
2912 vRet = pFormControl->GetNormalCaption().c_str(); | 2924 vRet = CJS_Value(pRuntime, pFormControl->GetNormalCaption().c_str()); |
2913 else if (nface == 1) | 2925 else if (nface == 1) |
2914 vRet = pFormControl->GetDownCaption().c_str(); | 2926 vRet = CJS_Value(pRuntime, pFormControl->GetDownCaption().c_str()); |
2915 else if (nface == 2) | 2927 else if (nface == 2) |
2916 vRet = pFormControl->GetRolloverCaption().c_str(); | 2928 vRet = CJS_Value(pRuntime, pFormControl->GetRolloverCaption().c_str()); |
2917 else | 2929 else |
2918 return FALSE; | 2930 return FALSE; |
2919 | 2931 |
2920 return TRUE; | 2932 return TRUE; |
2921 } | 2933 } |
2922 | 2934 |
2923 FX_BOOL Field::buttonGetIcon(IJS_Context* cc, | 2935 FX_BOOL Field::buttonGetIcon(IJS_Context* cc, |
2924 const std::vector<CJS_Value>& params, | 2936 const std::vector<CJS_Value>& params, |
2925 CJS_Value& vRet, | 2937 CJS_Value& vRet, |
2926 CFX_WideString& sError) { | 2938 CFX_WideString& sError) { |
| 2939 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 2940 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 2941 |
2927 int nface = 0; | 2942 int nface = 0; |
2928 int iSize = params.size(); | 2943 int iSize = params.size(); |
2929 if (iSize >= 1) | 2944 if (iSize >= 1) |
2930 nface = params[0].ToInt(); | 2945 nface = params[0].ToInt(pRuntime->GetIsolate()); |
2931 | 2946 |
2932 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 2947 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2933 if (FieldArray.empty()) | 2948 if (FieldArray.empty()) |
2934 return FALSE; | 2949 return FALSE; |
2935 | 2950 |
2936 CPDF_FormField* pFormField = FieldArray[0]; | 2951 CPDF_FormField* pFormField = FieldArray[0]; |
2937 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | 2952 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
2938 return FALSE; | 2953 return FALSE; |
2939 | 2954 |
2940 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 2955 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
2941 if (!pFormControl) | 2956 if (!pFormControl) |
2942 return FALSE; | 2957 return FALSE; |
2943 | 2958 |
2944 CJS_Context* pContext = (CJS_Context*)cc; | |
2945 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | |
2946 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( | 2959 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( |
2947 pRuntime->GetIsolate(), pRuntime, CJS_Icon::g_nObjDefnID); | 2960 pRuntime->GetIsolate(), pRuntime, CJS_Icon::g_nObjDefnID); |
2948 ASSERT(pObj.IsEmpty() == FALSE); | 2961 ASSERT(pObj.IsEmpty() == FALSE); |
2949 | 2962 |
2950 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); | 2963 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); |
2951 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); | 2964 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
2952 | 2965 |
2953 CPDF_Stream* pIconStream = nullptr; | 2966 CPDF_Stream* pIconStream = nullptr; |
2954 if (nface == 0) | 2967 if (nface == 0) |
2955 pIconStream = pFormControl->GetNormalIcon(); | 2968 pIconStream = pFormControl->GetNormalIcon(); |
2956 else if (nface == 1) | 2969 else if (nface == 1) |
2957 pIconStream = pFormControl->GetDownIcon(); | 2970 pIconStream = pFormControl->GetDownIcon(); |
2958 else if (nface == 2) | 2971 else if (nface == 2) |
2959 pIconStream = pFormControl->GetRolloverIcon(); | 2972 pIconStream = pFormControl->GetRolloverIcon(); |
2960 else | 2973 else |
2961 return FALSE; | 2974 return FALSE; |
2962 | 2975 |
2963 pIcon->SetStream(pIconStream); | 2976 pIcon->SetStream(pIconStream); |
2964 vRet = pJS_Icon; | 2977 vRet = CJS_Value(pRuntime, pJS_Icon); |
2965 | |
2966 return TRUE; | 2978 return TRUE; |
2967 } | 2979 } |
2968 | 2980 |
2969 FX_BOOL Field::buttonImportIcon(IJS_Context* cc, | 2981 FX_BOOL Field::buttonImportIcon(IJS_Context* cc, |
2970 const std::vector<CJS_Value>& params, | 2982 const std::vector<CJS_Value>& params, |
2971 CJS_Value& vRet, | 2983 CJS_Value& vRet, |
2972 CFX_WideString& sError) { | 2984 CFX_WideString& sError) { |
2973 return TRUE; | 2985 return TRUE; |
2974 } | 2986 } |
2975 | 2987 |
2976 FX_BOOL Field::buttonSetCaption(IJS_Context* cc, | 2988 FX_BOOL Field::buttonSetCaption(IJS_Context* cc, |
2977 const std::vector<CJS_Value>& params, | 2989 const std::vector<CJS_Value>& params, |
2978 CJS_Value& vRet, | 2990 CJS_Value& vRet, |
2979 CFX_WideString& sError) { | 2991 CFX_WideString& sError) { |
2980 return FALSE; | 2992 return FALSE; |
2981 } | 2993 } |
2982 | 2994 |
2983 FX_BOOL Field::buttonSetIcon(IJS_Context* cc, | 2995 FX_BOOL Field::buttonSetIcon(IJS_Context* cc, |
2984 const std::vector<CJS_Value>& params, | 2996 const std::vector<CJS_Value>& params, |
2985 CJS_Value& vRet, | 2997 CJS_Value& vRet, |
2986 CFX_WideString& sError) { | 2998 CFX_WideString& sError) { |
2987 return FALSE; | 2999 return FALSE; |
2988 } | 3000 } |
2989 | 3001 |
2990 FX_BOOL Field::checkThisBox(IJS_Context* cc, | 3002 FX_BOOL Field::checkThisBox(IJS_Context* cc, |
2991 const std::vector<CJS_Value>& params, | 3003 const std::vector<CJS_Value>& params, |
2992 CJS_Value& vRet, | 3004 CJS_Value& vRet, |
2993 CFX_WideString& sError) { | 3005 CFX_WideString& sError) { |
2994 ASSERT(m_pDocument); | 3006 int iSize = params.size(); |
| 3007 if (iSize < 1) |
| 3008 return FALSE; |
2995 | 3009 |
2996 if (!m_bCanSet) | 3010 if (!m_bCanSet) |
2997 return FALSE; | 3011 return FALSE; |
2998 | 3012 |
2999 int iSize = params.size(); | 3013 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
3000 if (iSize < 1) | 3014 int nWidget = params[0].ToInt(pRuntime->GetIsolate()); |
3001 return FALSE; | |
3002 | |
3003 int nWidget = params[0].ToInt(); | |
3004 | 3015 |
3005 bool bCheckit = true; | 3016 bool bCheckit = true; |
3006 if (iSize >= 2) | 3017 if (iSize >= 2) |
3007 bCheckit = params[1].ToBool(); | 3018 bCheckit = params[1].ToBool(pRuntime->GetIsolate()); |
3008 | 3019 |
3009 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 3020 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
3010 if (FieldArray.empty()) | 3021 if (FieldArray.empty()) |
3011 return FALSE; | 3022 return FALSE; |
3012 | 3023 |
3013 CPDF_FormField* pFormField = FieldArray[0]; | 3024 CPDF_FormField* pFormField = FieldArray[0]; |
3014 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && | 3025 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && |
3015 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) | 3026 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) |
3016 return FALSE; | 3027 return FALSE; |
3017 if (nWidget < 0 || nWidget >= pFormField->CountControls()) | 3028 if (nWidget < 0 || nWidget >= pFormField->CountControls()) |
(...skipping 20 matching lines...) Expand all Loading... |
3038 const std::vector<CJS_Value>& params, | 3049 const std::vector<CJS_Value>& params, |
3039 CJS_Value& vRet, | 3050 CJS_Value& vRet, |
3040 CFX_WideString& sError) { | 3051 CFX_WideString& sError) { |
3041 if (!m_bCanSet) | 3052 if (!m_bCanSet) |
3042 return FALSE; | 3053 return FALSE; |
3043 | 3054 |
3044 int iSize = params.size(); | 3055 int iSize = params.size(); |
3045 if (iSize < 1) | 3056 if (iSize < 1) |
3046 return FALSE; | 3057 return FALSE; |
3047 | 3058 |
3048 int nWidget = params[0].ToInt(); | 3059 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 3060 int nWidget = params[0].ToInt(pRuntime->GetIsolate()); |
3049 | 3061 |
3050 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 3062 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
3051 if (FieldArray.empty()) | 3063 if (FieldArray.empty()) |
3052 return FALSE; | 3064 return FALSE; |
3053 | 3065 |
3054 CPDF_FormField* pFormField = FieldArray[0]; | 3066 CPDF_FormField* pFormField = FieldArray[0]; |
3055 if (nWidget < 0 || nWidget >= pFormField->CountControls()) { | 3067 if (nWidget < 0 || nWidget >= pFormField->CountControls()) |
3056 vRet = FALSE; | |
3057 return FALSE; | 3068 return FALSE; |
3058 } | 3069 |
3059 vRet = pFormField->GetFieldType() == FIELDTYPE_CHECKBOX || | 3070 vRet = CJS_Value(pRuntime, |
3060 pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON; | 3071 pFormField->GetFieldType() == FIELDTYPE_CHECKBOX || |
| 3072 pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON); |
3061 | 3073 |
3062 return TRUE; | 3074 return TRUE; |
3063 } | 3075 } |
3064 | 3076 |
3065 FX_BOOL Field::deleteItemAt(IJS_Context* cc, | 3077 FX_BOOL Field::deleteItemAt(IJS_Context* cc, |
3066 const std::vector<CJS_Value>& params, | 3078 const std::vector<CJS_Value>& params, |
3067 CJS_Value& vRet, | 3079 CJS_Value& vRet, |
3068 CFX_WideString& sError) { | 3080 CFX_WideString& sError) { |
3069 return TRUE; | 3081 return TRUE; |
3070 } | 3082 } |
(...skipping 24 matching lines...) Expand all Loading... |
3095 int j = 0; | 3107 int j = 0; |
3096 for (const auto& pStr : swSort) { | 3108 for (const auto& pStr : swSort) { |
3097 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( | 3109 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( |
3098 pRuntime->GetIsolate(), pRuntime, CJS_Field::g_nObjDefnID); | 3110 pRuntime->GetIsolate(), pRuntime, CJS_Field::g_nObjDefnID); |
3099 ASSERT(!pObj.IsEmpty()); | 3111 ASSERT(!pObj.IsEmpty()); |
3100 | 3112 |
3101 CJS_Field* pJSField = | 3113 CJS_Field* pJSField = |
3102 static_cast<CJS_Field*>(FXJS_GetPrivate(pRuntime->GetIsolate(), pObj)); | 3114 static_cast<CJS_Field*>(FXJS_GetPrivate(pRuntime->GetIsolate(), pObj)); |
3103 Field* pField = static_cast<Field*>(pJSField->GetEmbedObject()); | 3115 Field* pField = static_cast<Field*>(pJSField->GetEmbedObject()); |
3104 pField->AttachField(m_pJSDoc, *pStr); | 3116 pField->AttachField(m_pJSDoc, *pStr); |
3105 | 3117 FormFieldArray.SetElement(pRuntime->GetIsolate(), j++, |
3106 CJS_Value FormFieldValue(pRuntime); | 3118 CJS_Value(pRuntime, pJSField)); |
3107 FormFieldValue = pJSField; | |
3108 FormFieldArray.SetElement(pRuntime->GetIsolate(), j++, FormFieldValue); | |
3109 } | 3119 } |
3110 | 3120 |
3111 vRet = CJS_Value(pRuntime, FormFieldArray); | 3121 vRet = CJS_Value(pRuntime, FormFieldArray); |
3112 return TRUE; | 3122 return TRUE; |
3113 } | 3123 } |
3114 | 3124 |
3115 FX_BOOL Field::getItemAt(IJS_Context* cc, | 3125 FX_BOOL Field::getItemAt(IJS_Context* cc, |
3116 const std::vector<CJS_Value>& params, | 3126 const std::vector<CJS_Value>& params, |
3117 CJS_Value& vRet, | 3127 CJS_Value& vRet, |
3118 CFX_WideString& sError) { | 3128 CFX_WideString& sError) { |
| 3129 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 3130 |
3119 int iSize = params.size(); | 3131 int iSize = params.size(); |
3120 | |
3121 int nIdx = -1; | 3132 int nIdx = -1; |
3122 if (iSize >= 1) | 3133 if (iSize >= 1) |
3123 nIdx = params[0].ToInt(); | 3134 nIdx = params[0].ToInt(pRuntime->GetIsolate()); |
3124 | 3135 |
3125 FX_BOOL bExport = TRUE; | 3136 FX_BOOL bExport = TRUE; |
3126 if (iSize >= 2) | 3137 if (iSize >= 2) |
3127 bExport = params[1].ToBool(); | 3138 bExport = params[1].ToBool(pRuntime->GetIsolate()); |
3128 | 3139 |
3129 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 3140 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
3130 if (FieldArray.empty()) | 3141 if (FieldArray.empty()) |
3131 return FALSE; | 3142 return FALSE; |
3132 | 3143 |
3133 CPDF_FormField* pFormField = FieldArray[0]; | 3144 CPDF_FormField* pFormField = FieldArray[0]; |
3134 if ((pFormField->GetFieldType() == FIELDTYPE_LISTBOX) || | 3145 if ((pFormField->GetFieldType() == FIELDTYPE_LISTBOX) || |
3135 (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX)) { | 3146 (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX)) { |
3136 if (nIdx == -1 || nIdx > pFormField->CountOptions()) | 3147 if (nIdx == -1 || nIdx > pFormField->CountOptions()) |
3137 nIdx = pFormField->CountOptions() - 1; | 3148 nIdx = pFormField->CountOptions() - 1; |
3138 if (bExport) { | 3149 if (bExport) { |
3139 CFX_WideString strval = pFormField->GetOptionValue(nIdx); | 3150 CFX_WideString strval = pFormField->GetOptionValue(nIdx); |
3140 if (strval.IsEmpty()) | 3151 if (strval.IsEmpty()) |
3141 vRet = pFormField->GetOptionLabel(nIdx).c_str(); | 3152 vRet = CJS_Value(pRuntime, pFormField->GetOptionLabel(nIdx).c_str()); |
3142 else | 3153 else |
3143 vRet = strval.c_str(); | 3154 vRet = CJS_Value(pRuntime, strval.c_str()); |
3144 } else { | 3155 } else { |
3145 vRet = pFormField->GetOptionLabel(nIdx).c_str(); | 3156 vRet = CJS_Value(pRuntime, pFormField->GetOptionLabel(nIdx).c_str()); |
3146 } | 3157 } |
3147 } else { | 3158 } else { |
3148 return FALSE; | 3159 return FALSE; |
3149 } | 3160 } |
3150 | 3161 |
3151 return TRUE; | 3162 return TRUE; |
3152 } | 3163 } |
3153 | 3164 |
3154 FX_BOOL Field::getLock(IJS_Context* cc, | 3165 FX_BOOL Field::getLock(IJS_Context* cc, |
3155 const std::vector<CJS_Value>& params, | 3166 const std::vector<CJS_Value>& params, |
3156 CJS_Value& vRet, | 3167 CJS_Value& vRet, |
3157 CFX_WideString& sError) { | 3168 CFX_WideString& sError) { |
3158 return FALSE; | 3169 return FALSE; |
3159 } | 3170 } |
3160 | 3171 |
3161 FX_BOOL Field::insertItemAt(IJS_Context* cc, | 3172 FX_BOOL Field::insertItemAt(IJS_Context* cc, |
3162 const std::vector<CJS_Value>& params, | 3173 const std::vector<CJS_Value>& params, |
3163 CJS_Value& vRet, | 3174 CJS_Value& vRet, |
3164 CFX_WideString& sError) { | 3175 CFX_WideString& sError) { |
3165 return TRUE; | 3176 return TRUE; |
3166 } | 3177 } |
3167 | 3178 |
3168 FX_BOOL Field::isBoxChecked(IJS_Context* cc, | 3179 FX_BOOL Field::isBoxChecked(IJS_Context* cc, |
3169 const std::vector<CJS_Value>& params, | 3180 const std::vector<CJS_Value>& params, |
3170 CJS_Value& vRet, | 3181 CJS_Value& vRet, |
3171 CFX_WideString& sError) { | 3182 CFX_WideString& sError) { |
| 3183 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 3184 |
3172 int nIndex = -1; | 3185 int nIndex = -1; |
3173 if (params.size() >= 1) | 3186 if (params.size() >= 1) |
3174 nIndex = params[0].ToInt(); | 3187 nIndex = params[0].ToInt(pRuntime->GetIsolate()); |
3175 | 3188 |
3176 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 3189 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
3177 if (FieldArray.empty()) | 3190 if (FieldArray.empty()) |
3178 return FALSE; | 3191 return FALSE; |
3179 | 3192 |
3180 CPDF_FormField* pFormField = FieldArray[0]; | 3193 CPDF_FormField* pFormField = FieldArray[0]; |
3181 if (nIndex < 0 || nIndex >= pFormField->CountControls()) { | 3194 if (nIndex < 0 || nIndex >= pFormField->CountControls()) { |
3182 vRet = FALSE; | |
3183 return FALSE; | 3195 return FALSE; |
3184 } | 3196 } |
3185 | 3197 |
3186 if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) || | 3198 vRet = CJS_Value(pRuntime, |
3187 (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)) { | 3199 ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX || |
3188 if (pFormField->GetControl(nIndex)->IsChecked() != 0) | 3200 pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) && |
3189 vRet = TRUE; | 3201 pFormField->GetControl(nIndex)->IsChecked() != 0)); |
3190 else | |
3191 vRet = FALSE; | |
3192 } else { | |
3193 vRet = FALSE; | |
3194 } | |
3195 | |
3196 return TRUE; | 3202 return TRUE; |
3197 } | 3203 } |
3198 | 3204 |
3199 FX_BOOL Field::isDefaultChecked(IJS_Context* cc, | 3205 FX_BOOL Field::isDefaultChecked(IJS_Context* cc, |
3200 const std::vector<CJS_Value>& params, | 3206 const std::vector<CJS_Value>& params, |
3201 CJS_Value& vRet, | 3207 CJS_Value& vRet, |
3202 CFX_WideString& sError) { | 3208 CFX_WideString& sError) { |
| 3209 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 3210 |
3203 int nIndex = -1; | 3211 int nIndex = -1; |
3204 if (params.size() >= 1) | 3212 if (params.size() >= 1) |
3205 nIndex = params[0].ToInt(); | 3213 nIndex = params[0].ToInt(pRuntime->GetIsolate()); |
3206 | 3214 |
3207 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 3215 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
3208 if (FieldArray.empty()) | 3216 if (FieldArray.empty()) |
3209 return FALSE; | 3217 return FALSE; |
3210 | 3218 |
3211 CPDF_FormField* pFormField = FieldArray[0]; | 3219 CPDF_FormField* pFormField = FieldArray[0]; |
3212 if (nIndex < 0 || nIndex >= pFormField->CountControls()) { | 3220 if (nIndex < 0 || nIndex >= pFormField->CountControls()) |
3213 vRet = FALSE; | |
3214 return FALSE; | 3221 return FALSE; |
3215 } | |
3216 if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) || | |
3217 (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)) { | |
3218 if (pFormField->GetControl(nIndex)->IsDefaultChecked() != 0) | |
3219 vRet = TRUE; | |
3220 else | |
3221 vRet = FALSE; | |
3222 } else { | |
3223 vRet = FALSE; | |
3224 } | |
3225 | 3222 |
| 3223 vRet = CJS_Value(pRuntime, |
| 3224 ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX || |
| 3225 pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) && |
| 3226 pFormField->GetControl(nIndex)->IsDefaultChecked() != 0)); |
3226 return TRUE; | 3227 return TRUE; |
3227 } | 3228 } |
3228 | 3229 |
3229 FX_BOOL Field::setAction(IJS_Context* cc, | 3230 FX_BOOL Field::setAction(IJS_Context* cc, |
3230 const std::vector<CJS_Value>& params, | 3231 const std::vector<CJS_Value>& params, |
3231 CJS_Value& vRet, | 3232 CJS_Value& vRet, |
3232 CFX_WideString& sError) { | 3233 CFX_WideString& sError) { |
3233 return TRUE; | 3234 return TRUE; |
3234 } | 3235 } |
3235 | 3236 |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3540 } | 3541 } |
3541 } | 3542 } |
3542 | 3543 |
3543 void Field::AddField(CPDFSDK_Document* pDocument, | 3544 void Field::AddField(CPDFSDK_Document* pDocument, |
3544 int nPageIndex, | 3545 int nPageIndex, |
3545 int nFieldType, | 3546 int nFieldType, |
3546 const CFX_WideString& sName, | 3547 const CFX_WideString& sName, |
3547 const CFX_FloatRect& rcCoords) { | 3548 const CFX_FloatRect& rcCoords) { |
3548 // Not supported. | 3549 // Not supported. |
3549 } | 3550 } |
OLD | NEW |