OLD | NEW |
(Empty) | |
| 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_FPDFDOC_TAGGED_INT_H_ |
| 8 #define CORE_FPDFDOC_TAGGED_INT_H_ |
| 9 |
| 10 #include <map> |
| 11 #include <memory> |
| 12 #include <vector> |
| 13 |
| 14 #include "core/fpdfdoc/include/fpdf_tagged.h" |
| 15 #include "core/fxcrt/include/cfx_retain_ptr.h" |
| 16 #include "third_party/base/stl_util.h" |
| 17 |
| 18 class CPDF_StructElementImpl; |
| 19 |
| 20 class CPDF_StructTreeImpl final : public IPDF_StructTree { |
| 21 public: |
| 22 explicit CPDF_StructTreeImpl(const CPDF_Document* pDoc); |
| 23 ~CPDF_StructTreeImpl() override; |
| 24 |
| 25 // IPDF_StructTree: |
| 26 int CountTopElements() const override; |
| 27 IPDF_StructElement* GetTopElement(int i) const override; |
| 28 |
| 29 void LoadDocTree(); |
| 30 void LoadPageTree(const CPDF_Dictionary* pPageDict); |
| 31 CPDF_StructElementImpl* AddPageNode( |
| 32 CPDF_Dictionary* pElement, |
| 33 std::map<CPDF_Dictionary*, CPDF_StructElementImpl*>& map, |
| 34 int nLevel = 0); |
| 35 FX_BOOL AddTopLevelNode(CPDF_Dictionary* pDict, |
| 36 CPDF_StructElementImpl* pElement); |
| 37 |
| 38 protected: |
| 39 const CPDF_Dictionary* const m_pTreeRoot; |
| 40 const CPDF_Dictionary* const m_pRoleMap; |
| 41 const CPDF_Dictionary* m_pPage; |
| 42 std::vector<CFX_RetainPtr<CPDF_StructElementImpl>> m_Kids; |
| 43 |
| 44 friend class CPDF_StructElementImpl; |
| 45 }; |
| 46 |
| 47 class CPDF_StructElementImpl final : public IPDF_StructElement { |
| 48 public: |
| 49 CPDF_StructElementImpl(CPDF_StructTreeImpl* pTree, |
| 50 CPDF_StructElementImpl* pParent, |
| 51 CPDF_Dictionary* pDict); |
| 52 |
| 53 // IPDF_StructElement |
| 54 IPDF_StructTree* GetTree() const override; |
| 55 const CFX_ByteString& GetType() const override; |
| 56 IPDF_StructElement* GetParent() const override; |
| 57 CPDF_Dictionary* GetDict() const override; |
| 58 int CountKids() const override; |
| 59 const CPDF_StructKid& GetKid(int index) const override; |
| 60 CPDF_Object* GetAttr(const CFX_ByteStringC& owner, |
| 61 const CFX_ByteStringC& name, |
| 62 FX_BOOL bInheritable = FALSE, |
| 63 FX_FLOAT fLevel = 0.0F) override; |
| 64 CFX_ByteString GetName(const CFX_ByteStringC& owner, |
| 65 const CFX_ByteStringC& name, |
| 66 const CFX_ByteStringC& default_value, |
| 67 FX_BOOL bInheritable = FALSE, |
| 68 int subindex = -1) override; |
| 69 FX_ARGB GetColor(const CFX_ByteStringC& owner, |
| 70 const CFX_ByteStringC& name, |
| 71 FX_ARGB default_value, |
| 72 FX_BOOL bInheritable = FALSE, |
| 73 int subindex = -1) override; |
| 74 FX_FLOAT GetNumber(const CFX_ByteStringC& owner, |
| 75 const CFX_ByteStringC& name, |
| 76 FX_FLOAT default_value, |
| 77 FX_BOOL bInheritable = FALSE, |
| 78 int subindex = -1) override; |
| 79 int GetInteger(const CFX_ByteStringC& owner, |
| 80 const CFX_ByteStringC& name, |
| 81 int default_value, |
| 82 FX_BOOL bInheritable = FALSE, |
| 83 int subindex = -1) override; |
| 84 |
| 85 void LoadKids(CPDF_Dictionary* pDict); |
| 86 void LoadKid(uint32_t PageObjNum, CPDF_Object* pObj, CPDF_StructKid* pKid); |
| 87 CPDF_Object* GetAttr(const CFX_ByteStringC& owner, |
| 88 const CFX_ByteStringC& name, |
| 89 FX_BOOL bInheritable, |
| 90 int subindex); |
| 91 CPDF_StructElementImpl* Retain(); |
| 92 void Release(); |
| 93 |
| 94 protected: |
| 95 ~CPDF_StructElementImpl() override; |
| 96 |
| 97 int m_RefCount; |
| 98 CPDF_StructTreeImpl* const m_pTree; |
| 99 CPDF_StructElementImpl* const m_pParent; |
| 100 CPDF_Dictionary* const m_pDict; |
| 101 CFX_ByteString m_Type; |
| 102 std::vector<CPDF_StructKid> m_Kids; |
| 103 |
| 104 friend class CPDF_StructTreeImpl; |
| 105 }; |
| 106 |
| 107 #endif // CORE_FPDFDOC_TAGGED_INT_H_ |
OLD | NEW |