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_LINEARIZED_HEADER_H_
8 #define CORE_FPDFAPI_PARSER_CPDF_LINEARIZED_HEADER_H_
9 
10 #include <memory>
11 
12 #include "core/fxcrt/fx_system.h"
13 
14 class CPDF_Dictionary;
15 class CPDF_Object;
16 class CPDF_SyntaxParser;
17 
18 class CPDF_LinearizedHeader {
19  public:
20   ~CPDF_LinearizedHeader();
21   static std::unique_ptr<CPDF_LinearizedHeader> Parse(
22       CPDF_SyntaxParser* parser);
23 
24   // Will only return values > 0.
GetFileSize()25   FX_FILESIZE GetFileSize() const { return m_szFileSize; }
GetFirstPageNo()26   uint32_t GetFirstPageNo() const { return m_dwFirstPageNo; }
27   // Will only return values > 0.
GetMainXRefTableFirstEntryOffset()28   FX_FILESIZE GetMainXRefTableFirstEntryOffset() const {
29     return m_szMainXRefTableFirstEntryOffset;
30   }
GetPageCount()31   uint32_t GetPageCount() const { return m_PageCount; }
32   // Will only return values > 0.
GetFirstPageEndOffset()33   FX_FILESIZE GetFirstPageEndOffset() const { return m_szFirstPageEndOffset; }
34   // Will only return values > 0.
GetFirstPageObjNum()35   uint32_t GetFirstPageObjNum() const { return m_FirstPageObjNum; }
36   // Will only return values > 0.
GetLastXRefOffset()37   FX_FILESIZE GetLastXRefOffset() const { return m_szLastXRefOffset; }
38 
39   bool HasHintTable() const;
40   // Will only return values > 0.
GetHintStart()41   FX_FILESIZE GetHintStart() const { return m_szHintStart; }
GetHintLength()42   uint32_t GetHintLength() const { return m_HintLength; }
43 
44  protected:
45   CPDF_LinearizedHeader(const CPDF_Dictionary* pDict,
46                         FX_FILESIZE szLastXRefOffset);
47 
48  private:
49   const FX_FILESIZE m_szFileSize;
50   const uint32_t m_dwFirstPageNo;
51   const FX_FILESIZE m_szMainXRefTableFirstEntryOffset;
52   const uint32_t m_PageCount;
53   const FX_FILESIZE m_szFirstPageEndOffset;
54   const uint32_t m_FirstPageObjNum;
55   const FX_FILESIZE m_szLastXRefOffset;
56   FX_FILESIZE m_szHintStart = 0;
57   uint32_t m_HintLength = 0;
58 };
59 
60 #endif  // CORE_FPDFAPI_PARSER_CPDF_LINEARIZED_HEADER_H_
61