Class HSLFTextParagraph
- All Implemented Interfaces:
Iterable<HSLFTextRun>,TextParagraph<HSLFShape,HSLFTextParagraph, HSLFTextRun>
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.poi.sl.usermodel.TextParagraph
TextParagraph.BulletStyle, TextParagraph.FontAlign, TextParagraph.TextAlign -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HSLFTextShapeprotected TextRulerAtomprotected final List<HSLFTextRun>protected static final POILogger -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTabStops(double positionInPoints, TabStop.TabStopType tabStopType) Set theTabStopcollectionvoidaddTextRun(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) voidRemoves the tabstops of this paragraphs.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 paragraphsReturns the bullet characterReturns the bullet colorReturns the bullet fontReturns the bullet size, null if unsetprotected static ColorgetColorFromColorIndexStruct(int rgb, HSLFSheet sheet) Returns the font alignment that is applied to the paragraph.intprotected intgetIndex()Returns the vertical line spacing that is to be used within a paragraph.protected <T extends TextProp>
TgetPropVal(TextPropCollection props, String propName) Fetch the value of the given Paragraph related TextProp.static StringgetRawText(List<HSLFTextParagraph> paragraphs) Record[]Returns records that make up the list of text paragraphs (there can be misc InteractiveInfo, TxInteractiveInfo and other records)Specifies the right margin of the paragraph.intReturns the type of the text, from the TextHeaderAtom.protected intgetSheet()The amount of vertical white space after the paragraph This may be specified in two different ways, percentage spacing and font point spacing:The amount of vertical white space before the paragraph This may be specified in two different ways, percentage spacing and font point spacing:Numbered List infoGet theTabStops- the list can't be and it's entries shouldn't be modified.static StringgetText(List<HSLFTextParagraph> paragraphs) Returns the alignment that is applied to the paragraph.Fetch the text runs that are contained within this block of textbooleanisBullet()Returns whether this rich text run has bulletsbooleanisDirty()booleanIs this Text Run one from aPPDrawing, or is it one from theSlideListWithText?booleanConvenience method to determine if this text paragraph is part of the slide header or footeriterator()voidsetBullet(boolean flag) Sets whether this rich text run has bulletsvoidSets the bullet charactervoidsetBulletColor(Color color) Sets the bullet colorvoidsetBulletFont(String typeface) Sets the bullet fontvoidsetBulletSize(Double size) Sets the bullet sizevoidsetBulletStyle(Object... styles) Sets the bullet styles.voidsetDirty()marks this paragraph dirty, so its records will be renewed on savevoidSpecifies 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.protected voidsetIndex(int index) Sets the index of the paragraph in the SLWT containervoidsetLeftMargin(Double leftMargin) Specifies the left margin of the paragraph.voidsetLineSpacing(Double lineSpacing) This element specifies the vertical line spacing that is to be used within a paragraph.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) Set the amount of vertical white space that will be present after the paragraph.voidsetSpaceBefore(Double spaceBefore) Set the amount of vertical white space that will be present before the paragraph.voidsetStyleTextProp9Atom(StyleTextProp9Atom styleTextProp9Atom) Numbered List infostatic HSLFTextRunsetText(List<HSLFTextParagraph> paragraphs, String text) Sets (overwrites) the current text.voidSpecifies the alignment that is to be applied to the paragraph.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 StringReturns a new string with line breaks converted into internal ppt representationtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
logger
-
_ruler
-
_runs
-
_parentShape
-
-
Method Details
-
addTextRun
-
getTextRuns
Description copied from interface:TextParagraphFetch the text runs that are contained within this block of text- Specified by:
getTextRunsin interfaceTextParagraph<HSLFShape,HSLFTextParagraph, HSLFTextRun>
-
getParagraphStyle
-
setParagraphStyle
-
supplySheet
Supply the Sheet we belong to, which might have an assigned SlideShow Also passes it on to our child RichTextRuns -
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- Parameters:
index-
-
getRunType
public int getRunType()Returns the type of the text, from the TextHeaderAtom. Possible values can be seen from TextHeaderAtom- See Also:
-
setRunType
public void setRunType(int runType) -
isDrawingBased
public boolean isDrawingBased()Is this Text Run one from aPPDrawing, or is it one from theSlideListWithText? -
getTextRuler
-
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
Numbered List info -
getStyleTextProp9Atom
Numbered List info -
iterator
- Specified by:
iteratorin interfaceIterable<HSLFTextRun>
-
getLeftMargin
- Specified by:
getLeftMarginin interfaceTextParagraph<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Returns:
- the left margin (in points) of the paragraph or null, if unset
-
setLeftMargin
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<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Parameters:
leftMargin- the left margin (in points) or null to unset
-
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<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Returns:
- the right margin (in points) of the paragraph or null, if unset
-
setRightMargin
- Specified by:
setRightMarginin interfaceTextParagraph<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Parameters:
rightMargin- the right margin (in points) of the paragraph
-
getIndent
- Specified by:
getIndentin interfaceTextParagraph<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Returns:
- the indent (in points) applied to the first line of text in the paragraph. or null, if unset
-
setIndent
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<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Parameters:
indent- the indent (in points) applied to the first line of text in the paragraph
-
getDefaultFontFamily
- Specified by:
getDefaultFontFamilyin interfaceTextParagraph<HSLFShape,HSLFTextParagraph, HSLFTextRun>
-
getDefaultFontSize
- Specified by:
getDefaultFontSizein interfaceTextParagraph<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Returns:
- the default font size, in case its not set in the textrun or null, if unset
-
setTextAlign
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<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Parameters:
align- text align
-
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<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Returns:
- alignment that is applied to the paragraph
-
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<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Returns:
- alignment that is applied to the paragraph
-
getAutoNumberingScheme
-
getAutoNumberingStartAt
-
getBulletStyle
- Specified by:
getBulletStylein interfaceTextParagraph<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Returns:
- the bullet style of the paragraph, if
nullthen no bullets are used
-
setBulletStyle
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<HSLFShape,HSLFTextParagraph, HSLFTextRun>
-
getParentShape
- Specified by:
getParentShapein interfaceTextParagraph<HSLFShape,HSLFTextParagraph, HSLFTextRun>
-
setParentShape
-
getIndentLevel
public int getIndentLevel()- Specified by:
getIndentLevelin 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: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<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
Sets the bullet character -
getBulletChar
Returns the bullet character -
setBulletSize
Sets the bullet size -
getBulletSize
Returns the bullet size, null if unset -
setBulletColor
Sets the bullet color -
getBulletColor
Returns the bullet color -
setBulletFont
Sets the bullet font -
getBulletFont
Returns the bullet font -
setLineSpacing
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<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Parameters:
lineSpacing- the vertical line spacing
-
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<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Returns:
- the vertical line spacing or null, if unset
-
setSpaceBefore
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<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Parameters:
spaceBefore- the vertical white space before the paragraph, null to unset
-
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<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Returns:
- the vertical white space before the paragraph, or null if unset
-
setSpaceAfter
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<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Parameters:
spaceAfter- the vertical white space after the paragraph, null to unset
-
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<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Returns:
- the vertical white space after the paragraph or null, if unset
-
getDefaultTabSize
- Specified by:
getDefaultTabSizein interfaceTextParagraph<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Returns:
- the default size for a tab character within this paragraph in points, null if unset
-
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<HSLFShape,HSLFTextParagraph, HSLFTextRun> - Returns:
- the tabstop collection or
nullif no tabstops are defined
-
addTabStops
Description copied from interface:TextParagraphSet theTabStopcollection- Specified by:
addTabStopsin interfaceTextParagraph<HSLFShape,HSLFTextParagraph, HSLFTextRun>
-
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<HSLFShape,HSLFTextParagraph, HSLFTextRun>
-
getPropVal
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
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
Check and add linebreaks to text runs leading other paragraphs- Parameters:
paragraphs-
-
storeText
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
Sets (overwrites) the current text. Uses the properties of the first paragraph / textrun- Parameters:
text- the text string used by this object.
-
getText
-
getRawText
-
toString
-
toInternalString
Returns a new string with line breaks converted into internal ppt representation -
toExternalString
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
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
-
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
-
getColorFromColorIndexStruct
-
setParagraphTextPropVal
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()
-