1 // Copyright 2018 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 #ifndef CORE_FPDFAPI_PARSER_CPDF_OBJECT_STREAM_H_ 6 #define CORE_FPDFAPI_PARSER_CPDF_OBJECT_STREAM_H_ 7 8 #include <map> 9 #include <memory> 10 11 #include "core/fpdfapi/parser/cpdf_object.h" 12 #include "core/fxcrt/retain_ptr.h" 13 14 class CPDF_IndirectObjectHolder; 15 class CPDF_Stream; 16 class IFX_SeekableReadStream; 17 18 // Implementation of logic of PDF "Object Streams". 19 // See "PDF 32000-1:2008" Spec. section 7.5.7. 20 class CPDF_ObjectStream { 21 public: 22 static bool IsObjectsStreamObject(const CPDF_Object* object); 23 24 static std::unique_ptr<CPDF_ObjectStream> Create(const CPDF_Stream* stream); 25 26 ~CPDF_ObjectStream(); 27 obj_num()28 uint32_t obj_num() const { return obj_num_; } extends_obj_num()29 uint32_t extends_obj_num() const { return extends_obj_num_; } 30 31 bool HasObject(uint32_t obj_number) const; 32 RetainPtr<CPDF_Object> ParseObject(CPDF_IndirectObjectHolder* pObjList, 33 uint32_t obj_number) const; objects_offsets()34 const std::map<uint32_t, uint32_t>& objects_offsets() const { 35 return objects_offsets_; 36 } 37 38 protected: 39 explicit CPDF_ObjectStream(const CPDF_Stream* stream); 40 41 void Init(const CPDF_Stream* stream); 42 RetainPtr<CPDF_Object> ParseObjectAtOffset( 43 CPDF_IndirectObjectHolder* pObjList, 44 uint32_t object_offset) const; 45 46 uint32_t obj_num_ = CPDF_Object::kInvalidObjNum; 47 uint32_t extends_obj_num_ = CPDF_Object::kInvalidObjNum; 48 49 RetainPtr<IFX_SeekableReadStream> data_stream_; 50 int first_object_offset_ = 0; 51 std::map<uint32_t, uint32_t> objects_offsets_; 52 }; 53 54 #endif // CORE_FPDFAPI_PARSER_CPDF_OBJECT_STREAM_H_ 55