Package org.apache.poi.xslf.usermodel
Class XSLFTextRun
- java.lang.Object
-
- org.apache.poi.xslf.usermodel.XSLFTextRun
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.poi.sl.usermodel.TextRun
TextRun.FieldType, TextRun.TextCap
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description XSLFHyperlinkcreateHyperlink()Creates a new hyperlink and assigns it to this text run.doublegetCharacterSpacing()TextRun.FieldTypegetFieldType()Experimental method to determine the field type, e.g.PaintStylegetFontColor()Returns the font color.java.lang.StringgetFontFamily()Get the font family - convenience method forTextRun.getFontInfo(FontGroup)java.lang.StringgetFontFamily(FontGroup fontGroup)Get the font family - convenience method forTextRun.getFontInfo(FontGroup)FontInfogetFontInfo(FontGroup fontGroup)Get the font info for the given font groupjava.lang.DoublegetFontSize()Returns the font size which is either set directly on this text run or given from the slide layoutXSLFHyperlinkgetHyperlink()Return the associated hyperlinkbytegetPitchAndFamily()java.lang.StringgetRawText()TextRun.TextCapgetTextCap()XmlObjectgetXmlObject()Return the text run xmlbeans object.booleanisBold()booleanisItalic()booleanisStrikethrough()booleanisSubscript()booleanisSuperscript()booleanisUnderlined()voidsetBaselineOffset(double baselineOffset)Set the baseline for both the superscript and subscript fonts.voidsetBold(boolean bold)Sets the bold statevoidsetCharacterSpacing(double spc)Set the spacing between characters within a text run.voidsetFontColor(java.awt.Color color)Sets the (solid) font color - convenience functionvoidsetFontColor(PaintStyle color)Sets the font colorvoidsetFontFamily(java.lang.String typeface)Specifies the typeface, or name of the font that is to be used for this text run - convenience method for callingTextRun.setFontInfo(FontInfo, FontGroup)with just a font namevoidsetFontFamily(java.lang.String typeface, FontGroup fontGroup)Specifies the typeface, or name of the font that is to be used for this text run - convenience method for callingTextRun.setFontInfo(FontInfo, FontGroup)with just a font namevoidsetFontInfo(FontInfo fontInfo, FontGroup fontGroup)Specifies the font to be used for this text run.voidsetFontSize(java.lang.Double fontSize)Sets the font size directly on this text run, if null is given, the font size defaults to the values given from the slide layoutvoidsetItalic(boolean italic)Sets the italic statevoidsetStrikethrough(boolean strike)Sets the strikethrough statevoidsetSubscript(boolean flag)Set whether the text in this run is formatted as subscript.voidsetSuperscript(boolean flag)Set whether the text in this run is formatted as superscript.voidsetText(java.lang.String text)voidsetUnderlined(boolean underline)Sets the underlined statejava.lang.StringtoString()
-
-
-
Method Detail
-
getRawText
public java.lang.String getRawText()
- Specified by:
getRawTextin interfaceTextRun
-
getXmlObject
public XmlObject getXmlObject()
Return the text run xmlbeans object. Depending on the type of text run, this can beCTTextField,CTTextLineBreakor usually aCTRegularTextRun- Returns:
- the xmlbeans object
-
setFontColor
public void setFontColor(java.awt.Color color)
Description copied from interface:TextRunSets the (solid) font color - convenience function- Specified by:
setFontColorin interfaceTextRun- Parameters:
color- the color
-
setFontColor
public void setFontColor(PaintStyle color)
Description copied from interface:TextRunSets the font color- Specified by:
setFontColorin interfaceTextRun- Parameters:
color- the color- See Also:
DrawPaint.createSolidPaint(Color)
-
getFontColor
public PaintStyle getFontColor()
Description copied from interface:TextRunReturns the font color. This usually returns aPaintStyle.SolidPaint, but but also other classes are possible- Specified by:
getFontColorin interfaceTextRun- Returns:
- the font color/paint
- See Also:
DrawPaint.getPaint(java.awt.Graphics2D, PaintStyle),PaintStyle.SolidPaint.getSolidColor(),DrawPaint.applyColorTransform(ColorStyle)
-
setFontSize
public void setFontSize(java.lang.Double fontSize)
Description copied from interface:TextRunSets the font size directly on this text run, if null is given, the font size defaults to the values given from the slide layout- Specified by:
setFontSizein interfaceTextRun- Parameters:
fontSize- font size in points, if null the underlying fontsize will be unset
-
getFontSize
public java.lang.Double getFontSize()
Description copied from interface:TextRunReturns the font size which is either set directly on this text run or given from the slide layout- Specified by:
getFontSizein interfaceTextRun- Returns:
- font size in points or null if font size is not set.
-
getCharacterSpacing
public double getCharacterSpacing()
- Returns:
- the spacing between characters within a text run, If this attribute is omitted than a value of 0 or no adjustment is assumed.
-
setCharacterSpacing
public void setCharacterSpacing(double spc)
Set the spacing between characters within a text run.The spacing is specified in points. Positive values will cause the text to expand, negative values to condense.
- Parameters:
spc- character spacing in points.
-
setFontFamily
public void setFontFamily(java.lang.String typeface)
Description copied from interface:TextRunSpecifies the typeface, or name of the font that is to be used for this text run - convenience method for callingTextRun.setFontInfo(FontInfo, FontGroup)with just a font name- Specified by:
setFontFamilyin interfaceTextRun- Parameters:
typeface- the font to apply to this text run. The value ofnullremoves the run specific font setting, so the default setting is activated again.
-
setFontFamily
public void setFontFamily(java.lang.String typeface, FontGroup fontGroup)Description copied from interface:TextRunSpecifies the typeface, or name of the font that is to be used for this text run - convenience method for callingTextRun.setFontInfo(FontInfo, FontGroup)with just a font name- Specified by:
setFontFamilyin interfaceTextRun- Parameters:
typeface- the font to apply to this text run. The value ofnullremoves the run specific font setting, so the default setting is activated again.fontGroup- the font group, i.e. the range of glpyhs to be covered. ifnull, the font group matching the first character will be returned
-
setFontInfo
public void setFontInfo(FontInfo fontInfo, FontGroup fontGroup)
Description copied from interface:TextRunSpecifies the font to be used for this text run.- Specified by:
setFontInfoin interfaceTextRun- Parameters:
fontInfo- the font to apply to this text run. The value ofnullremoves the run specific font setting, so the default setting is activated again.fontGroup- the font group, i.e. the range of glpyhs to be covered. defaults to latin, ifnull.
-
getFontFamily
public java.lang.String getFontFamily()
Description copied from interface:TextRunGet the font family - convenience method forTextRun.getFontInfo(FontGroup)- Specified by:
getFontFamilyin interfaceTextRun- Returns:
- font family or null if not set
-
getFontFamily
public java.lang.String getFontFamily(FontGroup fontGroup)
Description copied from interface:TextRunGet the font family - convenience method forTextRun.getFontInfo(FontGroup)- Specified by:
getFontFamilyin interfaceTextRun- Parameters:
fontGroup- the font group, i.e. the range of glpyhs to be covered. ifnull, the font group matching the first character will be returned- Returns:
- font family or null if not set
-
getFontInfo
public FontInfo getFontInfo(FontGroup fontGroup)
Description copied from interface:TextRunGet the font info for the given font group- Specified by:
getFontInfoin interfaceTextRun- Parameters:
fontGroup- the font group, i.e. the range of glpyhs to be covered. ifnull, the font group matching the first character will be returned- Returns:
- font info or
nullif not set
-
getPitchAndFamily
public byte getPitchAndFamily()
- Specified by:
getPitchAndFamilyin interfaceTextRun- Returns:
- the pitch and family id or -1 if not applicable
-
setStrikethrough
public void setStrikethrough(boolean strike)
Description copied from interface:TextRunSets the strikethrough state- Specified by:
setStrikethroughin interfaceTextRun- Parameters:
strike- set to true for stroked text, false for no stroking
-
isStrikethrough
public boolean isStrikethrough()
- Specified by:
isStrikethroughin interfaceTextRun- Returns:
- true, if text is stroked
-
isSuperscript
public boolean isSuperscript()
- Specified by:
isSuperscriptin interfaceTextRun- Returns:
- true, if text is super scripted
-
setBaselineOffset
public void setBaselineOffset(double baselineOffset)
Set the baseline for both the superscript and subscript fonts.The size is specified using a percentage. Positive values indicate superscript, negative values indicate subscript.
-
setSuperscript
public void setSuperscript(boolean flag)
Set whether the text in this run is formatted as superscript. Default base line offset is 30%- See Also:
setBaselineOffset(double)
-
setSubscript
public void setSubscript(boolean flag)
Set whether the text in this run is formatted as subscript. Default base line offset is -25%.- See Also:
setBaselineOffset(double)
-
isSubscript
public boolean isSubscript()
- Specified by:
isSubscriptin interfaceTextRun- Returns:
- true, if text is sub scripted
-
getTextCap
public TextRun.TextCap getTextCap()
- Specified by:
getTextCapin interfaceTextRun- Returns:
- whether a run of text will be formatted as a superscript text. Default is false.
-
setBold
public void setBold(boolean bold)
Description copied from interface:TextRunSets the bold state
-
isBold
public boolean isBold()
-
setItalic
public void setItalic(boolean italic)
Description copied from interface:TextRunSets the italic state
-
isItalic
public boolean isItalic()
-
setUnderlined
public void setUnderlined(boolean underline)
Description copied from interface:TextRunSets the underlined state- Specified by:
setUnderlinedin interfaceTextRun- Parameters:
underline- set to true for underlined text, false for no underlining
-
isUnderlined
public boolean isUnderlined()
- Specified by:
isUnderlinedin interfaceTextRun- Returns:
- true, if text is underlined
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
createHyperlink
public XSLFHyperlink createHyperlink()
Description copied from interface:TextRunCreates a new hyperlink and assigns it to this text run. If the text run has already a hyperlink assigned, return it instead- Specified by:
createHyperlinkin interfaceTextRun- Returns:
- the associated hyperlink
-
getHyperlink
public XSLFHyperlink getHyperlink()
Description copied from interface:TextRunReturn the associated hyperlink- Specified by:
getHyperlinkin interfaceTextRun- Returns:
- the associated hyperlink or null if no hyperlink was set
-
getFieldType
public TextRun.FieldType getFieldType()
Description copied from interface:TextRunExperimental method to determine the field type, e.g. slide number- Specified by:
getFieldTypein interfaceTextRun- Returns:
- the field type or
nullif text run is not a field
-
-