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/fsdk_mgr.h" | 8 #include "fpdfsdk/include/fsdk_mgr.h" |
9 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" | 9 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" |
10 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h" | 10 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 void CPDFXFA_App::ReleaseInstance() { | 24 void CPDFXFA_App::ReleaseInstance() { |
25 delete g_pApp; | 25 delete g_pApp; |
26 g_pApp = NULL; | 26 g_pApp = NULL; |
27 } | 27 } |
28 | 28 |
29 CPDFXFA_App::CPDFXFA_App() | 29 CPDFXFA_App::CPDFXFA_App() |
30 : m_bJavaScriptInitialized(FALSE), | 30 : m_bJavaScriptInitialized(FALSE), |
31 m_pXFAApp(NULL), | 31 m_pXFAApp(NULL), |
32 m_pFontMgr(NULL), | 32 m_pFontMgr(NULL), |
33 m_hJSERuntime(NULL), | 33 m_hJSERuntime(NULL), |
34 m_csAppType(JS_STR_VIEWERTYPE_STANDARD) { | 34 m_csAppType(JS_STR_VIEWERTYPE_STANDARD), |
| 35 m_bOwnedRuntime(false) { |
35 m_pEnvList.RemoveAll(); | 36 m_pEnvList.RemoveAll(); |
36 } | 37 } |
37 | 38 |
38 CPDFXFA_App::~CPDFXFA_App() { | 39 CPDFXFA_App::~CPDFXFA_App() { |
39 delete m_pFontMgr; | 40 delete m_pFontMgr; |
40 m_pFontMgr = NULL; | 41 m_pFontMgr = NULL; |
41 | 42 |
42 delete m_pXFAApp; | 43 delete m_pXFAApp; |
43 m_pXFAApp = NULL; | 44 m_pXFAApp = NULL; |
44 | 45 |
45 #ifdef PDF_ENABLE_XFA | 46 #ifdef PDF_ENABLE_XFA |
46 FXJSE_Runtime_Release(m_hJSERuntime); | 47 FXJSE_Runtime_Release(m_hJSERuntime, m_bOwnedRuntime); |
47 m_hJSERuntime = NULL; | 48 m_hJSERuntime = NULL; |
48 | 49 |
49 FXJSE_Finalize(); | 50 FXJSE_Finalize(); |
50 BC_Library_Destory(); | 51 BC_Library_Destory(); |
51 #endif | 52 #endif |
52 } | 53 } |
53 | 54 |
54 FX_BOOL CPDFXFA_App::Initialize() { | 55 FX_BOOL CPDFXFA_App::Initialize(FXJSE_HRUNTIME hRuntime) { |
55 #ifdef PDF_ENABLE_XFA | 56 #ifdef PDF_ENABLE_XFA |
56 BC_Library_Init(); | 57 BC_Library_Init(); |
57 FXJSE_Initialize(); | 58 FXJSE_Initialize(); |
58 | 59 |
59 m_hJSERuntime = FXJSE_Runtime_Create(); | 60 m_bOwnedRuntime = !hRuntime; |
| 61 m_hJSERuntime = hRuntime ? hRuntime : FXJSE_Runtime_Create(); |
60 if (!m_hJSERuntime) | 62 if (!m_hJSERuntime) |
61 return FALSE; | 63 return FALSE; |
62 | 64 |
63 m_pXFAApp = IXFA_App::Create(this); | 65 m_pXFAApp = IXFA_App::Create(this); |
64 if (!m_pXFAApp) | 66 if (!m_pXFAApp) |
65 return FALSE; | 67 return FALSE; |
66 | 68 |
67 m_pFontMgr = IXFA_FontMgr::CreateDefault(); | 69 m_pFontMgr = IXFA_FontMgr::CreateDefault(); |
68 if (!m_pFontMgr) | 70 if (!m_pFontMgr) |
69 return FALSE; | 71 return FALSE; |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 return FALSE; | 530 return FALSE; |
529 } | 531 } |
530 | 532 |
531 IFWL_AdapterTimerMgr* CPDFXFA_App::GetTimerMgr() { | 533 IFWL_AdapterTimerMgr* CPDFXFA_App::GetTimerMgr() { |
532 CXFA_FWLAdapterTimerMgr* pAdapter = NULL; | 534 CXFA_FWLAdapterTimerMgr* pAdapter = NULL; |
533 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 535 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); |
534 if (pEnv) | 536 if (pEnv) |
535 pAdapter = new CXFA_FWLAdapterTimerMgr(pEnv); | 537 pAdapter = new CXFA_FWLAdapterTimerMgr(pEnv); |
536 return pAdapter; | 538 return pAdapter; |
537 } | 539 } |
OLD | NEW |