summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_hint_tables.h
blob: d5feb4638cc8aa78618347428db0fb43dd7a9f9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef CORE_FPDFAPI_PARSER_CPDF_HINT_TABLES_H_
#define CORE_FPDFAPI_PARSER_CPDF_HINT_TABLES_H_

#include <vector>

#include "core/fpdfapi/parser/cpdf_data_avail.h"
#include "core/fxcrt/fx_stream.h"
#include "core/fxcrt/unowned_ptr.h"

class CFX_BitStream;
class CPDF_LinearizedHeader;
class CPDF_Stream;
class CPDF_ReadValidator;

class CPDF_HintTables {
 public:
  CPDF_HintTables(CPDF_ReadValidator* pValidator,
                  CPDF_LinearizedHeader* pLinearized);
  virtual ~CPDF_HintTables();

  bool GetPagePos(uint32_t index,
                  FX_FILESIZE* szPageStartPos,
                  FX_FILESIZE* szPageLength,
                  uint32_t* dwObjNum) const;

  CPDF_DataAvail::DocAvailStatus CheckPage(uint32_t index);

  bool LoadHintStream(CPDF_Stream* pHintStream);

 protected:
  bool ReadPageHintTable(CFX_BitStream* hStream);
  bool ReadSharedObjHintTable(CFX_BitStream* hStream, uint32_t offset);

 private:
  // Tests can override.
  virtual int GetEndOfFirstPageOffset() const;
  virtual int GetNumberOfPages() const;
  virtual int GetFirstPageObjectNumber() const;
  virtual int GetFirstPageNumber() const;
  virtual int ReadPrimaryHintStreamOffset() const;
  virtual int ReadPrimaryHintStreamLength() const;

  uint32_t GetItemLength(uint32_t index,
                         const std::vector<FX_FILESIZE>& szArray) const;

  // Owned by |m_pDataAvail|.
  UnownedPtr<CPDF_ReadValidator> m_pValidator;

  // Owned by |m_pDataAvail|.
  UnownedPtr<CPDF_LinearizedHeader> const m_pLinearized;

  uint32_t m_nFirstPageSharedObjs;
  FX_FILESIZE m_szFirstPageObjOffset;
  std::vector<uint32_t> m_dwDeltaNObjsArray;
  std::vector<uint32_t> m_dwNSharedObjsArray;
  std::vector<uint32_t> m_dwSharedObjNumArray;
  std::vector<uint32_t> m_dwIdentifierArray;
  std::vector<FX_FILESIZE> m_szPageOffsetArray;
  std::vector<FX_FILESIZE> m_szSharedObjOffsetArray;
};

#endif  // CORE_FPDFAPI_PARSER_CPDF_HINT_TABLES_H_