From 404e7e76fa8007468bd0ef58305ccff1895dfbf7 Mon Sep 17 00:00:00 2001 From: JUN FANG Date: Mon, 9 Mar 2015 14:57:38 -0700 Subject: Remove the calling 'FPDF_HasXFAField' in LoadXFADoc BUG=NA R=tsepez@chromium.org Review URL: https://codereview.chromium.org/983253004 --- fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp | 86 ++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 50 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp index f13870697b..87fb9d21ce 100644 --- a/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp +++ b/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp @@ -92,64 +92,50 @@ FX_BOOL CPDFXFA_Document::LoadXFADoc() m_XFAPageList.RemoveAll(); - int iDocType = DOCTYPE_PDF; - FX_BOOL hasXFAField = FPDF_HasXFAField(m_pPDFDoc, iDocType); + IXFA_App* pApp = m_pApp->GetXFAApp(); + if (!pApp) + return FALSE; - if (hasXFAField) + m_pXFADoc = pApp->CreateDoc(this, m_pPDFDoc); + if (!m_pXFADoc) { - IXFA_App* pApp = m_pApp->GetXFAApp(); - if (pApp) - { - m_pXFADoc = pApp->CreateDoc(this, m_pPDFDoc); - if (!m_pXFADoc) - { - SetLastError(FPDF_ERR_XFALOAD); - return FALSE; - } - - IXFA_DocHandler* pDocHandler = pApp->GetDocHandler(); - if (pDocHandler) - { - int iStatus = pDocHandler->StartLoad(m_pXFADoc); - iStatus = pDocHandler->DoLoad(m_pXFADoc, NULL); - if (iStatus != 100) - { - CloseXFADoc(pDocHandler); - SetLastError(FPDF_ERR_XFALOAD); - return FALSE; - } - pDocHandler->StopLoad(m_pXFADoc); - pDocHandler->SetJSERuntime(m_pXFADoc, m_pApp->GetJSERuntime()); - - if (pDocHandler->GetDocType(m_pXFADoc) == XFA_DOCTYPE_Dynamic) - m_iDocType = DOCTYPE_DYNIMIC_XFA; - else - m_iDocType = DOCTYPE_STATIC_XFA; - - m_pXFADocView = pDocHandler->CreateDocView(m_pXFADoc, XFA_DOCVIEW_View); - FXSYS_assert(m_pXFADocView); + SetLastError(FPDF_ERR_XFALOAD); + return FALSE; + } - if (m_pXFADocView->StartLayout() < 0) - { - CloseXFADoc(pDocHandler); - SetLastError(FPDF_ERR_XFALAYOUT); - return FALSE; - } - else - { - m_pXFADocView->DoLayout(NULL); - m_pXFADocView->StopLayout(); + IXFA_DocHandler* pDocHandler = pApp->GetDocHandler(); + if (!pDocHandler) + { + SetLastError(FPDF_ERR_XFALOAD); + return FALSE; + } - return TRUE; - } - } + pDocHandler->StartLoad(m_pXFADoc); + int iStatus = pDocHandler->DoLoad(m_pXFADoc, NULL); + if (iStatus != XFA_PARSESTATUS_Done) + { + CloseXFADoc(pDocHandler); + SetLastError(FPDF_ERR_XFALOAD); + return FALSE; + } + pDocHandler->StopLoad(m_pXFADoc); + pDocHandler->SetJSERuntime(m_pXFADoc, m_pApp->GetJSERuntime()); - return FALSE; - } + if (pDocHandler->GetDocType(m_pXFADoc) == XFA_DOCTYPE_Dynamic) + m_iDocType = DOCTYPE_DYNIMIC_XFA; + else + m_iDocType = DOCTYPE_STATIC_XFA; + m_pXFADocView = pDocHandler->CreateDocView(m_pXFADoc, XFA_DOCVIEW_View); + if (m_pXFADocView->StartLayout() < 0) + { + CloseXFADoc(pDocHandler); + SetLastError(FPDF_ERR_XFALAYOUT); return FALSE; } - + + m_pXFADocView->DoLayout(NULL); + m_pXFADocView->StopLayout(); return TRUE; } -- cgit v1.2.3