| 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_pXFADoc) { | 48 if (m_pJSContext && m_pSDKDoc && m_pSDKDoc->GetEnv()) |
| 49 IXFA_App* pApp = m_pApp->GetXFAApp(); | 49 m_pSDKDoc->GetEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext); |
| 50 if (pApp) { | 50 |
| 51 IXFA_DocHandler* pDocHandler = pApp->GetDocHandler(); | 51 delete m_pSDKDoc; |
| 52 if (pDocHandler) | 52 |
| 53 CloseXFADoc(pDocHandler); | |
| 54 } | |
| 55 delete m_pXFADoc; | |
| 56 m_pXFADoc = nullptr; | |
| 57 } | |
| 58 if (m_pPDFDoc) { | 53 if (m_pPDFDoc) { |
| 59 CPDF_Parser* pParser = m_pPDFDoc->GetParser(); | 54 CPDF_Parser* pParser = m_pPDFDoc->GetParser(); |
| 60 if (pParser) | 55 if (pParser) |
| 61 delete pParser; | 56 delete pParser; |
| 62 else | 57 else |
| 63 delete m_pPDFDoc; | 58 delete m_pPDFDoc; |
| 64 } | 59 } |
| 65 if (m_pJSContext && m_pSDKDoc && m_pSDKDoc->GetEnv()) | 60 if (m_pXFADoc) { |
| 66 m_pSDKDoc->GetEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext); | 61 IXFA_App* pApp = m_pApp->GetXFAApp(); |
| 67 delete m_pSDKDoc; | 62 if (pApp) { |
| 63 IXFA_DocHandler* pDocHandler = pApp->GetDocHandler(); |
| 64 if (pDocHandler) { |
| 65 CloseXFADoc(pDocHandler); |
| 66 } |
| 67 } |
| 68 delete m_pXFADoc; |
| 69 } |
| 68 } | 70 } |
| 69 | 71 |
| 70 FX_BOOL CPDFXFA_Document::LoadXFADoc() { | 72 FX_BOOL CPDFXFA_Document::LoadXFADoc() { |
| 71 if (!m_pPDFDoc) | 73 if (!m_pPDFDoc) |
| 72 return FALSE; | 74 return FALSE; |
| 73 | 75 |
| 74 m_XFAPageList.RemoveAll(); | 76 m_XFAPageList.RemoveAll(); |
| 75 | 77 |
| 76 IXFA_App* pApp = m_pApp->GetXFAApp(); | 78 IXFA_App* pApp = m_pApp->GetXFAApp(); |
| 77 if (!pApp) | 79 if (!pApp) |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 if (dwFlags == XFA_PAGEVIEWEVENT_PostAdded) { | 480 if (dwFlags == XFA_PAGEVIEWEVENT_PostAdded) { |
| 479 pPage = GetPage(pPageView->GetPageViewIndex()); | 481 pPage = GetPage(pPageView->GetPageViewIndex()); |
| 480 if (pPage) | 482 if (pPage) |
| 481 pPage->SetXFAPageView(pPageView); | 483 pPage->SetXFAPageView(pPageView); |
| 482 return; | 484 return; |
| 483 } | 485 } |
| 484 pPage = GetPage(pPageView); | 486 pPage = GetPage(pPageView); |
| 485 if (!pPage) | 487 if (!pPage) |
| 486 return; | 488 return; |
| 487 pPage->SetXFAPageView(nullptr); | 489 pPage->SetXFAPageView(nullptr); |
| 490 m_pSDKDoc->GetPageView(pPage)->ClearFXAnnots(); |
| 488 } | 491 } |
| 489 | 492 |
| 490 void CPDFXFA_Document::WidgetEvent(IXFA_Widget* hWidget, | 493 void CPDFXFA_Document::WidgetEvent(IXFA_Widget* hWidget, |
| 491 CXFA_WidgetAcc* pWidgetData, | 494 CXFA_WidgetAcc* pWidgetData, |
| 492 FX_DWORD dwEvent, | 495 FX_DWORD dwEvent, |
| 493 void* pParam, | 496 void* pParam, |
| 494 void* pAdditional) { | 497 void* pAdditional) { |
| 495 if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget) | 498 if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget) |
| 496 return; | 499 return; |
| 497 | 500 |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1253 } | 1256 } |
| 1254 | 1257 |
| 1255 return _GetHValueByName(szPropName, hValue, | 1258 return _GetHValueByName(szPropName, hValue, |
| 1256 m_pSDKDoc->GetEnv()->GetJSRuntime()); | 1259 m_pSDKDoc->GetEnv()->GetJSRuntime()); |
| 1257 } | 1260 } |
| 1258 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, | 1261 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, |
| 1259 FXJSE_HVALUE hValue, | 1262 FXJSE_HVALUE hValue, |
| 1260 IJS_Runtime* runTime) { | 1263 IJS_Runtime* runTime) { |
| 1261 return runTime->GetHValueByName(utf8Name, hValue); | 1264 return runTime->GetHValueByName(utf8Name, hValue); |
| 1262 } | 1265 } |
| OLD | NEW |