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 "core/include/fpdfdoc/fpdf_doc.h" | 7 #include "core/include/fpdfdoc/fpdf_doc.h" |
8 #include "doc_utils.h" | 8 #include "doc_utils.h" |
9 | 9 |
10 FX_BOOL PDF_FormField_IsUnison(CPDF_FormField* pField) { | 10 FX_BOOL PDF_FormField_IsUnison(CPDF_FormField* pField) { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 } | 200 } |
201 if (bNotify && m_pForm->m_pFormNotify != NULL) { | 201 if (bNotify && m_pForm->m_pFormNotify != NULL) { |
202 m_pForm->m_pFormNotify->AfterValueChange(this); | 202 m_pForm->m_pFormNotify->AfterValueChange(this); |
203 } | 203 } |
204 m_pForm->m_bUpdated = TRUE; | 204 m_pForm->m_bUpdated = TRUE; |
205 } break; | 205 } break; |
206 } | 206 } |
207 return TRUE; | 207 return TRUE; |
208 } | 208 } |
209 int CPDF_FormField::GetControlIndex(const CPDF_FormControl* pControl) { | 209 int CPDF_FormField::GetControlIndex(const CPDF_FormControl* pControl) { |
210 if (pControl == NULL) { | 210 if (!pControl) { |
211 return -1; | 211 return -1; |
212 } | 212 } |
213 int iCount = m_ControlList.GetSize(); | 213 for (int i = 0; i < m_ControlList.GetSize(); i++) { |
214 for (int i = 0; i < iCount; i++) { | 214 if (m_ControlList.GetAt(i) == pControl) |
215 CPDF_FormControl* pFind = (CPDF_FormControl*)m_ControlList.GetAt(i); | |
216 if (pFind == pControl) { | |
217 return i; | 215 return i; |
218 } | |
219 } | 216 } |
220 return -1; | 217 return -1; |
221 } | 218 } |
222 int CPDF_FormField::GetFieldType() { | 219 int CPDF_FormField::GetFieldType() { |
223 switch (m_Type) { | 220 switch (m_Type) { |
224 case PushButton: | 221 case PushButton: |
225 return FIELDTYPE_PUSHBUTTON; | 222 return FIELDTYPE_PUSHBUTTON; |
226 case CheckBox: | 223 case CheckBox: |
227 return FIELDTYPE_CHECKBOX; | 224 return FIELDTYPE_CHECKBOX; |
228 case RadioButton: | 225 case RadioButton: |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 } | 389 } |
393 if (CPDF_InterForm::m_bUpdateAP) { | 390 if (CPDF_InterForm::m_bUpdateAP) { |
394 UpdateAP(NULL); | 391 UpdateAP(NULL); |
395 } | 392 } |
396 return TRUE; | 393 return TRUE; |
397 } | 394 } |
398 FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value, FX_BOOL bNotify) { | 395 FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value, FX_BOOL bNotify) { |
399 return SetValue(value, FALSE, bNotify); | 396 return SetValue(value, FALSE, bNotify); |
400 } | 397 } |
401 int CPDF_FormField::GetMaxLen() { | 398 int CPDF_FormField::GetMaxLen() { |
402 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "MaxLen"); | 399 if (CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "MaxLen")) |
403 if (pObj == NULL) { | 400 return pObj->GetInteger(); |
404 int iCount = m_ControlList.GetSize(); | 401 |
405 for (int i = 0; i < iCount; i++) { | 402 for (int i = 0; i < m_ControlList.GetSize(); i++) { |
406 CPDF_FormControl* pControl = (CPDF_FormControl*)m_ControlList.GetAt(i); | 403 CPDF_FormControl* pControl = m_ControlList.GetAt(i); |
407 if (pControl == NULL) { | 404 if (!pControl) |
408 continue; | 405 continue; |
409 } | 406 |
410 CPDF_Dictionary* pWidgetDict = pControl->m_pWidgetDict; | 407 CPDF_Dictionary* pWidgetDict = pControl->m_pWidgetDict; |
411 if (pWidgetDict->KeyExist("MaxLen")) { | 408 if (pWidgetDict->KeyExist("MaxLen")) |
412 return pWidgetDict->GetInteger("MaxLen"); | 409 return pWidgetDict->GetInteger("MaxLen"); |
413 } | |
414 } | |
415 return 0; | |
416 } | 410 } |
417 return pObj->GetInteger(); | 411 return 0; |
418 } | 412 } |
419 int CPDF_FormField::CountSelectedItems() { | 413 int CPDF_FormField::CountSelectedItems() { |
420 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); | 414 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); |
421 if (!pValue) { | 415 if (!pValue) { |
422 pValue = FPDF_GetFieldAttr(m_pDict, "I"); | 416 pValue = FPDF_GetFieldAttr(m_pDict, "I"); |
423 if (!pValue) | 417 if (!pValue) |
424 return 0; | 418 return 0; |
425 } | 419 } |
426 | 420 |
427 if (pValue->IsString() || pValue->IsNumber()) | 421 if (pValue->IsString() || pValue->IsNumber()) |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")) | 1029 m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")) |
1036 pFontDict = m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")->GetDict( | 1030 pFontDict = m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")->GetDict( |
1037 font_name); | 1031 font_name); |
1038 | 1032 |
1039 if (pFontDict == NULL) { | 1033 if (pFontDict == NULL) { |
1040 return; | 1034 return; |
1041 } | 1035 } |
1042 m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict); | 1036 m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict); |
1043 m_FontSize = FX_atof(syntax.GetWord()); | 1037 m_FontSize = FX_atof(syntax.GetWord()); |
1044 } | 1038 } |
OLD | NEW |