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 "../fxcrt/fx_ext.h" | 10 #include "../fxcrt/fx_ext.h" |
11 #include "fpdf_objects.h" | 11 #include "fpdf_objects.h" |
12 | 12 |
13 class CPDF_Document; | 13 class CPDF_Document; |
14 class IPDF_DocParser; | |
15 class CPDF_Parser; | 14 class CPDF_Parser; |
16 class CPDF_SecurityHandler; | 15 class CPDF_SecurityHandler; |
17 class CPDF_StandardSecurityHandler; | 16 class CPDF_StandardSecurityHandler; |
18 class CPDF_CryptoHandler; | 17 class CPDF_CryptoHandler; |
19 class CPDF_Object; | 18 class CPDF_Object; |
20 class IFX_FileRead; | 19 class IFX_FileRead; |
21 class CFDF_Document; | 20 class CFDF_Document; |
22 class CFDF_Parser; | 21 class CFDF_Parser; |
23 class CFX_Font; | 22 class CFX_Font; |
24 class CFX_AffineMatrix; | 23 class CFX_AffineMatrix; |
(...skipping 29 matching lines...) Expand all Loading... |
54 | 53 |
55 class IPDF_EnumPageHandler | 54 class IPDF_EnumPageHandler |
56 { | 55 { |
57 public: | 56 public: |
58 virtual ~IPDF_EnumPageHandler() { } | 57 virtual ~IPDF_EnumPageHandler() { } |
59 virtual FX_BOOL EnumPage(CPDF_Dictionary* pPageDict) = 0; | 58 virtual FX_BOOL EnumPage(CPDF_Dictionary* pPageDict) = 0; |
60 }; | 59 }; |
61 class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjects | 60 class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjects |
62 { | 61 { |
63 public: | 62 public: |
64 | |
65 CPDF_Document(IPDF_DocParser* pParser); | |
66 | |
67 CPDF_Document(); | 63 CPDF_Document(); |
| 64 explicit CPDF_Document(CPDF_Parser* pParser); |
68 | 65 |
69 ~CPDF_Document(); | 66 ~CPDF_Document(); |
70 | 67 |
71 IPDF_DocParser*» » » GetParser() const | 68 CPDF_Parser*» » » GetParser() const |
72 { | 69 { |
73 return m_pParser; | 70 return m_pParser; |
74 } | 71 } |
75 | 72 |
76 CPDF_Dictionary* GetRoot() const | 73 CPDF_Dictionary* GetRoot() const |
77 { | 74 { |
78 return m_pRootDict; | 75 return m_pRootDict; |
79 } | 76 } |
80 | 77 |
81 CPDF_Dictionary* GetInfo() const | 78 CPDF_Dictionary* GetInfo() const |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 FX_BOOL m_Flags; | 360 FX_BOOL m_Flags; |
364 | 361 |
365 FX_FILESIZE m_DictStart; | 362 FX_FILESIZE m_DictStart; |
366 | 363 |
367 FX_FILESIZE m_DictEnd; | 364 FX_FILESIZE m_DictEnd; |
368 | 365 |
369 FX_FILESIZE m_DataStart; | 366 FX_FILESIZE m_DataStart; |
370 | 367 |
371 FX_FILESIZE m_DataEnd; | 368 FX_FILESIZE m_DataEnd; |
372 }; | 369 }; |
373 class IPDF_DocParser | |
374 { | |
375 public: | |
376 virtual ~IPDF_DocParser() { } | |
377 virtual FX_DWORD GetRootObjNum() = 0; | |
378 | |
379 virtual FX_DWORD GetInfoObjNum() = 0; | |
380 | |
381 virtual CPDF_Object* ParseIndirectObject(CPDF_IndirectObjects* pObjLi
st, FX_DWORD objnum, PARSE_CONTEXT* pContext = NULL) = 0; | |
382 | |
383 virtual FX_DWORD GetLastObjNum() = 0; | |
384 | |
385 virtual CPDF_Array* GetIDArray() = 0; | |
386 | |
387 virtual CPDF_Dictionary* GetEncryptDict() = 0; | |
388 | |
389 FX_BOOL IsEncrypted() | |
390 { | |
391 return GetEncryptDict() != NULL; | |
392 } | |
393 | |
394 virtual FX_DWORD GetPermissions(FX_BOOL bCheckRevision = FALSE) = 0; | |
395 | |
396 virtual FX_BOOL IsOwner() = 0; | |
397 | |
398 virtual FX_BOOL IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) =
0; | |
399 }; | |
400 | 370 |
401 #define PDFPARSE_ERROR_SUCCESS 0 | 371 #define PDFPARSE_ERROR_SUCCESS 0 |
402 #define PDFPARSE_ERROR_FILE 1 | 372 #define PDFPARSE_ERROR_FILE 1 |
403 #define PDFPARSE_ERROR_FORMAT 2 | 373 #define PDFPARSE_ERROR_FORMAT 2 |
404 #define PDFPARSE_ERROR_PASSWORD 3 | 374 #define PDFPARSE_ERROR_PASSWORD 3 |
405 #define PDFPARSE_ERROR_HANDLER 4 | 375 #define PDFPARSE_ERROR_HANDLER 4 |
406 #define PDFPARSE_ERROR_CERT 5 | 376 #define PDFPARSE_ERROR_CERT 5 |
407 class CPDF_Parser FX_FINAL : public IPDF_DocParser | 377 |
| 378 class CPDF_Parser |
408 { | 379 { |
409 public: | 380 public: |
410 | |
411 CPDF_Parser(); | 381 CPDF_Parser(); |
412 ~CPDF_Parser() override; | 382 ~CPDF_Parser(); |
413 | 383 |
414 FX_DWORD StartParse(FX_LPCSTR filename, FX_BOOL bReParse
= FALSE); | 384 FX_DWORD StartParse(FX_LPCSTR filename, FX_BOOL bReParse
= FALSE); |
415 | |
416 FX_DWORD StartParse(FX_LPCWSTR filename, FX_BOOL bReParse
= FALSE); | 385 FX_DWORD StartParse(FX_LPCWSTR filename, FX_BOOL bReParse
= FALSE); |
417 | |
418 FX_DWORD StartParse(IFX_FileRead* pFile, FX_BOOL bReParse
= FALSE, FX_BOOL bOwnFileRead = TRUE); | 386 FX_DWORD StartParse(IFX_FileRead* pFile, FX_BOOL bReParse
= FALSE, FX_BOOL bOwnFileRead = TRUE); |
419 | 387 |
420 void CloseParser(FX_BOOL bReParse = FALSE); | 388 void CloseParser(FX_BOOL bReParse = FALSE); |
421 | 389 |
422 virtual FX_DWORD» GetPermissions(FX_BOOL bCheckRevision = FALSE) FX_OVERRI
DE; | 390 FX_DWORD» GetPermissions(FX_BOOL bCheckRevision = FALSE); |
423 | 391 |
424 virtual FX_BOOL» » IsOwner() FX_OVERRIDE; | 392 FX_BOOL» » IsOwner(); |
425 | 393 |
426 void SetPassword(const FX_CHAR* password) | 394 void SetPassword(const FX_CHAR* password) |
427 { | 395 { |
428 m_Password = password; | 396 m_Password = password; |
429 } | 397 } |
430 | 398 |
431 CFX_ByteString GetPassword() | 399 CFX_ByteString GetPassword() |
432 { | 400 { |
433 return m_Password; | 401 return m_Password; |
434 } | 402 } |
(...skipping 22 matching lines...) Expand all Loading... |
457 | 425 |
458 FX_FILESIZE GetLastXRefOffset() | 426 FX_FILESIZE GetLastXRefOffset() |
459 { | 427 { |
460 return m_LastXRefOffset; | 428 return m_LastXRefOffset; |
461 } | 429 } |
462 | 430 |
463 CPDF_Document* GetDocument() | 431 CPDF_Document* GetDocument() |
464 { | 432 { |
465 return m_pDocument; | 433 return m_pDocument; |
466 } | 434 } |
467 CFX_ArrayTemplate<CPDF_Dictionary *> * GetOtherTrailers() | 435 |
| 436 CFX_ArrayTemplate<CPDF_Dictionary*>* GetOtherTrailers() |
468 { | 437 { |
469 return &m_Trailers; | 438 return &m_Trailers; |
470 } | 439 } |
471 | 440 |
472 virtual FX_DWORD» GetRootObjNum() FX_OVERRIDE; | 441 FX_DWORD» GetRootObjNum(); |
473 virtual FX_DWORD» GetInfoObjNum() FX_OVERRIDE; | 442 FX_DWORD» GetInfoObjNum() ; |
474 virtual CPDF_Array*»GetIDArray() FX_OVERRIDE; | 443 CPDF_Array*»GetIDArray() ; |
475 virtual CPDF_Dictionary*» GetEncryptDict() FX_OVERRIDE | 444 |
| 445 CPDF_Dictionary*» GetEncryptDict() |
476 { | 446 { |
477 return m_pEncryptDict; | 447 return m_pEncryptDict; |
478 } | 448 } |
479 virtual CPDF_Object*» » ParseIndirectObject(CPDF_IndirectObjects
* pObjList, FX_DWORD objnum, PARSE_CONTEXT* pContext = NULL) FX_OVERRIDE; | 449 |
480 virtual FX_DWORD» GetLastObjNum() FX_OVERRIDE; | 450 FX_BOOL» » » » IsEncrypted() |
481 virtual FX_BOOL» » IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) F
X_OVERRIDE; | 451 { |
| 452 return GetEncryptDict() != NULL; |
| 453 } |
| 454 |
| 455 |
| 456 CPDF_Object*» » ParseIndirectObject(CPDF_IndirectObjects* pObjLi
st, FX_DWORD objnum, PARSE_CONTEXT* pContext = NULL) ; |
| 457 FX_DWORD» » » GetLastObjNum(); |
| 458 FX_BOOL» » » » IsFormStream(FX_DWORD objnum, FX_BOOL& b
Form); |
482 | 459 |
483 FX_FILESIZE GetObjectOffset(FX_DWORD objnum); | 460 FX_FILESIZE GetObjectOffset(FX_DWORD objnum); |
484 | 461 |
485 FX_FILESIZE GetObjectSize(FX_DWORD objnum); | 462 FX_FILESIZE GetObjectSize(FX_DWORD objnum); |
486 | 463 |
487 int GetObjectVersion(FX_DWORD objnum) | 464 int GetObjectVersion(FX_DWORD objnum) |
488 { | 465 { |
489 return m_ObjVersion[objnum]; | 466 return m_ObjVersion[objnum]; |
490 } | 467 } |
491 | 468 |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 PDF_DATAAVAIL_PAGE, | 917 PDF_DATAAVAIL_PAGE, |
941 PDF_DATAAVAIL_PAGE_LATERLOAD, | 918 PDF_DATAAVAIL_PAGE_LATERLOAD, |
942 PDF_DATAAVAIL_RESOURCES, | 919 PDF_DATAAVAIL_RESOURCES, |
943 PDF_DATAAVAIL_DONE, | 920 PDF_DATAAVAIL_DONE, |
944 PDF_DATAAVAIL_ERROR, | 921 PDF_DATAAVAIL_ERROR, |
945 PDF_DATAAVAIL_LOADALLFILE, | 922 PDF_DATAAVAIL_LOADALLFILE, |
946 PDF_DATAAVAIL_TRAILER_APPEND | 923 PDF_DATAAVAIL_TRAILER_APPEND |
947 }; | 924 }; |
948 | 925 |
949 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ | 926 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ |
OLD | NEW |