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

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

Issue 1417893003: Add type cast definitions for CPDF_Array. (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
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 CPDF_Object* pOpt = FPDF_GetFieldAttr(m_pField->m_pDict, "Opt");
89 if (pOpt != NULL && pOpt->GetType() == PDFOBJ_ARRAY) { 89 if (pOpt && pOpt->IsArray()) {
90 int iIndex = m_pField->GetControlIndex(this); 90 int iIndex = m_pField->GetControlIndex(this);
91 csOn.Format("%d", iIndex); 91 csOn.Format("%d", iIndex);
92 } 92 }
93 } 93 }
94 if (csOn.IsEmpty()) { 94 if (csOn.IsEmpty())
95 csOn = "Yes"; 95 csOn = "Yes";
96 }
97 return csOn; 96 return csOn;
98 } 97 }
99 CFX_WideString CPDF_FormControl::GetExportValue() { 98 CFX_WideString CPDF_FormControl::GetExportValue() {
100 ASSERT(GetType() == CPDF_FormField::CheckBox || 99 ASSERT(GetType() == CPDF_FormField::CheckBox ||
101 GetType() == CPDF_FormField::RadioButton); 100 GetType() == CPDF_FormField::RadioButton);
102 CFX_ByteString csOn = GetOnStateName(); 101 CFX_ByteString csOn = GetOnStateName();
103 if (GetType() == CPDF_FormField::RadioButton || 102 if (GetType() == CPDF_FormField::RadioButton ||
104 GetType() == CPDF_FormField::CheckBox) { 103 GetType() == CPDF_FormField::CheckBox) {
105 CPDF_Object* pOpt = FPDF_GetFieldAttr(m_pField->m_pDict, "Opt"); 104 CPDF_Object* pOpt = FPDF_GetFieldAttr(m_pField->m_pDict, "Opt");
106 if (pOpt != NULL && pOpt->GetType() == PDFOBJ_ARRAY) { 105 if (CPDF_Array* pArray = ToArray(pOpt)) {
107 int iIndex = m_pField->GetControlIndex(this); 106 int iIndex = m_pField->GetControlIndex(this);
108 csOn = ((CPDF_Array*)pOpt)->GetString(iIndex); 107 csOn = pArray->GetString(iIndex);
109 } 108 }
110 } 109 }
111 if (csOn.IsEmpty()) { 110 if (csOn.IsEmpty()) {
112 csOn = "Yes"; 111 csOn = "Yes";
113 } 112 }
114 CFX_WideString csWOn = PDF_DecodeText(csOn); 113 CFX_WideString csWOn = PDF_DecodeText(csOn);
115 return csWOn; 114 return csWOn;
116 } 115 }
117 FX_BOOL CPDF_FormControl::IsChecked() { 116 FX_BOOL CPDF_FormControl::IsChecked() {
118 ASSERT(GetType() == CPDF_FormField::CheckBox || 117 ASSERT(GetType() == CPDF_FormField::CheckBox ||
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 return NULL; 438 return NULL;
440 } 439 }
441 return m_pDict->GetDict(FX_BSTRC("IF")); 440 return m_pDict->GetDict(FX_BSTRC("IF"));
442 } 441 }
443 int CPDF_ApSettings::GetTextPosition() { 442 int CPDF_ApSettings::GetTextPosition() {
444 if (m_pDict == NULL) { 443 if (m_pDict == NULL) {
445 return TEXTPOS_CAPTION; 444 return TEXTPOS_CAPTION;
446 } 445 }
447 return m_pDict->GetInteger(FX_BSTRC("TP"), TEXTPOS_CAPTION); 446 return m_pDict->GetInteger(FX_BSTRC("TP"), TEXTPOS_CAPTION);
448 } 447 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698