Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1020)

Side by Side Diff: core/fpdfapi/fpdf_parser/include/cpdf_parser.h

Issue 2267173005: Removing CPDF_Parser::CloseParser. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_parser.cpp ('k') | fpdfsdk/fpdfview.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_PARSER_H_ 7 #ifndef CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_PARSER_H_
8 #define CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_PARSER_H_ 8 #define CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_PARSER_H_
9 9
10 #include <map> 10 #include <map>
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 protected: 89 protected:
90 struct ObjectInfo { 90 struct ObjectInfo {
91 ObjectInfo() : pos(0), type(0), gennum(0) {} 91 ObjectInfo() : pos(0), type(0), gennum(0) {}
92 92
93 FX_FILESIZE pos; 93 FX_FILESIZE pos;
94 uint8_t type; 94 uint8_t type;
95 uint16_t gennum; 95 uint16_t gennum;
96 }; 96 };
97 97
98 void CloseParser(); 98 std::unique_ptr<CPDF_SyntaxParser> m_pSyntax;
99 std::map<uint32_t, ObjectInfo> m_ObjectInfo;
100
101 bool LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_BOOL bSkip);
102 FX_BOOL RebuildCrossRef();
103
104 private:
105 friend class CPDF_DataAvail;
106
107 enum class ParserState {
108 kDefault,
109 kComment,
110 kWhitespace,
111 kString,
112 kHexString,
113 kEscapedString,
114 kXref,
115 kObjNum,
116 kPostObjNum,
117 kGenNum,
118 kPostGenNum,
119 kTrailer,
120 kBeginObj,
121 kEndObj
122 };
123
99 CPDF_Object* ParseDirect(CPDF_Object* pObj); 124 CPDF_Object* ParseDirect(CPDF_Object* pObj);
100 FX_BOOL LoadAllCrossRefV4(FX_FILESIZE pos); 125 FX_BOOL LoadAllCrossRefV4(FX_FILESIZE pos);
101 FX_BOOL LoadAllCrossRefV5(FX_FILESIZE pos); 126 FX_BOOL LoadAllCrossRefV5(FX_FILESIZE pos);
102 bool LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_BOOL bSkip);
103 FX_BOOL LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef); 127 FX_BOOL LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef);
104 CPDF_Dictionary* LoadTrailerV4(); 128 CPDF_Dictionary* LoadTrailerV4();
105 FX_BOOL RebuildCrossRef();
106 Error SetEncryptHandler(); 129 Error SetEncryptHandler();
107 void ReleaseEncryptHandler(); 130 void ReleaseEncryptHandler();
108 FX_BOOL LoadLinearizedAllCrossRefV4(FX_FILESIZE pos, uint32_t dwObjCount); 131 FX_BOOL LoadLinearizedAllCrossRefV4(FX_FILESIZE pos, uint32_t dwObjCount);
109 FX_BOOL LoadLinearizedCrossRefV4(FX_FILESIZE pos, uint32_t dwObjCount); 132 FX_BOOL LoadLinearizedCrossRefV4(FX_FILESIZE pos, uint32_t dwObjCount);
110 FX_BOOL LoadLinearizedAllCrossRefV5(FX_FILESIZE pos); 133 FX_BOOL LoadLinearizedAllCrossRefV5(FX_FILESIZE pos);
111 Error LoadLinearizedMainXRefTable(); 134 Error LoadLinearizedMainXRefTable();
112 CPDF_StreamAcc* GetObjectStream(uint32_t number); 135 CPDF_StreamAcc* GetObjectStream(uint32_t number);
113 FX_BOOL IsLinearizedFile(IFX_FileRead* pFileAccess, uint32_t offset); 136 FX_BOOL IsLinearizedFile(IFX_FileRead* pFileAccess, uint32_t offset);
114 void SetEncryptDictionary(CPDF_Dictionary* pDict); 137 void SetEncryptDictionary(CPDF_Dictionary* pDict);
115 void ShrinkObjectMap(uint32_t size); 138 void ShrinkObjectMap(uint32_t size);
116 // A simple check whether the cross reference table matches with 139 // A simple check whether the cross reference table matches with
117 // the objects. 140 // the objects.
118 bool VerifyCrossRefV4(); 141 bool VerifyCrossRefV4();
119 142
120 CPDF_Document* m_pDocument; // not owned 143 CPDF_Document* m_pDocument; // not owned
121 std::unique_ptr<CPDF_SyntaxParser> m_pSyntax; 144 bool m_bHasParsed;
122 bool m_bOwnFileRead; 145 bool m_bOwnFileRead;
123 int m_FileVersion; 146 int m_FileVersion;
124 CPDF_Dictionary* m_pTrailer; 147 CPDF_Dictionary* m_pTrailer;
125 CPDF_Dictionary* m_pEncryptDict; 148 CPDF_Dictionary* m_pEncryptDict;
126 FX_FILESIZE m_LastXRefOffset; 149 FX_FILESIZE m_LastXRefOffset;
127 FX_BOOL m_bXRefStream; 150 FX_BOOL m_bXRefStream;
128 std::unique_ptr<CPDF_SecurityHandler> m_pSecurityHandler; 151 std::unique_ptr<CPDF_SecurityHandler> m_pSecurityHandler;
129 CFX_ByteString m_Password; 152 CFX_ByteString m_Password;
130 std::map<uint32_t, ObjectInfo> m_ObjectInfo;
131 std::set<FX_FILESIZE> m_SortedOffset; 153 std::set<FX_FILESIZE> m_SortedOffset;
132 CFX_ArrayTemplate<CPDF_Dictionary*> m_Trailers; 154 CFX_ArrayTemplate<CPDF_Dictionary*> m_Trailers;
133 bool m_bVersionUpdated; 155 bool m_bVersionUpdated;
134 CPDF_Object* m_pLinearized; 156 CPDF_Object* m_pLinearized;
135 uint32_t m_dwFirstPageNo; 157 uint32_t m_dwFirstPageNo;
136 uint32_t m_dwXrefStartObjNum; 158 uint32_t m_dwXrefStartObjNum;
137 159
138 // A map of object numbers to indirect streams. Map owns the streams. 160 // A map of object numbers to indirect streams. Map owns the streams.
139 std::map<uint32_t, std::unique_ptr<CPDF_StreamAcc>> m_ObjectStreamMap; 161 std::map<uint32_t, std::unique_ptr<CPDF_StreamAcc>> m_ObjectStreamMap;
140 162
141 // Mapping of object numbers to offsets. The offsets are relative to the first 163 // Mapping of object numbers to offsets. The offsets are relative to the first
142 // object in the stream. 164 // object in the stream.
143 using StreamObjectCache = std::map<uint32_t, uint32_t>; 165 using StreamObjectCache = std::map<uint32_t, uint32_t>;
144 166
145 // Mapping of streams to their object caches. This is valid as long as the 167 // Mapping of streams to their object caches. This is valid as long as the
146 // streams in |m_ObjectStreamMap| are valid. 168 // streams in |m_ObjectStreamMap| are valid.
147 std::map<CPDF_StreamAcc*, StreamObjectCache> m_ObjCache; 169 std::map<CPDF_StreamAcc*, StreamObjectCache> m_ObjCache;
148 170
149 // All indirect object numbers that are being parsed. 171 // All indirect object numbers that are being parsed.
150 std::set<uint32_t> m_ParsingObjNums; 172 std::set<uint32_t> m_ParsingObjNums;
151 173
152 friend class CPDF_DataAvail;
153 174
154 private:
155 enum class ParserState {
156 kDefault,
157 kComment,
158 kWhitespace,
159 kString,
160 kHexString,
161 kEscapedString,
162 kXref,
163 kObjNum,
164 kPostObjNum,
165 kGenNum,
166 kPostGenNum,
167 kTrailer,
168 kBeginObj,
169 kEndObj
170 };
171 }; 175 };
172 176
173 #endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_PARSER_H_ 177 #endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_PARSER_H_
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_parser.cpp ('k') | fpdfsdk/fpdfview.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698