|
| 1 | + |
| 2 | +Run underline |
| 3 | +============= |
| 4 | + |
| 5 | +Text in a Word document can be underlined in a variety of styles. |
| 6 | + |
| 7 | + |
| 8 | +Protocol |
| 9 | +-------- |
| 10 | + |
| 11 | +The call protocol for underline is overloaded such that it works like |
| 12 | +``.bold`` and ``.italic`` for single underline, but also allows an enumerated |
| 13 | +value to be assigned to specify more sophisticated underlining such as |
| 14 | +dashed, wavy, and double-underline:: |
| 15 | + |
| 16 | + >>> run = paragraph.add_run() |
| 17 | + >>> run.underline |
| 18 | + None |
| 19 | + >>> run.underline = True |
| 20 | + >>> run.underline |
| 21 | + True |
| 22 | + >>> run.underline = WD_UNDERLINE.SINGLE |
| 23 | + >>> run.underline |
| 24 | + True |
| 25 | + >>> run.underline = WD_UNDERLINE.DOUBLE |
| 26 | + >>> str(run.underline) |
| 27 | + DOUBLE (3) |
| 28 | + >>> run.underline = False |
| 29 | + >>> run.underline |
| 30 | + False |
| 31 | + >>> run.underline = WD_UNDERLINE.NONE |
| 32 | + >>> run.underline |
| 33 | + False |
| 34 | + >>> run.underline = None |
| 35 | + >>> run.underline |
| 36 | + None |
| 37 | + |
| 38 | + |
| 39 | +Enumerations |
| 40 | +------------ |
| 41 | + |
| 42 | +* `WdUnderline Enumeration on MSDN`_ |
| 43 | + |
| 44 | +.. _WdUnderline Enumeration on MSDN: |
| 45 | + http://msdn.microsoft.com/en-us/library/office/ff822388(v=office.15).aspx |
| 46 | + |
| 47 | + |
| 48 | +Specimen XML |
| 49 | +------------ |
| 50 | + |
| 51 | +.. highlight:: xml |
| 52 | + |
| 53 | +Baseline run:: |
| 54 | + |
| 55 | + <w:r> |
| 56 | + <w:t>underlining determined by inheritance</w:t> |
| 57 | + </w:r> |
| 58 | + |
| 59 | +Single underline:: |
| 60 | + |
| 61 | + <w:r> |
| 62 | + <w:rPr> |
| 63 | + <w:u w:val="single"/> |
| 64 | + </w:rPr> |
| 65 | + <w:t>single underlined</w:t> |
| 66 | + </w:r> |
| 67 | + |
| 68 | +Double underline:: |
| 69 | + |
| 70 | + <w:r> |
| 71 | + <w:rPr> |
| 72 | + <w:u w:val="double"/> |
| 73 | + </w:rPr> |
| 74 | + <w:t>single underlined</w:t> |
| 75 | + </w:r> |
| 76 | + |
| 77 | +Directly-applied no-underline, overrides inherited value:: |
| 78 | + |
| 79 | + <w:r> |
| 80 | + <w:rPr> |
| 81 | + <w:u w:val="none"/> |
| 82 | + </w:rPr> |
| 83 | + <w:t>not underlined</w:t> |
| 84 | + </w:r> |
| 85 | + |
| 86 | + |
| 87 | +Schema excerpt |
| 88 | +-------------- |
| 89 | + |
| 90 | +.. highlight:: xml |
| 91 | + |
| 92 | +:: |
| 93 | + |
| 94 | + <xsd:complexType name="CT_R"> <!-- flattened for readibility --> |
| 95 | + <xsd:sequence> |
| 96 | + <xsd:element name="rPr" type="CT_RPr" minOccurs="0"/> |
| 97 | + <xsd:group ref="EG_RunInnerContent" minOccurs="0" maxOccurs="unbounded"/> |
| 98 | + </xsd:sequence> |
| 99 | + <xsd:attribute name="rsidRPr" type="ST_LongHexNumber"/> |
| 100 | + <xsd:attribute name="rsidDel" type="ST_LongHexNumber"/> |
| 101 | + <xsd:attribute name="rsidR" type="ST_LongHexNumber"/> |
| 102 | + </xsd:complexType> |
| 103 | + |
| 104 | + <xsd:complexType name="CT_RPr"> <!-- flattened for readibility --> |
| 105 | + <xsd:sequence> |
| 106 | + <xsd:group ref="EG_RPrBase" minOccurs="0" maxOccurs="unbounded"/> |
| 107 | + <xsd:element name="rPrChange" type="CT_RPrChange" minOccurs="0"/> |
| 108 | + </xsd:sequence> |
| 109 | + </xsd:complexType> |
| 110 | + |
| 111 | + <xsd:group name="EG_RPrBase"> |
| 112 | + <xsd:choice> |
| 113 | + <xsd:element name="rStyle" type="CT_String"/> |
| 114 | + <xsd:element name="b" type="CT_OnOff"/> |
| 115 | + <xsd:element name="i" type="CT_OnOff"/> |
| 116 | + <xsd:element name="color" type="CT_Color"/> |
| 117 | + <xsd:element name="sz" type="CT_HpsMeasure"/> |
| 118 | + <xsd:element name="u" type="CT_Underline"/> |
| 119 | + <!-- 33 others --> |
| 120 | + </xsd:choice> |
| 121 | + </xsd:group> |
| 122 | + |
| 123 | + <xsd:complexType name="CT_Underline"> |
| 124 | + <xsd:attribute name="val" type="ST_Underline"/> |
| 125 | + <xsd:attribute name="color" type="ST_HexColor"/> |
| 126 | + <xsd:attribute name="themeColor" type="ST_ThemeColor"/> |
| 127 | + <xsd:attribute name="themeTint" type="ST_UcharHexNumber"/> |
| 128 | + <xsd:attribute name="themeShade" type="ST_UcharHexNumber"/> |
| 129 | + </xsd:complexType> |
| 130 | + |
| 131 | + <xsd:simpleType name="ST_Underline"> |
| 132 | + <xsd:restriction base="xsd:string"> |
| 133 | + <xsd:enumeration value="single"/> |
| 134 | + <xsd:enumeration value="words"/> |
| 135 | + <xsd:enumeration value="double"/> |
| 136 | + <xsd:enumeration value="thick"/> |
| 137 | + <xsd:enumeration value="dotted"/> |
| 138 | + <xsd:enumeration value="dottedHeavy"/> |
| 139 | + <xsd:enumeration value="dash"/> |
| 140 | + <xsd:enumeration value="dashedHeavy"/> |
| 141 | + <xsd:enumeration value="dashLong"/> |
| 142 | + <xsd:enumeration value="dashLongHeavy"/> |
| 143 | + <xsd:enumeration value="dotDash"/> |
| 144 | + <xsd:enumeration value="dashDotHeavy"/> |
| 145 | + <xsd:enumeration value="dotDotDash"/> |
| 146 | + <xsd:enumeration value="dashDotDotHeavy"/> |
| 147 | + <xsd:enumeration value="wave"/> |
| 148 | + <xsd:enumeration value="wavyHeavy"/> |
| 149 | + <xsd:enumeration value="wavyDouble"/> |
| 150 | + <xsd:enumeration value="none"/> |
| 151 | + </xsd:restriction> |
| 152 | + </xsd:simpleType> |
0 commit comments