summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_context.cpp5
-rw-r--r--xfa/fxfa/cxfa_ffdoc.cpp79
-rw-r--r--xfa/fxfa/cxfa_ffdoc.h4
3 files changed, 42 insertions, 46 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
index 5553025371..0ba7f31995 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
@@ -96,14 +96,13 @@ bool CPDFXFA_Context::LoadXFADoc() {
return false;
}
- m_pXFADoc->StartLoad();
- int iStatus = m_pXFADoc->DoLoad();
+ int iStatus = m_pXFADoc->Load();
if (iStatus != XFA_PARSESTATUS_Done) {
CloseXFADoc();
SetLastError(FPDF_ERR_XFALOAD);
return false;
}
- m_pXFADoc->StopLoad();
+
m_pXFADoc->GetXFADoc()->InitScriptContext(GetCJSRuntime());
if (m_pXFADoc->GetFormType() == FormType::kXFAFull)
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index 52ad5f692d..ad7bbd9531 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -165,10 +165,47 @@ CXFA_FFDoc::~CXFA_FFDoc() {
CloseDoc();
}
-int32_t CXFA_FFDoc::StartLoad() {
+int32_t CXFA_FFDoc::Load() {
m_pNotify = pdfium::MakeUnique<CXFA_FFNotify>(this);
m_pDocumentParser = pdfium::MakeUnique<CXFA_DocumentParser>(m_pNotify.get());
- return m_pDocumentParser->StartParse(m_pStream, XFA_PacketType::Xdp);
+ m_pDocumentParser->StartParse(m_pStream, XFA_PacketType::Xdp);
+
+ int32_t iStatus = m_pDocumentParser->DoParse();
+ if (iStatus != XFA_PARSESTATUS_Done)
+ return iStatus;
+ if (!m_pPDFDoc)
+ return XFA_PARSESTATUS_SyntaxErr;
+
+ m_pPDFFontMgr = pdfium::MakeUnique<CFGAS_PDFFontMgr>(
+ GetPDFDoc(), GetApp()->GetFDEFontMgr());
+
+ m_FormType = FormType::kXFAForeground;
+ CXFA_Node* pConfig = ToNode(
+ m_pDocumentParser->GetDocument()->GetXFAObject(XFA_HASHCODE_Config));
+ if (!pConfig)
+ return iStatus;
+
+ CXFA_Acrobat* pAcrobat =
+ pConfig->GetFirstChildByClass<CXFA_Acrobat>(XFA_Element::Acrobat);
+ if (!pAcrobat)
+ return iStatus;
+
+ CXFA_Acrobat7* pAcrobat7 =
+ pAcrobat->GetFirstChildByClass<CXFA_Acrobat7>(XFA_Element::Acrobat7);
+ if (!pAcrobat7)
+ return iStatus;
+
+ CXFA_DynamicRender* pDynamicRender =
+ pAcrobat7->GetFirstChildByClass<CXFA_DynamicRender>(
+ XFA_Element::DynamicRender);
+ if (!pDynamicRender)
+ return iStatus;
+
+ WideString wsType = pDynamicRender->JSObject()->GetContent(false);
+ if (wsType == L"required")
+ m_FormType = FormType::kXFAFull;
+
+ return iStatus;
}
bool XFA_GetPDFContentsFromPDFXML(CFX_XMLNode* pPDFElement,
@@ -229,44 +266,6 @@ void XFA_XPDPacket_MergeRootNode(CXFA_Node* pOriginRoot, CXFA_Node* pNewRoot) {
}
}
-int32_t CXFA_FFDoc::DoLoad() {
- int32_t iStatus = m_pDocumentParser->DoParse();
- if (iStatus == XFA_PARSESTATUS_Done && !m_pPDFDoc)
- return XFA_PARSESTATUS_SyntaxErr;
- return iStatus;
-}
-
-void CXFA_FFDoc::StopLoad() {
- m_pPDFFontMgr = pdfium::MakeUnique<CFGAS_PDFFontMgr>(
- GetPDFDoc(), GetApp()->GetFDEFontMgr());
-
- m_FormType = FormType::kXFAForeground;
- CXFA_Node* pConfig = ToNode(
- m_pDocumentParser->GetDocument()->GetXFAObject(XFA_HASHCODE_Config));
- if (!pConfig)
- return;
-
- CXFA_Acrobat* pAcrobat =
- pConfig->GetFirstChildByClass<CXFA_Acrobat>(XFA_Element::Acrobat);
- if (!pAcrobat)
- return;
-
- CXFA_Acrobat7* pAcrobat7 =
- pAcrobat->GetFirstChildByClass<CXFA_Acrobat7>(XFA_Element::Acrobat7);
- if (!pAcrobat7)
- return;
-
- CXFA_DynamicRender* pDynamicRender =
- pAcrobat7->GetFirstChildByClass<CXFA_DynamicRender>(
- XFA_Element::DynamicRender);
- if (!pDynamicRender)
- return;
-
- WideString wsType = pDynamicRender->JSObject()->GetContent(false);
- if (wsType == L"required")
- m_FormType = FormType::kXFAFull;
-}
-
CXFA_FFDocView* CXFA_FFDoc::CreateDocView() {
if (!m_DocView)
m_DocView = pdfium::MakeUnique<CXFA_FFDocView>(this);
diff --git a/xfa/fxfa/cxfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h
index ffa8bcc1d2..14bae5973a 100644
--- a/xfa/fxfa/cxfa_ffdoc.h
+++ b/xfa/fxfa/cxfa_ffdoc.h
@@ -58,9 +58,7 @@ class CXFA_FFDoc {
}
FormType GetFormType() const { return m_FormType; }
- int32_t StartLoad();
- int32_t DoLoad();
- void StopLoad();
+ int32_t Load();
CXFA_FFDocView* CreateDocView();