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_REFERENCE_H_ 8 #define CORE_FPDFAPI_PARSER_CPDF_REFERENCE_H_ 9 10 #include <memory> 11 #include <set> 12 13 #include "core/fpdfapi/parser/cpdf_object.h" 14 15 class CPDF_IndirectObjectHolder; 16 17 class CPDF_Reference : public CPDF_Object { 18 public: 19 CPDF_Reference(CPDF_IndirectObjectHolder* pDoc, uint32_t objnum); 20 ~CPDF_Reference() override; 21 22 // CPDF_Object: 23 Type GetType() const override; 24 std::unique_ptr<CPDF_Object> Clone() const override; 25 CPDF_Object* GetDirect() const override; 26 CFX_ByteString GetString() const override; 27 FX_FLOAT GetNumber() const override; 28 int GetInteger() const override; 29 CPDF_Dictionary* GetDict() const override; 30 bool IsReference() const override; 31 CPDF_Reference* AsReference() override; 32 const CPDF_Reference* AsReference() const override; 33 GetObjList()34 CPDF_IndirectObjectHolder* GetObjList() const { return m_pObjList; } GetRefObjNum()35 uint32_t GetRefObjNum() const { return m_RefObjNum; } 36 37 void SetRef(CPDF_IndirectObjectHolder* pDoc, uint32_t objnum); 38 39 protected: 40 std::unique_ptr<CPDF_Object> CloneNonCyclic( 41 bool bDirect, 42 std::set<const CPDF_Object*>* pVisited) const override; 43 CPDF_Object* SafeGetDirect() const; 44 45 CPDF_IndirectObjectHolder* m_pObjList; 46 uint32_t m_RefObjNum; 47 }; 48 ToReference(CPDF_Object * obj)49inline CPDF_Reference* ToReference(CPDF_Object* obj) { 50 return obj ? obj->AsReference() : nullptr; 51 } 52 ToReference(const CPDF_Object * obj)53inline const CPDF_Reference* ToReference(const CPDF_Object* obj) { 54 return obj ? obj->AsReference() : nullptr; 55 } 56 57 #endif // CORE_FPDFAPI_PARSER_CPDF_REFERENCE_H_ 58