Index: fpdfsdk/fpdfxfa/cpdfxfa_document.cpp |
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_document.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_document.cpp |
index 79d28c0637ffcd2480d653de491ec0b7e479c3f3..df0da31beb1d304f5dcce1712970e618c03479ef 100644 |
--- a/fpdfsdk/fpdfxfa/cpdfxfa_document.cpp |
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_document.cpp |
@@ -16,7 +16,6 @@ |
#include "fpdfsdk/fsdk_define.h" |
#include "fpdfsdk/javascript/ijs_runtime.h" |
#include "public/fpdf_formfill.h" |
-#include "third_party/base/ptr_util.h" |
#include "xfa/fxfa/cxfa_eventparam.h" |
#include "xfa/fxfa/xfa_ffapp.h" |
#include "xfa/fxfa/xfa_ffdoc.h" |
@@ -29,23 +28,19 @@ |
extern int GetLastError(); |
#endif |
-CPDFXFA_Document::CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc) |
+CPDFXFA_Document::CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc, |
+ CPDFXFA_App* pProvider) |
: m_iDocType(DOCTYPE_PDF), |
m_pPDFDoc(std::move(pPDFDoc)), |
m_pFormFillEnv(nullptr), |
m_pXFADocView(nullptr), |
+ m_pApp(pProvider), |
m_nLoadStatus(FXFA_LOADSTATUS_PRELOAD), |
m_nPageCount(0), |
m_DocEnv(this) {} |
CPDFXFA_Document::~CPDFXFA_Document() { |
m_nLoadStatus = FXFA_LOADSTATUS_CLOSING; |
- |
- // Must happen before we remove the form fill environment. |
- if (m_pXFADoc) { |
- if (CXFA_FFApp* pApp = GetApp()->GetXFAApp()) |
- CloseXFADoc(pApp->GetDocHandler()); |
- } |
if (m_pFormFillEnv) { |
m_pFormFillEnv->ClearAllFocusedAnnots(); |
@@ -55,21 +50,17 @@ |
m_pFormFillEnv = nullptr; |
} |
+ if (m_pXFADoc) { |
+ CXFA_FFApp* pApp = m_pApp->GetXFAApp(); |
+ if (pApp) { |
+ CXFA_FFDocHandler* pDocHandler = pApp->GetDocHandler(); |
+ if (pDocHandler) |
+ CloseXFADoc(pDocHandler); |
+ } |
+ m_pXFADoc.reset(); |
+ } |
+ |
m_nLoadStatus = FXFA_LOADSTATUS_CLOSED; |
-} |
- |
-void CPDFXFA_Document::CloseXFADoc(CXFA_FFDocHandler* pDoc) { |
- if (!pDoc) |
- return; |
- m_pXFADoc->CloseDoc(); |
- m_pXFADoc.reset(); |
- m_pXFADocView = nullptr; |
-} |
- |
-CPDFXFA_App* CPDFXFA_Document::GetApp() { |
- if (!m_pApp) |
- m_pApp = pdfium::MakeUnique<CPDFXFA_App>(); |
- return m_pApp.get(); |
} |
FX_BOOL CPDFXFA_Document::LoadXFADoc() { |
@@ -80,7 +71,7 @@ |
m_XFAPageList.RemoveAll(); |
- CXFA_FFApp* pApp = GetApp()->GetXFAApp(); |
+ CXFA_FFApp* pApp = m_pApp->GetXFAApp(); |
if (!pApp) |
return FALSE; |
@@ -104,7 +95,7 @@ |
return FALSE; |
} |
m_pXFADoc->StopLoad(); |
- m_pXFADoc->GetXFADoc()->InitScriptContext(GetApp()->GetJSERuntime()); |
+ m_pXFADoc->GetXFADoc()->InitScriptContext(m_pApp->GetJSERuntime()); |
if (m_pXFADoc->GetDocType() == XFA_DOCTYPE_Dynamic) |
m_iDocType = DOCTYPE_DYNAMIC_XFA; |