summaryrefslogtreecommitdiff
path: root/core/src/fpdfdoc/doc_action.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-10-20 16:24:45 -0400
committerDan Sinclair <dsinclair@chromium.org>2015-10-20 16:24:45 -0400
commitf1251c1ff2b3452854681d0648b4c1ca4180ff0d (patch)
treedbcff41b8f8a5ea3d1d5280ff0c946b9647c301a /core/src/fpdfdoc/doc_action.cpp
parent49f88b708d905b052bc00769ac7cb48202cac019 (diff)
downloadpdfium-f1251c1ff2b3452854681d0648b4c1ca4180ff0d.tar.xz
[Merge to XFA] Revert "Revert "Add type cast definitions for CPDF_Dictionary.""
This reverts commit 937840e1722d1f2b77d80575d6e710d760662c9c. Add type cast definitions for CPDF_Dictionary. This CL adds ToCPDFDictionary type definitions and updates one file to use instead of straight casts. I had to fix two places where we'd casted off the constness of the original pointer. BUG=pdfium:201 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1420583003 . (cherry picked from commit 39869b641511c882d78e17548293cdb458c36f38) Review URL: https://codereview.chromium.org/1410343003 .
Diffstat (limited to 'core/src/fpdfdoc/doc_action.cpp')
-rw-r--r--core/src/fpdfdoc/doc_action.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/core/src/fpdfdoc/doc_action.cpp b/core/src/fpdfdoc/doc_action.cpp
index 759a06c656..409d050484 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());