| 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 "../../include/fpdfdoc/fpdf_doc.h" | 7 #include "../../include/fpdfdoc/fpdf_doc.h" |
| 8 CFX_WideString GetFullName(CPDF_Dictionary* pFieldDict); | 8 CFX_WideString GetFullName(CPDF_Dictionary* pFieldDict); |
| 9 void SaveCheckedFieldStatus(CPDF_FormField* pField, C
FX_ByteArray& statusArray); | 9 void SaveCheckedFieldStatus(CPDF_FormField* pField, C
FX_ByteArray& statusArray); |
| 10 FX_BOOL PDF_FormField_IsUnison(CPDF_FormField *pField) | 10 FX_BOOL PDF_FormField_IsUnison(CPDF_FormField *pField) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 m_pForm = pForm; | 25 m_pForm = pForm; |
| 26 m_pFont = NULL; | 26 m_pFont = NULL; |
| 27 m_FontSize = 0; | 27 m_FontSize = 0; |
| 28 SyncFieldFlags(); | 28 SyncFieldFlags(); |
| 29 } | 29 } |
| 30 CPDF_FormField::~CPDF_FormField() | 30 CPDF_FormField::~CPDF_FormField() |
| 31 { | 31 { |
| 32 } | 32 } |
| 33 void CPDF_FormField::SyncFieldFlags() | 33 void CPDF_FormField::SyncFieldFlags() |
| 34 { | 34 { |
| 35 CFX_ByteString type_name = FPDF_GetFieldAttr(m_pDict, "FT")->GetString(); | 35 CFX_ByteString type_name = FPDF_GetFieldAttr(m_pDict, "FT") ? FPDF_GetFieldA
ttr(m_pDict, "FT")->GetString() : CFX_ByteString(); |
| 36 FX_DWORD flags = FPDF_GetFieldAttr(m_pDict, "Ff")->GetInteger(); | 36 FX_DWORD flags = FPDF_GetFieldAttr(m_pDict, "Ff")? FPDF_GetFieldAttr(m_pDict
, "Ff")->GetInteger() : 0; |
| 37 m_Flags = 0; | 37 m_Flags = 0; |
| 38 if (flags & 1) { | 38 if (flags & 1) { |
| 39 m_Flags |= FORMFIELD_READONLY; | 39 m_Flags |= FORMFIELD_READONLY; |
| 40 } | 40 } |
| 41 if (flags & 2) { | 41 if (flags & 2) { |
| 42 m_Flags |= FORMFIELD_REQUIRED; | 42 m_Flags |= FORMFIELD_REQUIRED; |
| 43 } | 43 } |
| 44 if (flags & 4) { | 44 if (flags & 4) { |
| 45 m_Flags |= FORMFIELD_NOEXPORT; | 45 m_Flags |= FORMFIELD_NOEXPORT; |
| 46 } | 46 } |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 sel_value = pValue->GetUnicodeText(); | 478 sel_value = pValue->GetUnicodeText(); |
| 479 } else if (pValue->GetType() == PDFOBJ_NUMBER) { | 479 } else if (pValue->GetType() == PDFOBJ_NUMBER) { |
| 480 return pValue->GetInteger(); | 480 return pValue->GetInteger(); |
| 481 } else { | 481 } else { |
| 482 if (pValue->GetType() != PDFOBJ_ARRAY) { | 482 if (pValue->GetType() != PDFOBJ_ARRAY) { |
| 483 return -1; | 483 return -1; |
| 484 } | 484 } |
| 485 if (index < 0) { | 485 if (index < 0) { |
| 486 return -1; | 486 return -1; |
| 487 } | 487 } |
| 488 sel_value = ((CPDF_Array*)pValue)->GetElementValue(index)->GetUnicodeTex
t(); | 488 CPDF_Object* elementValue = ((CPDF_Array*)pValue)->GetElementValue(index
); |
| 489 sel_value = elementValue ? elementValue->GetUnicodeText() : CFX_WideStri
ng(); |
| 489 } | 490 } |
| 490 if (index < CountSelectedOptions()) { | 491 if (index < CountSelectedOptions()) { |
| 491 int iOptIndex = GetSelectedOptionIndex(index); | 492 int iOptIndex = GetSelectedOptionIndex(index); |
| 492 CFX_WideString csOpt = GetOptionValue(iOptIndex); | 493 CFX_WideString csOpt = GetOptionValue(iOptIndex); |
| 493 if (csOpt == sel_value) { | 494 if (csOpt == sel_value) { |
| 494 return iOptIndex; | 495 return iOptIndex; |
| 495 } | 496 } |
| 496 } | 497 } |
| 497 int nOpts = CountOptions(); | 498 int nOpts = CountOptions(); |
| 498 for (int i = 0; i < nOpts; i ++) { | 499 for (int i = 0; i < nOpts; i ++) { |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 } | 1070 } |
| 1070 if (GetType() == ComboBox) { | 1071 if (GetType() == ComboBox) { |
| 1071 m_pForm->m_pFormNotify->AfterValueChange(this); | 1072 m_pForm->m_pFormNotify->AfterValueChange(this); |
| 1072 } | 1073 } |
| 1073 } | 1074 } |
| 1074 m_pForm->m_bUpdated = TRUE; | 1075 m_pForm->m_bUpdated = TRUE; |
| 1075 return TRUE; | 1076 return TRUE; |
| 1076 } | 1077 } |
| 1077 void CPDF_FormField::LoadDA() | 1078 void CPDF_FormField::LoadDA() |
| 1078 { | 1079 { |
| 1079 CFX_ByteString DA = FPDF_GetFieldAttr(m_pDict, "DA")->GetString(); | 1080 CFX_ByteString DA = FPDF_GetFieldAttr(m_pDict, "DA") ? FPDF_GetFieldAttr(m_p
Dict, "DA")->GetString() : CFX_ByteString(); |
| 1080 if (DA.IsEmpty()) { | 1081 if (DA.IsEmpty()) { |
| 1081 DA = m_pForm->m_pFormDict->GetString("DA"); | 1082 DA = m_pForm->m_pFormDict ? m_pForm->m_pFormDict->GetString("DA") : CFX_
ByteString(); |
| 1082 } | 1083 } |
| 1083 if (DA.IsEmpty()) { | 1084 if (DA.IsEmpty()) { |
| 1084 return; | 1085 return; |
| 1085 } | 1086 } |
| 1086 CPDF_SimpleParser syntax(DA); | 1087 CPDF_SimpleParser syntax(DA); |
| 1087 syntax.FindTagParam("Tf", 2); | 1088 syntax.FindTagParam("Tf", 2); |
| 1088 CFX_ByteString font_name = syntax.GetWord(); | 1089 CFX_ByteString font_name = syntax.GetWord(); |
| 1089 CPDF_Dictionary* pFontDict = m_pForm->m_pFormDict->GetDict("DR")->GetDict("F
ont")->GetDict(font_name); | 1090 CPDF_Dictionary* pFontDict = NULL; |
| 1091 if (m_pForm->m_pFormDict && m_pForm->m_pFormDict->GetDict("DR") && |
| 1092 m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font") ) |
| 1093 pFontDict = m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")->GetDict(fo
nt_name); |
| 1094 |
| 1090 if (pFontDict == NULL) { | 1095 if (pFontDict == NULL) { |
| 1091 return; | 1096 return; |
| 1092 } | 1097 } |
| 1093 m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict); | 1098 m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict); |
| 1094 m_FontSize = FX_atof(syntax.GetWord()); | 1099 m_FontSize = FX_atof(syntax.GetWord()); |
| 1095 } | 1100 } |
| OLD | NEW |