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

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: 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
Index: fpdfsdk/src/fpdfppo.cpp
diff --git a/fpdfsdk/src/fpdfppo.cpp b/fpdfsdk/src/fpdfppo.cpp
index ed2446471ee713b49525bfced37bdd3f7c1b52ed..3d1345258bdba33fabff8310079c2b916c9089da 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()
dsinclair 2015/10/20 19:18:31 This code differs slightly from master and was mer
+ : nullptr);
+
if (!pNewPages) {
pNewPages = new CPDF_Dictionary;
FX_DWORD NewPagesON = pDestPDFDoc->AddIndirectObject(pNewPages);
@@ -191,17 +191,16 @@ CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag(
if (pType->GetString().Compare("Page"))
return NULL;
-
if (!pDict->KeyExist("Parent"))
dsinclair 2015/10/20 19:18:31 This key check doesn't exist on master and caused
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);
@@ -213,7 +212,7 @@ CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag(
break;
}
dsinclair 2015/10/20 19:18:31 This is a bit weird, on master the while ends with
Tom Sepez 2015/10/20 19:49:28 Looks like on master we inverted the if at 207 to
dsinclair 2015/10/20 19:57:16 Done.
- return NULL;
+ return nullptr;
}
FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
@@ -229,7 +228,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 +299,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")) {

Powered by Google App Engine
This is Rietveld 408576698