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