File: underline.rst

package info (click to toggle)
python-docx 1.2.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,216 kB
  • sloc: xml: 25,323; python: 23,414; makefile: 175
file content (155 lines) | stat: -rw-r--r-- 4,247 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155

Underline
=========

Text in a Word document can be underlined in a variety of styles.


Protocol
--------

The call protocol for underline is overloaded such that it works like
``.bold`` and ``.italic`` for single underline, but also allows an enumerated
value to be assigned to specify more sophisticated underlining such as
dashed, wavy, and double-underline::

    >>> run = paragraph.add_run()
    >>> run.underline
    None
    >>> run.underline = True
    >>> run.underline
    True
    >>> run.underline = WD_UNDERLINE.SINGLE
    >>> run.underline
    True
    >>> run.underline = WD_UNDERLINE.DOUBLE
    >>> str(run.underline)
    DOUBLE (3)
    >>> run.underline = False
    >>> run.underline
    False
    >>> run.underline = WD_UNDERLINE.NONE
    >>> run.underline
    False
    >>> run.underline = None
    >>> run.underline
    None


Enumerations
------------

* `WdUnderline Enumeration on MSDN`_

.. _WdUnderline Enumeration on MSDN:
   http://msdn.microsoft.com/en-us/library/office/ff822388(v=office.15).aspx


Specimen XML
------------

.. highlight:: xml

Baseline run::

    <w:r>
      <w:t>underlining determined by inheritance</w:t>
    </w:r>

Single underline::

    <w:r>
      <w:rPr>
        <w:u w:val="single"/>
      </w:rPr>
      <w:t>single underlined</w:t>
    </w:r>

Double underline::

    <w:r>
      <w:rPr>
        <w:u w:val="double"/>
      </w:rPr>
      <w:t>single underlined</w:t>
    </w:r>

Directly-applied no-underline, overrides inherited value::

    <w:r>
      <w:rPr>
        <w:u w:val="none"/>
      </w:rPr>
      <w:t>not underlined</w:t>
    </w:r>


Schema excerpt
--------------

Note that the ``w:val`` attribute on ``CT_Underline`` is optional. When it is
not present no underline appears on the run.

.. highlight:: xml

::

  <xsd:complexType name="CT_R">  <!-- flattened for readibility -->
    <xsd:sequence>
      <xsd:element name="rPr" type="CT_RPr" minOccurs="0"/>
      <xsd:group   ref="EG_RunInnerContent" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
    <xsd:attribute name="rsidRPr" type="ST_LongHexNumber"/>
    <xsd:attribute name="rsidDel" type="ST_LongHexNumber"/>
    <xsd:attribute name="rsidR"   type="ST_LongHexNumber"/>
  </xsd:complexType>

  <xsd:complexType name="CT_RPr">  <!-- flattened for readibility -->
    <xsd:sequence>
      <xsd:group   ref="EG_RPrBase" minOccurs="0" maxOccurs="unbounded"/>
      <xsd:element name="rPrChange" type="CT_RPrChange" minOccurs="0"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:group name="EG_RPrBase">
    <xsd:choice>
      <xsd:element name="rStyle"          type="CT_String"/>
      <xsd:element name="b"               type="CT_OnOff"/>
      <xsd:element name="i"               type="CT_OnOff"/>
      <xsd:element name="color"           type="CT_Color"/>
      <xsd:element name="sz"              type="CT_HpsMeasure"/>
      <xsd:element name="u"               type="CT_Underline"/>
      <!-- 33 others -->
    </xsd:choice>
  </xsd:group>

  <xsd:complexType name="CT_Underline">
    <xsd:attribute name="val"        type="ST_Underline"/>
    <xsd:attribute name="color"      type="ST_HexColor"/>
    <xsd:attribute name="themeColor" type="ST_ThemeColor"/>
    <xsd:attribute name="themeTint"  type="ST_UcharHexNumber"/>
    <xsd:attribute name="themeShade" type="ST_UcharHexNumber"/>
  </xsd:complexType>

  <xsd:simpleType name="ST_Underline">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="single"/>
      <xsd:enumeration value="words"/>
      <xsd:enumeration value="double"/>
      <xsd:enumeration value="thick"/>
      <xsd:enumeration value="dotted"/>
      <xsd:enumeration value="dottedHeavy"/>
      <xsd:enumeration value="dash"/>
      <xsd:enumeration value="dashedHeavy"/>
      <xsd:enumeration value="dashLong"/>
      <xsd:enumeration value="dashLongHeavy"/>
      <xsd:enumeration value="dotDash"/>
      <xsd:enumeration value="dashDotHeavy"/>
      <xsd:enumeration value="dotDotDash"/>
      <xsd:enumeration value="dashDotDotHeavy"/>
      <xsd:enumeration value="wave"/>
      <xsd:enumeration value="wavyHeavy"/>
      <xsd:enumeration value="wavyDouble"/>
      <xsd:enumeration value="none"/>
    </xsd:restriction>
  </xsd:simpleType>