diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2015-10-26 12:51:50 -0400 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2015-10-26 12:51:50 -0400 |
commit | 9024e026dae1af064b8467bb0f62278417fb82d1 (patch) | |
tree | ff195a845b5cb07b7ddc657984f8e4ad2239c4cc /core/src/fpdfdoc | |
parent | 9b2741829b8a8c511ef0f2f313ff53d77ac96307 (diff) | |
download | pdfium-9024e026dae1af064b8467bb0f62278417fb82d1.tar.xz |
Add type cast definitions for CPDF_Reference.
This Cl adds ToReference, CPDF_Object::AsReference and CPDF_Object::IsReference
and updates the src to use them as needed.
BUG=pdfium:201
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1420973002 .
Diffstat (limited to 'core/src/fpdfdoc')
-rw-r--r-- | core/src/fpdfdoc/doc_form.cpp | 7 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_tagged.cpp | 30 |
2 files changed, 17 insertions, 20 deletions
diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp index 8078608883..3192445d90 100644 --- a/core/src/fpdfdoc/doc_form.cpp +++ b/core/src/fpdfdoc/doc_form.cpp @@ -1086,13 +1086,12 @@ CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) { } pField = new CPDF_FormField(this, pParent); CPDF_Object* pTObj = pDict->GetElement("T"); - if (pTObj && pTObj->GetType() == PDFOBJ_REFERENCE) { + if (ToReference(pTObj)) { CPDF_Object* pClone = pTObj->Clone(TRUE); - if (pClone) { + if (pClone) pDict->SetAt("T", pClone); - } else { + else pDict->SetAtName("T", ""); - } } m_pFieldTree->SetField(csWName, pField); } diff --git a/core/src/fpdfdoc/doc_tagged.cpp b/core/src/fpdfdoc/doc_tagged.cpp index f74aa7f6f5..f1877c6573 100644 --- a/core/src/fpdfdoc/doc_tagged.cpp +++ b/core/src/fpdfdoc/doc_tagged.cpp @@ -173,10 +173,10 @@ FX_BOOL CPDF_StructTreeImpl::AddTopLevelNode(CPDF_Dictionary* pDict, FX_DWORD i; FX_BOOL bSave = FALSE; for (i = 0; i < pTopKids->GetCount(); i++) { - CPDF_Object* pKidRef = pTopKids->GetElement(i); - if (!pKidRef || pKidRef->GetType() != PDFOBJ_REFERENCE) + CPDF_Reference* pKidRef = ToReference(pTopKids->GetElement(i)); + if (!pKidRef) continue; - if (((CPDF_Reference*)pKidRef)->GetRefObjNum() != pDict->GetObjNum()) + if (pKidRef->GetRefObjNum() != pDict->GetObjNum()) continue; if (m_Kids[i]) @@ -225,8 +225,8 @@ void CPDF_StructElementImpl::Release() { void CPDF_StructElementImpl::LoadKids(CPDF_Dictionary* pDict) { CPDF_Object* pObj = pDict->GetElement(FX_BSTRC("Pg")); FX_DWORD PageObjNum = 0; - if (pObj && pObj->GetType() == PDFOBJ_REFERENCE) - PageObjNum = ((CPDF_Reference*)pObj)->GetRefObjNum(); + if (CPDF_Reference* pRef = ToReference(pObj)) + PageObjNum = pRef->GetRefObjNum(); CPDF_Object* pKids = pDict->GetElementValue(FX_BSTRC("K")); if (!pKids) @@ -264,20 +264,18 @@ void CPDF_StructElementImpl::LoadKid(FX_DWORD PageObjNum, if (!pKidDict) return; - CPDF_Object* pPageObj = pKidDict->GetElement(FX_BSTRC("Pg")); - if (pPageObj && pPageObj->GetType() == PDFOBJ_REFERENCE) { - PageObjNum = ((CPDF_Reference*)pPageObj)->GetRefObjNum(); - } + if (CPDF_Reference* pRef = ToReference(pKidDict->GetElement(FX_BSTRC("Pg")))) + PageObjNum = pRef->GetRefObjNum(); + CFX_ByteString type = pKidDict->GetString(FX_BSTRC("Type")); if (type == FX_BSTRC("MCR")) { if (m_pTree->m_pPage && m_pTree->m_pPage->GetObjNum() != PageObjNum) { return; } pKid->m_Type = CPDF_StructKid::StreamContent; - CPDF_Object* pStreamObj = pKidDict->GetElement(FX_BSTRC("Stm")); - if (pStreamObj && pStreamObj->GetType() == PDFOBJ_REFERENCE) { - pKid->m_StreamContent.m_RefObjNum = - ((CPDF_Reference*)pStreamObj)->GetRefObjNum(); + if (CPDF_Reference* pRef = + ToReference(pKidDict->GetElement(FX_BSTRC("Stm")))) { + pKid->m_StreamContent.m_RefObjNum = pRef->GetRefObjNum(); } else { pKid->m_StreamContent.m_RefObjNum = 0; } @@ -288,9 +286,9 @@ void CPDF_StructElementImpl::LoadKid(FX_DWORD PageObjNum, return; } pKid->m_Type = CPDF_StructKid::Object; - CPDF_Object* pObj = pKidDict->GetElement(FX_BSTRC("Obj")); - if (pObj && pObj->GetType() == PDFOBJ_REFERENCE) { - pKid->m_Object.m_RefObjNum = ((CPDF_Reference*)pObj)->GetRefObjNum(); + if (CPDF_Reference* pObj = + ToReference(pKidDict->GetElement(FX_BSTRC("Obj")))) { + pKid->m_Object.m_RefObjNum = pObj->GetRefObjNum(); } else { pKid->m_Object.m_RefObjNum = 0; } |