org.apache.poi.hslf.usermodel

## Class HSLFTextRun

- java.lang.Object
- - org.apache.poi.hslf.usermodel.HSLFTextRun

- All Implemented Interfaces:
    TextRun

      public final class HSLFTextRun
      extends java.lang.Object
      implements TextRun

  Represents a run of text, all with the same style

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.poi.sl.usermodel.TextRun

      `TextRun.FieldType, TextRun.TextCap`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HSLFTextRun(HSLFTextParagraph parentParagraph)` Create a new wrapper around a rich text string

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `HSLFHyperlink` | `createHyperlink()` Creates a new hyperlink and assigns it to this text run.
    `TextPropCollection` | `getCharacterStyle()`
    `TextRun.FieldType` | `getFieldType()` Experimental method to determine the field type, e.g.
    `PaintStyle.SolidPaint` | `getFontColor()` Returns the font color.
    `java.lang.String` | `getFontFamily()` Get the font family - convenience method for `TextRun.getFontInfo(FontGroup)`
    `java.lang.String` | `getFontFamily(FontGroup fontGroup)` Get the font family - convenience method for `TextRun.getFontInfo(FontGroup)`
    `int` | `getFontIndex()` Gets the font index
    `HSLFFontInfo` | `getFontInfo(FontGroup fontGroup)` Get the font info for the given font group
    `java.lang.Double` | `getFontSize()` Returns the font size which is either set directly on this text run or given from the slide layout
    `HSLFHyperlink` | `getHyperlink()` Return the associated hyperlink
    `int` | `getLength()` Get the length of the text
    `HSLFTextParagraph` | `getParagraph()`
    `byte` | `getPitchAndFamily()`
    `java.lang.String` | `getRawText()` Fetch the text, in raw storage form
    `int` | `getSuperscript()` Gets the subscript/superscript option
    `TextRun.TextCap` | `getTextCap()`
    `HSLFTextParagraph` | `getTextParagraph()`
    `boolean` | `isBold()`
    `boolean` | `isEmbossed()` Is this text embossed?
    `boolean` | `isItalic()`
    `boolean` | `isShadowed()` Does the text have a shadow?
    `boolean` | `isStrikethrough()`
    `boolean` | `isSubscript()`
    `boolean` | `isSuperscript()`
    `boolean` | `isUnderlined()`
    `void` | `setBold(boolean bold)` Sets the bold state
    `void` | `setCharacterStyle(TextPropCollection characterStyle)`
    `void` | `setCharTextPropVal(java.lang.String propName, java.lang.Integer val)` Sets the value of the given Paragraph TextProp, add if required
    `void` | `setEmbossed(boolean flag)` Is this text embossed?
    `void` | `setFontColor(java.awt.Color color)` Sets the (solid) font color - convenience function
    `void` | `setFontColor(int bgr)` Sets color of the text, as a int bgr.
    `void` | `setFontColor(PaintStyle color)` Sets the font color
    `void` | `setFontFamily(java.lang.String typeface)` Specifies the typeface, or name of the font that is to be used for this text run - convenience method for calling `TextRun.setFontInfo(FontInfo, FontGroup)` with just a font name
    `void` | `setFontFamily(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 calling `TextRun.setFontInfo(FontInfo, FontGroup)` with just a font name
    `void` | `setFontIndex(int idx)` Sets the font index
    `void` | `setFontInfo(FontInfo fontInfo, FontGroup fontGroup)` Specifies the font to be used for this text run.
    `void` | `setFontSize(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 layout
    `void` | `setItalic(boolean italic)` Sets the italic state
    `void` | `setShadowed(boolean flag)` Does the text have a shadow?
    `void` | `setStrikethrough(boolean flag)` Sets the strikethrough state
    `void` | `setSuperscript(int val)` Sets the subscript/superscript option
    `void` | `setText(java.lang.String text)` Change the text
    `void` | `setUnderlined(boolean underlined)` Sets the underlined state
    `void` | `updateSheet()` Supply the SlideShow we belong to

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HSLFTextRun

          public HSLFTextRun(HSLFTextParagraph parentParagraph)

      Create a new wrapper around a rich text string
      Parameters:
        `parentParagraph` - the parent paragraph

  - ### Method Detail

    - #### getCharacterStyle

          public TextPropCollection getCharacterStyle()

    - #### setCharacterStyle

          public void setCharacterStyle(TextPropCollection characterStyle)

    - #### updateSheet

          public void updateSheet()

      Supply the SlideShow we belong to

    - #### getLength

          public int getLength()

      Get the length of the text

    - #### getRawText

          public java.lang.String getRawText()

      Fetch the text, in raw storage form
      Specified by:
        `getRawText` in interface `TextRun`

    - #### setText

          public void setText(java.lang.String text)

      Change the text
      Specified by:
        `setText` in interface `TextRun`

    - #### setCharTextPropVal

          public void setCharTextPropVal(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 TextProp
        `val` - The value to set for the TextProp

    - #### isBold

          public boolean isBold()

      Specified by:
        `isBold` in interface `TextRun`
      Returns:
        true, if text is bold

    - #### setBold

          public void setBold(boolean bold)

      Description copied from interface: `TextRun`
      Sets the bold state
      Specified by:
        `setBold` in interface `TextRun`
      Parameters:
        `bold` - set to true for bold text, false for normal weight

    - #### isItalic

          public boolean isItalic()

      Specified by:
        `isItalic` in interface `TextRun`
      Returns:
        true, if text is italic

    - #### setItalic

          public void setItalic(boolean italic)

      Description copied from interface: `TextRun`
      Sets the italic state
      Specified by:
        `setItalic` in interface `TextRun`
      Parameters:
        `italic` - set to true for italic text, false for non-italics

    - #### isUnderlined

          public boolean isUnderlined()

      Specified by:
        `isUnderlined` in interface `TextRun`
      Returns:
        true, if text is underlined

    - #### setUnderlined

          public void setUnderlined(boolean underlined)

      Description copied from interface: `TextRun`
      Sets the underlined state
      Specified by:
        `setUnderlined` in interface `TextRun`
      Parameters:
        `underlined` - set to true for underlined text, false for no underlining

    - #### isShadowed

          public boolean isShadowed()

      Does the text have a shadow?

    - #### setShadowed

          public void setShadowed(boolean flag)

      Does the text have a shadow?

    - #### isEmbossed

          public boolean isEmbossed()

      Is this text embossed?

    - #### setEmbossed

          public void setEmbossed(boolean flag)

      Is this text embossed?

    - #### isStrikethrough

          public boolean isStrikethrough()

      Specified by:
        `isStrikethrough` in interface `TextRun`
      Returns:
        true, if text is stroked

    - #### setStrikethrough

          public void setStrikethrough(boolean flag)

      Description copied from interface: `TextRun`
      Sets the strikethrough state
      Specified by:
        `setStrikethrough` in interface `TextRun`
      Parameters:
        `flag` - set to true for stroked text, false for no stroking

    - #### getSuperscript

          public int getSuperscript()

      Gets the subscript/superscript option
      Returns:
        the percentage of the font size. If the value is positive, it is superscript, otherwise it is subscript

    - #### setSuperscript

          public void setSuperscript(int val)

      Sets the subscript/superscript option
      Parameters:
        `val` - the percentage of the font size. If the value is positive, it is superscript, otherwise it is subscript

    - #### getFontSize

          public java.lang.Double getFontSize()

      Description copied from interface: `TextRun`
      Returns the font size which is either set directly on this text run or given from the slide layout
      Specified by:
        `getFontSize` in interface `TextRun`
      Returns:
        font size in points or null if font size is not set.

    - #### setFontSize

          public void setFontSize(java.lang.Double fontSize)

      Description copied from interface: `TextRun`
      Sets 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:
        `setFontSize` in interface `TextRun`
      Parameters:
        `fontSize` - font size in points, if null the underlying fontsize will be unset

    - #### getFontIndex

          public int getFontIndex()

      Gets the font index

    - #### setFontIndex

          public void setFontIndex(int idx)

      Sets the font index

    - #### setFontFamily

          public void setFontFamily(java.lang.String typeface)

      Description copied from interface: `TextRun`
      Specifies the typeface, or name of the font that is to be used for this text run - convenience method for calling `TextRun.setFontInfo(FontInfo, FontGroup)` with just a font name
      Specified by:
        `setFontFamily` in interface `TextRun`
      Parameters:
        `typeface` - the font to apply to this text run. The value of `null` removes 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: `TextRun`
      Specifies the typeface, or name of the font that is to be used for this text run - convenience method for calling `TextRun.setFontInfo(FontInfo, FontGroup)` with just a font name
      Specified by:
        `setFontFamily` in interface `TextRun`
      Parameters:
        `typeface` - the font to apply to this text run. The value of `null` removes 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. if `null`, the font group matching the first character will be returned

    - #### setFontInfo

          public void setFontInfo(FontInfo fontInfo,
                                  FontGroup fontGroup)

      Description copied from interface: `TextRun`
      Specifies the font to be used for this text run.
      Specified by:
        `setFontInfo` in interface `TextRun`
      Parameters:
        `fontInfo` - the font to apply to this text run. The value of `null` removes 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, if `null`.

    - #### getFontFamily

          public java.lang.String getFontFamily()

      Description copied from interface: `TextRun`
      Get the font family - convenience method for `TextRun.getFontInfo(FontGroup)`
      Specified by:
        `getFontFamily` in interface `TextRun`
      Returns:
        font family or null if not set

    - #### getFontFamily

          public java.lang.String getFontFamily(FontGroup fontGroup)

      Description copied from interface: `TextRun`
      Get the font family - convenience method for `TextRun.getFontInfo(FontGroup)`
      Specified by:
        `getFontFamily` in interface `TextRun`
      Parameters:
        `fontGroup` - the font group, i.e. the range of glpyhs to be covered. if `null`, the font group matching the first character will be returned
      Returns:
        font family or null if not set

    - #### getFontInfo

          public HSLFFontInfo getFontInfo(FontGroup fontGroup)

      Description copied from interface: `TextRun`
      Get the font info for the given font group
      Specified by:
        `getFontInfo` in interface `TextRun`
      Parameters:
        `fontGroup` - the font group, i.e. the range of glpyhs to be covered. if `null`, the font group matching the first character will be returned
      Returns:
        font info or `null` if not set

    - #### getFontColor

          public PaintStyle.SolidPaint getFontColor()

      Description copied from interface: `TextRun`
      Returns the font color. This usually returns a `PaintStyle.SolidPaint`, but but also other classes are possible
      Specified by:
        `getFontColor` in interface `TextRun`
      Returns:
        font color as PaintStyle
      See Also:
        `DrawPaint.getPaint(java.awt.Graphics2D, PaintStyle)`, `PaintStyle.SolidPaint.getSolidColor()`, `DrawPaint.applyColorTransform(ColorStyle)`

    - #### setFontColor

          public void setFontColor(int bgr)

      Sets color of the text, as a int bgr. (PowerPoint stores as BlueGreenRed, not the more usual RedGreenBlue)
      See Also:
        `Color`

    - #### setFontColor

          public void setFontColor(java.awt.Color color)

      Description copied from interface: `TextRun`
      Sets the (solid) font color - convenience function
      Specified by:
        `setFontColor` in interface `TextRun`
      Parameters:
        `color` - the color

    - #### setFontColor

          public void setFontColor(PaintStyle color)

      Description copied from interface: `TextRun`
      Sets the font color
      Specified by:
        `setFontColor` in interface `TextRun`
      Parameters:
        `color` - the color
      See Also:
        `DrawPaint.createSolidPaint(Color)`

    - #### getTextParagraph

          public HSLFTextParagraph getTextParagraph()

    - #### getTextCap

          public TextRun.TextCap getTextCap()

      Specified by:
        `getTextCap` in interface `TextRun`

    - #### isSubscript

          public boolean isSubscript()

      Specified by:
        `isSubscript` in interface `TextRun`
      Returns:
        true, if text is sub scripted

    - #### isSuperscript

          public boolean isSuperscript()

      Specified by:
        `isSuperscript` in interface `TextRun`
      Returns:
        true, if text is super scripted

    - #### getPitchAndFamily

          public byte getPitchAndFamily()

      Specified by:
        `getPitchAndFamily` in interface `TextRun`
      Returns:
        the pitch and family id or -1 if not applicable

    - #### getHyperlink

          public HSLFHyperlink getHyperlink()

      Description copied from interface: `TextRun`
      Return the associated hyperlink
      Specified by:
        `getHyperlink` in interface `TextRun`
      Returns:
        the associated hyperlink or null if no hyperlink was set

    - #### createHyperlink

          public HSLFHyperlink createHyperlink()

      Description copied from interface: `TextRun`
      Creates a new hyperlink and assigns it to this text run. If the text run has already a hyperlink assigned, return it instead
      Specified by:
        `createHyperlink` in interface `TextRun`
      Returns:
        the associated hyperlink

    - #### getFieldType

          public TextRun.FieldType getFieldType()

      Description copied from interface: `TextRun`
      Experimental method to determine the field type, e.g. slide number
      Specified by:
        `getFieldType` in interface `TextRun`
      Returns:
        the field type or `null` if text run is not a field

    - #### getParagraph

          public HSLFTextParagraph getParagraph()

      Specified by:
        `getParagraph` in interface `TextRun`
      Returns:
        the paragraph which contains this TextRun

Copyright 2020 The Apache Software Foundation or its licensors, as applicable.