summaryrefslogtreecommitdiff
path: root/core/src/fpdfdoc/tagged_int.h
blob: 7cf368083c96cacc62cfea6b6edbf294b3c60ac9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef CORE_SRC_FPDFDOC_TAGGED_INT_H_
#define CORE_SRC_FPDFDOC_TAGGED_INT_H_

#include "../../include/fpdfdoc/fpdf_tagged.h"

class CPDF_StructElementImpl;
class CPDF_StructTreeImpl : public CPDF_StructTree {
 public:
  CPDF_StructTreeImpl(const CPDF_Document* pDoc);
  ~CPDF_StructTreeImpl();
  int CountTopElements() const { return m_Kids.GetSize(); }
  CPDF_StructElement* GetTopElement(int i) const {
    return (CPDF_StructElement*)m_Kids.GetAt(i);
  }
  void LoadDocTree();
  void LoadPageTree(const CPDF_Dictionary* pPageDict);
  CPDF_StructElementImpl* AddPageNode(CPDF_Dictionary* pElement,
                                      CFX_MapPtrToPtr& map,
                                      int nLevel = 0);
  FX_BOOL AddTopLevelNode(CPDF_Dictionary* pDict,
                          CPDF_StructElementImpl* pElement);

 protected:
  const CPDF_Dictionary* m_pTreeRoot;
  const CPDF_Dictionary* m_pRoleMap;
  const CPDF_Dictionary* m_pPage;
  CFX_ArrayTemplate<CPDF_StructElementImpl*> m_Kids;
  friend class CPDF_StructElementImpl;
};
class CPDF_StructElementImpl final : public CPDF_StructElement {
 public:
  CPDF_StructElementImpl(CPDF_StructTreeImpl* pTree,
                         CPDF_StructElementImpl* pParent,
                         CPDF_Dictionary* pDict);
  CPDF_StructTree* GetTree() const { return m_pTree; }
  const CFX_ByteString& GetType() const { return m_Type; }
  CPDF_StructElement* GetParent() const { return m_pParent; }
  CPDF_Dictionary* GetDict() const { return m_pDict; }
  int CountKids() const { return m_Kids.GetSize(); }
  const CPDF_StructKid& GetKid(int index) const {
    return m_Kids.GetData()[index];
  }
  CFX_PtrArray* GetObjectArray() { return &m_ObjectArray; }

  CPDF_Object* GetAttr(const CFX_ByteStringC& owner,
                       const CFX_ByteStringC& name,
                       FX_BOOL bInheritable = FALSE,
                       FX_FLOAT fLevel = 0.0F);

  CFX_ByteString GetName(const CFX_ByteStringC& owner,
                         const CFX_ByteStringC& name,
                         const CFX_ByteStringC& default_value,
                         FX_BOOL bInheritable = FALSE,
                         int subindex = -1);
  FX_ARGB GetColor(const CFX_ByteStringC& owner,
                   const CFX_ByteStringC& name,
                   FX_ARGB default_value,
                   FX_BOOL bInheritable = FALSE,
                   int subindex = -1);
  FX_FLOAT GetNumber(const CFX_ByteStringC& owner,
                     const CFX_ByteStringC& name,
                     FX_FLOAT default_value,
                     FX_BOOL bInheritable = FALSE,
                     int subindex = -1);
  int GetInteger(const CFX_ByteStringC& owner,
                 const CFX_ByteStringC& name,
                 int default_value,
                 FX_BOOL bInheritable = FALSE,
                 int subindex = -1);
  CFX_PtrArray m_ObjectArray;
  void LoadKids(CPDF_Dictionary* pDict);
  void LoadKid(FX_DWORD PageObjNum, CPDF_Object* pObj, CPDF_StructKid* pKid);
  CPDF_Object* GetAttr(const CFX_ByteStringC& owner,
                       const CFX_ByteStringC& name,
                       FX_BOOL bInheritable,
                       int subindex);
  CPDF_StructElementImpl* Retain();
  void Release();

 protected:
  ~CPDF_StructElementImpl();

  CPDF_StructTreeImpl* m_pTree;
  CFX_ByteString m_Type;
  CPDF_StructElementImpl* m_pParent;
  CPDF_Dictionary* m_pDict;
  CFX_ArrayTemplate<CPDF_StructKid> m_Kids;
  int m_RefCount;

  friend class CPDF_StructTreeImpl;
};

#endif  // CORE_SRC_FPDFDOC_TAGGED_INT_H_