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