Clean up CPDF_AnnotList.
[pdfium.git] / fpdfsdk / src / fpdf_flatten.cpp
index fee93f2..75db8f8 100644 (file)
@@ -211,7 +211,7 @@ void SetPageContents(CFX_ByteString key,
   switch (iType) {
     case PDFOBJ_STREAM: {
       pContentsArray = new CPDF_Array;
-      CPDF_Stream* pContents = (CPDF_Stream*)pContentsObj;
+      CPDF_Stream* pContents = pContentsObj->AsStream();
       FX_DWORD dwObjNum = pDocument->AddIndirectObject(pContents);
       CPDF_StreamAcc acc;
       acc.LoadAllData(pContents);
@@ -226,7 +226,7 @@ void SetPageContents(CFX_ByteString key,
     }
 
     case PDFOBJ_ARRAY: {
-      pContentsArray = (CPDF_Array*)pContentsObj;
+      pContentsArray = pContentsObj->AsArray();
       break;
     }
     default:
@@ -444,18 +444,15 @@ 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->GetType() != PDFOBJ_STREAM)
+            if (!pFirstObj->IsStream())
               continue;
-
-            pAPStream = (CPDF_Stream*)pFirstObj;
+            pAPStream = pFirstObj->AsStream();
           }
         }
       }
     }
-
     if (!pAPStream)
       continue;