Package org.apache.poi.hslf.usermodel
Class HSLFTextParagraph
- java.lang.Object
-
- org.apache.poi.hslf.usermodel.HSLFTextParagraph
-
- All Implemented Interfaces:
Iterable<HSLFTextRun>,TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
public final class HSLFTextParagraph extends 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
-
-
Field Summary
Fields Modifier and Type Field Description protected HSLFTextShape_parentShapeprotected TextRulerAtom_rulerprotected List<HSLFTextRun>_runs
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTabStops(double positionInPoints, TabStop.TabStopType tabStopType)voidaddTextRun(HSLFTextRun run)protected static HSLFTextRunappendText(List<HSLFTextParagraph> paragraphs, String text, boolean newParagraph)Adds the supplied text onto the end of the TextParagraphs, creating a new RichTextRun for it to sit in.protected static voidapplyCharacterStyles(List<HSLFTextParagraph> paragraphs, List<TextPropCollection> charStyles)protected static voidapplyHyperlinks(List<HSLFTextParagraph> paragraphs)protected static voidapplyParagraphIndents(List<HSLFTextParagraph> paragraphs, List<IndentProp> paraStyles)protected static voidapplyParagraphStyles(List<HSLFTextParagraph> paragraphs, List<TextPropCollection> paraStyles)voidclearTabStops()TextRulerAtomcreateTextRuler()protected static List<HSLFTextParagraph>findTextParagraphs(EscherTextboxWrapper wrapper, HSLFSheet sheet)Scans through the supplied record array, looking for a TextHeaderAtom followed by one of a TextBytesAtom or a TextCharsAtom.static List<List<HSLFTextParagraph>>findTextParagraphs(PPDrawing ppdrawing, HSLFSheet sheet)For a given PPDrawing, grab all the TextRunsprotected static List<List<HSLFTextParagraph>>findTextParagraphs(Record[] records)Scans through the supplied record array, looking for a TextHeaderAtom followed by one of a TextBytesAtom or a TextCharsAtom.protected static voidfixLineEndings(List<HSLFTextParagraph> paragraphs)Check and add linebreaks to text runs leading other paragraphsAutoNumberingSchemegetAutoNumberingScheme()IntegergetAutoNumberingStartAt()CharactergetBulletChar()Returns the bullet characterColorgetBulletColor()Returns the bullet colorStringgetBulletFont()Returns the bullet fontDoublegetBulletSize()Returns the bullet size, null if unsetTextParagraph.BulletStylegetBulletStyle()protected static ColorgetColorFromColorIndexStruct(int rgb, HSLFSheet sheet)StringgetDefaultFontFamily()DoublegetDefaultFontSize()DoublegetDefaultTabSize()TextParagraph.FontAligngetFontAlign()DoublegetIndent()intgetIndentLevel()protected intgetIndex()DoublegetLeftMargin()DoublegetLineSpacing()TextPropCollectiongetParagraphStyle()HSLFTextShapegetParentShape()protected <T extends TextProp>
TgetPropVal(TextPropCollection props, String propName)Fetch the value of the given Paragraph related TextProp.static StringgetRawText(List<HSLFTextParagraph> paragraphs)Record[]getRecords()Returns records that make up the list of text paragraphs (there can be misc InteractiveInfo, TxInteractiveInfo and other records)DoublegetRightMargin()intgetRunType()Returns the type of the text, from the TextHeaderAtom.protected intgetShapeId()HSLFSheetgetSheet()DoublegetSpaceAfter()DoublegetSpaceBefore()StyleTextProp9AtomgetStyleTextProp9Atom()Numbered List infoList<? extends TabStop>getTabStops()static StringgetText(List<HSLFTextParagraph> paragraphs)TextParagraph.TextAligngetTextAlign()EscherTextboxWrappergetTextboxWrapper()TextRulerAtomgetTextRuler()List<HSLFTextRun>getTextRuns()booleanisBullet()Returns whether this rich text run has bulletsbooleanisDirty()booleanisDrawingBased()Is this Text Run one from aPPDrawing, or is it one from theSlideListWithText?booleanisHeaderOrFooter()Iterator<HSLFTextRun>iterator()voidsetBullet(boolean flag)Sets whether this rich text run has bulletsvoidsetBulletChar(Character c)Sets the bullet charactervoidsetBulletColor(Color color)Sets the bullet colorvoidsetBulletFont(String typeface)Sets the bullet fontvoidsetBulletSize(Double size)Sets the bullet sizevoidsetBulletStyle(Object... styles)voidsetDirty()marks this paragraph dirty, so its records will be renewed on savevoidsetIndent(Double indent)voidsetIndentLevel(int level)protected voidsetIndex(int index)Sets the index of the paragraph in the SLWT containervoidsetLeftMargin(Double leftMargin)voidsetLineSpacing(Double lineSpacing)voidsetParagraphStyle(TextPropCollection paragraphStyle)voidsetParagraphTextPropVal(String propName, Integer val)Sets the value of the given Paragraph TextProp, add if requiredvoidsetParentShape(HSLFTextShape parentShape)protected voidsetPropVal(TextPropCollection props, String name, Integer val)Returns the named TextProp, either by fetching it (if it exists) or adding it (if it didn't)voidsetRightMargin(Double rightMargin)voidsetRunType(int runType)protected voidsetShapeId(int id)voidsetSpaceAfter(Double spaceAfter)voidsetSpaceBefore(Double spaceBefore)voidsetStyleTextProp9Atom(StyleTextProp9Atom styleTextProp9Atom)Numbered List infostatic HSLFTextRunsetText(List<HSLFTextParagraph> paragraphs, String text)Sets (overwrites) the current text.voidsetTextAlign(TextParagraph.TextAlign align)Spliterator<HSLFTextRun>spliterator()protected static voidstoreText(List<HSLFTextParagraph> paragraphs)Saves the modified paragraphs/textrun to the records.static voidsupplySheet(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 StringtoExternalString(String rawText, int runType)Converts raw text from the text paragraphs to a formatted string, i.e.protected static StringtoInternalString(String s)Returns a new string with line breaks converted into internal ppt representationStringtoString()
-
-
-
Field Detail
-
_ruler
protected TextRulerAtom _ruler
-
_runs
protected final List<HSLFTextRun> _runs
-
_parentShape
protected HSLFTextShape _parentShape
-
-
Method Detail
-
addTextRun
public void addTextRun(HSLFTextRun run)
-
getTextRuns
public List<HSLFTextRun> getTextRuns()
- Specified by:
getTextRunsin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getParagraphStyle
public TextPropCollection getParagraphStyle()
-
setParagraphStyle
public void setParagraphStyle(TextPropCollection paragraphStyle)
-
supplySheet
public static void supplySheet(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()
-
getShapeId
protected int getShapeId()
- Returns:
- Shape ID
-
setShapeId
protected void setShapeId(int id)
- Parameters:
id- Shape ID
-
getIndex
protected int getIndex()
- Returns:
- 0-based index of the text run in the SLWT container
-
setIndex
protected void setIndex(int index)
Sets the index of the paragraph in the SLWT container
-
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 Iterator<HSLFTextRun> iterator()
- Specified by:
iteratorin interfaceIterable<HSLFTextRun>
-
spliterator
public Spliterator<HSLFTextRun> spliterator()
- Specified by:
spliteratorin interfaceIterable<HSLFTextRun>- Since:
- POI 5.2.0
-
getLeftMargin
public Double getLeftMargin()
- Specified by:
getLeftMarginin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
setLeftMargin
public void setLeftMargin(Double leftMargin)
- Specified by:
setLeftMarginin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getRightMargin
public Double getRightMargin()
- Specified by:
getRightMarginin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
setRightMargin
public void setRightMargin(Double rightMargin)
- Specified by:
setRightMarginin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getIndent
public Double getIndent()
- Specified by:
getIndentin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
setIndent
public void setIndent(Double indent)
- Specified by:
setIndentin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getDefaultFontFamily
public String getDefaultFontFamily()
- Specified by:
getDefaultFontFamilyin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getDefaultFontSize
public Double getDefaultFontSize()
- Specified by:
getDefaultFontSizein interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
setTextAlign
public void setTextAlign(TextParagraph.TextAlign align)
- Specified by:
setTextAlignin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getTextAlign
public TextParagraph.TextAlign getTextAlign()
- Specified by:
getTextAlignin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getFontAlign
public TextParagraph.FontAlign getFontAlign()
- Specified by:
getFontAlignin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getAutoNumberingScheme
public AutoNumberingScheme getAutoNumberingScheme()
-
getAutoNumberingStartAt
public Integer getAutoNumberingStartAt()
-
getBulletStyle
public TextParagraph.BulletStyle getBulletStyle()
- Specified by:
getBulletStylein interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
setBulletStyle
public void setBulletStyle(Object... styles)
- Specified by:
setBulletStylein interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getParentShape
public HSLFTextShape getParentShape()
- Specified by:
getParentShapein interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
setParentShape
public void setParentShape(HSLFTextShape parentShape)
-
getIndentLevel
public int getIndentLevel()
- Specified by:
getIndentLevelin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
setIndentLevel
public void setIndentLevel(int level)
- Specified by:
setIndentLevelin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
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(Character c)
Sets the bullet character
-
getBulletChar
public Character getBulletChar()
Returns the bullet character
-
setBulletSize
public void setBulletSize(Double size)
Sets the bullet size
-
getBulletSize
public Double getBulletSize()
Returns the bullet size, null if unset
-
setBulletColor
public void setBulletColor(Color color)
Sets the bullet color
-
getBulletColor
public Color getBulletColor()
Returns the bullet color
-
setBulletFont
public void setBulletFont(String typeface)
Sets the bullet font
-
getBulletFont
public String getBulletFont()
Returns the bullet font
-
setLineSpacing
public void setLineSpacing(Double lineSpacing)
- Specified by:
setLineSpacingin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getLineSpacing
public Double getLineSpacing()
- Specified by:
getLineSpacingin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
setSpaceBefore
public void setSpaceBefore(Double spaceBefore)
- Specified by:
setSpaceBeforein interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getSpaceBefore
public Double getSpaceBefore()
- Specified by:
getSpaceBeforein interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
setSpaceAfter
public void setSpaceAfter(Double spaceAfter)
- Specified by:
setSpaceAfterin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getSpaceAfter
public Double getSpaceAfter()
- Specified by:
getSpaceAfterin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getDefaultTabSize
public Double getDefaultTabSize()
- Specified by:
getDefaultTabSizein interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getTabStops
public List<? extends TabStop> getTabStops()
- Specified by:
getTabStopsin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
addTabStops
public void addTabStops(double positionInPoints, TabStop.TabStopType tabStopType)- Specified by:
addTabStopsin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
clearTabStops
public void clearTabStops()
- Specified by:
clearTabStopsin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>
-
getPropVal
protected <T extends TextProp> T getPropVal(TextPropCollection props, String propName)
Fetch the value of the given Paragraph related TextProp. Returns null if that TextProp isn't present. If the TextProp isn't present, the value from the appropriate Master Sheet will apply. The propName can be a comma-separated list, in case multiple equivalent values are queried
-
setPropVal
protected void setPropVal(TextPropCollection props, String name, Integer val)
Returns the named TextProp, either by fetching it (if it exists) or adding it (if it didn't)- Parameters:
props- the TextPropCollection to fetch from / add intoname- the name of the TextProp to fetch/addval- the value, null if unset
-
fixLineEndings
protected static void fixLineEndings(List<HSLFTextParagraph> paragraphs)
Check and add linebreaks to text runs leading other paragraphs
-
storeText
protected static void storeText(List<HSLFTextParagraph> paragraphs)
Saves the modified paragraphs/textrun to the records. Also updates the styles to the correct text length.
-
appendText
protected static HSLFTextRun appendText(List<HSLFTextParagraph> paragraphs, String text, boolean newParagraph)
Adds the supplied text onto the end of the TextParagraphs, creating a new RichTextRun for it to sit in.- Parameters:
text- the text string used by this object.
-
setText
public static HSLFTextRun setText(List<HSLFTextParagraph> paragraphs, 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 String getText(List<HSLFTextParagraph> paragraphs)
-
getRawText
public static String getRawText(List<HSLFTextParagraph> paragraphs)
-
toInternalString
protected static String toInternalString(String s)
Returns a new string with line breaks converted into internal ppt representation
-
toExternalString
public static String toExternalString(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 List<List<HSLFTextParagraph>> findTextParagraphs(PPDrawing ppdrawing, HSLFSheet sheet)
For a given PPDrawing, grab all the TextRuns
-
findTextParagraphs
protected static List<HSLFTextParagraph> findTextParagraphs(EscherTextboxWrapper wrapper, HSLFSheet sheet)
Scans through the supplied record array, looking for a TextHeaderAtom followed by one of a TextBytesAtom or a TextCharsAtom. Builds up TextRuns from these- Parameters:
wrapper- an EscherTextboxWrapper
-
findTextParagraphs
protected static List<List<HSLFTextParagraph>> findTextParagraphs(Record[] records)
Scans through the supplied record array, looking for a TextHeaderAtom followed by one of a TextBytesAtom or a TextCharsAtom. Builds up TextRuns from these- Parameters:
records- the records to build from
-
applyHyperlinks
protected static void applyHyperlinks(List<HSLFTextParagraph> paragraphs)
-
applyCharacterStyles
protected static void applyCharacterStyles(List<HSLFTextParagraph> paragraphs, List<TextPropCollection> charStyles)
-
applyParagraphStyles
protected static void applyParagraphStyles(List<HSLFTextParagraph> paragraphs, List<TextPropCollection> paraStyles)
-
applyParagraphIndents
protected static void applyParagraphIndents(List<HSLFTextParagraph> paragraphs, List<IndentProp> paraStyles)
-
getTextboxWrapper
public EscherTextboxWrapper getTextboxWrapper()
-
getColorFromColorIndexStruct
protected static Color getColorFromColorIndexStruct(int rgb, HSLFSheet sheet)
-
setParagraphTextPropVal
public void setParagraphTextPropVal(String propName, 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()
- Specified by:
isHeaderOrFooterin interfaceTextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun>- See Also:
RoundTripHFPlaceholder12
-
-