Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Side by Side Diff: core/src/fpdfdoc/doc_form.cpp

Issue 1420583003: Revert "Revert "Add type cast definitions for CPDF_Dictionary."" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fpdfdoc/doc_basic.cpp ('k') | core/src/fpdfdoc/doc_formcontrol.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "doc_utils.h" 8 #include "doc_utils.h"
9 9
10 const int nMaxRecursion = 32; 10 const int nMaxRecursion = 32;
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 return pArray->GetCount(); 847 return pArray->GetCount();
848 } 848 }
849 CPDF_FormField* CPDF_InterForm::GetFieldInCalculationOrder(int index) { 849 CPDF_FormField* CPDF_InterForm::GetFieldInCalculationOrder(int index) {
850 if (m_pFormDict == NULL || index < 0) { 850 if (m_pFormDict == NULL || index < 0) {
851 return NULL; 851 return NULL;
852 } 852 }
853 CPDF_Array* pArray = m_pFormDict->GetArray("CO"); 853 CPDF_Array* pArray = m_pFormDict->GetArray("CO");
854 if (pArray == NULL) { 854 if (pArray == NULL) {
855 return NULL; 855 return NULL;
856 } 856 }
857 CPDF_Object* pElement = pArray->GetElementValue(index); 857 if (CPDF_Dictionary* pElement =
858 if (pElement != NULL && pElement->GetType() == PDFOBJ_DICTIONARY) { 858 ToDictionary(pArray->GetElementValue(index))) {
859 return GetFieldByDict((CPDF_Dictionary*)pElement); 859 return GetFieldByDict(pElement);
860 } 860 }
861 return NULL; 861 return NULL;
862 } 862 }
863 int CPDF_InterForm::FindFieldInCalculationOrder(const CPDF_FormField* pField) { 863 int CPDF_InterForm::FindFieldInCalculationOrder(const CPDF_FormField* pField) {
864 if (m_pFormDict == NULL || pField == NULL) { 864 if (m_pFormDict == NULL || pField == NULL) {
865 return -1; 865 return -1;
866 } 866 }
867 CPDF_Array* pArray = m_pFormDict->GetArray("CO"); 867 CPDF_Array* pArray = m_pFormDict->GetArray("CO");
868 if (pArray == NULL) { 868 if (pArray == NULL) {
869 return -1; 869 return -1;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 return; 1042 return;
1043 } 1043 }
1044 int iAnnotCount = pAnnots->GetCount(); 1044 int iAnnotCount = pAnnots->GetCount();
1045 for (int i = 0; i < iAnnotCount; i++) { 1045 for (int i = 0; i < iAnnotCount; i++) {
1046 CPDF_Dictionary* pAnnot = pAnnots->GetDict(i); 1046 CPDF_Dictionary* pAnnot = pAnnots->GetDict(i);
1047 if (pAnnot != NULL && pAnnot->GetString(FX_BSTRC("Subtype")) == "Widget") { 1047 if (pAnnot != NULL && pAnnot->GetString(FX_BSTRC("Subtype")) == "Widget") {
1048 LoadField(pAnnot); 1048 LoadField(pAnnot);
1049 } 1049 }
1050 } 1050 }
1051 } 1051 }
1052 CPDF_FormField* CPDF_InterForm::AddTerminalField( 1052 CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) {
1053 const CPDF_Dictionary* pFieldDict) {
1054 if (!pFieldDict->KeyExist(FX_BSTRC("T"))) { 1053 if (!pFieldDict->KeyExist(FX_BSTRC("T"))) {
1055 return NULL; 1054 return NULL;
1056 } 1055 }
1057 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pFieldDict; 1056 CPDF_Dictionary* pDict = pFieldDict;
1058 CFX_WideString csWName = GetFullName(pDict); 1057 CFX_WideString csWName = GetFullName(pFieldDict);
1059 if (csWName.IsEmpty()) { 1058 if (csWName.IsEmpty()) {
1060 return NULL; 1059 return NULL;
1061 } 1060 }
1062 CPDF_FormField* pField = NULL; 1061 CPDF_FormField* pField = NULL;
1063 pField = m_pFieldTree->GetField(csWName); 1062 pField = m_pFieldTree->GetField(csWName);
1064 if (pField == NULL) { 1063 if (pField == NULL) {
1065 CPDF_Dictionary* pParent = (CPDF_Dictionary*)pFieldDict; 1064 CPDF_Dictionary* pParent = pFieldDict;
1066 if (!pFieldDict->KeyExist(FX_BSTRC("T")) && 1065 if (!pFieldDict->KeyExist(FX_BSTRC("T")) &&
1067 pFieldDict->GetString(FX_BSTRC("Subtype")) == FX_BSTRC("Widget")) { 1066 pFieldDict->GetString(FX_BSTRC("Subtype")) == FX_BSTRC("Widget")) {
1068 pParent = pFieldDict->GetDict(FX_BSTRC("Parent")); 1067 pParent = pFieldDict->GetDict(FX_BSTRC("Parent"));
1069 if (!pParent) { 1068 if (!pParent) {
1070 pParent = (CPDF_Dictionary*)pFieldDict; 1069 pParent = pFieldDict;
1071 } 1070 }
1072 } 1071 }
1073 if (pParent && pParent != pFieldDict && 1072 if (pParent && pParent != pFieldDict &&
1074 !pParent->KeyExist(FX_BSTRC("FT"))) { 1073 !pParent->KeyExist(FX_BSTRC("FT"))) {
1075 if (pFieldDict->KeyExist(FX_BSTRC("FT"))) { 1074 if (pFieldDict->KeyExist(FX_BSTRC("FT"))) {
1076 CPDF_Object* pFTValue = pFieldDict->GetElementValue(FX_BSTRC("FT")); 1075 CPDF_Object* pFTValue = pFieldDict->GetElementValue(FX_BSTRC("FT"));
1077 if (pFTValue) { 1076 if (pFTValue) {
1078 pParent->SetAt(FX_BSTRC("FT"), pFTValue->Clone()); 1077 pParent->SetAt(FX_BSTRC("FT"), pFTValue->Clone());
1079 } 1078 }
1080 } 1079 }
(...skipping 28 matching lines...) Expand all
1109 continue; 1108 continue;
1110 } 1109 }
1111 if (pKid->GetString("Subtype") != "Widget") { 1110 if (pKid->GetString("Subtype") != "Widget") {
1112 continue; 1111 continue;
1113 } 1112 }
1114 AddControl(pField, pKid); 1113 AddControl(pField, pKid);
1115 } 1114 }
1116 } 1115 }
1117 return pField; 1116 return pField;
1118 } 1117 }
1119 CPDF_FormControl* CPDF_InterForm::AddControl( 1118 CPDF_FormControl* CPDF_InterForm::AddControl(const CPDF_FormField* pField,
1120 const CPDF_FormField* pField, 1119 CPDF_Dictionary* pWidgetDict) {
1121 const CPDF_Dictionary* pWidgetDict) {
1122 const auto it = m_ControlMap.find(pWidgetDict); 1120 const auto it = m_ControlMap.find(pWidgetDict);
1123 if (it != m_ControlMap.end()) 1121 if (it != m_ControlMap.end())
1124 return it->second; 1122 return it->second;
1125 1123
1126 CPDF_FormControl* pControl = new CPDF_FormControl( 1124 CPDF_FormControl* pControl =
1127 (CPDF_FormField*)pField, (CPDF_Dictionary*)pWidgetDict); 1125 new CPDF_FormControl((CPDF_FormField*)pField, pWidgetDict);
1128 m_ControlMap[pWidgetDict] = pControl; 1126 m_ControlMap[pWidgetDict] = pControl;
1129 ((CPDF_FormField*)pField)->m_ControlList.Add(pControl); 1127 ((CPDF_FormField*)pField)->m_ControlList.Add(pControl);
1130 return pControl; 1128 return pControl;
1131 } 1129 }
1132 CPDF_FormField* CPDF_InterForm::CheckRequiredFields( 1130 CPDF_FormField* CPDF_InterForm::CheckRequiredFields(
1133 const CFX_PtrArray* fields, 1131 const CFX_PtrArray* fields,
1134 FX_BOOL bIncludeOrExclude) const { 1132 FX_BOOL bIncludeOrExclude) const {
1135 int nCount = m_pFieldTree->m_Root.CountFields(); 1133 int nCount = m_pFieldTree->m_Root.CountFields();
1136 for (int i = 0; i < nCount; i++) { 1134 for (int i = 0; i < nCount; i++) {
1137 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); 1135 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i);
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 FDF_ImportField(pField, L"", bNotify); 1371 FDF_ImportField(pField, L"", bNotify);
1374 } 1372 }
1375 if (bNotify && m_pFormNotify != NULL) { 1373 if (bNotify && m_pFormNotify != NULL) {
1376 m_pFormNotify->AfterFormImportData(this); 1374 m_pFormNotify->AfterFormImportData(this);
1377 } 1375 }
1378 return TRUE; 1376 return TRUE;
1379 } 1377 }
1380 void CPDF_InterForm::SetFormNotify(const CPDF_FormNotify* pNotify) { 1378 void CPDF_InterForm::SetFormNotify(const CPDF_FormNotify* pNotify) {
1381 m_pFormNotify = (CPDF_FormNotify*)pNotify; 1379 m_pFormNotify = (CPDF_FormNotify*)pNotify;
1382 } 1380 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_basic.cpp ('k') | core/src/fpdfdoc/doc_formcontrol.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698