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 <memory> 11 12 #include "core/include/fxcrt/fx_coordinates.h" 13 #include "core/include/fxcrt/fx_system.h" 14 15 class CCodec_ModuleMgr; 16 class CFX_BitmapDevice; 17 class CFX_DIBSource; 18 class CFX_Matrix; 19 class CPDF_ColorSpace; 20 class CPDF_Dictionary; 21 class CPDF_DocPageData; 22 class CPDF_DocRenderData; 23 class CPDF_Document; 24 class CPDF_FontGlobals; 25 class CPDF_Image; 26 class CPDF_Page; 27 class CPDF_PageObjects; 28 class CPDF_PageRenderCache; 29 class CPDF_RenderConfig; 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 class IPDF_PageModule; 41 class IPDF_RenderModule; 42 43 class CPDF_ModuleMgr { 44 public: 45 static CPDF_ModuleMgr* Get(); 46 static void Create(); 47 static void Destroy(); 48 static const int kFileBufSize = 512; 49 SetCodecModule(CCodec_ModuleMgr * pModule)50 void SetCodecModule(CCodec_ModuleMgr* pModule) { m_pCodecModule = pModule; } GetCodecModule()51 CCodec_ModuleMgr* GetCodecModule() { return m_pCodecModule; } 52 53 void InitPageModule(); 54 void InitRenderModule(); 55 GetRenderModule()56 IPDF_RenderModule* GetRenderModule() const { return m_pRenderModule.get(); } GetPageModule()57 IPDF_PageModule* GetPageModule() const { return m_pPageModule.get(); } 58 59 void LoadEmbeddedGB1CMaps(); 60 void LoadEmbeddedCNS1CMaps(); 61 void LoadEmbeddedJapan1CMaps(); 62 void LoadEmbeddedKorea1CMaps(); 63 64 ICodec_FaxModule* GetFaxModule(); 65 ICodec_JpegModule* GetJpegModule(); 66 ICodec_JpxModule* GetJpxModule(); 67 ICodec_Jbig2Module* GetJbig2Module(); 68 ICodec_IccModule* GetIccModule(); 69 ICodec_FlateModule* GetFlateModule(); 70 71 void SetPrivateData(void* module_id, 72 void* pData, 73 PD_CALLBACK_FREEDATA callback); 74 75 void* GetPrivateData(void* module_id); 76 77 private: 78 CPDF_ModuleMgr(); 79 ~CPDF_ModuleMgr(); 80 81 CCodec_ModuleMgr* m_pCodecModule; 82 std::unique_ptr<IPDF_RenderModule> m_pRenderModule; 83 std::unique_ptr<IPDF_PageModule> m_pPageModule; 84 FX_BOOL (*m_pDownloadCallback)(const FX_CHAR* module_name); 85 CFX_PrivateData m_privateData; 86 }; 87 88 class IPDF_PageModule { 89 public: ~IPDF_PageModule()90 virtual ~IPDF_PageModule() {} 91 92 virtual CPDF_DocPageData* CreateDocData(CPDF_Document* pDoc) = 0; 93 virtual void ReleaseDoc(CPDF_Document*) = 0; 94 virtual void ClearDoc(CPDF_Document*) = 0; 95 virtual CPDF_FontGlobals* GetFontGlobals() = 0; 96 virtual void ClearStockFont(CPDF_Document* pDoc) = 0; 97 virtual void NotifyCJKAvailable() = 0; 98 virtual CPDF_ColorSpace* GetStockCS(int family) = 0; 99 }; 100 101 class IPDF_RenderModule { 102 public: ~IPDF_RenderModule()103 virtual ~IPDF_RenderModule() {} 104 105 virtual CPDF_DocRenderData* CreateDocData(CPDF_Document* pDoc) = 0; 106 virtual void DestroyDocData(CPDF_DocRenderData*) = 0; 107 virtual void ClearDocData(CPDF_DocRenderData*) = 0; 108 virtual CPDF_DocRenderData* GetRenderData() = 0; 109 virtual CPDF_PageRenderCache* CreatePageCache(CPDF_Page* pPage) = 0; 110 virtual void DestroyPageCache(CPDF_PageRenderCache*) = 0; 111 virtual CPDF_RenderConfig* GetConfig() = 0; 112 }; 113 114 #endif // CORE_INCLUDE_FPDFAPI_FPDF_MODULE_H_ 115