• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "core/fxcrt/unowned_ptr.h"
15 
16 class CPDF_IndirectObjectHolder;
17 
18 class CPDF_Reference : public CPDF_Object {
19  public:
20   CPDF_Reference(CPDF_IndirectObjectHolder* pDoc, uint32_t objnum);
21   ~CPDF_Reference() override;
22 
23   // CPDF_Object:
24   Type GetType() const override;
25   std::unique_ptr<CPDF_Object> Clone() const override;
26   CPDF_Object* GetDirect() const override;
27   ByteString GetString() const override;
28   float GetNumber() const override;
29   int GetInteger() const override;
30   CPDF_Dictionary* GetDict() const override;
31   bool IsReference() const override;
32   CPDF_Reference* AsReference() override;
33   const CPDF_Reference* AsReference() const override;
34   bool WriteTo(IFX_ArchiveStream* archive) const override;
35 
GetObjList()36   CPDF_IndirectObjectHolder* GetObjList() const { return m_pObjList.Get(); }
GetRefObjNum()37   uint32_t GetRefObjNum() const { return m_RefObjNum; }
38   void SetRef(CPDF_IndirectObjectHolder* pDoc, uint32_t objnum);
39 
40  protected:
41   std::unique_ptr<CPDF_Object> CloneNonCyclic(
42       bool bDirect,
43       std::set<const CPDF_Object*>* pVisited) const override;
44   CPDF_Object* SafeGetDirect() const;
45 
46   UnownedPtr<CPDF_IndirectObjectHolder> m_pObjList;
47   uint32_t m_RefObjNum;
48 };
49 
ToReference(CPDF_Object * obj)50 inline CPDF_Reference* ToReference(CPDF_Object* obj) {
51   return obj ? obj->AsReference() : nullptr;
52 }
53 
ToReference(const CPDF_Object * obj)54 inline const CPDF_Reference* ToReference(const CPDF_Object* obj) {
55   return obj ? obj->AsReference() : nullptr;
56 }
57 
58 #endif  // CORE_FPDFAPI_PARSER_CPDF_REFERENCE_H_
59