• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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_FPDFAPI_CPDF_MODULEMGR_H_
8 #define CORE_FPDFAPI_CPDF_MODULEMGR_H_
9 
10 #include <memory>
11 #include <utility>
12 
13 class CCodec_FaxModule;
14 class CCodec_FlateModule;
15 class CCodec_IccModule;
16 class CCodec_Jbig2Module;
17 class CCodec_JpegModule;
18 class CCodec_JpxModule;
19 class CCodec_ModuleMgr;
20 class CPDF_PageModule;
21 
22 class CFSDK_UnsupportInfo_Adapter {
23  public:
CFSDK_UnsupportInfo_Adapter(void * unsp_info)24   explicit CFSDK_UnsupportInfo_Adapter(void* unsp_info)
25       : m_unsp_info(unsp_info) {}
26 
GetUnspInfo()27   void* GetUnspInfo() const { return m_unsp_info; }
28 
29  private:
30   void* const m_unsp_info;
31 };
32 
33 class CPDF_ModuleMgr {
34  public:
35   static CPDF_ModuleMgr* Get();
36   static void Destroy();
37   static const int kFileBufSize = 512;
38 
39   void Init();
40 
SetUnsupportInfoAdapter(std::unique_ptr<CFSDK_UnsupportInfo_Adapter> pAdapter)41   void SetUnsupportInfoAdapter(
42       std::unique_ptr<CFSDK_UnsupportInfo_Adapter> pAdapter) {
43     m_pUnsupportInfoAdapter = std::move(pAdapter);
44   }
GetUnsupportInfoAdapter()45   CFSDK_UnsupportInfo_Adapter* GetUnsupportInfoAdapter() const {
46     return m_pUnsupportInfoAdapter.get();
47   }
48 
GetCodecModule()49   CCodec_ModuleMgr* GetCodecModule() const { return m_pCodecModule.get(); }
GetPageModule()50   CPDF_PageModule* GetPageModule() const { return m_pPageModule.get(); }
51 
52   CCodec_FaxModule* GetFaxModule();
53   CCodec_JpegModule* GetJpegModule();
54   CCodec_JpxModule* GetJpxModule();
55   CCodec_Jbig2Module* GetJbig2Module();
56   CCodec_IccModule* GetIccModule();
57   CCodec_FlateModule* GetFlateModule();
58 
59  private:
60   CPDF_ModuleMgr();
61   ~CPDF_ModuleMgr();
62 
63   void InitCodecModule();
64   void InitPageModule();
65   void LoadEmbeddedMaps();
66   void LoadCodecModules();
67 
68   void LoadEmbeddedGB1CMaps();
69   void LoadEmbeddedCNS1CMaps();
70   void LoadEmbeddedJapan1CMaps();
71   void LoadEmbeddedKorea1CMaps();
72 
73   std::unique_ptr<CCodec_ModuleMgr> m_pCodecModule;
74   std::unique_ptr<CPDF_PageModule> m_pPageModule;
75   std::unique_ptr<CFSDK_UnsupportInfo_Adapter> m_pUnsupportInfoAdapter;
76 };
77 
78 #endif  // CORE_FPDFAPI_CPDF_MODULEMGR_H_
79