From 9024e026dae1af064b8467bb0f62278417fb82d1 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 26 Oct 2015 12:51:50 -0400 Subject: 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 . --- fpdfsdk/src/fpdf_flatten.cpp | 4 +--- fpdfsdk/src/fpdf_transformpage.cpp | 8 +++----- fpdfsdk/src/fpdfppo.cpp | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) (limited to 'fpdfsdk/src') diff --git a/fpdfsdk/src/fpdf_flatten.cpp b/fpdfsdk/src/fpdf_flatten.cpp index 39441c4aef..75db8f806d 100644 --- a/fpdfsdk/src/fpdf_flatten.cpp +++ b/fpdfsdk/src/fpdf_flatten.cpp @@ -444,12 +444,10 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { CFX_ByteString sKey; CPDF_Object* pFirstObj = pAPDic->GetNextElement(pos, sKey); if (pFirstObj) { - if (pFirstObj->GetType() == PDFOBJ_REFERENCE) + if (pFirstObj->IsReference()) pFirstObj = pFirstObj->GetDirect(); - if (!pFirstObj->IsStream()) continue; - pAPStream = pFirstObj->AsStream(); } } diff --git a/fpdfsdk/src/fpdf_transformpage.cpp b/fpdfsdk/src/fpdf_transformpage.cpp index 20713fe07d..8a835fb220 100644 --- a/fpdfsdk/src/fpdf_transformpage.cpp +++ b/fpdfsdk/src/fpdf_transformpage.cpp @@ -135,8 +135,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); pContentArray->InsertAt(0, pRef); pContentArray->AddReference(pDoc, pEndStream); - } else if (pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE) { - CPDF_Reference* pReference = (CPDF_Reference*)pContentObj; + } else if (CPDF_Reference* pReference = ToReference(pContentObj)) { CPDF_Object* pDirectObj = pReference->GetDirect(); if (pDirectObj) { if (CPDF_Array* pArray = pDirectObj->AsArray()) { @@ -165,7 +164,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, CPDF_Dictionary* pDict = nullptr; CFX_ByteString key; CPDF_Object* pObj = pPattenDict->GetNextElement(pos, key); - if (pObj->GetType() == PDFOBJ_REFERENCE) + if (pObj->IsReference()) pObj = pObj->GetDirect(); if (pObj->IsDictionary()) @@ -306,8 +305,7 @@ DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page, pContentArray = pArray; CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); pContentArray->InsertAt(0, pRef); - } else if (pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE) { - CPDF_Reference* pReference = (CPDF_Reference*)pContentObj; + } else if (CPDF_Reference* pReference = ToReference(pContentObj)) { CPDF_Object* pDirectObj = pReference->GetDirect(); if (pDirectObj) { if (CPDF_Array* pArray = pDirectObj->AsArray()) { diff --git a/fpdfsdk/src/fpdfppo.cpp b/fpdfsdk/src/fpdfppo.cpp index c9df813789..6bdd7c5e67 100644 --- a/fpdfsdk/src/fpdfppo.cpp +++ b/fpdfsdk/src/fpdfppo.cpp @@ -207,7 +207,7 @@ FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj, ObjectNumberMap* pObjNumberMap) { switch (pObj->GetType()) { case PDFOBJ_REFERENCE: { - CPDF_Reference* pReference = (CPDF_Reference*)pObj; + CPDF_Reference* pReference = pObj->AsReference(); FX_DWORD newobjnum = GetNewObjId(pDoc, pObjNumberMap, pReference); if (newobjnum == 0) return FALSE; -- cgit v1.2.3