ps-python-docx 1.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- docx/__init__.py +68 -0
- docx/api.py +37 -0
- docx/blkcntnr.py +101 -0
- docx/comments.py +163 -0
- docx/dml/__init__.py +0 -0
- docx/dml/color.py +112 -0
- docx/document.py +275 -0
- docx/drawing/__init__.py +59 -0
- docx/enum/__init__.py +0 -0
- docx/enum/base.py +150 -0
- docx/enum/dml.py +103 -0
- docx/enum/section.py +86 -0
- docx/enum/shape.py +19 -0
- docx/enum/style.py +452 -0
- docx/enum/table.py +136 -0
- docx/enum/text.py +367 -0
- docx/exceptions.py +18 -0
- docx/image/__init__.py +23 -0
- docx/image/bmp.py +43 -0
- docx/image/constants.py +172 -0
- docx/image/exceptions.py +13 -0
- docx/image/gif.py +38 -0
- docx/image/helpers.py +86 -0
- docx/image/image.py +234 -0
- docx/image/jpeg.py +425 -0
- docx/image/png.py +253 -0
- docx/image/tiff.py +289 -0
- docx/opc/__init__.py +0 -0
- docx/opc/constants.py +306 -0
- docx/opc/coreprops.py +142 -0
- docx/opc/exceptions.py +12 -0
- docx/opc/oxml.py +247 -0
- docx/opc/package.py +219 -0
- docx/opc/packuri.py +109 -0
- docx/opc/part.py +247 -0
- docx/opc/parts/__init__.py +0 -0
- docx/opc/parts/coreprops.py +48 -0
- docx/opc/phys_pkg.py +119 -0
- docx/opc/pkgreader.py +254 -0
- docx/opc/pkgwriter.py +115 -0
- docx/opc/rel.py +153 -0
- docx/opc/shared.py +31 -0
- docx/opc/spec.py +24 -0
- docx/oxml/__init__.py +261 -0
- docx/oxml/comments.py +124 -0
- docx/oxml/coreprops.py +298 -0
- docx/oxml/document.py +88 -0
- docx/oxml/drawing.py +11 -0
- docx/oxml/exceptions.py +10 -0
- docx/oxml/ns.py +109 -0
- docx/oxml/numbering.py +109 -0
- docx/oxml/parser.py +62 -0
- docx/oxml/section.py +537 -0
- docx/oxml/settings.py +138 -0
- docx/oxml/shape.py +299 -0
- docx/oxml/shared.py +52 -0
- docx/oxml/simpletypes.py +434 -0
- docx/oxml/styles.py +341 -0
- docx/oxml/table.py +977 -0
- docx/oxml/text/__init__.py +0 -0
- docx/oxml/text/font.py +333 -0
- docx/oxml/text/hyperlink.py +45 -0
- docx/oxml/text/pagebreak.py +278 -0
- docx/oxml/text/paragraph.py +106 -0
- docx/oxml/text/parfmt.py +392 -0
- docx/oxml/text/run.py +307 -0
- docx/oxml/xmlchemy.py +696 -0
- docx/package.py +110 -0
- docx/parts/__init__.py +0 -0
- docx/parts/comments.py +51 -0
- docx/parts/document.py +182 -0
- docx/parts/hdrftr.py +53 -0
- docx/parts/image.py +80 -0
- docx/parts/numbering.py +32 -0
- docx/parts/settings.py +50 -0
- docx/parts/story.py +95 -0
- docx/parts/styles.py +42 -0
- docx/parts/theme.py +53 -0
- docx/py.typed +0 -0
- docx/section.py +479 -0
- docx/settings.py +35 -0
- docx/shape.py +103 -0
- docx/shared.py +382 -0
- docx/styles/__init__.py +40 -0
- docx/styles/latent.py +198 -0
- docx/styles/style.py +264 -0
- docx/styles/styles.py +147 -0
- docx/table.py +537 -0
- docx/templates/default-comments.xml +12 -0
- docx/templates/default-docx-template/[Content_Types].xml +17 -0
- docx/templates/default-docx-template/_rels/.rels +7 -0
- docx/templates/default-docx-template/customXml/_rels/item1.xml.rels +4 -0
- docx/templates/default-docx-template/customXml/item1.xml +2 -0
- docx/templates/default-docx-template/customXml/itemProps1.xml +6 -0
- docx/templates/default-docx-template/docProps/app.xml +36 -0
- docx/templates/default-docx-template/docProps/core.xml +13 -0
- docx/templates/default-docx-template/docProps/thumbnail.jpeg +0 -0
- docx/templates/default-docx-template/word/_rels/document.xml.rels +11 -0
- docx/templates/default-docx-template/word/document.xml +11 -0
- docx/templates/default-docx-template/word/fontTable.xml +61 -0
- docx/templates/default-docx-template/word/numbering.xml +201 -0
- docx/templates/default-docx-template/word/settings.xml +53 -0
- docx/templates/default-docx-template/word/styles.xml +11844 -0
- docx/templates/default-docx-template/word/stylesWithEffects.xml +11800 -0
- docx/templates/default-docx-template/word/theme/theme1.xml +318 -0
- docx/templates/default-docx-template/word/webSettings.xml +5 -0
- docx/templates/default-footer.xml +27 -0
- docx/templates/default-header.xml +27 -0
- docx/templates/default-settings.xml +26 -0
- docx/templates/default-styles.xml +190 -0
- docx/templates/default.docx +0 -0
- docx/text/__init__.py +0 -0
- docx/text/font.py +472 -0
- docx/text/hyperlink.py +121 -0
- docx/text/pagebreak.py +104 -0
- docx/text/paragraph.py +173 -0
- docx/text/parfmt.py +286 -0
- docx/text/run.py +257 -0
- docx/text/tabstops.py +123 -0
- docx/theme.py +67 -0
- docx/types.py +34 -0
- ps_python_docx-1.3.0.dist-info/METADATA +77 -0
- ps_python_docx-1.3.0.dist-info/RECORD +126 -0
- ps_python_docx-1.3.0.dist-info/WHEEL +5 -0
- ps_python_docx-1.3.0.dist-info/licenses/LICENSE +20 -0
- ps_python_docx-1.3.0.dist-info/top_level.txt +1 -0
docx/oxml/shape.py
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"""Custom element classes for shape-related elements like `<w:inline>`."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, cast
|
|
6
|
+
|
|
7
|
+
from docx.oxml.ns import nsdecls
|
|
8
|
+
from docx.oxml.parser import parse_xml
|
|
9
|
+
from docx.oxml.simpletypes import (
|
|
10
|
+
ST_Coordinate,
|
|
11
|
+
ST_DrawingElementId,
|
|
12
|
+
ST_PositiveCoordinate,
|
|
13
|
+
ST_RelationshipId,
|
|
14
|
+
XsdString,
|
|
15
|
+
XsdToken,
|
|
16
|
+
)
|
|
17
|
+
from docx.oxml.xmlchemy import (
|
|
18
|
+
BaseOxmlElement,
|
|
19
|
+
OneAndOnlyOne,
|
|
20
|
+
OptionalAttribute,
|
|
21
|
+
RequiredAttribute,
|
|
22
|
+
ZeroOrOne,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
if TYPE_CHECKING:
|
|
26
|
+
from docx.shared import Length
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class CT_Anchor(BaseOxmlElement):
|
|
30
|
+
"""`<wp:anchor>` element, container for a "floating" shape."""
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class CT_Blip(BaseOxmlElement):
|
|
34
|
+
"""``<a:blip>`` element, specifies image source and adjustments such as alpha and
|
|
35
|
+
tint."""
|
|
36
|
+
|
|
37
|
+
embed: str | None = OptionalAttribute( # pyright: ignore[reportAssignmentType]
|
|
38
|
+
"r:embed", ST_RelationshipId
|
|
39
|
+
)
|
|
40
|
+
link: str | None = OptionalAttribute( # pyright: ignore[reportAssignmentType]
|
|
41
|
+
"r:link", ST_RelationshipId
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class CT_BlipFillProperties(BaseOxmlElement):
|
|
46
|
+
"""``<pic:blipFill>`` element, specifies picture properties."""
|
|
47
|
+
|
|
48
|
+
blip: CT_Blip = ZeroOrOne( # pyright: ignore[reportAssignmentType]
|
|
49
|
+
"a:blip", successors=("a:srcRect", "a:tile", "a:stretch")
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class CT_GraphicalObject(BaseOxmlElement):
|
|
54
|
+
"""``<a:graphic>`` element, container for a DrawingML object."""
|
|
55
|
+
|
|
56
|
+
graphicData: CT_GraphicalObjectData = OneAndOnlyOne( # pyright: ignore[reportAssignmentType]
|
|
57
|
+
"a:graphicData"
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class CT_GraphicalObjectData(BaseOxmlElement):
|
|
62
|
+
"""``<a:graphicData>`` element, container for the XML of a DrawingML object."""
|
|
63
|
+
|
|
64
|
+
pic: CT_Picture = ZeroOrOne("pic:pic") # pyright: ignore[reportAssignmentType]
|
|
65
|
+
uri: str = RequiredAttribute("uri", XsdToken) # pyright: ignore[reportAssignmentType]
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class CT_Inline(BaseOxmlElement):
|
|
69
|
+
"""`<wp:inline>` element, container for an inline shape."""
|
|
70
|
+
|
|
71
|
+
extent: CT_PositiveSize2D = OneAndOnlyOne("wp:extent") # pyright: ignore[reportAssignmentType]
|
|
72
|
+
docPr: CT_NonVisualDrawingProps = OneAndOnlyOne( # pyright: ignore[reportAssignmentType]
|
|
73
|
+
"wp:docPr"
|
|
74
|
+
)
|
|
75
|
+
graphic: CT_GraphicalObject = OneAndOnlyOne( # pyright: ignore[reportAssignmentType]
|
|
76
|
+
"a:graphic"
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
@classmethod
|
|
80
|
+
def new(cls, cx: Length, cy: Length, shape_id: int, pic: CT_Picture) -> CT_Inline:
|
|
81
|
+
"""Return a new ``<wp:inline>`` element populated with the values passed as
|
|
82
|
+
parameters."""
|
|
83
|
+
inline = cast(CT_Inline, parse_xml(cls._inline_xml()))
|
|
84
|
+
inline.extent.cx = cx
|
|
85
|
+
inline.extent.cy = cy
|
|
86
|
+
inline.docPr.id = shape_id
|
|
87
|
+
inline.docPr.name = "Picture %d" % shape_id
|
|
88
|
+
inline.graphic.graphicData.uri = "http://schemas.openxmlformats.org/drawingml/2006/picture"
|
|
89
|
+
inline.graphic.graphicData._insert_pic(pic)
|
|
90
|
+
return inline
|
|
91
|
+
|
|
92
|
+
@classmethod
|
|
93
|
+
def new_pic_inline(
|
|
94
|
+
cls, shape_id: int, rId: str, filename: str, cx: Length, cy: Length
|
|
95
|
+
) -> CT_Inline:
|
|
96
|
+
"""Create `wp:inline` element containing a `pic:pic` element.
|
|
97
|
+
|
|
98
|
+
The contents of the `pic:pic` element is taken from the argument values.
|
|
99
|
+
"""
|
|
100
|
+
pic_id = 0 # Word doesn't seem to use this, but does not omit it
|
|
101
|
+
pic = CT_Picture.new(pic_id, filename, rId, cx, cy)
|
|
102
|
+
inline = cls.new(cx, cy, shape_id, pic)
|
|
103
|
+
return inline
|
|
104
|
+
|
|
105
|
+
@classmethod
|
|
106
|
+
def _inline_xml(cls):
|
|
107
|
+
return (
|
|
108
|
+
"<wp:inline %s>\n"
|
|
109
|
+
' <wp:extent cx="914400" cy="914400"/>\n'
|
|
110
|
+
' <wp:docPr id="666" name="unnamed"/>\n'
|
|
111
|
+
" <wp:cNvGraphicFramePr>\n"
|
|
112
|
+
' <a:graphicFrameLocks noChangeAspect="1"/>\n'
|
|
113
|
+
" </wp:cNvGraphicFramePr>\n"
|
|
114
|
+
" <a:graphic>\n"
|
|
115
|
+
' <a:graphicData uri="URI not set"/>\n'
|
|
116
|
+
" </a:graphic>\n"
|
|
117
|
+
"</wp:inline>" % nsdecls("wp", "a", "pic", "r")
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
class CT_NonVisualDrawingProps(BaseOxmlElement):
|
|
122
|
+
"""Used for ``<wp:docPr>`` element, and perhaps others.
|
|
123
|
+
|
|
124
|
+
Specifies the id and name of a DrawingML drawing.
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
id = RequiredAttribute("id", ST_DrawingElementId)
|
|
128
|
+
name = RequiredAttribute("name", XsdString)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class CT_NonVisualPictureProperties(BaseOxmlElement):
|
|
132
|
+
"""``<pic:cNvPicPr>`` element, specifies picture locking and resize behaviors."""
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class CT_Picture(BaseOxmlElement):
|
|
136
|
+
"""``<pic:pic>`` element, a DrawingML picture."""
|
|
137
|
+
|
|
138
|
+
nvPicPr: CT_PictureNonVisual = OneAndOnlyOne( # pyright: ignore[reportAssignmentType]
|
|
139
|
+
"pic:nvPicPr"
|
|
140
|
+
)
|
|
141
|
+
blipFill: CT_BlipFillProperties = OneAndOnlyOne( # pyright: ignore[reportAssignmentType]
|
|
142
|
+
"pic:blipFill"
|
|
143
|
+
)
|
|
144
|
+
spPr: CT_ShapeProperties = OneAndOnlyOne("pic:spPr") # pyright: ignore[reportAssignmentType]
|
|
145
|
+
|
|
146
|
+
@classmethod
|
|
147
|
+
def new(cls, pic_id: int, filename: str, rId: str, cx: Length, cy: Length) -> CT_Picture:
|
|
148
|
+
"""A new minimum viable `<pic:pic>` (picture) element."""
|
|
149
|
+
pic = parse_xml(cls._pic_xml())
|
|
150
|
+
pic.nvPicPr.cNvPr.id = pic_id
|
|
151
|
+
pic.nvPicPr.cNvPr.name = filename
|
|
152
|
+
pic.blipFill.blip.embed = rId
|
|
153
|
+
pic.spPr.cx = cx
|
|
154
|
+
pic.spPr.cy = cy
|
|
155
|
+
return pic
|
|
156
|
+
|
|
157
|
+
@classmethod
|
|
158
|
+
def _pic_xml(cls):
|
|
159
|
+
return (
|
|
160
|
+
"<pic:pic %s>\n"
|
|
161
|
+
" <pic:nvPicPr>\n"
|
|
162
|
+
' <pic:cNvPr id="666" name="unnamed"/>\n'
|
|
163
|
+
" <pic:cNvPicPr/>\n"
|
|
164
|
+
" </pic:nvPicPr>\n"
|
|
165
|
+
" <pic:blipFill>\n"
|
|
166
|
+
" <a:blip/>\n"
|
|
167
|
+
" <a:stretch>\n"
|
|
168
|
+
" <a:fillRect/>\n"
|
|
169
|
+
" </a:stretch>\n"
|
|
170
|
+
" </pic:blipFill>\n"
|
|
171
|
+
" <pic:spPr>\n"
|
|
172
|
+
" <a:xfrm>\n"
|
|
173
|
+
' <a:off x="0" y="0"/>\n'
|
|
174
|
+
' <a:ext cx="914400" cy="914400"/>\n'
|
|
175
|
+
" </a:xfrm>\n"
|
|
176
|
+
' <a:prstGeom prst="rect"/>\n'
|
|
177
|
+
" </pic:spPr>\n"
|
|
178
|
+
"</pic:pic>" % nsdecls("pic", "a", "r")
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class CT_PictureNonVisual(BaseOxmlElement):
|
|
183
|
+
"""``<pic:nvPicPr>`` element, non-visual picture properties."""
|
|
184
|
+
|
|
185
|
+
cNvPr = OneAndOnlyOne("pic:cNvPr")
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class CT_Point2D(BaseOxmlElement):
|
|
189
|
+
"""Used for ``<a:off>`` element, and perhaps others.
|
|
190
|
+
|
|
191
|
+
Specifies an x, y coordinate (point).
|
|
192
|
+
"""
|
|
193
|
+
|
|
194
|
+
x = RequiredAttribute("x", ST_Coordinate)
|
|
195
|
+
y = RequiredAttribute("y", ST_Coordinate)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
class CT_PositiveSize2D(BaseOxmlElement):
|
|
199
|
+
"""Used for ``<wp:extent>`` element, and perhaps others later.
|
|
200
|
+
|
|
201
|
+
Specifies the size of a DrawingML drawing.
|
|
202
|
+
"""
|
|
203
|
+
|
|
204
|
+
cx: Length = RequiredAttribute( # pyright: ignore[reportAssignmentType]
|
|
205
|
+
"cx", ST_PositiveCoordinate
|
|
206
|
+
)
|
|
207
|
+
cy: Length = RequiredAttribute( # pyright: ignore[reportAssignmentType]
|
|
208
|
+
"cy", ST_PositiveCoordinate
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
class CT_PresetGeometry2D(BaseOxmlElement):
|
|
213
|
+
"""``<a:prstGeom>`` element, specifies an preset autoshape geometry, such as
|
|
214
|
+
``rect``."""
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
class CT_RelativeRect(BaseOxmlElement):
|
|
218
|
+
"""``<a:fillRect>`` element, specifying picture should fill containing rectangle
|
|
219
|
+
shape."""
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
class CT_ShapeProperties(BaseOxmlElement):
|
|
223
|
+
"""``<pic:spPr>`` element, specifies size and shape of picture container."""
|
|
224
|
+
|
|
225
|
+
xfrm = ZeroOrOne(
|
|
226
|
+
"a:xfrm",
|
|
227
|
+
successors=(
|
|
228
|
+
"a:custGeom",
|
|
229
|
+
"a:prstGeom",
|
|
230
|
+
"a:ln",
|
|
231
|
+
"a:effectLst",
|
|
232
|
+
"a:effectDag",
|
|
233
|
+
"a:scene3d",
|
|
234
|
+
"a:sp3d",
|
|
235
|
+
"a:extLst",
|
|
236
|
+
),
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
@property
|
|
240
|
+
def cx(self):
|
|
241
|
+
"""Shape width as an instance of Emu, or None if not present."""
|
|
242
|
+
xfrm = self.xfrm
|
|
243
|
+
if xfrm is None:
|
|
244
|
+
return None
|
|
245
|
+
return xfrm.cx
|
|
246
|
+
|
|
247
|
+
@cx.setter
|
|
248
|
+
def cx(self, value):
|
|
249
|
+
xfrm = self.get_or_add_xfrm()
|
|
250
|
+
xfrm.cx = value
|
|
251
|
+
|
|
252
|
+
@property
|
|
253
|
+
def cy(self):
|
|
254
|
+
"""Shape height as an instance of Emu, or None if not present."""
|
|
255
|
+
xfrm = self.xfrm
|
|
256
|
+
if xfrm is None:
|
|
257
|
+
return None
|
|
258
|
+
return xfrm.cy
|
|
259
|
+
|
|
260
|
+
@cy.setter
|
|
261
|
+
def cy(self, value):
|
|
262
|
+
xfrm = self.get_or_add_xfrm()
|
|
263
|
+
xfrm.cy = value
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
class CT_StretchInfoProperties(BaseOxmlElement):
|
|
267
|
+
"""``<a:stretch>`` element, specifies how picture should fill its containing
|
|
268
|
+
shape."""
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
class CT_Transform2D(BaseOxmlElement):
|
|
272
|
+
"""``<a:xfrm>`` element, specifies size and shape of picture container."""
|
|
273
|
+
|
|
274
|
+
off = ZeroOrOne("a:off", successors=("a:ext",))
|
|
275
|
+
ext = ZeroOrOne("a:ext", successors=())
|
|
276
|
+
|
|
277
|
+
@property
|
|
278
|
+
def cx(self):
|
|
279
|
+
ext = self.ext
|
|
280
|
+
if ext is None:
|
|
281
|
+
return None
|
|
282
|
+
return ext.cx
|
|
283
|
+
|
|
284
|
+
@cx.setter
|
|
285
|
+
def cx(self, value):
|
|
286
|
+
ext = self.get_or_add_ext()
|
|
287
|
+
ext.cx = value
|
|
288
|
+
|
|
289
|
+
@property
|
|
290
|
+
def cy(self):
|
|
291
|
+
ext = self.ext
|
|
292
|
+
if ext is None:
|
|
293
|
+
return None
|
|
294
|
+
return ext.cy
|
|
295
|
+
|
|
296
|
+
@cy.setter
|
|
297
|
+
def cy(self, value):
|
|
298
|
+
ext = self.get_or_add_ext()
|
|
299
|
+
ext.cy = value
|
docx/oxml/shared.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Objects shared by modules in the docx.oxml subpackage."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import cast
|
|
6
|
+
|
|
7
|
+
from docx.oxml.ns import qn
|
|
8
|
+
from docx.oxml.parser import OxmlElement
|
|
9
|
+
from docx.oxml.simpletypes import ST_DecimalNumber, ST_OnOff, ST_String
|
|
10
|
+
from docx.oxml.xmlchemy import BaseOxmlElement, OptionalAttribute, RequiredAttribute
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class CT_DecimalNumber(BaseOxmlElement):
|
|
14
|
+
"""Used for ``<w:numId>``, ``<w:ilvl>``, ``<w:abstractNumId>`` and several others,
|
|
15
|
+
containing a text representation of a decimal number (e.g. 42) in its ``val``
|
|
16
|
+
attribute."""
|
|
17
|
+
|
|
18
|
+
val: int = RequiredAttribute("w:val", ST_DecimalNumber) # pyright: ignore[reportAssignmentType]
|
|
19
|
+
|
|
20
|
+
@classmethod
|
|
21
|
+
def new(cls, nsptagname: str, val: int):
|
|
22
|
+
"""Return a new ``CT_DecimalNumber`` element having tagname `nsptagname` and
|
|
23
|
+
``val`` attribute set to `val`."""
|
|
24
|
+
return OxmlElement(nsptagname, attrs={qn("w:val"): str(val)})
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class CT_OnOff(BaseOxmlElement):
|
|
28
|
+
"""Used for `w:b`, `w:i` elements and others.
|
|
29
|
+
|
|
30
|
+
Contains a bool-ish string in its `val` attribute, xsd:boolean plus "on" and
|
|
31
|
+
"off". Defaults to `True`, so `<w:b>` for example means "bold is turned on".
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
val: bool = OptionalAttribute( # pyright: ignore[reportAssignmentType]
|
|
35
|
+
"w:val", ST_OnOff, default=True
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class CT_String(BaseOxmlElement):
|
|
40
|
+
"""Used for `w:pStyle` and `w:tblStyle` elements and others.
|
|
41
|
+
|
|
42
|
+
In those cases, it containing a style name in its `val` attribute.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
val: str = RequiredAttribute("w:val", ST_String) # pyright: ignore[reportAssignmentType]
|
|
46
|
+
|
|
47
|
+
@classmethod
|
|
48
|
+
def new(cls, nsptagname: str, val: str):
|
|
49
|
+
"""A new `CT_String`` element with tagname `nsptagname` and `val` attribute set to `val`."""
|
|
50
|
+
elm = cast(CT_String, OxmlElement(nsptagname))
|
|
51
|
+
elm.val = val
|
|
52
|
+
return elm
|