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