diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2015-10-22 15:02:06 -0400 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2015-10-22 15:02:06 -0400 |
commit | 2b11dc1220746d2f6f97a940fc9e4235c8ed4975 (patch) | |
tree | e25b2ba13112f4ead789260ee57fe5b40c13b83e /core/src/fpdfdoc/doc_action.cpp | |
parent | bc6c6723c37772b02de9e6e43fa0fd9439874905 (diff) | |
download | pdfium-2b11dc1220746d2f6f97a940fc9e4235c8ed4975.tar.xz |
Merge to XFA: Add type cast definitions for CPDF_Array.
This Cl adds ToArray, CPDF_Object::AsArray and CPDF_Object::IsArray and
updates the src to use them as needed.
BUG=pdfium:201
R=thestig@chromium.org, tsepez@chromium.org
Review URL: https://codereview.chromium.org/1417893003 .
(cherry picked from commit c2bfc000e502c42c9a3017038fd9104c7997d126)
Review URL: https://codereview.chromium.org/1419643005 .
Diffstat (limited to 'core/src/fpdfdoc/doc_action.cpp')
-rw-r--r-- | core/src/fpdfdoc/doc_action.cpp | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/core/src/fpdfdoc/doc_action.cpp b/core/src/fpdfdoc/doc_action.cpp index bcbfe0f112..d685f64cae 100644 --- a/core/src/fpdfdoc/doc_action.cpp +++ b/core/src/fpdfdoc/doc_action.cpp @@ -22,9 +22,8 @@ CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const { CFX_ByteStringC name = pDest->GetString(); return CPDF_Dest(name_tree.LookupNamedDest(pDoc, name)); } - if (pDest->GetType() == PDFOBJ_ARRAY) { - return CPDF_Dest((CPDF_Array*)pDest); - } + if (CPDF_Array* pArray = pDest->AsArray()) + return CPDF_Dest(pArray); return CPDF_Dest(); } const FX_CHAR* g_sATypes[] = { @@ -108,8 +107,8 @@ FX_DWORD CPDF_ActionFields::GetFieldsCount() const { return 1; if (pFields->IsString()) return 1; - if (pFields->GetType() == PDFOBJ_ARRAY) - return ((CPDF_Array*)pFields)->GetCount(); + if (CPDF_Array* pArray = pFields->AsArray()) + return pArray->GetCount(); return 0; } void CPDF_ActionFields::GetAllFields(CFX_PtrArray& fieldObjects) const { @@ -133,8 +132,7 @@ void CPDF_ActionFields::GetAllFields(CFX_PtrArray& fieldObjects) const { if (pFields->IsDictionary() || pFields->IsString()) { fieldObjects.Add(pFields); - } else if (pFields->GetType() == PDFOBJ_ARRAY) { - CPDF_Array* pArray = (CPDF_Array*)pFields; + } else if (CPDF_Array* pArray = pFields->AsArray()) { FX_DWORD iCount = pArray->GetCount(); for (FX_DWORD i = 0; i < iCount; i++) { CPDF_Object* pObj = pArray->GetElementValue(i); @@ -166,8 +164,8 @@ CPDF_Object* CPDF_ActionFields::GetField(FX_DWORD iIndex) const { if (pFields->IsDictionary() || pFields->IsString()) { if (iIndex == 0) pFindObj = pFields; - } else if (pFields->GetType() == PDFOBJ_ARRAY) { - pFindObj = ((CPDF_Array*)pFields)->GetElementValue(iIndex); + } else if (CPDF_Array* pArray = pFields->AsArray()) { + pFindObj = pArray->GetElementValue(iIndex); } return pFindObj; } @@ -222,20 +220,16 @@ int32_t CPDF_Action::GetOperationType() const { return 0; } FX_DWORD CPDF_Action::GetSubActionsCount() const { - if (m_pDict == NULL || !m_pDict->KeyExist("Next")) { + if (!m_pDict || !m_pDict->KeyExist("Next")) return 0; - } + CPDF_Object* pNext = m_pDict->GetElementValue("Next"); - if (!pNext) { + if (!pNext) return 0; - } - int iObjType = pNext->GetType(); - if (iObjType == PDFOBJ_DICTIONARY) { + if (pNext->IsDictionary()) return 1; - } - if (iObjType == PDFOBJ_ARRAY) { - return ((CPDF_Array*)pNext)->GetCount(); - } + if (CPDF_Array* pArray = pNext->AsArray()) + return pArray->GetCount(); return 0; } CPDF_Action CPDF_Action::GetSubAction(FX_DWORD iIndex) const { @@ -246,8 +240,7 @@ CPDF_Action CPDF_Action::GetSubAction(FX_DWORD iIndex) const { if (CPDF_Dictionary* pDict = ToDictionary(pNext)) { if (iIndex == 0) return CPDF_Action(pDict); - } else if (pNext->GetType() == PDFOBJ_ARRAY) { - CPDF_Array* pArray = static_cast<CPDF_Array*>(pNext); + } else if (CPDF_Array* pArray = ToArray(pNext)) { return CPDF_Action(pArray->GetDict(iIndex)); } return CPDF_Action(); |