Class XSLFTextParagraph
- java.lang.Object
-
- org.apache.poi.xslf.usermodel.XSLFTextParagraph
-
- All Implemented Interfaces:
java.lang.Iterable<XSLFTextRun>,TextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>
@Beta public class XSLFTextParagraph extends java.lang.Object implements TextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>
Represents a paragraph of text within the containing text body. The paragraph is the highest level text separation mechanism.- Since:
- POI-3.8
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.poi.sl.usermodel.TextParagraph
TextParagraph.BulletStyle, TextParagraph.FontAlign, TextParagraph.TextAlign
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description XSLFTextRunaddLineBreak()Insert a line breakXSLFTextRunaddNewTextRun()Add a new run of textvoidaddTabStop(double value)voidaddTabStops(double positionInPoints, TabStop.TabStopType tabStopType)Set theTabStopcollectionvoidclearTabStops()Removes the tabstops of this paragraphs.AutoNumberingSchemegetAutoNumberingScheme()java.lang.IntegergetAutoNumberingStartAt()java.lang.StringgetBulletCharacter()java.lang.StringgetBulletFont()PaintStylegetBulletFontColor()java.lang.DoublegetBulletFontSize()Returns the bullet size that is to be used within a paragraph.TextParagraph.BulletStylegetBulletStyle()java.lang.StringgetDefaultFontFamily()java.lang.DoublegetDefaultFontSize()java.lang.DoublegetDefaultTabSize()TextParagraph.FontAligngetFontAlign()Returns the font alignment that is applied to the paragraph.java.lang.DoublegetIndent()intgetIndentLevel()java.lang.DoublegetLeftMargin()java.lang.DoublegetLineSpacing()Returns the vertical line spacing that is to be used within a paragraph.XSLFTextShapegetParentShape()java.lang.DoublegetRightMargin()Specifies the right margin of the paragraph.java.lang.DoublegetSpaceAfter()The amount of vertical white space after the paragraph This may be specified in two different ways, percentage spacing and font point spacing:java.lang.DoublegetSpaceBefore()The amount of vertical white space before the paragraph This may be specified in two different ways, percentage spacing and font point spacing:doublegetTabStop(int idx)java.util.List<XSLFTabStop>getTabStops()Get theTabStops- the list can't be and it's entries shouldn't be modified.java.lang.StringgetText()TextParagraph.TextAligngetTextAlign()Returns the alignment that is applied to the paragraph.java.util.List<XSLFTextRun>getTextRuns()Fetch the text runs that are contained within this block of textCTTextParagraphgetXmlObject()booleanisBullet()Returns whether this paragraph has bulletsbooleanisHeaderOrFooter()Convenience method to determine if this text paragraph is part of the slide header or footerjava.util.Iterator<XSLFTextRun>iterator()voidsetBullet(boolean flag)voidsetBulletAutoNumber(AutoNumberingScheme scheme, int startAt)Specifies that automatic numbered bullet points should be applied to this paragraphvoidsetBulletCharacter(java.lang.String str)voidsetBulletFont(java.lang.String typeface)voidsetBulletFontColor(java.awt.Color color)voidsetBulletFontColor(PaintStyle color)Set the color to be used on bullet characters within a given paragraph.voidsetBulletFontSize(double bulletSize)Sets the bullet size that is to be used within a paragraph.voidsetBulletStyle(java.lang.Object... styles)Sets the bullet styles.voidsetFontAlign(TextParagraph.FontAlign align)Specifies the font alignment that is to be applied to the paragraph.voidsetIndent(java.lang.Double indent)Specifies the indent size that will be applied to the first line of text in the paragraph.voidsetIndentLevel(int level)Specifies the particular level text properties that this paragraph will follow.voidsetLeftMargin(java.lang.Double leftMargin)Specifies the left margin of the paragraph.voidsetLineSpacing(java.lang.Double lineSpacing)This element specifies the vertical line spacing that is to be used within a paragraph.voidsetRightMargin(java.lang.Double rightMargin)voidsetSpaceAfter(java.lang.Double spaceAfter)Set the amount of vertical white space that will be present after the paragraph.voidsetSpaceBefore(java.lang.Double spaceBefore)Set the amount of vertical white space that will be present before the paragraph.voidsetTextAlign(TextParagraph.TextAlign align)Specifies the alignment that is to be applied to the paragraph.java.lang.StringtoString()
-
-
-
Method Detail
-
getText
public java.lang.String getText()
-
getXmlObject
@Internal public CTTextParagraph getXmlObject()
-
getParentShape
public XSLFTextShape getParentShape()
- Specified by:
getParentShapein interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>
-
getTextRuns
public java.util.List<XSLFTextRun> getTextRuns()
Description copied from interface:TextParagraphFetch the text runs that are contained within this block of text- Specified by:
getTextRunsin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>
-
iterator
public java.util.Iterator<XSLFTextRun> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<XSLFTextRun>
-
addNewTextRun
public XSLFTextRun addNewTextRun()
Add a new run of text- Returns:
- a new run of text
-
addLineBreak
public XSLFTextRun addLineBreak()
Insert a line break- Returns:
- text run representing this line break ('\n')
-
getTextAlign
public TextParagraph.TextAlign getTextAlign()
Description copied from interface:TextParagraphReturns the alignment that is applied to the paragraph. If this attribute is omitted, then null is returned. User code can imply the valueTextParagraph.TextAlign.LEFTthen.- Specified by:
getTextAlignin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Returns:
- alignment that is applied to the paragraph
-
setTextAlign
public void setTextAlign(TextParagraph.TextAlign align)
Description copied from interface:TextParagraphSpecifies the alignment that is to be applied to the paragraph. Possible values for this include left, right, centered, justified and distributed, seeTextParagraph.TextAlign.- Specified by:
setTextAlignin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Parameters:
align- text align
-
getFontAlign
public TextParagraph.FontAlign getFontAlign()
Description copied from interface:TextParagraphReturns the font alignment that is applied to the paragraph. If this attribute is omitted, then null is return, user code can imply the a value ofTextParagraph.FontAlign.AUTO- Specified by:
getFontAlignin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Returns:
- alignment that is applied to the paragraph
-
setFontAlign
public void setFontAlign(TextParagraph.FontAlign align)
Specifies the font alignment that is to be applied to the paragraph. Possible values for this include auto, top, center, baseline and bottom. seeTextParagraph.FontAlign.- Parameters:
align- font align
-
getBulletFont
public java.lang.String getBulletFont()
- Returns:
- the font to be used on bullet characters within a given paragraph
-
setBulletFont
public void setBulletFont(java.lang.String typeface)
-
getBulletCharacter
public java.lang.String getBulletCharacter()
- Returns:
- the character to be used in place of the standard bullet point
-
setBulletCharacter
public void setBulletCharacter(java.lang.String str)
-
getBulletFontColor
public PaintStyle getBulletFontColor()
- Returns:
- the color of bullet characters within a given paragraph.
A
nullvalue means to use the text font color.
-
setBulletFontColor
public void setBulletFontColor(java.awt.Color color)
-
setBulletFontColor
public void setBulletFontColor(PaintStyle color)
Set the color to be used on bullet characters within a given paragraph.- Parameters:
color- the bullet color
-
getBulletFontSize
public java.lang.Double getBulletFontSize()
Returns the bullet size that is to be used within a paragraph. This may be specified in two different ways, percentage spacing and font point spacing:If bulletSize >= 0, then bulletSize is a percentage of the font size. If bulletSize < 0, then it specifies the size in points
- Returns:
- the bullet size
-
setBulletFontSize
public void setBulletFontSize(double bulletSize)
Sets the bullet size that is to be used within a paragraph. This may be specified in two different ways, percentage spacing and font point spacing:If bulletSize >= 0, then bulletSize is a percentage of the font size. If bulletSize < 0, then it specifies the size in points
-
getAutoNumberingScheme
public AutoNumberingScheme getAutoNumberingScheme()
- Returns:
- the auto numbering scheme, or null if not defined
-
getAutoNumberingStartAt
public java.lang.Integer getAutoNumberingStartAt()
- Returns:
- the auto numbering starting number, or null if not defined
-
setIndent
public void setIndent(java.lang.Double indent)
Description copied from interface:TextParagraphSpecifies the indent size that will be applied to the first line of text in the paragraph.- Specified by:
setIndentin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Parameters:
indent- the indent (in points) applied to the first line of text in the paragraph
-
getIndent
public java.lang.Double getIndent()
- Specified by:
getIndentin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Returns:
- the indent (in points) applied to the first line of text in the paragraph. or null, if unset
-
setLeftMargin
public void setLeftMargin(java.lang.Double leftMargin)
Description copied from interface:TextParagraphSpecifies the left margin of the paragraph. This is specified in addition to the text body inset and applies only to this text paragraph. That is the text body Inset and the LeftMargin attributes are additive with respect to the text position.- Specified by:
setLeftMarginin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Parameters:
leftMargin- the left margin (in points) or null to unset
-
getLeftMargin
public java.lang.Double getLeftMargin()
- Specified by:
getLeftMarginin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Returns:
- the left margin (in points) of the paragraph, null if unset
-
setRightMargin
public void setRightMargin(java.lang.Double rightMargin)
- Specified by:
setRightMarginin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Parameters:
rightMargin- the right margin (in points) of the paragraph
-
getRightMargin
public java.lang.Double getRightMargin()
Description copied from interface:TextParagraphSpecifies the right margin of the paragraph. This is specified in addition to the text body inset and applies only to this text paragraph. That is the text body Inset and the RightMargin attributes are additive with respect to the text position. The right margin is not support and therefore ignored by the HSLF implementation.- Specified by:
getRightMarginin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Returns:
- the right margin of the paragraph, null if unset
-
getDefaultTabSize
public java.lang.Double getDefaultTabSize()
- Specified by:
getDefaultTabSizein interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Returns:
- the default size for a tab character within this paragraph in points, null if unset
-
getTabStop
public double getTabStop(int idx)
-
addTabStop
public void addTabStop(double value)
-
setLineSpacing
public void setLineSpacing(java.lang.Double lineSpacing)
Description copied from interface:TextParagraphThis element specifies the vertical line spacing that is to be used within a paragraph. This may be specified in two different ways, percentage spacing and font point spacing:If linespacing >= 0, then linespacing is a percentage of normal line height If linespacing < 0, the absolute value of linespacing is the spacing in points
Examples:// spacing will be 120% of the size of the largest text on each line paragraph.setLineSpacing(120); // spacing will be 200% of the size of the largest text on each line paragraph.setLineSpacing(200); // spacing will be 48 points paragraph.setLineSpacing(-48.0);- Specified by:
setLineSpacingin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Parameters:
lineSpacing- the vertical line spacing
-
getLineSpacing
public java.lang.Double getLineSpacing()
Description copied from interface:TextParagraphReturns the vertical line spacing that is to be used within a paragraph. This may be specified in two different ways, percentage spacing and font point spacing:If linespacing >= 0, then linespacing is a percentage of normal line height. If linespacing < 0, the absolute value of linespacing is the spacing in points
- Specified by:
getLineSpacingin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Returns:
- the vertical line spacing or null, if unset
-
setSpaceBefore
public void setSpaceBefore(java.lang.Double spaceBefore)
Description copied from interface:TextParagraphSet the amount of vertical white space that will be present before the paragraph. This space is specified in either percentage or points:If spaceBefore >= 0, then space is a percentage of normal line height. If spaceBefore < 0, the absolute value of linespacing is the spacing in points
Examples:// The paragraph will be formatted to have a spacing before the paragraph text. // The spacing will be 200% of the size of the largest text on each line paragraph.setSpaceBefore(200); // The spacing will be a size of 48 points paragraph.setSpaceBefore(-48.0);- Specified by:
setSpaceBeforein interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Parameters:
spaceBefore- the vertical white space before the paragraph, null to unset
-
getSpaceBefore
public java.lang.Double getSpaceBefore()
Description copied from interface:TextParagraphThe amount of vertical white space before the paragraph This may be specified in two different ways, percentage spacing and font point spacing:If spaceBefore >= 0, then space is a percentage of normal line height. If spaceBefore < 0, the absolute value in points
- Specified by:
getSpaceBeforein interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Returns:
- the vertical white space before the paragraph, or null if unset
-
setSpaceAfter
public void setSpaceAfter(java.lang.Double spaceAfter)
Description copied from interface:TextParagraphSet the amount of vertical white space that will be present after the paragraph. This space is specified in either percentage or points:If spaceAfter >= 0, then space is a percentage of normal line height. If spaceAfter < 0, the absolute value of linespacing is the spacing in points
Examples:// The paragraph will be formatted to have a spacing after the paragraph text. // The spacing will be 200% of the size of the largest text on each line paragraph.setSpaceAfter(200); // The spacing will be a size of 48 points paragraph.setSpaceAfter(-48.0);- Specified by:
setSpaceAfterin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Parameters:
spaceAfter- the vertical white space after the paragraph, null to unset
-
getSpaceAfter
public java.lang.Double getSpaceAfter()
Description copied from interface:TextParagraphThe amount of vertical white space after the paragraph This may be specified in two different ways, percentage spacing and font point spacing:If spaceBefore >= 0, then space is a percentage of normal line height. If spaceBefore < 0, the absolute value of linespacing is the spacing in points
- Specified by:
getSpaceAfterin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Returns:
- the vertical white space after the paragraph or null, if unset
-
setIndentLevel
public void setIndentLevel(int level)
Description copied from interface:TextParagraphSpecifies the particular level text properties that this paragraph will follow. The value for this attribute formats the text according to the corresponding level paragraph properties defined in the SlideMaster.- Specified by:
setIndentLevelin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Parameters:
level- the level (0 ... 4)
-
getIndentLevel
public int getIndentLevel()
- Specified by:
getIndentLevelin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Returns:
- the text level of this paragraph (0-based). Default is 0.
-
isBullet
public boolean isBullet()
Returns whether this paragraph has bullets
-
setBullet
public void setBullet(boolean flag)
- Parameters:
flag- whether text in this paragraph has bullets
-
setBulletAutoNumber
public void setBulletAutoNumber(AutoNumberingScheme scheme, int startAt)
Specifies that automatic numbered bullet points should be applied to this paragraph- Parameters:
scheme- type of auto-numberingstartAt- the number that will start number for a given sequence of automatically numbered bullets (1-based).
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getDefaultFontSize
public java.lang.Double getDefaultFontSize()
- Specified by:
getDefaultFontSizein interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Returns:
- the default font size, in case its not set in the textrun or null, if unset
-
getDefaultFontFamily
public java.lang.String getDefaultFontFamily()
- Specified by:
getDefaultFontFamilyin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>
-
getBulletStyle
public TextParagraph.BulletStyle getBulletStyle()
- Specified by:
getBulletStylein interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Returns:
- the bullet style of the paragraph, if
nullthen no bullets are used
-
setBulletStyle
public void setBulletStyle(java.lang.Object... styles)
Description copied from interface:TextParagraphSets the bullet styles. If no styles are given, the bullets are omitted. Possible attributes are integer/double (bullet size), Color (bullet color), character (bullet character), string (bullet font), AutoNumberingScheme- Specified by:
setBulletStylein interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>
-
getTabStops
public java.util.List<XSLFTabStop> getTabStops()
Description copied from interface:TextParagraphGet theTabStops- the list can't be and it's entries shouldn't be modified. Opposed to other properties, this method is not cascading to the master sheet, if the property is not defined on the normal slide level, i.e. the tabstops on different levels aren't merged.- Specified by:
getTabStopsin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Returns:
- the tabstop collection or
nullif no tabstops are defined
-
addTabStops
public void addTabStops(double positionInPoints, TabStop.TabStopType tabStopType)Description copied from interface:TextParagraphSet theTabStopcollection- Specified by:
addTabStopsin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>
-
clearTabStops
public void clearTabStops()
Description copied from interface:TextParagraphRemoves the tabstops of this paragraphs. This doesn't affect inherited tabstops, e.g. inherited by the slide master- Specified by:
clearTabStopsin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>
-
isHeaderOrFooter
public boolean isHeaderOrFooter()
Description copied from interface:TextParagraphConvenience method to determine if this text paragraph is part of the slide header or footer- Specified by:
isHeaderOrFooterin interfaceTextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun>- Returns:
- true if this paragraph is part of a header or footer placeholder
-
-