OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ | 7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ |
8 #define CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ | 8 #define CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <memory> | 11 #include <memory> |
12 #include <set> | 12 #include <set> |
13 | 13 |
14 #include "core/include/fpdfapi/fpdf_objects.h" | 14 #include "core/include/fpdfapi/fpdf_objects.h" |
15 #include "core/include/fxcrt/fx_basic.h" | 15 #include "core/include/fxcrt/fx_basic.h" |
16 | 16 |
17 class CFX_Font; | 17 class CFX_Font; |
18 class CFX_Matrix; | 18 class CFX_Matrix; |
19 class CPDF_ColorSpace; | 19 class CPDF_ColorSpace; |
20 class CPDF_CryptoHandler; | 20 class CPDF_CryptoHandler; |
| 21 class CPDF_Document; |
21 class CPDF_DocPageData; | 22 class CPDF_DocPageData; |
22 class CPDF_DocRenderData; | 23 class CPDF_DocRenderData; |
23 class CPDF_Font; | 24 class CPDF_Font; |
24 class CPDF_FontEncoding; | 25 class CPDF_FontEncoding; |
25 class CPDF_IccProfile; | 26 class CPDF_IccProfile; |
26 class CPDF_Image; | 27 class CPDF_Image; |
27 class CPDF_Object; | 28 class CPDF_Object; |
28 class CPDF_Parser; | 29 class CPDF_Parser; |
29 class CPDF_Pattern; | 30 class CPDF_Pattern; |
30 class CPDF_StandardSecurityHandler; | 31 class CPDF_StandardSecurityHandler; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 ~ScopedSetInsertion() { m_Set->erase(m_Entry); } | 77 ~ScopedSetInsertion() { m_Set->erase(m_Entry); } |
77 | 78 |
78 private: | 79 private: |
79 std::set<T>* const m_Set; | 80 std::set<T>* const m_Set; |
80 const T m_Entry; | 81 const T m_Entry; |
81 }; | 82 }; |
82 | 83 |
83 // Indexed by 8-bit char code, contains unicode code points. | 84 // Indexed by 8-bit char code, contains unicode code points. |
84 extern const FX_WORD PDFDocEncoding[256]; | 85 extern const FX_WORD PDFDocEncoding[256]; |
85 | 86 |
86 class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder { | |
87 public: | |
88 CPDF_Document(); | |
89 explicit CPDF_Document(CPDF_Parser* pParser); | |
90 | |
91 ~CPDF_Document(); | |
92 | |
93 CPDF_Parser* GetParser() const { return m_pParser; } | |
94 | |
95 CPDF_Dictionary* GetRoot() const { return m_pRootDict; } | |
96 | |
97 CPDF_Dictionary* GetInfo() const { return m_pInfoDict; } | |
98 | |
99 void GetID(CFX_ByteString& id1, CFX_ByteString& id2) const { | |
100 id1 = m_ID1; | |
101 id2 = m_ID2; | |
102 } | |
103 | |
104 int GetPageCount() const; | |
105 | |
106 CPDF_Dictionary* GetPage(int iPage); | |
107 | |
108 int GetPageIndex(FX_DWORD objnum); | |
109 | |
110 FX_DWORD GetUserPermissions(FX_BOOL bCheckRevision = FALSE) const; | |
111 | |
112 CPDF_DocPageData* GetPageData() { return GetValidatePageData(); } | |
113 | |
114 void ClearPageData(); | |
115 | |
116 void RemoveColorSpaceFromPageData(CPDF_Object* pObject); | |
117 | |
118 CPDF_DocRenderData* GetRenderData() { return GetValidateRenderData(); } | |
119 | |
120 void ClearRenderData(); | |
121 | |
122 void ClearRenderFont(); | |
123 | |
124 FX_BOOL IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) const; | |
125 | |
126 // |pFontDict| must not be null. | |
127 CPDF_Font* LoadFont(CPDF_Dictionary* pFontDict); | |
128 | |
129 CPDF_ColorSpace* LoadColorSpace(CPDF_Object* pCSObj, | |
130 CPDF_Dictionary* pResources = NULL); | |
131 | |
132 CPDF_Pattern* LoadPattern(CPDF_Object* pObj, | |
133 FX_BOOL bShading, | |
134 const CFX_Matrix* matrix = NULL); | |
135 | |
136 CPDF_Image* LoadImageF(CPDF_Object* pObj); | |
137 | |
138 CPDF_StreamAcc* LoadFontFile(CPDF_Stream* pStream); | |
139 | |
140 CPDF_IccProfile* LoadIccProfile(CPDF_Stream* pStream); | |
141 | |
142 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | |
143 | |
144 CPDF_Font* AddWindowsFont(LOGFONTA* pLogFont, | |
145 FX_BOOL bVert, | |
146 FX_BOOL bTranslateName = FALSE); | |
147 CPDF_Font* AddWindowsFont(LOGFONTW* pLogFont, | |
148 FX_BOOL bVert, | |
149 FX_BOOL bTranslateName = FALSE); | |
150 #endif | |
151 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | |
152 CPDF_Font* AddMacFont(CTFontRef pFont, | |
153 FX_BOOL bVert, | |
154 FX_BOOL bTranslateName = FALSE); | |
155 #endif | |
156 | |
157 CPDF_Font* AddStandardFont(const FX_CHAR* font, CPDF_FontEncoding* pEncoding); | |
158 | |
159 CPDF_Font* AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert); | |
160 | |
161 void CreateNewDoc(); | |
162 | |
163 CPDF_Dictionary* CreateNewPage(int iPage); | |
164 | |
165 void DeletePage(int iPage); | |
166 | |
167 void LoadDoc(); | |
168 void LoadAsynDoc(CPDF_Dictionary* pLinearized); | |
169 void LoadPages(); | |
170 | |
171 protected: | |
172 CPDF_Dictionary* m_pRootDict; | |
173 | |
174 CPDF_Dictionary* m_pInfoDict; | |
175 | |
176 CFX_ByteString m_ID1; | |
177 | |
178 CFX_ByteString m_ID2; | |
179 | |
180 FX_BOOL m_bLinearized; | |
181 | |
182 FX_DWORD m_dwFirstPageNo; | |
183 | |
184 FX_DWORD m_dwFirstPageObjNum; | |
185 | |
186 CFX_DWordArray m_PageList; | |
187 | |
188 // Retrieve page count information by getting count value from the tree nodes | |
189 // or walking through the tree nodes to calculate it. | |
190 int RetrievePageCount() const; | |
191 CPDF_Dictionary* _FindPDFPage(CPDF_Dictionary* pPages, | |
192 int iPage, | |
193 int nPagesToGo, | |
194 int level); | |
195 int _FindPageIndex(CPDF_Dictionary* pNode, | |
196 FX_DWORD& skip_count, | |
197 FX_DWORD objnum, | |
198 int& index, | |
199 int level = 0); | |
200 FX_BOOL CheckOCGVisible(CPDF_Dictionary* pOCG, FX_BOOL bPrinting); | |
201 CPDF_DocPageData* GetValidatePageData(); | |
202 CPDF_DocRenderData* GetValidateRenderData(); | |
203 friend class CPDF_Creator; | |
204 friend class CPDF_Parser; | |
205 friend class CPDF_DataAvail; | |
206 friend class CPDF_OCContext; | |
207 | |
208 CPDF_DocPageData* m_pDocPage; | |
209 | |
210 CPDF_DocRenderData* m_pDocRender; | |
211 }; | |
212 | 87 |
213 class CPDF_SimpleParser { | 88 class CPDF_SimpleParser { |
214 public: | 89 public: |
215 CPDF_SimpleParser(const uint8_t* pData, FX_DWORD dwSize); | 90 CPDF_SimpleParser(const uint8_t* pData, FX_DWORD dwSize); |
216 CPDF_SimpleParser(const CFX_ByteStringC& str); | 91 CPDF_SimpleParser(const CFX_ByteStringC& str); |
217 | 92 |
218 CFX_ByteStringC GetWord(); | 93 CFX_ByteStringC GetWord(); |
219 | 94 |
220 // Find the token and its |nParams| parameters from the start of data, | 95 // Find the token and its |nParams| parameters from the start of data, |
221 // and move the current position to the start of those parameters. | 96 // and move the current position to the start of those parameters. |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 FX_DWORD src_size, | 646 FX_DWORD src_size, |
772 const CPDF_Dictionary* pDict, | 647 const CPDF_Dictionary* pDict, |
773 uint8_t*& dest_buf, | 648 uint8_t*& dest_buf, |
774 FX_DWORD& dest_size, | 649 FX_DWORD& dest_size, |
775 CFX_ByteString& ImageEncoding, | 650 CFX_ByteString& ImageEncoding, |
776 CPDF_Dictionary*& pImageParms, | 651 CPDF_Dictionary*& pImageParms, |
777 FX_DWORD estimated_size, | 652 FX_DWORD estimated_size, |
778 FX_BOOL bImageAcc); | 653 FX_BOOL bImageAcc); |
779 | 654 |
780 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ | 655 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ |
OLD | NEW |