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> |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 friend class CPDF_Creator; | 200 friend class CPDF_Creator; |
201 friend class CPDF_Parser; | 201 friend class CPDF_Parser; |
202 friend class CPDF_DataAvail; | 202 friend class CPDF_DataAvail; |
203 friend class CPDF_OCContext; | 203 friend class CPDF_OCContext; |
204 | 204 |
205 CPDF_DocPageData* m_pDocPage; | 205 CPDF_DocPageData* m_pDocPage; |
206 | 206 |
207 CPDF_DocRenderData* m_pDocRender; | 207 CPDF_DocRenderData* m_pDocRender; |
208 }; | 208 }; |
209 | 209 |
210 #define PDFWORD_EOF 0 | |
211 #define PDFWORD_NUMBER 1 | |
212 #define PDFWORD_TEXT 2 | |
213 #define PDFWORD_DELIMITER 3 | |
214 #define PDFWORD_NAME 4 | |
215 class CPDF_SimpleParser { | 210 class CPDF_SimpleParser { |
216 public: | 211 public: |
217 CPDF_SimpleParser(const uint8_t* pData, FX_DWORD dwSize); | 212 CPDF_SimpleParser(const uint8_t* pData, FX_DWORD dwSize); |
218 | 213 |
219 CPDF_SimpleParser(const CFX_ByteStringC& str); | 214 CPDF_SimpleParser(const CFX_ByteStringC& str); |
220 | 215 |
221 CFX_ByteStringC GetWord(); | 216 CFX_ByteStringC GetWord(); |
222 | 217 |
223 FX_BOOL SearchToken(const CFX_ByteStringC& token); | 218 FX_BOOL SearchToken(const CFX_ByteStringC& token); |
224 | 219 |
225 FX_BOOL SkipWord(const CFX_ByteStringC& token); | 220 FX_BOOL SkipWord(const CFX_ByteStringC& token); |
226 | 221 |
227 FX_BOOL FindTagPair(const CFX_ByteStringC& start_token, | 222 FX_BOOL FindTagPair(const CFX_ByteStringC& start_token, |
228 const CFX_ByteStringC& end_token, | 223 const CFX_ByteStringC& end_token, |
229 FX_DWORD& start_pos, | 224 FX_DWORD& start_pos, |
230 FX_DWORD& end_pos); | 225 FX_DWORD& end_pos); |
231 | 226 |
232 FX_BOOL FindTagParam(const CFX_ByteStringC& token, int nParams); | 227 FX_BOOL FindTagParam(const CFX_ByteStringC& token, int nParams); |
233 | 228 |
234 FX_DWORD GetPos() { return m_dwCurPos; } | 229 FX_DWORD GetPos() { return m_dwCurPos; } |
235 | 230 |
236 void SetPos(FX_DWORD pos) { | 231 void SetPos(FX_DWORD pos) { |
237 ASSERT(pos <= m_dwSize); | 232 ASSERT(pos <= m_dwSize); |
238 m_dwCurPos = pos; | 233 m_dwCurPos = pos; |
239 } | 234 } |
240 | 235 |
241 private: | 236 private: |
242 void ParseWord(const uint8_t*& pStart, FX_DWORD& dwSize, int& type); | 237 void ParseWord(const uint8_t*& pStart, FX_DWORD& dwSize); |
243 | 238 |
244 const uint8_t* m_pData; | 239 const uint8_t* m_pData; |
245 | |
246 FX_DWORD m_dwSize; | 240 FX_DWORD m_dwSize; |
247 | |
248 FX_DWORD m_dwCurPos; | 241 FX_DWORD m_dwCurPos; |
249 }; | 242 }; |
| 243 |
250 class CPDF_SyntaxParser { | 244 class CPDF_SyntaxParser { |
251 public: | 245 public: |
252 CPDF_SyntaxParser(); | 246 CPDF_SyntaxParser(); |
253 virtual ~CPDF_SyntaxParser(); | 247 virtual ~CPDF_SyntaxParser(); |
254 | 248 |
255 void InitParser(IFX_FileRead* pFileAccess, FX_DWORD HeaderOffset); | 249 void InitParser(IFX_FileRead* pFileAccess, FX_DWORD HeaderOffset); |
256 | 250 |
257 FX_FILESIZE SavePos() { return m_Pos; } | 251 FX_FILESIZE SavePos() { return m_Pos; } |
258 | 252 |
259 void RestorePos(FX_FILESIZE pos) { m_Pos = pos; } | 253 void RestorePos(FX_FILESIZE pos) { m_Pos = pos; } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 CFX_ByteString ReadHexString(); | 322 CFX_ByteString ReadHexString(); |
329 | 323 |
330 unsigned int ReadEOLMarkers(FX_FILESIZE pos); | 324 unsigned int ReadEOLMarkers(FX_FILESIZE pos); |
331 | 325 |
332 CPDF_Stream* ReadStream(CPDF_Dictionary* pDict, | 326 CPDF_Stream* ReadStream(CPDF_Dictionary* pDict, |
333 FX_DWORD objnum, | 327 FX_DWORD objnum, |
334 FX_DWORD gennum); | 328 FX_DWORD gennum); |
335 | 329 |
336 FX_FILESIZE m_Pos; | 330 FX_FILESIZE m_Pos; |
337 | 331 |
338 FX_BOOL m_bFileStream; | |
339 | |
340 int m_MetadataObjnum; | 332 int m_MetadataObjnum; |
341 | 333 |
342 IFX_FileRead* m_pFileAccess; | 334 IFX_FileRead* m_pFileAccess; |
343 | 335 |
344 FX_DWORD m_HeaderOffset; | 336 FX_DWORD m_HeaderOffset; |
345 | 337 |
346 FX_FILESIZE m_FileLen; | 338 FX_FILESIZE m_FileLen; |
347 | 339 |
348 uint8_t* m_pFileBuf; | 340 uint8_t* m_pFileBuf; |
349 | 341 |
350 FX_DWORD m_BufSize; | 342 FX_DWORD m_BufSize; |
351 | 343 |
352 FX_FILESIZE m_BufOffset; | 344 FX_FILESIZE m_BufOffset; |
353 | 345 |
354 std::unique_ptr<CPDF_CryptoHandler> m_pCryptoHandler; | 346 std::unique_ptr<CPDF_CryptoHandler> m_pCryptoHandler; |
355 | 347 |
356 uint8_t m_WordBuffer[257]; | 348 uint8_t m_WordBuffer[257]; |
357 | 349 |
358 FX_DWORD m_WordSize; | 350 FX_DWORD m_WordSize; |
359 | |
360 FX_FILESIZE m_dwWordPos; | |
361 }; | 351 }; |
362 | 352 |
363 #define PDFPARSE_ERROR_SUCCESS 0 | 353 #define PDFPARSE_ERROR_SUCCESS 0 |
364 #define PDFPARSE_ERROR_FILE 1 | 354 #define PDFPARSE_ERROR_FILE 1 |
365 #define PDFPARSE_ERROR_FORMAT 2 | 355 #define PDFPARSE_ERROR_FORMAT 2 |
366 #define PDFPARSE_ERROR_PASSWORD 3 | 356 #define PDFPARSE_ERROR_PASSWORD 3 |
367 #define PDFPARSE_ERROR_HANDLER 4 | 357 #define PDFPARSE_ERROR_HANDLER 4 |
368 #define PDFPARSE_ERROR_CERT 5 | 358 #define PDFPARSE_ERROR_CERT 5 |
369 | 359 |
370 class CPDF_Parser { | 360 class CPDF_Parser { |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 FX_DWORD src_size, | 971 FX_DWORD src_size, |
982 const CPDF_Dictionary* pDict, | 972 const CPDF_Dictionary* pDict, |
983 uint8_t*& dest_buf, | 973 uint8_t*& dest_buf, |
984 FX_DWORD& dest_size, | 974 FX_DWORD& dest_size, |
985 CFX_ByteString& ImageEncoding, | 975 CFX_ByteString& ImageEncoding, |
986 CPDF_Dictionary*& pImageParms, | 976 CPDF_Dictionary*& pImageParms, |
987 FX_DWORD estimated_size, | 977 FX_DWORD estimated_size, |
988 FX_BOOL bImageAcc); | 978 FX_BOOL bImageAcc); |
989 | 979 |
990 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ | 980 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ |
OLD | NEW |