TextSegment.h
1 #pragma once
2 // Copyright (c) 2001-2024 Aspose Pty Ltd. All Rights Reserved.
3 
4 #include <system/eventhandler.h>
5 #include <system/array.h>
6 #include <cstdint>
7 
8 #include "Aspose.PDF.Cpp/Text/TextState.h"
9 #include "Aspose.PDF.Cpp/Text/OnSegmentChangedEventArgs.h"
10 #include "Aspose.PDF.Cpp/aspose_pdf_api_defs.h"
11 
12 namespace Aspose
13 {
14 namespace Pdf
15 {
16 namespace Annotations
17 {
18 class Redaction;
19 class TextMarkupAnnotation;
20 } // namespace Annotations
21 class Document;
22 namespace Engine
23 {
24 namespace CommonData
25 {
26 namespace Text
27 {
28 namespace Segmenting
29 {
30 class PhysicalTextSegment;
31 namespace Settings
32 {
33 enum class NoCharacterAction;
34 } // namespace Settings
35 } // namespace Segmenting
36 } // namespace Text
37 } // namespace CommonData
38 namespace Data
39 {
40 class ITrailerable;
41 } // namespace Data
42 } // namespace Engine
43 class Hyperlink;
44 namespace LogicalStructure
45 {
46 class MCRElement;
47 } // namespace LogicalStructure
48 class Page;
49 class PageGenerator;
50 namespace PageModel
51 {
52 class TextElement;
53 } // namespace PageModel
54 class Rectangle;
55 class Table;
56 namespace Tests
57 {
58 namespace Text
59 {
60 class TextBuilderTests;
61 class TextFragmentAbsorberTests;
62 class TextParagraphAbsorberTests;
63 class TextSegmentTests;
64 } // namespace Text
65 } // namespace Tests
66 namespace Text
67 {
68 class CharInfo;
69 class CharInfoCollection;
70 class Font;
71 class Position;
72 class TextBuilder;
73 class TextEditOptions;
74 class TextFragment;
75 class TextFragmentAbsorber;
76 class TextFragmentCollection;
77 class TextFragmentState;
78 class TextParagraph;
79 class TextPostReplaceFixer;
80 class TextSegmentCollection;
81 } // namespace Text
82 } // namespace Pdf
83 } // namespace Aspose
84 namespace System
85 {
86 class EventArgs;
87 namespace Xml
88 {
89 class XmlReader;
90 class XmlTextWriter;
91 } // namespace Xml
92 } // namespace System
93 
94 namespace Aspose {
95 
96 namespace Pdf {
97 
98 namespace Text {
99 
137 class ASPOSE_PDF_SHARED_CLASS TextSegment final : public System::Object
138 {
139  typedef TextSegment ThisType;
140  typedef System::Object BaseType;
141 
142  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
143  ASPOSE_PDF_SHARED_RTTI_INFO_DECL();
144 
145  friend class Aspose::Pdf::Annotations::Redaction;
146  friend class Aspose::Pdf::PageModel::TextElement;
148  friend class Aspose::Pdf::Text::TextPostReplaceFixer;
150  friend class Aspose::Pdf::PageGenerator;
151  friend class Aspose::Pdf::Document;
162  friend class Aspose::Pdf::Table;
163  friend class Aspose::Pdf::Tests::Text::TextParagraphAbsorberTests;
164  friend class Aspose::Pdf::Tests::Text::TextFragmentAbsorberTests;
165  friend class Aspose::Pdf::Tests::Text::TextBuilderTests;
166  friend class Aspose::Pdf::Tests::Text::TextSegmentTests;
167 
168 public:
169 
173  ASPOSE_PDF_SHARED_API int32_t get_StartCharIndex() const;
177  ASPOSE_PDF_SHARED_API int32_t get_EndCharIndex() const;
181  ASPOSE_PDF_SHARED_API System::String get_Text() const;
185  ASPOSE_PDF_SHARED_API void set_Text(System::String value);
197  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Text::TextState> get_TextState() const;
209  ASPOSE_PDF_SHARED_API void set_TextState(System::SharedPtr<Aspose::Pdf::Text::TextState> value);
213  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Text::Position> get_Position() const;
217  ASPOSE_PDF_SHARED_API void set_Position(System::SharedPtr<Aspose::Pdf::Text::Position> value);
221  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Rectangle> get_Rectangle();
226  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Text::Position> get_BaselinePosition() const;
231  ASPOSE_PDF_SHARED_API void set_BaselinePosition(System::SharedPtr<Aspose::Pdf::Text::Position> value);
235  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Text::TextEditOptions> get_TextEditOptions() const;
239  ASPOSE_PDF_SHARED_API void set_TextEditOptions(System::SharedPtr<Aspose::Pdf::Text::TextEditOptions> value);
243  ASPOSE_PDF_SHARED_API System::SharedPtr<CharInfoCollection> get_Characters();
247  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Hyperlink> get_Hyperlink() const;
251  ASPOSE_PDF_SHARED_API void set_Hyperlink(System::SharedPtr<Aspose::Pdf::Hyperlink> value);
252 
258  ASPOSE_PDF_SHARED_API TextSegment();
265  ASPOSE_PDF_SHARED_API TextSegment(System::String text);
266 
272  static ASPOSE_PDF_SHARED_API System::String MyHtmlEncode(System::String value);
273 
274 protected:
275 
279  Aspose::Pdf::Text::TextState::AttachState get_AttachedState() const;
280  System::String get_McName() const;
281  void set_McName(System::String value);
282  int32_t get_McId() const;
283  void set_McId(int32_t value);
288  System::String get_Id() const;
292  void set_Id(System::String value);
293  Aspose::Pdf::Engine::CommonData::Text::Segmenting::Settings::NoCharacterAction get_PhysicalNoCharacterAction() const;
294  double get_Height();
304 
308 
317  void Detach();
321  void IsolatePhysicalSegment();
327  System::SharedPtr<TextSegment> Split(int32_t index);
331  void DeletePhysicalSegment();
332 
334 
335  MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(TextSegment, CODEPORTING_ARGS(System::SharedPtr<Aspose::Pdf::Engine::CommonData::Text::Segmenting::PhysicalTextSegment> physicalSegment, int32_t startCharIndex, int32_t endCharIndex, System::SharedPtr<Aspose::Pdf::Text::TextEditOptions> textEditOptions));
342  void OnSegmentIsolated(System::SharedPtr<OnSegmentChangedEventArgs> e);
343 
344  TextSegment(System::SharedPtr<Aspose::Pdf::Engine::CommonData::Text::Segmenting::PhysicalTextSegment> physicalSegment, int32_t startCharIndex, int32_t endCharIndex);
345 
346  MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(TextSegment, CODEPORTING_ARGS(System::SharedPtr<Aspose::Pdf::Engine::CommonData::Text::Segmenting::PhysicalTextSegment> physicalSegment, int32_t startCharIndex, int32_t endCharIndex));
353  void SetEncodedTextProperties(System::SharedPtr<Font> font, System::String text, System::ArrayPtr<int32_t> indices);
358  double MeasureSegment();
363  System::SharedPtr<CharInfo> GetCharInfo(int32_t charIndex);
368  void SetText(System::String value);
369  void ProcessHyperlink(System::SharedPtr<Page> page);
370  void Serialize(System::SharedPtr<System::Xml::XmlTextWriter> writer);
371  void Deserialize(System::SharedPtr<System::Xml::XmlReader> reader);
372 
373  virtual ASPOSE_PDF_SHARED_API ~TextSegment();
374 
375 private:
376 
377  System::String id;
381  System::String text;
383  int32_t startCharIndex;
384  int32_t endCharIndex;
385  int32_t adjustmentSpacesBeforeStart;
386  int32_t adjustmentSpacesBeforeEnd;
390  Engine::CommonData::Text::Segmenting::Settings::NoCharacterAction _physicalNoCharacterAction;
392  bool _isolated;
395  System::SharedPtr<CharInfoCollection> charInfoCollection;
397 
401  void set_AttachedState(Aspose::Pdf::Text::TextState::AttachState value);
402 
403  int32_t mcId;
404  System::String pr_McName;
405 
409  System::ArrayPtr<int32_t> get_Indices() const;
413  void set_Indices(System::ArrayPtr<int32_t> value);
414  void set_PhysicalNoCharacterAction(Aspose::Pdf::Engine::CommonData::Text::Segmenting::Settings::NoCharacterAction value);
415 
420  void InitializeDetachedSegment(System::String text);
428  void InitializeAttachedSegment(System::SharedPtr<Aspose::Pdf::Engine::CommonData::Text::Segmenting::PhysicalTextSegment> physicalSegment, int32_t startCharIndex, int32_t endCharIndex, System::SharedPtr<Aspose::Pdf::Text::TextEditOptions> textEditOptions);
429  void TextStateOnOnFontSizeChanged(System::SharedPtr<System::Object> sender, System::SharedPtr<System::EventArgs> eventArgs);
430  void TextStateOnOnFontChanged(System::SharedPtr<System::Object> sender, System::SharedPtr<System::EventArgs> eventArgs);
431  void CountAndjustmentSpaces();
432 
433 };
434 
435 } // namespace Text
436 } // namespace Pdf
437 } // namespace Aspose
438 
439 
Represents a text segments collection
Definition: TextSegmentCollection.h:62
String class used across the library. Is a substitute for C# System.String when translating code...
Definition: string.h:121
Represents fragment of Pdf text.
Definition: TextFragment.h:173
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:64
Class representing PDF document
Definition: Document.h:625
Definition: Artifact.h:67
Represents text paragraphs as multiline text object.
Definition: TextParagraph.h:86
Represents segment of Pdf text.
Definition: TextSegment.h:137
System::EventHandler OnPositionChanged
Definition: TextSegment.h:305
Represents an absorber object of text fragments. Performs text search and provides access to search r...
Definition: TextFragmentAbsorber.h:81
Definition: signed_info.h:13
Represents CharInfo objects collection.
Definition: CharInfoCollection.h:41
System::EventHandler OnTextChanged
Definition: TextSegment.h:306
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: fwd.h:22
means saving in XML format
Appends text object to Pdf page.
Definition: TextBuilder.h:73
Represents marked-content reference object in logical structure.
Definition: MCRElement.h:63
Class representing page of PDF document.
Definition: Page.h:375
Definition: AFRelationship.h:4
Represents a text fragments collection
Definition: TextFragmentCollection.h:57
AttachState
Enum for attached state of the objects
Definition: TextState.h:174
Represents a text state of a text fragment.
Definition: TextFragmentState.h:97
Abstract base class for text markup annotations.
Definition: TextMarkupAnnotation.h:57
System::EventHandler< System::SharedPtr< OnSegmentChangedEventArgs > > SegmentChanged
Definition: TextSegment.h:307
Represents a table that can be added to the page.
Definition: Table.h:86
MulticastDelegate< void(System::SharedPtr< Object >, TEventArgs)> EventHandler
Represents a method that reacts to and processes an event. This type should be allocated on stack and...
Definition: eventhandler.h:16
Represents a text state of a text
Definition: TextState.h:135
Whole PDF file will be submitted.
Class represents rectangle.
Definition: Rectangle.h:109