OLD | NEW |
| (Empty) |
1 // Copyright 2014 PDFium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #ifndef XFA_FXFA_INCLUDE_XFA_FFAPP_H_ | |
8 #define XFA_FXFA_INCLUDE_XFA_FFAPP_H_ | |
9 | |
10 #include <memory> | |
11 | |
12 #include "core/fpdfapi/fpdf_parser/cpdf_stream.h" | |
13 #include "core/fpdfapi/fpdf_parser/cpdf_stream_acc.h" | |
14 #include "xfa/fgas/font/fgas_font.h" | |
15 #include "xfa/fwl/core/ifwl_app.h" | |
16 #include "xfa/fxfa/include/fxfa.h" | |
17 | |
18 class CFWL_WidgetMgrDelegate; | |
19 class CXFA_DefFontMgr; | |
20 class CXFA_FWLAdapterWidgetMgr; | |
21 class CXFA_FWLTheme; | |
22 class CXFA_FFDocHandler; | |
23 class CXFA_FontMgr; | |
24 class IFWL_AdapterTimerMgr; | |
25 | |
26 class CXFA_FileRead : public IFX_FileRead { | |
27 public: | |
28 explicit CXFA_FileRead(const CFX_ArrayTemplate<CPDF_Stream*>& streams); | |
29 ~CXFA_FileRead() override; | |
30 | |
31 // IFX_FileRead | |
32 FX_FILESIZE GetSize() override; | |
33 FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; | |
34 void Release() override; | |
35 | |
36 protected: | |
37 CFX_ObjectArray<CPDF_StreamAcc> m_Data; | |
38 }; | |
39 | |
40 class CXFA_FFApp { | |
41 public: | |
42 explicit CXFA_FFApp(IXFA_AppProvider* pProvider); | |
43 ~CXFA_FFApp(); | |
44 | |
45 CXFA_FFDoc* CreateDoc(IXFA_DocEnvironment* pDocEnvironment, | |
46 IFX_FileRead* pStream, | |
47 FX_BOOL bTakeOverFile); | |
48 CXFA_FFDoc* CreateDoc(IXFA_DocEnvironment* pDocEnvironment, | |
49 CPDF_Document* pPDFDoc); | |
50 void SetDefaultFontMgr(std::unique_ptr<CXFA_DefFontMgr> pFontMgr); | |
51 | |
52 CXFA_FFDocHandler* GetDocHandler(); | |
53 CXFA_FWLAdapterWidgetMgr* GetWidgetMgr(CFWL_WidgetMgrDelegate* pDelegate); | |
54 IFGAS_FontMgr* GetFDEFontMgr(); | |
55 CXFA_FWLTheme* GetFWLTheme(); | |
56 | |
57 IXFA_AppProvider* GetAppProvider() const { return m_pProvider; } | |
58 IFWL_AdapterTimerMgr* GetTimerMgr() const; | |
59 CXFA_FontMgr* GetXFAFontMgr() const; | |
60 CFWL_WidgetMgrDelegate* GetWidgetMgrDelegate() const { | |
61 return m_pWidgetMgrDelegate; | |
62 } | |
63 | |
64 protected: | |
65 std::unique_ptr<CXFA_FFDocHandler> m_pDocHandler; | |
66 IXFA_AppProvider* const m_pProvider; | |
67 | |
68 // The fonts stored in the font manager may have been created by the default | |
69 // font manager. The GEFont::LoadFont call takes the manager as a param and | |
70 // stores it internally. When you destroy the GEFont it tries to unregister | |
71 // from the font manager and if the default font manager was destroyed first | |
72 // get get a use-after-free. The m_pFWLTheme can try to cleanup a GEFont | |
73 // when it frees, so make sure it gets cleaned up first. That requires | |
74 // m_pFWLApp to be cleaned up as well. | |
75 // | |
76 // TODO(dsinclair): The GEFont should have the FontMgr as the pointer instead | |
77 // of the DEFFontMgr so this goes away. Bug 561. | |
78 std::unique_ptr<IFGAS_FontMgr> m_pFDEFontMgr; | |
79 std::unique_ptr<CXFA_FontMgr> m_pFontMgr; | |
80 | |
81 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | |
82 std::unique_ptr<CFX_FontSourceEnum_File> m_pFontSource; | |
83 #endif | |
84 std::unique_ptr<CXFA_FWLAdapterWidgetMgr> m_pAdapterWidgetMgr; | |
85 CFWL_WidgetMgrDelegate* m_pWidgetMgrDelegate; // not owned. | |
86 | |
87 // |m_pFWLApp| has to be released first, then |m_pFWLTheme| since the former | |
88 // may refers to theme manager and the latter refers to font manager. | |
89 std::unique_ptr<CXFA_FWLTheme> m_pFWLTheme; | |
90 std::unique_ptr<IFWL_App> m_pFWLApp; | |
91 }; | |
92 | |
93 #endif // XFA_FXFA_INCLUDE_XFA_FFAPP_H_ | |
OLD | NEW |