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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 return PDF_CharType[c] == 'R'; | 57 return PDF_CharType[c] == 'R'; |
58 } | 58 } |
59 | 59 |
60 inline bool PDFCharIsLineEnding(uint8_t c) { | 60 inline bool PDFCharIsLineEnding(uint8_t c) { |
61 return c == '\r' || c == '\n'; | 61 return c == '\r' || c == '\n'; |
62 } | 62 } |
63 | 63 |
64 // Indexed by 8-bit char code, contains unicode code points. | 64 // Indexed by 8-bit char code, contains unicode code points. |
65 extern const FX_WORD PDFDocEncoding[256]; | 65 extern const FX_WORD PDFDocEncoding[256]; |
66 | 66 |
67 class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjects { | 67 class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder { |
68 public: | 68 public: |
69 CPDF_Document(); | 69 CPDF_Document(); |
70 explicit CPDF_Document(CPDF_Parser* pParser); | 70 explicit CPDF_Document(CPDF_Parser* pParser); |
71 | 71 |
72 ~CPDF_Document(); | 72 ~CPDF_Document(); |
73 | 73 |
74 CPDF_Parser* GetParser() const { return m_pParser; } | 74 CPDF_Parser* GetParser() const { return m_pParser; } |
75 | 75 |
76 CPDF_Dictionary* GetRoot() const { return m_pRootDict; } | 76 CPDF_Dictionary* GetRoot() const { return m_pRootDict; } |
77 | 77 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 public: | 236 public: |
237 CPDF_SyntaxParser(); | 237 CPDF_SyntaxParser(); |
238 virtual ~CPDF_SyntaxParser(); | 238 virtual ~CPDF_SyntaxParser(); |
239 | 239 |
240 void InitParser(IFX_FileRead* pFileAccess, FX_DWORD HeaderOffset); | 240 void InitParser(IFX_FileRead* pFileAccess, FX_DWORD HeaderOffset); |
241 | 241 |
242 FX_FILESIZE SavePos() { return m_Pos; } | 242 FX_FILESIZE SavePos() { return m_Pos; } |
243 | 243 |
244 void RestorePos(FX_FILESIZE pos) { m_Pos = pos; } | 244 void RestorePos(FX_FILESIZE pos) { m_Pos = pos; } |
245 | 245 |
246 CPDF_Object* GetObject(CPDF_IndirectObjects* pObjList, | 246 CPDF_Object* GetObject(CPDF_IndirectObjectHolder* pObjList, |
247 FX_DWORD objnum, | 247 FX_DWORD objnum, |
248 FX_DWORD gennum, | 248 FX_DWORD gennum, |
249 PARSE_CONTEXT* pContext, | 249 PARSE_CONTEXT* pContext, |
250 FX_BOOL bDecrypt); | 250 FX_BOOL bDecrypt); |
251 | 251 |
252 CPDF_Object* GetObjectByStrict(CPDF_IndirectObjects* pObjList, | 252 CPDF_Object* GetObjectByStrict(CPDF_IndirectObjectHolder* pObjList, |
253 FX_DWORD objnum, | 253 FX_DWORD objnum, |
254 FX_DWORD gennum, | 254 FX_DWORD gennum, |
255 PARSE_CONTEXT* pContext); | 255 PARSE_CONTEXT* pContext); |
256 | 256 |
257 int GetDirectNum(); | 257 int GetDirectNum(); |
258 | 258 |
259 CFX_ByteString GetString(FX_DWORD objnum, FX_DWORD gennum); | 259 CFX_ByteString GetString(FX_DWORD objnum, FX_DWORD gennum); |
260 | 260 |
261 CFX_ByteString GetName(); | 261 CFX_ByteString GetName(); |
262 | 262 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 FX_FILESIZE GetLastXRefOffset() { return m_LastXRefOffset; } | 396 FX_FILESIZE GetLastXRefOffset() { return m_LastXRefOffset; } |
397 | 397 |
398 CPDF_Document* GetDocument() { return m_pDocument; } | 398 CPDF_Document* GetDocument() { return m_pDocument; } |
399 | 399 |
400 FX_DWORD GetRootObjNum(); | 400 FX_DWORD GetRootObjNum(); |
401 FX_DWORD GetInfoObjNum(); | 401 FX_DWORD GetInfoObjNum(); |
402 CPDF_Array* GetIDArray(); | 402 CPDF_Array* GetIDArray(); |
403 | 403 |
404 CPDF_Dictionary* GetEncryptDict() { return m_pEncryptDict; } | 404 CPDF_Dictionary* GetEncryptDict() { return m_pEncryptDict; } |
405 | 405 |
406 CPDF_Object* ParseIndirectObject(CPDF_IndirectObjects* pObjList, | 406 CPDF_Object* ParseIndirectObject(CPDF_IndirectObjectHolder* pObjList, |
407 FX_DWORD objnum, | 407 FX_DWORD objnum, |
408 PARSE_CONTEXT* pContext = NULL); | 408 PARSE_CONTEXT* pContext = NULL); |
409 FX_DWORD GetLastObjNum() const; | 409 FX_DWORD GetLastObjNum() const; |
410 bool IsValidObjectNumber(FX_DWORD objnum) const; | 410 bool IsValidObjectNumber(FX_DWORD objnum) const; |
411 FX_BOOL IsFormStream(FX_DWORD objnum, FX_BOOL& bForm); | 411 FX_BOOL IsFormStream(FX_DWORD objnum, FX_BOOL& bForm); |
412 | 412 |
413 FX_FILESIZE GetObjectOffset(FX_DWORD objnum) const; | 413 FX_FILESIZE GetObjectOffset(FX_DWORD objnum) const; |
414 | 414 |
415 FX_FILESIZE GetObjectSize(FX_DWORD objnum) const; | 415 FX_FILESIZE GetObjectSize(FX_DWORD objnum) const; |
416 | 416 |
417 void GetIndirectBinary(FX_DWORD objnum, uint8_t*& pBuffer, FX_DWORD& size); | 417 void GetIndirectBinary(FX_DWORD objnum, uint8_t*& pBuffer, FX_DWORD& size); |
418 | 418 |
419 IFX_FileRead* GetFileAccess() const { return m_Syntax.m_pFileAccess; } | 419 IFX_FileRead* GetFileAccess() const { return m_Syntax.m_pFileAccess; } |
420 | 420 |
421 int GetFileVersion() const { return m_FileVersion; } | 421 int GetFileVersion() const { return m_FileVersion; } |
422 | 422 |
423 FX_BOOL IsXRefStream() const { return m_bXRefStream; } | 423 FX_BOOL IsXRefStream() const { return m_bXRefStream; } |
424 CPDF_Object* ParseIndirectObjectAt(CPDF_IndirectObjects* pObjList, | 424 CPDF_Object* ParseIndirectObjectAt(CPDF_IndirectObjectHolder* pObjList, |
425 FX_FILESIZE pos, | 425 FX_FILESIZE pos, |
426 FX_DWORD objnum, | 426 FX_DWORD objnum, |
427 PARSE_CONTEXT* pContext); | 427 PARSE_CONTEXT* pContext); |
428 | 428 |
429 CPDF_Object* ParseIndirectObjectAtByStrict(CPDF_IndirectObjects* pObjList, | 429 CPDF_Object* ParseIndirectObjectAtByStrict( |
430 FX_FILESIZE pos, | 430 CPDF_IndirectObjectHolder* pObjList, |
431 FX_DWORD objnum, | 431 FX_FILESIZE pos, |
432 PARSE_CONTEXT* pContext, | 432 FX_DWORD objnum, |
433 FX_FILESIZE* pResultPos); | 433 PARSE_CONTEXT* pContext, |
| 434 FX_FILESIZE* pResultPos); |
434 | 435 |
435 FX_DWORD StartAsynParse(IFX_FileRead* pFile, | 436 FX_DWORD StartAsynParse(IFX_FileRead* pFile, |
436 FX_BOOL bReParse = FALSE, | 437 FX_BOOL bReParse = FALSE, |
437 FX_BOOL bOwnFileRead = TRUE); | 438 FX_BOOL bOwnFileRead = TRUE); |
438 | 439 |
439 FX_DWORD GetFirstPageNo() { return m_dwFirstPageNo; } | 440 FX_DWORD GetFirstPageNo() { return m_dwFirstPageNo; } |
440 | 441 |
441 protected: | 442 protected: |
442 CPDF_Object* ParseDirect(CPDF_Object* pObj); | 443 CPDF_Object* ParseDirect(CPDF_Object* pObj); |
443 | 444 |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 pCharMap); | 789 pCharMap); |
789 } | 790 } |
790 CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString, | 791 CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString, |
791 int len = -1, | 792 int len = -1, |
792 CFX_CharMap* pCharMap = NULL); | 793 CFX_CharMap* pCharMap = NULL); |
793 inline CFX_ByteString PDF_EncodeText(const CFX_WideString& str, | 794 inline CFX_ByteString PDF_EncodeText(const CFX_WideString& str, |
794 CFX_CharMap* pCharMap = NULL) { | 795 CFX_CharMap* pCharMap = NULL) { |
795 return PDF_EncodeText(str.c_str(), str.GetLength(), pCharMap); | 796 return PDF_EncodeText(str.c_str(), str.GetLength(), pCharMap); |
796 } | 797 } |
797 FX_FLOAT PDF_ClipFloat(FX_FLOAT f); | 798 FX_FLOAT PDF_ClipFloat(FX_FLOAT f); |
798 class CFDF_Document : public CPDF_IndirectObjects { | 799 class CFDF_Document : public CPDF_IndirectObjectHolder { |
799 public: | 800 public: |
800 static CFDF_Document* CreateNewDoc(); | 801 static CFDF_Document* CreateNewDoc(); |
801 static CFDF_Document* ParseFile(IFX_FileRead* pFile, | 802 static CFDF_Document* ParseFile(IFX_FileRead* pFile, |
802 FX_BOOL bOwnFile = FALSE); | 803 FX_BOOL bOwnFile = FALSE); |
803 static CFDF_Document* ParseMemory(const uint8_t* pData, FX_DWORD size); | 804 static CFDF_Document* ParseMemory(const uint8_t* pData, FX_DWORD size); |
804 | 805 |
805 ~CFDF_Document(); | 806 ~CFDF_Document(); |
806 | 807 |
807 FX_BOOL WriteBuf(CFX_ByteTextBuf& buf) const; | 808 FX_BOOL WriteBuf(CFX_ByteTextBuf& buf) const; |
808 | 809 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 FX_DWORD src_size, | 980 FX_DWORD src_size, |
980 const CPDF_Dictionary* pDict, | 981 const CPDF_Dictionary* pDict, |
981 uint8_t*& dest_buf, | 982 uint8_t*& dest_buf, |
982 FX_DWORD& dest_size, | 983 FX_DWORD& dest_size, |
983 CFX_ByteString& ImageEncoding, | 984 CFX_ByteString& ImageEncoding, |
984 CPDF_Dictionary*& pImageParms, | 985 CPDF_Dictionary*& pImageParms, |
985 FX_DWORD estimated_size, | 986 FX_DWORD estimated_size, |
986 FX_BOOL bImageAcc); | 987 FX_BOOL bImageAcc); |
987 | 988 |
988 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ | 989 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ |
OLD | NEW |