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

Unified Diff: core/src/fpdfdoc/doc_action.cpp

Issue 1410343003: [Merge to XFA] Revert "Revert "Add type cast definitions for CPDF_Dictionary."" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Rebase to origin/xfa 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
« no previous file with comments | « core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp ('k') | core/src/fpdfdoc/doc_annot.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfdoc/doc_action.cpp
diff --git a/core/src/fpdfdoc/doc_action.cpp b/core/src/fpdfdoc/doc_action.cpp
index 759a06c65671bb778dcf82ac3cab039f48dcac40..409d0504840015ce4e1f0c236043963507c55a29 100644
--- a/core/src/fpdfdoc/doc_action.cpp
+++ b/core/src/fpdfdoc/doc_action.cpp
@@ -251,13 +251,10 @@ CPDF_Action CPDF_Action::GetSubAction(FX_DWORD iIndex) const {
return CPDF_Action();
}
CPDF_Object* pNext = m_pDict->GetElementValue("Next");
- int iObjType = pNext->GetType();
- if (iObjType == PDFOBJ_DICTIONARY) {
- CPDF_Dictionary* pDict = static_cast<CPDF_Dictionary*>(pNext);
- if (iIndex == 0) {
+ if (CPDF_Dictionary* pDict = ToDictionary(pNext)) {
+ if (iIndex == 0)
return CPDF_Action(pDict);
- }
- } else if (iObjType == PDFOBJ_ARRAY) {
+ } else if (pNext->GetType() == PDFOBJ_ARRAY) {
CPDF_Array* pArray = static_cast<CPDF_Array*>(pNext);
return CPDF_Action(pArray->GetDict(iIndex));
}
@@ -295,9 +292,10 @@ CPDF_Action CPDF_AAction::GetNextAction(FX_POSITION& pos,
return CPDF_Action();
}
CPDF_Object* pDirect = pObj->GetDirect();
- if (!pDirect || pDirect->GetType() != PDFOBJ_DICTIONARY) {
+ CPDF_Dictionary* pDict = ToDictionary(pDirect);
+ if (!pDict)
return CPDF_Action();
- }
+
int i = 0;
while (g_sAATypes[i][0] != '\0') {
if (csKey == g_sAATypes[i]) {
@@ -306,7 +304,7 @@ CPDF_Action CPDF_AAction::GetNextAction(FX_POSITION& pos,
i++;
}
eType = (AActionType)i;
- return CPDF_Action(static_cast<CPDF_Dictionary*>(pDirect));
+ return CPDF_Action(pDict);
}
CPDF_DocJSActions::CPDF_DocJSActions(CPDF_Document* pDoc) {
m_pDocument = pDoc;
@@ -321,7 +319,7 @@ CPDF_Action CPDF_DocJSActions::GetJSAction(int index,
ASSERT(m_pDocument != NULL);
CPDF_NameTree name_tree(m_pDocument, FX_BSTRC("JavaScript"));
CPDF_Object* pAction = name_tree.LookupValue(index, csName);
- if (pAction == NULL || pAction->GetType() != PDFOBJ_DICTIONARY) {
+ if (!ToDictionary(pAction)) {
return CPDF_Action();
}
return CPDF_Action(pAction->GetDict());
@@ -330,7 +328,7 @@ CPDF_Action CPDF_DocJSActions::GetJSAction(const CFX_ByteString& csName) const {
ASSERT(m_pDocument != NULL);
CPDF_NameTree name_tree(m_pDocument, FX_BSTRC("JavaScript"));
CPDF_Object* pAction = name_tree.LookupValue(csName);
- if (pAction == NULL || pAction->GetType() != PDFOBJ_DICTIONARY) {
+ if (!ToDictionary(pAction)) {
return CPDF_Action();
}
return CPDF_Action(pAction->GetDict());
« no previous file with comments | « core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp ('k') | core/src/fpdfdoc/doc_annot.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698