Underline Class

Defines the Underline Class.When the object is serialized out as xml, its qualified name is w:u.

Inheritance Hierarchy

System.Object
  DocumentFormat.OpenXml.OpenXmlElement
    DocumentFormat.OpenXml.OpenXmlLeafElement
      DocumentFormat.OpenXml.Wordprocessing.Underline

Namespace:  DocumentFormat.OpenXml.Wordprocessing
Assembly:  DocumentFormat.OpenXml (in DocumentFormat.OpenXml.dll)

Syntax

'Declaration
Public Class Underline _
    Inherits OpenXmlLeafElement
'Usage
Dim instance As Underline
public class Underline : OpenXmlLeafElement

Remarks

[ISO/IEC 29500-1 1st Edition]

17.3.2.40 u (Underline)

This element specifies that the contents of this run should be displayed along with an underline appearing directly below the character height (less all spacing above and below the characters on the line).

If this element is not present, the default value is to leave the formatting applied at previous level in the style hierarchy. If this element is never applied in the style hierarchy, then an underline shall not be applied to the contents of this run.

[Example: Consider a run of text which must have a double underline explicitly turned on for the contents of the run. This constraint is specified using the following WordprocessingML:

<w:rPr>
<w:u w:val="double"/>
</w:rPr>

This run explicitly declares an underline using the u property. The val of that underline is double, so the style of the underline on this run must be a double line. end example]

Parent Elements

rPr (§17.3.1.29); rPr (§17.3.1.30); rPr (§17.5.2.28); rPr (§17.9.25); rPr (§17.7.9.1); rPr (§17.7.5.4); rPr (§17.3.2.28); rPr (§17.5.2.27); rPr (§17.7.6.2); rPr (§17.3.2.27)

Attributes

Description

color (Underline Color)

Specifies the color for the underlining on this run.

This color can either be presented as a hex value (in RRGGBB format), or auto to allow a consumer to automatically determine the underline color as appropriate.

If the underline specifies the use of a theme color via the themeColor attribute, then this value is superseded by the theme color value.

[Example: Consider a run color with value auto, as follows:

<w:rPr>
  <w:u … w:color="auto" />
</w:rPr>

This color therefore can be automatically be modified by a consumer as appropriate, for example, in order to ensure that the underline can be distinguished against the page's background color. end example]

The possible values for this attribute are defined by the ST_HexColor simple type (§17.18.38).

themeColor (Underline Theme Color)

Specifies a theme color which should be applied to the current underline.

The specified theme color is a reference to one of the predefined theme colors, located in the document's Theme part, which allows for color information to be set centrally in the document.

If the themeColor attribute is specified, then the color attribute is ignored for this underline.

[Example: Consider an underlined run of text whose underline should be displayed using the accent3 theme color from the document’s Theme part. This requirement would be specified as follows in the resulting WordprocessingML:

<w:rPr>
  <w:u … w:themeColor="accent3" />
</w:rPr>

The themeColor attribute specifies that the underline must use the accent3 theme color. end example]

The possible values for this attribute are defined by the ST_ThemeColor simple type (§17.18.97).

themeShade (Underline Theme Color Shade)

Specifies the shade value applied to the supplied theme color (if any) for this underline.

If the themeShade is supplied, then it is applied to the RGB value of the theme color to determine the final color applied to this underline.

The themeShade value is stored as a hex encoding of the shade value (from 0 to 255) applied to the current border.

[Example: Consider a shade of 40% applied to a underline in a document. This shade is calculated as follows:

The resulting themeShade value in the file format would be 66. end example]

Given an RGB color defined as three hex values in RRGGBB format, the shade is applied as follows:

  • Convert the color to the HSL color format (values from 0 to 1)

  • Modify the luminance factor as follows:

  • Convert the resultant HSL color to RGB

[Example: Consider a document with a background using the accent2 theme color, whose RGB value (in RRGGBB hex format) is C0504D.

The equivalent HSL color value would be.

Applying the shade formula with a shade percentage of 75% to the luminance, we get:

Taking the resulting HSL color value of and converting back to RGB, we get 943634.

This transformed value can be seen in the resulting underline's color attribute:

<w:u w:color="943634" w:themeColor="accent2" w:themeShade="BF" />

end example]

The possible values for this attribute are defined by the ST_UcharHexNumber simple type (§17.18.98).

themeTint (Underline Theme Color Tint)

Specifies the tint value applied to the supplied theme color (if any) for this underline's contents.

If the themeTint is supplied, then it is applied to the RGB value of the theme color to determine the final color applied to this run.

The themeTint value is stored as a hex encoding of the tint value (from 0 to 255) applied to the current border.

[Example: Consider a tint of 60% applied to an underline in a document. This tint is calculated as follows:

The resulting themeTint value in the file format would be 99. end example]

Given an RGB color defined as three hex values in RRGGBB format, the shade is applied as follows:

  • Convert the color to the HSL color format (values from 0 to 1)

  • Modify the luminance factor as follows:

  • Convert the resultant HSL color to RGB

[Example: Consider a document with a background using the accent2 theme color, whose RGB value (in RRGGBB hex format) is 4F81BD.

The equivalent HSL color value would be.

Applying the tint formula with a tint percentage of 60% to the luminance, we get:

Taking the resulting HSL color value of and converting back to RGB, we get 95B3D7.

This transformed value can be seen in the resulting underline formatting's WordprocessingML color attribute:

<w:u … w:color="95B3D7" w:themeColor="accent2" w:themeTint="99" />

end example]

The possible values for this attribute are defined by the ST_UcharHexNumber simple type (§17.18.98).

val (Underline Style)

Specifies the pattern which shall be used to create the underline applied beneath the text in this run.

Each of these possible patterns are shown in the simple type referenced below.

[Example: Consider a run of text which must have a double underline explicitly turned on for the contents of the run. This constraint is specified using the following WordprocessingML:

<w:rPr>
<w:u w:val="double"/>
</w:rPr>

The val of the underline on this run is double, so the style of the underline on this run must be a double line. end example]

The possible values for this attribute are defined by the ST_Underline simple type (§17.18.99).

[Note: The W3C XML Schema definition of this element’s content model (CT_Underline) is located in §A.1. end note]

© ISO/IEC29500: 2008.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Underline Members

DocumentFormat.OpenXml.Wordprocessing Namespace