Class XSLFTextRun

  • All Implemented Interfaces:
    TextRun

    @Beta
    public class XSLFTextRun
    extends Object
    implements TextRun
    Represents a run of text within the containing text body. The run element is the lowest level text separation mechanism within a text body.
    • Method Detail

      • getXmlObject

        @Internal
        public XmlObject getXmlObject()
        Return the text run xmlbeans object. Depending on the type of text run, this can be CTTextField, CTTextLineBreak or usually a CTRegularTextRun
        Returns:
        the xmlbeans object
      • 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.
      • setStrikethrough

        public void setStrikethrough​(boolean strike)
        Specified by:
        setStrikethrough in interface TextRun
      • 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:
        isSubscript in interface TextRun
      • getTextCap

        public TextRun.TextCap getTextCap()
        Specified by:
        getTextCap in interface TextRun
        Returns:
        whether a run of text will be formatted as a superscript text. Default is false.
      • setBold

        public void setBold​(boolean bold)
        Specified by:
        setBold in interface TextRun
      • isBold

        public boolean isBold()
        Specified by:
        isBold in interface TextRun
      • setItalic

        public void setItalic​(boolean italic)
        Specified by:
        setItalic in interface TextRun
      • isItalic

        public boolean isItalic()
        Specified by:
        isItalic in interface TextRun
      • setUnderlined

        public void setUnderlined​(boolean underline)
        Specified by:
        setUnderlined in interface TextRun
      • isUnderlined

        public boolean isUnderlined()
        Specified by:
        isUnderlined in interface TextRun
      • getRPr

        @Internal
        public org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties getRPr​(boolean create)
        Return the character properties
        Parameters:
        create - if true, create an empty character properties object if it doesn't exist
        Returns:
        the character properties or null if create was false and the properties haven't exist