• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef CORE_FPDFDOC_CPDF_STRUCTELEMENT_H_
8 #define CORE_FPDFDOC_CPDF_STRUCTELEMENT_H_
9 
10 #include <vector>
11 
12 #include "core/fxcrt/fx_string.h"
13 #include "core/fxcrt/retain_ptr.h"
14 #include "core/fxcrt/unowned_ptr.h"
15 #include "core/fxge/fx_dib.h"
16 
17 class CPDF_Dictionary;
18 class CPDF_Object;
19 class CPDF_StructElement;
20 class CPDF_StructTree;
21 
22 class CPDF_StructKid {
23  public:
24   CPDF_StructKid();
25   CPDF_StructKid(const CPDF_StructKid& that);
26   ~CPDF_StructKid();
27 
28   enum { Invalid, Element, PageContent, StreamContent, Object } m_Type;
29 
30   RetainPtr<CPDF_StructElement> m_pElement;      // For Element.
31   UnownedPtr<CPDF_Dictionary> m_pDict;           // For Element.
32   uint32_t m_PageObjNum;  // For PageContent, StreamContent, Object.
33   uint32_t m_RefObjNum;   // For StreamContent, Object.
34   uint32_t m_ContentId;   // For PageContent, StreamContent.
35 };
36 
37 class CPDF_StructElement : public Retainable {
38  public:
39   template <typename T, typename... Args>
40   friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
41 
GetType()42   const ByteString& GetType() const { return m_Type; }
GetTitle()43   const ByteString& GetTitle() const { return m_Title; }
GetDict()44   CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
45 
46   size_t CountKids() const;
47   CPDF_StructElement* GetKidIfElement(size_t index) const;
GetKids()48   std::vector<CPDF_StructKid>* GetKids() { return &m_Kids; }
49 
50  private:
51   CPDF_StructElement(CPDF_StructTree* pTree,
52                      CPDF_StructElement* pParent,
53                      CPDF_Dictionary* pDict);
54   ~CPDF_StructElement() override;
55 
56   void LoadKids(CPDF_Dictionary* pDict);
57   void LoadKid(uint32_t PageObjNum, CPDF_Object* pObj, CPDF_StructKid* pKid);
58 
59   UnownedPtr<CPDF_StructTree> const m_pTree;
60   UnownedPtr<CPDF_StructElement> const m_pParent;
61   UnownedPtr<CPDF_Dictionary> const m_pDict;
62   ByteString m_Type;
63   ByteString m_Title;
64   std::vector<CPDF_StructKid> m_Kids;
65 };
66 
67 #endif  // CORE_FPDFDOC_CPDF_STRUCTELEMENT_H_
68