Element.h
1 #pragma once
2 // Copyright (c) 2001-2024 Aspose Pty Ltd. All Rights Reserved.
3 
4 #include <system/object_ext.h>
5 #include <system/enumerator_adapter.h>
6 #include <system/constraints.h>
7 #include <system/collections/list.h>
8 
9 #include "Aspose.PDF.Cpp/Tagged/LogicalStructure/ElementList.h"
10 #include "Aspose.PDF.Cpp/aspose_pdf_api_defs.h"
11 
12 namespace Aspose
13 {
14 namespace Pdf
15 {
16 namespace Engine
17 {
18 namespace Data
19 {
20 class IPdfName;
21 class IPdfPrimitive;
22 class ITrailerable;
23 } // namespace Data
24 } // namespace Engine
25 namespace LogicalStructure
26 {
27 class AnnotationElement;
28 class ElementListImplementation;
29 class ElementPdfEngine;
30 class LinkElement;
31 class MCRElement;
32 class OBJRElement;
33 class StructTreeRootElement;
34 class StructureAttributeCollection;
35 class StructureAttributes;
36 class StructureElement;
37 class TableCellElement;
38 class TableElement;
39 class TableTRElement;
40 } // namespace LogicalStructure
41 namespace Tagged
42 {
43 namespace Helpers
44 {
45 class StructureElementUtil;
46 class StructureTextStateFactory;
47 } // namespace Helpers
48 class ITaggedContent;
49 class TaggedContext;
50 } // namespace Tagged
51 namespace Tests
52 {
53 namespace LogicalStructure
54 {
55 class AnnotElementTests;
56 class BibEntryElementTests;
57 class BlockQuoteElementTests;
58 class CaptionElementTests;
59 class CodeElementTests;
60 class FormulaElementTests;
61 class IndexElementTests;
62 class NonStructElementTests;
63 class PrivateElementTests;
64 class QuoteElementTests;
65 class ReferenceElementTests;
66 class RubyElementTests;
67 class RubyRBElementTests;
68 class RubyRPElementTests;
69 class RubyRTElementTests;
70 class WarichuElementTests;
71 class WarichuWPElementTests;
72 class WarichuWTElementTests;
73 } // namespace LogicalStructure
74 class RegressionTests_v19_4;
75 namespace TaggedPdf
76 {
77 class TaggedPdfStructureTests;
78 } // namespace TaggedPdf
79 } // namespace Tests
80 } // namespace Pdf
81 } // namespace Aspose
82 
83 namespace Aspose {
84 
85 namespace Pdf {
86 
87 namespace LogicalStructure {
88 
92 class ASPOSE_PDF_SHARED_CLASS Element : public virtual System::Object
93 {
94  typedef Element ThisType;
95  typedef System::Object BaseType;
96 
97  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
98  ASPOSE_PDF_SHARED_RTTI_INFO_DECL();
99 
100  friend class Aspose::Pdf::Tagged::Helpers::StructureTextStateFactory;
101  friend class Aspose::Pdf::Tagged::Helpers::StructureElementUtil;
114  friend class Aspose::Pdf::Tagged::TaggedContext;
115  friend class Aspose::Pdf::Tests::RegressionTests_v19_4;
116  friend class Aspose::Pdf::Tests::TaggedPdf::TaggedPdfStructureTests;
117  friend class Aspose::Pdf::Tests::LogicalStructure::AnnotElementTests;
118  friend class Aspose::Pdf::Tests::LogicalStructure::BlockQuoteElementTests;
119  friend class Aspose::Pdf::Tests::LogicalStructure::BibEntryElementTests;
120  friend class Aspose::Pdf::Tests::LogicalStructure::CaptionElementTests;
121  friend class Aspose::Pdf::Tests::LogicalStructure::CodeElementTests;
122  friend class Aspose::Pdf::Tests::LogicalStructure::FormulaElementTests;
123  friend class Aspose::Pdf::Tests::LogicalStructure::IndexElementTests;
124  friend class Aspose::Pdf::Tests::LogicalStructure::NonStructElementTests;
125  friend class Aspose::Pdf::Tests::LogicalStructure::PrivateElementTests;
126  friend class Aspose::Pdf::Tests::LogicalStructure::ReferenceElementTests;
127  friend class Aspose::Pdf::Tests::LogicalStructure::RubyElementTests;
128  friend class Aspose::Pdf::Tests::LogicalStructure::RubyRBElementTests;
129  friend class Aspose::Pdf::Tests::LogicalStructure::RubyRPElementTests;
130  friend class Aspose::Pdf::Tests::LogicalStructure::RubyRTElementTests;
131  friend class Aspose::Pdf::Tests::LogicalStructure::QuoteElementTests;
132  friend class Aspose::Pdf::Tests::LogicalStructure::WarichuElementTests;
133  friend class Aspose::Pdf::Tests::LogicalStructure::WarichuWPElementTests;
134  friend class Aspose::Pdf::Tests::LogicalStructure::WarichuWTElementTests;
135 
136 public:
137 
142  ASPOSE_PDF_SHARED_API System::SharedPtr<Element> get_ParentElement() const;
149  ASPOSE_PDF_SHARED_API System::SharedPtr<ElementList> get_ChildElements();
150 
157  template <typename T>
159  {
160  typedef Element BaseT_Element;
161  assert_is_base_of(BaseT_Element, T);
162 
163  System::SharedPtr<System::Collections::Generic::List<T>> elements = System::MakeObject<System::Collections::Generic::List<T>>();
164 
165  for (auto&& element : System::IterateOver(get_ChildElements()))
166  {
167  if (System::ObjectExt::Is<T>(element))
168  {
169  elements->Add(System::AsCast<T>(element));
170  }
171 
172  if (recursiveSearch)
173  {
174  elements->AddRange(element->template FindElements<T>(recursiveSearch));
175  }
176  }
177 
178  return elements;
179  }
180 
186  ASPOSE_PDF_SHARED_API System::SharedPtr<Element> AppendChild(System::SharedPtr<Element> element);
191  ASPOSE_PDF_SHARED_API System::String ToString() const override;
192 
193 protected:
194 
195  System::SharedPtr<ElementPdfEngine> get_ElementEngine() const;
198 
200 
201  virtual ASPOSE_PDF_SHARED_API void PreSave();
202  virtual ASPOSE_PDF_SHARED_API void Save();
203  virtual ASPOSE_PDF_SHARED_API void SetParentElement(System::SharedPtr<Element> parentElement);
204  virtual bool CanBeAppended(System::SharedPtr<Element> element) = 0;
205 
206  virtual ASPOSE_PDF_SHARED_API ~Element();
207 
208 private:
209 
211  System::WeakPtr<Element> _parentElement;
212  System::SharedPtr<ElementList> _childElements;
213 
214  System::String ToString_NonConst();
215 
216 };
217 
218 } // namespace LogicalStructure
219 } // namespace Pdf
220 } // namespace Aspose
221 
222 
Represents Table structure element in logical structure.
Definition: BLSTableElement.h:69
String class used across the library. Is a substitute for C# System.String when translating code...
Definition: string.h:121
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:64
Represents StructTreeRoot object in logical structure.
Definition: StructTreeRootElement.h:67
Represents attributes of structure element for standard attribute owners.
Definition: StructureAttributes.h:47
Represents a base class for structure elements in logical structure.
Definition: StructureElement.h:62
Represents collection of attributes of structure elements.
Definition: StructureAttributeCollection.h:37
Represents a base class for annotation structure elements in logical structure.
Definition: ILSElement.h:164
Definition: signed_info.h:13
Represents object reference entity in logical structure.
Definition: OBJRElement.h:42
Represents a base class for table cell elements (TH and TD) in logical structure. ...
Definition: BLSTableElement.h:533
Represents TR structure element in logical structure of the table.
Definition: BLSTableElement.h:397
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: fwd.h:22
Represents marked-content reference object in logical structure.
Definition: MCRElement.h:63
System::SharedPtr< System::Collections::Generic::List< T > > FindElements(bool recursiveSearch=false)
Find Elements of a given type
Definition: Element.h:158
Definition: AFRelationship.h:4
std::enable_if_t<!Details::IsIterable< Enumerable >::value, Details::EnumeratorAdapter< Enumerable, T > > IterateOver(System::SmartPtr< Enumerable > enumerable)
This function property wraps enumerable (or iterable) object so it can be used with range-based for l...
Definition: enumerator_adapter.h:322
Subclass of System::SmartPtr which sets itself to weak mode at construction. Please note that this cl...
Definition: TextFragmentState.h:69
Represents a base class for element in logical structure.
Definition: Element.h:92
Whole PDF file will be submitted.