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

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

Issue 1419643005: Merge to XFA: Add type cast definitions for CPDF_Array. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
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
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 CPDF_FormControl::CPDF_FormControl(CPDF_FormField* pField, 8 CPDF_FormControl::CPDF_FormControl(CPDF_FormField* pField,
9 CPDF_Dictionary* pWidgetDict) { 9 CPDF_Dictionary* pWidgetDict) {
10 m_pField = pField; 10 m_pField = pField;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 } 79 }
80 } 80 }
81 } 81 }
82 CFX_ByteString CPDF_FormControl::GetCheckedAPState() { 82 CFX_ByteString CPDF_FormControl::GetCheckedAPState() {
83 ASSERT(GetType() == CPDF_FormField::CheckBox || 83 ASSERT(GetType() == CPDF_FormField::CheckBox ||
84 GetType() == CPDF_FormField::RadioButton); 84 GetType() == CPDF_FormField::RadioButton);
85 CFX_ByteString csOn = GetOnStateName(); 85 CFX_ByteString csOn = GetOnStateName();
86 if (GetType() == CPDF_FormField::RadioButton || 86 if (GetType() == CPDF_FormField::RadioButton ||
87 GetType() == CPDF_FormField::CheckBox) { 87 GetType() == CPDF_FormField::CheckBox) {
88 CPDF_Object* pOpt = FPDF_GetFieldAttr(m_pField->m_pDict, "Opt"); 88 if (ToArray(FPDF_GetFieldAttr(m_pField->m_pDict, "Opt"))) {
89 if (pOpt != NULL && pOpt->GetType() == PDFOBJ_ARRAY) {
90 int iIndex = m_pField->GetControlIndex(this); 89 int iIndex = m_pField->GetControlIndex(this);
91 csOn.Format("%d", iIndex); 90 csOn.Format("%d", iIndex);
92 } 91 }
93 } 92 }
94 if (csOn.IsEmpty()) { 93 if (csOn.IsEmpty())
95 csOn = "Yes"; 94 csOn = "Yes";
96 }
97 return csOn; 95 return csOn;
98 } 96 }
99 CFX_WideString CPDF_FormControl::GetExportValue() { 97 CFX_WideString CPDF_FormControl::GetExportValue() {
100 ASSERT(GetType() == CPDF_FormField::CheckBox || 98 ASSERT(GetType() == CPDF_FormField::CheckBox ||
101 GetType() == CPDF_FormField::RadioButton); 99 GetType() == CPDF_FormField::RadioButton);
102 CFX_ByteString csOn = GetOnStateName(); 100 CFX_ByteString csOn = GetOnStateName();
103 if (GetType() == CPDF_FormField::RadioButton || 101 if (GetType() == CPDF_FormField::RadioButton ||
104 GetType() == CPDF_FormField::CheckBox) { 102 GetType() == CPDF_FormField::CheckBox) {
105 CPDF_Object* pOpt = FPDF_GetFieldAttr(m_pField->m_pDict, "Opt"); 103 if (CPDF_Array* pArray =
106 if (pOpt != NULL && pOpt->GetType() == PDFOBJ_ARRAY) { 104 ToArray(FPDF_GetFieldAttr(m_pField->m_pDict, "Opt"))) {
107 int iIndex = m_pField->GetControlIndex(this); 105 int iIndex = m_pField->GetControlIndex(this);
108 csOn = ((CPDF_Array*)pOpt)->GetString(iIndex); 106 csOn = pArray->GetString(iIndex);
109 } 107 }
110 } 108 }
111 if (csOn.IsEmpty()) { 109 if (csOn.IsEmpty()) {
112 csOn = "Yes"; 110 csOn = "Yes";
113 } 111 }
114 CFX_WideString csWOn = PDF_DecodeText(csOn); 112 CFX_WideString csWOn = PDF_DecodeText(csOn);
115 return csWOn; 113 return csWOn;
116 } 114 }
117 FX_BOOL CPDF_FormControl::IsChecked() { 115 FX_BOOL CPDF_FormControl::IsChecked() {
118 ASSERT(GetType() == CPDF_FormField::CheckBox || 116 ASSERT(GetType() == CPDF_FormField::CheckBox ||
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 return NULL; 437 return NULL;
440 } 438 }
441 return m_pDict->GetDict(FX_BSTRC("IF")); 439 return m_pDict->GetDict(FX_BSTRC("IF"));
442 } 440 }
443 int CPDF_ApSettings::GetTextPosition() { 441 int CPDF_ApSettings::GetTextPosition() {
444 if (m_pDict == NULL) { 442 if (m_pDict == NULL) {
445 return TEXTPOS_CAPTION; 443 return TEXTPOS_CAPTION;
446 } 444 }
447 return m_pDict->GetInteger(FX_BSTRC("TP"), TEXTPOS_CAPTION); 445 return m_pDict->GetInteger(FX_BSTRC("TP"), TEXTPOS_CAPTION);
448 } 446 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698