Clean up CPDF_AnnotList.
[pdfium.git] / fpdfsdk / src / fpdf_transformpage.cpp
index d2ad26b..8a835fb 100644 (file)
@@ -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()) {
@@ -144,7 +143,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 (pDirectObj->GetType() == PDFOBJ_STREAM) {
+      } else if (pDirectObj->IsStream()) {
         pContentArray = new CPDF_Array();
         pContentArray->AddReference(pDoc, pStream->GetObjNum());
         pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
@@ -162,16 +161,17 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
     if (pPattenDict) {
       FX_POSITION pos = pPattenDict->GetStartPos();
       while (pos) {
-        CPDF_Dictionary* pDict = NULL;
+        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()) {
+
+        if (pObj->IsDictionary())
           pDict = pObj->AsDictionary();
-        } else if (pObj->GetType() == PDFOBJ_STREAM) {
-          pDict = ((CPDF_Stream*)pObj)->GetDict();
-        } else
+        else if (CPDF_Stream* pStream = pObj->AsStream())
+          pDict = pStream->GetDict();
+        else
           continue;
 
         CFX_AffineMatrix m = pDict->GetMatrix(FX_BSTRC("Matrix"));
@@ -305,15 +305,14 @@ 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()) {
         pContentArray = pArray;
         CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
         pContentArray->InsertAt(0, pRef);
-      } else if (pDirectObj->GetType() == PDFOBJ_STREAM) {
+      } else if (pDirectObj->IsStream()) {
         pContentArray = new CPDF_Array();
         pContentArray->AddReference(pDoc, pStream->GetObjNum());
         pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());