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/fpdfxfa/fpdfxfa_app.h" | 7 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h" |
8 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" | 8 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" |
9 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h" | 9 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h" |
10 #include "fpdfsdk/include/fsdk_define.h" | 10 #include "fpdfsdk/include/fsdk_define.h" |
11 #include "fpdfsdk/include/fsdk_mgr.h" | 11 #include "fpdfsdk/include/fsdk_mgr.h" |
12 #include "public/fpdf_formfill.h" | 12 #include "public/fpdf_formfill.h" |
13 #include "xfa/fxbarcode/include/BC_Library.h" | 13 #include "xfa/fxbarcode/include/BC_Library.h" |
| 14 #include "xfa/include/fxfa/xfa_ffapp.h" |
| 15 #include "xfa/include/fxfa/xfa_fontmgr.h" |
14 | 16 |
15 CPDFXFA_App* CPDFXFA_App::g_pApp = NULL; | 17 CPDFXFA_App* CPDFXFA_App::g_pApp = NULL; |
16 | 18 |
17 CPDFXFA_App* CPDFXFA_App::GetInstance() { | 19 CPDFXFA_App* CPDFXFA_App::GetInstance() { |
18 if (!g_pApp) { | 20 if (!g_pApp) { |
19 g_pApp = new CPDFXFA_App(); | 21 g_pApp = new CPDFXFA_App(); |
20 } | 22 } |
21 return g_pApp; | 23 return g_pApp; |
22 } | 24 } |
23 | 25 |
24 void CPDFXFA_App::ReleaseInstance() { | 26 void CPDFXFA_App::ReleaseInstance() { |
25 delete g_pApp; | 27 delete g_pApp; |
26 g_pApp = NULL; | 28 g_pApp = NULL; |
27 } | 29 } |
28 | 30 |
29 CPDFXFA_App::CPDFXFA_App() | 31 CPDFXFA_App::CPDFXFA_App() |
30 : m_bJavaScriptInitialized(FALSE), | 32 : m_bJavaScriptInitialized(FALSE), |
31 m_pXFAApp(NULL), | 33 m_pXFAApp(NULL), |
32 m_pFontMgr(NULL), | |
33 m_hJSERuntime(NULL), | 34 m_hJSERuntime(NULL), |
34 m_csAppType(JS_STR_VIEWERTYPE_STANDARD), | 35 m_csAppType(JS_STR_VIEWERTYPE_STANDARD), |
35 m_bOwnedRuntime(false) { | 36 m_bOwnedRuntime(false) { |
36 m_pEnvList.RemoveAll(); | 37 m_pEnvList.RemoveAll(); |
37 } | 38 } |
38 | 39 |
39 CPDFXFA_App::~CPDFXFA_App() { | 40 CPDFXFA_App::~CPDFXFA_App() { |
40 delete m_pFontMgr; | |
41 m_pFontMgr = NULL; | |
42 | |
43 delete m_pXFAApp; | 41 delete m_pXFAApp; |
44 m_pXFAApp = NULL; | 42 m_pXFAApp = NULL; |
45 | 43 |
46 #ifdef PDF_ENABLE_XFA | 44 #ifdef PDF_ENABLE_XFA |
47 FXJSE_Runtime_Release(m_hJSERuntime, m_bOwnedRuntime); | 45 FXJSE_Runtime_Release(m_hJSERuntime, m_bOwnedRuntime); |
48 m_hJSERuntime = NULL; | 46 m_hJSERuntime = NULL; |
49 | 47 |
50 FXJSE_Finalize(); | 48 FXJSE_Finalize(); |
51 BC_Library_Destory(); | 49 BC_Library_Destory(); |
52 #endif | 50 #endif |
53 } | 51 } |
54 | 52 |
55 FX_BOOL CPDFXFA_App::Initialize(FXJSE_HRUNTIME hRuntime) { | 53 FX_BOOL CPDFXFA_App::Initialize(FXJSE_HRUNTIME hRuntime) { |
56 #ifdef PDF_ENABLE_XFA | 54 #ifdef PDF_ENABLE_XFA |
57 BC_Library_Init(); | 55 BC_Library_Init(); |
58 FXJSE_Initialize(); | 56 FXJSE_Initialize(); |
59 | 57 |
60 m_bOwnedRuntime = !hRuntime; | 58 m_bOwnedRuntime = !hRuntime; |
61 m_hJSERuntime = hRuntime ? hRuntime : FXJSE_Runtime_Create(); | 59 m_hJSERuntime = hRuntime ? hRuntime : FXJSE_Runtime_Create(); |
62 if (!m_hJSERuntime) | 60 if (!m_hJSERuntime) |
63 return FALSE; | 61 return FALSE; |
64 | 62 |
65 m_pXFAApp = IXFA_App::Create(this); | 63 m_pXFAApp = new CXFA_FFApp(this); |
66 if (!m_pXFAApp) | 64 m_pXFAApp->SetDefaultFontMgr(new CXFA_DefFontMgr); |
67 return FALSE; | |
68 | |
69 m_pFontMgr = IXFA_FontMgr::CreateDefault(); | |
70 if (!m_pFontMgr) | |
71 return FALSE; | |
72 | |
73 m_pXFAApp->SetDefaultFontMgr(m_pFontMgr); | |
74 #endif | 65 #endif |
75 return TRUE; | 66 return TRUE; |
76 } | 67 } |
77 | 68 |
78 FX_BOOL CPDFXFA_App::AddFormFillEnv(CPDFDoc_Environment* pEnv) { | 69 FX_BOOL CPDFXFA_App::AddFormFillEnv(CPDFDoc_Environment* pEnv) { |
79 if (!pEnv) | 70 if (!pEnv) |
80 return FALSE; | 71 return FALSE; |
81 | 72 |
82 m_pEnvList.Add(pEnv); | 73 m_pEnvList.Add(pEnv); |
83 return TRUE; | 74 return TRUE; |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 return FALSE; | 521 return FALSE; |
531 } | 522 } |
532 | 523 |
533 IFWL_AdapterTimerMgr* CPDFXFA_App::GetTimerMgr() { | 524 IFWL_AdapterTimerMgr* CPDFXFA_App::GetTimerMgr() { |
534 CXFA_FWLAdapterTimerMgr* pAdapter = NULL; | 525 CXFA_FWLAdapterTimerMgr* pAdapter = NULL; |
535 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 526 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); |
536 if (pEnv) | 527 if (pEnv) |
537 pAdapter = new CXFA_FWLAdapterTimerMgr(pEnv); | 528 pAdapter = new CXFA_FWLAdapterTimerMgr(pEnv); |
538 return pAdapter; | 529 return pAdapter; |
539 } | 530 } |
OLD | NEW |