1// Copyright 2014 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_INCLUDE_FPDFDOC_FPDF_TAGGED_H_
8#define CORE_INCLUDE_FPDFDOC_FPDF_TAGGED_H_
9
10class CPDF_Document;
11class CPDF_Page;
12class CPDF_StructElement;
13class CPDF_StructTree;
14class IPDF_ReflowedPage;
15struct CPDF_StructKid;
16
17class CPDF_StructTree {
18 public:
19  static CPDF_StructTree* LoadDoc(const CPDF_Document* pDoc);
20
21  static CPDF_StructTree* LoadPage(const CPDF_Document* pDoc,
22                                   const CPDF_Dictionary* pPageDict);
23
24  virtual ~CPDF_StructTree() {}
25
26  virtual int CountTopElements() const = 0;
27
28  virtual CPDF_StructElement* GetTopElement(int i) const = 0;
29};
30struct CPDF_StructKid {
31  enum { Invalid, Element, PageContent, StreamContent, Object } m_Type;
32
33  union {
34    struct {
35      CPDF_StructElement* m_pElement;
36
37      CPDF_Dictionary* m_pDict;
38    } m_Element;
39    struct {
40      FX_DWORD m_PageObjNum;
41
42      FX_DWORD m_ContentId;
43    } m_PageContent;
44    struct {
45      FX_DWORD m_PageObjNum;
46
47      FX_DWORD m_ContentId;
48
49      FX_DWORD m_RefObjNum;
50    } m_StreamContent;
51    struct {
52      FX_DWORD m_PageObjNum;
53
54      FX_DWORD m_RefObjNum;
55    } m_Object;
56  };
57};
58class CPDF_StructElement {
59 public:
60  virtual ~CPDF_StructElement() {}
61
62  virtual CPDF_StructTree* GetTree() const = 0;
63
64  virtual const CFX_ByteString& GetType() const = 0;
65
66  virtual CPDF_StructElement* GetParent() const = 0;
67
68  virtual CPDF_Dictionary* GetDict() const = 0;
69
70  virtual int CountKids() const = 0;
71
72  virtual const CPDF_StructKid& GetKid(int index) const = 0;
73
74  virtual CPDF_Object* GetAttr(const CFX_ByteStringC& owner,
75                               const CFX_ByteStringC& name,
76                               FX_BOOL bInheritable = FALSE,
77                               FX_FLOAT fLevel = 0.0F) = 0;
78
79  virtual CFX_ByteString GetName(const CFX_ByteStringC& owner,
80                                 const CFX_ByteStringC& name,
81                                 const CFX_ByteStringC& default_value,
82                                 FX_BOOL bInheritable = FALSE,
83                                 int subindex = -1) = 0;
84
85  virtual FX_ARGB GetColor(const CFX_ByteStringC& owner,
86                           const CFX_ByteStringC& name,
87                           FX_ARGB default_value,
88                           FX_BOOL bInheritable = FALSE,
89                           int subindex = -1) = 0;
90
91  virtual FX_FLOAT GetNumber(const CFX_ByteStringC& owner,
92                             const CFX_ByteStringC& name,
93                             FX_FLOAT default_value,
94                             FX_BOOL bInheritable = FALSE,
95                             int subindex = -1) = 0;
96
97  virtual int GetInteger(const CFX_ByteStringC& owner,
98                         const CFX_ByteStringC& name,
99                         int default_value,
100                         FX_BOOL bInheritable = FALSE,
101                         int subindex = -1) = 0;
102};
103
104#endif  // CORE_INCLUDE_FPDFDOC_FPDF_TAGGED_H_
105