python-pptx2 2.13.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.
- pptx2/__init__.py +152 -0
- pptx2/_color.py +75 -0
- pptx2/_slide_importer.py +597 -0
- pptx2/_svg.py +155 -0
- pptx2/_template_applier.py +292 -0
- pptx2/_textstyle.py +187 -0
- pptx2/accessibility.py +365 -0
- pptx2/action.py +270 -0
- pptx2/animation.py +2237 -0
- pptx2/api.py +49 -0
- pptx2/audit.py +258 -0
- pptx2/chart/__init__.py +0 -0
- pptx2/chart/analytics.py +381 -0
- pptx2/chart/axis.py +543 -0
- pptx2/chart/category.py +200 -0
- pptx2/chart/chart.py +670 -0
- pptx2/chart/data.py +864 -0
- pptx2/chart/datalabel.py +406 -0
- pptx2/chart/legend.py +86 -0
- pptx2/chart/marker.py +70 -0
- pptx2/chart/palettes.py +129 -0
- pptx2/chart/plot.py +462 -0
- pptx2/chart/point.py +101 -0
- pptx2/chart/quick_layouts.py +325 -0
- pptx2/chart/series.py +334 -0
- pptx2/chart/xlsx.py +272 -0
- pptx2/chart/xmlwriter.py +1845 -0
- pptx2/compose/__init__.py +28 -0
- pptx2/compose/from_spec.py +1094 -0
- pptx2/design/__init__.py +8 -0
- pptx2/design/components.py +607 -0
- pptx2/design/figures.py +389 -0
- pptx2/design/layout.py +370 -0
- pptx2/design/recipes.py +1967 -0
- pptx2/design/style.py +209 -0
- pptx2/design/tokens.py +915 -0
- pptx2/diagrams.py +754 -0
- pptx2/dml/__init__.py +0 -0
- pptx2/dml/chtfmt.py +40 -0
- pptx2/dml/color.py +496 -0
- pptx2/dml/effect.py +909 -0
- pptx2/dml/fill.py +691 -0
- pptx2/dml/line.py +287 -0
- pptx2/dml/picture.py +212 -0
- pptx2/dml/three_d.py +381 -0
- pptx2/enum/__init__.py +0 -0
- pptx2/enum/action.py +71 -0
- pptx2/enum/animation.py +31 -0
- pptx2/enum/base.py +218 -0
- pptx2/enum/chart.py +574 -0
- pptx2/enum/dml.py +740 -0
- pptx2/enum/lang.py +685 -0
- pptx2/enum/presentation.py +133 -0
- pptx2/enum/shapes.py +1029 -0
- pptx2/enum/text.py +230 -0
- pptx2/exc.py +42 -0
- pptx2/formats.py +139 -0
- pptx2/geometry.py +420 -0
- pptx2/inherit.py +109 -0
- pptx2/lint.py +2256 -0
- pptx2/math.py +177 -0
- pptx2/media.py +197 -0
- pptx2/opc/__init__.py +0 -0
- pptx2/opc/constants.py +332 -0
- pptx2/opc/oxml.py +188 -0
- pptx2/opc/package.py +762 -0
- pptx2/opc/packuri.py +109 -0
- pptx2/opc/serialized.py +296 -0
- pptx2/opc/shared.py +20 -0
- pptx2/opc/spec.py +45 -0
- pptx2/oxml/__init__.py +555 -0
- pptx2/oxml/action.py +53 -0
- pptx2/oxml/chart/__init__.py +0 -0
- pptx2/oxml/chart/axis.py +337 -0
- pptx2/oxml/chart/chart.py +481 -0
- pptx2/oxml/chart/datalabel.py +253 -0
- pptx2/oxml/chart/legend.py +72 -0
- pptx2/oxml/chart/marker.py +61 -0
- pptx2/oxml/chart/plot.py +365 -0
- pptx2/oxml/chart/series.py +425 -0
- pptx2/oxml/chart/shared.py +220 -0
- pptx2/oxml/coreprops.py +288 -0
- pptx2/oxml/dml/__init__.py +0 -0
- pptx2/oxml/dml/color.py +135 -0
- pptx2/oxml/dml/effect.py +213 -0
- pptx2/oxml/dml/fill.py +316 -0
- pptx2/oxml/dml/line.py +12 -0
- pptx2/oxml/dml/three_d.py +110 -0
- pptx2/oxml/ns.py +135 -0
- pptx2/oxml/presentation.py +313 -0
- pptx2/oxml/shapes/__init__.py +19 -0
- pptx2/oxml/shapes/autoshape.py +467 -0
- pptx2/oxml/shapes/connector.py +107 -0
- pptx2/oxml/shapes/graphfrm.py +347 -0
- pptx2/oxml/shapes/groupshape.py +329 -0
- pptx2/oxml/shapes/picture.py +270 -0
- pptx2/oxml/shapes/shared.py +577 -0
- pptx2/oxml/simpletypes.py +1027 -0
- pptx2/oxml/slide.py +563 -0
- pptx2/oxml/table.py +650 -0
- pptx2/oxml/text.py +815 -0
- pptx2/oxml/theme.py +36 -0
- pptx2/oxml/xmlchemy.py +717 -0
- pptx2/package.py +222 -0
- pptx2/parts/__init__.py +0 -0
- pptx2/parts/chart.py +95 -0
- pptx2/parts/coreprops.py +167 -0
- pptx2/parts/diagram.py +37 -0
- pptx2/parts/embeddedpackage.py +93 -0
- pptx2/parts/image.py +275 -0
- pptx2/parts/media.py +37 -0
- pptx2/parts/presentation.py +136 -0
- pptx2/parts/slide.py +371 -0
- pptx2/presentation.py +408 -0
- pptx2/py.typed +0 -0
- pptx2/render.py +586 -0
- pptx2/section.py +272 -0
- pptx2/shapes/__init__.py +26 -0
- pptx2/shapes/autoshape.py +442 -0
- pptx2/shapes/base.py +1078 -0
- pptx2/shapes/connector.py +297 -0
- pptx2/shapes/freeform.py +337 -0
- pptx2/shapes/graphfrm.py +316 -0
- pptx2/shapes/group.py +264 -0
- pptx2/shapes/picture.py +422 -0
- pptx2/shapes/placeholder.py +468 -0
- pptx2/shapes/shapetree.py +2027 -0
- pptx2/shared.py +82 -0
- pptx2/skill/SKILL.md +450 -0
- pptx2/skill/__init__.py +78 -0
- pptx2/skill/__main__.py +64 -0
- pptx2/skill/references/animations.md +189 -0
- pptx2/skill/references/basics.md +421 -0
- pptx2/skill/references/charts.md +254 -0
- pptx2/skill/references/compose.md +234 -0
- pptx2/skill/references/design.md +366 -0
- pptx2/skill/references/effects.md +249 -0
- pptx2/skill/references/end-to-end-deck.md +231 -0
- pptx2/skill/references/geometry-and-arrows.md +334 -0
- pptx2/skill/references/lint.md +275 -0
- pptx2/skill/references/math.md +86 -0
- pptx2/skill/references/picture-effects.md +129 -0
- pptx2/skill/references/render.md +151 -0
- pptx2/skill/references/smart-art.md +75 -0
- pptx2/skill/references/space-aware-authoring.md +249 -0
- pptx2/skill/references/tables.md +244 -0
- pptx2/skill/references/theme.md +127 -0
- pptx2/skill/references/three-d.md +109 -0
- pptx2/skill/references/transitions.md +100 -0
- pptx2/slide.py +1244 -0
- pptx2/smart_art.py +220 -0
- pptx2/spec.py +633 -0
- pptx2/table.py +1181 -0
- pptx2/table_styles.py +184 -0
- pptx2/templates/default.pptx +0 -0
- pptx2/templates/docx-icon.emf +0 -0
- pptx2/templates/generic-icon.emf +0 -0
- pptx2/templates/notes.xml +23 -0
- pptx2/templates/notesMaster.xml +352 -0
- pptx2/templates/pptx-icon.emf +0 -0
- pptx2/templates/theme.xml +321 -0
- pptx2/templates/xlsx-icon.emf +0 -0
- pptx2/text/__init__.py +0 -0
- pptx2/text/fonts.py +482 -0
- pptx2/text/layout.py +374 -0
- pptx2/text/text.py +1272 -0
- pptx2/theme.py +721 -0
- pptx2/types.py +36 -0
- pptx2/util.py +263 -0
- python_pptx2-2.13.0.dist-info/METADATA +351 -0
- python_pptx2-2.13.0.dist-info/RECORD +175 -0
- python_pptx2-2.13.0.dist-info/WHEEL +5 -0
- python_pptx2-2.13.0.dist-info/entry_points.txt +3 -0
- python_pptx2-2.13.0.dist-info/licenses/LICENSE +22 -0
- python_pptx2-2.13.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"""lxml custom element classes for picture-related XML elements."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, cast
|
|
6
|
+
from xml.sax.saxutils import escape
|
|
7
|
+
|
|
8
|
+
from pptx2.oxml import parse_xml
|
|
9
|
+
from pptx2.oxml.ns import nsdecls
|
|
10
|
+
from pptx2.oxml.shapes.shared import BaseShapeElement
|
|
11
|
+
from pptx2.oxml.xmlchemy import BaseOxmlElement, OneAndOnlyOne
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from pptx2.oxml.shapes.shared import CT_ShapeProperties
|
|
15
|
+
from pptx2.util import Length
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class CT_Picture(BaseShapeElement):
|
|
19
|
+
"""`p:pic` element.
|
|
20
|
+
|
|
21
|
+
Represents a picture shape (an image placement on a slide).
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
nvPicPr = OneAndOnlyOne("p:nvPicPr")
|
|
25
|
+
blipFill = OneAndOnlyOne("p:blipFill")
|
|
26
|
+
spPr: CT_ShapeProperties = OneAndOnlyOne("p:spPr") # pyright: ignore[reportAssignmentType]
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def blip_rId(self) -> str | None:
|
|
30
|
+
"""Value of `p:blipFill/a:blip/@r:embed`.
|
|
31
|
+
|
|
32
|
+
Returns |None| if not present.
|
|
33
|
+
"""
|
|
34
|
+
blip = self.blipFill.blip
|
|
35
|
+
if blip is not None and blip.rEmbed is not None:
|
|
36
|
+
return blip.rEmbed
|
|
37
|
+
return None
|
|
38
|
+
|
|
39
|
+
def crop_to_fit(self, image_size, view_size):
|
|
40
|
+
"""
|
|
41
|
+
Set cropping values in `p:blipFill/a:srcRect` such that an image of
|
|
42
|
+
*image_size* will stretch to exactly fit *view_size* when its aspect
|
|
43
|
+
ratio is preserved.
|
|
44
|
+
"""
|
|
45
|
+
self.blipFill.crop(self._fill_cropping(image_size, view_size))
|
|
46
|
+
|
|
47
|
+
def get_or_add_ln(self):
|
|
48
|
+
"""
|
|
49
|
+
Return the <a:ln> grandchild element, newly added if not present.
|
|
50
|
+
"""
|
|
51
|
+
return self.spPr.get_or_add_ln()
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def ln(self):
|
|
55
|
+
"""
|
|
56
|
+
``<a:ln>`` grand-child element or |None| if not present
|
|
57
|
+
"""
|
|
58
|
+
return self.spPr.ln
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def new_ph_pic(cls, id_, name, desc, rId):
|
|
62
|
+
"""
|
|
63
|
+
Return a new `p:pic` placeholder element populated with the supplied
|
|
64
|
+
parameters.
|
|
65
|
+
"""
|
|
66
|
+
return parse_xml(cls._pic_ph_tmpl() % (id_, name, desc, rId))
|
|
67
|
+
|
|
68
|
+
@classmethod
|
|
69
|
+
def new_pic(cls, shape_id, name, desc, rId, x, y, cx, cy):
|
|
70
|
+
"""Return new `<p:pic>` element tree configured with supplied parameters."""
|
|
71
|
+
return parse_xml(cls._pic_tmpl() % (shape_id, name, escape(desc), rId, x, y, cx, cy))
|
|
72
|
+
|
|
73
|
+
@classmethod
|
|
74
|
+
def new_video_pic(
|
|
75
|
+
cls,
|
|
76
|
+
shape_id: int,
|
|
77
|
+
shape_name: str,
|
|
78
|
+
video_rId: str,
|
|
79
|
+
media_rId: str,
|
|
80
|
+
poster_frame_rId: str,
|
|
81
|
+
x: Length,
|
|
82
|
+
y: Length,
|
|
83
|
+
cx: Length,
|
|
84
|
+
cy: Length,
|
|
85
|
+
) -> CT_Picture:
|
|
86
|
+
"""Return a new `p:pic` populated with the specified video."""
|
|
87
|
+
return cast(
|
|
88
|
+
CT_Picture,
|
|
89
|
+
parse_xml(
|
|
90
|
+
cls._pic_video_tmpl()
|
|
91
|
+
% (
|
|
92
|
+
shape_id,
|
|
93
|
+
shape_name,
|
|
94
|
+
video_rId,
|
|
95
|
+
media_rId,
|
|
96
|
+
poster_frame_rId,
|
|
97
|
+
x,
|
|
98
|
+
y,
|
|
99
|
+
cx,
|
|
100
|
+
cy,
|
|
101
|
+
)
|
|
102
|
+
),
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
@property
|
|
106
|
+
def srcRect_b(self):
|
|
107
|
+
"""Value of `p:blipFill/a:srcRect/@b` or 0.0 if not present."""
|
|
108
|
+
return self._srcRect_x("b")
|
|
109
|
+
|
|
110
|
+
@srcRect_b.setter
|
|
111
|
+
def srcRect_b(self, value):
|
|
112
|
+
self.blipFill.get_or_add_srcRect().b = value
|
|
113
|
+
|
|
114
|
+
@property
|
|
115
|
+
def srcRect_l(self):
|
|
116
|
+
"""Value of `p:blipFill/a:srcRect/@l` or 0.0 if not present."""
|
|
117
|
+
return self._srcRect_x("l")
|
|
118
|
+
|
|
119
|
+
@srcRect_l.setter
|
|
120
|
+
def srcRect_l(self, value):
|
|
121
|
+
self.blipFill.get_or_add_srcRect().l = value # noqa
|
|
122
|
+
|
|
123
|
+
@property
|
|
124
|
+
def srcRect_r(self):
|
|
125
|
+
"""Value of `p:blipFill/a:srcRect/@r` or 0.0 if not present."""
|
|
126
|
+
return self._srcRect_x("r")
|
|
127
|
+
|
|
128
|
+
@srcRect_r.setter
|
|
129
|
+
def srcRect_r(self, value):
|
|
130
|
+
self.blipFill.get_or_add_srcRect().r = value
|
|
131
|
+
|
|
132
|
+
@property
|
|
133
|
+
def srcRect_t(self):
|
|
134
|
+
"""Value of `p:blipFill/a:srcRect/@t` or 0.0 if not present."""
|
|
135
|
+
return self._srcRect_x("t")
|
|
136
|
+
|
|
137
|
+
@srcRect_t.setter
|
|
138
|
+
def srcRect_t(self, value):
|
|
139
|
+
self.blipFill.get_or_add_srcRect().t = value
|
|
140
|
+
|
|
141
|
+
def _fill_cropping(self, image_size, view_size):
|
|
142
|
+
"""
|
|
143
|
+
Return a (left, top, right, bottom) 4-tuple containing the cropping
|
|
144
|
+
values required to display an image of *image_size* in *view_size*
|
|
145
|
+
when stretched proportionately. Each value is a percentage expressed
|
|
146
|
+
as a fraction of 1.0, e.g. 0.425 represents 42.5%. *image_size* and
|
|
147
|
+
*view_size* are each (width, height) pairs.
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
def aspect_ratio(width, height):
|
|
151
|
+
return width / height
|
|
152
|
+
|
|
153
|
+
ar_view = aspect_ratio(*view_size)
|
|
154
|
+
ar_image = aspect_ratio(*image_size)
|
|
155
|
+
|
|
156
|
+
if ar_view < ar_image: # image too wide
|
|
157
|
+
crop = (1.0 - (ar_view / ar_image)) / 2.0
|
|
158
|
+
return (crop, 0.0, crop, 0.0)
|
|
159
|
+
if ar_view > ar_image: # image too tall
|
|
160
|
+
crop = (1.0 - (ar_image / ar_view)) / 2.0
|
|
161
|
+
return (0.0, crop, 0.0, crop)
|
|
162
|
+
return (0.0, 0.0, 0.0, 0.0)
|
|
163
|
+
|
|
164
|
+
@classmethod
|
|
165
|
+
def _pic_ph_tmpl(cls):
|
|
166
|
+
return (
|
|
167
|
+
"<p:pic %s>\n"
|
|
168
|
+
" <p:nvPicPr>\n"
|
|
169
|
+
' <p:cNvPr id="%%d" name="%%s" descr="%%s"/>\n'
|
|
170
|
+
" <p:cNvPicPr>\n"
|
|
171
|
+
' <a:picLocks noGrp="1" noChangeAspect="1"/>\n'
|
|
172
|
+
" </p:cNvPicPr>\n"
|
|
173
|
+
" <p:nvPr/>\n"
|
|
174
|
+
" </p:nvPicPr>\n"
|
|
175
|
+
" <p:blipFill>\n"
|
|
176
|
+
' <a:blip r:embed="%%s"/>\n'
|
|
177
|
+
" <a:stretch>\n"
|
|
178
|
+
" <a:fillRect/>\n"
|
|
179
|
+
" </a:stretch>\n"
|
|
180
|
+
" </p:blipFill>\n"
|
|
181
|
+
" <p:spPr/>\n"
|
|
182
|
+
"</p:pic>" % nsdecls("p", "a", "r")
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
@classmethod
|
|
186
|
+
def _pic_tmpl(cls):
|
|
187
|
+
return (
|
|
188
|
+
"<p:pic %s>\n"
|
|
189
|
+
" <p:nvPicPr>\n"
|
|
190
|
+
' <p:cNvPr id="%%d" name="%%s" descr="%%s"/>\n'
|
|
191
|
+
" <p:cNvPicPr>\n"
|
|
192
|
+
' <a:picLocks noChangeAspect="1"/>\n'
|
|
193
|
+
" </p:cNvPicPr>\n"
|
|
194
|
+
" <p:nvPr/>\n"
|
|
195
|
+
" </p:nvPicPr>\n"
|
|
196
|
+
" <p:blipFill>\n"
|
|
197
|
+
' <a:blip r:embed="%%s"/>\n'
|
|
198
|
+
" <a:stretch>\n"
|
|
199
|
+
" <a:fillRect/>\n"
|
|
200
|
+
" </a:stretch>\n"
|
|
201
|
+
" </p:blipFill>\n"
|
|
202
|
+
" <p:spPr>\n"
|
|
203
|
+
" <a:xfrm>\n"
|
|
204
|
+
' <a:off x="%%d" y="%%d"/>\n'
|
|
205
|
+
' <a:ext cx="%%d" cy="%%d"/>\n'
|
|
206
|
+
" </a:xfrm>\n"
|
|
207
|
+
' <a:prstGeom prst="rect">\n'
|
|
208
|
+
" <a:avLst/>\n"
|
|
209
|
+
" </a:prstGeom>\n"
|
|
210
|
+
" </p:spPr>\n"
|
|
211
|
+
"</p:pic>" % nsdecls("a", "p", "r")
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
@classmethod
|
|
215
|
+
def _pic_video_tmpl(cls):
|
|
216
|
+
return (
|
|
217
|
+
"<p:pic %s>\n"
|
|
218
|
+
" <p:nvPicPr>\n"
|
|
219
|
+
' <p:cNvPr id="%%d" name="%%s">\n'
|
|
220
|
+
' <a:hlinkClick r:id="" action="ppaction://media"/>\n'
|
|
221
|
+
" </p:cNvPr>\n"
|
|
222
|
+
" <p:cNvPicPr>\n"
|
|
223
|
+
' <a:picLocks noChangeAspect="1"/>\n'
|
|
224
|
+
" </p:cNvPicPr>\n"
|
|
225
|
+
" <p:nvPr>\n"
|
|
226
|
+
' <a:videoFile r:link="%%s"/>\n'
|
|
227
|
+
" <p:extLst>\n"
|
|
228
|
+
' <p:ext uri="{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}">\n'
|
|
229
|
+
' <p14:media xmlns:p14="http://schemas.microsoft.com/of'
|
|
230
|
+
'fice/powerpoint/2010/main" r:embed="%%s"/>\n'
|
|
231
|
+
" </p:ext>\n"
|
|
232
|
+
" </p:extLst>\n"
|
|
233
|
+
" </p:nvPr>\n"
|
|
234
|
+
" </p:nvPicPr>\n"
|
|
235
|
+
" <p:blipFill>\n"
|
|
236
|
+
' <a:blip r:embed="%%s"/>\n'
|
|
237
|
+
" <a:stretch>\n"
|
|
238
|
+
" <a:fillRect/>\n"
|
|
239
|
+
" </a:stretch>\n"
|
|
240
|
+
" </p:blipFill>\n"
|
|
241
|
+
" <p:spPr>\n"
|
|
242
|
+
" <a:xfrm>\n"
|
|
243
|
+
' <a:off x="%%d" y="%%d"/>\n'
|
|
244
|
+
' <a:ext cx="%%d" cy="%%d"/>\n'
|
|
245
|
+
" </a:xfrm>\n"
|
|
246
|
+
' <a:prstGeom prst="rect">\n'
|
|
247
|
+
" <a:avLst/>\n"
|
|
248
|
+
" </a:prstGeom>\n"
|
|
249
|
+
" </p:spPr>\n"
|
|
250
|
+
"</p:pic>" % nsdecls("a", "p", "r")
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
def _srcRect_x(self, attr_name):
|
|
254
|
+
"""
|
|
255
|
+
Value of `p:blipFill/a:srcRect/@{attr_name}` or 0.0 if not present.
|
|
256
|
+
"""
|
|
257
|
+
srcRect = self.blipFill.srcRect
|
|
258
|
+
if srcRect is None:
|
|
259
|
+
return 0.0
|
|
260
|
+
return getattr(srcRect, attr_name)
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
class CT_PictureNonVisual(BaseOxmlElement):
|
|
264
|
+
"""
|
|
265
|
+
``<p:nvPicPr>`` element, containing non-visual properties for a picture
|
|
266
|
+
shape.
|
|
267
|
+
"""
|
|
268
|
+
|
|
269
|
+
cNvPr = OneAndOnlyOne("p:cNvPr")
|
|
270
|
+
nvPr = OneAndOnlyOne("p:nvPr")
|