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

Unified Diff: fpdfsdk/src/fpdfppo.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 | « fpdfsdk/src/fpdfeditpage.cpp ('k') | fpdfsdk/src/fpdfview.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/fpdfppo.cpp
diff --git a/fpdfsdk/src/fpdfppo.cpp b/fpdfsdk/src/fpdfppo.cpp
index ed2446471ee713b49525bfced37bdd3f7c1b52ed..6521258485b5ec3b9b6b66fc1bcf0709879b2102 100644
--- a/fpdfsdk/src/fpdfppo.cpp
+++ b/fpdfsdk/src/fpdfppo.cpp
@@ -59,10 +59,10 @@ FX_BOOL CPDF_PageOrganizer::PDFDocInit(CPDF_Document* pDestPDFDoc,
pNewRoot->SetAt("Type", new CPDF_Name("Catalog"));
}
- CPDF_Dictionary* pNewPages =
- (CPDF_Dictionary*)(pNewRoot->GetElement("Pages")
- ? pNewRoot->GetElement("Pages")->GetDirect()
- : NULL);
+ CPDF_Dictionary* pNewPages = ToDictionary(
+ pNewRoot->GetElement("Pages") ? pNewRoot->GetElement("Pages")->GetDirect()
+ : nullptr);
+
if (!pNewPages) {
pNewPages = new CPDF_Dictionary;
FX_DWORD NewPagesON = pDestPDFDoc->AddIndirectObject(pNewPages);
@@ -191,29 +191,25 @@ CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag(
if (pType->GetString().Compare("Page"))
return NULL;
-
if (!pDict->KeyExist("Parent"))
return NULL;
- CPDF_Object* pParent = pDict->GetElement("Parent")->GetDirect();
- if (!pParent || pParent->GetType() != PDFOBJ_DICTIONARY)
- return NULL;
- CPDF_Dictionary* pp = (CPDF_Dictionary*)pParent;
+ CPDF_Dictionary* pp = ToDictionary(pDict->GetElement("Parent")->GetDirect());
+ if (!pp)
+ return nullptr;
if (pDict->KeyExist((const char*)nSrctag))
return pDict->GetElement((const char*)nSrctag);
+
while (pp) {
if (pp->KeyExist((const char*)nSrctag))
return pp->GetElement((const char*)nSrctag);
- if (pp->KeyExist("Parent")) {
- pp = (CPDF_Dictionary*)pp->GetElement("Parent")->GetDirect();
- if (pp->GetType() == PDFOBJ_NULL)
- break;
- } else
+ if (!pp->KeyExist("Parent")) {
break;
+ }
+ pp = ToDictionary(pp->GetElement("Parent")->GetDirect());
}
-
- return NULL;
+ return nullptr;
}
FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
@@ -229,7 +225,7 @@ FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
break;
}
case PDFOBJ_DICTIONARY: {
- CPDF_Dictionary* pDict = (CPDF_Dictionary*)pObj;
+ CPDF_Dictionary* pDict = pObj->AsDictionary();
FX_POSITION pos = pDict->GetStartPos();
while (pos) {
@@ -300,8 +296,7 @@ int CPDF_PageOrganizer::GetNewObjId(CPDF_Document* pDoc,
return 0;
}
- if (pClone->GetType() == PDFOBJ_DICTIONARY) {
- CPDF_Dictionary* pDictClone = (CPDF_Dictionary*)pClone;
+ if (CPDF_Dictionary* pDictClone = pClone->AsDictionary()) {
if (pDictClone->KeyExist("Type")) {
CFX_ByteString strType = pDictClone->GetString("Type");
if (!FXSYS_stricmp(strType, "Pages")) {
« no previous file with comments | « fpdfsdk/src/fpdfeditpage.cpp ('k') | fpdfsdk/src/fpdfview.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698