forked from scanny/python-pptx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext.py
More file actions
256 lines (219 loc) · 8.2 KB
/
text.py
File metadata and controls
256 lines (219 loc) · 8.2 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# encoding: utf-8
"""
Enumerations used by text and related objects
"""
from __future__ import absolute_import
from .base import (
alias, Enumeration, EnumMember, ReturnValueOnlyEnumMember,
XmlEnumeration, XmlMappedEnumMember
)
class MSO_AUTO_SIZE(Enumeration):
"""
Determines the type of automatic sizing allowed.
The following names can be used to specify the automatic sizing behavior
used to fit a shape's text within the shape bounding box, for example::
from pptx.enum.text import MSO_AUTO_SIZE
shape.text_frame.auto_size = MSO_AUTO_SIZE.TEXT_TO_FIT_SHAPE
The word-wrap setting of the text frame interacts with the auto-size
setting to determine the specific auto-sizing behavior.
Note that ``TextFrame.auto_size`` can also be set to |None|, which removes
the auto size setting altogether. This causes the setting to be inherited,
either from the layout placeholder, in the case of a placeholder shape, or
from the theme.
"""
NONE = 0
SHAPE_TO_FIT_TEXT = 1
TEXT_TO_FIT_SHAPE = 2
__ms_name__ = 'MsoAutoSize'
__url__ = (
'http://msdn.microsoft.com/en-us/library/office/ff865367(v=office.15'
').aspx'
)
__members__ = (
EnumMember(
'NONE', 0, 'No automatic sizing of the shape or text will be don'
'e. Text can freely extend beyond the horizontal and vertical ed'
'ges of the shape bounding box.'
),
EnumMember(
'SHAPE_TO_FIT_TEXT', 1, 'The shape height and possibly width are'
' adjusted to fit the text. Note this setting interacts with the'
' TextFrame.word_wrap property setting. If word wrap is turned o'
'n, only the height of the shape will be adjusted; soft line bre'
'aks will be used to fit the text horizontally.'
),
EnumMember(
'TEXT_TO_FIT_SHAPE', 2, 'The font size is reduced as necessary t'
'o fit the text within the shape.'
),
ReturnValueOnlyEnumMember(
'MIXED', -2, 'Return value only; indicates a combination of auto'
'matic sizing schemes are used.'
),
)
@alias('MSO_UNDERLINE')
class MSO_TEXT_UNDERLINE_TYPE(XmlEnumeration):
"""
Indicates the type of underline for text. Used with
:attr:`.Font.underline` to specify the style of text underlining.
Alias: ``MSO_UNDERLINE``
Example::
from pptx.enum.text import MSO_UNDERLINE
run.font.underline = MSO_UNDERLINE.DOUBLE_LINE
"""
__ms_name__ = 'MsoTextUnderlineType'
__url__ = 'http://msdn.microsoft.com/en-us/library/aa432699.aspx'
__members__ = (
XmlMappedEnumMember(
'NONE', 0, 'none',
'Specifies no underline.'
),
XmlMappedEnumMember(
'DASH_HEAVY_LINE', 8, 'dashHeavy',
'Specifies a dash underline.'
),
XmlMappedEnumMember(
'DASH_LINE', 7, 'dash',
'Specifies a dash line underline.'
),
XmlMappedEnumMember(
'DASH_LONG_HEAVY_LINE', 10, 'dashLongHeavy',
'Specifies a long heavy line underline.'
),
XmlMappedEnumMember(
'DASH_LONG_LINE', 9, 'dashLong',
'Specifies a dashed long line underline.'
),
XmlMappedEnumMember(
'DOT_DASH_HEAVY_LINE', 12, 'dotDashHeavy',
'Specifies a dot dash heavy line underline.'
),
XmlMappedEnumMember(
'DOT_DASH_LINE', 11, 'dotDash',
'Specifies a dot dash line underline.'
),
XmlMappedEnumMember(
'DOT_DOT_DASH_HEAVY_LINE', 14, 'dotDotDashHeavy',
'Specifies a dot dot dash heavy line underline.'
),
XmlMappedEnumMember(
'DOT_DOT_DASH_LINE', 13, 'dotDotDash',
'Specifies a dot dot dash line underline.'
),
XmlMappedEnumMember(
'DOTTED_HEAVY_LINE', 6, 'dottedHeavy',
'Specifies a dotted heavy line underline.'
),
XmlMappedEnumMember(
'DOTTED_LINE', 5, 'dotted',
'Specifies a dotted line underline.'
),
XmlMappedEnumMember(
'DOUBLE_LINE', 3, 'dbl',
'Specifies a double line underline.'
),
XmlMappedEnumMember(
'HEAVY_LINE', 4, 'heavy',
'Specifies a heavy line underline.'
),
XmlMappedEnumMember(
'SINGLE_LINE', 2, 'sng',
'Specifies a single line underline.'
),
XmlMappedEnumMember(
'WAVY_DOUBLE_LINE', 17, 'wavyDbl',
'Specifies a wavy double line underline.'
),
XmlMappedEnumMember(
'WAVY_HEAVY_LINE', 16, 'wavyHeavy',
'Specifies a wavy heavy line underline.'
),
XmlMappedEnumMember(
'WAVY_LINE', 15, 'wavy',
'Specifies a wavy line underline.'
),
XmlMappedEnumMember(
'WORDS', 1, 'words',
'Specifies underlining words.'
),
ReturnValueOnlyEnumMember(
'MIXED', -2, 'Specifies a mixed of underline types.'
),
)
@alias('MSO_ANCHOR')
class MSO_VERTICAL_ANCHOR(XmlEnumeration):
"""
Specifies the vertical alignment of text in a text frame. Used with the
``.vertical_anchor`` property of the |TextFrame| object. Note that the
``vertical_anchor`` property can also have the value None, indicating
there is no directly specified vertical anchor setting and its effective
value is inherited from its placeholder if it has one or from the theme.
|None| may also be assigned to remove an explicitly specified vertical
anchor setting.
"""
__ms_name__ = 'MsoVerticalAnchor'
__url__ = 'http://msdn.microsoft.com/en-us/library/office/ff865255.aspx'
__members__ = (
XmlMappedEnumMember(
None, None, None, 'Text frame has no vertical anchor specified '
'and inherits its value from its layout placeholder or theme.'
),
XmlMappedEnumMember(
'TOP', 1, 't', 'Aligns text to top of text frame'
),
XmlMappedEnumMember(
'MIDDLE', 3, 'ctr', 'Centers text vertically'
),
XmlMappedEnumMember(
'BOTTOM', 4, 'b', 'Aligns text to bottom of text frame'
),
ReturnValueOnlyEnumMember(
'MIXED', -2, 'Return value only; indicates a combination of the '
'other states.'
),
)
@alias('PP_ALIGN')
class PP_PARAGRAPH_ALIGNMENT(XmlEnumeration):
"""
Specifies the horizontal alignment for one or more paragraphs.
Alias: ``PP_ALIGN``
Example::
from pptx.enum.text import PP_ALIGN
shape.paragraphs[0].alignment = PP_ALIGN.CENTER
"""
__ms_name__ = 'PpParagraphAlignment'
__url__ = (
'http://msdn.microsoft.com/en-us/library/office/ff745375(v=office.15'
').aspx'
)
__members__ = (
XmlMappedEnumMember(
'CENTER', 2, 'ctr', 'Center align'
),
XmlMappedEnumMember(
'DISTRIBUTE', 5, 'dist', 'Evenly distributes e.g. Japanese chara'
'cters from left to right within a line'
),
XmlMappedEnumMember(
'JUSTIFY', 4, 'just', 'Justified, i.e. each line both begins and'
' ends at the margin with spacing between words adjusted such th'
'at the line exactly fills the width of the paragraph.'
),
XmlMappedEnumMember(
'JUSTIFY_LOW', 7, 'justLow', 'Justify using a small amount of sp'
'ace between words.'
),
XmlMappedEnumMember(
'LEFT', 1, 'l', 'Left aligned'
),
XmlMappedEnumMember(
'RIGHT', 3, 'r', 'Right aligned'
),
XmlMappedEnumMember(
'THAI_DISTRIBUTE', 6, 'thaiDist', 'Thai distributed'
),
ReturnValueOnlyEnumMember(
'MIXED', -2, 'Return value only; indicates multiple paragraph al'
'ignments are present in a set of paragraphs.'
),
)