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 _FPDF_PARSER_ | 7 #ifndef _FPDF_PARSER_ |
8 #define _FPDF_PARSER_ | 8 #define _FPDF_PARSER_ |
9 #ifndef _FX_BASIC_H_ | 9 #ifndef _FX_BASIC_H_ |
10 #include "../fxcrt/fx_ext.h" | 10 #include "../fxcrt/fx_ext.h" |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 }; | 862 }; |
863 #define PDF_IS_LINEARIZED 1 | 863 #define PDF_IS_LINEARIZED 1 |
864 #define PDF_NOT_LINEARIZED 0 | 864 #define PDF_NOT_LINEARIZED 0 |
865 #define PDF_UNKNOW_LINEARIZED -1 | 865 #define PDF_UNKNOW_LINEARIZED -1 |
866 #define PDFFORM_NOTAVAIL 0 | 866 #define PDFFORM_NOTAVAIL 0 |
867 #define PDFFORM_AVAIL 1 | 867 #define PDFFORM_AVAIL 1 |
868 #define PDFFORM_NOTEXIST 2 | 868 #define PDFFORM_NOTEXIST 2 |
869 class IPDF_DataAvail | 869 class IPDF_DataAvail |
870 { | 870 { |
871 public: | 871 public: |
| 872 static IPDF_DataAvail* Create(IFX_FileAvail* pFileAvail, IFX_FileRead* pFile
Read); |
872 virtual ~IPDF_DataAvail() { } | 873 virtual ~IPDF_DataAvail() { } |
873 | 874 |
| 875 IFX_FileAvail* GetFileAvail() const { return m_pFileAvail; } |
| 876 IFX_FileRead* GetFileRead() const { return m_pFileRead; } |
| 877 |
874 virtual FX_BOOL IsDocAvail(IFX_DownloadHints* pHints) =
0; | 878 virtual FX_BOOL IsDocAvail(IFX_DownloadHints* pHints) =
0; |
| 879 virtual void SetDocument(CPDF_Document* pDoc) = 0; |
| 880 virtual FX_BOOL IsPageAvail(int iPage, IFX_DownloadHints
* pHints) = 0; |
| 881 virtual FX_BOOL IsLinearized() = 0; |
| 882 virtual FX_INT32 IsFormAvail(IFX_DownloadHints *pHints) = 0; |
| 883 virtual FX_INT32 IsLinearizedPDF() = 0; |
| 884 virtual void GetLinearizedMainXRefInfo(FX_FIL
ESIZE *pPos, FX_DWORD *pSize) = 0; |
875 | 885 |
876 virtual void» » » SetDocument(CPDF_Document* pDoc) = 0; | 886 protected: |
| 887 IPDF_DataAvail(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRead); |
877 | 888 |
878 virtual FX_BOOL» » » IsPageAvail(int iPage, IFX_DownloadHints
* pHints) = 0; | 889 IFX_FileAvail* m_pFileAvail; |
879 | 890 IFX_FileRead* m_pFileRead; |
880 virtual FX_BOOL» » » IsLinearized() = 0; | |
881 | |
882 virtual FX_INT32» » IsFormAvail(IFX_DownloadHints *pHints) = 0; | |
883 | |
884 virtual FX_INT32» » IsLinearizedPDF() = 0; | |
885 | |
886 virtual void» » » » GetLinearizedMainXRefInfo(FX_FIL
ESIZE *pPos, FX_DWORD *pSize) = 0; | |
887 }; | 891 }; |
888 class CPDF_SortObjNumArray : public CFX_Object | 892 class CPDF_SortObjNumArray : public CFX_Object |
889 { | 893 { |
890 public: | 894 public: |
891 | 895 |
892 void AddObjNum(FX_DWORD dwObjNum); | 896 void AddObjNum(FX_DWORD dwObjNum); |
893 | 897 |
894 FX_BOOL Find(FX_DWORD dwObjNum); | 898 FX_BOOL Find(FX_DWORD dwObjNum); |
895 | 899 |
896 void RemoveAll() | 900 void RemoveAll() |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 PDF_DATAAVAIL_ACROFORM_SUBOBJECT, | 939 PDF_DATAAVAIL_ACROFORM_SUBOBJECT, |
936 PDF_DATAAVAIL_PAGETREE, | 940 PDF_DATAAVAIL_PAGETREE, |
937 PDF_DATAAVAIL_PAGE, | 941 PDF_DATAAVAIL_PAGE, |
938 PDF_DATAAVAIL_PAGE_LATERLOAD, | 942 PDF_DATAAVAIL_PAGE_LATERLOAD, |
939 PDF_DATAAVAIL_RESOURCES, | 943 PDF_DATAAVAIL_RESOURCES, |
940 PDF_DATAAVAIL_DONE, | 944 PDF_DATAAVAIL_DONE, |
941 PDF_DATAAVAIL_ERROR, | 945 PDF_DATAAVAIL_ERROR, |
942 PDF_DATAAVAIL_LOADALLFILE, | 946 PDF_DATAAVAIL_LOADALLFILE, |
943 PDF_DATAAVAIL_TRAILER_APPEND | 947 PDF_DATAAVAIL_TRAILER_APPEND |
944 }; | 948 }; |
945 class CPDF_DataAvail FX_FINAL : public CFX_Object, public IPDF_DataAvail | |
946 { | |
947 public: | |
948 | |
949 CPDF_DataAvail(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRead); | |
950 ~CPDF_DataAvail(); | |
951 | |
952 virtual FX_BOOL IsDocAvail(IFX_DownloadHints* pHints) F
X_OVERRIDE; | |
953 | |
954 virtual void SetDocument(CPDF_Document* pDoc) FX_OVE
RRIDE; | |
955 | |
956 virtual FX_BOOL IsPageAvail(int iPage, IFX_DownloadHints
* pHints) FX_OVERRIDE; | |
957 | |
958 virtual FX_INT32 IsFormAvail(IFX_DownloadHints *pHints)
FX_OVERRIDE; | |
959 | |
960 virtual FX_INT32 IsLinearizedPDF() FX_OVERRIDE; | |
961 | |
962 virtual FX_BOOL IsLinearized() FX_OVERRIDE | |
963 { | |
964 return m_bLinearized; | |
965 } | |
966 | |
967 virtual void GetLinearizedMainXRefInfo(FX_FILESIZE *p
Pos, FX_DWORD *pSize) FX_OVERRIDE; | |
968 IFX_FileRead* GetFileRead() const | |
969 { | |
970 return m_pFileRead; | |
971 } | |
972 IFX_FileAvail* GetFileAvail() const | |
973 { | |
974 return m_pFileAvail; | |
975 } | |
976 protected: | |
977 FX_DWORD GetObjectSize(FX_DWORD objnum, FX_FILESI
ZE& offset); | |
978 FX_BOOL IsObjectsAvail(CFX_PtrArray& obj_array,
FX_BOOL bParsePage, IFX_DownloadHints* pHints, CFX_PtrArray &ret_array); | |
979 FX_BOOL CheckDocStatus(IFX_DownloadHints *pHints
); | |
980 FX_BOOL CheckHeader(IFX_DownloadHints* pHints); | |
981 FX_BOOL CheckFirstPage(IFX_DownloadHints *pHints
); | |
982 FX_BOOL CheckEnd(IFX_DownloadHints *pHints); | |
983 FX_BOOL CheckCrossRef(IFX_DownloadHints* pHints)
; | |
984 FX_BOOL CheckCrossRefItem(IFX_DownloadHints *pHi
nts); | |
985 FX_BOOL CheckTrailer(IFX_DownloadHints* pHints); | |
986 FX_BOOL CheckRoot(IFX_DownloadHints* pHints); | |
987 FX_BOOL CheckInfo(IFX_DownloadHints* pHints); | |
988 FX_BOOL CheckPages(IFX_DownloadHints* pHints); | |
989 FX_BOOL CheckPage(IFX_DownloadHints* pHints); | |
990 FX_BOOL CheckResources(IFX_DownloadHints* pHints
); | |
991 FX_BOOL CheckAnnots(IFX_DownloadHints* pHints); | |
992 FX_BOOL CheckAcroForm(IFX_DownloadHints* pHints)
; | |
993 FX_BOOL CheckAcroFormSubObject(IFX_DownloadHints
* pHints); | |
994 FX_BOOL CheckTrailerAppend(IFX_DownloadHints* pH
ints); | |
995 FX_BOOL CheckPageStatus(IFX_DownloadHints* pHint
s); | |
996 FX_BOOL CheckAllCrossRefStream(IFX_DownloadHints
*pHints); | |
997 | |
998 FX_DWORD CheckCrossRefStream(IFX_DownloadHints *p
Hints, FX_FILESIZE &xref_offset); | |
999 FX_BOOL IsLinearizedFile(FX_LPBYTE pData, FX_DWO
RD dwLen); | |
1000 void SetStartOffset(FX_FILESIZE dwOffset); | |
1001 FX_BOOL GetNextToken(CFX_ByteString &token); | |
1002 FX_BOOL GetNextChar(FX_BYTE &ch); | |
1003 CPDF_Object * ParseIndirectObjectAt(FX_FILESIZE pos, F
X_DWORD objnum); | |
1004 CPDF_Object * GetObject(FX_DWORD objnum, IFX_DownloadH
ints* pHints, FX_BOOL *pExistInFile); | |
1005 FX_BOOL GetPageKids(CPDF_Parser *pParser, CPDF_O
bject *pPages); | |
1006 FX_BOOL PreparePageItem(); | |
1007 FX_BOOL LoadPages(IFX_DownloadHints* pHints); | |
1008 FX_BOOL LoadAllXref(IFX_DownloadHints* pHints); | |
1009 FX_BOOL LoadAllFile(IFX_DownloadHints* pHints); | |
1010 FX_BOOL CheckLinearizedData(IFX_DownloadHints* p
Hints); | |
1011 FX_BOOL CheckFileResources(IFX_DownloadHints* pH
ints); | |
1012 FX_BOOL CheckPageAnnots(int iPage, IFX_DownloadH
ints* pHints); | |
1013 | |
1014 FX_BOOL CheckLinearizedFirstPage(int iPage, IFX_
DownloadHints* pHints); | |
1015 FX_BOOL HaveResourceAncestor(CPDF_Dictionary *pD
ict); | |
1016 FX_BOOL CheckPage(FX_INT32 iPage, IFX_DownloadHi
nts* pHints); | |
1017 FX_BOOL LoadDocPages(IFX_DownloadHints* pHints); | |
1018 FX_BOOL LoadDocPage(FX_INT32 iPage, IFX_Download
Hints* pHints); | |
1019 FX_BOOL CheckPageNode(CPDF_PageNode &pageNodes,
FX_INT32 iPage, FX_INT32 &iCount, IFX_DownloadHints* pHints); | |
1020 FX_BOOL CheckUnkownPageNode(FX_DWORD dwPageNo, C
PDF_PageNode *pPageNode, IFX_DownloadHints* pHints); | |
1021 FX_BOOL CheckArrayPageNode(FX_DWORD dwPageNo, CP
DF_PageNode *pPageNode, IFX_DownloadHints* pHints); | |
1022 FX_BOOL CheckPageCount(IFX_DownloadHints* pHints
); | |
1023 FX_BOOL IsFirstCheck(int iPage); | |
1024 void ResetFirstCheck(int iPage); | |
1025 | |
1026 CPDF_Parser m_parser; | |
1027 | |
1028 CPDF_SyntaxParser m_syntaxParser; | |
1029 | |
1030 CPDF_Object *m_pRoot; | |
1031 | |
1032 FX_DWORD m_dwRootObjNum; | |
1033 | |
1034 FX_DWORD m_dwInfoObjNum; | |
1035 | |
1036 CPDF_Object *m_pLinearized; | |
1037 | |
1038 CPDF_Object *m_pTrailer; | |
1039 | |
1040 FX_BOOL m_bDocAvail; | |
1041 | |
1042 FX_FILESIZE m_dwHeaderOffset; | |
1043 | |
1044 FX_FILESIZE m_dwLastXRefOffset; | |
1045 | |
1046 FX_FILESIZE m_dwXRefOffset; | |
1047 | |
1048 FX_FILESIZE m_dwTrailerOffset; | |
1049 | |
1050 FX_FILESIZE m_dwCurrentOffset; | |
1051 | |
1052 PDF_DATAAVAIL_STATUS m_docStatus; | |
1053 | |
1054 IFX_FileAvail* m_pFileAvail; | |
1055 | |
1056 IFX_FileRead* m_pFileRead; | |
1057 | |
1058 FX_FILESIZE m_dwFileLen; | |
1059 | |
1060 CPDF_Document* m_pDocument; | |
1061 | |
1062 CPDF_SortObjNumArray m_objnum_array; | |
1063 | |
1064 CFX_PtrArray m_objs_array; | |
1065 | |
1066 FX_FILESIZE m_Pos; | |
1067 | |
1068 FX_FILESIZE m_bufferOffset; | |
1069 | |
1070 FX_DWORD m_bufferSize; | |
1071 | |
1072 CFX_ByteString m_WordBuf; | |
1073 | |
1074 FX_BYTE m_WordBuffer[257]; | |
1075 | |
1076 FX_DWORD m_WordSize; | |
1077 | |
1078 FX_BYTE m_bufferData[512]; | |
1079 | |
1080 CFX_FileSizeArray m_CrossOffset; | |
1081 | |
1082 CFX_DWordArray m_XRefStreamList; | |
1083 | |
1084 CFX_DWordArray m_PageObjList; | |
1085 | |
1086 FX_DWORD m_PagesObjNum; | |
1087 | |
1088 FX_BOOL m_bLinearized; | |
1089 | |
1090 FX_DWORD m_dwFirstPageNo; | |
1091 | |
1092 FX_BOOL m_bLinearedDataOK; | |
1093 | |
1094 FX_BOOL m_bMainXRefLoadTried; | |
1095 | |
1096 FX_BOOL m_bMainXRefLoadedOK; | |
1097 | |
1098 FX_BOOL m_bPagesTreeLoad; | |
1099 | |
1100 FX_BOOL m_bPagesLoad; | |
1101 | |
1102 CPDF_Parser * m_pCurrentParser; | |
1103 | |
1104 FX_FILESIZE m_dwCurrentXRefSteam; | |
1105 | |
1106 FX_BOOL m_bAnnotsLoad; | |
1107 | |
1108 FX_BOOL m_bHaveAcroForm; | |
1109 | |
1110 FX_DWORD m_dwAcroFormObjNum; | |
1111 | |
1112 FX_BOOL m_bAcroFormLoad; | |
1113 | |
1114 CPDF_Object * m_pAcroForm; | |
1115 | |
1116 CFX_PtrArray m_arrayAcroforms; | |
1117 | |
1118 CPDF_Dictionary * m_pPageDict; | |
1119 | |
1120 CPDF_Object * m_pPageResource; | |
1121 | |
1122 FX_BOOL m_bNeedDownLoadResource; | |
1123 | |
1124 FX_BOOL m_bPageLoadedOK; | |
1125 | |
1126 FX_BOOL m_bLinearizedFormParamLoad; | |
1127 | |
1128 CFX_PtrArray m_PagesArray; | |
1129 | |
1130 FX_DWORD m_dwEncryptObjNum; | |
1131 | |
1132 FX_FILESIZE m_dwPrevXRefOffset; | |
1133 | |
1134 FX_BOOL m_bTotalLoadPageTree; | |
1135 | |
1136 FX_BOOL m_bCurPageDictLoadOK; | |
1137 | |
1138 CPDF_PageNode m_pageNodes; | |
1139 | |
1140 CFX_CMapDWordToDWord * m_pageMapCheckState; | |
1141 | |
1142 CFX_CMapDWordToDWord * m_pagesLoadState; | |
1143 }; | |
1144 #endif | 949 #endif |
OLD | NEW |