OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "fpdfsdk/include/fsdk_define.h" | 7 #include "fpdfsdk/include/fsdk_define.h" |
8 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" | 8 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" |
9 #include "fpdfsdk/include/fsdk_mgr.h" | 9 #include "fpdfsdk/include/fsdk_mgr.h" |
10 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h" | 10 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 : m_iDocType(DOCTYPE_PDF), | 38 : m_iDocType(DOCTYPE_PDF), |
39 m_pPDFDoc(pPDFDoc), | 39 m_pPDFDoc(pPDFDoc), |
40 m_pSDKDoc(nullptr), | 40 m_pSDKDoc(nullptr), |
41 m_pXFADoc(nullptr), | 41 m_pXFADoc(nullptr), |
42 m_pXFADocView(nullptr), | 42 m_pXFADocView(nullptr), |
43 m_pApp(pProvider), | 43 m_pApp(pProvider), |
44 m_pJSContext(nullptr) { | 44 m_pJSContext(nullptr) { |
45 } | 45 } |
46 | 46 |
47 CPDFXFA_Document::~CPDFXFA_Document() { | 47 CPDFXFA_Document::~CPDFXFA_Document() { |
48 if (m_pJSContext && m_pSDKDoc && m_pSDKDoc->GetEnv()) | 48 if (m_pXFADoc) { |
49 m_pSDKDoc->GetEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext); | 49 IXFA_App* pApp = m_pApp->GetXFAApp(); |
50 | 50 if (pApp) { |
51 delete m_pSDKDoc; | 51 IXFA_DocHandler* pDocHandler = pApp->GetDocHandler(); |
52 | 52 if (pDocHandler) |
| 53 CloseXFADoc(pDocHandler); |
| 54 } |
| 55 delete m_pXFADoc; |
| 56 m_pXFADoc = nullptr; |
| 57 } |
53 if (m_pPDFDoc) { | 58 if (m_pPDFDoc) { |
54 CPDF_Parser* pParser = m_pPDFDoc->GetParser(); | 59 CPDF_Parser* pParser = m_pPDFDoc->GetParser(); |
55 if (pParser) | 60 if (pParser) |
56 delete pParser; | 61 delete pParser; |
57 else | 62 else |
58 delete m_pPDFDoc; | 63 delete m_pPDFDoc; |
59 } | 64 } |
60 if (m_pXFADoc) { | 65 if (m_pJSContext && m_pSDKDoc && m_pSDKDoc->GetEnv()) |
61 IXFA_App* pApp = m_pApp->GetXFAApp(); | 66 m_pSDKDoc->GetEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext); |
62 if (pApp) { | 67 delete m_pSDKDoc; |
63 IXFA_DocHandler* pDocHandler = pApp->GetDocHandler(); | |
64 if (pDocHandler) { | |
65 CloseXFADoc(pDocHandler); | |
66 } | |
67 } | |
68 delete m_pXFADoc; | |
69 } | |
70 } | 68 } |
71 | 69 |
72 FX_BOOL CPDFXFA_Document::LoadXFADoc() { | 70 FX_BOOL CPDFXFA_Document::LoadXFADoc() { |
73 if (!m_pPDFDoc) | 71 if (!m_pPDFDoc) |
74 return FALSE; | 72 return FALSE; |
75 | 73 |
76 m_XFAPageList.RemoveAll(); | 74 m_XFAPageList.RemoveAll(); |
77 | 75 |
78 IXFA_App* pApp = m_pApp->GetXFAApp(); | 76 IXFA_App* pApp = m_pApp->GetXFAApp(); |
79 if (!pApp) | 77 if (!pApp) |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 if (dwFlags == XFA_PAGEVIEWEVENT_PostAdded) { | 478 if (dwFlags == XFA_PAGEVIEWEVENT_PostAdded) { |
481 pPage = GetPage(pPageView->GetPageViewIndex()); | 479 pPage = GetPage(pPageView->GetPageViewIndex()); |
482 if (pPage) | 480 if (pPage) |
483 pPage->SetXFAPageView(pPageView); | 481 pPage->SetXFAPageView(pPageView); |
484 return; | 482 return; |
485 } | 483 } |
486 pPage = GetPage(pPageView); | 484 pPage = GetPage(pPageView); |
487 if (!pPage) | 485 if (!pPage) |
488 return; | 486 return; |
489 pPage->SetXFAPageView(nullptr); | 487 pPage->SetXFAPageView(nullptr); |
490 m_pSDKDoc->GetPageView(pPage)->ClearFXAnnots(); | |
491 } | 488 } |
492 | 489 |
493 void CPDFXFA_Document::WidgetEvent(IXFA_Widget* hWidget, | 490 void CPDFXFA_Document::WidgetEvent(IXFA_Widget* hWidget, |
494 CXFA_WidgetAcc* pWidgetData, | 491 CXFA_WidgetAcc* pWidgetData, |
495 FX_DWORD dwEvent, | 492 FX_DWORD dwEvent, |
496 void* pParam, | 493 void* pParam, |
497 void* pAdditional) { | 494 void* pAdditional) { |
498 if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget) | 495 if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget) |
499 return; | 496 return; |
500 | 497 |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 } | 1253 } |
1257 | 1254 |
1258 return _GetHValueByName(szPropName, hValue, | 1255 return _GetHValueByName(szPropName, hValue, |
1259 m_pSDKDoc->GetEnv()->GetJSRuntime()); | 1256 m_pSDKDoc->GetEnv()->GetJSRuntime()); |
1260 } | 1257 } |
1261 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, | 1258 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, |
1262 FXJSE_HVALUE hValue, | 1259 FXJSE_HVALUE hValue, |
1263 IJS_Runtime* runTime) { | 1260 IJS_Runtime* runTime) { |
1264 return runTime->GetHValueByName(utf8Name, hValue); | 1261 return runTime->GetHValueByName(utf8Name, hValue); |
1265 } | 1262 } |
OLD | NEW |