Skip to content

Commit 331d41b

Browse files
LodrKumquatyulian-gaponenko
authored andcommitted
Text elements wrapping support
DEVSIX-1192
1 parent 284c511 commit 331d41b

19 files changed

+1003
-126
lines changed

layout/src/main/java/com/itextpdf/layout/layout/TextLayoutResult.java

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,27 @@ This file is part of the iText (R) project.
5151
public class TextLayoutResult extends MinMaxWidthLayoutResult {
5252

5353
/**
54-
* Indicates whether some word was splitted during {@link com.itextpdf.layout.renderer.TextRenderer#layout(LayoutContext) layout}.
54+
* Indicates whether some word was split during {@link com.itextpdf.layout.renderer.TextRenderer#layout(LayoutContext) layout}.
5555
*/
5656
protected boolean wordHasBeenSplit;
5757
/**
5858
* Indicates whether split was forced by new line symbol in text or not.
5959
*/
6060
protected boolean splitForcedByNewline;
6161

62+
protected boolean containsPossibleBreak = false;
63+
64+
protected boolean lineStartsWithWhiteSpace = false;
65+
66+
protected boolean lineEndsWithSplitCharacterOrWhiteSpace = false;
67+
6268
/**
6369
* Creates the {@link LayoutResult result of {@link com.itextpdf.layout.renderer.TextRenderer#layout(LayoutContext) layouting}}.
6470
* The {@link LayoutResult#causeOfNothing} will be set as null.
6571
*
6672
* @param status the status of {@link com.itextpdf.layout.renderer.TextRenderer#layout(LayoutContext)}
6773
* @param occupiedArea the area occupied by the content
68-
* @param splitRenderer the renderer to draw the splitted part of the content
74+
* @param splitRenderer the renderer to draw the split part of the content
6975
* @param overflowRenderer the renderer to draw the overflowed part of the content
7076
*/
7177
public TextLayoutResult(int status, LayoutArea occupiedArea, IRenderer splitRenderer, IRenderer overflowRenderer) {
@@ -77,7 +83,7 @@ public TextLayoutResult(int status, LayoutArea occupiedArea, IRenderer splitRend
7783
*
7884
* @param status the status of {@link com.itextpdf.layout.renderer.TextRenderer#layout(LayoutContext)}
7985
* @param occupiedArea the area occupied by the content
80-
* @param splitRenderer the renderer to draw the splitted part of the content
86+
* @param splitRenderer the renderer to draw the split part of the content
8187
* @param overflowRenderer the renderer to draw the overflowed part of the content
8288
* @param cause the first renderer to produce {@link LayoutResult#NOTHING}
8389
*/
@@ -89,7 +95,7 @@ public TextLayoutResult(int status, LayoutArea occupiedArea, IRenderer splitRend
8995
* Indicates whether some word in a rendered text was split during {@link com.itextpdf.layout.renderer.IRenderer#layout layout}.
9096
* The value will be set as true if, for example, the rendered words width is bigger than the width of layout area.
9197
*
92-
* @return whether some word was splitted or not.
98+
* @return whether some word was split or not.
9399
*/
94100
public boolean isWordHasBeenSplit() {
95101
return wordHasBeenSplit;
@@ -128,4 +134,70 @@ public TextLayoutResult setSplitForcedByNewline(boolean isSplitForcedByNewline)
128134
this.splitForcedByNewline = isSplitForcedByNewline;
129135
return this;
130136
}
137+
138+
/**
139+
* Indicates whether split renderer contains possible break.
140+
* Possible breaks are either whitespaces or split characters.
141+
*
142+
* @return true if there's a possible break within the split renderer.
143+
* @see com.itextpdf.layout.splitting.ISplitCharacters
144+
*/
145+
public boolean isContainsPossibleBreak() {
146+
return containsPossibleBreak;
147+
}
148+
149+
/**
150+
* Sets {@link #isContainsPossibleBreak()}.
151+
*
152+
* @param containsPossibleBreak indicates that split renderer contains possible break.
153+
* @return {@link com.itextpdf.layout.layout.TextLayoutResult this layout result} the setting was applied on.
154+
* @see #isContainsPossibleBreak
155+
*/
156+
public TextLayoutResult setContainsPossibleBreak(boolean containsPossibleBreak) {
157+
this.containsPossibleBreak = containsPossibleBreak;
158+
return this;
159+
}
160+
161+
/**
162+
* Sets {@link #isLineStartsWithWhiteSpace()}.
163+
*
164+
* @param lineStartsWithWhiteSpace indicates if TextRenderer#line starts with a whitespace.
165+
* @return {@link com.itextpdf.layout.layout.TextLayoutResult this layout result} the setting was applied on.
166+
* @see #isLineStartsWithWhiteSpace
167+
*/
168+
public TextLayoutResult setLineStartsWithWhiteSpace(boolean lineStartsWithWhiteSpace) {
169+
this.lineStartsWithWhiteSpace = lineStartsWithWhiteSpace;
170+
return this;
171+
}
172+
173+
/**
174+
* Indicates whether TextRenderer#line starts with a whitespace.
175+
*
176+
* @return true if TextRenderer#line starts with a whitespace.
177+
*/
178+
public boolean isLineStartsWithWhiteSpace() {
179+
return lineStartsWithWhiteSpace;
180+
}
181+
182+
/**
183+
* Sets {@link #isLineEndsWithSplitCharacterOrWhiteSpace()}.
184+
*
185+
* @param lineEndsWithSplitCharacterOrWhiteSpace indicates if TextRenderer#line ends with a splitCharacter.
186+
* @return {@link com.itextpdf.layout.layout.TextLayoutResult this layout result} the setting was applied on.
187+
* @see #isLineEndsWithSplitCharacterOrWhiteSpace
188+
*/
189+
public TextLayoutResult setLineEndsWithSplitCharacterOrWhiteSpace(boolean lineEndsWithSplitCharacterOrWhiteSpace) {
190+
this.lineEndsWithSplitCharacterOrWhiteSpace = lineEndsWithSplitCharacterOrWhiteSpace;
191+
return this;
192+
}
193+
194+
/**
195+
* Indicates whether TextRenderer#line ends with a splitCharacter.
196+
*
197+
* @return true if TextRenderer#line ends with a splitCharacter.
198+
* @see com.itextpdf.layout.splitting.ISplitCharacters
199+
*/
200+
public boolean isLineEndsWithSplitCharacterOrWhiteSpace() {
201+
return lineEndsWithSplitCharacterOrWhiteSpace;
202+
}
131203
}

0 commit comments

Comments
 (0)