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 _FPDF_MODULE_
8#define _FPDF_MODULE_
9#ifndef _FXCRT_EXTENSION_
10#include "../fxcrt/fx_ext.h"
11#endif
12class CPDF_ModuleMgr;
13class CPDF_PageModuleDef;
14class CPDF_RenderModuleDef;
15class CPDF_SecurityHandler;
16class CCodec_ModuleMgr;
17class CPDF_Dictionary;
18class ICodec_JpegModule;
19class ICodec_JpxModule;
20class ICodec_FaxModule;
21class ICodec_Jbig2Module;
22class ICodec_IccModule;
23class ICodec_FlateModule;
24#define ADDIN_NAME_CJK			"Eastern Asian Language Support"
25#define ADDIN_NAME_DECODER		"JPEG2000 and JBIG2 Image Decoders"
26class CPDF_ModuleMgr : public CFX_Object
27{
28public:
29
30    static void	Create();
31
32    static CPDF_ModuleMgr*	Get();
33
34    static void	Destroy();
35
36
37
38    void		SetCodecModule(CCodec_ModuleMgr* pModule)
39    {
40        m_pCodecModule = pModule;
41    }
42    CCodec_ModuleMgr*		GetCodecModule()
43    {
44        return m_pCodecModule;
45    }
46
47    void		InitPageModule();
48
49    void		InitRenderModule();
50
51
52    void		SetModulePath(FX_LPCSTR module_name, FX_LPCSTR path);
53
54    CFX_ByteString GetModuleFilePath(FX_LPCSTR module_name, FX_LPCSTR name);
55
56    void		SetDownloadCallback(FX_BOOL (*callback)(FX_LPCSTR module_name));
57
58    FX_BOOL		DownloadModule(FX_LPCSTR module_name);
59
60    void		NotifyModuleAvailable(FX_LPCSTR module_name);
61
62
63
64    CPDF_RenderModuleDef*	GetRenderModule() const
65    {
66        return m_pRenderModule;
67    }
68
69    CPDF_PageModuleDef*		GetPageModule() const
70    {
71        return m_pPageModule;
72    }
73
74
75
76
77    void					LoadEmbeddedGB1CMaps();
78
79    void					LoadEmbeddedCNS1CMaps();
80
81    void					LoadEmbeddedJapan1CMaps();
82
83    void					LoadEmbeddedKorea1CMaps();
84
85    ICodec_FaxModule*		GetFaxModule();
86    ICodec_JpegModule*		GetJpegModule();
87    ICodec_JpxModule*		GetJpxModule();
88    ICodec_Jbig2Module*		GetJbig2Module();
89    ICodec_IccModule*		GetIccModule();
90    ICodec_FlateModule*		GetFlateModule();
91
92    void					RegisterSecurityHandler(FX_LPCSTR name, CPDF_SecurityHandler * (*CreateHandler)(void* param), void* param);
93
94    CPDF_SecurityHandler*	CreateSecurityHandler(FX_LPCSTR name);
95
96    void					SetPrivateData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback);
97
98    FX_LPVOID				GetPrivateData(FX_LPVOID module_id);
99
100    int						m_FileBufSize;
101protected:
102
103    CPDF_ModuleMgr();
104
105    ~CPDF_ModuleMgr();
106    void					Initialize();
107
108    void					InitModules();
109
110
111
112    CCodec_ModuleMgr*		m_pCodecModule;
113
114    CPDF_RenderModuleDef*	m_pRenderModule;
115
116    CPDF_PageModuleDef*		m_pPageModule;
117
118
119    FX_BOOL (*m_pDownloadCallback)(FX_LPCSTR module_name);
120
121    CFX_ByteString			m_DefaultModulePath;
122
123    CFX_CMapByteStringToPtr	m_ModulePathList;
124
125    CFX_MapByteStringToPtr	m_SecurityHandlerMap;
126
127    CFX_PrivateData			m_privateData;
128};
129class CPDF_Document;
130class CPDF_DocPageData;
131class CPDF_FontGlobals;
132class IPDF_FontMgr;
133class IPDF_FontMapper;
134class CPDF_ColorSpace;
135class CPDF_PageModuleDef : public CFX_Object
136{
137public:
138    virtual ~CPDF_PageModuleDef() {}
139
140    virtual CPDF_DocPageData*	CreateDocData(CPDF_Document* pDoc)
141    {
142        return NULL;
143    }
144
145    virtual void				ReleaseDoc(CPDF_Document*) {}
146    virtual void				ClearDoc(CPDF_Document*) {}
147
148    virtual CPDF_FontGlobals*	GetFontGlobals()
149    {
150        return NULL;
151    }
152
153    virtual void				ClearStockFont(CPDF_Document* pDoc) {}
154
155    virtual void				NotifyCJKAvailable() {}
156
157    virtual CPDF_ColorSpace*	GetStockCS(int family)
158    {
159        return NULL;
160    }
161};
162class CPDF_PageObjects;
163class CFX_AffineMatrix;
164class CPDF_RenderOptions;
165class CPDF_Page;
166class CPDF_DocRenderData;
167class CPDF_PageRenderCache;
168class CFX_BitmapDevice;
169class CPDF_Stream;
170class CFX_DIBSource;
171class CPDF_RenderConfig;
172class CPDF_Image;
173class CPDF_RenderModuleDef : public CFX_Object
174{
175public:
176    virtual ~CPDF_RenderModuleDef() {}
177
178    virtual CPDF_DocRenderData*	CreateDocData(CPDF_Document* pDoc)
179    {
180        return NULL;
181    }
182
183    virtual void	DestroyDocData(CPDF_DocRenderData*) {}
184    virtual void	ClearDocData(CPDF_DocRenderData*) {}
185
186    virtual CPDF_DocRenderData* GetRenderData()
187    {
188        return NULL;
189    }
190
191    virtual CPDF_PageRenderCache*	CreatePageCache(CPDF_Page* pPage)
192    {
193        return NULL;
194    }
195
196    virtual void	DestroyPageCache(CPDF_PageRenderCache*) {}
197
198    virtual void	NotifyDecoderAvailable() {}
199
200    virtual CPDF_RenderConfig* GetConfig()
201    {
202        return NULL;
203    }
204};
205#endif
206