Chromium Code Reviews| 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] = (FX_FLOAT)Upper_Leftx.ToInt(pRuntime->GetIsolate()); |
| 2099 pArray[1] = (FX_FLOAT)Lower_Righty.ToInt(); | 2099 pArray[1] = (FX_FLOAT)Lower_Righty.ToInt(pRuntime->GetIsolate()); |
| 2100 pArray[2] = (FX_FLOAT)Lower_Rightx.ToInt(); | 2100 pArray[2] = (FX_FLOAT)Lower_Rightx.ToInt(pRuntime->GetIsolate()); |
| 2101 pArray[3] = (FX_FLOAT)Upper_Lefty.ToInt(); | 2101 pArray[3] = (FX_FLOAT)Upper_Lefty.ToInt(pRuntime->GetIsolate()); |
|
dsinclair
2016/08/09 19:25:33
static_cast?
Tom Sepez
2016/08/09 20:33:24
Done.
| |
| 2102 | 2102 |
| 2103 CFX_FloatRect crRect(pArray); | 2103 CFX_FloatRect crRect(pArray); |
| 2104 if (m_bDelay) { | 2104 if (m_bDelay) { |
| 2105 AddDelay_Rect(FP_RECT, crRect); | 2105 AddDelay_Rect(FP_RECT, crRect); |
| 2106 } else { | 2106 } else { |
| 2107 Field::SetRect(m_pDocument, m_FieldName, m_nFormControlIndex, crRect); | 2107 Field::SetRect(m_pDocument, m_FieldName, m_nFormControlIndex, crRect); |
| 2108 } | 2108 } |
| 2109 } else { | 2109 } else { |
| 2110 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 2110 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
| 2111 if (FieldArray.empty()) | 2111 if (FieldArray.empty()) |
| 2112 return FALSE; | 2112 return FALSE; |
| 2113 | 2113 |
| 2114 CPDF_FormField* pFormField = FieldArray[0]; | 2114 CPDF_FormField* pFormField = FieldArray[0]; |
| 2115 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 2115 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); |
| 2116 CPDFSDK_Widget* pWidget = | 2116 CPDFSDK_Widget* pWidget = |
| 2117 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); | 2117 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); |
| 2118 if (!pWidget) | 2118 if (!pWidget) |
| 2119 return FALSE; | 2119 return FALSE; |
| 2120 | 2120 |
| 2121 CFX_FloatRect crRect = pWidget->GetRect(); | 2121 CFX_FloatRect crRect = pWidget->GetRect(); |
| 2122 Upper_Leftx = (int32_t)crRect.left; | 2122 Upper_Leftx = CJS_Value(pRuntime, (int32_t)crRect.left); |
|
dsinclair
2016/08/09 19:25:33
static_cast? (and below)
Tom Sepez
2016/08/09 20:33:24
Done.
| |
| 2123 Upper_Lefty = (int32_t)crRect.top; | 2123 Upper_Lefty = CJS_Value(pRuntime, (int32_t)crRect.top); |
| 2124 Lower_Rightx = (int32_t)crRect.right; | 2124 Lower_Rightx = CJS_Value(pRuntime, (int32_t)crRect.right); |
| 2125 Lower_Righty = (int32_t)crRect.bottom; | 2125 Lower_Righty = CJS_Value(pRuntime, (int32_t)crRect.bottom); |
| 2126 | 2126 |
| 2127 CJS_Array rcArray; | 2127 CJS_Array rcArray; |
| 2128 rcArray.SetElement(pRuntime->GetIsolate(), 0, Upper_Leftx); | 2128 rcArray.SetElement(pRuntime->GetIsolate(), 0, Upper_Leftx); |
| 2129 rcArray.SetElement(pRuntime->GetIsolate(), 1, Upper_Lefty); | 2129 rcArray.SetElement(pRuntime->GetIsolate(), 1, Upper_Lefty); |
| 2130 rcArray.SetElement(pRuntime->GetIsolate(), 2, Lower_Rightx); | 2130 rcArray.SetElement(pRuntime->GetIsolate(), 2, Lower_Rightx); |
| 2131 rcArray.SetElement(pRuntime->GetIsolate(), 3, Lower_Righty); | 2131 rcArray.SetElement(pRuntime->GetIsolate(), 3, Lower_Righty); |
| 2132 vp << rcArray; | 2132 vp << rcArray; |
| 2133 } | 2133 } |
| 2134 return TRUE; | 2134 return TRUE; |
| 2135 } | 2135 } |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2302 FX_BOOL Field::strokeColor(IJS_Context* cc, | 2302 FX_BOOL Field::strokeColor(IJS_Context* cc, |
| 2303 CJS_PropValue& vp, | 2303 CJS_PropValue& vp, |
| 2304 CFX_WideString& sError) { | 2304 CFX_WideString& sError) { |
| 2305 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 2305 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 2306 CJS_Array crArray; | 2306 CJS_Array crArray; |
| 2307 | 2307 |
| 2308 if (vp.IsSetting()) { | 2308 if (vp.IsSetting()) { |
| 2309 if (!m_bCanSet) | 2309 if (!m_bCanSet) |
| 2310 return FALSE; | 2310 return FALSE; |
| 2311 | 2311 |
| 2312 if (!vp.IsArrayObject()) | 2312 if (!vp.GetJSValue()->IsArrayObject()) |
| 2313 return FALSE; | 2313 return FALSE; |
| 2314 | 2314 |
| 2315 vp >> crArray; | 2315 vp >> crArray; |
| 2316 | 2316 |
| 2317 CPWL_Color color; | 2317 CPWL_Color color; |
| 2318 color::ConvertArrayToPWLColor(pRuntime, crArray, &color); | 2318 color::ConvertArrayToPWLColor(pRuntime, crArray, &color); |
| 2319 | 2319 |
| 2320 if (m_bDelay) { | 2320 if (m_bDelay) { |
| 2321 AddDelay_Color(FP_STROKECOLOR, color); | 2321 AddDelay_Color(FP_STROKECOLOR, color); |
| 2322 } else { | 2322 } else { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2447 FX_BOOL Field::textColor(IJS_Context* cc, | 2447 FX_BOOL Field::textColor(IJS_Context* cc, |
| 2448 CJS_PropValue& vp, | 2448 CJS_PropValue& vp, |
| 2449 CFX_WideString& sError) { | 2449 CFX_WideString& sError) { |
| 2450 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 2450 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 2451 CJS_Array crArray; | 2451 CJS_Array crArray; |
| 2452 | 2452 |
| 2453 if (vp.IsSetting()) { | 2453 if (vp.IsSetting()) { |
| 2454 if (!m_bCanSet) | 2454 if (!m_bCanSet) |
| 2455 return FALSE; | 2455 return FALSE; |
| 2456 | 2456 |
| 2457 if (!vp.IsArrayObject()) | 2457 if (!vp.GetJSValue()->IsArrayObject()) |
| 2458 return FALSE; | 2458 return FALSE; |
| 2459 | 2459 |
| 2460 vp >> crArray; | 2460 vp >> crArray; |
| 2461 | 2461 |
| 2462 CPWL_Color color; | 2462 CPWL_Color color; |
| 2463 color::ConvertArrayToPWLColor(pRuntime, crArray, &color); | 2463 color::ConvertArrayToPWLColor(pRuntime, crArray, &color); |
| 2464 | 2464 |
| 2465 if (m_bDelay) { | 2465 if (m_bDelay) { |
| 2466 AddDelay_Color(FP_TEXTCOLOR, color); | 2466 AddDelay_Color(FP_TEXTCOLOR, color); |
| 2467 } else { | 2467 } else { |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2691 FX_BOOL Field::value(IJS_Context* cc, | 2691 FX_BOOL Field::value(IJS_Context* cc, |
| 2692 CJS_PropValue& vp, | 2692 CJS_PropValue& vp, |
| 2693 CFX_WideString& sError) { | 2693 CFX_WideString& sError) { |
| 2694 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 2694 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 2695 | 2695 |
| 2696 if (vp.IsSetting()) { | 2696 if (vp.IsSetting()) { |
| 2697 if (!m_bCanSet) | 2697 if (!m_bCanSet) |
| 2698 return FALSE; | 2698 return FALSE; |
| 2699 | 2699 |
| 2700 std::vector<CFX_WideString> strArray; | 2700 std::vector<CFX_WideString> strArray; |
| 2701 if (vp.IsArrayObject()) { | 2701 if (vp.GetJSValue()->IsArrayObject()) { |
| 2702 CJS_Array ValueArray; | 2702 CJS_Array ValueArray; |
| 2703 vp.ConvertToArray(ValueArray); | 2703 vp.GetJSValue()->ConvertToArray(pRuntime->GetIsolate(), ValueArray); |
| 2704 for (int i = 0, sz = ValueArray.GetLength(); i < sz; i++) { | 2704 for (int i = 0, sz = ValueArray.GetLength(); i < sz; i++) { |
| 2705 CJS_Value ElementValue(pRuntime); | 2705 CJS_Value ElementValue(pRuntime); |
| 2706 ValueArray.GetElement(pRuntime->GetIsolate(), i, ElementValue); | 2706 ValueArray.GetElement(pRuntime->GetIsolate(), i, ElementValue); |
| 2707 strArray.push_back(ElementValue.ToCFXWideString()); | 2707 strArray.push_back( |
| 2708 ElementValue.ToCFXWideString(pRuntime->GetIsolate())); | |
| 2708 } | 2709 } |
| 2709 } else { | 2710 } else { |
| 2710 CFX_WideString swValue; | 2711 CFX_WideString swValue; |
| 2711 vp >> swValue; | 2712 vp >> swValue; |
| 2712 strArray.push_back(swValue); | 2713 strArray.push_back(swValue); |
| 2713 } | 2714 } |
| 2714 | 2715 |
| 2715 if (m_bDelay) { | 2716 if (m_bDelay) { |
| 2716 AddDelay_WideStringArray(FP_VALUE, strArray); | 2717 AddDelay_WideStringArray(FP_VALUE, strArray); |
| 2717 } else { | 2718 } else { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2730 case FIELDTYPE_TEXTFIELD: { | 2731 case FIELDTYPE_TEXTFIELD: { |
| 2731 vp << pFormField->GetValue(); | 2732 vp << pFormField->GetValue(); |
| 2732 } break; | 2733 } break; |
| 2733 case FIELDTYPE_LISTBOX: { | 2734 case FIELDTYPE_LISTBOX: { |
| 2734 if (pFormField->CountSelectedItems() > 1) { | 2735 if (pFormField->CountSelectedItems() > 1) { |
| 2735 CJS_Array ValueArray; | 2736 CJS_Array ValueArray; |
| 2736 CJS_Value ElementValue(pRuntime); | 2737 CJS_Value ElementValue(pRuntime); |
| 2737 int iIndex; | 2738 int iIndex; |
| 2738 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { | 2739 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { |
| 2739 iIndex = pFormField->GetSelectedIndex(i); | 2740 iIndex = pFormField->GetSelectedIndex(i); |
| 2740 ElementValue = pFormField->GetOptionValue(iIndex).c_str(); | 2741 ElementValue = |
| 2741 if (FXSYS_wcslen(ElementValue.ToCFXWideString().c_str()) == 0) | 2742 CJS_Value(pRuntime, pFormField->GetOptionValue(iIndex).c_str()); |
| 2742 ElementValue = pFormField->GetOptionLabel(iIndex).c_str(); | 2743 if (FXSYS_wcslen( |
| 2744 ElementValue.ToCFXWideString(pRuntime->GetIsolate()) | |
| 2745 .c_str()) == 0) | |
|
dsinclair
2016/08/09 19:25:33
nit: {}'s
Tom Sepez
2016/08/09 20:33:24
Done.
| |
| 2746 ElementValue = CJS_Value( | |
| 2747 pRuntime, pFormField->GetOptionLabel(iIndex).c_str()); | |
| 2743 ValueArray.SetElement(pRuntime->GetIsolate(), i, ElementValue); | 2748 ValueArray.SetElement(pRuntime->GetIsolate(), i, ElementValue); |
| 2744 } | 2749 } |
| 2745 vp << ValueArray; | 2750 vp << ValueArray; |
| 2746 } else { | 2751 } else { |
| 2747 vp << pFormField->GetValue(); | 2752 vp << pFormField->GetValue(); |
| 2748 } | 2753 } |
| 2749 } break; | 2754 } break; |
| 2750 case FIELDTYPE_CHECKBOX: | 2755 case FIELDTYPE_CHECKBOX: |
| 2751 case FIELDTYPE_RADIOBUTTON: { | 2756 case FIELDTYPE_RADIOBUTTON: { |
| 2752 bool bFind = false; | 2757 bool bFind = false; |
| 2753 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 2758 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
| 2754 if (pFormField->GetControl(i)->IsChecked()) { | 2759 if (pFormField->GetControl(i)->IsChecked()) { |
| 2755 vp << pFormField->GetControl(i)->GetExportValue(); | 2760 vp << pFormField->GetControl(i)->GetExportValue(); |
| 2756 bFind = true; | 2761 bFind = true; |
| 2757 break; | 2762 break; |
| 2758 } | 2763 } |
| 2759 } | 2764 } |
| 2760 if (!bFind) | 2765 if (!bFind) |
| 2761 vp << L"Off"; | 2766 vp << L"Off"; |
| 2762 } break; | 2767 } break; |
| 2763 default: | 2768 default: |
| 2764 vp << pFormField->GetValue(); | 2769 vp << pFormField->GetValue(); |
| 2765 break; | 2770 break; |
| 2766 } | 2771 } |
| 2767 } | 2772 } |
| 2768 vp.MaybeCoerceToNumber(); | 2773 vp.GetJSValue()->MaybeCoerceToNumber(m_isolate); |
| 2769 return TRUE; | 2774 return TRUE; |
| 2770 } | 2775 } |
| 2771 | 2776 |
| 2772 void Field::SetValue(CPDFSDK_Document* pDocument, | 2777 void Field::SetValue(CPDFSDK_Document* pDocument, |
| 2773 const CFX_WideString& swFieldName, | 2778 const CFX_WideString& swFieldName, |
| 2774 int nControlIndex, | 2779 int nControlIndex, |
| 2775 const std::vector<CFX_WideString>& strArray) { | 2780 const std::vector<CFX_WideString>& strArray) { |
| 2776 ASSERT(pDocument); | 2781 ASSERT(pDocument); |
| 2777 if (strArray.empty()) | 2782 if (strArray.empty()) |
| 2778 return; | 2783 return; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2884 } | 2889 } |
| 2885 return TRUE; | 2890 return TRUE; |
| 2886 } | 2891 } |
| 2887 return FALSE; | 2892 return FALSE; |
| 2888 } | 2893 } |
| 2889 | 2894 |
| 2890 FX_BOOL Field::buttonGetCaption(IJS_Context* cc, | 2895 FX_BOOL Field::buttonGetCaption(IJS_Context* cc, |
| 2891 const std::vector<CJS_Value>& params, | 2896 const std::vector<CJS_Value>& params, |
| 2892 CJS_Value& vRet, | 2897 CJS_Value& vRet, |
| 2893 CFX_WideString& sError) { | 2898 CFX_WideString& sError) { |
| 2899 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | |
| 2900 | |
| 2894 int nface = 0; | 2901 int nface = 0; |
| 2895 int iSize = params.size(); | 2902 int iSize = params.size(); |
| 2896 if (iSize >= 1) | 2903 if (iSize >= 1) |
| 2897 nface = params[0].ToInt(); | 2904 nface = params[0].ToInt(pRuntime->GetIsolate()); |
| 2898 | 2905 |
| 2899 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 2906 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
| 2900 if (FieldArray.empty()) | 2907 if (FieldArray.empty()) |
| 2901 return FALSE; | 2908 return FALSE; |
| 2902 | 2909 |
| 2903 CPDF_FormField* pFormField = FieldArray[0]; | 2910 CPDF_FormField* pFormField = FieldArray[0]; |
| 2904 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | 2911 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
| 2905 return FALSE; | 2912 return FALSE; |
| 2906 | 2913 |
| 2907 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 2914 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 2908 if (!pFormControl) | 2915 if (!pFormControl) |
| 2909 return FALSE; | 2916 return FALSE; |
| 2910 | 2917 |
| 2911 if (nface == 0) | 2918 if (nface == 0) |
| 2912 vRet = pFormControl->GetNormalCaption().c_str(); | 2919 vRet = CJS_Value(pRuntime, pFormControl->GetNormalCaption().c_str()); |
| 2913 else if (nface == 1) | 2920 else if (nface == 1) |
| 2914 vRet = pFormControl->GetDownCaption().c_str(); | 2921 vRet = CJS_Value(pRuntime, pFormControl->GetDownCaption().c_str()); |
| 2915 else if (nface == 2) | 2922 else if (nface == 2) |
| 2916 vRet = pFormControl->GetRolloverCaption().c_str(); | 2923 vRet = CJS_Value(pRuntime, pFormControl->GetRolloverCaption().c_str()); |
| 2917 else | 2924 else |
| 2918 return FALSE; | 2925 return FALSE; |
| 2919 | 2926 |
| 2920 return TRUE; | 2927 return TRUE; |
| 2921 } | 2928 } |
| 2922 | 2929 |
| 2923 FX_BOOL Field::buttonGetIcon(IJS_Context* cc, | 2930 FX_BOOL Field::buttonGetIcon(IJS_Context* cc, |
| 2924 const std::vector<CJS_Value>& params, | 2931 const std::vector<CJS_Value>& params, |
| 2925 CJS_Value& vRet, | 2932 CJS_Value& vRet, |
| 2926 CFX_WideString& sError) { | 2933 CFX_WideString& sError) { |
| 2934 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | |
| 2935 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | |
| 2936 | |
| 2927 int nface = 0; | 2937 int nface = 0; |
| 2928 int iSize = params.size(); | 2938 int iSize = params.size(); |
| 2929 if (iSize >= 1) | 2939 if (iSize >= 1) |
| 2930 nface = params[0].ToInt(); | 2940 nface = params[0].ToInt(pRuntime->GetIsolate()); |
| 2931 | 2941 |
| 2932 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 2942 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
| 2933 if (FieldArray.empty()) | 2943 if (FieldArray.empty()) |
| 2934 return FALSE; | 2944 return FALSE; |
| 2935 | 2945 |
| 2936 CPDF_FormField* pFormField = FieldArray[0]; | 2946 CPDF_FormField* pFormField = FieldArray[0]; |
| 2937 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | 2947 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
| 2938 return FALSE; | 2948 return FALSE; |
| 2939 | 2949 |
| 2940 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 2950 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 2941 if (!pFormControl) | 2951 if (!pFormControl) |
| 2942 return FALSE; | 2952 return FALSE; |
| 2943 | 2953 |
| 2944 CJS_Context* pContext = (CJS_Context*)cc; | |
| 2945 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | |
| 2946 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( | 2954 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( |
| 2947 pRuntime->GetIsolate(), pRuntime, CJS_Icon::g_nObjDefnID); | 2955 pRuntime->GetIsolate(), pRuntime, CJS_Icon::g_nObjDefnID); |
| 2948 ASSERT(pObj.IsEmpty() == FALSE); | 2956 ASSERT(pObj.IsEmpty() == FALSE); |
| 2949 | 2957 |
| 2950 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); | 2958 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); |
| 2951 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); | 2959 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
| 2952 | 2960 |
| 2953 CPDF_Stream* pIconStream = nullptr; | 2961 CPDF_Stream* pIconStream = nullptr; |
| 2954 if (nface == 0) | 2962 if (nface == 0) |
| 2955 pIconStream = pFormControl->GetNormalIcon(); | 2963 pIconStream = pFormControl->GetNormalIcon(); |
| 2956 else if (nface == 1) | 2964 else if (nface == 1) |
| 2957 pIconStream = pFormControl->GetDownIcon(); | 2965 pIconStream = pFormControl->GetDownIcon(); |
| 2958 else if (nface == 2) | 2966 else if (nface == 2) |
| 2959 pIconStream = pFormControl->GetRolloverIcon(); | 2967 pIconStream = pFormControl->GetRolloverIcon(); |
| 2960 else | 2968 else |
| 2961 return FALSE; | 2969 return FALSE; |
| 2962 | 2970 |
| 2963 pIcon->SetStream(pIconStream); | 2971 pIcon->SetStream(pIconStream); |
| 2964 vRet = pJS_Icon; | 2972 vRet = CJS_Value(pRuntime, pJS_Icon); |
| 2965 | |
| 2966 return TRUE; | 2973 return TRUE; |
| 2967 } | 2974 } |
| 2968 | 2975 |
| 2969 FX_BOOL Field::buttonImportIcon(IJS_Context* cc, | 2976 FX_BOOL Field::buttonImportIcon(IJS_Context* cc, |
| 2970 const std::vector<CJS_Value>& params, | 2977 const std::vector<CJS_Value>& params, |
| 2971 CJS_Value& vRet, | 2978 CJS_Value& vRet, |
| 2972 CFX_WideString& sError) { | 2979 CFX_WideString& sError) { |
| 2973 return TRUE; | 2980 return TRUE; |
| 2974 } | 2981 } |
| 2975 | 2982 |
| 2976 FX_BOOL Field::buttonSetCaption(IJS_Context* cc, | 2983 FX_BOOL Field::buttonSetCaption(IJS_Context* cc, |
| 2977 const std::vector<CJS_Value>& params, | 2984 const std::vector<CJS_Value>& params, |
| 2978 CJS_Value& vRet, | 2985 CJS_Value& vRet, |
| 2979 CFX_WideString& sError) { | 2986 CFX_WideString& sError) { |
| 2980 return FALSE; | 2987 return FALSE; |
| 2981 } | 2988 } |
| 2982 | 2989 |
| 2983 FX_BOOL Field::buttonSetIcon(IJS_Context* cc, | 2990 FX_BOOL Field::buttonSetIcon(IJS_Context* cc, |
| 2984 const std::vector<CJS_Value>& params, | 2991 const std::vector<CJS_Value>& params, |
| 2985 CJS_Value& vRet, | 2992 CJS_Value& vRet, |
| 2986 CFX_WideString& sError) { | 2993 CFX_WideString& sError) { |
| 2987 return FALSE; | 2994 return FALSE; |
| 2988 } | 2995 } |
| 2989 | 2996 |
| 2990 FX_BOOL Field::checkThisBox(IJS_Context* cc, | 2997 FX_BOOL Field::checkThisBox(IJS_Context* cc, |
| 2991 const std::vector<CJS_Value>& params, | 2998 const std::vector<CJS_Value>& params, |
| 2992 CJS_Value& vRet, | 2999 CJS_Value& vRet, |
| 2993 CFX_WideString& sError) { | 3000 CFX_WideString& sError) { |
| 3001 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | |
|
dsinclair
2016/08/09 19:25:33
...
Tom Sepez
2016/08/09 20:33:24
Done.
| |
| 2994 ASSERT(m_pDocument); | 3002 ASSERT(m_pDocument); |
| 2995 | 3003 |
| 2996 if (!m_bCanSet) | 3004 if (!m_bCanSet) |
| 2997 return FALSE; | 3005 return FALSE; |
| 2998 | 3006 |
| 2999 int iSize = params.size(); | 3007 int iSize = params.size(); |
| 3000 if (iSize < 1) | 3008 if (iSize < 1) |
| 3001 return FALSE; | 3009 return FALSE; |
| 3002 | 3010 |
| 3003 int nWidget = params[0].ToInt(); | 3011 int nWidget = params[0].ToInt(pRuntime->GetIsolate()); |
| 3004 | 3012 |
| 3005 bool bCheckit = true; | 3013 bool bCheckit = true; |
| 3006 if (iSize >= 2) | 3014 if (iSize >= 2) |
| 3007 bCheckit = params[1].ToBool(); | 3015 bCheckit = params[1].ToBool(pRuntime->GetIsolate()); |
| 3008 | 3016 |
| 3009 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 3017 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
| 3010 if (FieldArray.empty()) | 3018 if (FieldArray.empty()) |
| 3011 return FALSE; | 3019 return FALSE; |
| 3012 | 3020 |
| 3013 CPDF_FormField* pFormField = FieldArray[0]; | 3021 CPDF_FormField* pFormField = FieldArray[0]; |
| 3014 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && | 3022 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && |
| 3015 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) | 3023 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) |
| 3016 return FALSE; | 3024 return FALSE; |
| 3017 if (nWidget < 0 || nWidget >= pFormField->CountControls()) | 3025 if (nWidget < 0 || nWidget >= pFormField->CountControls()) |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 3031 const std::vector<CJS_Value>& params, | 3039 const std::vector<CJS_Value>& params, |
| 3032 CJS_Value& vRet, | 3040 CJS_Value& vRet, |
| 3033 CFX_WideString& sError) { | 3041 CFX_WideString& sError) { |
| 3034 return TRUE; | 3042 return TRUE; |
| 3035 } | 3043 } |
| 3036 | 3044 |
| 3037 FX_BOOL Field::defaultIsChecked(IJS_Context* cc, | 3045 FX_BOOL Field::defaultIsChecked(IJS_Context* cc, |
| 3038 const std::vector<CJS_Value>& params, | 3046 const std::vector<CJS_Value>& params, |
| 3039 CJS_Value& vRet, | 3047 CJS_Value& vRet, |
| 3040 CFX_WideString& sError) { | 3048 CFX_WideString& sError) { |
| 3049 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | |
|
dsinclair
2016/08/09 19:25:33
...
Tom Sepez
2016/08/09 20:33:24
Done.
| |
| 3050 | |
| 3041 if (!m_bCanSet) | 3051 if (!m_bCanSet) |
| 3042 return FALSE; | 3052 return FALSE; |
| 3043 | 3053 |
| 3044 int iSize = params.size(); | 3054 int iSize = params.size(); |
| 3045 if (iSize < 1) | 3055 if (iSize < 1) |
| 3046 return FALSE; | 3056 return FALSE; |
| 3047 | 3057 |
| 3048 int nWidget = params[0].ToInt(); | 3058 int nWidget = params[0].ToInt(pRuntime->GetIsolate()); |
| 3049 | 3059 |
| 3050 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 3060 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
| 3051 if (FieldArray.empty()) | 3061 if (FieldArray.empty()) |
| 3052 return FALSE; | 3062 return FALSE; |
| 3053 | 3063 |
| 3054 CPDF_FormField* pFormField = FieldArray[0]; | 3064 CPDF_FormField* pFormField = FieldArray[0]; |
| 3055 if (nWidget < 0 || nWidget >= pFormField->CountControls()) { | 3065 if (nWidget < 0 || nWidget >= pFormField->CountControls()) |
| 3056 vRet = FALSE; | |
|
dsinclair
2016/08/09 19:25:33
Not needed?
Tom Sepez
2016/08/09 20:33:24
When we return false, JS throws an execption, and
| |
| 3057 return FALSE; | 3066 return FALSE; |
| 3058 } | 3067 |
| 3059 vRet = pFormField->GetFieldType() == FIELDTYPE_CHECKBOX || | 3068 vRet = CJS_Value(pRuntime, |
| 3060 pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON; | 3069 pFormField->GetFieldType() == FIELDTYPE_CHECKBOX || |
| 3070 pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON); | |
| 3061 | 3071 |
| 3062 return TRUE; | 3072 return TRUE; |
| 3063 } | 3073 } |
| 3064 | 3074 |
| 3065 FX_BOOL Field::deleteItemAt(IJS_Context* cc, | 3075 FX_BOOL Field::deleteItemAt(IJS_Context* cc, |
| 3066 const std::vector<CJS_Value>& params, | 3076 const std::vector<CJS_Value>& params, |
| 3067 CJS_Value& vRet, | 3077 CJS_Value& vRet, |
| 3068 CFX_WideString& sError) { | 3078 CFX_WideString& sError) { |
| 3069 return TRUE; | 3079 return TRUE; |
| 3070 } | 3080 } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 3095 int j = 0; | 3105 int j = 0; |
| 3096 for (const auto& pStr : swSort) { | 3106 for (const auto& pStr : swSort) { |
| 3097 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( | 3107 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( |
| 3098 pRuntime->GetIsolate(), pRuntime, CJS_Field::g_nObjDefnID); | 3108 pRuntime->GetIsolate(), pRuntime, CJS_Field::g_nObjDefnID); |
| 3099 ASSERT(!pObj.IsEmpty()); | 3109 ASSERT(!pObj.IsEmpty()); |
| 3100 | 3110 |
| 3101 CJS_Field* pJSField = | 3111 CJS_Field* pJSField = |
| 3102 static_cast<CJS_Field*>(FXJS_GetPrivate(pRuntime->GetIsolate(), pObj)); | 3112 static_cast<CJS_Field*>(FXJS_GetPrivate(pRuntime->GetIsolate(), pObj)); |
| 3103 Field* pField = static_cast<Field*>(pJSField->GetEmbedObject()); | 3113 Field* pField = static_cast<Field*>(pJSField->GetEmbedObject()); |
| 3104 pField->AttachField(m_pJSDoc, *pStr); | 3114 pField->AttachField(m_pJSDoc, *pStr); |
| 3105 | 3115 FormFieldArray.SetElement(pRuntime->GetIsolate(), j++, |
| 3106 CJS_Value FormFieldValue(pRuntime); | 3116 CJS_Value(pRuntime, pJSField)); |
| 3107 FormFieldValue = pJSField; | |
| 3108 FormFieldArray.SetElement(pRuntime->GetIsolate(), j++, FormFieldValue); | |
| 3109 } | 3117 } |
| 3110 | 3118 |
| 3111 vRet = CJS_Value(pRuntime, FormFieldArray); | 3119 vRet = CJS_Value(pRuntime, FormFieldArray); |
| 3112 return TRUE; | 3120 return TRUE; |
| 3113 } | 3121 } |
| 3114 | 3122 |
| 3115 FX_BOOL Field::getItemAt(IJS_Context* cc, | 3123 FX_BOOL Field::getItemAt(IJS_Context* cc, |
| 3116 const std::vector<CJS_Value>& params, | 3124 const std::vector<CJS_Value>& params, |
| 3117 CJS_Value& vRet, | 3125 CJS_Value& vRet, |
| 3118 CFX_WideString& sError) { | 3126 CFX_WideString& sError) { |
| 3127 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | |
| 3128 | |
| 3119 int iSize = params.size(); | 3129 int iSize = params.size(); |
| 3120 | |
| 3121 int nIdx = -1; | 3130 int nIdx = -1; |
| 3122 if (iSize >= 1) | 3131 if (iSize >= 1) |
| 3123 nIdx = params[0].ToInt(); | 3132 nIdx = params[0].ToInt(pRuntime->GetIsolate()); |
| 3124 | 3133 |
| 3125 FX_BOOL bExport = TRUE; | 3134 FX_BOOL bExport = TRUE; |
| 3126 if (iSize >= 2) | 3135 if (iSize >= 2) |
| 3127 bExport = params[1].ToBool(); | 3136 bExport = params[1].ToBool(pRuntime->GetIsolate()); |
| 3128 | 3137 |
| 3129 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 3138 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
| 3130 if (FieldArray.empty()) | 3139 if (FieldArray.empty()) |
| 3131 return FALSE; | 3140 return FALSE; |
| 3132 | 3141 |
| 3133 CPDF_FormField* pFormField = FieldArray[0]; | 3142 CPDF_FormField* pFormField = FieldArray[0]; |
| 3134 if ((pFormField->GetFieldType() == FIELDTYPE_LISTBOX) || | 3143 if ((pFormField->GetFieldType() == FIELDTYPE_LISTBOX) || |
| 3135 (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX)) { | 3144 (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX)) { |
| 3136 if (nIdx == -1 || nIdx > pFormField->CountOptions()) | 3145 if (nIdx == -1 || nIdx > pFormField->CountOptions()) |
| 3137 nIdx = pFormField->CountOptions() - 1; | 3146 nIdx = pFormField->CountOptions() - 1; |
| 3138 if (bExport) { | 3147 if (bExport) { |
| 3139 CFX_WideString strval = pFormField->GetOptionValue(nIdx); | 3148 CFX_WideString strval = pFormField->GetOptionValue(nIdx); |
| 3140 if (strval.IsEmpty()) | 3149 if (strval.IsEmpty()) |
| 3141 vRet = pFormField->GetOptionLabel(nIdx).c_str(); | 3150 vRet = CJS_Value(pRuntime, pFormField->GetOptionLabel(nIdx).c_str()); |
| 3142 else | 3151 else |
| 3143 vRet = strval.c_str(); | 3152 vRet = CJS_Value(pRuntime, strval.c_str()); |
| 3144 } else { | 3153 } else { |
| 3145 vRet = pFormField->GetOptionLabel(nIdx).c_str(); | 3154 vRet = CJS_Value(pRuntime, pFormField->GetOptionLabel(nIdx).c_str()); |
| 3146 } | 3155 } |
| 3147 } else { | 3156 } else { |
| 3148 return FALSE; | 3157 return FALSE; |
| 3149 } | 3158 } |
| 3150 | 3159 |
| 3151 return TRUE; | 3160 return TRUE; |
| 3152 } | 3161 } |
| 3153 | 3162 |
| 3154 FX_BOOL Field::getLock(IJS_Context* cc, | 3163 FX_BOOL Field::getLock(IJS_Context* cc, |
| 3155 const std::vector<CJS_Value>& params, | 3164 const std::vector<CJS_Value>& params, |
| 3156 CJS_Value& vRet, | 3165 CJS_Value& vRet, |
| 3157 CFX_WideString& sError) { | 3166 CFX_WideString& sError) { |
| 3158 return FALSE; | 3167 return FALSE; |
| 3159 } | 3168 } |
| 3160 | 3169 |
| 3161 FX_BOOL Field::insertItemAt(IJS_Context* cc, | 3170 FX_BOOL Field::insertItemAt(IJS_Context* cc, |
| 3162 const std::vector<CJS_Value>& params, | 3171 const std::vector<CJS_Value>& params, |
| 3163 CJS_Value& vRet, | 3172 CJS_Value& vRet, |
| 3164 CFX_WideString& sError) { | 3173 CFX_WideString& sError) { |
| 3165 return TRUE; | 3174 return TRUE; |
| 3166 } | 3175 } |
| 3167 | 3176 |
| 3168 FX_BOOL Field::isBoxChecked(IJS_Context* cc, | 3177 FX_BOOL Field::isBoxChecked(IJS_Context* cc, |
| 3169 const std::vector<CJS_Value>& params, | 3178 const std::vector<CJS_Value>& params, |
| 3170 CJS_Value& vRet, | 3179 CJS_Value& vRet, |
| 3171 CFX_WideString& sError) { | 3180 CFX_WideString& sError) { |
| 3181 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | |
| 3182 | |
| 3172 int nIndex = -1; | 3183 int nIndex = -1; |
| 3173 if (params.size() >= 1) | 3184 if (params.size() >= 1) |
| 3174 nIndex = params[0].ToInt(); | 3185 nIndex = params[0].ToInt(pRuntime->GetIsolate()); |
| 3175 | 3186 |
| 3176 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 3187 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
| 3177 if (FieldArray.empty()) | 3188 if (FieldArray.empty()) |
| 3178 return FALSE; | 3189 return FALSE; |
| 3179 | 3190 |
| 3180 CPDF_FormField* pFormField = FieldArray[0]; | 3191 CPDF_FormField* pFormField = FieldArray[0]; |
| 3181 if (nIndex < 0 || nIndex >= pFormField->CountControls()) { | 3192 if (nIndex < 0 || nIndex >= pFormField->CountControls()) { |
| 3182 vRet = FALSE; | |
|
dsinclair
2016/08/09 19:25:33
Not needed?
Tom Sepez
2016/08/09 20:33:24
See above.
| |
| 3183 return FALSE; | 3193 return FALSE; |
| 3184 } | 3194 } |
| 3185 | 3195 |
| 3186 if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) || | 3196 vRet = CJS_Value(pRuntime, |
| 3187 (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)) { | 3197 ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX || |
| 3188 if (pFormField->GetControl(nIndex)->IsChecked() != 0) | 3198 pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) && |
| 3189 vRet = TRUE; | 3199 pFormField->GetControl(nIndex)->IsChecked() != 0)); |
| 3190 else | |
| 3191 vRet = FALSE; | |
| 3192 } else { | |
| 3193 vRet = FALSE; | |
| 3194 } | |
| 3195 | |
| 3196 return TRUE; | 3200 return TRUE; |
| 3197 } | 3201 } |
| 3198 | 3202 |
| 3199 FX_BOOL Field::isDefaultChecked(IJS_Context* cc, | 3203 FX_BOOL Field::isDefaultChecked(IJS_Context* cc, |
| 3200 const std::vector<CJS_Value>& params, | 3204 const std::vector<CJS_Value>& params, |
| 3201 CJS_Value& vRet, | 3205 CJS_Value& vRet, |
| 3202 CFX_WideString& sError) { | 3206 CFX_WideString& sError) { |
| 3207 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | |
| 3208 | |
| 3203 int nIndex = -1; | 3209 int nIndex = -1; |
| 3204 if (params.size() >= 1) | 3210 if (params.size() >= 1) |
| 3205 nIndex = params[0].ToInt(); | 3211 nIndex = params[0].ToInt(pRuntime->GetIsolate()); |
| 3206 | 3212 |
| 3207 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 3213 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
| 3208 if (FieldArray.empty()) | 3214 if (FieldArray.empty()) |
| 3209 return FALSE; | 3215 return FALSE; |
| 3210 | 3216 |
| 3211 CPDF_FormField* pFormField = FieldArray[0]; | 3217 CPDF_FormField* pFormField = FieldArray[0]; |
| 3212 if (nIndex < 0 || nIndex >= pFormField->CountControls()) { | 3218 if (nIndex < 0 || nIndex >= pFormField->CountControls()) |
| 3213 vRet = FALSE; | |
|
dsinclair
2016/08/09 19:25:33
...
Tom Sepez
2016/08/09 20:33:24
...
| |
| 3214 return FALSE; | 3219 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 | 3220 |
| 3221 vRet = CJS_Value(pRuntime, | |
| 3222 ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX || | |
| 3223 pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) && | |
| 3224 pFormField->GetControl(nIndex)->IsDefaultChecked() != 0)); | |
| 3226 return TRUE; | 3225 return TRUE; |
| 3227 } | 3226 } |
| 3228 | 3227 |
| 3229 FX_BOOL Field::setAction(IJS_Context* cc, | 3228 FX_BOOL Field::setAction(IJS_Context* cc, |
| 3230 const std::vector<CJS_Value>& params, | 3229 const std::vector<CJS_Value>& params, |
| 3231 CJS_Value& vRet, | 3230 CJS_Value& vRet, |
| 3232 CFX_WideString& sError) { | 3231 CFX_WideString& sError) { |
| 3233 return TRUE; | 3232 return TRUE; |
| 3234 } | 3233 } |
| 3235 | 3234 |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3540 } | 3539 } |
| 3541 } | 3540 } |
| 3542 | 3541 |
| 3543 void Field::AddField(CPDFSDK_Document* pDocument, | 3542 void Field::AddField(CPDFSDK_Document* pDocument, |
| 3544 int nPageIndex, | 3543 int nPageIndex, |
| 3545 int nFieldType, | 3544 int nFieldType, |
| 3546 const CFX_WideString& sName, | 3545 const CFX_WideString& sName, |
| 3547 const CFX_FloatRect& rcCoords) { | 3546 const CFX_FloatRect& rcCoords) { |
| 3548 // Not supported. | 3547 // Not supported. |
| 3549 } | 3548 } |
| OLD | NEW |