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")) { |