Initial commit.
[pdfium.git] / core / include / fpdfapi / fpdf_parser.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4  \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _FPDF_PARSER_\r
8 #define _FPDF_PARSER_\r
9 #ifndef _FX_BASIC_H_\r
10 #include "../fxcrt/fx_ext.h"\r
11 #endif\r
12 #ifndef _FPDF_OBJECTS_\r
13 #include "fpdf_objects.h"\r
14 #endif\r
15 class CPDF_Document;\r
16 class IPDF_DocParser;\r
17 class CPDF_Parser;\r
18 class CPDF_SecurityHandler;\r
19 class CPDF_StandardSecurityHandler;\r
20 class CPDF_CryptoHandler;\r
21 class CPDF_Object;\r
22 class IFX_FileRead;\r
23 class CFDF_Document;\r
24 class CFDF_Parser;\r
25 class CFX_Font;\r
26 class CFX_AffineMatrix;\r
27 class CFX_FloatRect;\r
28 class CPDF_Point;\r
29 class CPDF_DocPageData;\r
30 class CPDF_DocRenderData;\r
31 class CPDF_ModuleMgr;\r
32 class CFX_DIBSource;\r
33 class CPDF_Font;\r
34 class CPDF_Image;\r
35 class CPDF_ColorSpace;\r
36 class CPDF_Pattern;\r
37 class CPDF_FontEncoding;\r
38 class CPDF_IccProfile;\r
39 class CFX_PrivateData;\r
40 #define FPDFPERM_PRINT                  0x0004\r
41 #define FPDFPERM_MODIFY                 0x0008\r
42 #define FPDFPERM_EXTRACT                0x0010\r
43 #define FPDFPERM_ANNOT_FORM             0x0020\r
44 #define FPDFPERM_FILL_FORM              0x0100\r
45 #define FPDFPERM_EXTRACT_ACCESS 0x0200\r
46 #define FPDFPERM_ASSEMBLE               0x0400\r
47 #define FPDFPERM_PRINT_HIGH             0x0800\r
48 #define FPDF_PAGE_MAX_NUM               0xFFFFF\r
49 class IPDF_EnumPageHandler\r
50 {\r
51 public:\r
52 \r
53     virtual FX_BOOL EnumPage(CPDF_Dictionary* pPageDict) = 0;\r
54 };\r
55 class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjects\r
56 {\r
57 public:\r
58 \r
59     CPDF_Document(IPDF_DocParser* pParser);\r
60 \r
61     CPDF_Document();\r
62 \r
63     ~CPDF_Document();\r
64 \r
65     IPDF_DocParser*                     GetParser() const\r
66     {\r
67         return m_pParser;\r
68     }\r
69 \r
70     CPDF_Dictionary*            GetRoot() const\r
71     {\r
72         return m_pRootDict;\r
73     }\r
74 \r
75     CPDF_Dictionary*            GetInfo() const\r
76     {\r
77         return m_pInfoDict;\r
78     }\r
79 \r
80     void                                        GetID(CFX_ByteString& id1, CFX_ByteString& id2) const\r
81     {\r
82         id1 = m_ID1;\r
83         id2 = m_ID2;\r
84     }\r
85 \r
86     int                                         GetPageCount() const;\r
87 \r
88     CPDF_Dictionary*            GetPage(int iPage);\r
89 \r
90     int                                         GetPageIndex(FX_DWORD objnum);\r
91 \r
92     void                                        EnumPages(IPDF_EnumPageHandler* pHandler);\r
93 \r
94     FX_DWORD                            GetUserPermissions(FX_BOOL bCheckRevision = FALSE) const;\r
95 \r
96     FX_BOOL                                     IsOwner() const;\r
97 \r
98 \r
99 \r
100     CPDF_DocPageData*           GetPageData()\r
101     {\r
102         return GetValidatePageData();\r
103     }\r
104 \r
105     void                                        ClearPageData();\r
106 \r
107     void                                        RemoveColorSpaceFromPageData(CPDF_Object* pObject);\r
108 \r
109 \r
110     CPDF_DocRenderData*         GetRenderData()\r
111     {\r
112         return GetValidateRenderData();\r
113     }\r
114 \r
115     void                                        ClearRenderData();\r
116 \r
117     void                                        ClearRenderFont();\r
118 \r
119 \r
120     FX_BOOL                                     IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) const;\r
121 \r
122 \r
123 \r
124 \r
125     CPDF_Font*                          LoadFont(CPDF_Dictionary* pFontDict);\r
126 \r
127     CPDF_Font*                          FindFont(CPDF_Dictionary* pFontDict);\r
128 \r
129     CPDF_ColorSpace*            LoadColorSpace(CPDF_Object* pCSObj, CPDF_Dictionary* pResources = NULL);\r
130 \r
131     CPDF_Pattern*                       LoadPattern(CPDF_Object* pObj, FX_BOOL bShading, const CFX_AffineMatrix* matrix = NULL);\r
132 \r
133     CPDF_Image*                         LoadImageF(CPDF_Object* pObj);\r
134 \r
135     CPDF_StreamAcc*                     LoadFontFile(CPDF_Stream* pStream);\r
136 \r
137     CPDF_IccProfile*            LoadIccProfile(CPDF_Stream* pStream, int nComponents);\r
138 \r
139 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_\r
140 \r
141     CPDF_Font*                          AddWindowsFont(LOGFONTA* pLogFont, FX_BOOL bVert, FX_BOOL bTranslateName = FALSE);\r
142     CPDF_Font*                          AddWindowsFont(LOGFONTW* pLogFont, FX_BOOL bVert, FX_BOOL bTranslateName = FALSE);\r
143 #endif\r
144 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_\r
145     CPDF_Font*              AddMacFont(CTFontRef pFont, FX_BOOL bVert, FX_BOOL bTranslateName = FALSE);\r
146 #endif\r
147 \r
148     CPDF_Font*                          AddStandardFont(const FX_CHAR* font, CPDF_FontEncoding* pEncoding);\r
149 \r
150 \r
151     CPDF_Font*                          AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert);\r
152 \r
153     void                                        CreateNewDoc();\r
154 \r
155     CPDF_Dictionary*            CreateNewPage(int iPage);\r
156 \r
157     void                                        DeletePage(int iPage);\r
158 \r
159     void                                        LoadDoc();\r
160     void                                        LoadAsynDoc(CPDF_Dictionary *pLinearized);\r
161     void                                        LoadPages();\r
162 protected:\r
163 \r
164     CPDF_Dictionary*            m_pRootDict;\r
165 \r
166     CPDF_Dictionary*            m_pInfoDict;\r
167 \r
168     CFX_ByteString                      m_ID1;\r
169 \r
170     CFX_ByteString                      m_ID2;\r
171 \r
172 \r
173     FX_BOOL                                     m_bLinearized;\r
174 \r
175     FX_DWORD                            m_dwFirstPageNo;\r
176 \r
177     FX_DWORD                            m_dwFirstPageObjNum;\r
178 \r
179     CFX_DWordArray                      m_PageList;\r
180 \r
181     int                                         _GetPageCount() const;\r
182     CPDF_Dictionary*            _FindPDFPage(CPDF_Dictionary* pPages, int iPage, int nPagesToGo, int level);\r
183     int                                         _FindPageIndex(CPDF_Dictionary* pNode, FX_DWORD& skip_count, FX_DWORD objnum, int& index, int level = 0);\r
184     FX_BOOL                                     IsContentUsedElsewhere(FX_DWORD objnum, CPDF_Dictionary* pPageDict);\r
185     FX_BOOL                                     CheckOCGVisible(CPDF_Dictionary* pOCG, FX_BOOL bPrinting);\r
186     CPDF_DocPageData*           GetValidatePageData();\r
187     CPDF_DocRenderData*         GetValidateRenderData();\r
188     friend class                        CPDF_Creator;\r
189     friend class                        CPDF_Parser;\r
190     friend class                        CPDF_DataAvail;\r
191     friend class                        CPDF_OCContext;\r
192 \r
193 \r
194 \r
195     CPDF_DocPageData*           m_pDocPage;\r
196 \r
197     CPDF_DocRenderData*         m_pDocRender;\r
198 \r
199 };\r
200 \r
201 #define PDFWORD_EOF                     0\r
202 #define PDFWORD_NUMBER          1\r
203 #define PDFWORD_TEXT            2\r
204 #define PDFWORD_DELIMITER       3\r
205 #define PDFWORD_NAME            4\r
206 class CPDF_SimpleParser : public CFX_Object\r
207 {\r
208 public:\r
209 \r
210     CPDF_SimpleParser(FX_LPCBYTE pData, FX_DWORD dwSize);\r
211 \r
212     CPDF_SimpleParser(FX_BSTR str);\r
213 \r
214     CFX_ByteStringC             GetWord();\r
215 \r
216     FX_BOOL                             SearchToken(FX_BSTR token);\r
217 \r
218     FX_BOOL                             SkipWord(FX_BSTR token);\r
219 \r
220     FX_BOOL                             FindTagPair(FX_BSTR start_token, FX_BSTR end_token,\r
221                                     FX_DWORD& start_pos, FX_DWORD& end_pos);\r
222 \r
223     FX_BOOL                             FindTagParam(FX_BSTR token, int nParams);\r
224 \r
225     FX_DWORD                    GetPos()\r
226     {\r
227         return m_dwCurPos;\r
228     }\r
229 \r
230     void                                SetPos(FX_DWORD pos)\r
231     {\r
232         ASSERT(pos <= m_dwSize);\r
233         m_dwCurPos = pos;\r
234     }\r
235 private:\r
236 \r
237     void                                ParseWord(FX_LPCBYTE& pStart, FX_DWORD& dwSize, int& type);\r
238 \r
239     FX_LPCBYTE                  m_pData;\r
240 \r
241     FX_DWORD                    m_dwSize;\r
242 \r
243     FX_DWORD                    m_dwCurPos;\r
244 };\r
245 class CPDF_SyntaxParser : public CFX_Object\r
246 {\r
247 public:\r
248 \r
249     CPDF_SyntaxParser();\r
250 \r
251     ~CPDF_SyntaxParser();\r
252 \r
253     void                                InitParser(IFX_FileRead* pFileAccess, FX_DWORD HeaderOffset);\r
254 \r
255     FX_FILESIZE                 SavePos()\r
256     {\r
257         return m_Pos;\r
258     }\r
259 \r
260     void                                RestorePos(FX_FILESIZE pos)\r
261     {\r
262         m_Pos = pos;\r
263     }\r
264 \r
265     CPDF_Object*                GetObject(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, FX_DWORD gennum, int level, struct PARSE_CONTEXT* pContext = NULL, FX_BOOL bDecrypt = TRUE);\r
266 \r
267 \r
268     CPDF_Object*                GetObjectByStrict(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, FX_DWORD gennum, int level, struct PARSE_CONTEXT* pContext = NULL);\r
269 \r
270     int                                 GetDirectNum();\r
271 \r
272     CFX_ByteString              GetString(FX_DWORD objnum, FX_DWORD gennum);\r
273 \r
274     CFX_ByteString              GetName();\r
275 \r
276     CFX_ByteString              GetKeyword();\r
277 \r
278     void                                GetBinary(FX_BYTE* buffer, FX_DWORD size);\r
279 \r
280     void                                ToNextLine();\r
281 \r
282     void                                ToNextWord();\r
283 \r
284     FX_BOOL                             SearchWord(FX_BSTR word, FX_BOOL bWholeWord, FX_BOOL bForward, FX_FILESIZE limit);\r
285 \r
286     int                                 SearchMultiWord(FX_BSTR words, FX_BOOL bWholeWord, FX_FILESIZE limit);\r
287 \r
288     FX_FILESIZE                 FindTag(FX_BSTR tag, FX_FILESIZE limit);\r
289 \r
290     void                                SetEncrypt(CPDF_CryptoHandler* pCryptoHandler)\r
291     {\r
292         m_pCryptoHandler = pCryptoHandler;\r
293     }\r
294 \r
295     FX_BOOL                             IsEncrypted()\r
296     {\r
297         return m_pCryptoHandler != NULL;\r
298     }\r
299 \r
300     FX_BOOL                             GetCharAt(FX_FILESIZE pos, FX_BYTE& ch);\r
301 \r
302     FX_BOOL                             ReadBlock(FX_BYTE* pBuf, FX_DWORD size);\r
303 \r
304     CFX_ByteString              GetNextWord(FX_BOOL& bIsNumber);\r
305 protected:\r
306 \r
307     virtual FX_BOOL                             GetNextChar(FX_BYTE& ch);\r
308 \r
309     FX_BOOL                             GetCharAtBackward(FX_FILESIZE pos, FX_BYTE& ch);\r
310 \r
311     void                                GetNextWord();\r
312 \r
313     FX_BOOL                             IsWholeWord(FX_FILESIZE startpos, FX_FILESIZE limit, FX_LPCBYTE tag, FX_DWORD taglen);\r
314 \r
315     CFX_ByteString              ReadString();\r
316 \r
317     CFX_ByteString              ReadHexString();\r
318 \r
319     CPDF_Stream*                ReadStream(CPDF_Dictionary* pDict, PARSE_CONTEXT* pContext, FX_DWORD objnum, FX_DWORD gennum);\r
320 \r
321     FX_FILESIZE                 m_Pos;\r
322 \r
323     FX_BOOL                             m_bFileStream;\r
324 \r
325     int                                 m_MetadataObjnum;\r
326 \r
327     IFX_FileRead*               m_pFileAccess;\r
328 \r
329     FX_DWORD                    m_HeaderOffset;\r
330 \r
331     FX_FILESIZE                 m_FileLen;\r
332 \r
333     FX_BYTE*                    m_pFileBuf;\r
334 \r
335     FX_DWORD                    m_BufSize;\r
336 \r
337     FX_FILESIZE                 m_BufOffset;\r
338 \r
339     CPDF_CryptoHandler* m_pCryptoHandler;\r
340 \r
341     FX_BYTE                             m_WordBuffer[257];\r
342 \r
343     FX_DWORD                    m_WordSize;\r
344 \r
345     FX_BOOL                             m_bIsNumber;\r
346 \r
347     FX_FILESIZE                 m_dwWordPos;\r
348     friend class                CPDF_Parser;\r
349     friend class                CPDF_DataAvail;\r
350 };\r
351 \r
352 #define PDFPARSE_TYPEONLY       1\r
353 #define PDFPARSE_NOSTREAM       2\r
354 struct PARSE_CONTEXT {\r
355 \r
356     FX_BOOL             m_Flags;\r
357 \r
358     FX_FILESIZE m_DictStart;\r
359 \r
360     FX_FILESIZE m_DictEnd;\r
361 \r
362     FX_FILESIZE m_DataStart;\r
363 \r
364     FX_FILESIZE m_DataEnd;\r
365 };\r
366 class IPDF_DocParser : public CFX_Object\r
367 {\r
368 public:\r
369 \r
370     virtual FX_DWORD    GetRootObjNum() = 0;\r
371 \r
372     virtual FX_DWORD    GetInfoObjNum() = 0;\r
373 \r
374     virtual CPDF_Object*        ParseIndirectObject(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, PARSE_CONTEXT* pContext = NULL) = 0;\r
375 \r
376     virtual FX_DWORD    GetLastObjNum() = 0;\r
377 \r
378     virtual CPDF_Array* GetIDArray() = 0;\r
379 \r
380     virtual CPDF_Dictionary*    GetEncryptDict() = 0;\r
381 \r
382     FX_BOOL                             IsEncrypted()\r
383     {\r
384         return GetEncryptDict() != NULL;\r
385     }\r
386 \r
387     virtual FX_DWORD    GetPermissions(FX_BOOL bCheckRevision = FALSE) = 0;\r
388 \r
389     virtual FX_BOOL             IsOwner() = 0;\r
390 \r
391     virtual FX_BOOL             IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) = 0;\r
392 };\r
393 \r
394 #define PDFPARSE_ERROR_SUCCESS          0\r
395 #define PDFPARSE_ERROR_FILE                     1\r
396 #define PDFPARSE_ERROR_FORMAT           2\r
397 #define PDFPARSE_ERROR_PASSWORD         3\r
398 #define PDFPARSE_ERROR_HANDLER          4\r
399 #define PDFPARSE_ERROR_CERT                     5\r
400 class CPDF_Parser : public IPDF_DocParser\r
401 {\r
402 public:\r
403 \r
404     CPDF_Parser();\r
405 \r
406     ~CPDF_Parser();\r
407 \r
408     FX_DWORD                    StartParse(FX_LPCSTR filename, FX_BOOL bReParse = FALSE);\r
409 \r
410     FX_DWORD                    StartParse(FX_LPCWSTR filename, FX_BOOL bReParse = FALSE);\r
411 \r
412     FX_DWORD                    StartParse(IFX_FileRead* pFile, FX_BOOL bReParse = FALSE, FX_BOOL bOwnFileRead = TRUE);\r
413 \r
414     void                                CloseParser(FX_BOOL bReParse = FALSE);\r
415 \r
416     virtual FX_DWORD    GetPermissions(FX_BOOL bCheckRevision = FALSE);\r
417 \r
418     virtual FX_BOOL             IsOwner();\r
419 \r
420     void                                SetPassword(const FX_CHAR* password)\r
421     {\r
422         m_Password = password;\r
423     }\r
424 \r
425     CFX_ByteString              GetPassword()\r
426     {\r
427         return m_Password;\r
428     }\r
429 \r
430     CPDF_SecurityHandler* GetSecurityHandler()\r
431     {\r
432         return m_pSecurityHandler;\r
433     }\r
434 \r
435     CPDF_CryptoHandler* GetCryptoHandler()\r
436     {\r
437         return m_Syntax.m_pCryptoHandler;\r
438     }\r
439 \r
440     void                                SetSecurityHandler(CPDF_SecurityHandler* pSecurityHandler, FX_BOOL bForced = FALSE);\r
441 \r
442     CFX_ByteString              GetRecipient()\r
443     {\r
444         return m_bsRecipient;\r
445     }\r
446 \r
447     CPDF_Dictionary*    GetTrailer()\r
448     {\r
449         return m_pTrailer;\r
450     }\r
451 \r
452     FX_FILESIZE                 GetLastXRefOffset()\r
453     {\r
454         return m_LastXRefOffset;\r
455     }\r
456 \r
457     CPDF_Document*              GetDocument()\r
458     {\r
459         return m_pDocument;\r
460     }\r
461     CFX_ArrayTemplate<CPDF_Dictionary *> * GetOtherTrailers()\r
462     {\r
463         return &m_Trailers;\r
464     }\r
465 \r
466     virtual FX_DWORD    GetRootObjNum();\r
467     virtual FX_DWORD    GetInfoObjNum();\r
468     virtual CPDF_Array* GetIDArray();\r
469     virtual CPDF_Dictionary*    GetEncryptDict()\r
470     {\r
471         return m_pEncryptDict;\r
472     }\r
473     virtual CPDF_Object*                ParseIndirectObject(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, PARSE_CONTEXT* pContext = NULL);\r
474     virtual FX_DWORD    GetLastObjNum();\r
475     virtual FX_BOOL             IsFormStream(FX_DWORD objnum, FX_BOOL& bForm);\r
476 \r
477     FX_FILESIZE                 GetObjectOffset(FX_DWORD objnum);\r
478 \r
479     FX_FILESIZE                 GetObjectSize(FX_DWORD objnum);\r
480 \r
481     int                                 GetObjectVersion(FX_DWORD objnum)\r
482     {\r
483         return m_ObjVersion[objnum];\r
484     }\r
485 \r
486     void                                GetIndirectBinary(FX_DWORD objnum, FX_BYTE*& pBuffer, FX_DWORD& size);\r
487 \r
488     FX_BOOL                             GetFileStreamOption()\r
489     {\r
490         return m_Syntax.m_bFileStream;\r
491     }\r
492 \r
493     void                                SetFileStreamOption(FX_BOOL b)\r
494     {\r
495         m_Syntax.m_bFileStream = b;\r
496     }\r
497 \r
498     IFX_FileRead*               GetFileAccess() const\r
499     {\r
500         return m_Syntax.m_pFileAccess;\r
501     }\r
502 \r
503     int                                 GetFileVersion() const\r
504     {\r
505         return m_FileVersion;\r
506     }\r
507 \r
508     FX_BOOL                             IsXRefStream() const\r
509     {\r
510         return m_bXRefStream;\r
511     }\r
512     CPDF_Object*                ParseIndirectObjectAt(CPDF_IndirectObjects* pObjList, FX_FILESIZE pos, FX_DWORD objnum,\r
513             struct PARSE_CONTEXT* pContext);\r
514 \r
515     CPDF_Object*                ParseIndirectObjectAtByStrict(CPDF_IndirectObjects* pObjList, FX_FILESIZE pos, FX_DWORD objnum,\r
516             struct PARSE_CONTEXT* pContext, FX_FILESIZE *pResultPos);\r
517 \r
518     FX_DWORD                    StartAsynParse(IFX_FileRead* pFile, FX_BOOL bReParse = FALSE, FX_BOOL bOwnFileRead = TRUE);\r
519 \r
520     FX_DWORD                    GetFirstPageNo()\r
521     {\r
522         return m_dwFirstPageNo;\r
523     }\r
524 protected:\r
525 \r
526     CPDF_Document*              m_pDocument;\r
527 \r
528     CPDF_SyntaxParser   m_Syntax;\r
529     FX_BOOL                             m_bOwnFileRead;\r
530     CPDF_Object*                ParseDirect(CPDF_Object* pObj);\r
531 \r
532     FX_BOOL                             LoadAllCrossRefV4(FX_FILESIZE pos);\r
533 \r
534     FX_BOOL                             LoadAllCrossRefV5(FX_FILESIZE pos);\r
535 \r
536     FX_BOOL                             LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_BOOL bSkip, FX_BOOL bFirst);\r
537 \r
538     FX_BOOL                             LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, FX_BOOL bMainXRef);\r
539 \r
540     CPDF_Dictionary*    LoadTrailerV4();\r
541 \r
542     FX_BOOL                             RebuildCrossRef();\r
543 \r
544     FX_DWORD                    SetEncryptHandler();\r
545 \r
546     void                                ReleaseEncryptHandler();\r
547 \r
548     FX_BOOL                             LoadLinearizedAllCrossRefV4(FX_FILESIZE pos, FX_DWORD dwObjCount);\r
549 \r
550     FX_BOOL                             LoadLinearizedCrossRefV4(FX_FILESIZE pos, FX_DWORD dwObjCount);\r
551 \r
552     FX_BOOL                             LoadLinearizedAllCrossRefV5(FX_FILESIZE pos);\r
553 \r
554     FX_DWORD                    LoadLinearizedMainXRefTable();\r
555 \r
556     CFX_MapPtrToPtr             m_ObjectStreamMap;\r
557 \r
558     CPDF_StreamAcc*             GetObjectStream(FX_DWORD number);\r
559 \r
560     FX_BOOL                             IsLinearizedFile(IFX_FileRead* pFileAccess, FX_DWORD offset);\r
561 \r
562 \r
563 \r
564     int                                 m_FileVersion;\r
565 \r
566     CPDF_Dictionary*    m_pTrailer;\r
567 \r
568     CPDF_Dictionary*    m_pEncryptDict;\r
569     void SetEncryptDictionary(CPDF_Dictionary* pDict);\r
570 \r
571     FX_FILESIZE                 m_LastXRefOffset;\r
572 \r
573     FX_BOOL                             m_bXRefStream;\r
574 \r
575 \r
576     CPDF_SecurityHandler*       m_pSecurityHandler;\r
577 \r
578     FX_BOOL                                     m_bForceUseSecurityHandler;\r
579 \r
580     CFX_ByteString                      m_bsRecipient;\r
581 \r
582     CFX_ByteString              m_FilePath;\r
583 \r
584     CFX_ByteString              m_Password;\r
585 \r
586     CFX_FileSizeArray   m_CrossRef;\r
587 \r
588     CFX_ByteArray               m_V5Type;\r
589 \r
590     CFX_FileSizeArray   m_SortedOffset;\r
591 \r
592     CFX_WordArray               m_ObjVersion;\r
593     CFX_ArrayTemplate<CPDF_Dictionary *>        m_Trailers;\r
594 \r
595     FX_BOOL                             m_bVersionUpdated;\r
596 \r
597     CPDF_Object*                m_pLinearized;\r
598 \r
599     FX_DWORD                    m_dwFirstPageNo;\r
600 \r
601     FX_DWORD                    m_dwXrefStartObjNum;\r
602     friend class                CPDF_Creator;\r
603     friend class                CPDF_DataAvail;\r
604 };\r
605 #define FXCIPHER_NONE   0\r
606 #define FXCIPHER_RC4    1\r
607 #define FXCIPHER_AES    2\r
608 #define FXCIPHER_AES2   3\r
609 class CPDF_SecurityHandler : public CFX_Object\r
610 {\r
611 public:\r
612 \r
613     virtual ~CPDF_SecurityHandler() {}\r
614 \r
615     virtual FX_BOOL             OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict) = 0;\r
616 \r
617     virtual FX_DWORD    GetPermissions() = 0;\r
618 \r
619     virtual FX_BOOL             IsOwner() = 0;\r
620 \r
621     virtual FX_BOOL             GetCryptInfo(int& cipher, FX_LPCBYTE& buffer, int& keylen) = 0;\r
622 \r
623     virtual FX_BOOL             IsMetadataEncrypted()\r
624     {\r
625         return TRUE;\r
626     }\r
627 \r
628     virtual CPDF_CryptoHandler* CreateCryptoHandler() = 0;\r
629 \r
630     virtual CPDF_StandardSecurityHandler* GetStandardHandler()\r
631     {\r
632         return NULL;\r
633     }\r
634 };\r
635 #define PDF_ENCRYPT_CONTENT                             0\r
636 class CPDF_StandardSecurityHandler : public CPDF_SecurityHandler\r
637 {\r
638 public:\r
639     CPDF_StandardSecurityHandler();\r
640 \r
641     virtual ~CPDF_StandardSecurityHandler();\r
642     virtual FX_BOOL             OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict);\r
643     virtual FX_DWORD    GetPermissions();\r
644     virtual FX_BOOL             IsOwner()\r
645     {\r
646         return m_bOwner;\r
647     }\r
648     virtual FX_BOOL             GetCryptInfo(int& cipher, FX_LPCBYTE& buffer, int& keylen);\r
649     virtual FX_BOOL             IsMetadataEncrypted();\r
650     virtual CPDF_CryptoHandler* CreateCryptoHandler();\r
651     virtual CPDF_StandardSecurityHandler* GetStandardHandler()\r
652     {\r
653         return this;\r
654     }\r
655 \r
656     void                                OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_Array* pIdArray,\r
657                                  FX_LPCBYTE user_pass, FX_DWORD user_size,\r
658                                  FX_LPCBYTE owner_pass, FX_DWORD owner_size, FX_DWORD type = PDF_ENCRYPT_CONTENT);\r
659 \r
660     void                                OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_Array* pIdArray,\r
661                                  FX_LPCBYTE user_pass, FX_DWORD user_size, FX_DWORD type = PDF_ENCRYPT_CONTENT);\r
662 \r
663     CFX_ByteString              GetUserPassword(FX_LPCBYTE owner_pass, FX_DWORD pass_size);\r
664     CFX_ByteString              GetUserPassword(FX_LPCBYTE owner_pass, FX_DWORD pass_size, FX_INT32 key_len);\r
665     int                                 GetVersion()\r
666     {\r
667         return m_Version;\r
668     }\r
669     int                                 GetRevision()\r
670     {\r
671         return m_Revision;\r
672     }\r
673 \r
674     int                                 CheckPassword(FX_LPCBYTE password, FX_DWORD pass_size, FX_BOOL bOwner, FX_LPBYTE key);\r
675     int                                 CheckPassword(FX_LPCBYTE password, FX_DWORD pass_size, FX_BOOL bOwner, FX_LPBYTE key, int key_len);\r
676 private:\r
677 \r
678     int                                 m_Version;\r
679 \r
680     int                                 m_Revision;\r
681 \r
682     CPDF_Parser*                m_pParser;\r
683 \r
684     CPDF_Dictionary*    m_pEncryptDict;\r
685 \r
686     FX_BOOL                             LoadDict(CPDF_Dictionary* pEncryptDict);\r
687     FX_BOOL                             LoadDict(CPDF_Dictionary* pEncryptDict, FX_DWORD type, int& cipher, int& key_len);\r
688 \r
689     FX_BOOL                             CheckUserPassword(FX_LPCBYTE password, FX_DWORD pass_size,\r
690                                           FX_BOOL bIgnoreEncryptMeta, FX_LPBYTE key, FX_INT32 key_len);\r
691 \r
692     FX_BOOL                             CheckOwnerPassword(FX_LPCBYTE password, FX_DWORD pass_size, FX_LPBYTE key, FX_INT32 key_len);\r
693     FX_BOOL                             AES256_CheckPassword(FX_LPCBYTE password, FX_DWORD size, FX_BOOL bOwner, FX_LPBYTE key);\r
694     void                                AES256_SetPassword(CPDF_Dictionary* pEncryptDict, FX_LPCBYTE password, FX_DWORD size, FX_BOOL bOwner, FX_LPCBYTE key);\r
695     void                                AES256_SetPerms(CPDF_Dictionary* pEncryptDict, FX_DWORD permission, FX_BOOL bEncryptMetadata, FX_LPCBYTE key);\r
696     void                                OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_Array* pIdArray,\r
697                                  FX_LPCBYTE user_pass, FX_DWORD user_size,\r
698                                  FX_LPCBYTE owner_pass, FX_DWORD owner_size, FX_BOOL bDefault, FX_DWORD type);\r
699     FX_BOOL                             CheckSecurity(FX_INT32 key_len);\r
700 \r
701     FX_BOOL                             m_bOwner;\r
702 \r
703     FX_DWORD                    m_Permissions;\r
704 \r
705     int                                 m_Cipher;\r
706 \r
707     FX_BYTE                             m_EncryptKey[32];\r
708 \r
709     int                                 m_KeyLen;\r
710 };\r
711 class CPDF_CryptoHandler : public CFX_Object\r
712 {\r
713 public:\r
714 \r
715     virtual ~CPDF_CryptoHandler() {}\r
716 \r
717     virtual FX_BOOL             Init(CPDF_Dictionary* pEncryptDict, CPDF_SecurityHandler* pSecurityHandler) = 0;\r
718 \r
719     virtual FX_DWORD    DecryptGetSize(FX_DWORD src_size) = 0;\r
720 \r
721     virtual FX_LPVOID   DecryptStart(FX_DWORD objnum, FX_DWORD gennum) = 0;\r
722 \r
723     virtual FX_BOOL             DecryptStream(FX_LPVOID context, FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) = 0;\r
724 \r
725     virtual FX_BOOL             DecryptFinish(FX_LPVOID context, CFX_BinaryBuf& dest_buf) = 0;\r
726 \r
727 \r
728     virtual FX_DWORD    EncryptGetSize(FX_DWORD objnum, FX_DWORD version, FX_LPCBYTE src_buf, FX_DWORD src_size) = 0;\r
729 \r
730     virtual FX_BOOL             EncryptContent(FX_DWORD objnum, FX_DWORD version, FX_LPCBYTE src_buf, FX_DWORD src_size,\r
731                                        FX_LPBYTE dest_buf, FX_DWORD& dest_size) = 0;\r
732 \r
733     void                                Decrypt(FX_DWORD objnum, FX_DWORD version, CFX_ByteString& str);\r
734 };\r
735 class CPDF_StandardCryptoHandler : public CPDF_CryptoHandler\r
736 {\r
737 public:\r
738 \r
739     CPDF_StandardCryptoHandler();\r
740 \r
741     virtual ~CPDF_StandardCryptoHandler();\r
742 \r
743     FX_BOOL                             Init(int cipher, FX_LPCBYTE key, int keylen);\r
744     virtual FX_BOOL             Init(CPDF_Dictionary* pEncryptDict, CPDF_SecurityHandler* pSecurityHandler);\r
745     virtual FX_DWORD    DecryptGetSize(FX_DWORD src_size);\r
746     virtual FX_LPVOID   DecryptStart(FX_DWORD objnum, FX_DWORD gennum);\r
747     virtual FX_BOOL             DecryptStream(FX_LPVOID context, FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf);\r
748     virtual FX_BOOL             DecryptFinish(FX_LPVOID context, CFX_BinaryBuf& dest_buf);\r
749     virtual FX_DWORD    EncryptGetSize(FX_DWORD objnum, FX_DWORD version, FX_LPCBYTE src_buf, FX_DWORD src_size);\r
750     virtual FX_BOOL             EncryptContent(FX_DWORD objnum, FX_DWORD version, FX_LPCBYTE src_buf, FX_DWORD src_size,\r
751                                        FX_LPBYTE dest_buf, FX_DWORD& dest_size);\r
752 protected:\r
753 \r
754     virtual void                CryptBlock(FX_BOOL bEncrypt, FX_DWORD objnum, FX_DWORD gennum, FX_LPCBYTE src_buf, FX_DWORD src_size,\r
755                                    FX_LPBYTE dest_buf, FX_DWORD& dest_size);\r
756     virtual FX_LPVOID   CryptStart(FX_DWORD objnum, FX_DWORD gennum, FX_BOOL bEncrypt);\r
757     virtual FX_BOOL             CryptStream(FX_LPVOID context, FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt);\r
758     virtual FX_BOOL             CryptFinish(FX_LPVOID context, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt);\r
759 \r
760     FX_BYTE                             m_EncryptKey[32];\r
761 \r
762     int                                 m_KeyLen;\r
763 \r
764     int                                 m_Cipher;\r
765 \r
766     FX_LPBYTE                   m_pAESContext;\r
767 };\r
768 class CPDF_Point : public CFX_Object\r
769 {\r
770 public:\r
771 \r
772     CPDF_Point(FX_FLOAT xx, FX_FLOAT yy)\r
773     {\r
774         x = xx;\r
775         y = yy;\r
776     }\r
777 \r
778     FX_FLOAT                    x;\r
779 \r
780     FX_FLOAT                    y;\r
781 };\r
782 \r
783 #define CPDF_Rect               CFX_FloatRect\r
784 #define CPDF_Matrix             CFX_AffineMatrix\r
785 CFX_ByteString PDF_NameDecode(FX_BSTR orig);\r
786 CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig);\r
787 CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig);\r
788 CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex = FALSE);\r
789 CFX_WideString PDF_DecodeText(const CFX_ByteString& str, CFX_CharMap* pCharMap = NULL);\r
790 CFX_WideString PDF_DecodeText(FX_LPCBYTE pData, FX_DWORD size, CFX_CharMap* pCharMap = NULL);\r
791 CFX_ByteString PDF_EncodeText(FX_LPCWSTR pString, int len = -1, CFX_CharMap* pCharMap = NULL);\r
792 FX_FLOAT PDF_ClipFloat(FX_FLOAT f);\r
793 class CFDF_Document : public CPDF_IndirectObjects\r
794 {\r
795 public:\r
796 \r
797     static CFDF_Document*       CreateNewDoc();\r
798 \r
799     static CFDF_Document*       ParseFile(FX_LPCSTR file_path);\r
800 \r
801     static CFDF_Document*       ParseFile(FX_LPCWSTR file_path);\r
802 \r
803     static CFDF_Document*       ParseFile(IFX_FileRead *pFile, FX_BOOL bOwnFile = FALSE);\r
804 \r
805     static CFDF_Document*       ParseMemory(FX_LPCBYTE pData, FX_DWORD size);\r
806 \r
807     ~CFDF_Document();\r
808 \r
809     FX_BOOL                                     WriteFile(FX_LPCSTR file_path) const;\r
810 \r
811     FX_BOOL                                     WriteFile(FX_LPCWSTR file_path) const;\r
812 \r
813     FX_BOOL                                     WriteFile(IFX_FileWrite *pFile) const;\r
814 \r
815     FX_BOOL                                     WriteBuf(CFX_ByteTextBuf& buf) const;\r
816 \r
817     CPDF_Dictionary*            GetRoot() const\r
818     {\r
819         return m_pRootDict;\r
820     }\r
821 \r
822     CFX_WideString                      GetWin32Path() const;\r
823 protected:\r
824 \r
825     CFDF_Document();\r
826     void        ParseStream(IFX_FileRead *pFile, FX_BOOL bOwnFile);\r
827     CPDF_Dictionary*            m_pRootDict;\r
828     IFX_FileRead*                       m_pFile;\r
829     FX_BOOL                                     m_bOwnFile;\r
830 };\r
831 \r
832 CFX_WideString  FPDF_FileSpec_GetWin32Path(const CPDF_Object* pFileSpec);\r
833 void                    FPDF_FileSpec_SetWin32Path(CPDF_Object* pFileSpec, const CFX_WideString& fullpath);\r
834 \r
835 void FlateEncode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size);\r
836 FX_DWORD FlateDecode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size);\r
837 FX_DWORD RunLengthDecode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size);\r
838 class CPDF_NumberTree : public CFX_Object\r
839 {\r
840 public:\r
841 \r
842     CPDF_NumberTree(CPDF_Dictionary* pRoot)\r
843     {\r
844         m_pRoot = pRoot;\r
845     }\r
846 \r
847     CPDF_Object*                LookupValue(int num);\r
848 protected:\r
849 \r
850     CPDF_Dictionary*    m_pRoot;\r
851 };\r
852 \r
853 class IFX_FileAvail\r
854 {\r
855 public:\r
856 \r
857     virtual FX_BOOL                     IsDataAvail( FX_FILESIZE offset, FX_DWORD size) = 0;\r
858 };\r
859 class IFX_DownloadHints\r
860 {\r
861 public:\r
862 \r
863     virtual void                        AddSegment(FX_FILESIZE offset, FX_DWORD size) = 0;\r
864 };\r
865 #define PDF_IS_LINEARIZED                       1\r
866 #define PDF_NOT_LINEARIZED                      0\r
867 #define PDF_UNKNOW_LINEARIZED           -1\r
868 #define PDFFORM_NOTAVAIL                0\r
869 #define PDFFORM_AVAIL                   1\r
870 #define PDFFORM_NOTEXIST                2\r
871 class IPDF_DataAvail\r
872 {\r
873 public:\r
874 \r
875     virtual FX_BOOL                     IsDocAvail(IFX_DownloadHints* pHints) = 0;\r
876 \r
877 \r
878     virtual void                        SetDocument(CPDF_Document* pDoc) = 0;\r
879 \r
880 \r
881     virtual FX_BOOL                     IsPageAvail(int iPage, IFX_DownloadHints* pHints) = 0;\r
882 \r
883     virtual FX_BOOL                     IsLinearized() = 0;\r
884 \r
885     virtual FX_INT32            IsFormAvail(IFX_DownloadHints *pHints) = 0;\r
886 \r
887     virtual FX_INT32            IsLinearizedPDF() = 0;\r
888 \r
889     virtual void                                GetLinearizedMainXRefInfo(FX_FILESIZE *pPos, FX_DWORD *pSize) = 0;\r
890 };\r
891 class CPDF_SortObjNumArray : public CFX_Object\r
892 {\r
893 public:\r
894 \r
895     void AddObjNum(FX_DWORD dwObjNum);\r
896 \r
897     FX_BOOL Find(FX_DWORD dwObjNum);\r
898 \r
899     void RemoveAll()\r
900     {\r
901         m_number_array.RemoveAll();\r
902     }\r
903 protected:\r
904 \r
905     FX_BOOL BinarySearch(FX_DWORD value, int &iNext);\r
906 protected:\r
907 \r
908     CFX_DWordArray                      m_number_array;\r
909 };\r
910 enum PDF_PAGENODE_TYPE {\r
911     PDF_PAGENODE_UNKOWN = 0,\r
912     PDF_PAGENODE_PAGE,\r
913     PDF_PAGENODE_PAGES,\r
914     PDF_PAGENODE_ARRAY,\r
915 };\r
916 class CPDF_PageNode : public CFX_Object\r
917 {\r
918 public:\r
919     CPDF_PageNode() : m_type(PDF_PAGENODE_UNKOWN) {}\r
920     ~CPDF_PageNode();\r
921     PDF_PAGENODE_TYPE   m_type;\r
922     FX_DWORD                    m_dwPageNo;\r
923     CFX_PtrArray                m_childNode;\r
924 };\r
925 enum PDF_DATAAVAIL_STATUS {\r
926     PDF_DATAAVAIL_HEADER = 0,\r
927     PDF_DATAAVAIL_FIRSTPAGE,\r
928     PDF_DATAAVAIL_FIRSTPAGE_PREPARE,\r
929     PDF_DATAAVAIL_END,\r
930     PDF_DATAAVAIL_CROSSREF,\r
931     PDF_DATAAVAIL_CROSSREF_ITEM,\r
932     PDF_DATAAVAIL_CROSSREF_STREAM,\r
933     PDF_DATAAVAIL_TRAILER,\r
934     PDF_DATAAVAIL_LOADALLCRSOSSREF,\r
935     PDF_DATAAVAIL_ROOT,\r
936     PDF_DATAAVAIL_INFO,\r
937     PDF_DATAAVAIL_ACROFORM,\r
938     PDF_DATAAVAIL_ACROFORM_SUBOBJECT,\r
939     PDF_DATAAVAIL_PAGETREE,\r
940     PDF_DATAAVAIL_PAGE,\r
941     PDF_DATAAVAIL_PAGE_LATERLOAD,\r
942     PDF_DATAAVAIL_RESOURCES,\r
943     PDF_DATAAVAIL_DONE,\r
944     PDF_DATAAVAIL_ERROR,\r
945     PDF_DATAAVAIL_LOADALLFILE,\r
946     PDF_DATAAVAIL_TRAILER_APPEND\r
947 };\r
948 class CPDF_DataAvail : public CFX_Object, public IPDF_DataAvail\r
949 {\r
950 public:\r
951 \r
952     CPDF_DataAvail(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRead);\r
953     ~CPDF_DataAvail();\r
954 \r
955     virtual FX_BOOL                             IsDocAvail(IFX_DownloadHints* pHints);\r
956 \r
957 \r
958     virtual void                                SetDocument(CPDF_Document* pDoc);\r
959 \r
960 \r
961     virtual FX_BOOL                             IsPageAvail(int iPage, IFX_DownloadHints* pHints);\r
962 \r
963     virtual FX_INT32                    IsFormAvail(IFX_DownloadHints *pHints);\r
964 \r
965     virtual FX_INT32                    IsLinearizedPDF();\r
966 \r
967     virtual FX_BOOL                             IsLinearized()\r
968     {\r
969         return m_bLinearized;\r
970     }\r
971 \r
972     virtual void                                GetLinearizedMainXRefInfo(FX_FILESIZE *pPos, FX_DWORD *pSize);\r
973     IFX_FileRead*                               GetFileRead() const\r
974     {\r
975         return m_pFileRead;\r
976     }\r
977     IFX_FileAvail*                              GetFileAvail() const\r
978     {\r
979         return m_pFileAvail;\r
980     }\r
981 protected:\r
982     FX_DWORD                                    GetObjectSize(FX_DWORD objnum, FX_FILESIZE& offset);\r
983     FX_BOOL                                             IsObjectsAvail(CFX_PtrArray& obj_array, FX_BOOL bParsePage, IFX_DownloadHints* pHints, CFX_PtrArray &ret_array);\r
984     FX_BOOL                                             CheckDocStatus(IFX_DownloadHints *pHints);\r
985     FX_BOOL                                             CheckHeader(IFX_DownloadHints* pHints);\r
986     FX_BOOL                                             CheckFirstPage(IFX_DownloadHints *pHints);\r
987     FX_BOOL                                             CheckEnd(IFX_DownloadHints *pHints);\r
988     FX_BOOL                                             CheckCrossRef(IFX_DownloadHints* pHints);\r
989     FX_BOOL                                             CheckCrossRefItem(IFX_DownloadHints *pHints);\r
990     FX_BOOL                                             CheckTrailer(IFX_DownloadHints* pHints);\r
991     FX_BOOL                                             CheckRoot(IFX_DownloadHints* pHints);\r
992     FX_BOOL                                             CheckInfo(IFX_DownloadHints* pHints);\r
993     FX_BOOL                                             CheckPages(IFX_DownloadHints* pHints);\r
994     FX_BOOL                                             CheckPage(IFX_DownloadHints* pHints);\r
995     FX_BOOL                                             CheckResources(IFX_DownloadHints* pHints);\r
996     FX_BOOL                                             CheckAnnots(IFX_DownloadHints* pHints);\r
997     FX_BOOL                                             CheckAcroForm(IFX_DownloadHints* pHints);\r
998     FX_BOOL                                             CheckAcroFormSubObject(IFX_DownloadHints* pHints);\r
999     FX_BOOL                                             CheckTrailerAppend(IFX_DownloadHints* pHints);\r
1000     FX_BOOL                                             CheckPageStatus(IFX_DownloadHints* pHints);\r
1001     FX_BOOL                                             CheckAllCrossRefStream(IFX_DownloadHints *pHints);\r
1002 \r
1003     FX_DWORD                                    CheckCrossRefStream(IFX_DownloadHints *pHints, FX_FILESIZE &xref_offset);\r
1004     FX_BOOL                                             IsLinearizedFile(FX_LPBYTE pData, FX_DWORD dwLen);\r
1005     void                                                SetStartOffset(FX_FILESIZE dwOffset);\r
1006     FX_BOOL                                             GetNextToken(CFX_ByteString &token);\r
1007     FX_BOOL                                             GetNextChar(FX_BYTE &ch);\r
1008     CPDF_Object *                               ParseIndirectObjectAt(FX_FILESIZE pos, FX_DWORD objnum);\r
1009     CPDF_Object *                               GetObject(FX_DWORD objnum, IFX_DownloadHints* pHints, FX_BOOL *pExistInFile);\r
1010     FX_BOOL                                             GetPageKids(CPDF_Parser *pParser, CPDF_Object *pPages);\r
1011     FX_BOOL                                             PreparePageItem();\r
1012     FX_BOOL                                             LoadPages(IFX_DownloadHints* pHints);\r
1013     FX_BOOL                                             LoadAllXref(IFX_DownloadHints* pHints);\r
1014     FX_BOOL                                             LoadAllFile(IFX_DownloadHints* pHints);\r
1015     FX_BOOL                                             CheckLinearizedData(IFX_DownloadHints* pHints);\r
1016     FX_BOOL                                             CheckFileResources(IFX_DownloadHints* pHints);\r
1017     FX_BOOL                                             CheckPageAnnots(int iPage, IFX_DownloadHints* pHints);\r
1018 \r
1019     FX_BOOL                                             CheckLinearizedFirstPage(int iPage, IFX_DownloadHints* pHints);\r
1020     FX_BOOL                                             HaveResourceAncestor(CPDF_Dictionary *pDict);\r
1021     FX_BOOL                                             CheckPage(FX_INT32 iPage, IFX_DownloadHints* pHints);\r
1022     FX_BOOL                                             LoadDocPages(IFX_DownloadHints* pHints);\r
1023     FX_BOOL                                             LoadDocPage(FX_INT32 iPage, IFX_DownloadHints* pHints);\r
1024     FX_BOOL                                             CheckPageNode(CPDF_PageNode &pageNodes, FX_INT32 iPage, FX_INT32 &iCount, IFX_DownloadHints* pHints);\r
1025     FX_BOOL                                             CheckUnkownPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pPageNode, IFX_DownloadHints* pHints);\r
1026     FX_BOOL                                             CheckArrayPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pPageNode, IFX_DownloadHints* pHints);\r
1027     FX_BOOL                     CheckPageCount(IFX_DownloadHints* pHints);\r
1028     FX_BOOL                                             IsFirstCheck(int iPage);\r
1029     void                                                ResetFirstCheck(int iPage);\r
1030 \r
1031     CPDF_Parser                         m_parser;\r
1032 \r
1033     CPDF_SyntaxParser           m_syntaxParser;\r
1034 \r
1035     CPDF_Object                         *m_pRoot;\r
1036 \r
1037     FX_DWORD                            m_dwRootObjNum;\r
1038 \r
1039     FX_DWORD                            m_dwInfoObjNum;\r
1040 \r
1041     CPDF_Object                         *m_pLinearized;\r
1042 \r
1043     CPDF_Object                         *m_pTrailer;\r
1044 \r
1045     FX_BOOL                                     m_bDocAvail;\r
1046 \r
1047     FX_FILESIZE                         m_dwHeaderOffset;\r
1048 \r
1049     FX_FILESIZE                         m_dwLastXRefOffset;\r
1050 \r
1051     FX_FILESIZE                         m_dwXRefOffset;\r
1052 \r
1053     FX_FILESIZE                         m_dwTrailerOffset;\r
1054 \r
1055     FX_FILESIZE                         m_dwCurrentOffset;\r
1056 \r
1057     PDF_DATAAVAIL_STATUS        m_docStatus;\r
1058 \r
1059     IFX_FileAvail*                      m_pFileAvail;\r
1060 \r
1061     IFX_FileRead*                       m_pFileRead;\r
1062 \r
1063     FX_FILESIZE                         m_dwFileLen;\r
1064 \r
1065     CPDF_Document*                      m_pDocument;\r
1066 \r
1067     CPDF_SortObjNumArray        m_objnum_array;\r
1068 \r
1069     CFX_PtrArray                        m_objs_array;\r
1070 \r
1071     FX_FILESIZE                         m_Pos;\r
1072 \r
1073     FX_FILESIZE                         m_bufferOffset;\r
1074 \r
1075     FX_DWORD                            m_bufferSize;\r
1076 \r
1077     CFX_ByteString                      m_WordBuf;\r
1078 \r
1079     FX_BYTE                                     m_WordBuffer[257];\r
1080 \r
1081     FX_DWORD                            m_WordSize;\r
1082 \r
1083     FX_BYTE                                     m_bufferData[512];\r
1084 \r
1085     CFX_FileSizeArray           m_CrossOffset;\r
1086 \r
1087     CFX_DWordArray                      m_XRefStreamList;\r
1088 \r
1089     CFX_DWordArray                      m_PageObjList;\r
1090 \r
1091     FX_DWORD                            m_PagesObjNum;\r
1092 \r
1093     FX_BOOL                                     m_bLinearized;\r
1094 \r
1095     FX_DWORD                            m_dwFirstPageNo;\r
1096 \r
1097     FX_BOOL                                     m_bLinearedDataOK;\r
1098 \r
1099     FX_BOOL                                     m_bMainXRefLoad;\r
1100 \r
1101     FX_BOOL                                     m_bMainXRefLoadedOK;\r
1102 \r
1103     FX_BOOL                                     m_bPagesTreeLoad;\r
1104 \r
1105     FX_BOOL                                     m_bPagesLoad;\r
1106 \r
1107     CPDF_Parser *                       m_pCurrentParser;\r
1108 \r
1109     FX_FILESIZE                         m_dwCurrentXRefSteam;\r
1110 \r
1111     FX_BOOL                                     m_bAnnotsLoad;\r
1112 \r
1113     FX_BOOL                                     m_bHaveAcroForm;\r
1114 \r
1115     FX_DWORD                            m_dwAcroFormObjNum;\r
1116 \r
1117     FX_BOOL                                     m_bAcroFormLoad;\r
1118 \r
1119     CPDF_Object *                       m_pAcroForm;\r
1120 \r
1121     CFX_PtrArray                        m_arrayAcroforms;\r
1122 \r
1123     CPDF_Dictionary *           m_pPageDict;\r
1124 \r
1125     CPDF_Object *                       m_pPageResource;\r
1126 \r
1127     FX_BOOL                                     m_bNeedDownLoadResource;\r
1128 \r
1129     FX_BOOL                                     m_bPageLoadedOK;\r
1130 \r
1131     FX_BOOL                                     m_bLinearizedFormParamLoad;\r
1132 \r
1133     CFX_PtrArray                        m_PagesArray;\r
1134 \r
1135     FX_DWORD                            m_dwEncryptObjNum;\r
1136 \r
1137     FX_FILESIZE                         m_dwPrevXRefOffset;\r
1138 \r
1139     FX_BOOL                                     m_bTotalLoadPageTree;\r
1140 \r
1141     FX_BOOL                                     m_bCurPageDictLoadOK;\r
1142 \r
1143     CPDF_PageNode                       m_pageNodes;\r
1144 \r
1145     CFX_CMapDWordToDWord *      m_pageMapCheckState;\r
1146 \r
1147     CFX_CMapDWordToDWord *      m_pagesLoadState;\r
1148 };\r
1149 #endif\r