Remove the calling 'FPDF_HasXFAField' in LoadXFADoc
authorJUN FANG <jun_fang@foxitsoftware.com>
Mon, 9 Mar 2015 21:57:38 +0000 (14:57 -0700)
committerJUN FANG <jun_fang@foxitsoftware.com>
Mon, 9 Mar 2015 21:57:38 +0000 (14:57 -0700)
BUG=NA
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/983253004

fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp

index f138706..87fb9d2 100644 (file)
@@ -92,64 +92,50 @@ FX_BOOL CPDFXFA_Document::LoadXFADoc()
 \r
        m_XFAPageList.RemoveAll();\r
 \r
-       int iDocType = DOCTYPE_PDF;\r
-       FX_BOOL hasXFAField = FPDF_HasXFAField(m_pPDFDoc, iDocType);\r
+       IXFA_App* pApp = m_pApp->GetXFAApp();\r
+       if (!pApp)\r
+               return FALSE;\r
 \r
-       if (hasXFAField)\r
+       m_pXFADoc = pApp->CreateDoc(this, m_pPDFDoc);\r
+       if (!m_pXFADoc)\r
        {\r
-               IXFA_App* pApp = m_pApp->GetXFAApp();\r
-               if (pApp)\r
-               {\r
-                       m_pXFADoc = pApp->CreateDoc(this, m_pPDFDoc);\r
-                       if (!m_pXFADoc)\r
-                       {\r
-                               SetLastError(FPDF_ERR_XFALOAD);\r
-                               return FALSE;\r
-                       }\r
-\r
-                       IXFA_DocHandler* pDocHandler = pApp->GetDocHandler();\r
-                       if (pDocHandler)\r
-                       {\r
-                               int iStatus = pDocHandler->StartLoad(m_pXFADoc);\r
-                               iStatus = pDocHandler->DoLoad(m_pXFADoc, NULL);\r
-                               if (iStatus != 100) \r
-                               {\r
-                                       CloseXFADoc(pDocHandler);\r
-                                       SetLastError(FPDF_ERR_XFALOAD);\r
-                                       return FALSE;\r
-                               }\r
-                               pDocHandler->StopLoad(m_pXFADoc);\r
-                               pDocHandler->SetJSERuntime(m_pXFADoc, m_pApp->GetJSERuntime());\r
-\r
-                               if (pDocHandler->GetDocType(m_pXFADoc) == XFA_DOCTYPE_Dynamic)\r
-                                       m_iDocType = DOCTYPE_DYNIMIC_XFA;\r
-                               else\r
-                                       m_iDocType = DOCTYPE_STATIC_XFA;\r
-\r
-                               m_pXFADocView = pDocHandler->CreateDocView(m_pXFADoc, XFA_DOCVIEW_View);\r
-                               FXSYS_assert(m_pXFADocView);\r
+               SetLastError(FPDF_ERR_XFALOAD);\r
+               return FALSE;\r
+       }\r
 \r
-                               if (m_pXFADocView->StartLayout() < 0) \r
-                               {\r
-                                       CloseXFADoc(pDocHandler);\r
-                                       SetLastError(FPDF_ERR_XFALAYOUT);\r
-                                       return FALSE;\r
-                               }\r
-                               else\r
-                               {\r
-                                       m_pXFADocView->DoLayout(NULL);\r
-                                       m_pXFADocView->StopLayout();\r
+       IXFA_DocHandler* pDocHandler = pApp->GetDocHandler();\r
+       if (!pDocHandler)\r
+       {\r
+               SetLastError(FPDF_ERR_XFALOAD);\r
+               return FALSE;\r
+       }\r
 \r
-                                       return TRUE;\r
-                               }                               \r
-                       }\r
+       pDocHandler->StartLoad(m_pXFADoc);\r
+       int iStatus = pDocHandler->DoLoad(m_pXFADoc, NULL);\r
+       if (iStatus != XFA_PARSESTATUS_Done) \r
+       {\r
+               CloseXFADoc(pDocHandler);\r
+               SetLastError(FPDF_ERR_XFALOAD);\r
+               return FALSE;\r
+       }\r
+       pDocHandler->StopLoad(m_pXFADoc);\r
+       pDocHandler->SetJSERuntime(m_pXFADoc, m_pApp->GetJSERuntime());\r
 \r
-                       return FALSE;\r
-               }\r
+       if (pDocHandler->GetDocType(m_pXFADoc) == XFA_DOCTYPE_Dynamic)\r
+               m_iDocType = DOCTYPE_DYNIMIC_XFA;\r
+       else\r
+               m_iDocType = DOCTYPE_STATIC_XFA;\r
 \r
+       m_pXFADocView = pDocHandler->CreateDocView(m_pXFADoc, XFA_DOCVIEW_View);\r
+       if (m_pXFADocView->StartLayout() < 0)\r
+       {\r
+               CloseXFADoc(pDocHandler);\r
+               SetLastError(FPDF_ERR_XFALAYOUT);\r
                return FALSE;\r
        }\r
-       \r
+\r
+       m_pXFADocView->DoLayout(NULL);\r
+       m_pXFADocView->StopLayout();\r
        return TRUE;\r
 }\r
 \r