TextParagraph.h
1 #pragma once
2 // Copyright (c) 2001-2024 Aspose Pty Ltd. All Rights Reserved.
3 
4 #include <system/array.h>
5 #include <cstdint>
6 
7 #include "Aspose.PDF.Cpp/aspose_pdf_api_defs.h"
8 
9 namespace Aspose
10 {
11 namespace Pdf
12 {
13 class Color;
14 namespace Engine
15 {
16 namespace CommonData
17 {
18 namespace Text
19 {
20 namespace Segmenting
21 {
22 class PhysicalTextSegment;
23 class SegmentsGroupState;
24 class TextSegmenter;
25 } // namespace Segmenting
26 } // namespace Text
27 } // namespace CommonData
28 } // namespace Engine
29 namespace Facades
30 {
31 class PdfFileMend;
32 } // namespace Facades
33 class Heading;
34 enum class HorizontalAlignment;
35 class MarginInfo;
36 class Matrix;
37 class PageGenerator;
38 class Rectangle;
39 namespace Tests
40 {
41 class RegressionTests_v9_9;
42 namespace Text
43 {
44 class TextBuilderTests;
45 class TextParagraphAbsorberTests;
46 } // namespace Text
47 } // namespace Tests
48 namespace Text
49 {
50 class Position;
51 class TextBuilder;
52 class TextEditOptions;
53 class TextFormattingOptions;
54 class TextFragment;
55 class TextFragmentCollection;
56 class TextSegment;
57 class TextSegmentCollection;
58 class TextState;
59 } // namespace Text
60 enum class VerticalAlignment;
61 } // namespace Pdf
62 } // namespace Aspose
63 namespace System
64 {
65 namespace Collections
66 {
67 namespace Generic
68 {
69 template <typename, typename> class Dictionary;
70 template <typename> class List;
71 } // namespace Generic
72 } // namespace Collections
73 } // namespace System
74 
75 namespace Aspose {
76 
77 namespace Pdf {
78 
79 namespace Text {
80 
86 class ASPOSE_PDF_SHARED_CLASS TextParagraph final : public System::Object
87 {
88  typedef TextParagraph ThisType;
89  typedef System::Object BaseType;
90 
91  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
92  ASPOSE_PDF_SHARED_RTTI_INFO_DECL();
93 
94  friend class Aspose::Pdf::Heading;
95  friend class Aspose::Pdf::PageGenerator;
98  friend class Aspose::Pdf::Tests::Text::TextParagraphAbsorberTests;
99  friend class Aspose::Pdf::Tests::Text::TextBuilderTests;
100  friend class Aspose::Pdf::Tests::RegressionTests_v9_9;
101 
102 protected:
103 
108  {
112  WholeParagraph,
116  LogicalLine
117  };
118 
119 
120 private:
121 
122  class IJustificationElement : public System::Object
123  {
124  typedef IJustificationElement ThisType;
125  typedef System::Object BaseType;
126 
127  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
128  RTTI_INFO_DECL();
129 
130  };
131 
132  class JustificationWord : public Aspose::Pdf::Text::TextParagraph::IJustificationElement
133  {
134  typedef JustificationWord ThisType;
135  typedef Aspose::Pdf::Text::TextParagraph::IJustificationElement BaseType;
136 
137  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
138  RTTI_INFO_DECL();
139 
140  public:
141 
142  System::String get_Word() const;
143  void set_Word(System::String value);
144  int32_t get_StartPos() const;
145  void set_StartPos(int32_t value);
146  int32_t get_EndPos() const;
147  void set_EndPos(int32_t value);
148  const System::SharedPtr<TextSegment>& get_InitialSegment() const;
149  void set_InitialSegment(System::SharedPtr<TextSegment> value);
150  double get_Width() const;
151  void set_Width(double value);
152  double get_SpaceWidth() const;
153  void set_SpaceWidth(double value);
154 
155  JustificationWord();
156 
157  private:
158 
159  System::String pr_Word;
160  int32_t pr_StartPos;
161  int32_t pr_EndPos;
162  System::SharedPtr<TextSegment> pr_InitialSegment;
163  double pr_Width;
164  double pr_SpaceWidth;
165 
166  };
167 
168  class JustificationSpace : public Aspose::Pdf::Text::TextParagraph::IJustificationElement
169  {
170  typedef JustificationSpace ThisType;
171  typedef Aspose::Pdf::Text::TextParagraph::IJustificationElement BaseType;
172 
173  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
174  RTTI_INFO_DECL();
175 
176  public:
177 
178  const System::SharedPtr<TextSegment>& get_InitialSegment() const;
179  void set_InitialSegment(System::SharedPtr<TextSegment> value);
180  double get_SpaceWidth() const;
181  void set_SpaceWidth(double value);
182 
183  JustificationSpace();
184 
185  private:
186 
187  System::SharedPtr<TextSegment> pr_InitialSegment;
188  double pr_SpaceWidth;
189 
190  };
191 
192 
193 public:
194 
201  ASPOSE_PDF_SHARED_API Aspose::Pdf::VerticalAlignment get_VerticalAlignment() const;
208  ASPOSE_PDF_SHARED_API void set_VerticalAlignment(Aspose::Pdf::VerticalAlignment value);
213  ASPOSE_PDF_SHARED_API float get_SubsequentLinesIndent() const;
218  ASPOSE_PDF_SHARED_API void set_SubsequentLinesIndent(float value);
223  ASPOSE_PDF_SHARED_API float get_FirstLineIndent() const;
228  ASPOSE_PDF_SHARED_API void set_FirstLineIndent(float value);
232  ASPOSE_PDF_SHARED_API bool get_Justify();
236  ASPOSE_PDF_SHARED_API void set_Justify(bool value);
243  ASPOSE_PDF_SHARED_API Aspose::Pdf::HorizontalAlignment get_HorizontalAlignment() const;
250  ASPOSE_PDF_SHARED_API void set_HorizontalAlignment(Aspose::Pdf::HorizontalAlignment value);
254  ASPOSE_PDF_SHARED_API System::SharedPtr<TextFormattingOptions> get_FormattingOptions() const;
258  ASPOSE_PDF_SHARED_API void set_FormattingOptions(System::SharedPtr<TextFormattingOptions> value);
262  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Text::Position> get_Position() const;
266  ASPOSE_PDF_SHARED_API void set_Position(System::SharedPtr<Aspose::Pdf::Text::Position> value);
270  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Rectangle> get_TextRectangle();
274  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Rectangle> get_Rectangle() const;
278  ASPOSE_PDF_SHARED_API void set_Rectangle(System::SharedPtr<Aspose::Pdf::Rectangle> value);
282  ASPOSE_PDF_SHARED_API System::SharedPtr<MarginInfo> get_Margin() const;
286  ASPOSE_PDF_SHARED_API void set_Margin(System::SharedPtr<MarginInfo> value);
290  ASPOSE_PDF_SHARED_API double get_Rotation() const;
294  ASPOSE_PDF_SHARED_API void set_Rotation(double value);
295 
299  ASPOSE_PDF_SHARED_API TextParagraph();
300 
310  ASPOSE_PDF_SHARED_API void BeginEdit();
320  ASPOSE_PDF_SHARED_API void EndEdit();
325  ASPOSE_PDF_SHARED_API void AppendLine(System::String line);
332  ASPOSE_PDF_SHARED_API void AppendLine(System::String line, float lineSpacing);
338  ASPOSE_PDF_SHARED_API void AppendLine(System::String line, System::SharedPtr<TextState> textState);
346  ASPOSE_PDF_SHARED_API void AppendLine(System::String line, System::SharedPtr<TextState> textState, float lineSpacing);
351  ASPOSE_PDF_SHARED_API void AppendLine(System::SharedPtr<TextFragment> line);
357  ASPOSE_PDF_SHARED_API void AppendLine(System::SharedPtr<TextFragment> line, System::SharedPtr<TextState> textState);
365  ASPOSE_PDF_SHARED_API void AppendLine(System::SharedPtr<TextFragment> line, System::SharedPtr<TextState> textState, float lineSpacing);
366 
367 protected:
368 
370  System::String get_McName() const;
371  int32_t get_McId() const;
375  System::SharedPtr<Color> get_BackgroundColor() const;
379  void set_BackgroundColor(System::SharedPtr<Color> value);
383  bool get_LimitWithBounds() const;
387  void set_LimitWithBounds(bool value);
392  bool get_PreserveOriginalLinespacing() const;
397  void set_PreserveOriginalLinespacing(bool value);
405  System::String get_HyphenSymbol() const;
413  void set_HyphenSymbol(System::String value);
421  System::SharedPtr<TextFragmentCollection> get_RemainingLines();
426  System::SharedPtr<TextSegment> get_LastSegment();
427  double get_LastFragmentHeight();
431  System::SharedPtr<Aspose::Pdf::Matrix> get_Matrix() const;
435  void set_Matrix(System::SharedPtr<Aspose::Pdf::Matrix> value);
436  bool get_OldCodeCompatibilityMode() const;
437  void set_OldCodeCompatibilityMode(bool value);
441  TextParagraph::TextBackgroundMode get_BackgroundMode() const;
445  void set_BackgroundMode(TextParagraph::TextBackgroundMode value);
451 
461  void RemoveLineByIndex(int32_t index);
470  void InsertAtBeginning(System::SharedPtr<TextFragment> line, System::SharedPtr<TextSegment> segmentInserted);
479  void AddToEnd(System::SharedPtr<TextFragment> line, System::SharedPtr<TextSegment> segmentAdded);
480 
481 private:
482 
486  bool updatingPositioning;
499 
501 
504  Aspose::Pdf::VerticalAlignment verticalAlignment;
505  Aspose::Pdf::HorizontalAlignment horizontalAlignment;
506  System::SharedPtr<Color> backgroundColor;
507  double rotation;
508  bool isAttached;
509  int32_t clipsCount;
510  System::String hyphenSymbol;
511  bool limitWithBounds;
512  bool isEditing;
513  int32_t suspendedUpdateRequest;
514  float subsequentLinesIndent;
515  float firstLineIndent;
516  bool preserveOriginalLinespacing;
517  static const float DefaultSpacing;
518  bool _oldCodeCompatibilityMode;
522  TextParagraph::TextBackgroundMode _backgroundMode;
524  static const int32_t MagicDeltaHeight;
525  static const int32_t FontLinedeltaHeight;
526  static const int32_t DeltaLeft;
527  static const int32_t DeltaRight;
528  static const int32_t DeltaHeight;
529  static const int32_t DeltaUp;
530  static const int32_t DeltaBottom;
531  static const int32_t EmulatedItalicRightCorrection;
532  System::String pr_McName;
533 
534  void set_McName(System::String value);
535 
536  int32_t pr_McId;
537 
538  void set_McId(int32_t value);
539 
542 
546  System::SharedPtr<Aspose::Pdf::Rectangle> get_InsideMarginRectangle();
550  System::SharedPtr<Aspose::Pdf::Text::Position> get_InsideMarginPosition();
551 
555  void UpdateTextRectangle(double textHeight, double textMaxWidth, double& dx, double& dy);
559  void UpdateMatrixCoordinates();
563  void UpdatePositioningInEditingMode();
568  void UpdatePositioning();
573  void UpdatePositioning(bool forceUpdate);
574  void ShiftSegment(double shiftDx, double shiftDy);
575  double DoWrapPositioning();
576  double ComputeLength(System::String input, System::SharedPtr<TextState> textState, int32_t key);
577  float GetLineIndent(bool isFirstLine);
578  void InsertLineWrapLog(int32_t index);
579  double DoNoWrapPositioning();
580  void AddLineToRemaining(System::SharedPtr<TextFragment> inLine);
581  static void SkipSpaces(int32_t& j, int32_t charCount, System::String txt);
582  bool FlushPotentialLine(System::SharedPtr<TextFragment> outLine, bool fillRemainingLines, System::SharedPtr<TextSegmentCollection> remainingLine, System::SharedPtr<TextSegmentCollection> potentialLine, double nextLineShift, float indent, bool isLastSubline);
583  void PositionSegmentsLeft(System::SharedPtr<TextSegmentCollection> ponentialLine, double nextLineShift, float indent);
584  void PositionSegmentsCenter(System::SharedPtr<TextSegmentCollection> ponentialLine, double nextLineShift, float indent);
585  void PositionSegmentsRight(System::SharedPtr<TextSegmentCollection> potentialLine, double nextLineShift, float indent);
586  void PositionSegmentsJustify(System::SharedPtr<TextSegmentCollection> ponentialLine, double nextLineShift, float indent);
587  double ComputeLineShift(int32_t currentLineIndex, System::SharedPtr<TextSegmentCollection> ponentialLine);
588  static void AddNewLine(int32_t& lineIndex, System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<TextSegmentCollection>>> newLines);
593  float GetLineSpacingBeforeIndex(System::SharedPtr<TextSegmentCollection> line, int32_t i);
598  System::SharedPtr<TextSegment> CreateNewSegment(System::String text, System::SharedPtr<TextState> state, bool allowAttachment);
607  void ClearPhysicalSegments();
611  void FlushDetachedProperties();
615  void FlushBGColor();
619  void FlushClipBox();
623  double ComputeMaxTextHeight(System::SharedPtr<TextSegmentCollection> segments);
624  void CorrectRegardingMatrix(System::SharedPtr<TextFragment> textFragment, System::SharedPtr<Aspose::Pdf::Rectangle> newRect);
625  void CorrectRegardingMatrix(System::SharedPtr<TextFragmentCollection> textFragments, System::SharedPtr<Aspose::Pdf::Rectangle>& newRect);
631  void ResetBoxProperties();
632  void AppendLineInternal(System::SharedPtr<TextFragment> fragement, System::SharedPtr<TextState> textState, float lineSpacing);
633  void SplitAndAddSublines(System::String line, System::SharedPtr<TextState> textState, float lineSpacing);
634  void SplitAndAddSublinesFragment(System::SharedPtr<TextFragment> fragment, System::SharedPtr<TextState> textState, float lineSpacing);
635  void CheckForSubstitutionAdd(System::SharedPtr<TextFragment> line, System::SharedPtr<TextState> textState, float lineSpacing);
636  void SubstituteToChunksAndAddSublines(System::String line, System::SharedPtr<TextState> textState);
637  bool IsSeparatorLastIn(System::SharedPtr<TextSegmentCollection> potentialLine);
638  static System::String GetTextWrapNotificationMessage(System::SharedPtr<TextFragment> line);
639 
640 };
641 
642 } // namespace Text
643 } // namespace Pdf
644 } // namespace Aspose
645 
646 
VerticalAlignment
Enumeration of possible vertical alignment values.
Definition: VerticalAlignment.h:16
String class used across the library. Is a substitute for C# System.String when translating code...
Definition: string.h:121
class ASPOSECPP_SHARED_CLASS List
Definition: ienumerable.h:17
Represents a class for adding texts and images on the pages of existing PDF document.
Definition: PdfFileMend.h:49
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:64
Definition: Artifact.h:67
Represents text paragraphs as multiline text object.
Definition: TextParagraph.h:86
HorizontalAlignment
Describes horizontal alignment.
Definition: HorizontalAlignment.h:16
Definition: signed_info.h:13
Represents heading.
Definition: Heading.h:58
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: fwd.h:22
Represents a text type.
Appends text object to Pdf page.
Definition: TextBuilder.h:73
Definition: AFRelationship.h:4
Forward declaration of Dictionary class.
Definition: Artifact.h:73
TextBackgroundMode
Background mode for TextParagraph
Definition: TextParagraph.h:107
List forward declaration.
Definition: Artifact.h:74
Whole PDF file will be submitted.