summaryrefslogtreecommitdiff
path: root/core/include/fpdfapi/fpdf_module.h
blob: 5877e1137246321c73c04a0a8ec3bbc63b43b8a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef CORE_INCLUDE_FPDFAPI_FPDF_MODULE_H_
#define CORE_INCLUDE_FPDFAPI_FPDF_MODULE_H_

#include "../../../third_party/base/nonstd_unique_ptr.h"
#include "../fxcrt/fx_coordinates.h"
#include "../fxcrt/fx_system.h"

class CCodec_ModuleMgr;
class CFX_AffineMatrix;
class CFX_BitmapDevice;
class CFX_DIBSource;
class CPDF_ColorSpace;
class CPDF_Dictionary;
class CPDF_DocPageData;
class CPDF_DocRenderData;
class CPDF_Document;
class CPDF_FontGlobals;
class CPDF_Image;
class CPDF_Page;
class CPDF_PageObjects;
class CPDF_PageRenderCache;
class CPDF_RenderConfig;
class CPDF_RenderOptions;
class CPDF_SecurityHandler;
class CPDF_Stream;
class ICodec_FaxModule;
class ICodec_FlateModule;
class ICodec_IccModule;
class ICodec_Jbig2Module;
class ICodec_JpegModule;
class ICodec_JpxModule;
class IPDF_FontMapper;
class IPDF_PageModule;
class IPDF_RenderModule;

class CPDF_ModuleMgr
{
public:
    static CPDF_ModuleMgr* Get();
    static void Create();
    static void Destroy();
    static const int kFileBufSize = 512;

    void SetCodecModule(CCodec_ModuleMgr* pModule)
    {
        m_pCodecModule = pModule;
    }
    CCodec_ModuleMgr* GetCodecModule()
    {
        return m_pCodecModule;
    }

    void InitPageModule();

    void InitRenderModule();

    void SetDownloadCallback(FX_BOOL (*callback)(const FX_CHAR* module_name));

    FX_BOOL DownloadModule(const FX_CHAR* module_name);

    void NotifyModuleAvailable(const FX_CHAR* module_name);

    IPDF_RenderModule* GetRenderModule() const
    {
        return m_pRenderModule.get();
    }

    IPDF_PageModule* GetPageModule() const
    {
        return m_pPageModule.get();
    }

    void LoadEmbeddedGB1CMaps();
    void LoadEmbeddedCNS1CMaps();
    void LoadEmbeddedJapan1CMaps();
    void LoadEmbeddedKorea1CMaps();

    ICodec_FaxModule* GetFaxModule();
    ICodec_JpegModule* GetJpegModule();
    ICodec_JpxModule* GetJpxModule();
    ICodec_Jbig2Module* GetJbig2Module();
    ICodec_IccModule* GetIccModule();
    ICodec_FlateModule* GetFlateModule();

    void RegisterSecurityHandler(
        const FX_CHAR* name,
        CPDF_SecurityHandler* (*CreateHandler)(void* param),
        void* param);

    CPDF_SecurityHandler* CreateSecurityHandler(const FX_CHAR* name);

    void SetPrivateData(void* module_id,
                        void* pData,
                        PD_CALLBACK_FREEDATA callback);

    void* GetPrivateData(void* module_id);

private:
    CPDF_ModuleMgr();
    ~CPDF_ModuleMgr();

    CCodec_ModuleMgr* m_pCodecModule;

    nonstd::unique_ptr<IPDF_RenderModule> m_pRenderModule;
    nonstd::unique_ptr<IPDF_PageModule> m_pPageModule;

    FX_BOOL (*m_pDownloadCallback)(const FX_CHAR* module_name);

    CFX_MapByteStringToPtr m_SecurityHandlerMap;

    CFX_PrivateData m_privateData;
};

class IPDF_PageModule
{
public:
    virtual ~IPDF_PageModule() {}

    virtual CPDF_DocPageData* CreateDocData(CPDF_Document* pDoc) = 0;
    virtual void ReleaseDoc(CPDF_Document*) = 0;
    virtual void ClearDoc(CPDF_Document*) = 0;
    virtual CPDF_FontGlobals* GetFontGlobals() = 0;
    virtual void ClearStockFont(CPDF_Document* pDoc) = 0;
    virtual void NotifyCJKAvailable() = 0;
    virtual CPDF_ColorSpace* GetStockCS(int family) = 0;
};

class IPDF_RenderModule
{
public:
    virtual ~IPDF_RenderModule() {}

    virtual CPDF_DocRenderData* CreateDocData(CPDF_Document* pDoc) = 0;
    virtual void DestroyDocData(CPDF_DocRenderData*) = 0;
    virtual void ClearDocData(CPDF_DocRenderData*) = 0;
    virtual CPDF_DocRenderData* GetRenderData() = 0;
    virtual CPDF_PageRenderCache* CreatePageCache(CPDF_Page* pPage) = 0;
    virtual void DestroyPageCache(CPDF_PageRenderCache*)  = 0;
    virtual CPDF_RenderConfig* GetConfig() = 0;
};

#endif  // CORE_INCLUDE_FPDFAPI_FPDF_MODULE_H_