Class HSLFTextParagraph
- java.lang.Object
-
- org.apache.poi.hslf.usermodel.HSLFTextParagraph
-
- All Implemented Interfaces:
java.lang.Iterable<HSLFTextRun>
,TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
public final class HSLFTextParagraph extends java.lang.Object implements TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
This class represents a run of text in a powerpoint document. That run could be text on a sheet, or text in a note. It is only a very basic class for now
-
-
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 Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTabStops(double positionInPoints, TabStop.TabStopType tabStopType)
Set theTabStop
collectionvoid
addTextRun(HSLFTextRun run)
void
clearTabStops()
Removes the tabstops of this paragraphs.TextRulerAtom
createTextRuler()
static java.util.List<java.util.List<HSLFTextParagraph>>
findTextParagraphs(PPDrawing ppdrawing, HSLFSheet sheet)
For a given PPDrawing, grab all the TextRunsAutoNumberingScheme
getAutoNumberingScheme()
java.lang.Integer
getAutoNumberingStartAt()
java.lang.Character
getBulletChar()
Returns the bullet characterjava.awt.Color
getBulletColor()
Returns the bullet colorjava.lang.String
getBulletFont()
Returns the bullet fontjava.lang.Double
getBulletSize()
Returns the bullet size, null if unsetTextParagraph.BulletStyle
getBulletStyle()
java.lang.String
getDefaultFontFamily()
java.lang.Double
getDefaultFontSize()
java.lang.Double
getDefaultTabSize()
TextParagraph.FontAlign
getFontAlign()
Returns the font alignment that is applied to the paragraph.java.lang.Double
getIndent()
int
getIndentLevel()
java.lang.Double
getLeftMargin()
java.lang.Double
getLineSpacing()
Returns the vertical line spacing that is to be used within a paragraph.TextPropCollection
getParagraphStyle()
HSLFTextShape
getParentShape()
static java.lang.String
getRawText(java.util.List<HSLFTextParagraph> paragraphs)
Record[]
getRecords()
Returns records that make up the list of text paragraphs (there can be misc InteractiveInfo, TxInteractiveInfo and other records)java.lang.Double
getRightMargin()
Specifies the right margin of the paragraph.int
getRunType()
Returns the type of the text, from the TextHeaderAtom.HSLFSheet
getSheet()
java.lang.Double
getSpaceAfter()
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.Double
getSpaceBefore()
The amount of vertical white space before the paragraph This may be specified in two different ways, percentage spacing and font point spacing:StyleTextProp9Atom
getStyleTextProp9Atom()
Numbered List infojava.util.List<? extends TabStop>
getTabStops()
Get theTabStops
- the list can't be and it's entries shouldn't be modified.static java.lang.String
getText(java.util.List<HSLFTextParagraph> paragraphs)
TextParagraph.TextAlign
getTextAlign()
Returns the alignment that is applied to the paragraph.EscherTextboxWrapper
getTextboxWrapper()
TextRulerAtom
getTextRuler()
java.util.List<HSLFTextRun>
getTextRuns()
Fetch the text runs that are contained within this block of textboolean
isBullet()
Returns whether this rich text run has bulletsboolean
isDirty()
boolean
isDrawingBased()
Is this Text Run one from aPPDrawing
, or is it one from theSlideListWithText
?boolean
isHeaderOrFooter()
Convenience method to determine if this text paragraph is part of the slide header or footerjava.util.Iterator<HSLFTextRun>
iterator()
void
setBullet(boolean flag)
Sets whether this rich text run has bulletsvoid
setBulletChar(java.lang.Character c)
Sets the bullet charactervoid
setBulletColor(java.awt.Color color)
Sets the bullet colorvoid
setBulletFont(java.lang.String typeface)
Sets the bullet fontvoid
setBulletSize(java.lang.Double size)
Sets the bullet sizevoid
setBulletStyle(java.lang.Object... styles)
Sets the bullet styles.void
setDirty()
marks this paragraph dirty, so its records will be renewed on savevoid
setIndent(java.lang.Double indent)
Specifies the indent size that will be applied to the first line of text in the paragraph.void
setIndentLevel(int level)
Specifies the particular level text properties that this paragraph will follow.void
setLeftMargin(java.lang.Double leftMargin)
Specifies the left margin of the paragraph.void
setLineSpacing(java.lang.Double lineSpacing)
This element specifies the vertical line spacing that is to be used within a paragraph.void
setParagraphStyle(TextPropCollection paragraphStyle)
void
setParagraphTextPropVal(java.lang.String propName, java.lang.Integer val)
Sets the value of the given Paragraph TextProp, add if requiredvoid
setParentShape(HSLFTextShape parentShape)
void
setRightMargin(java.lang.Double rightMargin)
void
setRunType(int runType)
void
setSpaceAfter(java.lang.Double spaceAfter)
Set the amount of vertical white space that will be present after the paragraph.void
setSpaceBefore(java.lang.Double spaceBefore)
Set the amount of vertical white space that will be present before the paragraph.void
setStyleTextProp9Atom(StyleTextProp9Atom styleTextProp9Atom)
Numbered List infostatic HSLFTextRun
setText(java.util.List<HSLFTextParagraph> paragraphs, java.lang.String text)
Sets (overwrites) the current text.void
setTextAlign(TextParagraph.TextAlign align)
Specifies the alignment that is to be applied to the paragraph.static void
supplySheet(java.util.List<HSLFTextParagraph> paragraphs, HSLFSheet sheet)
Supply the Sheet we belong to, which might have an assigned SlideShow Also passes it on to our child RichTextRunsstatic java.lang.String
toExternalString(java.lang.String rawText, int runType)
Converts raw text from the text paragraphs to a formatted string, i.e.java.lang.String
toString()
-
-
-
Method Detail
-
addTextRun
public void addTextRun(HSLFTextRun run)
-
getTextRuns
public java.util.List<HSLFTextRun> getTextRuns()
Description copied from interface:TextParagraph
Fetch the text runs that are contained within this block of text- Specified by:
getTextRuns
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getParagraphStyle
public TextPropCollection getParagraphStyle()
-
setParagraphStyle
public void setParagraphStyle(TextPropCollection paragraphStyle)
-
supplySheet
public static void supplySheet(java.util.List<HSLFTextParagraph> paragraphs, HSLFSheet sheet)
Supply the Sheet we belong to, which might have an assigned SlideShow Also passes it on to our child RichTextRuns
-
getSheet
public HSLFSheet getSheet()
-
getRunType
public int getRunType()
Returns the type of the text, from the TextHeaderAtom. Possible values can be seen from TextHeaderAtom- See Also:
TextHeaderAtom
-
setRunType
public void setRunType(int runType)
-
isDrawingBased
public boolean isDrawingBased()
Is this Text Run one from aPPDrawing
, or is it one from theSlideListWithText
?
-
getTextRuler
public TextRulerAtom getTextRuler()
-
createTextRuler
public TextRulerAtom createTextRuler()
-
getRecords
public Record[] getRecords()
Returns records that make up the list of text paragraphs (there can be misc InteractiveInfo, TxInteractiveInfo and other records)- Returns:
- text run records
-
setStyleTextProp9Atom
public void setStyleTextProp9Atom(StyleTextProp9Atom styleTextProp9Atom)
Numbered List info
-
getStyleTextProp9Atom
public StyleTextProp9Atom getStyleTextProp9Atom()
Numbered List info
-
iterator
public java.util.Iterator<HSLFTextRun> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<HSLFTextRun>
-
getLeftMargin
public java.lang.Double getLeftMargin()
- Specified by:
getLeftMargin
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Returns:
- the left margin (in points) of the paragraph or null, if unset
-
setLeftMargin
public void setLeftMargin(java.lang.Double leftMargin)
Description copied from interface:TextParagraph
Specifies 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:
setLeftMargin
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Parameters:
leftMargin
- the left margin (in points) or null to unset
-
getRightMargin
public java.lang.Double getRightMargin()
Description copied from interface:TextParagraph
Specifies 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:
getRightMargin
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Returns:
- the right margin (in points) of the paragraph or null, if unset
-
setRightMargin
public void setRightMargin(java.lang.Double rightMargin)
- Specified by:
setRightMargin
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Parameters:
rightMargin
- the right margin (in points) of the paragraph
-
getIndent
public java.lang.Double getIndent()
- Specified by:
getIndent
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Returns:
- the indent (in points) applied to the first line of text in the paragraph. or null, if unset
-
setIndent
public void setIndent(java.lang.Double indent)
Description copied from interface:TextParagraph
Specifies the indent size that will be applied to the first line of text in the paragraph.- Specified by:
setIndent
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Parameters:
indent
- the indent (in points) applied to the first line of text in the paragraph
-
getDefaultFontFamily
public java.lang.String getDefaultFontFamily()
- Specified by:
getDefaultFontFamily
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getDefaultFontSize
public java.lang.Double getDefaultFontSize()
- Specified by:
getDefaultFontSize
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Returns:
- the default font size, in case its not set in the textrun or null, if unset
-
setTextAlign
public void setTextAlign(TextParagraph.TextAlign align)
Description copied from interface:TextParagraph
Specifies 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:
setTextAlign
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Parameters:
align
- text align
-
getTextAlign
public TextParagraph.TextAlign getTextAlign()
Description copied from interface:TextParagraph
Returns the alignment that is applied to the paragraph. If this attribute is omitted, then null is returned. User code can imply the valueTextParagraph.TextAlign.LEFT
then.- Specified by:
getTextAlign
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Returns:
- alignment that is applied to the paragraph
-
getFontAlign
public TextParagraph.FontAlign getFontAlign()
Description copied from interface:TextParagraph
Returns 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:
getFontAlign
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Returns:
- alignment that is applied to the paragraph
-
getAutoNumberingScheme
public AutoNumberingScheme getAutoNumberingScheme()
-
getAutoNumberingStartAt
public java.lang.Integer getAutoNumberingStartAt()
-
getBulletStyle
public TextParagraph.BulletStyle getBulletStyle()
- Specified by:
getBulletStyle
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Returns:
- the bullet style of the paragraph, if
null
then no bullets are used
-
setBulletStyle
public void setBulletStyle(java.lang.Object... styles)
Description copied from interface:TextParagraph
Sets 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:
setBulletStyle
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getParentShape
public HSLFTextShape getParentShape()
- Specified by:
getParentShape
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
setParentShape
public void setParentShape(HSLFTextShape parentShape)
-
getIndentLevel
public int getIndentLevel()
- Specified by:
getIndentLevel
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Returns:
- the text level of this paragraph (0-based). Default is 0.
-
setIndentLevel
public void setIndentLevel(int level)
Description copied from interface:TextParagraph
Specifies 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:
setIndentLevel
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Parameters:
level
- the level (0 ... 4)
-
setBullet
public void setBullet(boolean flag)
Sets whether this rich text run has bullets
-
isBullet
public boolean isBullet()
Returns whether this rich text run has bullets
-
setBulletChar
public void setBulletChar(java.lang.Character c)
Sets the bullet character
-
getBulletChar
public java.lang.Character getBulletChar()
Returns the bullet character
-
setBulletSize
public void setBulletSize(java.lang.Double size)
Sets the bullet size
-
getBulletSize
public java.lang.Double getBulletSize()
Returns the bullet size, null if unset
-
setBulletColor
public void setBulletColor(java.awt.Color color)
Sets the bullet color
-
getBulletColor
public java.awt.Color getBulletColor()
Returns the bullet color
-
setBulletFont
public void setBulletFont(java.lang.String typeface)
Sets the bullet font
-
getBulletFont
public java.lang.String getBulletFont()
Returns the bullet font
-
setLineSpacing
public void setLineSpacing(java.lang.Double lineSpacing)
Description copied from interface:TextParagraph
This 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:
setLineSpacing
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Parameters:
lineSpacing
- the vertical line spacing
-
getLineSpacing
public java.lang.Double getLineSpacing()
Description copied from interface:TextParagraph
Returns 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:
getLineSpacing
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Returns:
- the vertical line spacing or null, if unset
-
setSpaceBefore
public void setSpaceBefore(java.lang.Double spaceBefore)
Description copied from interface:TextParagraph
Set 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:
setSpaceBefore
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Parameters:
spaceBefore
- the vertical white space before the paragraph, null to unset
-
getSpaceBefore
public java.lang.Double getSpaceBefore()
Description copied from interface:TextParagraph
The 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:
getSpaceBefore
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Returns:
- the vertical white space before the paragraph, or null if unset
-
setSpaceAfter
public void setSpaceAfter(java.lang.Double spaceAfter)
Description copied from interface:TextParagraph
Set 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:
setSpaceAfter
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Parameters:
spaceAfter
- the vertical white space after the paragraph, null to unset
-
getSpaceAfter
public java.lang.Double getSpaceAfter()
Description copied from interface:TextParagraph
The 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:
getSpaceAfter
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Returns:
- the vertical white space after the paragraph or null, if unset
-
getDefaultTabSize
public java.lang.Double getDefaultTabSize()
- Specified by:
getDefaultTabSize
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Returns:
- the default size for a tab character within this paragraph in points, null if unset
-
getTabStops
public java.util.List<? extends TabStop> getTabStops()
Description copied from interface:TextParagraph
Get 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:
getTabStops
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Returns:
- the tabstop collection or
null
if no tabstops are defined
-
addTabStops
public void addTabStops(double positionInPoints, TabStop.TabStopType tabStopType)
Description copied from interface:TextParagraph
Set theTabStop
collection- Specified by:
addTabStops
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
clearTabStops
public void clearTabStops()
Description copied from interface:TextParagraph
Removes the tabstops of this paragraphs. This doesn't affect inherited tabstops, e.g. inherited by the slide master- Specified by:
clearTabStops
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
setText
public static HSLFTextRun setText(java.util.List<HSLFTextParagraph> paragraphs, java.lang.String text)
Sets (overwrites) the current text. Uses the properties of the first paragraph / textrun- Parameters:
text
- the text string used by this object.
-
getText
public static java.lang.String getText(java.util.List<HSLFTextParagraph> paragraphs)
-
getRawText
public static java.lang.String getRawText(java.util.List<HSLFTextParagraph> paragraphs)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toExternalString
public static java.lang.String toExternalString(java.lang.String rawText, int runType)
Converts raw text from the text paragraphs to a formatted string, i.e. it converts certain control characters used in the raw txt- Parameters:
rawText
- the raw textrunType
- the run type of the shape, paragraph or headerAtom. use -1 if unknown- Returns:
- the formatted string
-
findTextParagraphs
public static java.util.List<java.util.List<HSLFTextParagraph>> findTextParagraphs(PPDrawing ppdrawing, HSLFSheet sheet)
For a given PPDrawing, grab all the TextRuns
-
getTextboxWrapper
public EscherTextboxWrapper getTextboxWrapper()
-
setParagraphTextPropVal
public void setParagraphTextPropVal(java.lang.String propName, java.lang.Integer val)
Sets the value of the given Paragraph TextProp, add if required- Parameters:
propName
- The name of the Paragraph TextPropval
- The value to set for the TextProp
-
setDirty
public void setDirty()
marks this paragraph dirty, so its records will be renewed on save
-
isDirty
public boolean isDirty()
-
isHeaderOrFooter
public boolean isHeaderOrFooter()
Convenience method to determine if this text paragraph is part of the slide header or footer- Specified by:
isHeaderOrFooter
in interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
- Returns:
- true if this paragraph is part of a header or footer placeholder
- See Also:
RoundTripHFPlaceholder12
-
-