From 0370d6b8aab1b7880dd2727e7d9aed04cc358360 Mon Sep 17 00:00:00 2001 From: tsepez Date: Thu, 26 Jan 2017 12:15:34 -0800 Subject: Cleanup CPDF_StructElement. Pre-cursor to properly ref-counting it. Rename to match the CPDF_/IPDF_ conventions. Move CPDF_ structure out of IPDF-defining headers. Break friendships. Review-Url: https://codereview.chromium.org/2640923006 --- core/fpdfdoc/tagged_int.h | 65 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 21 deletions(-) (limited to 'core/fpdfdoc/tagged_int.h') diff --git a/core/fpdfdoc/tagged_int.h b/core/fpdfdoc/tagged_int.h index 03f1c40ad6..6a24700502 100644 --- a/core/fpdfdoc/tagged_int.h +++ b/core/fpdfdoc/tagged_int.h @@ -15,39 +15,62 @@ #include "core/fxcrt/cfx_retain_ptr.h" #include "third_party/base/stl_util.h" -class CPDF_StructElementImpl; +class CPDF_StructElement; + +struct CPDF_StructKid { + enum { Invalid, Element, PageContent, StreamContent, Object } m_Type; + + union { + struct { + CPDF_StructElement* m_pElement; + CPDF_Dictionary* m_pDict; + } m_Element; + struct { + uint32_t m_PageObjNum; + uint32_t m_ContentId; + } m_PageContent; + struct { + uint32_t m_PageObjNum; + uint32_t m_ContentId; + uint32_t m_RefObjNum; + } m_StreamContent; + struct { + uint32_t m_PageObjNum; + uint32_t m_RefObjNum; + } m_Object; + }; +}; -class CPDF_StructTreeImpl final : public IPDF_StructTree { +class CPDF_StructTree final : public IPDF_StructTree { public: - explicit CPDF_StructTreeImpl(const CPDF_Document* pDoc); - ~CPDF_StructTreeImpl() override; + explicit CPDF_StructTree(const CPDF_Document* pDoc); + ~CPDF_StructTree() override; // IPDF_StructTree: int CountTopElements() const override; IPDF_StructElement* GetTopElement(int i) const override; void LoadPageTree(const CPDF_Dictionary* pPageDict); - CPDF_StructElementImpl* AddPageNode( + CPDF_StructElement* AddPageNode( CPDF_Dictionary* pElement, - std::map& map, + std::map& map, int nLevel = 0); - bool AddTopLevelNode(CPDF_Dictionary* pDict, - CPDF_StructElementImpl* pElement); + bool AddTopLevelNode(CPDF_Dictionary* pDict, CPDF_StructElement* pElement); protected: const CPDF_Dictionary* const m_pTreeRoot; const CPDF_Dictionary* const m_pRoleMap; const CPDF_Dictionary* m_pPage; - std::vector> m_Kids; + std::vector> m_Kids; - friend class CPDF_StructElementImpl; + friend class CPDF_StructElement; }; -class CPDF_StructElementImpl final : public IPDF_StructElement { +class CPDF_StructElement final : public IPDF_StructElement { public: - CPDF_StructElementImpl(CPDF_StructTreeImpl* pTree, - CPDF_StructElementImpl* pParent, - CPDF_Dictionary* pDict); + CPDF_StructElement(CPDF_StructTree* pTree, + CPDF_StructElement* pParent, + CPDF_Dictionary* pDict); // IPDF_StructElement IPDF_StructTree* GetTree() const override; @@ -55,7 +78,7 @@ class CPDF_StructElementImpl final : public IPDF_StructElement { IPDF_StructElement* GetParent() const override; CPDF_Dictionary* GetDict() const override; int CountKids() const override; - const CPDF_StructKid& GetKid(int index) const override; + IPDF_StructElement* GetKidIfElement(int index) const override; CPDF_Object* GetAttr(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, bool bInheritable = false, @@ -81,26 +104,26 @@ class CPDF_StructElementImpl final : public IPDF_StructElement { bool bInheritable = false, int subindex = -1) override; + std::vector* GetKids() { return &m_Kids; } void LoadKids(CPDF_Dictionary* pDict); void LoadKid(uint32_t PageObjNum, CPDF_Object* pObj, CPDF_StructKid* pKid); CPDF_Object* GetAttr(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, bool bInheritable, int subindex); - CPDF_StructElementImpl* Retain(); + + CPDF_StructElement* Retain(); void Release(); protected: - ~CPDF_StructElementImpl() override; + ~CPDF_StructElement() override; int m_RefCount; - CPDF_StructTreeImpl* const m_pTree; - CPDF_StructElementImpl* const m_pParent; + CPDF_StructTree* const m_pTree; + CPDF_StructElement* const m_pParent; CPDF_Dictionary* const m_pDict; CFX_ByteString m_Type; std::vector m_Kids; - - friend class CPDF_StructTreeImpl; }; #endif // CORE_FPDFDOC_TAGGED_INT_H_ -- cgit v1.2.3