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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" | 9 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" |
10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 } | 749 } |
750 CPDF_FormField* CPDF_InterForm::GetFieldInCalculationOrder(int index) { | 750 CPDF_FormField* CPDF_InterForm::GetFieldInCalculationOrder(int index) { |
751 if (!m_pFormDict || index < 0) { | 751 if (!m_pFormDict || index < 0) { |
752 return NULL; | 752 return NULL; |
753 } | 753 } |
754 CPDF_Array* pArray = m_pFormDict->GetArrayBy("CO"); | 754 CPDF_Array* pArray = m_pFormDict->GetArrayBy("CO"); |
755 if (!pArray) { | 755 if (!pArray) { |
756 return NULL; | 756 return NULL; |
757 } | 757 } |
758 if (CPDF_Dictionary* pElement = | 758 if (CPDF_Dictionary* pElement = |
759 ToDictionary(pArray->GetElementValue(index))) { | 759 ToDictionary(pArray->GetDirectObjectAt(index))) { |
760 return GetFieldByDict(pElement); | 760 return GetFieldByDict(pElement); |
761 } | 761 } |
762 return NULL; | 762 return NULL; |
763 } | 763 } |
764 int CPDF_InterForm::FindFieldInCalculationOrder(const CPDF_FormField* pField) { | 764 int CPDF_InterForm::FindFieldInCalculationOrder(const CPDF_FormField* pField) { |
765 if (!m_pFormDict || !pField) { | 765 if (!m_pFormDict || !pField) { |
766 return -1; | 766 return -1; |
767 } | 767 } |
768 CPDF_Array* pArray = m_pFormDict->GetArrayBy("CO"); | 768 CPDF_Array* pArray = m_pFormDict->GetArrayBy("CO"); |
769 if (!pArray) { | 769 if (!pArray) { |
770 return -1; | 770 return -1; |
771 } | 771 } |
772 for (uint32_t i = 0; i < pArray->GetCount(); i++) { | 772 for (uint32_t i = 0; i < pArray->GetCount(); i++) { |
773 CPDF_Object* pElement = pArray->GetElementValue(i); | 773 CPDF_Object* pElement = pArray->GetDirectObjectAt(i); |
774 if (pElement == pField->m_pDict) { | 774 if (pElement == pField->m_pDict) { |
775 return i; | 775 return i; |
776 } | 776 } |
777 } | 777 } |
778 return -1; | 778 return -1; |
779 } | 779 } |
780 uint32_t CPDF_InterForm::CountFormFonts() { | 780 uint32_t CPDF_InterForm::CountFormFonts() { |
781 return CountInterFormFonts(m_pFormDict); | 781 return CountInterFormFonts(m_pFormDict); |
782 } | 782 } |
783 CPDF_Font* CPDF_InterForm::GetFormFont(uint32_t index, | 783 CPDF_Font* CPDF_InterForm::GetFormFont(uint32_t index, |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 CPDF_Dictionary* pParent = pFieldDict; | 946 CPDF_Dictionary* pParent = pFieldDict; |
947 if (!pFieldDict->KeyExist("T") && | 947 if (!pFieldDict->KeyExist("T") && |
948 pFieldDict->GetStringBy("Subtype") == "Widget") { | 948 pFieldDict->GetStringBy("Subtype") == "Widget") { |
949 pParent = pFieldDict->GetDictBy("Parent"); | 949 pParent = pFieldDict->GetDictBy("Parent"); |
950 if (!pParent) { | 950 if (!pParent) { |
951 pParent = pFieldDict; | 951 pParent = pFieldDict; |
952 } | 952 } |
953 } | 953 } |
954 if (pParent && pParent != pFieldDict && !pParent->KeyExist("FT")) { | 954 if (pParent && pParent != pFieldDict && !pParent->KeyExist("FT")) { |
955 if (pFieldDict->KeyExist("FT")) { | 955 if (pFieldDict->KeyExist("FT")) { |
956 CPDF_Object* pFTValue = pFieldDict->GetElementValue("FT"); | 956 CPDF_Object* pFTValue = pFieldDict->GetDirectObjectBy("FT"); |
957 if (pFTValue) { | 957 if (pFTValue) { |
958 pParent->SetAt("FT", pFTValue->Clone()); | 958 pParent->SetAt("FT", pFTValue->Clone()); |
959 } | 959 } |
960 } | 960 } |
961 if (pFieldDict->KeyExist("Ff")) { | 961 if (pFieldDict->KeyExist("Ff")) { |
962 CPDF_Object* pFfValue = pFieldDict->GetElementValue("Ff"); | 962 CPDF_Object* pFfValue = pFieldDict->GetDirectObjectBy("Ff"); |
963 if (pFfValue) { | 963 if (pFfValue) { |
964 pParent->SetAt("Ff", pFfValue->Clone()); | 964 pParent->SetAt("Ff", pFfValue->Clone()); |
965 } | 965 } |
966 } | 966 } |
967 } | 967 } |
968 pField = new CPDF_FormField(this, pParent); | 968 pField = new CPDF_FormField(this, pParent); |
969 CPDF_Object* pTObj = pDict->GetElement("T"); | 969 CPDF_Object* pTObj = pDict->GetObjectBy("T"); |
970 if (ToReference(pTObj)) { | 970 if (ToReference(pTObj)) { |
971 CPDF_Object* pClone = pTObj->Clone(TRUE); | 971 CPDF_Object* pClone = pTObj->Clone(TRUE); |
972 if (pClone) | 972 if (pClone) |
973 pDict->SetAt("T", pClone); | 973 pDict->SetAt("T", pClone); |
974 else | 974 else |
975 pDict->SetAtName("T", ""); | 975 pDict->SetAtName("T", ""); |
976 } | 976 } |
977 m_pFieldTree->SetField(csWName, pField); | 977 m_pFieldTree->SetField(csWName, pField); |
978 } | 978 } |
979 CPDF_Array* pKids = pFieldDict->GetArrayBy("Kids"); | 979 CPDF_Array* pKids = pFieldDict->GetArrayBy("Kids"); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 } | 1150 } |
1151 if (iRet < 0) { | 1151 if (iRet < 0) { |
1152 return; | 1152 return; |
1153 } | 1153 } |
1154 } | 1154 } |
1155 pField->SetValue(csWValue); | 1155 pField->SetValue(csWValue); |
1156 CPDF_FormField::Type eType = pField->GetType(); | 1156 CPDF_FormField::Type eType = pField->GetType(); |
1157 if ((eType == CPDF_FormField::ListBox || eType == CPDF_FormField::ComboBox) && | 1157 if ((eType == CPDF_FormField::ListBox || eType == CPDF_FormField::ComboBox) && |
1158 pFieldDict->KeyExist("Opt")) { | 1158 pFieldDict->KeyExist("Opt")) { |
1159 pField->m_pDict->SetAt("Opt", | 1159 pField->m_pDict->SetAt("Opt", |
1160 pFieldDict->GetElementValue("Opt")->Clone(TRUE)); | 1160 pFieldDict->GetDirectObjectBy("Opt")->Clone(TRUE)); |
1161 } | 1161 } |
1162 if (bNotify && m_pFormNotify) { | 1162 if (bNotify && m_pFormNotify) { |
1163 if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) { | 1163 if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) { |
1164 m_pFormNotify->AfterCheckedStatusChange(pField); | 1164 m_pFormNotify->AfterCheckedStatusChange(pField); |
1165 } else if (iType == FIELDTYPE_LISTBOX) { | 1165 } else if (iType == FIELDTYPE_LISTBOX) { |
1166 m_pFormNotify->AfterSelectionChange(pField); | 1166 m_pFormNotify->AfterSelectionChange(pField); |
1167 } else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD) { | 1167 } else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD) { |
1168 m_pFormNotify->AfterValueChange(pField); | 1168 m_pFormNotify->AfterValueChange(pField); |
1169 } | 1169 } |
1170 } | 1170 } |
(...skipping 29 matching lines...) Expand all Loading... |
1200 FDF_ImportField(pField, L"", bNotify); | 1200 FDF_ImportField(pField, L"", bNotify); |
1201 } | 1201 } |
1202 if (bNotify && m_pFormNotify) { | 1202 if (bNotify && m_pFormNotify) { |
1203 m_pFormNotify->AfterFormImportData(this); | 1203 m_pFormNotify->AfterFormImportData(this); |
1204 } | 1204 } |
1205 return TRUE; | 1205 return TRUE; |
1206 } | 1206 } |
1207 void CPDF_InterForm::SetFormNotify(const CPDF_FormNotify* pNotify) { | 1207 void CPDF_InterForm::SetFormNotify(const CPDF_FormNotify* pNotify) { |
1208 m_pFormNotify = (CPDF_FormNotify*)pNotify; | 1208 m_pFormNotify = (CPDF_FormNotify*)pNotify; |
1209 } | 1209 } |
OLD | NEW |