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

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

Issue 1832173003: Remove FX_DWORD from core/ and delete definition (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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/fpdfdoc/doc_bookmark.cpp ('k') | core/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 <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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 while (iPos < iLength && csNewFieldName[iPos] != L'.') { 563 while (iPos < iLength && csNewFieldName[iPos] != L'.') {
564 csSub += csNewFieldName[iPos++]; 564 csSub += csNewFieldName[iPos++];
565 } 565 }
566 for (int i = csSub.GetLength() - 1; i > -1; i--) { 566 for (int i = csSub.GetLength() - 1; i > -1; i--) {
567 if (csSub[i] == L' ' || csSub[i] == L'.') { 567 if (csSub[i] == L' ' || csSub[i] == L'.') {
568 csSub.SetAt(i, L'\0'); 568 csSub.SetAt(i, L'\0');
569 } else { 569 } else {
570 break; 570 break;
571 } 571 }
572 } 572 }
573 FX_DWORD dwCount = m_pFieldTree->m_Root.CountFields(); 573 uint32_t dwCount = m_pFieldTree->m_Root.CountFields();
574 for (FX_DWORD m = 0; m < dwCount; m++) { 574 for (uint32_t m = 0; m < dwCount; m++) {
575 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(m); 575 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(m);
576 if (!pField) { 576 if (!pField) {
577 continue; 577 continue;
578 } 578 }
579 if (pField == pExcludedField) { 579 if (pField == pExcludedField) {
580 if (pExcludedControl) { 580 if (pExcludedControl) {
581 if (pField->CountControls() < 2) { 581 if (pField->CountControls() < 2) {
582 continue; 582 continue;
583 } 583 }
584 } else { 584 } else {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 i++; 662 i++;
663 } 663 }
664 if (i == name1.GetLength()) { 664 if (i == name1.GetLength()) {
665 return 2; 665 return 2;
666 } 666 }
667 if (i == name2.GetLength()) { 667 if (i == name2.GetLength()) {
668 return 3; 668 return 3;
669 } 669 }
670 return 0; 670 return 0;
671 } 671 }
672 FX_DWORD CPDF_InterForm::CountFields(const CFX_WideString& csFieldName) { 672 uint32_t CPDF_InterForm::CountFields(const CFX_WideString& csFieldName) {
673 if (csFieldName.IsEmpty()) { 673 if (csFieldName.IsEmpty()) {
674 return (FX_DWORD)m_pFieldTree->m_Root.CountFields(); 674 return (uint32_t)m_pFieldTree->m_Root.CountFields();
675 } 675 }
676 CFieldTree::_Node* pNode = m_pFieldTree->FindNode(csFieldName); 676 CFieldTree::_Node* pNode = m_pFieldTree->FindNode(csFieldName);
677 return pNode ? pNode->CountFields() : 0; 677 return pNode ? pNode->CountFields() : 0;
678 } 678 }
679 CPDF_FormField* CPDF_InterForm::GetField(FX_DWORD index, 679 CPDF_FormField* CPDF_InterForm::GetField(uint32_t index,
680 const CFX_WideString& csFieldName) { 680 const CFX_WideString& csFieldName) {
681 if (csFieldName == L"") { 681 if (csFieldName == L"") {
682 return m_pFieldTree->m_Root.GetField(index); 682 return m_pFieldTree->m_Root.GetField(index);
683 } 683 }
684 CFieldTree::_Node* pNode = m_pFieldTree->FindNode(csFieldName); 684 CFieldTree::_Node* pNode = m_pFieldTree->FindNode(csFieldName);
685 return pNode ? pNode->GetField(index) : nullptr; 685 return pNode ? pNode->GetField(index) : nullptr;
686 } 686 }
687 687
688 CPDF_FormField* CPDF_InterForm::GetFieldByDict( 688 CPDF_FormField* CPDF_InterForm::GetFieldByDict(
689 CPDF_Dictionary* pFieldDict) const { 689 CPDF_Dictionary* pFieldDict) const {
690 if (!pFieldDict) { 690 if (!pFieldDict) {
691 return NULL; 691 return NULL;
692 } 692 }
693 CFX_WideString csWName = GetFullName(pFieldDict); 693 CFX_WideString csWName = GetFullName(pFieldDict);
694 return m_pFieldTree->GetField(csWName); 694 return m_pFieldTree->GetField(csWName);
695 } 695 }
696 696
697 CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage, 697 CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage,
698 FX_FLOAT pdf_x, 698 FX_FLOAT pdf_x,
699 FX_FLOAT pdf_y, 699 FX_FLOAT pdf_y,
700 int* z_order) const { 700 int* z_order) const {
701 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArrayBy("Annots"); 701 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArrayBy("Annots");
702 if (!pAnnotList) 702 if (!pAnnotList)
703 return nullptr; 703 return nullptr;
704 704
705 for (FX_DWORD i = pAnnotList->GetCount(); i > 0; --i) { 705 for (uint32_t i = pAnnotList->GetCount(); i > 0; --i) {
706 FX_DWORD annot_index = i - 1; 706 uint32_t annot_index = i - 1;
707 CPDF_Dictionary* pAnnot = pAnnotList->GetDictAt(annot_index); 707 CPDF_Dictionary* pAnnot = pAnnotList->GetDictAt(annot_index);
708 if (!pAnnot) 708 if (!pAnnot)
709 continue; 709 continue;
710 710
711 const auto it = m_ControlMap.find(pAnnot); 711 const auto it = m_ControlMap.find(pAnnot);
712 if (it == m_ControlMap.end()) 712 if (it == m_ControlMap.end())
713 continue; 713 continue;
714 714
715 CPDF_FormControl* pControl = it->second; 715 CPDF_FormControl* pControl = it->second;
716 CFX_FloatRect rect = pControl->GetRect(); 716 CFX_FloatRect rect = pControl->GetRect();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 (FX_DWORD 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->GetElementValue(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 FX_DWORD 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(FX_DWORD index, 783 CPDF_Font* CPDF_InterForm::GetFormFont(uint32_t index,
784 CFX_ByteString& csNameTag) { 784 CFX_ByteString& csNameTag) {
785 return GetInterFormFont(m_pFormDict, m_pDocument, index, csNameTag); 785 return GetInterFormFont(m_pFormDict, m_pDocument, index, csNameTag);
786 } 786 }
787 CPDF_Font* CPDF_InterForm::GetFormFont(CFX_ByteString csNameTag) { 787 CPDF_Font* CPDF_InterForm::GetFormFont(CFX_ByteString csNameTag) {
788 return GetInterFormFont(m_pFormDict, m_pDocument, csNameTag); 788 return GetInterFormFont(m_pFormDict, m_pDocument, csNameTag);
789 } 789 }
790 CPDF_Font* CPDF_InterForm::GetFormFont(CFX_ByteString csFontName, 790 CPDF_Font* CPDF_InterForm::GetFormFont(CFX_ByteString csFontName,
791 CFX_ByteString& csNameTag) { 791 CFX_ByteString& csNameTag) {
792 return GetInterFormFont(m_pFormDict, m_pDocument, csFontName, csNameTag); 792 return GetInterFormFont(m_pFormDict, m_pDocument, csFontName, csNameTag);
793 } 793 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 return true; 881 return true;
882 } 882 }
883 883
884 void CPDF_InterForm::LoadField(CPDF_Dictionary* pFieldDict, int nLevel) { 884 void CPDF_InterForm::LoadField(CPDF_Dictionary* pFieldDict, int nLevel) {
885 if (nLevel > nMaxRecursion) { 885 if (nLevel > nMaxRecursion) {
886 return; 886 return;
887 } 887 }
888 if (!pFieldDict) { 888 if (!pFieldDict) {
889 return; 889 return;
890 } 890 }
891 FX_DWORD dwParentObjNum = pFieldDict->GetObjNum(); 891 uint32_t dwParentObjNum = pFieldDict->GetObjNum();
892 CPDF_Array* pKids = pFieldDict->GetArrayBy("Kids"); 892 CPDF_Array* pKids = pFieldDict->GetArrayBy("Kids");
893 if (!pKids) { 893 if (!pKids) {
894 AddTerminalField(pFieldDict); 894 AddTerminalField(pFieldDict);
895 return; 895 return;
896 } 896 }
897 CPDF_Dictionary* pFirstKid = pKids->GetDictAt(0); 897 CPDF_Dictionary* pFirstKid = pKids->GetDictAt(0);
898 if (!pFirstKid) { 898 if (!pFirstKid) {
899 return; 899 return;
900 } 900 }
901 if (pFirstKid->KeyExist("T") || pFirstKid->KeyExist("Kids")) { 901 if (pFirstKid->KeyExist("T") || pFirstKid->KeyExist("Kids")) {
902 for (FX_DWORD i = 0; i < pKids->GetCount(); i++) { 902 for (uint32_t i = 0; i < pKids->GetCount(); i++) {
903 CPDF_Dictionary* pChildDict = pKids->GetDictAt(i); 903 CPDF_Dictionary* pChildDict = pKids->GetDictAt(i);
904 if (pChildDict) { 904 if (pChildDict) {
905 if (pChildDict->GetObjNum() != dwParentObjNum) { 905 if (pChildDict->GetObjNum() != dwParentObjNum) {
906 LoadField(pChildDict, nLevel + 1); 906 LoadField(pChildDict, nLevel + 1);
907 } 907 }
908 } 908 }
909 } 909 }
910 } else { 910 } else {
911 AddTerminalField(pFieldDict); 911 AddTerminalField(pFieldDict);
912 } 912 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
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");
980 if (!pKids) { 980 if (!pKids) {
981 if (pFieldDict->GetStringBy("Subtype") == "Widget") { 981 if (pFieldDict->GetStringBy("Subtype") == "Widget") {
982 AddControl(pField, pFieldDict); 982 AddControl(pField, pFieldDict);
983 } 983 }
984 } else { 984 } else {
985 for (FX_DWORD i = 0; i < pKids->GetCount(); i++) { 985 for (uint32_t i = 0; i < pKids->GetCount(); i++) {
986 CPDF_Dictionary* pKid = pKids->GetDictAt(i); 986 CPDF_Dictionary* pKid = pKids->GetDictAt(i);
987 if (!pKid) { 987 if (!pKid) {
988 continue; 988 continue;
989 } 989 }
990 if (pKid->GetStringBy("Subtype") != "Widget") { 990 if (pKid->GetStringBy("Subtype") != "Widget") {
991 continue; 991 continue;
992 } 992 }
993 AddControl(pField, pKid); 993 AddControl(pField, pKid);
994 } 994 }
995 } 995 }
(...skipping 19 matching lines...) Expand all
1015 for (int i = 0; i < nCount; ++i) { 1015 for (int i = 0; i < nCount; ++i) {
1016 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); 1016 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i);
1017 if (!pField) 1017 if (!pField)
1018 continue; 1018 continue;
1019 1019
1020 int32_t iType = pField->GetType(); 1020 int32_t iType = pField->GetType();
1021 if (iType == CPDF_FormField::PushButton || 1021 if (iType == CPDF_FormField::PushButton ||
1022 iType == CPDF_FormField::CheckBox || iType == CPDF_FormField::ListBox) { 1022 iType == CPDF_FormField::CheckBox || iType == CPDF_FormField::ListBox) {
1023 continue; 1023 continue;
1024 } 1024 }
1025 FX_DWORD dwFlags = pField->GetFieldFlags(); 1025 uint32_t dwFlags = pField->GetFieldFlags();
1026 // TODO(thestig): Look up these magic numbers and add constants for them. 1026 // TODO(thestig): Look up these magic numbers and add constants for them.
1027 if (dwFlags & 0x04) 1027 if (dwFlags & 0x04)
1028 continue; 1028 continue;
1029 1029
1030 bool bFind = true; 1030 bool bFind = true;
1031 if (fields) 1031 if (fields)
1032 bFind = pdfium::ContainsValue(*fields, pField); 1032 bFind = pdfium::ContainsValue(*fields, pField);
1033 if (bIncludeOrExclude == bFind) { 1033 if (bIncludeOrExclude == bFind) {
1034 CPDF_Dictionary* pFieldDict = pField->m_pDict; 1034 CPDF_Dictionary* pFieldDict = pField->m_pDict;
1035 if ((dwFlags & 0x02) != 0 && pFieldDict->GetStringBy("V").IsEmpty()) { 1035 if ((dwFlags & 0x02) != 0 && pFieldDict->GetStringBy("V").IsEmpty()) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 } 1071 }
1072 } 1072 }
1073 CPDF_Array* pFields = new CPDF_Array; 1073 CPDF_Array* pFields = new CPDF_Array;
1074 pMainDict->SetAt("Fields", pFields); 1074 pMainDict->SetAt("Fields", pFields);
1075 int nCount = m_pFieldTree->m_Root.CountFields(); 1075 int nCount = m_pFieldTree->m_Root.CountFields();
1076 for (int i = 0; i < nCount; i++) { 1076 for (int i = 0; i < nCount; i++) {
1077 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); 1077 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i);
1078 if (!pField || pField->GetType() == CPDF_FormField::PushButton) { 1078 if (!pField || pField->GetType() == CPDF_FormField::PushButton) {
1079 continue; 1079 continue;
1080 } 1080 }
1081 FX_DWORD dwFlags = pField->GetFieldFlags(); 1081 uint32_t dwFlags = pField->GetFieldFlags();
1082 if (dwFlags & 0x04) 1082 if (dwFlags & 0x04)
1083 continue; 1083 continue;
1084 1084
1085 if (bIncludeOrExclude == pdfium::ContainsValue(fields, pField)) { 1085 if (bIncludeOrExclude == pdfium::ContainsValue(fields, pField)) {
1086 if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetStringBy("V").IsEmpty()) 1086 if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetStringBy("V").IsEmpty())
1087 continue; 1087 continue;
1088 1088
1089 CFX_WideString fullname = GetFullName(pField->GetFieldDict()); 1089 CFX_WideString fullname = GetFullName(pField->GetFieldDict());
1090 CPDF_Dictionary* pFieldDict = new CPDF_Dictionary; 1090 CPDF_Dictionary* pFieldDict = new CPDF_Dictionary;
1091 pFieldDict->SetAt("T", new CPDF_String(fullname)); 1091 pFieldDict->SetAt("T", new CPDF_String(fullname));
(...skipping 21 matching lines...) Expand all
1113 const CFX_WideString& parent_name, 1113 const CFX_WideString& parent_name,
1114 FX_BOOL bNotify, 1114 FX_BOOL bNotify,
1115 int nLevel) { 1115 int nLevel) {
1116 CFX_WideString name; 1116 CFX_WideString name;
1117 if (!parent_name.IsEmpty()) { 1117 if (!parent_name.IsEmpty()) {
1118 name = parent_name + L"."; 1118 name = parent_name + L".";
1119 } 1119 }
1120 name += pFieldDict->GetUnicodeTextBy("T"); 1120 name += pFieldDict->GetUnicodeTextBy("T");
1121 CPDF_Array* pKids = pFieldDict->GetArrayBy("Kids"); 1121 CPDF_Array* pKids = pFieldDict->GetArrayBy("Kids");
1122 if (pKids) { 1122 if (pKids) {
1123 for (FX_DWORD i = 0; i < pKids->GetCount(); i++) { 1123 for (uint32_t i = 0; i < pKids->GetCount(); i++) {
1124 CPDF_Dictionary* pKid = pKids->GetDictAt(i); 1124 CPDF_Dictionary* pKid = pKids->GetDictAt(i);
1125 if (!pKid) { 1125 if (!pKid) {
1126 continue; 1126 continue;
1127 } 1127 }
1128 if (nLevel <= nMaxRecursion) { 1128 if (nLevel <= nMaxRecursion) {
1129 FDF_ImportField(pKid, name, bNotify, nLevel + 1); 1129 FDF_ImportField(pKid, name, bNotify, nLevel + 1);
1130 } 1130 }
1131 } 1131 }
1132 return; 1132 return;
1133 } 1133 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 if (!pFields) { 1185 if (!pFields) {
1186 return FALSE; 1186 return FALSE;
1187 } 1187 }
1188 m_bsEncoding = pMainDict->GetStringBy("Encoding"); 1188 m_bsEncoding = pMainDict->GetStringBy("Encoding");
1189 if (bNotify && m_pFormNotify) { 1189 if (bNotify && m_pFormNotify) {
1190 int iRet = m_pFormNotify->BeforeFormImportData(this); 1190 int iRet = m_pFormNotify->BeforeFormImportData(this);
1191 if (iRet < 0) { 1191 if (iRet < 0) {
1192 return FALSE; 1192 return FALSE;
1193 } 1193 }
1194 } 1194 }
1195 for (FX_DWORD i = 0; i < pFields->GetCount(); i++) { 1195 for (uint32_t i = 0; i < pFields->GetCount(); i++) {
1196 CPDF_Dictionary* pField = pFields->GetDictAt(i); 1196 CPDF_Dictionary* pField = pFields->GetDictAt(i);
1197 if (!pField) { 1197 if (!pField) {
1198 continue; 1198 continue;
1199 } 1199 }
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 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/doc_bookmark.cpp ('k') | core/fpdfdoc/doc_formcontrol.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698