Home | History | Annotate | Download | only in fpdfapi
      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
     12 class CPDF_ModuleMgr;
     13 class CPDF_PageModuleDef;
     14 class CPDF_RenderModuleDef;
     15 class CPDF_SecurityHandler;
     16 class CCodec_ModuleMgr;
     17 class CPDF_Dictionary;
     18 class ICodec_JpegModule;
     19 class ICodec_JpxModule;
     20 class ICodec_FaxModule;
     21 class ICodec_Jbig2Module;
     22 class ICodec_IccModule;
     23 class ICodec_FlateModule;
     24 #define ADDIN_NAME_CJK			"Eastern Asian Language Support"
     25 #define ADDIN_NAME_DECODER		"JPEG2000 and JBIG2 Image Decoders"
     26 class CPDF_ModuleMgr : public CFX_Object
     27 {
     28 public:
     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;
    101 protected:
    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 };
    129 class CPDF_Document;
    130 class CPDF_DocPageData;
    131 class CPDF_FontGlobals;
    132 class IPDF_FontMgr;
    133 class IPDF_FontMapper;
    134 class CPDF_ColorSpace;
    135 class CPDF_PageModuleDef : public CFX_Object
    136 {
    137 public:
    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 };
    162 class CPDF_PageObjects;
    163 class CFX_AffineMatrix;
    164 class CPDF_RenderOptions;
    165 class CPDF_Page;
    166 class CPDF_DocRenderData;
    167 class CPDF_PageRenderCache;
    168 class CFX_BitmapDevice;
    169 class CPDF_Stream;
    170 class CFX_DIBSource;
    171 class CPDF_RenderConfig;
    172 class CPDF_Image;
    173 class CPDF_RenderModuleDef : public CFX_Object
    174 {
    175 public:
    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