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

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

Issue 1648233002: Merge to XFA: Member function name refactoring (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: more xfa changes Created 4 years, 10 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_formcontrol.cpp ('k') | core/src/fpdfdoc/doc_link.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 "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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 if (CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "MaxLen")) 401 if (CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "MaxLen"))
402 return pObj->GetInteger(); 402 return pObj->GetInteger();
403 403
404 for (int i = 0; i < m_ControlList.GetSize(); i++) { 404 for (int i = 0; i < m_ControlList.GetSize(); i++) {
405 CPDF_FormControl* pControl = m_ControlList.GetAt(i); 405 CPDF_FormControl* pControl = m_ControlList.GetAt(i);
406 if (!pControl) 406 if (!pControl)
407 continue; 407 continue;
408 408
409 CPDF_Dictionary* pWidgetDict = pControl->m_pWidgetDict; 409 CPDF_Dictionary* pWidgetDict = pControl->m_pWidgetDict;
410 if (pWidgetDict->KeyExist("MaxLen")) 410 if (pWidgetDict->KeyExist("MaxLen"))
411 return pWidgetDict->GetInteger("MaxLen"); 411 return pWidgetDict->GetIntegerBy("MaxLen");
412 } 412 }
413 return 0; 413 return 0;
414 } 414 }
415 int CPDF_FormField::CountSelectedItems() { 415 int CPDF_FormField::CountSelectedItems() {
416 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); 416 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
417 if (!pValue) { 417 if (!pValue) {
418 pValue = FPDF_GetFieldAttr(m_pDict, "I"); 418 pValue = FPDF_GetFieldAttr(m_pDict, "I");
419 if (!pValue) 419 if (!pValue)
420 return 0; 420 return 0;
421 } 421 }
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I"); 941 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I");
942 if (!pObj) { 942 if (!pObj) {
943 return -1; 943 return -1;
944 } 944 }
945 CPDF_Array* pArray = pObj->GetArray(); 945 CPDF_Array* pArray = pObj->GetArray();
946 if (!pArray) { 946 if (!pArray) {
947 return -1; 947 return -1;
948 } 948 }
949 int iCount = (int)pArray->GetCount(); 949 int iCount = (int)pArray->GetCount();
950 if (iCount > 0 && index < iCount) { 950 if (iCount > 0 && index < iCount) {
951 return pArray->GetInteger(index); 951 return pArray->GetIntegerAt(index);
952 } 952 }
953 return -1; 953 return -1;
954 } 954 }
955 FX_BOOL CPDF_FormField::IsOptionSelected(int iOptIndex) { 955 FX_BOOL CPDF_FormField::IsOptionSelected(int iOptIndex) {
956 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I"); 956 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I");
957 if (!pObj) { 957 if (!pObj) {
958 return FALSE; 958 return FALSE;
959 } 959 }
960 CPDF_Array* pArray = pObj->GetArray(); 960 CPDF_Array* pArray = pObj->GetArray();
961 if (!pArray) { 961 if (!pArray) {
962 return FALSE; 962 return FALSE;
963 } 963 }
964 int iCount = (int)pArray->GetCount(); 964 int iCount = (int)pArray->GetCount();
965 for (int i = 0; i < iCount; i++) { 965 for (int i = 0; i < iCount; i++) {
966 if (pArray->GetInteger(i) == iOptIndex) { 966 if (pArray->GetIntegerAt(i) == iOptIndex) {
967 return TRUE; 967 return TRUE;
968 } 968 }
969 } 969 }
970 return FALSE; 970 return FALSE;
971 } 971 }
972 FX_BOOL CPDF_FormField::SelectOption(int iOptIndex, 972 FX_BOOL CPDF_FormField::SelectOption(int iOptIndex,
973 FX_BOOL bSelected, 973 FX_BOOL bSelected,
974 FX_BOOL bNotify) { 974 FX_BOOL bNotify) {
975 CPDF_Array* pArray = m_pDict->GetArray("I"); 975 CPDF_Array* pArray = m_pDict->GetArrayBy("I");
976 if (!pArray) { 976 if (!pArray) {
977 if (!bSelected) { 977 if (!bSelected) {
978 return TRUE; 978 return TRUE;
979 } 979 }
980 pArray = new CPDF_Array; 980 pArray = new CPDF_Array;
981 m_pDict->SetAt("I", pArray); 981 m_pDict->SetAt("I", pArray);
982 } 982 }
983 FX_BOOL bReturn = FALSE; 983 FX_BOOL bReturn = FALSE;
984 for (int i = 0; i < (int)pArray->GetCount(); i++) { 984 for (int i = 0; i < (int)pArray->GetCount(); i++) {
985 int iFind = pArray->GetInteger(i); 985 int iFind = pArray->GetIntegerAt(i);
986 if (iFind == iOptIndex) { 986 if (iFind == iOptIndex) {
987 if (bSelected) { 987 if (bSelected) {
988 return TRUE; 988 return TRUE;
989 } 989 }
990 if (bNotify && m_pForm->m_pFormNotify) { 990 if (bNotify && m_pForm->m_pFormNotify) {
991 int iRet = 0; 991 int iRet = 0;
992 CFX_WideString csValue = GetOptionLabel(iOptIndex); 992 CFX_WideString csValue = GetOptionLabel(iOptIndex);
993 if (GetType() == ListBox) { 993 if (GetType() == ListBox) {
994 iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csValue); 994 iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csValue);
995 } 995 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 } 1074 }
1075 m_pForm->m_bUpdated = TRUE; 1075 m_pForm->m_bUpdated = TRUE;
1076 return TRUE; 1076 return TRUE;
1077 } 1077 }
1078 void CPDF_FormField::LoadDA() { 1078 void CPDF_FormField::LoadDA() {
1079 CFX_ByteString DA; 1079 CFX_ByteString DA;
1080 if (CPDF_Object* pObj_t = FPDF_GetFieldAttr(m_pDict, "DA")) { 1080 if (CPDF_Object* pObj_t = FPDF_GetFieldAttr(m_pDict, "DA")) {
1081 DA = pObj_t->GetString(); 1081 DA = pObj_t->GetString();
1082 } 1082 }
1083 if (DA.IsEmpty() && m_pForm->m_pFormDict) { 1083 if (DA.IsEmpty() && m_pForm->m_pFormDict) {
1084 DA = m_pForm->m_pFormDict->GetString("DA"); 1084 DA = m_pForm->m_pFormDict->GetStringBy("DA");
1085 } 1085 }
1086 if (DA.IsEmpty()) { 1086 if (DA.IsEmpty()) {
1087 return; 1087 return;
1088 } 1088 }
1089 CPDF_SimpleParser syntax(DA); 1089 CPDF_SimpleParser syntax(DA);
1090 syntax.FindTagParam("Tf", 2); 1090 syntax.FindTagParam("Tf", 2);
1091 CFX_ByteString font_name = syntax.GetWord(); 1091 CFX_ByteString font_name = syntax.GetWord();
1092 CPDF_Dictionary* pFontDict = NULL; 1092 CPDF_Dictionary* pFontDict = NULL;
1093 if (m_pForm->m_pFormDict && m_pForm->m_pFormDict->GetDict("DR") && 1093 if (m_pForm->m_pFormDict && m_pForm->m_pFormDict->GetDictBy("DR") &&
1094 m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")) 1094 m_pForm->m_pFormDict->GetDictBy("DR")->GetDictBy("Font"))
1095 pFontDict = m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")->GetDict( 1095 pFontDict = m_pForm->m_pFormDict->GetDictBy("DR")
1096 font_name); 1096 ->GetDictBy("Font")
1097 ->GetDictBy(font_name);
1097 1098
1098 if (!pFontDict) { 1099 if (!pFontDict) {
1099 return; 1100 return;
1100 } 1101 }
1101 m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict); 1102 m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict);
1102 m_FontSize = FX_atof(syntax.GetWord()); 1103 m_FontSize = FX_atof(syntax.GetWord());
1103 } 1104 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_formcontrol.cpp ('k') | core/src/fpdfdoc/doc_link.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698