• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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_FPDFAPI_PARSER_CPDF_HINT_TABLES_H_
8 #define CORE_FPDFAPI_PARSER_CPDF_HINT_TABLES_H_
9 
10 #include <vector>
11 
12 #include "core/fpdfapi/parser/cpdf_data_avail.h"
13 #include "core/fxcrt/fx_stream.h"
14 #include "core/fxcrt/unowned_ptr.h"
15 
16 class CFX_BitStream;
17 class CPDF_LinearizedHeader;
18 class CPDF_Stream;
19 class CPDF_ReadValidator;
20 
21 class CPDF_HintTables {
22  public:
23   CPDF_HintTables(CPDF_ReadValidator* pValidator,
24                   CPDF_LinearizedHeader* pLinearized);
25   virtual ~CPDF_HintTables();
26 
27   bool GetPagePos(uint32_t index,
28                   FX_FILESIZE* szPageStartPos,
29                   FX_FILESIZE* szPageLength,
30                   uint32_t* dwObjNum) const;
31 
32   CPDF_DataAvail::DocAvailStatus CheckPage(uint32_t index);
33 
34   bool LoadHintStream(CPDF_Stream* pHintStream);
35 
36  protected:
37   bool ReadPageHintTable(CFX_BitStream* hStream);
38   bool ReadSharedObjHintTable(CFX_BitStream* hStream, uint32_t offset);
39 
40  private:
41   // Tests can override.
42   virtual int GetEndOfFirstPageOffset() const;
43   virtual int GetNumberOfPages() const;
44   virtual int GetFirstPageObjectNumber() const;
45   virtual int GetFirstPageNumber() const;
46   virtual int ReadPrimaryHintStreamOffset() const;
47   virtual int ReadPrimaryHintStreamLength() const;
48 
49   uint32_t GetItemLength(uint32_t index,
50                          const std::vector<FX_FILESIZE>& szArray) const;
51 
52   // Owned by |m_pDataAvail|.
53   UnownedPtr<CPDF_ReadValidator> m_pValidator;
54 
55   // Owned by |m_pDataAvail|.
56   UnownedPtr<CPDF_LinearizedHeader> const m_pLinearized;
57 
58   uint32_t m_nFirstPageSharedObjs;
59   FX_FILESIZE m_szFirstPageObjOffset;
60   std::vector<uint32_t> m_dwDeltaNObjsArray;
61   std::vector<uint32_t> m_dwNSharedObjsArray;
62   std::vector<uint32_t> m_dwSharedObjNumArray;
63   std::vector<uint32_t> m_dwIdentifierArray;
64   std::vector<FX_FILESIZE> m_szPageOffsetArray;
65   std::vector<FX_FILESIZE> m_szSharedObjOffsetArray;
66 };
67 
68 #endif  // CORE_FPDFAPI_PARSER_CPDF_HINT_TABLES_H_
69