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