diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2015-10-20 14:57:56 -0400 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2015-10-20 14:57:56 -0400 |
commit | 39869b641511c882d78e17548293cdb458c36f38 (patch) | |
tree | 6e7fee229f9c8a5d628c2dfe81b3e9848a9670d2 /fpdfsdk/src/fpdfppo.cpp | |
parent | 19169dae5bf92813b7419793f61dfca8b4fb9124 (diff) | |
download | pdfium-39869b641511c882d78e17548293cdb458c36f38.tar.xz |
Revert "Revert "Add type cast definitions for CPDF_Dictionary.""
This reverts commit 937840e1722d1f2b77d80575d6e710d760662c9c.
Add type cast definitions for CPDF_Dictionary.
This CL adds ToCPDFDictionary type definitions and updates one file to use
instead of straight casts. I had to fix two places where we'd casted off the
constness of the original pointer.
BUG=pdfium:201
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1420583003 .
Diffstat (limited to 'fpdfsdk/src/fpdfppo.cpp')
-rw-r--r-- | fpdfsdk/src/fpdfppo.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/fpdfsdk/src/fpdfppo.cpp b/fpdfsdk/src/fpdfppo.cpp index 2508adca7b..ab25b76934 100644 --- a/fpdfsdk/src/fpdfppo.cpp +++ b/fpdfsdk/src/fpdfppo.cpp @@ -60,7 +60,7 @@ FX_BOOL CPDF_PageOrganizer::PDFDocInit(CPDF_Document* pDestPDFDoc, CPDF_Object* pElement = pNewRoot->GetElement("Pages"); CPDF_Dictionary* pNewPages = - pElement ? (CPDF_Dictionary*)pElement->GetDirect() : nullptr; + pElement ? ToDictionary(pElement->GetDirect()) : nullptr; if (!pNewPages) { pNewPages = new CPDF_Dictionary; FX_DWORD NewPagesON = pDestPDFDoc->AddIndirectObject(pNewPages); @@ -183,14 +183,13 @@ CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag( if (pType->GetString().Compare("Page")) return nullptr; - CPDF_Object* pParent = pDict->GetElement("Parent")->GetDirect(); - if (!pParent || pParent->GetType() != PDFOBJ_DICTIONARY) + CPDF_Dictionary* pp = ToDictionary(pDict->GetElement("Parent")->GetDirect()); + if (!pp) return nullptr; if (pDict->KeyExist((const char*)nSrctag)) return pDict->GetElement((const char*)nSrctag); - CPDF_Dictionary* pp = (CPDF_Dictionary*)pParent; while (pp) { if (pp->KeyExist((const char*)nSrctag)) { return pp->GetElement((const char*)nSrctag); @@ -198,12 +197,8 @@ CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag( if (!pp->KeyExist("Parent")) { break; } - pp = (CPDF_Dictionary*)pp->GetElement("Parent")->GetDirect(); - if (pp->GetType() == PDFOBJ_NULL) { - break; - } + pp = ToDictionary(pp->GetElement("Parent")->GetDirect()); } - return nullptr; } @@ -220,7 +215,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) { @@ -291,8 +286,7 @@ FX_DWORD CPDF_PageOrganizer::GetNewObjId(CPDF_Document* pDoc, if (!pClone) 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")) { |