OLD | NEW |
| (Empty) |
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_INCLUDE_FPDFAPI_CPDF_DOCUMENT_H_ | |
8 #define CORE_INCLUDE_FPDFAPI_CPDF_DOCUMENT_H_ | |
9 | |
10 #include "core/include/fpdfapi/cpdf_indirect_object_holder.h" | |
11 #include "core/include/fpdfapi/cpdf_object.h" | |
12 #include "core/include/fxcrt/fx_basic.h" | |
13 | |
14 class CFX_Font; | |
15 class CFX_Matrix; | |
16 class CPDF_ColorSpace; | |
17 class CPDF_DocPageData; | |
18 class CPDF_DocRenderData; | |
19 class CPDF_Font; | |
20 class CPDF_FontEncoding; | |
21 class CPDF_IccProfile; | |
22 class CPDF_Image; | |
23 class CPDF_Pattern; | |
24 class CPDF_StreamAcc; | |
25 | |
26 #define FPDFPERM_PRINT 0x0004 | |
27 #define FPDFPERM_MODIFY 0x0008 | |
28 #define FPDFPERM_EXTRACT 0x0010 | |
29 #define FPDFPERM_ANNOT_FORM 0x0020 | |
30 #define FPDFPERM_FILL_FORM 0x0100 | |
31 #define FPDFPERM_EXTRACT_ACCESS 0x0200 | |
32 #define FPDFPERM_ASSEMBLE 0x0400 | |
33 #define FPDFPERM_PRINT_HIGH 0x0800 | |
34 #define FPDF_PAGE_MAX_NUM 0xFFFFF | |
35 | |
36 class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder { | |
37 public: | |
38 CPDF_Document(); | |
39 explicit CPDF_Document(CPDF_Parser* pParser); | |
40 ~CPDF_Document(); | |
41 | |
42 CPDF_Parser* GetParser() const { return m_pParser; } | |
43 CPDF_Dictionary* GetRoot() const { return m_pRootDict; } | |
44 CPDF_Dictionary* GetInfo() const { return m_pInfoDict; } | |
45 | |
46 void GetID(CFX_ByteString& id1, CFX_ByteString& id2) const { | |
47 id1 = m_ID1; | |
48 id2 = m_ID2; | |
49 } | |
50 | |
51 int GetPageCount() const; | |
52 CPDF_Dictionary* GetPage(int iPage); | |
53 int GetPageIndex(FX_DWORD objnum); | |
54 FX_DWORD GetUserPermissions(FX_BOOL bCheckRevision = FALSE) const; | |
55 CPDF_DocPageData* GetPageData() { return GetValidatePageData(); } | |
56 void ClearPageData(); | |
57 void RemoveColorSpaceFromPageData(CPDF_Object* pObject); | |
58 | |
59 CPDF_DocRenderData* GetRenderData() { return GetValidateRenderData(); } | |
60 void ClearRenderData(); | |
61 void ClearRenderFont(); | |
62 | |
63 FX_BOOL IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) const; | |
64 | |
65 // |pFontDict| must not be null. | |
66 CPDF_Font* LoadFont(CPDF_Dictionary* pFontDict); | |
67 CPDF_ColorSpace* LoadColorSpace(CPDF_Object* pCSObj, | |
68 CPDF_Dictionary* pResources = NULL); | |
69 | |
70 CPDF_Pattern* LoadPattern(CPDF_Object* pObj, | |
71 FX_BOOL bShading, | |
72 const CFX_Matrix* matrix = NULL); | |
73 | |
74 CPDF_Image* LoadImageF(CPDF_Object* pObj); | |
75 CPDF_StreamAcc* LoadFontFile(CPDF_Stream* pStream); | |
76 CPDF_IccProfile* LoadIccProfile(CPDF_Stream* pStream); | |
77 | |
78 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | |
79 | |
80 CPDF_Font* AddWindowsFont(LOGFONTA* pLogFont, | |
81 FX_BOOL bVert, | |
82 FX_BOOL bTranslateName = FALSE); | |
83 CPDF_Font* AddWindowsFont(LOGFONTW* pLogFont, | |
84 FX_BOOL bVert, | |
85 FX_BOOL bTranslateName = FALSE); | |
86 #endif | |
87 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | |
88 CPDF_Font* AddMacFont(CTFontRef pFont, | |
89 FX_BOOL bVert, | |
90 FX_BOOL bTranslateName = FALSE); | |
91 #endif | |
92 | |
93 CPDF_Font* AddStandardFont(const FX_CHAR* font, CPDF_FontEncoding* pEncoding); | |
94 CPDF_Font* AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert); | |
95 void CreateNewDoc(); | |
96 | |
97 CPDF_Dictionary* CreateNewPage(int iPage); | |
98 void DeletePage(int iPage); | |
99 | |
100 void LoadDoc(); | |
101 void LoadAsynDoc(CPDF_Dictionary* pLinearized); | |
102 void LoadPages(); | |
103 | |
104 protected: | |
105 // Retrieve page count information by getting count value from the tree nodes | |
106 // or walking through the tree nodes to calculate it. | |
107 int RetrievePageCount() const; | |
108 CPDF_Dictionary* _FindPDFPage(CPDF_Dictionary* pPages, | |
109 int iPage, | |
110 int nPagesToGo, | |
111 int level); | |
112 int _FindPageIndex(CPDF_Dictionary* pNode, | |
113 FX_DWORD& skip_count, | |
114 FX_DWORD objnum, | |
115 int& index, | |
116 int level = 0); | |
117 FX_BOOL CheckOCGVisible(CPDF_Dictionary* pOCG, FX_BOOL bPrinting); | |
118 CPDF_DocPageData* GetValidatePageData(); | |
119 CPDF_DocRenderData* GetValidateRenderData(); | |
120 friend class CPDF_Creator; | |
121 friend class CPDF_Parser; | |
122 friend class CPDF_DataAvail; | |
123 friend class CPDF_OCContext; | |
124 | |
125 CPDF_Dictionary* m_pRootDict; | |
126 CPDF_Dictionary* m_pInfoDict; | |
127 CFX_ByteString m_ID1; | |
128 CFX_ByteString m_ID2; | |
129 FX_BOOL m_bLinearized; | |
130 FX_DWORD m_dwFirstPageNo; | |
131 FX_DWORD m_dwFirstPageObjNum; | |
132 CFX_DWordArray m_PageList; | |
133 CPDF_DocPageData* m_pDocPage; | |
134 CPDF_DocRenderData* m_pDocRender; | |
135 }; | |
136 | |
137 #endif // CORE_INCLUDE_FPDFAPI_CPDF_DOCUMENT_H_ | |
OLD | NEW |