1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef CORE_SRC_FPDFAPI_FPDF_PARSER_PARSER_INT_H_
8 #define CORE_SRC_FPDFAPI_FPDF_PARSER_PARSER_INT_H_
9 
10 #include "core/include/fxcrt/fx_basic.h"
11 #include "core/include/fxcrt/fx_stream.h"
12 
13 class CFX_BitStream;
14 class CPDF_DataAvail;
15 class CPDF_Dictionary;
16 class CPDF_Stream;
17 class IFX_DownloadHints;
18 
19 class CPDF_HintTables {
20  public:
CPDF_HintTables(CPDF_DataAvail * pDataAvail,CPDF_Dictionary * pLinearized)21   CPDF_HintTables(CPDF_DataAvail* pDataAvail, CPDF_Dictionary* pLinearized)
22       : m_pLinearizedDict(pLinearized),
23         m_pDataAvail(pDataAvail),
24         m_nFirstPageSharedObjs(0),
25         m_szFirstPageObjOffset(0) {}
26   ~CPDF_HintTables();
27 
28   FX_BOOL GetPagePos(int index,
29                      FX_FILESIZE& szPageStartPos,
30                      FX_FILESIZE& szPageLength,
31                      FX_DWORD& dwObjNum);
32   IPDF_DataAvail::DocAvailStatus CheckPage(int index,
33                                            IFX_DownloadHints* pHints);
34   FX_BOOL LoadHintStream(CPDF_Stream* pHintStream);
35 
36  protected:
37   FX_BOOL ReadPageHintTable(CFX_BitStream* hStream);
38   FX_BOOL ReadSharedObjHintTable(CFX_BitStream* hStream, FX_DWORD offset);
39   FX_DWORD GetItemLength(int index, const CFX_FileSizeArray& szArray);
40 
41  private:
42   int ReadPrimaryHintStreamOffset() const;
43   int ReadPrimaryHintStreamLength() const;
44 
45   CPDF_Dictionary* m_pLinearizedDict;
46   CPDF_DataAvail* m_pDataAvail;
47   FX_DWORD m_nFirstPageSharedObjs;
48   FX_FILESIZE m_szFirstPageObjOffset;
49   CFX_DWordArray m_dwDeltaNObjsArray;
50   CFX_DWordArray m_dwNSharedObjsArray;
51   CFX_DWordArray m_dwSharedObjNumArray;
52   CFX_DWordArray m_dwIdentifierArray;
53   CFX_FileSizeArray m_szPageOffsetArray;
54   CFX_FileSizeArray m_szSharedObjOffsetArray;
55 };
56 
57 #endif  // CORE_SRC_FPDFAPI_FPDF_PARSER_PARSER_INT_H_
58