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_basic.h" 14 #include "core/fxcrt/fx_stream.h" 15 16 class CFX_BitStream; 17 class CPDF_LinearizedHeader; 18 class CPDF_Stream; 19 20 class CPDF_HintTables { 21 public: 22 CPDF_HintTables(CPDF_DataAvail* pDataAvail, 23 CPDF_LinearizedHeader* pLinearized); 24 virtual ~CPDF_HintTables(); 25 26 bool GetPagePos(uint32_t index, 27 FX_FILESIZE* szPageStartPos, 28 FX_FILESIZE* szPageLength, 29 uint32_t* dwObjNum); 30 31 CPDF_DataAvail::DocAvailStatus CheckPage( 32 uint32_t index, 33 CPDF_DataAvail::DownloadHints* pHints); 34 35 bool LoadHintStream(CPDF_Stream* pHintStream); 36 37 protected: 38 bool ReadPageHintTable(CFX_BitStream* hStream); 39 bool ReadSharedObjHintTable(CFX_BitStream* hStream, uint32_t offset); 40 41 private: 42 // Tests can override. 43 virtual int GetEndOfFirstPageOffset() const; 44 virtual int GetNumberOfPages() const; 45 virtual int GetFirstPageObjectNumber() const; 46 virtual int GetFirstPageNumber() const; 47 virtual int ReadPrimaryHintStreamOffset() const; 48 virtual int ReadPrimaryHintStreamLength() const; 49 50 uint32_t GetItemLength(uint32_t index, 51 const std::vector<FX_FILESIZE>& szArray); 52 53 // Owner, outlives this object. 54 CPDF_DataAvail* const m_pDataAvail; 55 56 // Owned by |m_pDataAvail|. 57 CPDF_LinearizedHeader* const m_pLinearized; 58 59 uint32_t m_nFirstPageSharedObjs; 60 FX_FILESIZE m_szFirstPageObjOffset; 61 std::vector<uint32_t> m_dwDeltaNObjsArray; 62 std::vector<uint32_t> m_dwNSharedObjsArray; 63 std::vector<uint32_t> m_dwSharedObjNumArray; 64 std::vector<uint32_t> m_dwIdentifierArray; 65 std::vector<FX_FILESIZE> m_szPageOffsetArray; 66 std::vector<FX_FILESIZE> m_szSharedObjOffsetArray; 67 }; 68 69 #endif // CORE_FPDFAPI_PARSER_CPDF_HINT_TABLES_H_ 70