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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: core/src/fpdfdoc/doc_formcontrol.cpp
diff --git a/core/src/fpdfdoc/doc_formcontrol.cpp b/core/src/fpdfdoc/doc_formcontrol.cpp
index c5f47d20cb486160ea81d5e165c7c21ec34276ec..35329f9e059023f27287b7542fe77900850e2fa1 100644
--- a/core/src/fpdfdoc/doc_formcontrol.cpp
+++ b/core/src/fpdfdoc/doc_formcontrol.cpp
@@ -85,15 +85,13 @@ CFX_ByteString CPDF_FormControl::GetCheckedAPState() {
CFX_ByteString csOn = GetOnStateName();
if (GetType() == CPDF_FormField::RadioButton ||
GetType() == CPDF_FormField::CheckBox) {
- CPDF_Object* pOpt = FPDF_GetFieldAttr(m_pField->m_pDict, "Opt");
- if (pOpt != NULL && pOpt->GetType() == PDFOBJ_ARRAY) {
+ if (ToArray(FPDF_GetFieldAttr(m_pField->m_pDict, "Opt"))) {
int iIndex = m_pField->GetControlIndex(this);
csOn.Format("%d", iIndex);
}
}
- if (csOn.IsEmpty()) {
+ if (csOn.IsEmpty())
csOn = "Yes";
- }
return csOn;
}
CFX_WideString CPDF_FormControl::GetExportValue() {
@@ -102,10 +100,10 @@ CFX_WideString CPDF_FormControl::GetExportValue() {
CFX_ByteString csOn = GetOnStateName();
if (GetType() == CPDF_FormField::RadioButton ||
GetType() == CPDF_FormField::CheckBox) {
- CPDF_Object* pOpt = FPDF_GetFieldAttr(m_pField->m_pDict, "Opt");
- if (pOpt != NULL && pOpt->GetType() == PDFOBJ_ARRAY) {
+ if (CPDF_Array* pArray =
+ ToArray(FPDF_GetFieldAttr(m_pField->m_pDict, "Opt"))) {
int iIndex = m_pField->GetControlIndex(this);
- csOn = ((CPDF_Array*)pOpt)->GetString(iIndex);
+ csOn = pArray->GetString(iIndex);
}
}
if (csOn.IsEmpty()) {

Powered by Google App Engine
This is Rietveld 408576698