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 _FPDF_TAGGED_INT_H_ 8 #define _FPDF_TAGGED_INT_H_ 9 class CPDF_StructTreeImpl; 10 class CPDF_StructElementImpl; 11 class CPDF_StructTreeImpl : public CPDF_StructTree 12 { 13 public: 14 CPDF_StructTreeImpl(const CPDF_Document* pDoc); 15 ~CPDF_StructTreeImpl(); 16 int CountTopElements() const 17 { 18 return m_Kids.GetSize(); 19 } 20 CPDF_StructElement* GetTopElement(int i) const 21 { 22 return (CPDF_StructElement*)m_Kids.GetAt(i); 23 } 24 void LoadDocTree(); 25 void LoadPageTree(const CPDF_Dictionary* pPageDict); 26 CPDF_StructElementImpl* AddPageNode(CPDF_Dictionary* pElement, CFX_MapPtrToPtr& map, int nLevel = 0); 27 FX_BOOL AddTopLevelNode(CPDF_Dictionary* pDict, CPDF_StructElementImpl* pElement); 28 protected: 29 const CPDF_Dictionary* m_pTreeRoot; 30 const CPDF_Dictionary* m_pRoleMap; 31 const CPDF_Dictionary* m_pPage; 32 CFX_ArrayTemplate<CPDF_StructElementImpl*> m_Kids; 33 friend class CPDF_StructElementImpl; 34 }; 35 class CPDF_StructElementImpl : public CPDF_StructElement 36 { 37 public: 38 CPDF_StructElementImpl(CPDF_StructTreeImpl* pTree, CPDF_StructElementImpl* pParent, CPDF_Dictionary* pDict); 39 ~CPDF_StructElementImpl(); 40 CPDF_StructTree* GetTree() const 41 { 42 return m_pTree; 43 } 44 const CFX_ByteString& GetType() const 45 { 46 return m_Type; 47 } 48 CPDF_StructElement* GetParent() const 49 { 50 return m_pParent; 51 } 52 CPDF_Dictionary * GetDict() const 53 { 54 return m_pDict; 55 } 56 int CountKids() const 57 { 58 return m_Kids.GetSize(); 59 } 60 const CPDF_StructKid& GetKid(int index) const 61 { 62 return m_Kids.GetData()[index]; 63 } 64 CFX_PtrArray* GetObjectArray() 65 { 66 return &m_ObjectArray; 67 } 68 69 CPDF_Object* GetAttr(FX_BSTR owner, FX_BSTR name, FX_BOOL bInheritable = FALSE, FX_FLOAT fLevel = 0.0F); 70 71 CFX_ByteString GetName(FX_BSTR owner, FX_BSTR name, FX_BSTR default_value, FX_BOOL bInheritable = FALSE, int subindex = -1); 72 FX_ARGB GetColor(FX_BSTR owner, FX_BSTR name, FX_ARGB default_value, FX_BOOL bInheritable = FALSE, int subindex = -1); 73 FX_FLOAT GetNumber(FX_BSTR owner, FX_BSTR name, FX_FLOAT default_value, FX_BOOL bInheritable = FALSE, int subindex = -1); 74 int GetInteger(FX_BSTR owner, FX_BSTR name, int default_value, FX_BOOL bInheritable = FALSE, int subindex = -1); 75 CFX_PtrArray m_ObjectArray; 76 void LoadKids(CPDF_Dictionary* pDict); 77 void LoadKid(FX_DWORD PageObjNum, CPDF_Object* pObj, CPDF_StructKid* pKid); 78 CPDF_Object* GetAttr(FX_BSTR owner, FX_BSTR name, FX_BOOL bInheritable, int subindex); 79 CPDF_StructElementImpl* Retain(); 80 void Release(); 81 protected: 82 CPDF_StructTreeImpl* m_pTree; 83 CFX_ByteString m_Type; 84 CPDF_StructElementImpl* m_pParent; 85 CPDF_Dictionary* m_pDict; 86 CFX_ArrayTemplate<CPDF_StructKid> m_Kids; 87 88 int m_RefCount; 89 friend class CPDF_StructTreeImpl; 90 }; 91 #endif 92