From 7f389615a0fca78532482d6f4070d18c5d2f9f5d Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Thu, 6 Apr 2017 13:38:54 -0400 Subject: Cleanup the tagged code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL removes the IPDF_Struct* classes in favour of their only implementation. The tagged code was split out into files matching the classes they contain. The friendship between CPDF_StructTree and CPDF_StructElement was broken in favour of accessors. Bug: pdfium:672 Change-Id: Iade83b608fb7168b3b0f41338d10d5fd8ab91a6e Reviewed-on: https://pdfium-review.googlesource.com/3820 Reviewed-by: Tom Sepez Reviewed-by: Nicolás Peña Commit-Queue: dsinclair --- core/fpdfdoc/cpdf_structelement.h | 94 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 core/fpdfdoc/cpdf_structelement.h (limited to 'core/fpdfdoc/cpdf_structelement.h') diff --git a/core/fpdfdoc/cpdf_structelement.h b/core/fpdfdoc/cpdf_structelement.h new file mode 100644 index 0000000000..b227397431 --- /dev/null +++ b/core/fpdfdoc/cpdf_structelement.h @@ -0,0 +1,94 @@ +// Copyright 2017 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_FPDFDOC_CPDF_STRUCTELEMENT_H_ +#define CORE_FPDFDOC_CPDF_STRUCTELEMENT_H_ + +#include + +#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/fx_string.h" +#include "core/fxge/fx_dib.h" + +class CPDF_Dictionary; +class CPDF_Object; +class CPDF_StructElement; +class CPDF_StructTree; + +class CPDF_StructKid { + public: + CPDF_StructKid(); + CPDF_StructKid(const CPDF_StructKid& that); + ~CPDF_StructKid(); + + enum { Invalid, Element, PageContent, StreamContent, Object } m_Type; + + CFX_RetainPtr m_pElement; // For Element. + CPDF_Dictionary* m_pDict; // For Element. + uint32_t m_PageObjNum; // For PageContent, StreamContent, Object. + uint32_t m_RefObjNum; // For StreamContent, Object. + uint32_t m_ContentId; // For PageContent, StreamContent. +}; + +class CPDF_StructElement : public CFX_Retainable { + public: + template + friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + + 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; + CPDF_StructElement* GetKidIfElement(int index) const; + CPDF_Object* GetAttr(const CFX_ByteStringC& owner, + const CFX_ByteStringC& name, + bool bInheritable = false, + float fLevel = 0.0F); + CFX_ByteString GetName(const CFX_ByteStringC& owner, + const CFX_ByteStringC& name, + const CFX_ByteStringC& default_value, + bool bInheritable = false, + int subindex = -1); + FX_ARGB GetColor(const CFX_ByteStringC& owner, + const CFX_ByteStringC& name, + FX_ARGB default_value, + bool bInheritable = false, + int subindex = -1); + float GetNumber(const CFX_ByteStringC& owner, + const CFX_ByteStringC& name, + float default_value, + bool bInheritable = false, + int subindex = -1); + int GetInteger(const CFX_ByteStringC& owner, + const CFX_ByteStringC& name, + int default_value, + bool bInheritable = false, + int subindex = -1); + + 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); + + private: + CPDF_StructElement(CPDF_StructTree* pTree, + CPDF_StructElement* pParent, + CPDF_Dictionary* pDict); + ~CPDF_StructElement() override; + + CPDF_StructTree* const m_pTree; + CPDF_StructElement* const m_pParent; + CPDF_Dictionary* const m_pDict; + CFX_ByteString m_Type; + std::vector m_Kids; +}; + +#endif // CORE_FPDFDOC_CPDF_STRUCTELEMENT_H_ -- cgit v1.2.3