summaryrefslogtreecommitdiff
path: root/core/src/fpdfdoc
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-03-05 16:44:22 -0800
committerTom Sepez <tsepez@chromium.org>2015-03-05 16:44:22 -0800
commit7b5bc26e8267fec38bef9f95cd04d2bd731faff3 (patch)
tree9203aa0ff0d4a34616a5161b2ded34ce7e9ada24 /core/src/fpdfdoc
parent827a1722f70e7092270b5e0fdfba1e9c0b1ac50f (diff)
downloadpdfium-7b5bc26e8267fec38bef9f95cd04d2bd731faff3.tar.xz
Merge to XFA: Make conversion between CPDF_Action and its dictionary explicit.
Original Review URL: https://codereview.chromium.org/984773002 R=thestig@chromium.org TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/984783002
Diffstat (limited to 'core/src/fpdfdoc')
-rw-r--r--core/src/fpdfdoc/doc_action.cpp62
-rw-r--r--core/src/fpdfdoc/doc_bookmark.cpp4
-rw-r--r--core/src/fpdfdoc/doc_formcontrol.cpp17
-rw-r--r--core/src/fpdfdoc/doc_link.cpp2
4 files changed, 43 insertions, 42 deletions
diff --git a/core/src/fpdfdoc/doc_action.cpp b/core/src/fpdfdoc/doc_action.cpp
index 801c69fbb7..324153563a 100644
--- a/core/src/fpdfdoc/doc_action.cpp
+++ b/core/src/fpdfdoc/doc_action.cpp
@@ -94,7 +94,7 @@ FX_DWORD CPDF_ActionFields::GetFieldsCount() const
if (m_pAction == NULL) {
return 0;
}
- CPDF_Dictionary* pDict = (CPDF_Dictionary*)(*m_pAction);
+ CPDF_Dictionary* pDict = m_pAction->GetDict();
if (pDict == NULL) {
return 0;
}
@@ -124,7 +124,7 @@ void CPDF_ActionFields::GetAllFields(CFX_PtrArray& fieldObjects) const
if (m_pAction == NULL) {
return;
}
- CPDF_Dictionary* pDict = (CPDF_Dictionary*)(*m_pAction);
+ CPDF_Dictionary* pDict = m_pAction->GetDict();
if (pDict == NULL) {
return;
}
@@ -157,7 +157,7 @@ CPDF_Object* CPDF_ActionFields::GetField(FX_DWORD iIndex) const
if (m_pAction == NULL) {
return NULL;
}
- CPDF_Dictionary* pDict = (CPDF_Dictionary*)(*m_pAction);
+ CPDF_Dictionary* pDict = m_pAction->GetDict();
if (pDict == NULL) {
return NULL;
}
@@ -260,19 +260,20 @@ FX_DWORD CPDF_Action::GetSubActionsCount() const
CPDF_Action CPDF_Action::GetSubAction(FX_DWORD iIndex) const
{
if (m_pDict == NULL || !m_pDict->KeyExist("Next")) {
- return NULL;
+ 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) {
- return (CPDF_Dictionary*)pNext;
+ return CPDF_Action(pDict);
}
+ } else if (iObjType == PDFOBJ_ARRAY) {
+ CPDF_Array* pArray = static_cast<CPDF_Array*>(pNext);
+ return CPDF_Action(pArray->GetDict(iIndex));
}
- if (iObjType == PDFOBJ_ARRAY) {
- return ((CPDF_Array*)pNext)->GetDict(iIndex);
- }
- return NULL;
+ return CPDF_Action();
}
const FX_CHAR* g_sAATypes[] = {"E", "X", "D", "U", "Fo", "Bl", "PO", "PC", "PV", "PI",
"O", "C",
@@ -289,10 +290,10 @@ FX_BOOL CPDF_AAction::ActionExist(AActionType eType) const
}
CPDF_Action CPDF_AAction::GetAction(AActionType eType) const
{
- if (m_pDict == NULL) {
- return NULL;
+ if (!m_pDict) {
+ return CPDF_Action();
}
- return m_pDict->GetDict(g_sAATypes[(int)eType]);
+ return CPDF_Action(m_pDict->GetDict(g_sAATypes[(int)eType]));
}
FX_POSITION CPDF_AAction::GetStartPos() const
{
@@ -304,25 +305,26 @@ FX_POSITION CPDF_AAction::GetStartPos() const
CPDF_Action CPDF_AAction::GetNextAction(FX_POSITION& pos, AActionType& eType) const
{
if (m_pDict == NULL) {
- return NULL;
+ return CPDF_Action();
}
CFX_ByteString csKey;
CPDF_Object* pObj = m_pDict->GetNextElement(pos, csKey);
- if (pObj != NULL) {
- CPDF_Object* pDirect = pObj->GetDirect();
- if (pDirect != NULL && pDirect->GetType() == PDFOBJ_DICTIONARY) {
- int i = 0;
- while (g_sAATypes[i][0] != '\0') {
- if (csKey == g_sAATypes[i]) {
- break;
- }
- i ++;
- }
- eType = (AActionType)i;
- return (CPDF_Dictionary*)pDirect;
+ if (!pObj) {
+ return CPDF_Action();
+ }
+ CPDF_Object* pDirect = pObj->GetDirect();
+ if (!pDirect || pDirect->GetType() != PDFOBJ_DICTIONARY) {
+ return CPDF_Action();
+ }
+ int i = 0;
+ while (g_sAATypes[i][0] != '\0') {
+ if (csKey == g_sAATypes[i]) {
+ break;
}
+ i++;
}
- return NULL;
+ eType = (AActionType)i;
+ return CPDF_Action(static_cast<CPDF_Dictionary*>(pDirect));
}
CPDF_DocJSActions::CPDF_DocJSActions(CPDF_Document* pDoc)
{
@@ -340,9 +342,9 @@ CPDF_Action CPDF_DocJSActions::GetJSAction(int index, CFX_ByteString& csName) co
CPDF_NameTree name_tree(m_pDocument, FX_BSTRC("JavaScript"));
CPDF_Object *pAction = name_tree.LookupValue(index, csName);
if (pAction == NULL || pAction->GetType() != PDFOBJ_DICTIONARY) {
- return NULL;
+ return CPDF_Action();
}
- return pAction->GetDict();
+ return CPDF_Action(pAction->GetDict());
}
CPDF_Action CPDF_DocJSActions::GetJSAction(const CFX_ByteString& csName) const
{
@@ -350,9 +352,9 @@ CPDF_Action CPDF_DocJSActions::GetJSAction(const CFX_ByteString& csName) const
CPDF_NameTree name_tree(m_pDocument, FX_BSTRC("JavaScript"));
CPDF_Object *pAction = name_tree.LookupValue(csName);
if (pAction == NULL || pAction->GetType() != PDFOBJ_DICTIONARY) {
- return NULL;
+ return CPDF_Action();
}
- return pAction->GetDict();
+ return CPDF_Action(pAction->GetDict());
}
int CPDF_DocJSActions::FindJSAction(const CFX_ByteString& csName) const
{
diff --git a/core/src/fpdfdoc/doc_bookmark.cpp b/core/src/fpdfdoc/doc_bookmark.cpp
index e7b383eced..a3a194337e 100644
--- a/core/src/fpdfdoc/doc_bookmark.cpp
+++ b/core/src/fpdfdoc/doc_bookmark.cpp
@@ -86,7 +86,7 @@ CPDF_Dest CPDF_Bookmark::GetDest(CPDF_Document* pDocument) const
CPDF_Action CPDF_Bookmark::GetAction() const
{
if (!m_pDict) {
- return NULL;
+ return CPDF_Action();
}
- return m_pDict->GetDict("A");
+ return CPDF_Action(m_pDict->GetDict("A"));
}
diff --git a/core/src/fpdfdoc/doc_formcontrol.cpp b/core/src/fpdfdoc/doc_formcontrol.cpp
index 61cd980754..1ab63234d6 100644
--- a/core/src/fpdfdoc/doc_formcontrol.cpp
+++ b/core/src/fpdfdoc/doc_formcontrol.cpp
@@ -248,18 +248,17 @@ int CPDF_FormControl::GetTextPosition()
}
CPDF_Action CPDF_FormControl::GetAction()
{
- if (m_pWidgetDict == NULL) {
- return NULL;
+ if (!m_pWidgetDict) {
+ return CPDF_Action();
}
if (m_pWidgetDict->KeyExist("A")) {
- return m_pWidgetDict->GetDict("A");
- } else {
- CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "A");
- if (pObj == NULL) {
- return NULL;
- }
- return pObj->GetDict();
+ return CPDF_Action(m_pWidgetDict->GetDict("A"));
+ }
+ CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "A");
+ if (!pObj) {
+ return CPDF_Action();
}
+ return CPDF_Action(pObj->GetDict());
}
CPDF_AAction CPDF_FormControl::GetAdditionalAction()
{
diff --git a/core/src/fpdfdoc/doc_link.cpp b/core/src/fpdfdoc/doc_link.cpp
index 964b84e549..e7b6be5ca4 100644
--- a/core/src/fpdfdoc/doc_link.cpp
+++ b/core/src/fpdfdoc/doc_link.cpp
@@ -103,5 +103,5 @@ CPDF_Dest CPDF_Link::GetDest(CPDF_Document* pDoc)
}
CPDF_Action CPDF_Link::GetAction()
{
- return m_pDict->GetDict("A");
+ return CPDF_Action(m_pDict->GetDict("A"));
}