1 // Copyright 2017 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_AVAIL_H_ 6 #define CORE_FPDFAPI_PARSER_CPDF_OBJECT_AVAIL_H_ 7 8 #include <memory> 9 #include <set> 10 #include <stack> 11 12 #include "core/fpdfapi/parser/cpdf_data_avail.h" 13 #include "core/fxcrt/maybe_owned.h" 14 #include "core/fxcrt/unowned_ptr.h" 15 16 class CPDF_Object; 17 class CPDF_Reference; 18 class CPDF_IndirectObjectHolder; 19 class CPDF_ReadValidator; 20 21 // Helper for check availability of object tree. 22 class CPDF_ObjectAvail { 23 public: 24 CPDF_ObjectAvail(CPDF_ReadValidator* validator, 25 CPDF_IndirectObjectHolder* holder, 26 const CPDF_Object* root); 27 CPDF_ObjectAvail(CPDF_ReadValidator* validator, 28 CPDF_IndirectObjectHolder* holder, 29 uint32_t obj_num); 30 virtual ~CPDF_ObjectAvail(); 31 32 CPDF_DataAvail::DocAvailStatus CheckAvail(); 33 34 protected: 35 virtual bool ExcludeObject(const CPDF_Object* object) const; 36 37 private: 38 bool LoadRootObject(); 39 bool CheckObjects(); 40 bool AppendObjectSubRefs(const CPDF_Object* object, 41 std::stack<uint32_t>* refs) const; 42 void CleanMemory(); 43 bool HasObjectParsed(uint32_t obj_num) const; 44 45 UnownedPtr<CPDF_ReadValidator> validator_; 46 // TODO(art-snake): Make it UnownedPtr<, after fix document owning issue. 47 CPDF_IndirectObjectHolder* holder_; 48 MaybeOwned<const CPDF_Object> root_; 49 std::set<uint32_t> parsed_objnums_; 50 std::stack<uint32_t> non_parsed_objects_; 51 }; 52 53 #endif // CORE_FPDFAPI_PARSER_CPDF_OBJECT_AVAIL_H_ 54