| 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/src/javascript/Field.h" | 7 #include "fpdfsdk/src/javascript/Field.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 3004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3015 | 3015 |
| 3016 if (!m_bCanSet) | 3016 if (!m_bCanSet) |
| 3017 return FALSE; | 3017 return FALSE; |
| 3018 | 3018 |
| 3019 int iSize = params.size(); | 3019 int iSize = params.size(); |
| 3020 if (iSize < 1) | 3020 if (iSize < 1) |
| 3021 return FALSE; | 3021 return FALSE; |
| 3022 | 3022 |
| 3023 int nWidget = params[0].ToInt(); | 3023 int nWidget = params[0].ToInt(); |
| 3024 | 3024 |
| 3025 FX_BOOL bCheckit = TRUE; | 3025 bool bCheckit = true; |
| 3026 if (iSize >= 2) | 3026 if (iSize >= 2) |
| 3027 bCheckit = params[1].ToBool(); | 3027 bCheckit = params[1].ToBool(); |
| 3028 | 3028 |
| 3029 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 3029 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
| 3030 if (FieldArray.empty()) | 3030 if (FieldArray.empty()) |
| 3031 return FALSE; | 3031 return FALSE; |
| 3032 | 3032 |
| 3033 CPDF_FormField* pFormField = FieldArray[0]; | 3033 CPDF_FormField* pFormField = FieldArray[0]; |
| 3034 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && | 3034 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && |
| 3035 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) | 3035 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) |
| 3036 return FALSE; | 3036 return FALSE; |
| 3037 if (nWidget < 0 || nWidget >= pFormField->CountControls()) | 3037 if (nWidget < 0 || nWidget >= pFormField->CountControls()) |
| 3038 return FALSE; | 3038 return FALSE; |
| 3039 // TODO(weili): Check whether anything special needed for radio button, |
| 3040 // otherwise merge these branches. |
| 3039 if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) | 3041 if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) |
| 3040 pFormField->CheckControl(nWidget, bCheckit, TRUE); | 3042 pFormField->CheckControl(nWidget, bCheckit, true); |
| 3041 else | 3043 else |
| 3042 pFormField->CheckControl(nWidget, bCheckit, TRUE); | 3044 pFormField->CheckControl(nWidget, bCheckit, true); |
| 3043 | 3045 |
| 3044 UpdateFormField(m_pDocument, pFormField, TRUE, TRUE, TRUE); | 3046 UpdateFormField(m_pDocument, pFormField, TRUE, TRUE, TRUE); |
| 3045 return TRUE; | 3047 return TRUE; |
| 3046 } | 3048 } |
| 3047 | 3049 |
| 3048 FX_BOOL Field::clearItems(IJS_Context* cc, | 3050 FX_BOOL Field::clearItems(IJS_Context* cc, |
| 3049 const std::vector<CJS_Value>& params, | 3051 const std::vector<CJS_Value>& params, |
| 3050 CJS_Value& vRet, | 3052 CJS_Value& vRet, |
| 3051 CFX_WideString& sError) { | 3053 CFX_WideString& sError) { |
| 3052 return TRUE; | 3054 return TRUE; |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3589 } | 3591 } |
| 3590 } | 3592 } |
| 3591 | 3593 |
| 3592 void Field::AddField(CPDFSDK_Document* pDocument, | 3594 void Field::AddField(CPDFSDK_Document* pDocument, |
| 3593 int nPageIndex, | 3595 int nPageIndex, |
| 3594 int nFieldType, | 3596 int nFieldType, |
| 3595 const CFX_WideString& sName, | 3597 const CFX_WideString& sName, |
| 3596 const CFX_FloatRect& rcCoords) { | 3598 const CFX_FloatRect& rcCoords) { |
| 3597 // Not supported. | 3599 // Not supported. |
| 3598 } | 3600 } |
| OLD | NEW |