Add type cast definitions for CPDF_Array.
[pdfium.git] / fpdfsdk / src / fsdk_mgr.cpp
index 5b94aef..f43a45b 100644 (file)
@@ -6,11 +6,10 @@
 
 #include "../../public/fpdf_ext.h"
 #include "../../third_party/base/nonstd_unique_ptr.h"
+#include "../include/formfiller/FFL_FormFiller.h"
 #include "../include/fsdk_define.h"
 #include "../include/fsdk_mgr.h"
-#include "../include/formfiller/FFL_FormFiller.h"
 #include "../include/javascript/IJavaScript.h"
-#include "../include/javascript/JS_Runtime.h"
 
 #if _FX_OS_ == _FX_ANDROID_
 #include "time.h"
@@ -146,20 +145,22 @@ FX_BOOL CFX_SystemHandler::FindNativeTrueTypeFont(
     int32_t nCharset,
     CFX_ByteString sFontFaceName) {
   CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr();
-  if (pFontMgr) {
-    CFX_FontMapper* pFontMapper = pFontMgr->m_pBuiltinMapper;
-    if (pFontMapper) {
-      int nSize = pFontMapper->m_InstalledTTFonts.GetSize();
-      if (nSize == 0) {
-        pFontMapper->LoadInstalledFonts();
-        nSize = pFontMapper->m_InstalledTTFonts.GetSize();
-      }
+  if (!pFontMgr)
+    return FALSE;
 
-      for (int i = 0; i < nSize; i++) {
-        if (pFontMapper->m_InstalledTTFonts[i].Compare(sFontFaceName))
-          return TRUE;
-      }
-    }
+  CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper();
+  if (!pFontMapper)
+    return FALSE;
+
+  int nSize = pFontMapper->m_InstalledTTFonts.GetSize();
+  if (nSize == 0) {
+    pFontMapper->LoadInstalledFonts();
+    nSize = pFontMapper->m_InstalledTTFonts.GetSize();
+  }
+
+  for (int i = 0; i < nSize; ++i) {
+    if (pFontMapper->m_InstalledTTFonts[i].Compare(sFontFaceName))
+      return TRUE;
   }
 
   return FALSE;
@@ -224,6 +225,7 @@ CPDFDoc_Environment::~CPDFDoc_Environment() {
 
   delete m_pAnnotHandlerMgr;
   m_pAnnotHandlerMgr = NULL;
+
   delete m_pActionHandler;
   m_pActionHandler = NULL;
 }
@@ -370,11 +372,11 @@ void CPDFDoc_Environment::JS_docmailForm(void* mailData,
   }
 }
 
-IFXJS_Runtime* CPDFDoc_Environment::GetJSRuntime() {
+IJS_Runtime* CPDFDoc_Environment::GetJSRuntime() {
   if (!IsJSInitiated())
     return NULL;
   if (!m_pJSRuntime)
-    m_pJSRuntime.reset(new CJS_Runtime(this));
+    m_pJSRuntime.reset(IJS_Runtime::Create(this));
   return m_pJSRuntime.get();
 }
 
@@ -477,11 +479,10 @@ FX_BOOL CPDFSDK_Document::ProcOpenAction() {
   if (!pOpenAction)
     return FALSE;
 
-  if (pOpenAction->GetType() == PDFOBJ_ARRAY)
+  if (pOpenAction->IsArray())
     return TRUE;
 
-  if (pOpenAction->GetType() == PDFOBJ_DICTIONARY) {
-    CPDF_Dictionary* pDict = (CPDF_Dictionary*)pOpenAction;
+  if (CPDF_Dictionary* pDict = pOpenAction->AsDictionary()) {
     CPDF_Action action(pDict);
     if (m_pEnv->GetActionHander())
       m_pEnv->GetActionHander()->DoAction_DocOpen(action, this);
@@ -594,7 +595,7 @@ FX_BOOL CPDFSDK_Document::GetPermissions(int nFlag) {
   return dwPermissions & nFlag;
 }
 
-IFXJS_Runtime* CPDFSDK_Document::GetJsRuntime() {
+IJS_Runtime* CPDFSDK_Document::GetJsRuntime() {
   ASSERT(m_pEnv != NULL);
   return m_pEnv->GetJSRuntime();
 }
@@ -660,11 +661,9 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice,
 
   CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
   CPDFSDK_AnnotIterator annotIterator(this, TRUE);
-  CPDFSDK_Annot* pSDKAnnot = nullptr;
   int index = -1;
-  while ((pSDKAnnot = annotIterator.Next(index))) {
+  while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next(index)) {
     CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
-    ASSERT(pAnnotHandlerMgr);
     pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0);
   }
 }