Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_structelement.h
Go to the documentation of this file.
1// Copyright 2017 The PDFium Authors
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_CPDF_STRUCTELEMENT_H_
8#define CORE_FPDFDOC_CPDF_STRUCTELEMENT_H_
9
10#include <vector>
11
12#include "core/fxcrt/fx_string.h"
13#include "core/fxcrt/retain_ptr.h"
14#include "core/fxcrt/unowned_ptr.h"
15#include "third_party/abseil-cpp/absl/types/optional.h"
16
17class CPDF_Dictionary;
18class CPDF_Object;
19class CPDF_StructTree;
20
21class CPDF_StructElement final : public Retainable {
22 public:
24
25 ByteString GetType() const { return m_Type; }
26 ByteString GetObjType() const;
27 WideString GetAltText() const;
28 WideString GetActualText() const;
29 WideString GetTitle() const;
30 absl::optional<WideString> GetID() const;
32 RetainPtr<const CPDF_Object> GetA() const;
33 RetainPtr<const CPDF_Object> GetK() const;
34
35 size_t CountKids() const;
36 CPDF_StructElement* GetKidIfElement(size_t index) const;
37 int GetKidContentId(size_t index) const;
38 bool UpdateKidIfElement(const CPDF_Dictionary* pDict,
39 CPDF_StructElement* pElement);
40
41 CPDF_StructElement* GetParent() const { return m_pParentElement; }
42 void SetParent(CPDF_StructElement* pParentElement) {
43 m_pParentElement = pParentElement;
44 }
45
46 private:
47 struct Kid {
48 enum Type { kInvalid, kElement, kPageContent, kStreamContent, kObject };
49
50 Kid();
51 Kid(const Kid& that);
52 ~Kid();
53
54 Type m_Type = kInvalid;
55 uint32_t m_PageObjNum = 0; // For {PageContent, StreamContent, Object}.
56 uint32_t m_RefObjNum = 0; // For {StreamContent, Object} types.
57 uint32_t m_ContentId = 0; // For {PageContent, StreamContent} types.
58 RetainPtr<CPDF_StructElement> m_pElement; // For Element type.
59 RetainPtr<const CPDF_Dictionary> m_pDict; // For Element type.
60 };
61
62 CPDF_StructElement(const CPDF_StructTree* pTree,
63 RetainPtr<const CPDF_Dictionary> pDict);
64 ~CPDF_StructElement() override;
65
66 void LoadKids();
67 void LoadKid(uint32_t page_obj_num,
68 RetainPtr<const CPDF_Object> pKidObj,
69 Kid& kid);
70
71 UnownedPtr<const CPDF_StructTree> const m_pTree;
72 RetainPtr<const CPDF_Dictionary> const m_pDict;
73 UnownedPtr<CPDF_StructElement> m_pParentElement;
74 const ByteString m_Type;
75 std::vector<Kid> m_Kids;
76};
77
78#endif // CORE_FPDFDOC_CPDF_STRUCTELEMENT_H_
int GetIntegerFor(const ByteString &key) const
ByteString GetNameFor(const ByteString &key) const
uint32_t GetRefObjNum() const
void SetParent(CPDF_StructElement *pParentElement)
int GetKidContentId(size_t index) const
absl::optional< WideString > GetID() const
bool UpdateKidIfElement(const CPDF_Dictionary *pDict, CPDF_StructElement *pElement)
ByteString GetType() const
RetainPtr< const CPDF_Object > GetK() const
WideString GetTitle() const
absl::optional< WideString > GetLang() const
CPDF_StructElement * GetKidIfElement(size_t index) const
WideString GetActualText() const
CPDF_StructElement * GetParent() const
ByteString GetObjType() const
WideString GetAltText() const
RetainPtr< const CPDF_Object > GetA() const
bool operator==(const char *ptr) const
#define CONSTRUCT_VIA_MAKE_RETAIN
Definition retain_ptr.h:224