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 "xfa/fxfa/app/xfa_ffapp.h" | 7 #include "xfa/include/fxfa/xfa_ffapp.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "xfa/fwl/core/ifwl_widgetmgrdelegate.h" | 11 #include "xfa/fwl/core/ifwl_widgetmgrdelegate.h" |
12 #include "xfa/fxfa/app/xfa_ffdoc.h" | |
13 #include "xfa/fxfa/app/xfa_ffdochandler.h" | |
14 #include "xfa/fxfa/app/xfa_ffwidgethandler.h" | |
15 #include "xfa/fxfa/app/xfa_fontmgr.h" | |
16 #include "xfa/fxfa/app/xfa_fwladapter.h" | 12 #include "xfa/fxfa/app/xfa_fwladapter.h" |
17 #include "xfa/fxfa/app/xfa_fwltheme.h" | 13 #include "xfa/fxfa/app/xfa_fwltheme.h" |
| 14 #include "xfa/include/fxfa/xfa_ffdoc.h" |
| 15 #include "xfa/include/fxfa/xfa_ffdochandler.h" |
| 16 #include "xfa/include/fxfa/xfa_ffwidgethandler.h" |
| 17 #include "xfa/include/fxfa/xfa_fontmgr.h" |
18 | 18 |
19 CXFA_FileRead::CXFA_FileRead(const CFX_ArrayTemplate<CPDF_Stream*>& streams) { | 19 CXFA_FileRead::CXFA_FileRead(const CFX_ArrayTemplate<CPDF_Stream*>& streams) { |
20 int32_t iCount = streams.GetSize(); | 20 int32_t iCount = streams.GetSize(); |
21 for (int32_t i = 0; i < iCount; i++) { | 21 for (int32_t i = 0; i < iCount; i++) { |
22 CPDF_StreamAcc& acc = m_Data.Add(); | 22 CPDF_StreamAcc& acc = m_Data.Add(); |
23 acc.LoadAllData(streams[i]); | 23 acc.LoadAllData(streams[i]); |
24 } | 24 } |
25 } | 25 } |
26 FX_FILESIZE CXFA_FileRead::GetSize() { | 26 FX_FILESIZE CXFA_FileRead::GetSize() { |
27 uint32_t dwSize = 0; | 27 uint32_t dwSize = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
54 size -= dwRead; | 54 size -= dwRead; |
55 if (size == 0) { | 55 if (size == 0) { |
56 return TRUE; | 56 return TRUE; |
57 } | 57 } |
58 buffer = (uint8_t*)buffer + dwRead; | 58 buffer = (uint8_t*)buffer + dwRead; |
59 offset = 0; | 59 offset = 0; |
60 index++; | 60 index++; |
61 } | 61 } |
62 return FALSE; | 62 return FALSE; |
63 } | 63 } |
64 // static | 64 |
65 IXFA_App* IXFA_App::Create(IXFA_AppProvider* pProvider) { | |
66 return new CXFA_FFApp(pProvider); | |
67 } | |
68 // virtual | |
69 IXFA_App::~IXFA_App() {} | |
70 CXFA_FFApp::CXFA_FFApp(IXFA_AppProvider* pProvider) | 65 CXFA_FFApp::CXFA_FFApp(IXFA_AppProvider* pProvider) |
71 : m_pDocHandler(nullptr), | 66 : m_pDocHandler(nullptr), |
72 m_pFWLTheme(nullptr), | 67 m_pFWLTheme(nullptr), |
73 m_pProvider(pProvider), | 68 m_pProvider(pProvider), |
74 m_pFontMgr(nullptr), | 69 m_pFontMgr(nullptr), |
75 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 70 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
76 m_pFontSource(nullptr), | 71 m_pFontSource(nullptr), |
77 #endif | 72 #endif |
78 m_pAdapterWidgetMgr(nullptr), | 73 m_pAdapterWidgetMgr(nullptr), |
79 m_pWidgetMgrDelegate(nullptr), | 74 m_pWidgetMgrDelegate(nullptr), |
80 m_pFDEFontMgr(nullptr), | 75 m_pFDEFontMgr(nullptr), |
81 m_pMenuHandler(nullptr), | 76 m_pMenuHandler(nullptr), |
82 m_pAdapterThreadMgr(nullptr) { | 77 m_pAdapterThreadMgr(nullptr) { |
83 m_pFWLApp = IFWL_App::Create(this); | 78 m_pFWLApp = IFWL_App::Create(this); |
84 FWL_SetApp(m_pFWLApp); | 79 FWL_SetApp(m_pFWLApp); |
85 m_pFWLApp->Initialize(); | 80 m_pFWLApp->Initialize(); |
86 IXFA_TimeZoneProvider::Create(); | 81 CXFA_TimeZoneProvider::Create(); |
87 } | 82 } |
88 CXFA_FFApp::~CXFA_FFApp() { | 83 CXFA_FFApp::~CXFA_FFApp() { |
89 delete m_pDocHandler; | 84 delete m_pDocHandler; |
90 if (m_pFWLApp) { | 85 if (m_pFWLApp) { |
91 m_pFWLApp->Finalize(); | 86 m_pFWLApp->Finalize(); |
92 m_pFWLApp->Release(); | 87 m_pFWLApp->Release(); |
93 delete m_pFWLApp; | 88 delete m_pFWLApp; |
94 } | 89 } |
95 if (m_pFWLTheme) | 90 if (m_pFWLTheme) |
96 m_pFWLTheme->Release(); | 91 m_pFWLTheme->Release(); |
97 delete m_pAdapterWidgetMgr; | 92 delete m_pAdapterWidgetMgr; |
98 delete m_pAdapterThreadMgr; | 93 delete m_pAdapterThreadMgr; |
99 delete m_pMenuHandler; | 94 delete m_pMenuHandler; |
100 IXFA_TimeZoneProvider::Destroy(); | 95 CXFA_TimeZoneProvider::Destroy(); |
101 delete m_pFontMgr; | 96 delete m_pFontMgr; |
102 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 97 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
103 if (m_pFontSource) | 98 if (m_pFontSource) |
104 m_pFontSource->Release(); | 99 m_pFontSource->Release(); |
105 #endif | 100 #endif |
106 if (m_pFDEFontMgr) | 101 if (m_pFDEFontMgr) |
107 m_pFDEFontMgr->Release(); | 102 m_pFDEFontMgr->Release(); |
108 } | 103 } |
109 IXFA_MenuHandler* CXFA_FFApp::GetMenuHandler() { | 104 CXFA_FFMenuHandler* CXFA_FFApp::GetMenuHandler() { |
110 if (!m_pMenuHandler) { | 105 if (!m_pMenuHandler) { |
111 m_pMenuHandler = new CXFA_FFMenuHandler; | 106 m_pMenuHandler = new CXFA_FFMenuHandler; |
112 } | 107 } |
113 return m_pMenuHandler; | 108 return m_pMenuHandler; |
114 } | 109 } |
115 IXFA_DocHandler* CXFA_FFApp::GetDocHandler() { | 110 CXFA_FFDocHandler* CXFA_FFApp::GetDocHandler() { |
116 if (!m_pDocHandler) { | 111 if (!m_pDocHandler) { |
117 m_pDocHandler = new CXFA_FFDocHandler; | 112 m_pDocHandler = new CXFA_FFDocHandler; |
118 } | 113 } |
119 return m_pDocHandler; | 114 return m_pDocHandler; |
120 } | 115 } |
121 IXFA_Doc* CXFA_FFApp::CreateDoc(IXFA_DocProvider* pProvider, | 116 CXFA_FFDoc* CXFA_FFApp::CreateDoc(IXFA_DocProvider* pProvider, |
122 IFX_FileRead* pStream, | 117 IFX_FileRead* pStream, |
123 FX_BOOL bTakeOverFile) { | 118 FX_BOOL bTakeOverFile) { |
124 CXFA_FFDoc* pDoc = new CXFA_FFDoc(this, pProvider); | 119 CXFA_FFDoc* pDoc = new CXFA_FFDoc(this, pProvider); |
125 FX_BOOL bSuccess = pDoc->OpenDoc(pStream, bTakeOverFile); | 120 FX_BOOL bSuccess = pDoc->OpenDoc(pStream, bTakeOverFile); |
126 if (!bSuccess) { | 121 if (!bSuccess) { |
127 delete pDoc; | 122 delete pDoc; |
128 pDoc = NULL; | 123 pDoc = NULL; |
129 } | 124 } |
130 return pDoc; | 125 return pDoc; |
131 } | 126 } |
132 IXFA_Doc* CXFA_FFApp::CreateDoc(IXFA_DocProvider* pProvider, | 127 CXFA_FFDoc* CXFA_FFApp::CreateDoc(IXFA_DocProvider* pProvider, |
133 CPDF_Document* pPDFDoc) { | 128 CPDF_Document* pPDFDoc) { |
134 if (pPDFDoc == NULL) { | 129 if (pPDFDoc == NULL) { |
135 return NULL; | 130 return NULL; |
136 } | 131 } |
137 CXFA_FFDoc* pDoc = new CXFA_FFDoc(this, pProvider); | 132 CXFA_FFDoc* pDoc = new CXFA_FFDoc(this, pProvider); |
138 FX_BOOL bSuccess = pDoc->OpenDoc(pPDFDoc); | 133 FX_BOOL bSuccess = pDoc->OpenDoc(pPDFDoc); |
139 if (!bSuccess) { | 134 if (!bSuccess) { |
140 delete pDoc; | 135 delete pDoc; |
141 pDoc = NULL; | 136 pDoc = NULL; |
142 } | 137 } |
143 return pDoc; | 138 return pDoc; |
144 } | 139 } |
145 | 140 |
146 void CXFA_FFApp::SetDefaultFontMgr(IXFA_FontMgr* pFontMgr) { | 141 void CXFA_FFApp::SetDefaultFontMgr(CXFA_DefFontMgr* pFontMgr) { |
147 if (!m_pFontMgr) { | 142 if (!m_pFontMgr) { |
148 m_pFontMgr = new CXFA_FontMgr(); | 143 m_pFontMgr = new CXFA_FontMgr(); |
149 } | 144 } |
150 m_pFontMgr->SetDefFontMgr(pFontMgr); | 145 m_pFontMgr->SetDefFontMgr(pFontMgr); |
151 } | 146 } |
152 CXFA_FontMgr* CXFA_FFApp::GetXFAFontMgr() { | 147 CXFA_FontMgr* CXFA_FFApp::GetXFAFontMgr() { |
153 return m_pFontMgr; | 148 return m_pFontMgr; |
154 } | 149 } |
155 IFX_FontMgr* CXFA_FFApp::GetFDEFontMgr() { | 150 IFX_FontMgr* CXFA_FFApp::GetFDEFontMgr() { |
156 if (!m_pFDEFontMgr) { | 151 if (!m_pFDEFontMgr) { |
(...skipping 24 matching lines...) Expand all Loading... |
181 } | 176 } |
182 IFWL_AdapterThreadMgr* CXFA_FFApp::GetThreadMgr() { | 177 IFWL_AdapterThreadMgr* CXFA_FFApp::GetThreadMgr() { |
183 if (!m_pAdapterThreadMgr) { | 178 if (!m_pAdapterThreadMgr) { |
184 m_pAdapterThreadMgr = new CFWL_SDAdapterThreadMgr; | 179 m_pAdapterThreadMgr = new CFWL_SDAdapterThreadMgr; |
185 } | 180 } |
186 return m_pAdapterThreadMgr; | 181 return m_pAdapterThreadMgr; |
187 } | 182 } |
188 IFWL_AdapterTimerMgr* CXFA_FFApp::GetTimerMgr() { | 183 IFWL_AdapterTimerMgr* CXFA_FFApp::GetTimerMgr() { |
189 return m_pProvider->GetTimerMgr(); | 184 return m_pProvider->GetTimerMgr(); |
190 } | 185 } |
OLD | NEW |