ybelkada HF Staff commited on
Commit
68e2bb4
·
verified ·
1 Parent(s): bda5c7d

Harbor format: 14 coding_additions tasks (part 6)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +3 -0
  2. tasks/tasksmith-74f059424102/environment/source/src/pptx/oxml/slide.py +347 -0
  3. tasks/tasksmith-74f059424102/environment/source/src/pptx/oxml/table.py +588 -0
  4. tasks/tasksmith-74f059424102/environment/source/src/pptx/oxml/text.py +618 -0
  5. tasks/tasksmith-74f059424102/environment/source/src/pptx/oxml/theme.py +29 -0
  6. tasks/tasksmith-74f059424102/environment/source/src/pptx/oxml/xmlchemy.py +717 -0
  7. tasks/tasksmith-74f059424102/environment/source/src/pptx/package.py +222 -0
  8. tasks/tasksmith-74f059424102/environment/source/src/pptx/parts/__init__.py +0 -0
  9. tasks/tasksmith-74f059424102/environment/source/src/pptx/parts/chart.py +95 -0
  10. tasks/tasksmith-74f059424102/environment/source/src/pptx/parts/coreprops.py +167 -0
  11. tasks/tasksmith-74f059424102/environment/source/src/pptx/parts/embeddedpackage.py +93 -0
  12. tasks/tasksmith-74f059424102/environment/source/src/pptx/parts/image.py +275 -0
  13. tasks/tasksmith-74f059424102/environment/source/src/pptx/parts/media.py +37 -0
  14. tasks/tasksmith-74f059424102/environment/source/src/pptx/parts/presentation.py +126 -0
  15. tasks/tasksmith-74f059424102/environment/source/src/pptx/parts/slide.py +297 -0
  16. tasks/tasksmith-74f059424102/environment/source/src/pptx/presentation.py +113 -0
  17. tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/__init__.py +26 -0
  18. tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/autoshape.py +355 -0
  19. tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/base.py +244 -0
  20. tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/connector.py +297 -0
  21. tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/freeform.py +338 -0
  22. tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/graphfrm.py +166 -0
  23. tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/group.py +69 -0
  24. tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/picture.py +203 -0
  25. tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/placeholder.py +407 -0
  26. tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/shapetree.py +1190 -0
  27. tasks/tasksmith-74f059424102/environment/source/src/pptx/shared.py +82 -0
  28. tasks/tasksmith-74f059424102/environment/source/src/pptx/slide.py +498 -0
  29. tasks/tasksmith-74f059424102/environment/source/src/pptx/spec.py +632 -0
  30. tasks/tasksmith-74f059424102/environment/source/src/pptx/table.py +496 -0
  31. tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/default.pptx +0 -0
  32. tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/docx-icon.emf +3 -0
  33. tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/generic-icon.emf +0 -0
  34. tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/notes.xml +23 -0
  35. tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/notesMaster.xml +352 -0
  36. tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/pptx-icon.emf +0 -0
  37. tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/theme.xml +321 -0
  38. tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/xlsx-icon.emf +3 -0
  39. tasks/tasksmith-74f059424102/environment/source/src/pptx/text/__init__.py +0 -0
  40. tasks/tasksmith-74f059424102/environment/source/src/pptx/text/fonts.py +399 -0
  41. tasks/tasksmith-74f059424102/environment/source/src/pptx/text/layout.py +325 -0
  42. tasks/tasksmith-74f059424102/environment/source/src/pptx/text/text.py +681 -0
  43. tasks/tasksmith-74f059424102/environment/source/src/pptx/types.py +36 -0
  44. tasks/tasksmith-74f059424102/environment/source/src/pptx/util.py +214 -0
  45. tasks/tasksmith-74f059424102/environment/source/src/python_pptx.egg-info/PKG-INFO +599 -0
  46. tasks/tasksmith-74f059424102/environment/source/src/python_pptx.egg-info/SOURCES.txt +502 -0
  47. tasks/tasksmith-74f059424102/environment/source/src/python_pptx.egg-info/dependency_links.txt +1 -0
  48. tasks/tasksmith-74f059424102/environment/source/src/python_pptx.egg-info/not-zip-safe +1 -0
  49. tasks/tasksmith-74f059424102/environment/source/src/python_pptx.egg-info/requires.txt +3 -0
  50. tasks/tasksmith-74f059424102/environment/source/src/python_pptx.egg-info/top_level.txt +1 -0
.gitattributes CHANGED
@@ -88,3 +88,6 @@ tasks/tasksmith-74f059424102/environment/source/spec/ISO-IEC-29500-1/ISO-IEC-295
88
  tasks/tasksmith-74f059424102/environment/source/spec/ISO-IEC-29500-2/ISO-IEC-29500-2.pdf filter=lfs diff=lfs merge=lfs -text
89
  tasks/tasksmith-74f059424102/environment/source/spec/ISO-IEC-29500-3/ISO-IEC-29500-3.pdf filter=lfs diff=lfs merge=lfs -text
90
  tasks/tasksmith-74f059424102/environment/source/spec/ISO-IEC-29500-4/ISO-IEC-29500-4.pdf filter=lfs diff=lfs merge=lfs -text
 
 
 
 
88
  tasks/tasksmith-74f059424102/environment/source/spec/ISO-IEC-29500-2/ISO-IEC-29500-2.pdf filter=lfs diff=lfs merge=lfs -text
89
  tasks/tasksmith-74f059424102/environment/source/spec/ISO-IEC-29500-3/ISO-IEC-29500-3.pdf filter=lfs diff=lfs merge=lfs -text
90
  tasks/tasksmith-74f059424102/environment/source/spec/ISO-IEC-29500-4/ISO-IEC-29500-4.pdf filter=lfs diff=lfs merge=lfs -text
91
+ tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/docx-icon.emf filter=lfs diff=lfs merge=lfs -text
92
+ tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/xlsx-icon.emf filter=lfs diff=lfs merge=lfs -text
93
+ tasks/tasksmith-74f059424102/environment/source/tests/test_files/calibriz.ttf filter=lfs diff=lfs merge=lfs -text
tasks/tasksmith-74f059424102/environment/source/src/pptx/oxml/slide.py ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Slide-related custom element classes, including those for masters."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Callable, cast
6
+
7
+ from pptx.oxml import parse_from_template, parse_xml
8
+ from pptx.oxml.dml.fill import CT_GradientFillProperties
9
+ from pptx.oxml.ns import nsdecls
10
+ from pptx.oxml.simpletypes import XsdString
11
+ from pptx.oxml.xmlchemy import (
12
+ BaseOxmlElement,
13
+ Choice,
14
+ OneAndOnlyOne,
15
+ OptionalAttribute,
16
+ RequiredAttribute,
17
+ ZeroOrMore,
18
+ ZeroOrOne,
19
+ ZeroOrOneChoice,
20
+ )
21
+
22
+ if TYPE_CHECKING:
23
+ from pptx.oxml.shapes.groupshape import CT_GroupShape
24
+
25
+
26
+ class _BaseSlideElement(BaseOxmlElement):
27
+ """Base class for the six slide types, providing common methods."""
28
+
29
+ cSld: CT_CommonSlideData
30
+
31
+ @property
32
+ def spTree(self) -> CT_GroupShape:
33
+ """Return required `p:cSld/p:spTree` grandchild."""
34
+ return self.cSld.spTree
35
+
36
+
37
+ class CT_Background(BaseOxmlElement):
38
+ """`p:bg` element."""
39
+
40
+ _insert_bgPr: Callable[[CT_BackgroundProperties], None]
41
+
42
+ # ---these two are actually a choice, not a sequence, but simpler for
43
+ # ---present purposes this way.
44
+ _tag_seq = ("p:bgPr", "p:bgRef")
45
+ bgPr: CT_BackgroundProperties | None = ZeroOrOne( # pyright: ignore[reportAssignmentType]
46
+ "p:bgPr", successors=()
47
+ )
48
+ bgRef = ZeroOrOne("p:bgRef", successors=())
49
+ del _tag_seq
50
+
51
+ def add_noFill_bgPr(self):
52
+ """Return a new `p:bgPr` element with noFill properties."""
53
+ xml = "<p:bgPr %s>\n" " <a:noFill/>\n" " <a:effectLst/>\n" "</p:bgPr>" % nsdecls("a", "p")
54
+ bgPr = cast(CT_BackgroundProperties, parse_xml(xml))
55
+ self._insert_bgPr(bgPr)
56
+ return bgPr
57
+
58
+
59
+ class CT_BackgroundProperties(BaseOxmlElement):
60
+ """`p:bgPr` element."""
61
+
62
+ _tag_seq = (
63
+ "a:noFill",
64
+ "a:solidFill",
65
+ "a:gradFill",
66
+ "a:blipFill",
67
+ "a:pattFill",
68
+ "a:grpFill",
69
+ "a:effectLst",
70
+ "a:effectDag",
71
+ "a:extLst",
72
+ )
73
+ eg_fillProperties = ZeroOrOneChoice(
74
+ (
75
+ Choice("a:noFill"),
76
+ Choice("a:solidFill"),
77
+ Choice("a:gradFill"),
78
+ Choice("a:blipFill"),
79
+ Choice("a:pattFill"),
80
+ Choice("a:grpFill"),
81
+ ),
82
+ successors=_tag_seq[6:],
83
+ )
84
+ del _tag_seq
85
+
86
+ def _new_gradFill(self):
87
+ """Override default to add default gradient subtree."""
88
+ return CT_GradientFillProperties.new_gradFill()
89
+
90
+
91
+ class CT_CommonSlideData(BaseOxmlElement):
92
+ """`p:cSld` element."""
93
+
94
+ _remove_bg: Callable[[], None]
95
+ get_or_add_bg: Callable[[], CT_Background]
96
+
97
+ _tag_seq = ("p:bg", "p:spTree", "p:custDataLst", "p:controls", "p:extLst")
98
+ bg: CT_Background | None = ZeroOrOne( # pyright: ignore[reportAssignmentType]
99
+ "p:bg", successors=_tag_seq[1:]
100
+ )
101
+ spTree: CT_GroupShape = OneAndOnlyOne("p:spTree") # pyright: ignore[reportAssignmentType]
102
+ del _tag_seq
103
+ name: str = OptionalAttribute( # pyright: ignore[reportAssignmentType]
104
+ "name", XsdString, default=""
105
+ )
106
+
107
+ def get_or_add_bgPr(self) -> CT_BackgroundProperties:
108
+ """Return `p:bg/p:bgPr` grandchild.
109
+
110
+ If no such grandchild is present, any existing `p:bg` child is first removed and a new
111
+ default `p:bg` with noFill settings is added.
112
+ """
113
+ bg = self.bg
114
+ if bg is None or bg.bgPr is None:
115
+ bg = self._change_to_noFill_bg()
116
+ return cast(CT_BackgroundProperties, bg.bgPr)
117
+
118
+ def _change_to_noFill_bg(self) -> CT_Background:
119
+ """Establish a `p:bg` child with no-fill settings.
120
+
121
+ Any existing `p:bg` child is first removed.
122
+ """
123
+ self._remove_bg()
124
+ bg = self.get_or_add_bg()
125
+ bg.add_noFill_bgPr()
126
+ return bg
127
+
128
+
129
+ class CT_NotesMaster(_BaseSlideElement):
130
+ """`p:notesMaster` element, root of a notes master part."""
131
+
132
+ _tag_seq = ("p:cSld", "p:clrMap", "p:hf", "p:notesStyle", "p:extLst")
133
+ cSld: CT_CommonSlideData = OneAndOnlyOne("p:cSld") # pyright: ignore[reportAssignmentType]
134
+ del _tag_seq
135
+
136
+ @classmethod
137
+ def new_default(cls) -> CT_NotesMaster:
138
+ """Return a new `p:notesMaster` element based on the built-in default template."""
139
+ return cast(CT_NotesMaster, parse_from_template("notesMaster"))
140
+
141
+
142
+ class CT_NotesSlide(_BaseSlideElement):
143
+ """`p:notes` element, root of a notes slide part."""
144
+
145
+ _tag_seq = ("p:cSld", "p:clrMapOvr", "p:extLst")
146
+ cSld: CT_CommonSlideData = OneAndOnlyOne("p:cSld") # pyright: ignore[reportAssignmentType]
147
+ del _tag_seq
148
+
149
+ @classmethod
150
+ def new(cls) -> CT_NotesSlide:
151
+ """Return a new ``<p:notes>`` element based on the default template.
152
+
153
+ Note that the template does not include placeholders, which must be subsequently cloned
154
+ from the notes master.
155
+ """
156
+ return cast(CT_NotesSlide, parse_from_template("notes"))
157
+
158
+
159
+ class CT_Slide(_BaseSlideElement):
160
+ """`p:sld` element, root element of a slide part (XML document)."""
161
+
162
+ _tag_seq = ("p:cSld", "p:clrMapOvr", "p:transition", "p:timing", "p:extLst")
163
+ cSld: CT_CommonSlideData = OneAndOnlyOne("p:cSld") # pyright: ignore[reportAssignmentType]
164
+ clrMapOvr = ZeroOrOne("p:clrMapOvr", successors=_tag_seq[2:])
165
+ timing = ZeroOrOne("p:timing", successors=_tag_seq[4:])
166
+ del _tag_seq
167
+
168
+ @classmethod
169
+ def new(cls) -> CT_Slide:
170
+ """Return new `p:sld` element configured as base slide shape."""
171
+ return cast(CT_Slide, parse_xml(cls._sld_xml()))
172
+
173
+ @property
174
+ def bg(self):
175
+ """Return `p:bg` grandchild or None if not present."""
176
+ return self.cSld.bg
177
+
178
+ def get_or_add_childTnLst(self):
179
+ """Return parent element for a new `p:video` child element.
180
+
181
+ The `p:video` element causes play controls to appear under a video
182
+ shape (pic shape containing video). There can be more than one video
183
+ shape on a slide, which causes the precondition to vary. It needs to
184
+ handle the case when there is no `p:sld/p:timing` element and when
185
+ that element already exists. If the case isn't simple, it just nukes
186
+ what's there and adds a fresh one. This could theoretically remove
187
+ desired existing timing information, but there isn't any evidence
188
+ available to me one way or the other, so I've taken the simple
189
+ approach.
190
+ """
191
+ childTnLst = self._childTnLst
192
+ if childTnLst is None:
193
+ childTnLst = self._add_childTnLst()
194
+ return childTnLst
195
+
196
+ def _add_childTnLst(self):
197
+ """Add `./p:timing/p:tnLst/p:par/p:cTn/p:childTnLst` descendant.
198
+
199
+ Any existing `p:timing` child element is ruthlessly removed and
200
+ replaced.
201
+ """
202
+ self.remove(self.get_or_add_timing())
203
+ timing = parse_xml(self._childTnLst_timing_xml())
204
+ self._insert_timing(timing)
205
+ return timing.xpath("./p:tnLst/p:par/p:cTn/p:childTnLst")[0]
206
+
207
+ @property
208
+ def _childTnLst(self):
209
+ """Return `./p:timing/p:tnLst/p:par/p:cTn/p:childTnLst` descendant.
210
+
211
+ Return None if that element is not present.
212
+ """
213
+ childTnLsts = self.xpath("./p:timing/p:tnLst/p:par/p:cTn/p:childTnLst")
214
+ if not childTnLsts:
215
+ return None
216
+ return childTnLsts[0]
217
+
218
+ @staticmethod
219
+ def _childTnLst_timing_xml():
220
+ return (
221
+ "<p:timing %s>\n"
222
+ " <p:tnLst>\n"
223
+ " <p:par>\n"
224
+ ' <p:cTn id="1" dur="indefinite" restart="never" nodeType="'
225
+ 'tmRoot">\n'
226
+ " <p:childTnLst/>\n"
227
+ " </p:cTn>\n"
228
+ " </p:par>\n"
229
+ " </p:tnLst>\n"
230
+ "</p:timing>" % nsdecls("p")
231
+ )
232
+
233
+ @staticmethod
234
+ def _sld_xml():
235
+ return (
236
+ "<p:sld %s>\n"
237
+ " <p:cSld>\n"
238
+ " <p:spTree>\n"
239
+ " <p:nvGrpSpPr>\n"
240
+ ' <p:cNvPr id="1" name=""/>\n'
241
+ " <p:cNvGrpSpPr/>\n"
242
+ " <p:nvPr/>\n"
243
+ " </p:nvGrpSpPr>\n"
244
+ " <p:grpSpPr/>\n"
245
+ " </p:spTree>\n"
246
+ " </p:cSld>\n"
247
+ " <p:clrMapOvr>\n"
248
+ " <a:masterClrMapping/>\n"
249
+ " </p:clrMapOvr>\n"
250
+ "</p:sld>" % nsdecls("a", "p", "r")
251
+ )
252
+
253
+
254
+ class CT_SlideLayout(_BaseSlideElement):
255
+ """`p:sldLayout` element, root of a slide layout part."""
256
+
257
+ _tag_seq = ("p:cSld", "p:clrMapOvr", "p:transition", "p:timing", "p:hf", "p:extLst")
258
+ cSld: CT_CommonSlideData = OneAndOnlyOne("p:cSld") # pyright: ignore[reportAssignmentType]
259
+ del _tag_seq
260
+
261
+
262
+ class CT_SlideLayoutIdList(BaseOxmlElement):
263
+ """`p:sldLayoutIdLst` element, child of `p:sldMaster`.
264
+
265
+ Contains references to the slide layouts that inherit from the slide master.
266
+ """
267
+
268
+ sldLayoutId_lst: list[CT_SlideLayoutIdListEntry]
269
+
270
+ sldLayoutId = ZeroOrMore("p:sldLayoutId")
271
+
272
+
273
+ class CT_SlideLayoutIdListEntry(BaseOxmlElement):
274
+ """`p:sldLayoutId` element, child of `p:sldLayoutIdLst`.
275
+
276
+ Contains a reference to a slide layout.
277
+ """
278
+
279
+ rId: str = RequiredAttribute("r:id", XsdString) # pyright: ignore[reportAssignmentType]
280
+
281
+
282
+ class CT_SlideMaster(_BaseSlideElement):
283
+ """`p:sldMaster` element, root of a slide master part."""
284
+
285
+ get_or_add_sldLayoutIdLst: Callable[[], CT_SlideLayoutIdList]
286
+
287
+ _tag_seq = (
288
+ "p:cSld",
289
+ "p:clrMap",
290
+ "p:sldLayoutIdLst",
291
+ "p:transition",
292
+ "p:timing",
293
+ "p:hf",
294
+ "p:txStyles",
295
+ "p:extLst",
296
+ )
297
+ cSld: CT_CommonSlideData = OneAndOnlyOne("p:cSld") # pyright: ignore[reportAssignmentType]
298
+ sldLayoutIdLst: CT_SlideLayoutIdList = ZeroOrOne( # pyright: ignore[reportAssignmentType]
299
+ "p:sldLayoutIdLst", successors=_tag_seq[3:]
300
+ )
301
+ del _tag_seq
302
+
303
+
304
+ class CT_SlideTiming(BaseOxmlElement):
305
+ """`p:timing` element, specifying animations and timed behaviors."""
306
+
307
+ _tag_seq = ("p:tnLst", "p:bldLst", "p:extLst")
308
+ tnLst = ZeroOrOne("p:tnLst", successors=_tag_seq[1:])
309
+ del _tag_seq
310
+
311
+
312
+ class CT_TimeNodeList(BaseOxmlElement):
313
+ """`p:tnLst` or `p:childTnList` element."""
314
+
315
+ def add_video(self, shape_id):
316
+ """Add a new `p:video` child element for movie having *shape_id*."""
317
+ video_xml = (
318
+ "<p:video %s>\n"
319
+ ' <p:cMediaNode vol="80000">\n'
320
+ ' <p:cTn id="%d" fill="hold" display="0">\n'
321
+ " <p:stCondLst>\n"
322
+ ' <p:cond delay="indefinite"/>\n'
323
+ " </p:stCondLst>\n"
324
+ " </p:cTn>\n"
325
+ " <p:tgtEl>\n"
326
+ ' <p:spTgt spid="%d"/>\n'
327
+ " </p:tgtEl>\n"
328
+ " </p:cMediaNode>\n"
329
+ "</p:video>\n" % (nsdecls("p"), self._next_cTn_id, shape_id)
330
+ )
331
+ video = parse_xml(video_xml)
332
+ self.append(video)
333
+
334
+ @property
335
+ def _next_cTn_id(self):
336
+ """Return the next available unique ID (int) for p:cTn element."""
337
+ cTn_id_strs = self.xpath("/p:sld/p:timing//p:cTn/@id")
338
+ ids = [int(id_str) for id_str in cTn_id_strs]
339
+ return max(ids) + 1
340
+
341
+
342
+ class CT_TLMediaNodeVideo(BaseOxmlElement):
343
+ """`p:video` element, specifying video media details."""
344
+
345
+ _tag_seq = ("p:cMediaNode",)
346
+ cMediaNode = OneAndOnlyOne("p:cMediaNode")
347
+ del _tag_seq
tasks/tasksmith-74f059424102/environment/source/src/pptx/oxml/table.py ADDED
@@ -0,0 +1,588 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Custom element classes for table-related XML elements"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Callable, Iterator, cast
6
+
7
+ from pptx.enum.text import MSO_VERTICAL_ANCHOR
8
+ from pptx.oxml import parse_xml
9
+ from pptx.oxml.dml.fill import CT_GradientFillProperties
10
+ from pptx.oxml.ns import nsdecls
11
+ from pptx.oxml.simpletypes import ST_Coordinate, ST_Coordinate32, XsdBoolean, XsdInt
12
+ from pptx.oxml.text import CT_TextBody
13
+ from pptx.oxml.xmlchemy import (
14
+ BaseOxmlElement,
15
+ Choice,
16
+ OneAndOnlyOne,
17
+ OptionalAttribute,
18
+ RequiredAttribute,
19
+ ZeroOrMore,
20
+ ZeroOrOne,
21
+ ZeroOrOneChoice,
22
+ )
23
+ from pptx.util import Emu, lazyproperty
24
+
25
+ if TYPE_CHECKING:
26
+ from pptx.util import Length
27
+
28
+
29
+ class CT_Table(BaseOxmlElement):
30
+ """`a:tbl` custom element class"""
31
+
32
+ get_or_add_tblPr: Callable[[], CT_TableProperties]
33
+ tr_lst: list[CT_TableRow]
34
+ _add_tr: Callable[..., CT_TableRow]
35
+
36
+ _tag_seq = ("a:tblPr", "a:tblGrid", "a:tr")
37
+ tblPr: CT_TableProperties | None = ZeroOrOne( # pyright: ignore[reportAssignmentType]
38
+ "a:tblPr", successors=_tag_seq[1:]
39
+ )
40
+ tblGrid: CT_TableGrid = OneAndOnlyOne("a:tblGrid") # pyright: ignore[reportAssignmentType]
41
+ tr = ZeroOrMore("a:tr", successors=_tag_seq[3:])
42
+ del _tag_seq
43
+
44
+ def add_tr(self, height: Length) -> CT_TableRow:
45
+ """Return a newly created `a:tr` child element having its `h` attribute set to `height`."""
46
+ return self._add_tr(h=height)
47
+
48
+ @property
49
+ def bandCol(self) -> bool:
50
+ return self._get_boolean_property("bandCol")
51
+
52
+ @bandCol.setter
53
+ def bandCol(self, value: bool):
54
+ self._set_boolean_property("bandCol", value)
55
+
56
+ @property
57
+ def bandRow(self) -> bool:
58
+ return self._get_boolean_property("bandRow")
59
+
60
+ @bandRow.setter
61
+ def bandRow(self, value: bool):
62
+ self._set_boolean_property("bandRow", value)
63
+
64
+ @property
65
+ def firstCol(self) -> bool:
66
+ return self._get_boolean_property("firstCol")
67
+
68
+ @firstCol.setter
69
+ def firstCol(self, value: bool):
70
+ self._set_boolean_property("firstCol", value)
71
+
72
+ @property
73
+ def firstRow(self) -> bool:
74
+ return self._get_boolean_property("firstRow")
75
+
76
+ @firstRow.setter
77
+ def firstRow(self, value: bool):
78
+ self._set_boolean_property("firstRow", value)
79
+
80
+ def iter_tcs(self) -> Iterator[CT_TableCell]:
81
+ """Generate each `a:tc` element in this tbl.
82
+
83
+ `a:tc` elements are generated left-to-right, top-to-bottom.
84
+ """
85
+ return (tc for tr in self.tr_lst for tc in tr.tc_lst)
86
+
87
+ @property
88
+ def lastCol(self) -> bool:
89
+ return self._get_boolean_property("lastCol")
90
+
91
+ @lastCol.setter
92
+ def lastCol(self, value: bool):
93
+ self._set_boolean_property("lastCol", value)
94
+
95
+ @property
96
+ def lastRow(self) -> bool:
97
+ return self._get_boolean_property("lastRow")
98
+
99
+ @lastRow.setter
100
+ def lastRow(self, value: bool):
101
+ self._set_boolean_property("lastRow", value)
102
+
103
+ @classmethod
104
+ def new_tbl(
105
+ cls, rows: int, cols: int, width: int, height: int, tableStyleId: str | None = None
106
+ ) -> CT_Table:
107
+ """Return a new `p:tbl` element tree."""
108
+ # working hypothesis is this is the default table style GUID
109
+ if tableStyleId is None:
110
+ tableStyleId = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}"
111
+
112
+ xml = cls._tbl_tmpl() % (tableStyleId)
113
+ tbl = cast(CT_Table, parse_xml(xml))
114
+
115
+ # add specified number of rows and columns
116
+ rowheight = height // rows
117
+ colwidth = width // cols
118
+
119
+ for col in range(cols):
120
+ # adjust width of last col to absorb any div error
121
+ if col == cols - 1:
122
+ colwidth = width - ((cols - 1) * colwidth)
123
+ tbl.tblGrid.add_gridCol(width=Emu(colwidth))
124
+
125
+ for row in range(rows):
126
+ # adjust height of last row to absorb any div error
127
+ if row == rows - 1:
128
+ rowheight = height - ((rows - 1) * rowheight)
129
+ tr = tbl.add_tr(height=Emu(rowheight))
130
+ for col in range(cols):
131
+ tr.add_tc()
132
+
133
+ return tbl
134
+
135
+ def tc(self, row_idx: int, col_idx: int) -> CT_TableCell:
136
+ """Return `a:tc` element at `row_idx`, `col_idx`."""
137
+ return self.tr_lst[row_idx].tc_lst[col_idx]
138
+
139
+ def _get_boolean_property(self, propname: str) -> bool:
140
+ """Generalized getter for the boolean properties on the `a:tblPr` child element.
141
+
142
+ Defaults to False if `propname` attribute is missing or `a:tblPr` element itself is not
143
+ present.
144
+ """
145
+ tblPr = self.tblPr
146
+ if tblPr is None:
147
+ return False
148
+ propval = getattr(tblPr, propname)
149
+ return {True: True, False: False, None: False}[propval]
150
+
151
+ def _set_boolean_property(self, propname: str, value: bool) -> None:
152
+ """Generalized setter for boolean properties on the `a:tblPr` child element.
153
+
154
+ Sets `propname` attribute appropriately based on `value`. If `value` is True, the
155
+ attribute is set to "1"; a tblPr child element is added if necessary. If `value` is False,
156
+ the `propname` attribute is removed if present, allowing its default value of False to be
157
+ its effective value.
158
+ """
159
+ if value not in (True, False):
160
+ raise ValueError("assigned value must be either True or False, got %s" % value)
161
+ tblPr = self.get_or_add_tblPr()
162
+ setattr(tblPr, propname, value)
163
+
164
+ @classmethod
165
+ def _tbl_tmpl(cls):
166
+ return (
167
+ "<a:tbl %s>\n"
168
+ ' <a:tblPr firstRow="1" bandRow="1">\n'
169
+ " <a:tableStyleId>%s</a:tableStyleId>\n"
170
+ " </a:tblPr>\n"
171
+ " <a:tblGrid/>\n"
172
+ "</a:tbl>" % (nsdecls("a"), "%s")
173
+ )
174
+
175
+
176
+ class CT_TableCell(BaseOxmlElement):
177
+ """`a:tc` custom element class"""
178
+
179
+ get_or_add_tcPr: Callable[[], CT_TableCellProperties]
180
+ get_or_add_txBody: Callable[[], CT_TextBody]
181
+
182
+ _tag_seq = ("a:txBody", "a:tcPr", "a:extLst")
183
+ txBody: CT_TextBody | None = ZeroOrOne( # pyright: ignore[reportAssignmentType]
184
+ "a:txBody", successors=_tag_seq[1:]
185
+ )
186
+ tcPr: CT_TableCellProperties | None = ZeroOrOne( # pyright: ignore[reportAssignmentType]
187
+ "a:tcPr", successors=_tag_seq[2:]
188
+ )
189
+ del _tag_seq
190
+
191
+ gridSpan: int = OptionalAttribute( # pyright: ignore[reportAssignmentType]
192
+ "gridSpan", XsdInt, default=1
193
+ )
194
+ rowSpan: int = OptionalAttribute( # pyright: ignore[reportAssignmentType]
195
+ "rowSpan", XsdInt, default=1
196
+ )
197
+ hMerge: bool = OptionalAttribute( # pyright: ignore[reportAssignmentType]
198
+ "hMerge", XsdBoolean, default=False
199
+ )
200
+ vMerge: bool = OptionalAttribute( # pyright: ignore[reportAssignmentType]
201
+ "vMerge", XsdBoolean, default=False
202
+ )
203
+
204
+ @property
205
+ def anchor(self) -> MSO_VERTICAL_ANCHOR | None:
206
+ """String held in `anchor` attribute of `a:tcPr` child element of this `a:tc` element."""
207
+ if self.tcPr is None:
208
+ return None
209
+ return self.tcPr.anchor
210
+
211
+ @anchor.setter
212
+ def anchor(self, anchor_enum_idx: MSO_VERTICAL_ANCHOR | None):
213
+ """Set value of anchor attribute on `a:tcPr` child element."""
214
+ if anchor_enum_idx is None and self.tcPr is None:
215
+ return
216
+ tcPr = self.get_or_add_tcPr()
217
+ tcPr.anchor = anchor_enum_idx
218
+
219
+ def append_ps_from(self, spanned_tc: CT_TableCell):
220
+ """Append `a:p` elements taken from `spanned_tc`.
221
+
222
+ Any non-empty paragraph elements in `spanned_tc` are removed and appended to the
223
+ text-frame of this cell. If `spanned_tc` is left with no content after this process, a
224
+ single empty `a:p` element is added to ensure the cell is compliant with the spec.
225
+ """
226
+ source_txBody = spanned_tc.get_or_add_txBody()
227
+ target_txBody = self.get_or_add_txBody()
228
+
229
+ # ---if source is empty, there's nothing to do---
230
+ if source_txBody.is_empty:
231
+ return
232
+
233
+ # ---a single empty paragraph in target is overwritten---
234
+ if target_txBody.is_empty:
235
+ target_txBody.clear_content()
236
+
237
+ for p in source_txBody.p_lst:
238
+ target_txBody.append(p)
239
+
240
+ # ---neither source nor target can be left without ps---
241
+ source_txBody.unclear_content()
242
+ target_txBody.unclear_content()
243
+
244
+ @property
245
+ def col_idx(self) -> int:
246
+ """Offset of this cell's column in its table."""
247
+ # ---tc elements come before any others in `a:tr` element---
248
+ return cast(CT_TableRow, self.getparent()).index(self)
249
+
250
+ @property
251
+ def is_merge_origin(self) -> bool:
252
+ """True if cell is top-left in merged cell range."""
253
+ if self.gridSpan > 1 and not self.vMerge:
254
+ return True
255
+ return self.rowSpan > 1 and not self.hMerge
256
+
257
+ @property
258
+ def is_spanned(self) -> bool:
259
+ """True if cell is in merged cell range but not merge origin cell."""
260
+ return self.hMerge or self.vMerge
261
+
262
+ @property
263
+ def marT(self) -> Length:
264
+ """Top margin for this cell.
265
+
266
+ This value is stored in the `marT` attribute of the `a:tcPr` child element of this `a:tc`.
267
+
268
+ Read/write. If the attribute is not present, the default value `45720` (0.05 inches) is
269
+ returned for top and bottom; `91440` (0.10 inches) is the default for left and right.
270
+ Assigning |None| to any `marX` property clears that attribute from the element,
271
+ effectively setting it to the default value.
272
+ """
273
+ return self._get_marX("marT", Emu(45720))
274
+
275
+ @marT.setter
276
+ def marT(self, value: Length | None):
277
+ self._set_marX("marT", value)
278
+
279
+ @property
280
+ def marR(self) -> Length:
281
+ """Right margin value represented in `marR` attribute."""
282
+ return self._get_marX("marR", Emu(91440))
283
+
284
+ @marR.setter
285
+ def marR(self, value: Length | None):
286
+ self._set_marX("marR", value)
287
+
288
+ @property
289
+ def marB(self) -> Length:
290
+ """Bottom margin value represented in `marB` attribute."""
291
+ return self._get_marX("marB", Emu(45720))
292
+
293
+ @marB.setter
294
+ def marB(self, value: Length | None):
295
+ self._set_marX("marB", value)
296
+
297
+ @property
298
+ def marL(self) -> Length:
299
+ """Left margin value represented in `marL` attribute."""
300
+ return self._get_marX("marL", Emu(91440))
301
+
302
+ @marL.setter
303
+ def marL(self, value: Length | None):
304
+ self._set_marX("marL", value)
305
+
306
+ @classmethod
307
+ def new(cls) -> CT_TableCell:
308
+ """Return a new `a:tc` element subtree."""
309
+ return cast(
310
+ CT_TableCell,
311
+ parse_xml(
312
+ f"<a:tc {nsdecls('a')}>\n"
313
+ f" <a:txBody>\n"
314
+ f" <a:bodyPr/>\n"
315
+ f" <a:lstStyle/>\n"
316
+ f" <a:p/>\n"
317
+ f" </a:txBody>\n"
318
+ f" <a:tcPr/>\n"
319
+ f"</a:tc>"
320
+ ),
321
+ )
322
+
323
+ @property
324
+ def row_idx(self) -> int:
325
+ """Offset of this cell's row in its table."""
326
+ return cast(CT_TableRow, self.getparent()).row_idx
327
+
328
+ @property
329
+ def tbl(self) -> CT_Table:
330
+ """Table element this cell belongs to."""
331
+ return cast(CT_Table, self.xpath("ancestor::a:tbl")[0])
332
+
333
+ @property
334
+ def text(self) -> str: # pyright: ignore[reportIncompatibleMethodOverride]
335
+ """str text contained in cell"""
336
+ # ---note this shadows lxml _Element.text---
337
+ txBody = self.txBody
338
+ if txBody is None:
339
+ return ""
340
+ return "\n".join([p.text for p in txBody.p_lst])
341
+
342
+ def _get_marX(self, attr_name: str, default: Length) -> Length:
343
+ """Generalized method to get margin values."""
344
+ if self.tcPr is None:
345
+ return Emu(default)
346
+ return Emu(int(self.tcPr.get(attr_name, default)))
347
+
348
+ def _new_txBody(self) -> CT_TextBody:
349
+ return CT_TextBody.new_a_txBody()
350
+
351
+ def _set_marX(self, marX: str, value: Length | None) -> None:
352
+ """Set value of marX attribute on `a:tcPr` child element.
353
+
354
+ If `marX` is |None|, the marX attribute is removed. `marX` is a string, one of `('marL',
355
+ 'marR', 'marT', 'marB')`.
356
+ """
357
+ if value is None and self.tcPr is None:
358
+ return
359
+ tcPr = self.get_or_add_tcPr()
360
+ setattr(tcPr, marX, value)
361
+
362
+
363
+ class CT_TableCellProperties(BaseOxmlElement):
364
+ """`a:tcPr` custom element class"""
365
+
366
+ eg_fillProperties = ZeroOrOneChoice(
367
+ (
368
+ Choice("a:noFill"),
369
+ Choice("a:solidFill"),
370
+ Choice("a:gradFill"),
371
+ Choice("a:blipFill"),
372
+ Choice("a:pattFill"),
373
+ Choice("a:grpFill"),
374
+ ),
375
+ successors=("a:headers", "a:extLst"),
376
+ )
377
+ anchor: MSO_VERTICAL_ANCHOR | None = OptionalAttribute( # pyright: ignore[reportAssignmentType]
378
+ "anchor", MSO_VERTICAL_ANCHOR
379
+ )
380
+ marL: Length | None = OptionalAttribute( # pyright: ignore[reportAssignmentType]
381
+ "marL", ST_Coordinate32
382
+ )
383
+ marR: Length | None = OptionalAttribute( # pyright: ignore[reportAssignmentType]
384
+ "marR", ST_Coordinate32
385
+ )
386
+ marT: Length | None = OptionalAttribute( # pyright: ignore[reportAssignmentType]
387
+ "marT", ST_Coordinate32
388
+ )
389
+ marB: Length | None = OptionalAttribute( # pyright: ignore[reportAssignmentType]
390
+ "marB", ST_Coordinate32
391
+ )
392
+
393
+ def _new_gradFill(self):
394
+ return CT_GradientFillProperties.new_gradFill()
395
+
396
+
397
+ class CT_TableCol(BaseOxmlElement):
398
+ """`a:gridCol` custom element class."""
399
+
400
+ w: Length = RequiredAttribute("w", ST_Coordinate) # pyright: ignore[reportAssignmentType]
401
+
402
+
403
+ class CT_TableGrid(BaseOxmlElement):
404
+ """`a:tblGrid` custom element class."""
405
+
406
+ gridCol_lst: list[CT_TableCol]
407
+ _add_gridCol: Callable[..., CT_TableCol]
408
+
409
+ gridCol = ZeroOrMore("a:gridCol")
410
+
411
+ def add_gridCol(self, width: Length) -> CT_TableCol:
412
+ """A newly appended `a:gridCol` child element having its `w` attribute set to `width`."""
413
+ return self._add_gridCol(w=width)
414
+
415
+
416
+ class CT_TableProperties(BaseOxmlElement):
417
+ """`a:tblPr` custom element class."""
418
+
419
+ bandRow = OptionalAttribute("bandRow", XsdBoolean, default=False)
420
+ bandCol = OptionalAttribute("bandCol", XsdBoolean, default=False)
421
+ firstRow = OptionalAttribute("firstRow", XsdBoolean, default=False)
422
+ firstCol = OptionalAttribute("firstCol", XsdBoolean, default=False)
423
+ lastRow = OptionalAttribute("lastRow", XsdBoolean, default=False)
424
+ lastCol = OptionalAttribute("lastCol", XsdBoolean, default=False)
425
+
426
+
427
+ class CT_TableRow(BaseOxmlElement):
428
+ """`a:tr` custom element class."""
429
+
430
+ tc_lst: list[CT_TableCell]
431
+ _add_tc: Callable[[], CT_TableCell]
432
+
433
+ tc = ZeroOrMore("a:tc", successors=("a:extLst",))
434
+ h: Length = RequiredAttribute("h", ST_Coordinate) # pyright: ignore[reportAssignmentType]
435
+
436
+ def add_tc(self) -> CT_TableCell:
437
+ """A newly added minimal valid `a:tc` child element."""
438
+ return self._add_tc()
439
+
440
+ @property
441
+ def row_idx(self) -> int:
442
+ """Offset of this row in its table."""
443
+ return cast(CT_Table, self.getparent()).tr_lst.index(self)
444
+
445
+ def _new_tc(self):
446
+ return CT_TableCell.new()
447
+
448
+
449
+ class TcRange(object):
450
+ """A 2D block of `a:tc` cell elements in a table.
451
+
452
+ This object assumes the structure of the underlying table does not change during its lifetime.
453
+ Structural changes in this context would be insertion or removal of rows or columns.
454
+
455
+ The client is expected to create, use, and then abandon an instance in the context of a single
456
+ user operation that is known to have no structural side-effects of this type.
457
+ """
458
+
459
+ def __init__(self, tc: CT_TableCell, other_tc: CT_TableCell):
460
+ self._tc = tc
461
+ self._other_tc = other_tc
462
+
463
+ @classmethod
464
+ def from_merge_origin(cls, tc: CT_TableCell):
465
+ """Return instance created from merge-origin tc element."""
466
+ other_tc = tc.tbl.tc(
467
+ tc.row_idx + tc.rowSpan - 1, # ---other_row_idx
468
+ tc.col_idx + tc.gridSpan - 1, # ---other_col_idx
469
+ )
470
+ return cls(tc, other_tc)
471
+
472
+ @lazyproperty
473
+ def contains_merged_cell(self) -> bool:
474
+ """True if one or more cells in range are part of a merged cell."""
475
+ for tc in self.iter_tcs():
476
+ if tc.gridSpan > 1:
477
+ return True
478
+ if tc.rowSpan > 1:
479
+ return True
480
+ if tc.hMerge:
481
+ return True
482
+ if tc.vMerge:
483
+ return True
484
+ return False
485
+
486
+ @lazyproperty
487
+ def dimensions(self) -> tuple[int, int]:
488
+ """(row_count, col_count) pair describing size of range."""
489
+ _, _, width, height = self._extents
490
+ return height, width
491
+
492
+ @lazyproperty
493
+ def in_same_table(self):
494
+ """True if both cells provided to constructor are in same table."""
495
+ if self._tc.tbl is self._other_tc.tbl:
496
+ return True
497
+ return False
498
+
499
+ def iter_except_left_col_tcs(self):
500
+ """Generate each `a:tc` element not in leftmost column of range."""
501
+ for tr in self._tbl.tr_lst[self._top : self._bottom]:
502
+ for tc in tr.tc_lst[self._left + 1 : self._right]:
503
+ yield tc
504
+
505
+ def iter_except_top_row_tcs(self):
506
+ """Generate each `a:tc` element in non-first rows of range."""
507
+ for tr in self._tbl.tr_lst[self._top + 1 : self._bottom]:
508
+ for tc in tr.tc_lst[self._left : self._right]:
509
+ yield tc
510
+
511
+ def iter_left_col_tcs(self):
512
+ """Generate each `a:tc` element in leftmost column of range."""
513
+ col_idx = self._left
514
+ for tr in self._tbl.tr_lst[self._top : self._bottom]:
515
+ yield tr.tc_lst[col_idx]
516
+
517
+ def iter_tcs(self):
518
+ """Generate each `a:tc` element in this range.
519
+
520
+ Cell elements are generated left-to-right, top-to-bottom.
521
+ """
522
+ return (
523
+ tc
524
+ for tr in self._tbl.tr_lst[self._top : self._bottom]
525
+ for tc in tr.tc_lst[self._left : self._right]
526
+ )
527
+
528
+ def iter_top_row_tcs(self):
529
+ """Generate each `a:tc` element in topmost row of range."""
530
+ tr = self._tbl.tr_lst[self._top]
531
+ for tc in tr.tc_lst[self._left : self._right]:
532
+ yield tc
533
+
534
+ def move_content_to_origin(self):
535
+ """Move all paragraphs in range to origin cell."""
536
+ tcs = list(self.iter_tcs())
537
+ origin_tc = tcs[0]
538
+ for spanned_tc in tcs[1:]:
539
+ origin_tc.append_ps_from(spanned_tc)
540
+
541
+ @lazyproperty
542
+ def _bottom(self):
543
+ """Index of row following last row of range"""
544
+ _, top, _, height = self._extents
545
+ return top + height
546
+
547
+ @lazyproperty
548
+ def _extents(self) -> tuple[int, int, int, int]:
549
+ """A (left, top, width, height) tuple describing range extents.
550
+
551
+ Note this is normalized to accommodate the various orderings of the corner cells provided
552
+ on construction, which may be in any of four configurations such as (top-left,
553
+ bottom-right), (bottom-left, top-right), etc.
554
+ """
555
+
556
+ def start_and_size(idx: int, other_idx: int) -> tuple[int, int]:
557
+ """Return beginning and length of range based on two indexes."""
558
+ return min(idx, other_idx), abs(idx - other_idx) + 1
559
+
560
+ tc, other_tc = self._tc, self._other_tc
561
+
562
+ left, width = start_and_size(tc.col_idx, other_tc.col_idx)
563
+ top, height = start_and_size(tc.row_idx, other_tc.row_idx)
564
+
565
+ return left, top, width, height
566
+
567
+ @lazyproperty
568
+ def _left(self):
569
+ """Index of leftmost column in range."""
570
+ left, _, _, _ = self._extents
571
+ return left
572
+
573
+ @lazyproperty
574
+ def _right(self):
575
+ """Index of column following the last column in range."""
576
+ left, _, width, _ = self._extents
577
+ return left + width
578
+
579
+ @lazyproperty
580
+ def _tbl(self):
581
+ """`a:tbl` element containing this cell range."""
582
+ return self._tc.tbl
583
+
584
+ @lazyproperty
585
+ def _top(self):
586
+ """Index of topmost row in range."""
587
+ _, top, _, _ = self._extents
588
+ return top
tasks/tasksmith-74f059424102/environment/source/src/pptx/oxml/text.py ADDED
@@ -0,0 +1,618 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Custom element classes for text-related XML elements"""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re
6
+ from typing import TYPE_CHECKING, Callable, cast
7
+
8
+ from pptx.enum.lang import MSO_LANGUAGE_ID
9
+ from pptx.enum.text import (
10
+ MSO_AUTO_SIZE,
11
+ MSO_TEXT_UNDERLINE_TYPE,
12
+ MSO_VERTICAL_ANCHOR,
13
+ PP_PARAGRAPH_ALIGNMENT,
14
+ )
15
+ from pptx.exc import InvalidXmlError
16
+ from pptx.oxml import parse_xml
17
+ from pptx.oxml.dml.fill import CT_GradientFillProperties
18
+ from pptx.oxml.ns import nsdecls
19
+ from pptx.oxml.simpletypes import (
20
+ ST_Coordinate32,
21
+ ST_TextFontScalePercentOrPercentString,
22
+ ST_TextFontSize,
23
+ ST_TextIndentLevelType,
24
+ ST_TextSpacingPercentOrPercentString,
25
+ ST_TextSpacingPoint,
26
+ ST_TextTypeface,
27
+ ST_TextWrappingType,
28
+ XsdBoolean,
29
+ )
30
+ from pptx.oxml.xmlchemy import (
31
+ BaseOxmlElement,
32
+ Choice,
33
+ OneAndOnlyOne,
34
+ OneOrMore,
35
+ OptionalAttribute,
36
+ RequiredAttribute,
37
+ ZeroOrMore,
38
+ ZeroOrOne,
39
+ ZeroOrOneChoice,
40
+ )
41
+ from pptx.util import Emu, Length
42
+
43
+ if TYPE_CHECKING:
44
+ from pptx.oxml.action import CT_Hyperlink
45
+
46
+
47
+ class CT_RegularTextRun(BaseOxmlElement):
48
+ """`a:r` custom element class"""
49
+
50
+ get_or_add_rPr: Callable[[], CT_TextCharacterProperties]
51
+
52
+ rPr: CT_TextCharacterProperties | None = ZeroOrOne( # pyright: ignore[reportAssignmentType]
53
+ "a:rPr", successors=("a:t",)
54
+ )
55
+ t: BaseOxmlElement = OneAndOnlyOne("a:t") # pyright: ignore[reportAssignmentType]
56
+
57
+ @property
58
+ def text(self) -> str:
59
+ """All text of (required) `a:t` child."""
60
+ text = self.t.text
61
+ # -- t.text is None when t element is empty, e.g. '<a:t/>' --
62
+ return text or ""
63
+
64
+ @text.setter
65
+ def text(self, value: str): # pyright: ignore[reportIncompatibleMethodOverride]
66
+ self.t.text = self._escape_ctrl_chars(value)
67
+
68
+ @staticmethod
69
+ def _escape_ctrl_chars(s: str) -> str:
70
+ """Return str after replacing each control character with a plain-text escape.
71
+
72
+ For example, a BEL character (x07) would appear as "_x0007_". Horizontal-tab
73
+ (x09) and line-feed (x0A) are not escaped. All other characters in the range
74
+ x00-x1F are escaped.
75
+ """
76
+ return re.sub(r"([\x00-\x08\x0B-\x1F])", lambda match: "_x%04X_" % ord(match.group(1)), s)
77
+
78
+
79
+ class CT_TextBody(BaseOxmlElement):
80
+ """`p:txBody` custom element class.
81
+
82
+ Also used for `c:txPr` in charts and perhaps other elements.
83
+ """
84
+
85
+ add_p: Callable[[], CT_TextParagraph]
86
+ p_lst: list[CT_TextParagraph]
87
+
88
+ bodyPr: CT_TextBodyProperties = OneAndOnlyOne( # pyright: ignore[reportAssignmentType]
89
+ "a:bodyPr"
90
+ )
91
+ p: CT_TextParagraph = OneOrMore("a:p") # pyright: ignore[reportAssignmentType]
92
+
93
+ def clear_content(self):
94
+ """Remove all `a:p` children, but leave any others.
95
+
96
+ cf. lxml `_Element.clear()` method which removes all children.
97
+ """
98
+ for p in self.p_lst:
99
+ self.remove(p)
100
+
101
+ @property
102
+ def defRPr(self) -> CT_TextCharacterProperties:
103
+ """`a:defRPr` element of required first `p` child, added with its ancestors if not present.
104
+
105
+ Used when element is a ``c:txPr`` in a chart and the `p` element is used only to specify
106
+ formatting, not content.
107
+ """
108
+ p = self.p_lst[0]
109
+ pPr = p.get_or_add_pPr()
110
+ defRPr = pPr.get_or_add_defRPr()
111
+ return defRPr
112
+
113
+ @property
114
+ def is_empty(self) -> bool:
115
+ """True if only a single empty `a:p` element is present."""
116
+ ps = self.p_lst
117
+ if len(ps) > 1:
118
+ return False
119
+
120
+ if not ps:
121
+ raise InvalidXmlError("p:txBody must have at least one a:p")
122
+
123
+ if ps[0].text != "":
124
+ return False
125
+ return True
126
+
127
+ @classmethod
128
+ def new(cls):
129
+ """Return a new `p:txBody` element tree."""
130
+ xml = cls._txBody_tmpl()
131
+ txBody = parse_xml(xml)
132
+ return txBody
133
+
134
+ @classmethod
135
+ def new_a_txBody(cls) -> CT_TextBody:
136
+ """Return a new `a:txBody` element tree.
137
+
138
+ Suitable for use in a table cell and possibly other situations.
139
+ """
140
+ xml = cls._a_txBody_tmpl()
141
+ txBody = cast(CT_TextBody, parse_xml(xml))
142
+ return txBody
143
+
144
+ @classmethod
145
+ def new_p_txBody(cls):
146
+ """Return a new `p:txBody` element tree, suitable for use in an `p:sp` element."""
147
+ xml = cls._p_txBody_tmpl()
148
+ return parse_xml(xml)
149
+
150
+ @classmethod
151
+ def new_txPr(cls):
152
+ """Return a `c:txPr` element tree.
153
+
154
+ Suitable for use in a chart object like data labels or tick labels.
155
+ """
156
+ xml = (
157
+ "<c:txPr %s>\n"
158
+ " <a:bodyPr/>\n"
159
+ " <a:lstStyle/>\n"
160
+ " <a:p>\n"
161
+ " <a:pPr>\n"
162
+ " <a:defRPr/>\n"
163
+ " </a:pPr>\n"
164
+ " </a:p>\n"
165
+ "</c:txPr>\n"
166
+ ) % nsdecls("c", "a")
167
+ txPr = parse_xml(xml)
168
+ return txPr
169
+
170
+ def unclear_content(self):
171
+ """Ensure p:txBody has at least one a:p child.
172
+
173
+ Intuitively, reverse a ".clear_content()" operation to minimum conformance with spec
174
+ (single empty paragraph).
175
+ """
176
+ if len(self.p_lst) > 0:
177
+ return
178
+ self.add_p()
179
+
180
+ @classmethod
181
+ def _a_txBody_tmpl(cls):
182
+ return "<a:txBody %s>\n" " <a:bodyPr/>\n" " <a:p/>\n" "</a:txBody>\n" % (nsdecls("a"))
183
+
184
+ @classmethod
185
+ def _p_txBody_tmpl(cls):
186
+ return (
187
+ "<p:txBody %s>\n" " <a:bodyPr/>\n" " <a:p/>\n" "</p:txBody>\n" % (nsdecls("p", "a"))
188
+ )
189
+
190
+ @classmethod
191
+ def _txBody_tmpl(cls):
192
+ return (
193
+ "<p:txBody %s>\n"
194
+ " <a:bodyPr/>\n"
195
+ " <a:lstStyle/>\n"
196
+ " <a:p/>\n"
197
+ "</p:txBody>\n" % (nsdecls("a", "p"))
198
+ )
199
+
200
+
201
+ class CT_TextBodyProperties(BaseOxmlElement):
202
+ """`a:bodyPr` custom element class."""
203
+
204
+ _add_noAutofit: Callable[[], BaseOxmlElement]
205
+ _add_normAutofit: Callable[[], CT_TextNormalAutofit]
206
+ _add_spAutoFit: Callable[[], BaseOxmlElement]
207
+ _remove_eg_textAutoFit: Callable[[], None]
208
+
209
+ noAutofit: BaseOxmlElement | None
210
+ normAutofit: CT_TextNormalAutofit | None
211
+ spAutoFit: BaseOxmlElement | None
212
+
213
+ eg_textAutoFit = ZeroOrOneChoice(
214
+ (Choice("a:noAutofit"), Choice("a:normAutofit"), Choice("a:spAutoFit")),
215
+ successors=("a:scene3d", "a:sp3d", "a:flatTx", "a:extLst"),
216
+ )
217
+ lIns: Length = OptionalAttribute( # pyright: ignore[reportAssignmentType]
218
+ "lIns", ST_Coordinate32, default=Emu(91440)
219
+ )
220
+ tIns: Length = OptionalAttribute( # pyright: ignore[reportAssignmentType]
221
+ "tIns", ST_Coordinate32, default=Emu(45720)
222
+ )
223
+ rIns: Length = OptionalAttribute( # pyright: ignore[reportAssignmentType]
224
+ "rIns", ST_Coordinate32, default=Emu(91440)
225
+ )
226
+ bIns: Length = OptionalAttribute( # pyright: ignore[reportAssignmentType]
227
+ "bIns", ST_Coordinate32, default=Emu(45720)
228
+ )
229
+ anchor: MSO_VERTICAL_ANCHOR | None = OptionalAttribute( # pyright: ignore[reportAssignmentType]
230
+ "anchor", MSO_VERTICAL_ANCHOR
231
+ )
232
+ wrap: str | None = OptionalAttribute( # pyright: ignore[reportAssignmentType]
233
+ "wrap", ST_TextWrappingType
234
+ )
235
+
236
+ @property
237
+ def autofit(self):
238
+ """The autofit setting for the text frame, a member of the `MSO_AUTO_SIZE` enumeration."""
239
+ if self.noAutofit is not None:
240
+ return MSO_AUTO_SIZE.NONE
241
+ if self.normAutofit is not None:
242
+ return MSO_AUTO_SIZE.TEXT_TO_FIT_SHAPE
243
+ if self.spAutoFit is not None:
244
+ return MSO_AUTO_SIZE.SHAPE_TO_FIT_TEXT
245
+ return None
246
+
247
+ @autofit.setter
248
+ def autofit(self, value: MSO_AUTO_SIZE | None):
249
+ if value is not None and value not in MSO_AUTO_SIZE:
250
+ raise ValueError(
251
+ f"only None or a member of the MSO_AUTO_SIZE enumeration can be assigned to"
252
+ f" CT_TextBodyProperties.autofit, got {value}"
253
+ )
254
+ self._remove_eg_textAutoFit()
255
+ if value == MSO_AUTO_SIZE.NONE:
256
+ self._add_noAutofit()
257
+ elif value == MSO_AUTO_SIZE.TEXT_TO_FIT_SHAPE:
258
+ self._add_normAutofit()
259
+ elif value == MSO_AUTO_SIZE.SHAPE_TO_FIT_TEXT:
260
+ self._add_spAutoFit()
261
+
262
+
263
+ class CT_TextCharacterProperties(BaseOxmlElement):
264
+ """Custom element class for `a:rPr`, `a:defRPr`, and `a:endParaRPr`.
265
+
266
+ 'rPr' is short for 'run properties', and it corresponds to the |Font| proxy class.
267
+ """
268
+
269
+ get_or_add_hlinkClick: Callable[[], CT_Hyperlink]
270
+ get_or_add_latin: Callable[[], CT_TextFont]
271
+ _remove_latin: Callable[[], None]
272
+ _remove_hlinkClick: Callable[[], None]
273
+
274
+ eg_fillProperties = ZeroOrOneChoice(
275
+ (
276
+ Choice("a:noFill"),
277
+ Choice("a:solidFill"),
278
+ Choice("a:gradFill"),
279
+ Choice("a:blipFill"),
280
+ Choice("a:pattFill"),
281
+ Choice("a:grpFill"),
282
+ ),
283
+ successors=(
284
+ "a:effectLst",
285
+ "a:effectDag",
286
+ "a:highlight",
287
+ "a:uLnTx",
288
+ "a:uLn",
289
+ "a:uFillTx",
290
+ "a:uFill",
291
+ "a:latin",
292
+ "a:ea",
293
+ "a:cs",
294
+ "a:sym",
295
+ "a:hlinkClick",
296
+ "a:hlinkMouseOver",
297
+ "a:rtl",
298
+ "a:extLst",
299
+ ),
300
+ )
301
+ latin: CT_TextFont | None = ZeroOrOne( # pyright: ignore[reportAssignmentType]
302
+ "a:latin",
303
+ successors=(
304
+ "a:ea",
305
+ "a:cs",
306
+ "a:sym",
307
+ "a:hlinkClick",
308
+ "a:hlinkMouseOver",
309
+ "a:rtl",
310
+ "a:extLst",
311
+ ),
312
+ )
313
+ hlinkClick: CT_Hyperlink | None = ZeroOrOne( # pyright: ignore[reportAssignmentType]
314
+ "a:hlinkClick", successors=("a:hlinkMouseOver", "a:rtl", "a:extLst")
315
+ )
316
+
317
+ lang: MSO_LANGUAGE_ID | None = OptionalAttribute( # pyright: ignore[reportAssignmentType]
318
+ "lang", MSO_LANGUAGE_ID
319
+ )
320
+ sz: int | None = OptionalAttribute( # pyright: ignore[reportAssignmentType]
321
+ "sz", ST_TextFontSize
322
+ )
323
+ b: bool | None = OptionalAttribute("b", XsdBoolean) # pyright: ignore[reportAssignmentType]
324
+ i: bool | None = OptionalAttribute("i", XsdBoolean) # pyright: ignore[reportAssignmentType]
325
+ u: MSO_TEXT_UNDERLINE_TYPE | None = OptionalAttribute( # pyright: ignore[reportAssignmentType]
326
+ "u", MSO_TEXT_UNDERLINE_TYPE
327
+ )
328
+
329
+ def _new_gradFill(self):
330
+ return CT_GradientFillProperties.new_gradFill()
331
+
332
+ def add_hlinkClick(self, rId: str) -> CT_Hyperlink:
333
+ """Add an `a:hlinkClick` child element with r:id attribute set to `rId`."""
334
+ hlinkClick = self.get_or_add_hlinkClick()
335
+ hlinkClick.rId = rId
336
+ return hlinkClick
337
+
338
+
339
+ class CT_TextField(BaseOxmlElement):
340
+ """`a:fld` field element, for either a slide number or date field."""
341
+
342
+ get_or_add_rPr: Callable[[], CT_TextCharacterProperties]
343
+
344
+ rPr: CT_TextCharacterProperties | None = ZeroOrOne( # pyright: ignore[reportAssignmentType]
345
+ "a:rPr", successors=("a:pPr", "a:t")
346
+ )
347
+ t: BaseOxmlElement | None = ZeroOrOne( # pyright: ignore[reportAssignmentType]
348
+ "a:t", successors=()
349
+ )
350
+
351
+ @property
352
+ def text(self) -> str: # pyright: ignore[reportIncompatibleMethodOverride]
353
+ """The text of the `a:t` child element."""
354
+ t = self.t
355
+ if t is None:
356
+ return ""
357
+ return t.text or ""
358
+
359
+
360
+ class CT_TextFont(BaseOxmlElement):
361
+ """Custom element class for `a:latin`, `a:ea`, `a:cs`, and `a:sym`.
362
+
363
+ These occur as child elements of CT_TextCharacterProperties, e.g. `a:rPr`.
364
+ """
365
+
366
+ typeface: str = RequiredAttribute( # pyright: ignore[reportAssignmentType]
367
+ "typeface", ST_TextTypeface
368
+ )
369
+
370
+
371
+ class CT_TextLineBreak(BaseOxmlElement):
372
+ """`a:br` line break element"""
373
+
374
+ get_or_add_rPr: Callable[[], CT_TextCharacterProperties]
375
+
376
+ rPr = ZeroOrOne("a:rPr", successors=())
377
+
378
+ @property
379
+ def text(self): # pyright: ignore[reportIncompatibleMethodOverride]
380
+ """Unconditionally a single vertical-tab character.
381
+
382
+ A line break element can contain no text other than the implicit line feed it
383
+ represents.
384
+ """
385
+ return "\v"
386
+
387
+
388
+ class CT_TextNormalAutofit(BaseOxmlElement):
389
+ """`a:normAutofit` element specifying fit text to shape font reduction, etc."""
390
+
391
+ fontScale = OptionalAttribute(
392
+ "fontScale", ST_TextFontScalePercentOrPercentString, default=100.0
393
+ )
394
+
395
+
396
+ class CT_TextParagraph(BaseOxmlElement):
397
+ """`a:p` custom element class"""
398
+
399
+ get_or_add_endParaRPr: Callable[[], CT_TextCharacterProperties]
400
+ get_or_add_pPr: Callable[[], CT_TextParagraphProperties]
401
+ r_lst: list[CT_RegularTextRun]
402
+ _add_br: Callable[[], CT_TextLineBreak]
403
+ _add_r: Callable[[], CT_RegularTextRun]
404
+
405
+ pPr: CT_TextParagraphProperties | None = ZeroOrOne( # pyright: ignore[reportAssignmentType]
406
+ "a:pPr", successors=("a:r", "a:br", "a:fld", "a:endParaRPr")
407
+ )
408
+ r = ZeroOrMore("a:r", successors=("a:endParaRPr",))
409
+ br = ZeroOrMore("a:br", successors=("a:endParaRPr",))
410
+ endParaRPr: CT_TextCharacterProperties | None = ZeroOrOne(
411
+ "a:endParaRPr", successors=()
412
+ ) # pyright: ignore[reportAssignmentType]
413
+
414
+ def add_br(self) -> CT_TextLineBreak:
415
+ """Return a newly appended `a:br` element."""
416
+ return self._add_br()
417
+
418
+ def add_r(self, text: str | None = None) -> CT_RegularTextRun:
419
+ """Return a newly appended `a:r` element."""
420
+ r = self._add_r()
421
+ if text:
422
+ r.text = text
423
+ return r
424
+
425
+ def append_text(self, text: str):
426
+ """Append `a:r` and `a:br` elements to `p` based on `text`.
427
+
428
+ Any `\n` or `\v` (vertical-tab) characters in `text` delimit `a:r` (run) elements and
429
+ themselves are translated to `a:br` (line-break) elements. The vertical-tab character
430
+ appears in clipboard text from PowerPoint at "soft" line-breaks (new-line, but not new
431
+ paragraph).
432
+ """
433
+ for idx, r_str in enumerate(re.split("\n|\v", text)):
434
+ # ---breaks are only added _between_ items, not at start---
435
+ if idx > 0:
436
+ self.add_br()
437
+ # ---runs that would be empty are not added---
438
+ if r_str:
439
+ self.add_r(r_str)
440
+
441
+ @property
442
+ def content_children(self) -> tuple[CT_RegularTextRun | CT_TextLineBreak | CT_TextField, ...]:
443
+ """Sequence containing text-container child elements of this `a:p` element.
444
+
445
+ These include `a:r`, `a:br`, and `a:fld`.
446
+ """
447
+ return tuple(
448
+ e for e in self if isinstance(e, (CT_RegularTextRun, CT_TextLineBreak, CT_TextField))
449
+ )
450
+
451
+ @property
452
+ def text(self) -> str: # pyright: ignore[reportIncompatibleMethodOverride]
453
+ """str text contained in this paragraph."""
454
+ # ---note this shadows the lxml _Element.text---
455
+ return "".join([child.text for child in self.content_children])
456
+
457
+ def _new_r(self):
458
+ r_xml = "<a:r %s><a:t/></a:r>" % nsdecls("a")
459
+ return parse_xml(r_xml)
460
+
461
+
462
+ class CT_TextParagraphProperties(BaseOxmlElement):
463
+ """`a:pPr` custom element class."""
464
+
465
+ get_or_add_defRPr: Callable[[], CT_TextCharacterProperties]
466
+ _add_lnSpc: Callable[[], CT_TextSpacing]
467
+ _add_spcAft: Callable[[], CT_TextSpacing]
468
+ _add_spcBef: Callable[[], CT_TextSpacing]
469
+ _remove_lnSpc: Callable[[], None]
470
+ _remove_spcAft: Callable[[], None]
471
+ _remove_spcBef: Callable[[], None]
472
+
473
+ _tag_seq = (
474
+ "a:lnSpc",
475
+ "a:spcBef",
476
+ "a:spcAft",
477
+ "a:buClrTx",
478
+ "a:buClr",
479
+ "a:buSzTx",
480
+ "a:buSzPct",
481
+ "a:buSzPts",
482
+ "a:buFontTx",
483
+ "a:buFont",
484
+ "a:buNone",
485
+ "a:buAutoNum",
486
+ "a:buChar",
487
+ "a:buBlip",
488
+ "a:tabLst",
489
+ "a:defRPr",
490
+ "a:extLst",
491
+ )
492
+ lnSpc: CT_TextSpacing | None = ZeroOrOne( # pyright: ignore[reportAssignmentType]
493
+ "a:lnSpc", successors=_tag_seq[1:]
494
+ )
495
+ spcBef: CT_TextSpacing | None = ZeroOrOne( # pyright: ignore[reportAssignmentType]
496
+ "a:spcBef", successors=_tag_seq[2:]
497
+ )
498
+ spcAft: CT_TextSpacing | None = ZeroOrOne( # pyright: ignore[reportAssignmentType]
499
+ "a:spcAft", successors=_tag_seq[3:]
500
+ )
501
+ defRPr: CT_TextCharacterProperties | None = ZeroOrOne( # pyright: ignore[reportAssignmentType]
502
+ "a:defRPr", successors=_tag_seq[16:]
503
+ )
504
+ lvl: int = OptionalAttribute( # pyright: ignore[reportAssignmentType]
505
+ "lvl", ST_TextIndentLevelType, default=0
506
+ )
507
+ algn: PP_PARAGRAPH_ALIGNMENT | None = OptionalAttribute(
508
+ "algn", PP_PARAGRAPH_ALIGNMENT
509
+ ) # pyright: ignore[reportAssignmentType]
510
+ del _tag_seq
511
+
512
+ @property
513
+ def line_spacing(self) -> float | Length | None:
514
+ """The spacing between baselines of successive lines in this paragraph.
515
+
516
+ A float value indicates a number of lines. A |Length| value indicates a fixed spacing.
517
+ Value is contained in `./a:lnSpc/a:spcPts/@val` or `./a:lnSpc/a:spcPct/@val`. Value is
518
+ |None| if no element is present.
519
+ """
520
+ lnSpc = self.lnSpc
521
+ if lnSpc is None:
522
+ return None
523
+ if lnSpc.spcPts is not None:
524
+ return lnSpc.spcPts.val
525
+ return cast(CT_TextSpacingPercent, lnSpc.spcPct).val
526
+
527
+ @line_spacing.setter
528
+ def line_spacing(self, value: float | Length | None):
529
+ self._remove_lnSpc()
530
+ if value is None:
531
+ return
532
+ if isinstance(value, Length):
533
+ self._add_lnSpc().set_spcPts(value)
534
+ else:
535
+ self._add_lnSpc().set_spcPct(value)
536
+
537
+ @property
538
+ def space_after(self) -> Length | None:
539
+ """The EMU equivalent of the centipoints value in `./a:spcAft/a:spcPts/@val`."""
540
+ spcAft = self.spcAft
541
+ if spcAft is None:
542
+ return None
543
+ spcPts = spcAft.spcPts
544
+ if spcPts is None:
545
+ return None
546
+ return spcPts.val
547
+
548
+ @space_after.setter
549
+ def space_after(self, value: Length | None):
550
+ self._remove_spcAft()
551
+ if value is not None:
552
+ self._add_spcAft().set_spcPts(value)
553
+
554
+ @property
555
+ def space_before(self):
556
+ """The EMU equivalent of the centipoints value in `./a:spcBef/a:spcPts/@val`."""
557
+ spcBef = self.spcBef
558
+ if spcBef is None:
559
+ return None
560
+ spcPts = spcBef.spcPts
561
+ if spcPts is None:
562
+ return None
563
+ return spcPts.val
564
+
565
+ @space_before.setter
566
+ def space_before(self, value: Length | None):
567
+ self._remove_spcBef()
568
+ if value is not None:
569
+ self._add_spcBef().set_spcPts(value)
570
+
571
+
572
+ class CT_TextSpacing(BaseOxmlElement):
573
+ """Used for `a:lnSpc`, `a:spcBef`, and `a:spcAft` elements."""
574
+
575
+ get_or_add_spcPct: Callable[[], CT_TextSpacingPercent]
576
+ get_or_add_spcPts: Callable[[], CT_TextSpacingPoint]
577
+ _remove_spcPct: Callable[[], None]
578
+ _remove_spcPts: Callable[[], None]
579
+
580
+ # this should actually be a OneAndOnlyOneChoice, but that's not
581
+ # implemented yet.
582
+ spcPct: CT_TextSpacingPercent | None = ZeroOrOne( # pyright: ignore[reportAssignmentType]
583
+ "a:spcPct"
584
+ )
585
+ spcPts: CT_TextSpacingPoint | None = ZeroOrOne( # pyright: ignore[reportAssignmentType]
586
+ "a:spcPts"
587
+ )
588
+
589
+ def set_spcPct(self, value: float):
590
+ """Set spacing to `value` lines, e.g. 1.75 lines.
591
+
592
+ A ./a:spcPts child is removed if present.
593
+ """
594
+ self._remove_spcPts()
595
+ spcPct = self.get_or_add_spcPct()
596
+ spcPct.val = value
597
+
598
+ def set_spcPts(self, value: Length):
599
+ """Set spacing to `value` points. A ./a:spcPct child is removed if present."""
600
+ self._remove_spcPct()
601
+ spcPts = self.get_or_add_spcPts()
602
+ spcPts.val = value
603
+
604
+
605
+ class CT_TextSpacingPercent(BaseOxmlElement):
606
+ """`a:spcPct` element, specifying spacing in thousandths of a percent in its `val` attribute."""
607
+
608
+ val: float = RequiredAttribute( # pyright: ignore[reportAssignmentType]
609
+ "val", ST_TextSpacingPercentOrPercentString
610
+ )
611
+
612
+
613
+ class CT_TextSpacingPoint(BaseOxmlElement):
614
+ """`a:spcPts` element, specifying spacing in centipoints in its `val` attribute."""
615
+
616
+ val: Length = RequiredAttribute( # pyright: ignore[reportAssignmentType]
617
+ "val", ST_TextSpacingPoint
618
+ )
tasks/tasksmith-74f059424102/environment/source/src/pptx/oxml/theme.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """lxml custom element classes for theme-related XML elements."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from . import parse_from_template
6
+ from .xmlchemy import BaseOxmlElement
7
+
8
+
9
+ class CT_OfficeStyleSheet(BaseOxmlElement):
10
+ """
11
+ ``<a:theme>`` element, root of a theme part
12
+ """
13
+
14
+ _tag_seq = (
15
+ "a:themeElements",
16
+ "a:objectDefaults",
17
+ "a:extraClrSchemeLst",
18
+ "a:custClrLst",
19
+ "a:extLst",
20
+ )
21
+ del _tag_seq
22
+
23
+ @classmethod
24
+ def new_default(cls):
25
+ """
26
+ Return a new ``<a:theme>`` element containing default settings
27
+ suitable for use with a notes master.
28
+ """
29
+ return parse_from_template("theme")
tasks/tasksmith-74f059424102/environment/source/src/pptx/oxml/xmlchemy.py ADDED
@@ -0,0 +1,717 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Base and meta classes enabling declarative definition of custom element classes."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re
6
+ from typing import Any, Callable, Iterable, Protocol, Sequence, Type, cast
7
+
8
+ from lxml import etree
9
+ from lxml.etree import ElementBase, _Element # pyright: ignore[reportPrivateUsage]
10
+
11
+ from pptx.exc import InvalidXmlError
12
+ from pptx.oxml import oxml_parser
13
+ from pptx.oxml.ns import NamespacePrefixedTag, _nsmap, qn # pyright: ignore[reportPrivateUsage]
14
+ from pptx.util import lazyproperty
15
+
16
+
17
+ class AttributeType(Protocol):
18
+ """Interface for an object that can act as an attribute type.
19
+
20
+ An attribute-type specifies how values are transformed to and from the XML "string" value of the
21
+ attribute.
22
+ """
23
+
24
+ @classmethod
25
+ def from_xml(cls, xml_value: str) -> Any:
26
+ """Transform an attribute value to a Python value."""
27
+ ...
28
+
29
+ @classmethod
30
+ def to_xml(cls, value: Any) -> str:
31
+ """Transform a Python value to a str value suitable to this XML attribute."""
32
+ ...
33
+
34
+
35
+ def OxmlElement(nsptag_str: str, nsmap: dict[str, str] | None = None) -> BaseOxmlElement:
36
+ """Return a "loose" lxml element having the tag specified by `nsptag_str`.
37
+
38
+ `nsptag_str` must contain the standard namespace prefix, e.g. 'a:tbl'. The resulting element is
39
+ an instance of the custom element class for this tag name if one is defined.
40
+ """
41
+ nsptag = NamespacePrefixedTag(nsptag_str)
42
+ nsmap = nsmap if nsmap is not None else nsptag.nsmap
43
+ return oxml_parser.makeelement(nsptag.clark_name, nsmap=nsmap)
44
+
45
+
46
+ def serialize_for_reading(element: ElementBase):
47
+ """
48
+ Serialize *element* to human-readable XML suitable for tests. No XML
49
+ declaration.
50
+ """
51
+ xml = etree.tostring(element, encoding="unicode", pretty_print=True)
52
+ return XmlString(xml)
53
+
54
+
55
+ class XmlString(str):
56
+ """Provides string comparison override suitable for serialized XML; useful for tests."""
57
+
58
+ # ' <w:xyz xmlns:a="http://ns/decl/a" attr_name="val">text</w:xyz>'
59
+ # | | || |
60
+ # +----------+------------------------------------------++-----------+
61
+ # front attrs | text
62
+ # close
63
+
64
+ _xml_elm_line_patt = re.compile(r"( *</?[\w:]+)(.*?)(/?>)([^<]*</[\w:]+>)?")
65
+
66
+ def __eq__(self, other: object) -> bool:
67
+ if not isinstance(other, str):
68
+ return False
69
+ lines = self.splitlines()
70
+ lines_other = other.splitlines()
71
+ if len(lines) != len(lines_other):
72
+ return False
73
+ for line, line_other in zip(lines, lines_other):
74
+ if not self._eq_elm_strs(line, line_other):
75
+ return False
76
+ return True
77
+
78
+ def __ne__(self, other: object) -> bool:
79
+ return not self.__eq__(other)
80
+
81
+ def _attr_seq(self, attrs: str) -> list[str]:
82
+ """Return a sequence of attribute strings parsed from *attrs*.
83
+
84
+ Each attribute string is stripped of whitespace on both ends.
85
+ """
86
+ attrs = attrs.strip()
87
+ attr_lst = attrs.split()
88
+ return sorted(attr_lst)
89
+
90
+ def _eq_elm_strs(self, line: str, line_2: str) -> bool:
91
+ """True if the element in `line_2` is XML-equivalent to the element in `line`.
92
+
93
+ In particular, the order of attributes in XML is not significant.
94
+ """
95
+ front, attrs, close, text = self._parse_line(line)
96
+ front_2, attrs_2, close_2, text_2 = self._parse_line(line_2)
97
+ if front != front_2:
98
+ return False
99
+ if self._attr_seq(attrs) != self._attr_seq(attrs_2):
100
+ return False
101
+ if close != close_2:
102
+ return False
103
+ if text != text_2:
104
+ return False
105
+ return True
106
+
107
+ def _parse_line(self, line: str):
108
+ """Return front, attrs, close, text 4-tuple result of parsing XML element string `line`."""
109
+ match = self._xml_elm_line_patt.match(line)
110
+ if match is None:
111
+ raise ValueError("`line` does not match pattern for an XML element")
112
+ front, attrs, close, text = [match.group(n) for n in range(1, 5)]
113
+ return front, attrs, close, text
114
+
115
+
116
+ class MetaOxmlElement(type):
117
+ """Metaclass for BaseOxmlElement."""
118
+
119
+ def __init__(cls, clsname: str, bases: tuple[type, ...], clsdict: dict[str, Any]):
120
+ dispatchable = (
121
+ OneAndOnlyOne,
122
+ OneOrMore,
123
+ OptionalAttribute,
124
+ RequiredAttribute,
125
+ ZeroOrMore,
126
+ ZeroOrOne,
127
+ ZeroOrOneChoice,
128
+ )
129
+ for key, value in clsdict.items():
130
+ if isinstance(value, dispatchable):
131
+ value.populate_class_members(cls, key)
132
+
133
+
134
+ class BaseAttribute:
135
+ """Base class for OptionalAttribute and RequiredAttribute, providing common methods."""
136
+
137
+ def __init__(self, attr_name: str, simple_type: type[AttributeType]):
138
+ self._attr_name = attr_name
139
+ self._simple_type = simple_type
140
+
141
+ def populate_class_members(self, element_cls: Type[BaseOxmlElement], prop_name: str):
142
+ """
143
+ Add the appropriate methods to *element_cls*.
144
+ """
145
+ self._element_cls = element_cls
146
+ self._prop_name = prop_name
147
+
148
+ self._add_attr_property()
149
+
150
+ def _add_attr_property(self):
151
+ """Add a read/write `{prop_name}` property to the element class.
152
+
153
+ The property returns the interpreted value of this attribute on access and changes the
154
+ attribute value to its ST_* counterpart on assignment.
155
+ """
156
+ property_ = property(self._getter, self._setter, None)
157
+ # assign unconditionally to overwrite element name definition
158
+ setattr(self._element_cls, self._prop_name, property_)
159
+
160
+ @property
161
+ def _clark_name(self):
162
+ if ":" in self._attr_name:
163
+ return qn(self._attr_name)
164
+ return self._attr_name
165
+
166
+ @property
167
+ def _getter(self) -> Callable[[BaseOxmlElement], Any]:
168
+ """Callable suitable for the "get" side of the attribute property descriptor."""
169
+ raise NotImplementedError("must be implemented by each subclass")
170
+
171
+ @property
172
+ def _setter(self) -> Callable[[BaseOxmlElement, Any], None]:
173
+ """Callable suitable for the "set" side of the attribute property descriptor."""
174
+ raise NotImplementedError("must be implemented by each subclass")
175
+
176
+
177
+ class OptionalAttribute(BaseAttribute):
178
+ """Defines an optional attribute on a custom element class.
179
+
180
+ An optional attribute returns a default value when not present for reading. When assigned
181
+ |None|, the attribute is removed.
182
+ """
183
+
184
+ def __init__(self, attr_name: str, simple_type: type[AttributeType], default: Any = None):
185
+ super(OptionalAttribute, self).__init__(attr_name, simple_type)
186
+ self._default = default
187
+
188
+ @property
189
+ def _docstring(self):
190
+ """
191
+ Return the string to use as the ``__doc__`` attribute of the property
192
+ for this attribute.
193
+ """
194
+ return (
195
+ "%s type-converted value of ``%s`` attribute, or |None| (or spec"
196
+ "ified default value) if not present. Assigning the default valu"
197
+ "e causes the attribute to be removed from the element."
198
+ % (self._simple_type.__name__, self._attr_name)
199
+ )
200
+
201
+ @property
202
+ def _getter(self) -> Callable[[BaseOxmlElement], Any]:
203
+ """Callable suitable for the "get" side of the attribute property descriptor."""
204
+
205
+ def get_attr_value(obj: BaseOxmlElement) -> Any:
206
+ attr_str_value = obj.get(self._clark_name)
207
+ if attr_str_value is None:
208
+ return self._default
209
+ return self._simple_type.from_xml(attr_str_value)
210
+
211
+ get_attr_value.__doc__ = self._docstring
212
+ return get_attr_value
213
+
214
+ @property
215
+ def _setter(self) -> Callable[[BaseOxmlElement, Any], None]:
216
+ """Callable suitable for the "set" side of the attribute property descriptor."""
217
+
218
+ def set_attr_value(obj: BaseOxmlElement, value: Any) -> None:
219
+ # -- when an XML attribute has a default value, setting it to that default removes the
220
+ # -- attribute from the element (when it is present)
221
+ if value == self._default:
222
+ if self._clark_name in obj.attrib:
223
+ del obj.attrib[self._clark_name]
224
+ return
225
+ str_value = self._simple_type.to_xml(value)
226
+ obj.set(self._clark_name, str_value)
227
+
228
+ return set_attr_value
229
+
230
+
231
+ class RequiredAttribute(BaseAttribute):
232
+ """Defines a required attribute on a custom element class.
233
+
234
+ A required attribute is assumed to be present for reading, so does not have a default value;
235
+ its actual value is always used. If missing on read, an |InvalidXmlError| is raised. It also
236
+ does not remove the attribute if |None| is assigned. Assigning |None| raises |TypeError| or
237
+ |ValueError|, depending on the simple type of the attribute.
238
+ """
239
+
240
+ @property
241
+ def _getter(self) -> Callable[[BaseOxmlElement], Any]:
242
+ """Callable suitable for the "get" side of the attribute property descriptor."""
243
+
244
+ def get_attr_value(obj: BaseOxmlElement) -> Any:
245
+ attr_str_value = obj.get(self._clark_name)
246
+ if attr_str_value is None:
247
+ raise InvalidXmlError(
248
+ "required '%s' attribute not present on element %s" % (self._attr_name, obj.tag)
249
+ )
250
+ return self._simple_type.from_xml(attr_str_value)
251
+
252
+ get_attr_value.__doc__ = self._docstring
253
+ return get_attr_value
254
+
255
+ @property
256
+ def _docstring(self):
257
+ """
258
+ Return the string to use as the ``__doc__`` attribute of the property
259
+ for this attribute.
260
+ """
261
+ return "%s type-converted value of ``%s`` attribute." % (
262
+ self._simple_type.__name__,
263
+ self._attr_name,
264
+ )
265
+
266
+ @property
267
+ def _setter(self) -> Callable[[BaseOxmlElement, Any], None]:
268
+ """Callable suitable for the "set" side of the attribute property descriptor."""
269
+
270
+ def set_attr_value(obj: BaseOxmlElement, value: Any) -> None:
271
+ str_value = self._simple_type.to_xml(value)
272
+ obj.set(self._clark_name, str_value)
273
+
274
+ return set_attr_value
275
+
276
+
277
+ class _BaseChildElement:
278
+ """Base class for the child element classes corresponding to varying cardinalities.
279
+
280
+ Subclasses include ZeroOrOne and ZeroOrMore.
281
+ """
282
+
283
+ def __init__(self, nsptagname: str, successors: Sequence[str] = ()):
284
+ super(_BaseChildElement, self).__init__()
285
+ self._nsptagname = nsptagname
286
+ self._successors = successors
287
+
288
+ def populate_class_members(self, element_cls: Type[BaseOxmlElement], prop_name: str):
289
+ """Baseline behavior for adding the appropriate methods to `element_cls`."""
290
+ self._element_cls = element_cls
291
+ self._prop_name = prop_name
292
+
293
+ def _add_adder(self):
294
+ """Add an ``_add_x()`` method to the element class for this child element."""
295
+
296
+ def _add_child(obj: BaseOxmlElement, **attrs: Any):
297
+ new_method = getattr(obj, self._new_method_name)
298
+ child = new_method()
299
+ for key, value in attrs.items():
300
+ setattr(child, key, value)
301
+ insert_method = getattr(obj, self._insert_method_name)
302
+ insert_method(child)
303
+ return child
304
+
305
+ _add_child.__doc__ = (
306
+ "Add a new ``<%s>`` child element unconditionally, inserted in t"
307
+ "he correct sequence." % self._nsptagname
308
+ )
309
+ self._add_to_class(self._add_method_name, _add_child)
310
+
311
+ def _add_creator(self):
312
+ """Add a `_new_{prop_name}()` method to the element class.
313
+
314
+ This method creates a new, empty element of the correct type, having no attributes.
315
+ """
316
+ creator = self._creator
317
+ creator.__doc__ = (
318
+ 'Return a "loose", newly created ``<%s>`` element having no attri'
319
+ "butes, text, or children." % self._nsptagname
320
+ )
321
+ self._add_to_class(self._new_method_name, creator)
322
+
323
+ def _add_getter(self):
324
+ """Add a read-only `{prop_name}` property to the parent element class.
325
+
326
+ The property locates and returns this child element or `None` if not present.
327
+ """
328
+ property_ = property(self._getter, None, None)
329
+ # assign unconditionally to overwrite element name definition
330
+ setattr(self._element_cls, self._prop_name, property_)
331
+
332
+ def _add_inserter(self):
333
+ """Add an ``_insert_x()`` method to the element class for this child element."""
334
+
335
+ def _insert_child(obj: BaseOxmlElement, child: BaseOxmlElement):
336
+ obj.insert_element_before(child, *self._successors)
337
+ return child
338
+
339
+ _insert_child.__doc__ = (
340
+ "Return the passed ``<%s>`` element after inserting it as a chil"
341
+ "d in the correct sequence." % self._nsptagname
342
+ )
343
+ self._add_to_class(self._insert_method_name, _insert_child)
344
+
345
+ def _add_list_getter(self):
346
+ """
347
+ Add a read-only ``{prop_name}_lst`` property to the element class to
348
+ retrieve a list of child elements matching this type.
349
+ """
350
+ prop_name = f"{self._prop_name}_lst"
351
+ property_ = property(self._list_getter, None, None)
352
+ setattr(self._element_cls, prop_name, property_)
353
+
354
+ @lazyproperty
355
+ def _add_method_name(self):
356
+ return "_add_%s" % self._prop_name
357
+
358
+ def _add_to_class(self, name: str, method: Callable[..., Any]):
359
+ """Add `method` to the target class as `name`, unless `name` is already defined there."""
360
+ if hasattr(self._element_cls, name):
361
+ return
362
+ setattr(self._element_cls, name, method)
363
+
364
+ @property
365
+ def _creator(self) -> Callable[[BaseOxmlElement], BaseOxmlElement]:
366
+ """Callable that creates a new, empty element of the child type, having no attributes."""
367
+
368
+ def new_child_element(obj: BaseOxmlElement):
369
+ return OxmlElement(self._nsptagname)
370
+
371
+ return new_child_element
372
+
373
+ @property
374
+ def _getter(self) -> Callable[[BaseOxmlElement], BaseOxmlElement | None]:
375
+ """Callable suitable for the "get" side of the property descriptor.
376
+
377
+ This default getter returns the child element with matching tag name or |None| if not
378
+ present.
379
+ """
380
+
381
+ def get_child_element(obj: BaseOxmlElement) -> BaseOxmlElement | None:
382
+ return obj.find(qn(self._nsptagname))
383
+
384
+ get_child_element.__doc__ = (
385
+ "``<%s>`` child element or |None| if not present." % self._nsptagname
386
+ )
387
+ return get_child_element
388
+
389
+ @lazyproperty
390
+ def _insert_method_name(self):
391
+ return "_insert_%s" % self._prop_name
392
+
393
+ @property
394
+ def _list_getter(self) -> Callable[[BaseOxmlElement], list[BaseOxmlElement]]:
395
+ """Callable suitable for the "get" side of a list property descriptor."""
396
+
397
+ def get_child_element_list(obj: BaseOxmlElement) -> list[BaseOxmlElement]:
398
+ return cast("list[BaseOxmlElement]", obj.findall(qn(self._nsptagname)))
399
+
400
+ get_child_element_list.__doc__ = (
401
+ "A list containing each of the ``<%s>`` child elements, in the o"
402
+ "rder they appear." % self._nsptagname
403
+ )
404
+ return get_child_element_list
405
+
406
+ @lazyproperty
407
+ def _remove_method_name(self):
408
+ return "_remove_%s" % self._prop_name
409
+
410
+ @lazyproperty
411
+ def _new_method_name(self):
412
+ return "_new_%s" % self._prop_name
413
+
414
+
415
+ class Choice(_BaseChildElement):
416
+ """Defines a child element belonging to a group, only one of which may appear as a child."""
417
+
418
+ @property
419
+ def nsptagname(self):
420
+ return self._nsptagname
421
+
422
+ def populate_class_members( # pyright: ignore[reportIncompatibleMethodOverride]
423
+ self, element_cls: Type[BaseOxmlElement], group_prop_name: str, successors: Sequence[str]
424
+ ):
425
+ """Add the appropriate methods to `element_cls`."""
426
+ self._element_cls = element_cls
427
+ self._group_prop_name = group_prop_name
428
+ self._successors = successors
429
+
430
+ self._add_getter()
431
+ self._add_creator()
432
+ self._add_inserter()
433
+ self._add_adder()
434
+ self._add_get_or_change_to_method()
435
+
436
+ def _add_get_or_change_to_method(self) -> None:
437
+ """Add a `get_or_change_to_x()` method to the element class for this child element."""
438
+
439
+ def get_or_change_to_child(obj: BaseOxmlElement):
440
+ child = getattr(obj, self._prop_name)
441
+ if child is not None:
442
+ return child
443
+ remove_group_method = getattr(obj, self._remove_group_method_name)
444
+ remove_group_method()
445
+ add_method = getattr(obj, self._add_method_name)
446
+ child = add_method()
447
+ return child
448
+
449
+ get_or_change_to_child.__doc__ = (
450
+ "Return the ``<%s>`` child, replacing any other group element if" " found."
451
+ ) % self._nsptagname
452
+ self._add_to_class(self._get_or_change_to_method_name, get_or_change_to_child)
453
+
454
+ @property
455
+ def _prop_name(self):
456
+ """
457
+ Calculate property name from tag name, e.g. a:schemeClr -> schemeClr.
458
+ """
459
+ if ":" in self._nsptagname:
460
+ start = self._nsptagname.index(":") + 1
461
+ else:
462
+ start = 0
463
+ return self._nsptagname[start:]
464
+
465
+ @lazyproperty
466
+ def _get_or_change_to_method_name(self):
467
+ return "get_or_change_to_%s" % self._prop_name
468
+
469
+ @lazyproperty
470
+ def _remove_group_method_name(self):
471
+ return "_remove_%s" % self._group_prop_name
472
+
473
+
474
+ class OneAndOnlyOne(_BaseChildElement):
475
+ """Defines a required child element for MetaOxmlElement."""
476
+
477
+ def __init__(self, nsptagname: str):
478
+ super(OneAndOnlyOne, self).__init__(nsptagname, ())
479
+
480
+ def populate_class_members(self, element_cls: Type[BaseOxmlElement], prop_name: str):
481
+ """
482
+ Add the appropriate methods to *element_cls*.
483
+ """
484
+ super(OneAndOnlyOne, self).populate_class_members(element_cls, prop_name)
485
+ self._add_getter()
486
+
487
+ @property
488
+ def _getter(self) -> Callable[[BaseOxmlElement], BaseOxmlElement]:
489
+ """Callable suitable for the "get" side of the property descriptor."""
490
+
491
+ def get_child_element(obj: BaseOxmlElement) -> BaseOxmlElement:
492
+ child = obj.find(qn(self._nsptagname))
493
+ if child is None:
494
+ raise InvalidXmlError(
495
+ "required ``<%s>`` child element not present" % self._nsptagname
496
+ )
497
+ return child
498
+
499
+ get_child_element.__doc__ = "Required ``<%s>`` child element." % self._nsptagname
500
+ return get_child_element
501
+
502
+
503
+ class OneOrMore(_BaseChildElement):
504
+ """Defines a repeating child element for MetaOxmlElement that must appear at least once."""
505
+
506
+ def populate_class_members(self, element_cls: Type[BaseOxmlElement], prop_name: str):
507
+ """Add the appropriate methods to *element_cls*."""
508
+ super(OneOrMore, self).populate_class_members(element_cls, prop_name)
509
+ self._add_list_getter()
510
+ self._add_creator()
511
+ self._add_inserter()
512
+ self._add_adder()
513
+ self._add_public_adder()
514
+ delattr(element_cls, prop_name)
515
+
516
+ def _add_public_adder(self) -> None:
517
+ """Add a public `.add_x()` method to the parent element class."""
518
+
519
+ def add_child(obj: BaseOxmlElement) -> BaseOxmlElement:
520
+ private_add_method = getattr(obj, self._add_method_name)
521
+ child = private_add_method()
522
+ return child
523
+
524
+ add_child.__doc__ = (
525
+ "Add a new ``<%s>`` child element unconditionally, inserted in t"
526
+ "he correct sequence." % self._nsptagname
527
+ )
528
+ self._add_to_class(self._public_add_method_name, add_child)
529
+
530
+ @lazyproperty
531
+ def _public_add_method_name(self):
532
+ """
533
+ add_childElement() is public API for a repeating element, allowing
534
+ new elements to be added to the sequence. May be overridden to
535
+ provide a friendlier API to clients having domain appropriate
536
+ parameter names for required attributes.
537
+ """
538
+ return "add_%s" % self._prop_name
539
+
540
+
541
+ class ZeroOrMore(_BaseChildElement):
542
+ """
543
+ Defines an optional repeating child element for MetaOxmlElement.
544
+ """
545
+
546
+ def populate_class_members(self, element_cls: Type[BaseOxmlElement], prop_name: str):
547
+ """
548
+ Add the appropriate methods to *element_cls*.
549
+ """
550
+ super(ZeroOrMore, self).populate_class_members(element_cls, prop_name)
551
+ self._add_list_getter()
552
+ self._add_creator()
553
+ self._add_inserter()
554
+ self._add_adder()
555
+ delattr(element_cls, prop_name)
556
+
557
+
558
+ class ZeroOrOne(_BaseChildElement):
559
+ """Defines an optional child element for MetaOxmlElement."""
560
+
561
+ def populate_class_members(self, element_cls: Type[BaseOxmlElement], prop_name: str):
562
+ """Add the appropriate methods to `element_cls`."""
563
+ super(ZeroOrOne, self).populate_class_members(element_cls, prop_name)
564
+ self._add_getter()
565
+ self._add_creator()
566
+ self._add_inserter()
567
+ self._add_adder()
568
+ self._add_get_or_adder()
569
+ self._add_remover()
570
+
571
+ def _add_get_or_adder(self):
572
+ """Add a `.get_or_add_x()` method to the element class for this child element."""
573
+
574
+ def get_or_add_child(obj: BaseOxmlElement) -> BaseOxmlElement:
575
+ child = getattr(obj, self._prop_name)
576
+ if child is None:
577
+ add_method = getattr(obj, self._add_method_name)
578
+ child = add_method()
579
+ return child
580
+
581
+ get_or_add_child.__doc__ = (
582
+ "Return the ``<%s>`` child element, newly added if not present."
583
+ ) % self._nsptagname
584
+ self._add_to_class(self._get_or_add_method_name, get_or_add_child)
585
+
586
+ def _add_remover(self):
587
+ """Add a `._remove_x()` method to the element class for this child element."""
588
+
589
+ def _remove_child(obj: BaseOxmlElement) -> None:
590
+ obj.remove_all(self._nsptagname)
591
+
592
+ _remove_child.__doc__ = f"Remove all `{self._nsptagname}` child elements."
593
+ self._add_to_class(self._remove_method_name, _remove_child)
594
+
595
+ @lazyproperty
596
+ def _get_or_add_method_name(self):
597
+ return "get_or_add_%s" % self._prop_name
598
+
599
+
600
+ class ZeroOrOneChoice(_BaseChildElement):
601
+ """An `EG_*` element group where at most one of its members may appear as a child."""
602
+
603
+ def __init__(self, choices: Iterable[Choice], successors: Iterable[str] = ()):
604
+ self._choices = tuple(choices)
605
+ self._successors = tuple(successors)
606
+
607
+ def populate_class_members(self, element_cls: Type[BaseOxmlElement], prop_name: str):
608
+ """Add the appropriate methods to `element_cls`."""
609
+ super(ZeroOrOneChoice, self).populate_class_members(element_cls, prop_name)
610
+ self._add_choice_getter()
611
+ for choice in self._choices:
612
+ choice.populate_class_members(element_cls, self._prop_name, self._successors)
613
+ self._add_group_remover()
614
+
615
+ def _add_choice_getter(self):
616
+ """Add a read-only `.{prop_name}` property to the element class.
617
+
618
+ The property returns the present member of this group, or |None| if none are present.
619
+ """
620
+ property_ = property(self._choice_getter, None, None)
621
+ # assign unconditionally to overwrite element name definition
622
+ setattr(self._element_cls, self._prop_name, property_)
623
+
624
+ def _add_group_remover(self):
625
+ """Add a `._remove_eg_x()` method to the element class for this choice group."""
626
+
627
+ def _remove_choice_group(obj: BaseOxmlElement) -> None:
628
+ for tagname in self._member_nsptagnames:
629
+ obj.remove_all(tagname)
630
+
631
+ _remove_choice_group.__doc__ = "Remove the current choice group child element if present."
632
+ self._add_to_class(self._remove_choice_group_method_name, _remove_choice_group)
633
+
634
+ @property
635
+ def _choice_getter(self):
636
+ """
637
+ Return a function object suitable for the "get" side of the property
638
+ descriptor.
639
+ """
640
+
641
+ def get_group_member_element(obj: BaseOxmlElement) -> BaseOxmlElement | None:
642
+ return cast(
643
+ "BaseOxmlElement | None", obj.first_child_found_in(*self._member_nsptagnames)
644
+ )
645
+
646
+ get_group_member_element.__doc__ = (
647
+ "Return the child element belonging to this element group, or "
648
+ "|None| if no member child is present."
649
+ )
650
+ return get_group_member_element
651
+
652
+ @lazyproperty
653
+ def _member_nsptagnames(self) -> list[str]:
654
+ """Sequence of namespace-prefixed tagnames, one for each member element of choice group."""
655
+ return [choice.nsptagname for choice in self._choices]
656
+
657
+ @lazyproperty
658
+ def _remove_choice_group_method_name(self):
659
+ """Function-name for choice remover."""
660
+ return f"_remove_{self._prop_name}"
661
+
662
+
663
+ # -- lxml typing isn't quite right here, just ignore this error on _Element --
664
+ class BaseOxmlElement(etree.ElementBase, metaclass=MetaOxmlElement):
665
+ """Effective base class for all custom element classes.
666
+
667
+ Adds standardized behavior to all classes in one place.
668
+ """
669
+
670
+ def __repr__(self):
671
+ return "<%s '<%s>' at 0x%0x>" % (
672
+ self.__class__.__name__,
673
+ self._nsptag,
674
+ id(self),
675
+ )
676
+
677
+ def first_child_found_in(self, *tagnames: str) -> _Element | None:
678
+ """First child with tag in `tagnames`, or None if not found."""
679
+ for tagname in tagnames:
680
+ child = self.find(qn(tagname))
681
+ if child is not None:
682
+ return child
683
+ return None
684
+
685
+ def insert_element_before(self, elm: ElementBase, *tagnames: str):
686
+ successor = self.first_child_found_in(*tagnames)
687
+ if successor is not None:
688
+ successor.addprevious(elm)
689
+ else:
690
+ self.append(elm)
691
+ return elm
692
+
693
+ def remove_all(self, *tagnames: str) -> None:
694
+ """Remove child elements with tagname (e.g. "a:p") in `tagnames`."""
695
+ for tagname in tagnames:
696
+ matching = self.findall(qn(tagname))
697
+ for child in matching:
698
+ self.remove(child)
699
+
700
+ @property
701
+ def xml(self) -> str:
702
+ """XML string for this element, suitable for testing purposes.
703
+
704
+ Pretty printed for readability and without an XML declaration at the top.
705
+ """
706
+ return serialize_for_reading(self)
707
+
708
+ def xpath(self, xpath_str: str) -> Any: # pyright: ignore[reportIncompatibleMethodOverride]
709
+ """Override of `lxml` _Element.xpath() method.
710
+
711
+ Provides standard Open XML namespace mapping (`nsmap`) in centralized location.
712
+ """
713
+ return super().xpath(xpath_str, namespaces=_nsmap)
714
+
715
+ @property
716
+ def _nsptag(self) -> str:
717
+ return NamespacePrefixedTag.from_clark_name(self.tag)
tasks/tasksmith-74f059424102/environment/source/src/pptx/package.py ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Overall .pptx package."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import IO, Iterator
6
+
7
+ from pptx.opc.constants import RELATIONSHIP_TYPE as RT
8
+ from pptx.opc.package import OpcPackage
9
+ from pptx.opc.packuri import PackURI
10
+ from pptx.parts.coreprops import CorePropertiesPart
11
+ from pptx.parts.image import Image, ImagePart
12
+ from pptx.parts.media import MediaPart
13
+ from pptx.util import lazyproperty
14
+
15
+
16
+ class Package(OpcPackage):
17
+ """An overall .pptx package."""
18
+
19
+ @lazyproperty
20
+ def core_properties(self) -> CorePropertiesPart:
21
+ """Instance of |CoreProperties| holding read/write Dublin Core doc properties.
22
+
23
+ Creates a default core properties part if one is not present (not common).
24
+ """
25
+ try:
26
+ return self.part_related_by(RT.CORE_PROPERTIES)
27
+ except KeyError:
28
+ core_props = CorePropertiesPart.default(self)
29
+ self.relate_to(core_props, RT.CORE_PROPERTIES)
30
+ return core_props
31
+
32
+ def get_or_add_image_part(self, image_file: str | IO[bytes]):
33
+ """
34
+ Return an |ImagePart| object containing the image in *image_file*. If
35
+ the image part already exists in this package, it is reused,
36
+ otherwise a new one is created.
37
+ """
38
+ return self._image_parts.get_or_add_image_part(image_file)
39
+
40
+ def get_or_add_media_part(self, media):
41
+ """Return a |MediaPart| object containing the media in *media*.
42
+
43
+ If a media part for this media bytestream ("file") is already present
44
+ in this package, it is reused, otherwise a new one is created.
45
+ """
46
+ return self._media_parts.get_or_add_media_part(media)
47
+
48
+ def next_image_partname(self, ext: str) -> PackURI:
49
+ """Return a |PackURI| instance representing the next available image partname.
50
+
51
+ Partname uses the next available sequence number. *ext* is used as the extention on the
52
+ returned partname.
53
+ """
54
+
55
+ def first_available_image_idx():
56
+ image_idxs = sorted(
57
+ [
58
+ part.partname.idx
59
+ for part in self.iter_parts()
60
+ if (
61
+ part.partname.startswith("/ppt/media/image")
62
+ and part.partname.idx is not None
63
+ )
64
+ ]
65
+ )
66
+ for i, image_idx in enumerate(image_idxs):
67
+ idx = i + 1
68
+ if idx < image_idx:
69
+ return idx
70
+ return len(image_idxs) + 1
71
+
72
+ idx = first_available_image_idx()
73
+ return PackURI("/ppt/media/image%d.%s" % (idx, ext))
74
+
75
+ def next_media_partname(self, ext):
76
+ """Return |PackURI| instance for next available media partname.
77
+
78
+ Partname is first available, starting at sequence number 1. Empty
79
+ sequence numbers are reused. *ext* is used as the extension on the
80
+ returned partname.
81
+ """
82
+
83
+ def first_available_media_idx():
84
+ media_idxs = sorted(
85
+ [
86
+ part.partname.idx
87
+ for part in self.iter_parts()
88
+ if part.partname.startswith("/ppt/media/media")
89
+ ]
90
+ )
91
+ for i, media_idx in enumerate(media_idxs):
92
+ idx = i + 1
93
+ if idx < media_idx:
94
+ return idx
95
+ return len(media_idxs) + 1
96
+
97
+ idx = first_available_media_idx()
98
+ return PackURI("/ppt/media/media%d.%s" % (idx, ext))
99
+
100
+ @property
101
+ def presentation_part(self):
102
+ """
103
+ Reference to the |Presentation| instance contained in this package.
104
+ """
105
+ return self.main_document_part
106
+
107
+ @lazyproperty
108
+ def _image_parts(self):
109
+ """
110
+ |_ImageParts| object providing access to the image parts in this
111
+ package.
112
+ """
113
+ return _ImageParts(self)
114
+
115
+ @lazyproperty
116
+ def _media_parts(self):
117
+ """Return |_MediaParts| object for this package.
118
+
119
+ The media parts object provides access to all the media parts in this
120
+ package.
121
+ """
122
+ return _MediaParts(self)
123
+
124
+
125
+ class _ImageParts(object):
126
+ """Provides access to the image parts in a package."""
127
+
128
+ def __init__(self, package):
129
+ super(_ImageParts, self).__init__()
130
+ self._package = package
131
+
132
+ def __iter__(self) -> Iterator[ImagePart]:
133
+ """Generate a reference to each |ImagePart| object in the package."""
134
+ image_parts = []
135
+ for rel in self._package.iter_rels():
136
+ if rel.is_external:
137
+ continue
138
+ if rel.reltype != RT.IMAGE:
139
+ continue
140
+ image_part = rel.target_part
141
+ if image_part in image_parts:
142
+ continue
143
+ image_parts.append(image_part)
144
+ yield image_part
145
+
146
+ def get_or_add_image_part(self, image_file: str | IO[bytes]) -> ImagePart:
147
+ """Return |ImagePart| object containing the image in `image_file`.
148
+
149
+ `image_file` can be either a path to an image file or a file-like object
150
+ containing an image. If an image part containing this same image already exists,
151
+ that instance is returned, otherwise a new image part is created.
152
+ """
153
+ image = Image.from_file(image_file)
154
+ image_part = self._find_by_sha1(image.sha1)
155
+ return image_part if image_part else ImagePart.new(self._package, image)
156
+
157
+ def _find_by_sha1(self, sha1: str) -> ImagePart | None:
158
+ """
159
+ Return an |ImagePart| object belonging to this package or |None| if
160
+ no matching image part is found. The image part is identified by the
161
+ SHA1 hash digest of the image binary it contains.
162
+ """
163
+ for image_part in self:
164
+ # ---skip unknown/unsupported image types, like SVG---
165
+ if not hasattr(image_part, "sha1"):
166
+ continue
167
+ if image_part.sha1 == sha1:
168
+ return image_part
169
+ return None
170
+
171
+
172
+ class _MediaParts(object):
173
+ """Provides access to the media parts in a package.
174
+
175
+ Supports iteration and :meth:`get()` using the media object SHA1 hash as
176
+ its key.
177
+ """
178
+
179
+ def __init__(self, package):
180
+ super(_MediaParts, self).__init__()
181
+ self._package = package
182
+
183
+ def __iter__(self):
184
+ """Generate a reference to each |MediaPart| object in the package."""
185
+ # A media part can appear in more than one relationship (and commonly
186
+ # does in the case of video). Use media_parts to keep track of those
187
+ # that have been "yielded"; they can be skipped if they occur again.
188
+ media_parts = []
189
+ for rel in self._package.iter_rels():
190
+ if rel.is_external:
191
+ continue
192
+ if rel.reltype not in (RT.MEDIA, RT.VIDEO):
193
+ continue
194
+ media_part = rel.target_part
195
+ if media_part in media_parts:
196
+ continue
197
+ media_parts.append(media_part)
198
+ yield media_part
199
+
200
+ def get_or_add_media_part(self, media):
201
+ """Return a |MediaPart| object containing the media in *media*.
202
+
203
+ If this package already contains a media part for the same
204
+ bytestream, that instance is returned, otherwise a new media part is
205
+ created.
206
+ """
207
+ media_part = self._find_by_sha1(media.sha1)
208
+ if media_part is None:
209
+ media_part = MediaPart.new(self._package, media)
210
+ return media_part
211
+
212
+ def _find_by_sha1(self, sha1):
213
+ """Return |MediaPart| object having *sha1* hash or None if not found.
214
+
215
+ All media parts belonging to this package are considered. A media
216
+ part is identified by the SHA1 hash digest of its bytestream
217
+ ("file").
218
+ """
219
+ for media_part in self:
220
+ if media_part.sha1 == sha1:
221
+ return media_part
222
+ return None
tasks/tasksmith-74f059424102/environment/source/src/pptx/parts/__init__.py ADDED
File without changes
tasks/tasksmith-74f059424102/environment/source/src/pptx/parts/chart.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Chart part objects, including Chart and Charts."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ from pptx.chart.chart import Chart
8
+ from pptx.opc.constants import CONTENT_TYPE as CT
9
+ from pptx.opc.constants import RELATIONSHIP_TYPE as RT
10
+ from pptx.opc.package import XmlPart
11
+ from pptx.parts.embeddedpackage import EmbeddedXlsxPart
12
+ from pptx.util import lazyproperty
13
+
14
+ if TYPE_CHECKING:
15
+ from pptx.chart.data import ChartData
16
+ from pptx.enum.chart import XL_CHART_TYPE
17
+ from pptx.package import Package
18
+
19
+
20
+ class ChartPart(XmlPart):
21
+ """A chart part.
22
+
23
+ Corresponds to parts having partnames matching ppt/charts/chart[1-9][0-9]*.xml
24
+ """
25
+
26
+ partname_template = "/ppt/charts/chart%d.xml"
27
+
28
+ @classmethod
29
+ def new(cls, chart_type: XL_CHART_TYPE, chart_data: ChartData, package: Package):
30
+ """Return new |ChartPart| instance added to `package`.
31
+
32
+ Returned chart-part contains a chart of `chart_type` depicting `chart_data`.
33
+ """
34
+ chart_part = cls.load(
35
+ package.next_partname(cls.partname_template),
36
+ CT.DML_CHART,
37
+ package,
38
+ chart_data.xml_bytes(chart_type),
39
+ )
40
+ chart_part.chart_workbook.update_from_xlsx_blob(chart_data.xlsx_blob)
41
+ return chart_part
42
+
43
+ @lazyproperty
44
+ def chart(self):
45
+ """|Chart| object representing the chart in this part."""
46
+ return Chart(self._element, self)
47
+
48
+ @lazyproperty
49
+ def chart_workbook(self):
50
+ """
51
+ The |ChartWorkbook| object providing access to the external chart
52
+ data in a linked or embedded Excel workbook.
53
+ """
54
+ return ChartWorkbook(self._element, self)
55
+
56
+
57
+ class ChartWorkbook(object):
58
+ """Provides access to external chart data in a linked or embedded Excel workbook."""
59
+
60
+ def __init__(self, chartSpace, chart_part):
61
+ super(ChartWorkbook, self).__init__()
62
+ self._chartSpace = chartSpace
63
+ self._chart_part = chart_part
64
+
65
+ def update_from_xlsx_blob(self, xlsx_blob):
66
+ """
67
+ Replace the Excel spreadsheet in the related |EmbeddedXlsxPart| with
68
+ the Excel binary in *xlsx_blob*, adding a new |EmbeddedXlsxPart| if
69
+ there isn't one.
70
+ """
71
+ xlsx_part = self.xlsx_part
72
+ if xlsx_part is None:
73
+ self.xlsx_part = EmbeddedXlsxPart.new(xlsx_blob, self._chart_part.package)
74
+ return
75
+ xlsx_part.blob = xlsx_blob
76
+
77
+ @property
78
+ def xlsx_part(self):
79
+ """Optional |EmbeddedXlsxPart| object containing data for this chart.
80
+
81
+ This related part has its rId at `c:chartSpace/c:externalData/@rId`. This value
82
+ is |None| if there is no `<c:externalData>` element.
83
+ """
84
+ xlsx_part_rId = self._chartSpace.xlsx_part_rId
85
+ return None if xlsx_part_rId is None else self._chart_part.related_part(xlsx_part_rId)
86
+
87
+ @xlsx_part.setter
88
+ def xlsx_part(self, xlsx_part):
89
+ """
90
+ Set the related |EmbeddedXlsxPart| to *xlsx_part*. Assume one does
91
+ not already exist.
92
+ """
93
+ rId = self._chart_part.relate_to(xlsx_part, RT.PACKAGE)
94
+ externalData = self._chartSpace.get_or_add_externalData()
95
+ externalData.rId = rId
tasks/tasksmith-74f059424102/environment/source/src/pptx/parts/coreprops.py ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Core properties part, corresponds to ``/docProps/core.xml`` part in package."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import datetime as dt
6
+ from typing import TYPE_CHECKING
7
+
8
+ from pptx.opc.constants import CONTENT_TYPE as CT
9
+ from pptx.opc.package import XmlPart
10
+ from pptx.opc.packuri import PackURI
11
+ from pptx.oxml.coreprops import CT_CoreProperties
12
+
13
+ if TYPE_CHECKING:
14
+ from pptx.package import Package
15
+
16
+
17
+ class CorePropertiesPart(XmlPart):
18
+ """Corresponds to part named `/docProps/core.xml`.
19
+
20
+ Contains the core document properties for this document package.
21
+ """
22
+
23
+ _element: CT_CoreProperties
24
+
25
+ @classmethod
26
+ def default(cls, package: Package):
27
+ """Return default new |CorePropertiesPart| instance suitable as starting point.
28
+
29
+ This provides a base for adding core-properties to a package that doesn't yet
30
+ have any.
31
+ """
32
+ core_props = cls._new(package)
33
+ core_props.title = "PowerPoint Presentation"
34
+ core_props.last_modified_by = "python-pptx"
35
+ core_props.revision = 1
36
+ core_props.modified = dt.datetime.now(dt.timezone.utc).replace(tzinfo=None)
37
+ return core_props
38
+
39
+ @property
40
+ def author(self) -> str:
41
+ return self._element.author_text
42
+
43
+ @author.setter
44
+ def author(self, value: str):
45
+ self._element.author_text = value
46
+
47
+ @property
48
+ def category(self) -> str:
49
+ return self._element.category_text
50
+
51
+ @category.setter
52
+ def category(self, value: str):
53
+ self._element.category_text = value
54
+
55
+ @property
56
+ def comments(self) -> str:
57
+ return self._element.comments_text
58
+
59
+ @comments.setter
60
+ def comments(self, value: str):
61
+ self._element.comments_text = value
62
+
63
+ @property
64
+ def content_status(self) -> str:
65
+ return self._element.contentStatus_text
66
+
67
+ @content_status.setter
68
+ def content_status(self, value: str):
69
+ self._element.contentStatus_text = value
70
+
71
+ @property
72
+ def created(self):
73
+ return self._element.created_datetime
74
+
75
+ @created.setter
76
+ def created(self, value: dt.datetime):
77
+ self._element.created_datetime = value
78
+
79
+ @property
80
+ def identifier(self) -> str:
81
+ return self._element.identifier_text
82
+
83
+ @identifier.setter
84
+ def identifier(self, value: str):
85
+ self._element.identifier_text = value
86
+
87
+ @property
88
+ def keywords(self) -> str:
89
+ return self._element.keywords_text
90
+
91
+ @keywords.setter
92
+ def keywords(self, value: str):
93
+ self._element.keywords_text = value
94
+
95
+ @property
96
+ def language(self) -> str:
97
+ return self._element.language_text
98
+
99
+ @language.setter
100
+ def language(self, value: str):
101
+ self._element.language_text = value
102
+
103
+ @property
104
+ def last_modified_by(self) -> str:
105
+ return self._element.lastModifiedBy_text
106
+
107
+ @last_modified_by.setter
108
+ def last_modified_by(self, value: str):
109
+ self._element.lastModifiedBy_text = value
110
+
111
+ @property
112
+ def last_printed(self):
113
+ return self._element.lastPrinted_datetime
114
+
115
+ @last_printed.setter
116
+ def last_printed(self, value: dt.datetime):
117
+ self._element.lastPrinted_datetime = value
118
+
119
+ @property
120
+ def modified(self):
121
+ return self._element.modified_datetime
122
+
123
+ @modified.setter
124
+ def modified(self, value: dt.datetime):
125
+ self._element.modified_datetime = value
126
+
127
+ @property
128
+ def revision(self):
129
+ return self._element.revision_number
130
+
131
+ @revision.setter
132
+ def revision(self, value: int):
133
+ self._element.revision_number = value
134
+
135
+ @property
136
+ def subject(self) -> str:
137
+ return self._element.subject_text
138
+
139
+ @subject.setter
140
+ def subject(self, value: str):
141
+ self._element.subject_text = value
142
+
143
+ @property
144
+ def title(self) -> str:
145
+ return self._element.title_text
146
+
147
+ @title.setter
148
+ def title(self, value: str):
149
+ self._element.title_text = value
150
+
151
+ @property
152
+ def version(self) -> str:
153
+ return self._element.version_text
154
+
155
+ @version.setter
156
+ def version(self, value: str):
157
+ self._element.version_text = value
158
+
159
+ @classmethod
160
+ def _new(cls, package: Package) -> CorePropertiesPart:
161
+ """Return new empty |CorePropertiesPart| instance."""
162
+ return CorePropertiesPart(
163
+ PackURI("/docProps/core.xml"),
164
+ CT.OPC_CORE_PROPERTIES,
165
+ package,
166
+ CT_CoreProperties.new_coreProperties(),
167
+ )
tasks/tasksmith-74f059424102/environment/source/src/pptx/parts/embeddedpackage.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Embedded Package part objects.
2
+
3
+ "Package" in this context means another OPC package, i.e. a DOCX, PPTX, or XLSX "file".
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import TYPE_CHECKING
9
+
10
+ from pptx.enum.shapes import PROG_ID
11
+ from pptx.opc.constants import CONTENT_TYPE as CT
12
+ from pptx.opc.package import Part
13
+
14
+ if TYPE_CHECKING:
15
+ from pptx.package import Package
16
+
17
+
18
+ class EmbeddedPackagePart(Part):
19
+ """A distinct OPC package, e.g. an Excel file, embedded in this PPTX package.
20
+
21
+ Has a partname like: `ppt/embeddings/Microsoft_Excel_Sheet1.xlsx`.
22
+ """
23
+
24
+ @classmethod
25
+ def factory(cls, prog_id: PROG_ID | str, object_blob: bytes, package: Package):
26
+ """Return a new |EmbeddedPackagePart| subclass instance added to *package*.
27
+
28
+ The subclass is determined by `prog_id` which corresponds to the "application"
29
+ used to open the "file-type" of `object_blob`. The returned part contains the
30
+ bytes of `object_blob` and has the content-type also determined by `prog_id`.
31
+ """
32
+ # --- a generic OLE object has no subclass ---
33
+ if not isinstance(prog_id, PROG_ID):
34
+ return cls(
35
+ package.next_partname("/ppt/embeddings/oleObject%d.bin"),
36
+ CT.OFC_OLE_OBJECT,
37
+ package,
38
+ object_blob,
39
+ )
40
+
41
+ # --- A Microsoft Office file-type is a distinguished package object ---
42
+ EmbeddedPartCls = {
43
+ PROG_ID.DOCX: EmbeddedDocxPart,
44
+ PROG_ID.PPTX: EmbeddedPptxPart,
45
+ PROG_ID.XLSX: EmbeddedXlsxPart,
46
+ }[prog_id]
47
+
48
+ return EmbeddedPartCls.new(object_blob, package)
49
+
50
+ @classmethod
51
+ def new(cls, blob: bytes, package: Package):
52
+ """Return new |EmbeddedPackagePart| subclass object.
53
+
54
+ The returned part object contains `blob` and is added to `package`.
55
+ """
56
+ return cls(
57
+ package.next_partname(cls.partname_template),
58
+ cls.content_type,
59
+ package,
60
+ blob,
61
+ )
62
+
63
+
64
+ class EmbeddedDocxPart(EmbeddedPackagePart):
65
+ """A Word .docx file stored in a part.
66
+
67
+ This part-type arises when a Word document appears as an embedded OLE-object shape.
68
+ """
69
+
70
+ partname_template = "/ppt/embeddings/Microsoft_Word_Document%d.docx"
71
+ content_type = CT.WML_DOCUMENT
72
+
73
+
74
+ class EmbeddedPptxPart(EmbeddedPackagePart):
75
+ """A PowerPoint file stored in a part.
76
+
77
+ This part-type arises when a PowerPoint presentation (.pptx file) appears as an
78
+ embedded OLE-object shape.
79
+ """
80
+
81
+ partname_template = "/ppt/embeddings/Microsoft_PowerPoint_Presentation%d.pptx"
82
+ content_type = CT.PML_PRESENTATION
83
+
84
+
85
+ class EmbeddedXlsxPart(EmbeddedPackagePart):
86
+ """An Excel file stored in a part.
87
+
88
+ This part-type arises as the data source for a chart, but may also be the OLE-object
89
+ for an embedded object shape.
90
+ """
91
+
92
+ partname_template = "/ppt/embeddings/Microsoft_Excel_Sheet%d.xlsx"
93
+ content_type = CT.SML_SHEET
tasks/tasksmith-74f059424102/environment/source/src/pptx/parts/image.py ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ImagePart and related objects."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import hashlib
6
+ import io
7
+ import os
8
+ from typing import IO, TYPE_CHECKING, Any, cast
9
+
10
+ from PIL import Image as PIL_Image
11
+
12
+ from pptx.opc.package import Part
13
+ from pptx.opc.spec import image_content_types
14
+ from pptx.util import Emu, lazyproperty
15
+
16
+ if TYPE_CHECKING:
17
+ from pptx.opc.packuri import PackURI
18
+ from pptx.package import Package
19
+ from pptx.util import Length
20
+
21
+
22
+ class ImagePart(Part):
23
+ """An image part.
24
+
25
+ An image part generally has a partname matching the regex `ppt/media/image[1-9][0-9]*.*`.
26
+ """
27
+
28
+ def __init__(
29
+ self,
30
+ partname: PackURI,
31
+ content_type: str,
32
+ package: Package,
33
+ blob: bytes,
34
+ filename: str | None = None,
35
+ ):
36
+ super(ImagePart, self).__init__(partname, content_type, package, blob)
37
+ self._blob = blob
38
+ self._filename = filename
39
+
40
+ @classmethod
41
+ def new(cls, package: Package, image: Image) -> ImagePart:
42
+ """Return new |ImagePart| instance containing `image`.
43
+
44
+ `image` is an |Image| object.
45
+ """
46
+ return cls(
47
+ package.next_image_partname(image.ext),
48
+ image.content_type,
49
+ package,
50
+ image.blob,
51
+ image.filename,
52
+ )
53
+
54
+ @property
55
+ def desc(self) -> str:
56
+ """The filename associated with this image.
57
+
58
+ Either the filename of the original image or a generic name of the form `image.ext` where
59
+ `ext` is appropriate to the image file format, e.g. `'jpg'`. An image created using a path
60
+ will have that filename; one created with a file-like object will have a generic name.
61
+ """
62
+ # -- return generic filename if original filename is unknown --
63
+ if self._filename is None:
64
+ return f"image.{self.ext}"
65
+ return self._filename
66
+
67
+ @property
68
+ def ext(self) -> str:
69
+ """File-name extension for this image e.g. `'png'`."""
70
+ return self.partname.ext
71
+
72
+ @property
73
+ def image(self) -> Image:
74
+ """An |Image| object containing the image in this image part.
75
+
76
+ Note this is a `pptx.image.Image` object, not a PIL Image.
77
+ """
78
+ return Image(self._blob, self.desc)
79
+
80
+ def scale(self, scaled_cx: int | None, scaled_cy: int | None) -> tuple[int, int]:
81
+ """Return scaled image dimensions in EMU based on the combination of parameters supplied.
82
+
83
+ If `scaled_cx` and `scaled_cy` are both |None|, the native image size is returned. If
84
+ neither `scaled_cx` nor `scaled_cy` is |None|, their values are returned unchanged. If a
85
+ value is provided for either `scaled_cx` or `scaled_cy` and the other is |None|, the
86
+ missing value is calculated such that the image's aspect ratio is preserved.
87
+ """
88
+ image_cx, image_cy = self._native_size
89
+
90
+ if scaled_cx and scaled_cy:
91
+ return scaled_cx, scaled_cy
92
+
93
+ if scaled_cx and not scaled_cy:
94
+ scaling_factor = float(scaled_cx) / float(image_cx)
95
+ scaled_cy = int(round(image_cy * scaling_factor))
96
+ return scaled_cx, scaled_cy
97
+
98
+ if not scaled_cx and scaled_cy:
99
+ scaling_factor = float(scaled_cy) / float(image_cy)
100
+ scaled_cx = int(round(image_cx * scaling_factor))
101
+ return scaled_cx, scaled_cy
102
+
103
+ # -- only remaining case is both `scaled_cx` and `scaled_cy` are `None` --
104
+ return image_cx, image_cy
105
+
106
+ @lazyproperty
107
+ def sha1(self) -> str:
108
+ """The 40-character SHA1 hash digest for the image binary of this image part.
109
+
110
+ like: `"1be010ea47803b00e140b852765cdf84f491da47"`.
111
+ """
112
+ return hashlib.sha1(self._blob).hexdigest()
113
+
114
+ @property
115
+ def _dpi(self) -> tuple[int, int]:
116
+ """(horz_dpi, vert_dpi) pair representing the dots-per-inch resolution of this image."""
117
+ image = Image.from_blob(self._blob)
118
+ return image.dpi
119
+
120
+ @property
121
+ def _native_size(self) -> tuple[Length, Length]:
122
+ """A (width, height) 2-tuple representing the native dimensions of the image in EMU.
123
+
124
+ Calculated based on the image DPI value, if present, assuming 72 dpi as a default.
125
+ """
126
+ EMU_PER_INCH = 914400
127
+ horz_dpi, vert_dpi = self._dpi
128
+ width_px, height_px = self._px_size
129
+
130
+ width = EMU_PER_INCH * width_px / horz_dpi
131
+ height = EMU_PER_INCH * height_px / vert_dpi
132
+
133
+ return Emu(int(width)), Emu(int(height))
134
+
135
+ @property
136
+ def _px_size(self) -> tuple[int, int]:
137
+ """A (width, height) 2-tuple representing the dimensions of this image in pixels."""
138
+ image = Image.from_blob(self._blob)
139
+ return image.size
140
+
141
+
142
+ class Image(object):
143
+ """Immutable value object representing an image such as a JPEG, PNG, or GIF."""
144
+
145
+ def __init__(self, blob: bytes, filename: str | None):
146
+ super(Image, self).__init__()
147
+ self._blob = blob
148
+ self._filename = filename
149
+
150
+ @classmethod
151
+ def from_blob(cls, blob: bytes, filename: str | None = None) -> Image:
152
+ """Return a new |Image| object loaded from the image binary in `blob`."""
153
+ return cls(blob, filename)
154
+
155
+ @classmethod
156
+ def from_file(cls, image_file: str | IO[bytes]) -> Image:
157
+ """Return a new |Image| object loaded from `image_file`.
158
+
159
+ `image_file` can be either a path (str) or a file-like object.
160
+ """
161
+ if isinstance(image_file, str):
162
+ # treat image_file as a path
163
+ with open(image_file, "rb") as f:
164
+ blob = f.read()
165
+ filename = os.path.basename(image_file)
166
+ else:
167
+ # assume image_file is a file-like object
168
+ # ---reposition file cursor if it has one---
169
+ if callable(getattr(image_file, "seek")):
170
+ image_file.seek(0)
171
+ blob = image_file.read()
172
+ filename = None
173
+
174
+ return cls.from_blob(blob, filename)
175
+
176
+ @property
177
+ def blob(self) -> bytes:
178
+ """The binary image bytestream of this image."""
179
+ return self._blob
180
+
181
+ @lazyproperty
182
+ def content_type(self) -> str:
183
+ """MIME-type of this image, e.g. `"image/jpeg"`."""
184
+ return image_content_types[self.ext]
185
+
186
+ @lazyproperty
187
+ def dpi(self) -> tuple[int, int]:
188
+ """A (horz_dpi, vert_dpi) 2-tuple specifying the dots-per-inch resolution of this image.
189
+
190
+ A default value of (72, 72) is used if the dpi is not specified in the image file.
191
+ """
192
+
193
+ def int_dpi(dpi: Any):
194
+ """Return an integer dots-per-inch value corresponding to `dpi`.
195
+
196
+ If `dpi` is |None|, a non-numeric type, less than 1 or greater than 2048, 72 is
197
+ returned.
198
+ """
199
+ try:
200
+ int_dpi = int(round(float(dpi)))
201
+ if int_dpi < 1 or int_dpi > 2048:
202
+ int_dpi = 72
203
+ except (TypeError, ValueError):
204
+ int_dpi = 72
205
+ return int_dpi
206
+
207
+ def normalize_pil_dpi(pil_dpi: tuple[int, int] | None):
208
+ """Return a (horz_dpi, vert_dpi) 2-tuple corresponding to `pil_dpi`.
209
+
210
+ The value for the 'dpi' key in the `info` dict of a PIL image. If the 'dpi' key is not
211
+ present or contains an invalid value, `(72, 72)` is returned.
212
+ """
213
+ if isinstance(pil_dpi, tuple):
214
+ return (int_dpi(pil_dpi[0]), int_dpi(pil_dpi[1]))
215
+ return (72, 72)
216
+
217
+ return normalize_pil_dpi(self._pil_props[2])
218
+
219
+ @lazyproperty
220
+ def ext(self) -> str:
221
+ """Canonical file extension for this image e.g. `'png'`.
222
+
223
+ The returned extension is all lowercase and is the canonical extension for the content type
224
+ of this image, regardless of what extension may have been used in its filename, if any.
225
+ """
226
+ ext_map = {
227
+ "BMP": "bmp",
228
+ "GIF": "gif",
229
+ "JPEG": "jpg",
230
+ "PNG": "png",
231
+ "TIFF": "tiff",
232
+ "WMF": "wmf",
233
+ }
234
+ format = self._format
235
+ if format not in ext_map:
236
+ tmpl = "unsupported image format, expected one of: %s, got '%s'"
237
+ raise ValueError(tmpl % (ext_map.keys(), format))
238
+ return ext_map[format]
239
+
240
+ @property
241
+ def filename(self) -> str | None:
242
+ """Filename from path used to load this image, if loaded from the filesystem.
243
+
244
+ |None| if no filename was used in loading, such as when loaded from an in-memory stream.
245
+ """
246
+ return self._filename
247
+
248
+ @lazyproperty
249
+ def sha1(self) -> str:
250
+ """SHA1 hash digest of the image blob."""
251
+ return hashlib.sha1(self._blob).hexdigest()
252
+
253
+ @lazyproperty
254
+ def size(self) -> tuple[int, int]:
255
+ """A (width, height) 2-tuple specifying the dimensions of this image in pixels."""
256
+ return self._pil_props[1]
257
+
258
+ @property
259
+ def _format(self) -> str | None:
260
+ """The PIL Image format of this image, e.g. 'PNG'."""
261
+ return self._pil_props[0]
262
+
263
+ @lazyproperty
264
+ def _pil_props(self) -> tuple[str | None, tuple[int, int], tuple[int, int] | None]:
265
+ """tuple of image properties extracted from this image using Pillow."""
266
+ stream = io.BytesIO(self._blob)
267
+ pil_image = PIL_Image.open(stream) # pyright: ignore[reportUnknownMemberType]
268
+ format = pil_image.format
269
+ width_px, height_px = pil_image.size
270
+ dpi = cast(
271
+ "tuple[int, int] | None",
272
+ pil_image.info.get("dpi"), # pyright: ignore[reportUnknownMemberType]
273
+ )
274
+ stream.close()
275
+ return (format, (width_px, height_px), dpi)
tasks/tasksmith-74f059424102/environment/source/src/pptx/parts/media.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """MediaPart and related objects."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import hashlib
6
+
7
+ from pptx.opc.package import Part
8
+ from pptx.util import lazyproperty
9
+
10
+
11
+ class MediaPart(Part):
12
+ """A media part, containing an audio or video resource.
13
+
14
+ A media part generally has a partname matching the regex
15
+ `ppt/media/media[1-9][0-9]*.*`.
16
+ """
17
+
18
+ @classmethod
19
+ def new(cls, package, media):
20
+ """Return new |MediaPart| instance containing `media`.
21
+
22
+ `media` must be a |Media| object.
23
+ """
24
+ return cls(
25
+ package.next_media_partname(media.ext),
26
+ media.content_type,
27
+ package,
28
+ media.blob,
29
+ )
30
+
31
+ @lazyproperty
32
+ def sha1(self):
33
+ """The SHA1 hash digest for the media binary of this media part.
34
+
35
+ Example: `'1be010ea47803b00e140b852765cdf84f491da47'`
36
+ """
37
+ return hashlib.sha1(self._blob).hexdigest()
tasks/tasksmith-74f059424102/environment/source/src/pptx/parts/presentation.py ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Presentation part, the main part in a .pptx package."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import IO, TYPE_CHECKING, Iterable
6
+
7
+ from pptx.opc.constants import RELATIONSHIP_TYPE as RT
8
+ from pptx.opc.package import XmlPart
9
+ from pptx.opc.packuri import PackURI
10
+ from pptx.parts.slide import NotesMasterPart, SlidePart
11
+ from pptx.presentation import Presentation
12
+ from pptx.util import lazyproperty
13
+
14
+ if TYPE_CHECKING:
15
+ from pptx.parts.coreprops import CorePropertiesPart
16
+ from pptx.slide import NotesMaster, Slide, SlideLayout, SlideMaster
17
+
18
+
19
+ class PresentationPart(XmlPart):
20
+ """Top level class in object model.
21
+
22
+ Represents the contents of the /ppt directory of a .pptx file.
23
+ """
24
+
25
+ def add_slide(self, slide_layout: SlideLayout):
26
+ """Return (rId, slide) pair of a newly created blank slide.
27
+
28
+ New slide inherits appearance from `slide_layout`.
29
+ """
30
+ partname = self._next_slide_partname
31
+ slide_layout_part = slide_layout.part
32
+ slide_part = SlidePart.new(partname, self.package, slide_layout_part)
33
+ rId = self.relate_to(slide_part, RT.SLIDE)
34
+ return rId, slide_part.slide
35
+
36
+ @property
37
+ def core_properties(self) -> CorePropertiesPart:
38
+ """A |CoreProperties| object for the presentation.
39
+
40
+ Provides read/write access to the Dublin Core properties of this presentation.
41
+ """
42
+ return self.package.core_properties
43
+
44
+ def get_slide(self, slide_id: int) -> Slide | None:
45
+ """Return optional related |Slide| object identified by `slide_id`.
46
+
47
+ Returns |None| if no slide with `slide_id` is related to this presentation.
48
+ """
49
+ for sldId in self._element.sldIdLst:
50
+ if sldId.id == slide_id:
51
+ return self.related_part(sldId.rId).slide
52
+ return None
53
+
54
+ @lazyproperty
55
+ def notes_master(self) -> NotesMaster:
56
+ """
57
+ Return the |NotesMaster| object for this presentation. If the
58
+ presentation does not have a notes master, one is created from
59
+ a default template. The same single instance is returned on each
60
+ call.
61
+ """
62
+ return self.notes_master_part.notes_master
63
+
64
+ @lazyproperty
65
+ def notes_master_part(self) -> NotesMasterPart:
66
+ """Return the |NotesMasterPart| object for this presentation.
67
+
68
+ If the presentation does not have a notes master, one is created from a default template.
69
+ The same single instance is returned on each call.
70
+ """
71
+ try:
72
+ return self.part_related_by(RT.NOTES_MASTER)
73
+ except KeyError:
74
+ notes_master_part = NotesMasterPart.create_default(self.package)
75
+ self.relate_to(notes_master_part, RT.NOTES_MASTER)
76
+ return notes_master_part
77
+
78
+ @lazyproperty
79
+ def presentation(self):
80
+ """
81
+ A |Presentation| object providing access to the content of this
82
+ presentation.
83
+ """
84
+ return Presentation(self._element, self)
85
+
86
+ def related_slide(self, rId: str) -> Slide:
87
+ """Return |Slide| object for related |SlidePart| related by `rId`."""
88
+ return self.related_part(rId).slide
89
+
90
+ def related_slide_master(self, rId: str) -> SlideMaster:
91
+ """Return |SlideMaster| object for |SlideMasterPart| related by `rId`."""
92
+ return self.related_part(rId).slide_master
93
+
94
+ def rename_slide_parts(self, rIds: Iterable[str]):
95
+ """Assign incrementing partnames to the slide parts identified by `rIds`.
96
+
97
+ Partnames are like `/ppt/slides/slide9.xml` and are assigned in the order their id appears
98
+ in the `rIds` sequence. The name portion is always `slide`. The number part forms a
99
+ continuous sequence starting at 1 (e.g. 1, 2, ... 10, ...). The extension is always
100
+ `.xml`.
101
+ """
102
+ for idx, rId in enumerate(rIds):
103
+ slide_part = self.related_part(rId)
104
+ slide_part.partname = PackURI("/ppt/slides/slide%d.xml" % (idx + 1))
105
+
106
+ def save(self, path_or_stream: str | IO[bytes]):
107
+ """Save this presentation package to `path_or_stream`.
108
+
109
+ `path_or_stream` can be either a path to a filesystem location (a string) or a
110
+ file-like object.
111
+ """
112
+ self.package.save(path_or_stream)
113
+
114
+ def slide_id(self, slide_part):
115
+ """Return the slide-id associated with `slide_part`."""
116
+ for sldId in self._element.sldIdLst:
117
+ if self.related_part(sldId.rId) is slide_part:
118
+ return sldId.id
119
+ raise ValueError("matching slide_part not found")
120
+
121
+ @property
122
+ def _next_slide_partname(self):
123
+ """Return |PackURI| instance containing next available slide partname."""
124
+ sldIdLst = self._element.get_or_add_sldIdLst()
125
+ partname_str = "/ppt/slides/slide%d.xml" % (len(sldIdLst) + 1)
126
+ return PackURI(partname_str)
tasks/tasksmith-74f059424102/environment/source/src/pptx/parts/slide.py ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Slide and related objects."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import IO, TYPE_CHECKING, cast
6
+
7
+ from pptx.enum.shapes import PROG_ID
8
+ from pptx.opc.constants import CONTENT_TYPE as CT
9
+ from pptx.opc.constants import RELATIONSHIP_TYPE as RT
10
+ from pptx.opc.package import XmlPart
11
+ from pptx.opc.packuri import PackURI
12
+ from pptx.oxml.slide import CT_NotesMaster, CT_NotesSlide, CT_Slide
13
+ from pptx.oxml.theme import CT_OfficeStyleSheet
14
+ from pptx.parts.chart import ChartPart
15
+ from pptx.parts.embeddedpackage import EmbeddedPackagePart
16
+ from pptx.slide import NotesMaster, NotesSlide, Slide, SlideLayout, SlideMaster
17
+ from pptx.util import lazyproperty
18
+
19
+ if TYPE_CHECKING:
20
+ from pptx.chart.data import ChartData
21
+ from pptx.enum.chart import XL_CHART_TYPE
22
+ from pptx.media import Video
23
+ from pptx.parts.image import Image, ImagePart
24
+
25
+
26
+ class BaseSlidePart(XmlPart):
27
+ """Base class for slide parts.
28
+
29
+ This includes slide, slide-layout, and slide-master parts, but also notes-slide,
30
+ notes-master, and handout-master parts.
31
+ """
32
+
33
+ _element: CT_Slide
34
+
35
+ def get_image(self, rId: str) -> Image:
36
+ """Return an |Image| object containing the image related to this slide by *rId*.
37
+
38
+ Raises |KeyError| if no image is related by that id, which would generally indicate a
39
+ corrupted .pptx file.
40
+ """
41
+ return cast("ImagePart", self.related_part(rId)).image
42
+
43
+ def get_or_add_image_part(self, image_file: str | IO[bytes]):
44
+ """Return `(image_part, rId)` pair corresponding to `image_file`.
45
+
46
+ The returned |ImagePart| object contains the image in `image_file` and is
47
+ related to this slide with the key `rId`. If either the image part or
48
+ relationship already exists, they are reused, otherwise they are newly created.
49
+ """
50
+ image_part = self._package.get_or_add_image_part(image_file)
51
+ rId = self.relate_to(image_part, RT.IMAGE)
52
+ return image_part, rId
53
+
54
+ @property
55
+ def name(self) -> str:
56
+ """Internal name of this slide."""
57
+ return self._element.cSld.name
58
+
59
+
60
+ class NotesMasterPart(BaseSlidePart):
61
+ """Notes master part.
62
+
63
+ Corresponds to package file `ppt/notesMasters/notesMaster1.xml`.
64
+ """
65
+
66
+ @classmethod
67
+ def create_default(cls, package):
68
+ """
69
+ Create and return a default notes master part, including creating the
70
+ new theme it requires.
71
+ """
72
+ notes_master_part = cls._new(package)
73
+ theme_part = cls._new_theme_part(package)
74
+ notes_master_part.relate_to(theme_part, RT.THEME)
75
+ return notes_master_part
76
+
77
+ @lazyproperty
78
+ def notes_master(self):
79
+ """
80
+ Return the |NotesMaster| object that proxies this notes master part.
81
+ """
82
+ return NotesMaster(self._element, self)
83
+
84
+ @classmethod
85
+ def _new(cls, package):
86
+ """
87
+ Create and return a standalone, default notes master part based on
88
+ the built-in template (without any related parts, such as theme).
89
+ """
90
+ return NotesMasterPart(
91
+ PackURI("/ppt/notesMasters/notesMaster1.xml"),
92
+ CT.PML_NOTES_MASTER,
93
+ package,
94
+ CT_NotesMaster.new_default(),
95
+ )
96
+
97
+ @classmethod
98
+ def _new_theme_part(cls, package):
99
+ """Return new default theme-part suitable for use with a notes master."""
100
+ return XmlPart(
101
+ package.next_partname("/ppt/theme/theme%d.xml"),
102
+ CT.OFC_THEME,
103
+ package,
104
+ CT_OfficeStyleSheet.new_default(),
105
+ )
106
+
107
+
108
+ class NotesSlidePart(BaseSlidePart):
109
+ """Notes slide part.
110
+
111
+ Contains the slide notes content and the layout for the slide handout page.
112
+ Corresponds to package file `ppt/notesSlides/notesSlide[1-9][0-9]*.xml`.
113
+ """
114
+
115
+ @classmethod
116
+ def new(cls, package, slide_part):
117
+ """Return new |NotesSlidePart| for the slide in `slide_part`.
118
+
119
+ The new notes-slide part is based on the (singleton) notes master and related to
120
+ both the notes-master part and `slide_part`. If no notes-master is present,
121
+ one is created based on the default template.
122
+ """
123
+ notes_master_part = package.presentation_part.notes_master_part
124
+ notes_slide_part = cls._add_notes_slide_part(package, slide_part, notes_master_part)
125
+ notes_slide = notes_slide_part.notes_slide
126
+ notes_slide.clone_master_placeholders(notes_master_part.notes_master)
127
+ return notes_slide_part
128
+
129
+ @lazyproperty
130
+ def notes_master(self):
131
+ """Return the |NotesMaster| object this notes slide inherits from."""
132
+ notes_master_part = self.part_related_by(RT.NOTES_MASTER)
133
+ return notes_master_part.notes_master
134
+
135
+ @lazyproperty
136
+ def notes_slide(self):
137
+ """Return the |NotesSlide| object that proxies this notes slide part."""
138
+ return NotesSlide(self._element, self)
139
+
140
+ @classmethod
141
+ def _add_notes_slide_part(cls, package, slide_part, notes_master_part):
142
+ """Create and return a new notes-slide part.
143
+
144
+ The return part is fully related, but has no shape content (i.e. placeholders
145
+ not cloned).
146
+ """
147
+ notes_slide_part = NotesSlidePart(
148
+ package.next_partname("/ppt/notesSlides/notesSlide%d.xml"),
149
+ CT.PML_NOTES_SLIDE,
150
+ package,
151
+ CT_NotesSlide.new(),
152
+ )
153
+ notes_slide_part.relate_to(notes_master_part, RT.NOTES_MASTER)
154
+ notes_slide_part.relate_to(slide_part, RT.SLIDE)
155
+ return notes_slide_part
156
+
157
+
158
+ class SlidePart(BaseSlidePart):
159
+ """Slide part. Corresponds to package files ppt/slides/slide[1-9][0-9]*.xml."""
160
+
161
+ @classmethod
162
+ def new(cls, partname, package, slide_layout_part):
163
+ """Return newly-created blank slide part.
164
+
165
+ The new slide-part has `partname` and a relationship to `slide_layout_part`.
166
+ """
167
+ slide_part = cls(partname, CT.PML_SLIDE, package, CT_Slide.new())
168
+ slide_part.relate_to(slide_layout_part, RT.SLIDE_LAYOUT)
169
+ return slide_part
170
+
171
+ def add_chart_part(self, chart_type: XL_CHART_TYPE, chart_data: ChartData):
172
+ """Return str rId of new |ChartPart| object containing chart of `chart_type`.
173
+
174
+ The chart depicts `chart_data` and is related to the slide contained in this
175
+ part by `rId`.
176
+ """
177
+ return self.relate_to(ChartPart.new(chart_type, chart_data, self._package), RT.CHART)
178
+
179
+ def add_embedded_ole_object_part(
180
+ self, prog_id: PROG_ID | str, ole_object_file: str | IO[bytes]
181
+ ):
182
+ """Return rId of newly-added OLE-object part formed from `ole_object_file`."""
183
+ relationship_type = RT.PACKAGE if isinstance(prog_id, PROG_ID) else RT.OLE_OBJECT
184
+ return self.relate_to(
185
+ EmbeddedPackagePart.factory(
186
+ prog_id, self._blob_from_file(ole_object_file), self._package
187
+ ),
188
+ relationship_type,
189
+ )
190
+
191
+ def get_or_add_video_media_part(self, video: Video) -> tuple[str, str]:
192
+ """Return rIds for media and video relationships to media part.
193
+
194
+ A new |MediaPart| object is created if it does not already exist
195
+ (such as would occur if the same video appeared more than once in
196
+ a presentation). Two relationships to the media part are created,
197
+ one each with MEDIA and VIDEO relationship types. The need for two
198
+ appears to be for legacy support for an earlier (pre-Office 2010)
199
+ PowerPoint media embedding strategy.
200
+ """
201
+ media_part = self._package.get_or_add_media_part(video)
202
+ media_rId = self.relate_to(media_part, RT.MEDIA)
203
+ video_rId = self.relate_to(media_part, RT.VIDEO)
204
+ return media_rId, video_rId
205
+
206
+ @property
207
+ def has_notes_slide(self):
208
+ """
209
+ Return True if this slide has a notes slide, False otherwise. A notes
210
+ slide is created by the :attr:`notes_slide` property when one doesn't
211
+ exist; use this property to test for a notes slide without the
212
+ possible side-effect of creating one.
213
+ """
214
+ try:
215
+ self.part_related_by(RT.NOTES_SLIDE)
216
+ except KeyError:
217
+ return False
218
+ return True
219
+
220
+ @lazyproperty
221
+ def notes_slide(self) -> NotesSlide:
222
+ """The |NotesSlide| instance associated with this slide.
223
+
224
+ If the slide does not have a notes slide, a new one is created. The same single instance
225
+ is returned on each call.
226
+ """
227
+ try:
228
+ notes_slide_part = self.part_related_by(RT.NOTES_SLIDE)
229
+ except KeyError:
230
+ notes_slide_part = self._add_notes_slide_part()
231
+ return notes_slide_part.notes_slide
232
+
233
+ @lazyproperty
234
+ def slide(self):
235
+ """
236
+ The |Slide| object representing this slide part.
237
+ """
238
+ return Slide(self._element, self)
239
+
240
+ @property
241
+ def slide_id(self) -> int:
242
+ """Return the slide identifier stored in the presentation part for this slide part."""
243
+ presentation_part = self.package.presentation_part
244
+ return presentation_part.slide_id(self)
245
+
246
+ @property
247
+ def slide_layout(self) -> SlideLayout:
248
+ """|SlideLayout| object the slide in this part inherits appearance from."""
249
+ slide_layout_part = self.part_related_by(RT.SLIDE_LAYOUT)
250
+ return slide_layout_part.slide_layout
251
+
252
+ def _add_notes_slide_part(self):
253
+ """
254
+ Return a newly created |NotesSlidePart| object related to this slide
255
+ part. Caller is responsible for ensuring this slide doesn't already
256
+ have a notes slide part.
257
+ """
258
+ notes_slide_part = NotesSlidePart.new(self.package, self)
259
+ self.relate_to(notes_slide_part, RT.NOTES_SLIDE)
260
+ return notes_slide_part
261
+
262
+
263
+ class SlideLayoutPart(BaseSlidePart):
264
+ """Slide layout part.
265
+
266
+ Corresponds to package files ``ppt/slideLayouts/slideLayout[1-9][0-9]*.xml``.
267
+ """
268
+
269
+ @lazyproperty
270
+ def slide_layout(self):
271
+ """
272
+ The |SlideLayout| object representing this part.
273
+ """
274
+ return SlideLayout(self._element, self)
275
+
276
+ @property
277
+ def slide_master(self) -> SlideMaster:
278
+ """Slide master from which this slide layout inherits properties."""
279
+ return self.part_related_by(RT.SLIDE_MASTER).slide_master
280
+
281
+
282
+ class SlideMasterPart(BaseSlidePart):
283
+ """Slide master part.
284
+
285
+ Corresponds to package files ppt/slideMasters/slideMaster[1-9][0-9]*.xml.
286
+ """
287
+
288
+ def related_slide_layout(self, rId: str) -> SlideLayout:
289
+ """Return |SlideLayout| related to this slide-master by key `rId`."""
290
+ return self.related_part(rId).slide_layout
291
+
292
+ @lazyproperty
293
+ def slide_master(self):
294
+ """
295
+ The |SlideMaster| object representing this part.
296
+ """
297
+ return SlideMaster(self._element, self)
tasks/tasksmith-74f059424102/environment/source/src/pptx/presentation.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Main presentation object."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import IO, TYPE_CHECKING, cast
6
+
7
+ from pptx.shared import PartElementProxy
8
+ from pptx.slide import SlideMasters, Slides
9
+ from pptx.util import lazyproperty
10
+
11
+ if TYPE_CHECKING:
12
+ from pptx.oxml.presentation import CT_Presentation, CT_SlideId
13
+ from pptx.parts.presentation import PresentationPart
14
+ from pptx.slide import NotesMaster, SlideLayouts
15
+ from pptx.util import Length
16
+
17
+
18
+ class Presentation(PartElementProxy):
19
+ """PresentationML (PML) presentation.
20
+
21
+ Not intended to be constructed directly. Use :func:`pptx.Presentation` to open or
22
+ create a presentation.
23
+ """
24
+
25
+ _element: CT_Presentation
26
+ part: PresentationPart # pyright: ignore[reportIncompatibleMethodOverride]
27
+
28
+ @property
29
+ def core_properties(self):
30
+ """|CoreProperties| instance for this presentation.
31
+
32
+ Provides read/write access to the Dublin Core document properties for the presentation.
33
+ """
34
+ return self.part.core_properties
35
+
36
+ @property
37
+ def notes_master(self) -> NotesMaster:
38
+ """Instance of |NotesMaster| for this presentation.
39
+
40
+ If the presentation does not have a notes master, one is created from a default template
41
+ and returned. The same single instance is returned on each call.
42
+ """
43
+ return self.part.notes_master
44
+
45
+ def save(self, file: str | IO[bytes]):
46
+ """Writes this presentation to `file`.
47
+
48
+ `file` can be either a file-path or a file-like object open for writing bytes.
49
+ """
50
+ self.part.save(file)
51
+
52
+ @property
53
+ def slide_height(self) -> Length | None:
54
+ """Height of slides in this presentation, in English Metric Units (EMU).
55
+
56
+ Returns |None| if no slide width is defined. Read/write.
57
+ """
58
+ sldSz = self._element.sldSz
59
+ if sldSz is None:
60
+ return None
61
+ return sldSz.cy
62
+
63
+ @slide_height.setter
64
+ def slide_height(self, height: Length):
65
+ sldSz = self._element.get_or_add_sldSz()
66
+ sldSz.cy = height
67
+
68
+ @property
69
+ def slide_layouts(self) -> SlideLayouts:
70
+ """|SlideLayouts| collection belonging to the first |SlideMaster| of this presentation.
71
+
72
+ A presentation can have more than one slide master and each master will have its own set
73
+ of layouts. This property is a convenience for the common case where the presentation has
74
+ only a single slide master.
75
+ """
76
+ return self.slide_masters[0].slide_layouts
77
+
78
+ @property
79
+ def slide_master(self):
80
+ """
81
+ First |SlideMaster| object belonging to this presentation. Typically,
82
+ presentations have only a single slide master. This property provides
83
+ simpler access in that common case.
84
+ """
85
+ return self.slide_masters[0]
86
+
87
+ @lazyproperty
88
+ def slide_masters(self) -> SlideMasters:
89
+ """|SlideMasters| collection of slide-masters belonging to this presentation."""
90
+ return SlideMasters(self._element.get_or_add_sldMasterIdLst(), self)
91
+
92
+ @property
93
+ def slide_width(self):
94
+ """
95
+ Width of slides in this presentation, in English Metric Units (EMU).
96
+ Returns |None| if no slide width is defined. Read/write.
97
+ """
98
+ sldSz = self._element.sldSz
99
+ if sldSz is None:
100
+ return None
101
+ return sldSz.cx
102
+
103
+ @slide_width.setter
104
+ def slide_width(self, width: Length):
105
+ sldSz = self._element.get_or_add_sldSz()
106
+ sldSz.cx = width
107
+
108
+ @lazyproperty
109
+ def slides(self):
110
+ """|Slides| object containing the slides in this presentation."""
111
+ sldIdLst = self._element.get_or_add_sldIdLst()
112
+ self.part.rename_slide_parts([cast("CT_SlideId", sldId).rId for sldId in sldIdLst])
113
+ return Slides(sldIdLst, self)
tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/__init__.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Objects used across sub-package."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ if TYPE_CHECKING:
8
+ from pptx.opc.package import XmlPart
9
+ from pptx.types import ProvidesPart
10
+
11
+
12
+ class Subshape(object):
13
+ """Provides access to the containing part for drawing elements that occur below a shape.
14
+
15
+ Access to the part is required for example to add or drop a relationship. Provides
16
+ `self._parent` attribute to subclasses.
17
+ """
18
+
19
+ def __init__(self, parent: ProvidesPart):
20
+ super(Subshape, self).__init__()
21
+ self._parent = parent
22
+
23
+ @property
24
+ def part(self) -> XmlPart:
25
+ """The package part containing this object."""
26
+ return self._parent.part
tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/autoshape.py ADDED
@@ -0,0 +1,355 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Autoshape-related objects such as Shape and Adjustment."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from numbers import Number
6
+ from typing import TYPE_CHECKING, Iterable
7
+ from xml.sax import saxutils
8
+
9
+ from pptx.dml.fill import FillFormat
10
+ from pptx.dml.line import LineFormat
11
+ from pptx.enum.shapes import MSO_AUTO_SHAPE_TYPE, MSO_SHAPE_TYPE
12
+ from pptx.shapes.base import BaseShape
13
+ from pptx.spec import autoshape_types
14
+ from pptx.text.text import TextFrame
15
+ from pptx.util import lazyproperty
16
+
17
+ if TYPE_CHECKING:
18
+ from pptx.oxml.shapes.autoshape import CT_GeomGuide, CT_PresetGeometry2D, CT_Shape
19
+ from pptx.spec import AdjustmentValue
20
+ from pptx.types import ProvidesPart
21
+
22
+
23
+ class Adjustment:
24
+ """An adjustment value for an autoshape.
25
+
26
+ An adjustment value corresponds to the position of an adjustment handle on an auto shape.
27
+ Adjustment handles are the small yellow diamond-shaped handles that appear on certain auto
28
+ shapes and allow the outline of the shape to be adjusted. For example, a rounded rectangle has
29
+ an adjustment handle that allows the radius of its corner rounding to be adjusted.
30
+
31
+ Values are |float| and generally range from 0.0 to 1.0, although the value can be negative or
32
+ greater than 1.0 in certain circumstances.
33
+ """
34
+
35
+ def __init__(self, name: str, def_val: int, actual: int | None = None):
36
+ super(Adjustment, self).__init__()
37
+ self.name = name
38
+ self.def_val = def_val
39
+ self.actual = actual
40
+
41
+ @property
42
+ def effective_value(self) -> float:
43
+ """Read/write |float| representing normalized adjustment value for this adjustment.
44
+
45
+ Actual values are a large-ish integer expressed in shape coordinates, nominally between 0
46
+ and 100,000. The effective value is normalized to a corresponding value nominally between
47
+ 0.0 and 1.0. Intuitively this represents the proportion of the width or height of the shape
48
+ at which the adjustment value is located from its starting point. For simple shapes such as
49
+ a rounded rectangle, this intuitive correspondence holds. For more complicated shapes and
50
+ at more extreme shape proportions (e.g. width is much greater than height), the value can
51
+ become negative or greater than 1.0.
52
+ """
53
+ raw_value = self.actual if self.actual is not None else self.def_val
54
+ return self._normalize(raw_value)
55
+
56
+ @effective_value.setter
57
+ def effective_value(self, value: float):
58
+ if not isinstance(value, Number):
59
+ raise ValueError(f"adjustment value must be numeric, got {repr(value)}")
60
+ self.actual = self._denormalize(value)
61
+
62
+ @staticmethod
63
+ def _denormalize(value: float) -> int:
64
+ """Return integer corresponding to normalized `raw_value` on unit basis of 100,000.
65
+
66
+ See Adjustment.normalize for additional details.
67
+ """
68
+ return int(value * 100000.0)
69
+
70
+ @staticmethod
71
+ def _normalize(raw_value: int) -> float:
72
+ """Return normalized value for `raw_value`.
73
+
74
+ A normalized value is a |float| between 0.0 and 1.0 for nominal raw values between 0 and
75
+ 100,000. Raw values less than 0 and greater than 100,000 are valid and return values
76
+ calculated on the same unit basis of 100,000.
77
+ """
78
+ return raw_value / 100000.0
79
+
80
+ @property
81
+ def val(self) -> int:
82
+ """Denormalized effective value.
83
+
84
+ Expressed in shape coordinates, this is suitable for using in the XML.
85
+ """
86
+ return self.actual if self.actual is not None else self.def_val
87
+
88
+
89
+ class AdjustmentCollection:
90
+ """Sequence of |Adjustment| instances for an auto shape.
91
+
92
+ Each represents an available adjustment for a shape of its type. Supports `len()` and indexed
93
+ access, e.g. `shape.adjustments[1] = 0.15`.
94
+ """
95
+
96
+ def __init__(self, prstGeom: CT_PresetGeometry2D):
97
+ super(AdjustmentCollection, self).__init__()
98
+ self._adjustments_ = self._initialized_adjustments(prstGeom)
99
+ self._prstGeom = prstGeom
100
+
101
+ def __getitem__(self, idx: int) -> float:
102
+ """Provides indexed access, (e.g. 'adjustments[9]')."""
103
+ return self._adjustments_[idx].effective_value
104
+
105
+ def __setitem__(self, idx: int, value: float):
106
+ """Provides item assignment via an indexed expression, e.g. `adjustments[9] = 999.9`.
107
+
108
+ Causes all adjustment values in collection to be written to the XML.
109
+ """
110
+ self._adjustments_[idx].effective_value = value
111
+ self._rewrite_guides()
112
+
113
+ def _initialized_adjustments(self, prstGeom: CT_PresetGeometry2D | None) -> list[Adjustment]:
114
+ """Return an initialized list of adjustment values based on the contents of `prstGeom`."""
115
+ if prstGeom is None:
116
+ return []
117
+ davs = AutoShapeType.default_adjustment_values(prstGeom.prst)
118
+ adjustments = [Adjustment(name, def_val) for name, def_val in davs]
119
+ self._update_adjustments_with_actuals(adjustments, prstGeom.gd_lst)
120
+ return adjustments
121
+
122
+ def _rewrite_guides(self):
123
+ """Write `a:gd` elements to the XML, one for each adjustment value.
124
+
125
+ Any existing guide elements are overwritten.
126
+ """
127
+ guides = [(adj.name, adj.val) for adj in self._adjustments_]
128
+ self._prstGeom.rewrite_guides(guides)
129
+
130
+ @staticmethod
131
+ def _update_adjustments_with_actuals(
132
+ adjustments: Iterable[Adjustment], guides: Iterable[CT_GeomGuide]
133
+ ):
134
+ """Update |Adjustment| instances in `adjustments` with actual values held in `guides`.
135
+
136
+ `guides` is a list of `a:gd` elements. Guides with a name that does not match an adjustment
137
+ object are skipped.
138
+ """
139
+ adjustments_by_name = dict((adj.name, adj) for adj in adjustments)
140
+ for gd in guides:
141
+ name = gd.name
142
+ actual = int(gd.fmla[4:])
143
+ try:
144
+ adjustment = adjustments_by_name[name]
145
+ except KeyError:
146
+ continue
147
+ adjustment.actual = actual
148
+ return
149
+
150
+ @property
151
+ def _adjustments(self) -> tuple[Adjustment, ...]:
152
+ """Sequence of |Adjustment| objects contained in collection."""
153
+ return tuple(self._adjustments_)
154
+
155
+ def __len__(self):
156
+ """Implement built-in function len()"""
157
+ return len(self._adjustments_)
158
+
159
+
160
+ class AutoShapeType:
161
+ """Provides access to metadata for an auto-shape of type identified by `autoshape_type_id`.
162
+
163
+ Instances are cached, so no more than one instance for a particular auto shape type is in
164
+ memory.
165
+
166
+ Instances provide the following attributes:
167
+
168
+ .. attribute:: autoshape_type_id
169
+
170
+ Integer uniquely identifying this auto shape type. Corresponds to a
171
+ value in `pptx.constants.MSO` like `MSO_SHAPE.ROUNDED_RECTANGLE`.
172
+
173
+ .. attribute:: basename
174
+
175
+ Base part of shape name for auto shapes of this type, e.g. `Rounded
176
+ Rectangle` becomes `Rounded Rectangle 99` when the distinguishing
177
+ integer is added to the shape name.
178
+
179
+ .. attribute:: prst
180
+
181
+ String identifier for this auto shape type used in the `a:prstGeom`
182
+ element.
183
+
184
+ """
185
+
186
+ _instances: dict[MSO_AUTO_SHAPE_TYPE, AutoShapeType] = {}
187
+
188
+ def __new__(cls, autoshape_type_id: MSO_AUTO_SHAPE_TYPE) -> AutoShapeType:
189
+ """Only create new instance on first call for content_type.
190
+
191
+ After that, use cached instance.
192
+ """
193
+ # -- if there's not a matching instance in the cache, create one --
194
+ if autoshape_type_id not in cls._instances:
195
+ inst = super(AutoShapeType, cls).__new__(cls)
196
+ cls._instances[autoshape_type_id] = inst
197
+ # -- return the instance; note that __init__() gets called either way --
198
+ return cls._instances[autoshape_type_id]
199
+
200
+ def __init__(self, autoshape_type_id: MSO_AUTO_SHAPE_TYPE):
201
+ """Initialize attributes from constant values in `pptx.spec`."""
202
+ # -- skip loading if this instance is from the cache --
203
+ if hasattr(self, "_loaded"):
204
+ return
205
+ # -- raise on bad autoshape_type_id --
206
+ if autoshape_type_id not in autoshape_types:
207
+ raise KeyError(
208
+ "no autoshape type with id '%s' in pptx.spec.autoshape_types" % autoshape_type_id
209
+ )
210
+ # -- otherwise initialize new instance --
211
+ autoshape_type = autoshape_types[autoshape_type_id]
212
+ self._autoshape_type_id = autoshape_type_id
213
+ self._basename = autoshape_type["basename"]
214
+ self._loaded = True
215
+
216
+ @property
217
+ def autoshape_type_id(self) -> MSO_AUTO_SHAPE_TYPE:
218
+ """MSO_AUTO_SHAPE_TYPE enumeration member identifying this auto shape type."""
219
+ return self._autoshape_type_id
220
+
221
+ @property
222
+ def basename(self) -> str:
223
+ """Base of shape name for this auto shape type.
224
+
225
+ A shape name is like "Rounded Rectangle 7" and appears as an XML attribute for example at
226
+ `p:sp/p:nvSpPr/p:cNvPr{name}`. This basename value is the name less the distinguishing
227
+ integer. This value is escaped because at least one autoshape-type name includes double
228
+ quotes ('"No" Symbol').
229
+ """
230
+ return saxutils.escape(self._basename, {'"': "&quot;"})
231
+
232
+ @classmethod
233
+ def default_adjustment_values(cls, prst: MSO_AUTO_SHAPE_TYPE) -> tuple[AdjustmentValue, ...]:
234
+ """Sequence of (name, value) pair adjustment value defaults for `prst` autoshape-type."""
235
+ return autoshape_types[prst]["avLst"]
236
+
237
+ @classmethod
238
+ def id_from_prst(cls, prst: str) -> MSO_AUTO_SHAPE_TYPE:
239
+ """Select auto shape type with matching `prst`.
240
+
241
+ e.g. `MSO_SHAPE.RECTANGLE` corresponding to preset geometry keyword `"rect"`.
242
+ """
243
+ return MSO_AUTO_SHAPE_TYPE.from_xml(prst)
244
+
245
+ @property
246
+ def prst(self):
247
+ """
248
+ Preset geometry identifier string for this auto shape. Used in the
249
+ `prst` attribute of `a:prstGeom` element to specify the geometry
250
+ to be used in rendering the shape, for example `'roundRect'`.
251
+ """
252
+ return MSO_AUTO_SHAPE_TYPE.to_xml(self._autoshape_type_id)
253
+
254
+
255
+ class Shape(BaseShape):
256
+ """A shape that can appear on a slide.
257
+
258
+ Corresponds to the `p:sp` element that can appear in any of the slide-type parts
259
+ (slide, slideLayout, slideMaster, notesPage, notesMaster, handoutMaster).
260
+ """
261
+
262
+ def __init__(self, sp: CT_Shape, parent: ProvidesPart):
263
+ super(Shape, self).__init__(sp, parent)
264
+ self._sp = sp
265
+
266
+ @lazyproperty
267
+ def adjustments(self) -> AdjustmentCollection:
268
+ """Read-only reference to |AdjustmentCollection| instance for this shape."""
269
+ return AdjustmentCollection(self._sp.prstGeom)
270
+
271
+ @property
272
+ def auto_shape_type(self):
273
+ """Enumeration value identifying the type of this auto shape.
274
+
275
+ Like `MSO_SHAPE.ROUNDED_RECTANGLE`. Raises |ValueError| if this shape is not an auto shape.
276
+ """
277
+ if not self._sp.is_autoshape:
278
+ raise ValueError("shape is not an auto shape")
279
+ return self._sp.prst
280
+
281
+ @lazyproperty
282
+ def fill(self):
283
+ """|FillFormat| instance for this shape.
284
+
285
+ Provides access to fill properties such as fill color.
286
+ """
287
+ return FillFormat.from_fill_parent(self._sp.spPr)
288
+
289
+ def get_or_add_ln(self):
290
+ """Return the `a:ln` element containing the line format properties XML for this shape."""
291
+ return self._sp.get_or_add_ln()
292
+
293
+ @property
294
+ def has_text_frame(self) -> bool:
295
+ """|True| if this shape can contain text. Always |True| for an AutoShape."""
296
+ return True
297
+
298
+ @lazyproperty
299
+ def line(self):
300
+ """|LineFormat| instance for this shape.
301
+
302
+ Provides access to line properties such as line color.
303
+ """
304
+ return LineFormat(self)
305
+
306
+ @property
307
+ def ln(self):
308
+ """The `a:ln` element containing the line format properties such as line color and width.
309
+
310
+ |None| if no `a:ln` element is present.
311
+ """
312
+ return self._sp.ln
313
+
314
+ @property
315
+ def shape_type(self) -> MSO_SHAPE_TYPE:
316
+ """Unique integer identifying the type of this shape, like `MSO_SHAPE_TYPE.TEXT_BOX`."""
317
+ if self.is_placeholder:
318
+ return MSO_SHAPE_TYPE.PLACEHOLDER
319
+ if self._sp.has_custom_geometry:
320
+ return MSO_SHAPE_TYPE.FREEFORM
321
+ if self._sp.is_autoshape:
322
+ return MSO_SHAPE_TYPE.AUTO_SHAPE
323
+ if self._sp.is_textbox:
324
+ return MSO_SHAPE_TYPE.TEXT_BOX
325
+ raise NotImplementedError("Shape instance of unrecognized shape type")
326
+
327
+ @property
328
+ def text(self) -> str:
329
+ """Read/write. Text in shape as a single string.
330
+
331
+ The returned string will contain a newline character (`"\\n"`) separating each paragraph
332
+ and a vertical-tab (`"\\v"`) character for each line break (soft carriage return) in the
333
+ shape's text.
334
+
335
+ Assignment to `text` replaces any text previously contained in the shape, along with any
336
+ paragraph or font formatting applied to it. A newline character (`"\\n"`) in the assigned
337
+ text causes a new paragraph to be started. A vertical-tab (`"\\v"`) character in the
338
+ assigned text causes a line-break (soft carriage-return) to be inserted. (The vertical-tab
339
+ character appears in clipboard text copied from PowerPoint as its str encoding of
340
+ line-breaks.)
341
+ """
342
+ return self.text_frame.text
343
+
344
+ @text.setter
345
+ def text(self, text: str):
346
+ self.text_frame.text = text
347
+
348
+ @property
349
+ def text_frame(self):
350
+ """|TextFrame| instance for this shape.
351
+
352
+ Contains the text of the shape and provides access to text formatting properties.
353
+ """
354
+ txBody = self._sp.get_or_add_txBody()
355
+ return TextFrame(txBody, self)
tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/base.py ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Base shape-related objects such as BaseShape."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, cast
6
+
7
+ from pptx.action import ActionSetting
8
+ from pptx.dml.effect import ShadowFormat
9
+ from pptx.shared import ElementProxy
10
+ from pptx.util import lazyproperty
11
+
12
+ if TYPE_CHECKING:
13
+ from pptx.enum.shapes import MSO_SHAPE_TYPE, PP_PLACEHOLDER
14
+ from pptx.oxml.shapes import ShapeElement
15
+ from pptx.oxml.shapes.shared import CT_Placeholder
16
+ from pptx.parts.slide import BaseSlidePart
17
+ from pptx.types import ProvidesPart
18
+ from pptx.util import Length
19
+
20
+
21
+ class BaseShape(object):
22
+ """Base class for shape objects.
23
+
24
+ Subclasses include |Shape|, |Picture|, and |GraphicFrame|.
25
+ """
26
+
27
+ def __init__(self, shape_elm: ShapeElement, parent: ProvidesPart):
28
+ super().__init__()
29
+ self._element = shape_elm
30
+ self._parent = parent
31
+
32
+ def __eq__(self, other: object) -> bool:
33
+ """|True| if this shape object proxies the same element as *other*.
34
+
35
+ Equality for proxy objects is defined as referring to the same XML element, whether or not
36
+ they are the same proxy object instance.
37
+ """
38
+ if not isinstance(other, BaseShape):
39
+ return False
40
+ return self._element is other._element
41
+
42
+ def __ne__(self, other: object) -> bool:
43
+ if not isinstance(other, BaseShape):
44
+ return True
45
+ return self._element is not other._element
46
+
47
+ @lazyproperty
48
+ def click_action(self) -> ActionSetting:
49
+ """|ActionSetting| instance providing access to click behaviors.
50
+
51
+ Click behaviors are hyperlink-like behaviors including jumping to a hyperlink (web page)
52
+ or to another slide in the presentation. The click action is that defined on the overall
53
+ shape, not a run of text within the shape. An |ActionSetting| object is always returned,
54
+ even when no click behavior is defined on the shape.
55
+ """
56
+ cNvPr = self._element._nvXxPr.cNvPr # pyright: ignore[reportPrivateUsage]
57
+ return ActionSetting(cNvPr, self)
58
+
59
+ @property
60
+ def element(self) -> ShapeElement:
61
+ """`lxml` element for this shape, e.g. a CT_Shape instance.
62
+
63
+ Note that manipulating this element improperly can produce an invalid presentation file.
64
+ Make sure you know what you're doing if you use this to change the underlying XML.
65
+ """
66
+ return self._element
67
+
68
+ @property
69
+ def has_chart(self) -> bool:
70
+ """|True| if this shape is a graphic frame containing a chart object.
71
+
72
+ |False| otherwise. When |True|, the chart object can be accessed using the ``.chart``
73
+ property.
74
+ """
75
+ # This implementation is unconditionally False, the True version is
76
+ # on GraphicFrame subclass.
77
+ return False
78
+
79
+ @property
80
+ def has_table(self) -> bool:
81
+ """|True| if this shape is a graphic frame containing a table object.
82
+
83
+ |False| otherwise. When |True|, the table object can be accessed using the ``.table``
84
+ property.
85
+ """
86
+ # This implementation is unconditionally False, the True version is
87
+ # on GraphicFrame subclass.
88
+ return False
89
+
90
+ @property
91
+ def has_text_frame(self) -> bool:
92
+ """|True| if this shape can contain text."""
93
+ # overridden on Shape to return True. Only <p:sp> has text frame
94
+ return False
95
+
96
+ @property
97
+ def height(self) -> Length:
98
+ """Read/write. Integer distance between top and bottom extents of shape in EMUs."""
99
+ return self._element.cy
100
+
101
+ @height.setter
102
+ def height(self, value: Length):
103
+ self._element.cy = value
104
+
105
+ @property
106
+ def is_placeholder(self) -> bool:
107
+ """True if this shape is a placeholder.
108
+
109
+ A shape is a placeholder if it has a <p:ph> element.
110
+ """
111
+ return self._element.has_ph_elm
112
+
113
+ @property
114
+ def left(self) -> Length:
115
+ """Integer distance of the left edge of this shape from the left edge of the slide.
116
+
117
+ Read/write. Expressed in English Metric Units (EMU)
118
+ """
119
+ return self._element.x
120
+
121
+ @left.setter
122
+ def left(self, value: Length):
123
+ self._element.x = value
124
+
125
+ @property
126
+ def name(self) -> str:
127
+ """Name of this shape, e.g. 'Picture 7'."""
128
+ return self._element.shape_name
129
+
130
+ @name.setter
131
+ def name(self, value: str):
132
+ self._element._nvXxPr.cNvPr.name = value # pyright: ignore[reportPrivateUsage]
133
+
134
+ @property
135
+ def part(self) -> BaseSlidePart:
136
+ """The package part containing this shape.
137
+
138
+ A |BaseSlidePart| subclass in this case. Access to a slide part should only be required if
139
+ you are extending the behavior of |pp| API objects.
140
+ """
141
+ return cast("BaseSlidePart", self._parent.part)
142
+
143
+ @property
144
+ def placeholder_format(self) -> _PlaceholderFormat:
145
+ """Provides access to placeholder-specific properties such as placeholder type.
146
+
147
+ Raises |ValueError| on access if the shape is not a placeholder.
148
+ """
149
+ ph = self._element.ph
150
+ if ph is None:
151
+ raise ValueError("shape is not a placeholder")
152
+ return _PlaceholderFormat(ph)
153
+
154
+ @property
155
+ def rotation(self) -> float:
156
+ """Degrees of clockwise rotation.
157
+
158
+ Read/write float. Negative values can be assigned to indicate counter-clockwise rotation,
159
+ e.g. assigning -45.0 will change setting to 315.0.
160
+ """
161
+ return self._element.rot
162
+
163
+ @rotation.setter
164
+ def rotation(self, value: float):
165
+ self._element.rot = value
166
+
167
+ @lazyproperty
168
+ def shadow(self) -> ShadowFormat:
169
+ """|ShadowFormat| object providing access to shadow for this shape.
170
+
171
+ A |ShadowFormat| object is always returned, even when no shadow is
172
+ explicitly defined on this shape (i.e. it inherits its shadow
173
+ behavior).
174
+ """
175
+ return ShadowFormat(self._element.spPr)
176
+
177
+ @property
178
+ def shape_id(self) -> int:
179
+ """Read-only positive integer identifying this shape.
180
+
181
+ The id of a shape is unique among all shapes on a slide.
182
+ """
183
+ return self._element.shape_id
184
+
185
+ @property
186
+ def shape_type(self) -> MSO_SHAPE_TYPE:
187
+ """A member of MSO_SHAPE_TYPE classifying this shape by type.
188
+
189
+ Like ``MSO_SHAPE_TYPE.CHART``. Must be implemented by subclasses.
190
+ """
191
+ raise NotImplementedError(f"{type(self).__name__} does not implement `.shape_type`")
192
+
193
+ @property
194
+ def top(self) -> Length:
195
+ """Distance from the top edge of the slide to the top edge of this shape.
196
+
197
+ Read/write. Expressed in English Metric Units (EMU)
198
+ """
199
+ return self._element.y
200
+
201
+ @top.setter
202
+ def top(self, value: Length):
203
+ self._element.y = value
204
+
205
+ @property
206
+ def width(self) -> Length:
207
+ """Distance between left and right extents of this shape.
208
+
209
+ Read/write. Expressed in English Metric Units (EMU).
210
+ """
211
+ return self._element.cx
212
+
213
+ @width.setter
214
+ def width(self, value: Length):
215
+ self._element.cx = value
216
+
217
+
218
+ class _PlaceholderFormat(ElementProxy):
219
+ """Provides properties specific to placeholders, such as the placeholder type.
220
+
221
+ Accessed via the :attr:`~.BaseShape.placeholder_format` property of a placeholder shape,
222
+ """
223
+
224
+ def __init__(self, element: CT_Placeholder):
225
+ super().__init__(element)
226
+ self._ph = element
227
+
228
+ @property
229
+ def element(self) -> CT_Placeholder:
230
+ """The `p:ph` element proxied by this object."""
231
+ return self._ph
232
+
233
+ @property
234
+ def idx(self) -> int:
235
+ """Integer placeholder 'idx' attribute."""
236
+ return self._ph.idx
237
+
238
+ @property
239
+ def type(self) -> PP_PLACEHOLDER:
240
+ """Placeholder type.
241
+
242
+ A member of the :ref:`PpPlaceholderType` enumeration, e.g. PP_PLACEHOLDER.CHART
243
+ """
244
+ return self._ph.type
tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/connector.py ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Connector (line) shape and related objects.
2
+
3
+ A connector is a line shape having end-points that can be connected to other
4
+ objects (but not to other connectors). A connector can be straight, have
5
+ elbows, or can be curved.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from pptx.dml.line import LineFormat
11
+ from pptx.enum.shapes import MSO_SHAPE_TYPE
12
+ from pptx.shapes.base import BaseShape
13
+ from pptx.util import Emu, lazyproperty
14
+
15
+
16
+ class Connector(BaseShape):
17
+ """Connector (line) shape.
18
+
19
+ A connector is a linear shape having end-points that can be connected to
20
+ other objects (but not to other connectors). A connector can be straight,
21
+ have elbows, or can be curved.
22
+ """
23
+
24
+ def begin_connect(self, shape, cxn_pt_idx):
25
+ """
26
+ **EXPERIMENTAL** - *The current implementation only works properly
27
+ with rectangular shapes, such as pictures and rectangles. Use with
28
+ other shape types may cause unexpected visual alignment of the
29
+ connected end-point and could lead to a load error if cxn_pt_idx
30
+ exceeds the connection point count available on the connected shape.
31
+ That said, a quick test should reveal what to expect when using this
32
+ method with other shape types.*
33
+
34
+ Connect the beginning of this connector to *shape* at the connection
35
+ point specified by *cxn_pt_idx*. Each shape has zero or more
36
+ connection points and they are identified by index, starting with 0.
37
+ Generally, the first connection point of a shape is at the top center
38
+ of its bounding box and numbering proceeds counter-clockwise from
39
+ there. However this is only a convention and may vary, especially
40
+ with non built-in shapes.
41
+ """
42
+ self._connect_begin_to(shape, cxn_pt_idx)
43
+ self._move_begin_to_cxn(shape, cxn_pt_idx)
44
+
45
+ @property
46
+ def begin_x(self):
47
+ """
48
+ Return the X-position of the begin point of this connector, in
49
+ English Metric Units (as a |Length| object).
50
+ """
51
+ cxnSp = self._element
52
+ x, cx, flipH = cxnSp.x, cxnSp.cx, cxnSp.flipH
53
+ begin_x = x + cx if flipH else x
54
+ return Emu(begin_x)
55
+
56
+ @begin_x.setter
57
+ def begin_x(self, value):
58
+ cxnSp = self._element
59
+ x, cx, flipH, new_x = cxnSp.x, cxnSp.cx, cxnSp.flipH, int(value)
60
+
61
+ if flipH:
62
+ old_x = x + cx
63
+ dx = abs(new_x - old_x)
64
+ if new_x >= old_x:
65
+ cxnSp.cx = cx + dx
66
+ elif dx <= cx:
67
+ cxnSp.cx = cx - dx
68
+ else:
69
+ cxnSp.flipH = False
70
+ cxnSp.x = new_x
71
+ cxnSp.cx = dx - cx
72
+ else:
73
+ dx = abs(new_x - x)
74
+ if new_x <= x:
75
+ cxnSp.x = new_x
76
+ cxnSp.cx = cx + dx
77
+ elif dx <= cx:
78
+ cxnSp.x = new_x
79
+ cxnSp.cx = cx - dx
80
+ else:
81
+ cxnSp.flipH = True
82
+ cxnSp.x = x + cx
83
+ cxnSp.cx = dx - cx
84
+
85
+ @property
86
+ def begin_y(self):
87
+ """
88
+ Return the Y-position of the begin point of this connector, in
89
+ English Metric Units (as a |Length| object).
90
+ """
91
+ cxnSp = self._element
92
+ y, cy, flipV = cxnSp.y, cxnSp.cy, cxnSp.flipV
93
+ begin_y = y + cy if flipV else y
94
+ return Emu(begin_y)
95
+
96
+ @begin_y.setter
97
+ def begin_y(self, value):
98
+ cxnSp = self._element
99
+ y, cy, flipV, new_y = cxnSp.y, cxnSp.cy, cxnSp.flipV, int(value)
100
+
101
+ if flipV:
102
+ old_y = y + cy
103
+ dy = abs(new_y - old_y)
104
+ if new_y >= old_y:
105
+ cxnSp.cy = cy + dy
106
+ elif dy <= cy:
107
+ cxnSp.cy = cy - dy
108
+ else:
109
+ cxnSp.flipV = False
110
+ cxnSp.y = new_y
111
+ cxnSp.cy = dy - cy
112
+ else:
113
+ dy = abs(new_y - y)
114
+ if new_y <= y:
115
+ cxnSp.y = new_y
116
+ cxnSp.cy = cy + dy
117
+ elif dy <= cy:
118
+ cxnSp.y = new_y
119
+ cxnSp.cy = cy - dy
120
+ else:
121
+ cxnSp.flipV = True
122
+ cxnSp.y = y + cy
123
+ cxnSp.cy = dy - cy
124
+
125
+ def end_connect(self, shape, cxn_pt_idx):
126
+ """
127
+ **EXPERIMENTAL** - *The current implementation only works properly
128
+ with rectangular shapes, such as pictures and rectangles. Use with
129
+ other shape types may cause unexpected visual alignment of the
130
+ connected end-point and could lead to a load error if cxn_pt_idx
131
+ exceeds the connection point count available on the connected shape.
132
+ That said, a quick test should reveal what to expect when using this
133
+ method with other shape types.*
134
+
135
+ Connect the ending of this connector to *shape* at the connection
136
+ point specified by *cxn_pt_idx*.
137
+ """
138
+ self._connect_end_to(shape, cxn_pt_idx)
139
+ self._move_end_to_cxn(shape, cxn_pt_idx)
140
+
141
+ @property
142
+ def end_x(self):
143
+ """
144
+ Return the X-position of the end point of this connector, in English
145
+ Metric Units (as a |Length| object).
146
+ """
147
+ cxnSp = self._element
148
+ x, cx, flipH = cxnSp.x, cxnSp.cx, cxnSp.flipH
149
+ end_x = x if flipH else x + cx
150
+ return Emu(end_x)
151
+
152
+ @end_x.setter
153
+ def end_x(self, value):
154
+ cxnSp = self._element
155
+ x, cx, flipH, new_x = cxnSp.x, cxnSp.cx, cxnSp.flipH, int(value)
156
+
157
+ if flipH:
158
+ dx = abs(new_x - x)
159
+ if new_x <= x:
160
+ cxnSp.x = new_x
161
+ cxnSp.cx = cx + dx
162
+ elif dx <= cx:
163
+ cxnSp.x = new_x
164
+ cxnSp.cx = cx - dx
165
+ else:
166
+ cxnSp.flipH = False
167
+ cxnSp.x = x + cx
168
+ cxnSp.cx = dx - cx
169
+ else:
170
+ old_x = x + cx
171
+ dx = abs(new_x - old_x)
172
+ if new_x >= old_x:
173
+ cxnSp.cx = cx + dx
174
+ elif dx <= cx:
175
+ cxnSp.cx = cx - dx
176
+ else:
177
+ cxnSp.flipH = True
178
+ cxnSp.x = new_x
179
+ cxnSp.cx = dx - cx
180
+
181
+ @property
182
+ def end_y(self):
183
+ """
184
+ Return the Y-position of the end point of this connector, in English
185
+ Metric Units (as a |Length| object).
186
+ """
187
+ cxnSp = self._element
188
+ y, cy, flipV = cxnSp.y, cxnSp.cy, cxnSp.flipV
189
+ end_y = y if flipV else y + cy
190
+ return Emu(end_y)
191
+
192
+ @end_y.setter
193
+ def end_y(self, value):
194
+ cxnSp = self._element
195
+ y, cy, flipV, new_y = cxnSp.y, cxnSp.cy, cxnSp.flipV, int(value)
196
+
197
+ if flipV:
198
+ dy = abs(new_y - y)
199
+ if new_y <= y:
200
+ cxnSp.y = new_y
201
+ cxnSp.cy = cy + dy
202
+ elif dy <= cy:
203
+ cxnSp.y = new_y
204
+ cxnSp.cy = cy - dy
205
+ else:
206
+ cxnSp.flipV = False
207
+ cxnSp.y = y + cy
208
+ cxnSp.cy = dy - cy
209
+ else:
210
+ old_y = y + cy
211
+ dy = abs(new_y - old_y)
212
+ if new_y >= old_y:
213
+ cxnSp.cy = cy + dy
214
+ elif dy <= cy:
215
+ cxnSp.cy = cy - dy
216
+ else:
217
+ cxnSp.flipV = True
218
+ cxnSp.y = new_y
219
+ cxnSp.cy = dy - cy
220
+
221
+ def get_or_add_ln(self):
222
+ """Helper method required by |LineFormat|."""
223
+ return self._element.spPr.get_or_add_ln()
224
+
225
+ @lazyproperty
226
+ def line(self):
227
+ """|LineFormat| instance for this connector.
228
+
229
+ Provides access to line properties such as line color, width, and
230
+ line style.
231
+ """
232
+ return LineFormat(self)
233
+
234
+ @property
235
+ def ln(self):
236
+ """Helper method required by |LineFormat|.
237
+
238
+ The ``<a:ln>`` element containing the line format properties such as
239
+ line color and width. |None| if no `<a:ln>` element is present.
240
+ """
241
+ return self._element.spPr.ln
242
+
243
+ @property
244
+ def shape_type(self):
245
+ """Member of `MSO_SHAPE_TYPE` identifying the type of this shape.
246
+
247
+ Unconditionally `MSO_SHAPE_TYPE.LINE` for a `Connector` object.
248
+ """
249
+ return MSO_SHAPE_TYPE.LINE
250
+
251
+ def _connect_begin_to(self, shape, cxn_pt_idx):
252
+ """
253
+ Add or update a stCxn element for this connector that connects its
254
+ begin point to the connection point of *shape* specified by
255
+ *cxn_pt_idx*.
256
+ """
257
+ cNvCxnSpPr = self._element.nvCxnSpPr.cNvCxnSpPr
258
+ stCxn = cNvCxnSpPr.get_or_add_stCxn()
259
+ stCxn.id = shape.shape_id
260
+ stCxn.idx = cxn_pt_idx
261
+
262
+ def _connect_end_to(self, shape, cxn_pt_idx):
263
+ """
264
+ Add or update an endCxn element for this connector that connects its
265
+ end point to the connection point of *shape* specified by
266
+ *cxn_pt_idx*.
267
+ """
268
+ cNvCxnSpPr = self._element.nvCxnSpPr.cNvCxnSpPr
269
+ endCxn = cNvCxnSpPr.get_or_add_endCxn()
270
+ endCxn.id = shape.shape_id
271
+ endCxn.idx = cxn_pt_idx
272
+
273
+ def _move_begin_to_cxn(self, shape, cxn_pt_idx):
274
+ """
275
+ Move the begin point of this connector to coordinates of the
276
+ connection point of *shape* specified by *cxn_pt_idx*.
277
+ """
278
+ x, y, cx, cy = shape.left, shape.top, shape.width, shape.height
279
+ self.begin_x, self.begin_y = {
280
+ 0: (int(x + cx / 2), y),
281
+ 1: (x, int(y + cy / 2)),
282
+ 2: (int(x + cx / 2), y + cy),
283
+ 3: (x + cx, int(y + cy / 2)),
284
+ }[cxn_pt_idx]
285
+
286
+ def _move_end_to_cxn(self, shape, cxn_pt_idx):
287
+ """
288
+ Move the end point of this connector to the coordinates of the
289
+ connection point of *shape* specified by *cxn_pt_idx*.
290
+ """
291
+ x, y, cx, cy = shape.left, shape.top, shape.width, shape.height
292
+ self.end_x, self.end_y = {
293
+ 0: (int(x + cx / 2), y),
294
+ 1: (x, int(y + cy / 2)),
295
+ 2: (int(x + cx / 2), y + cy),
296
+ 3: (x + cx, int(y + cy / 2)),
297
+ }[cxn_pt_idx]
tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/freeform.py ADDED
@@ -0,0 +1,338 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Objects related to construction of freeform shapes."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Sequence
6
+ from typing import TYPE_CHECKING, Iterable, Iterator
7
+
8
+ from pptx.util import Emu, lazyproperty
9
+
10
+ if TYPE_CHECKING:
11
+ from typing_extensions import TypeAlias
12
+
13
+ from pptx.oxml.shapes.autoshape import (
14
+ CT_Path2D,
15
+ CT_Path2DClose,
16
+ CT_Path2DLineTo,
17
+ CT_Path2DMoveTo,
18
+ CT_Shape,
19
+ )
20
+ from pptx.shapes.shapetree import _BaseGroupShapes # pyright: ignore[reportPrivateUsage]
21
+ from pptx.util import Length
22
+
23
+ CT_DrawingOperation: TypeAlias = "CT_Path2DClose | CT_Path2DLineTo | CT_Path2DMoveTo"
24
+ DrawingOperation: TypeAlias = "_LineSegment | _MoveTo | _Close"
25
+
26
+
27
+ class FreeformBuilder(Sequence[DrawingOperation]):
28
+ """Allows a freeform shape to be specified and created.
29
+
30
+ The initial pen position is provided on construction. From there, drawing proceeds using
31
+ successive calls to draw line segments. The freeform shape may be closed by calling the
32
+ :meth:`close` method.
33
+
34
+ A shape may have more than one contour, in which case overlapping areas are "subtracted". A
35
+ contour is a sequence of line segments beginning with a "move-to" operation. A move-to
36
+ operation is automatically inserted in each new freeform; additional move-to ops can be
37
+ inserted with the `.move_to()` method.
38
+ """
39
+
40
+ def __init__(
41
+ self,
42
+ shapes: _BaseGroupShapes,
43
+ start_x: Length,
44
+ start_y: Length,
45
+ x_scale: float,
46
+ y_scale: float,
47
+ ):
48
+ super(FreeformBuilder, self).__init__()
49
+ self._shapes = shapes
50
+ self._start_x = start_x
51
+ self._start_y = start_y
52
+ self._x_scale = x_scale
53
+ self._y_scale = y_scale
54
+
55
+ def __getitem__( # pyright: ignore[reportIncompatibleMethodOverride]
56
+ self, idx: int
57
+ ) -> DrawingOperation:
58
+ return self._drawing_operations.__getitem__(idx)
59
+
60
+ def __iter__(self) -> Iterator[DrawingOperation]:
61
+ return self._drawing_operations.__iter__()
62
+
63
+ def __len__(self):
64
+ return self._drawing_operations.__len__()
65
+
66
+ @classmethod
67
+ def new(
68
+ cls,
69
+ shapes: _BaseGroupShapes,
70
+ start_x: float,
71
+ start_y: float,
72
+ x_scale: float,
73
+ y_scale: float,
74
+ ):
75
+ """Return a new |FreeformBuilder| object.
76
+
77
+ The initial pen location is specified (in local coordinates) by
78
+ (`start_x`, `start_y`).
79
+ """
80
+ return cls(shapes, Emu(int(round(start_x))), Emu(int(round(start_y))), x_scale, y_scale)
81
+
82
+ def add_line_segments(self, vertices: Iterable[tuple[float, float]], close: bool = True):
83
+ """Add a straight line segment to each point in `vertices`.
84
+
85
+ `vertices` must be an iterable of (x, y) pairs (2-tuples). Each x and y value is rounded
86
+ to the nearest integer before use. The optional `close` parameter determines whether the
87
+ resulting contour is `closed` or left `open`.
88
+
89
+ Returns this |FreeformBuilder| object so it can be used in chained calls.
90
+ """
91
+ for x, y in vertices:
92
+ self._add_line_segment(x, y)
93
+ if close:
94
+ self._add_close()
95
+ return self
96
+
97
+ def convert_to_shape(self, origin_x: Length = Emu(0), origin_y: Length = Emu(0)):
98
+ """Return new freeform shape positioned relative to specified offset.
99
+
100
+ `origin_x` and `origin_y` locate the origin of the local coordinate system in slide
101
+ coordinates (EMU), perhaps most conveniently by use of a |Length| object.
102
+
103
+ Note that this method may be called more than once to add multiple shapes of the same
104
+ geometry in different locations on the slide.
105
+ """
106
+ sp = self._add_freeform_sp(origin_x, origin_y)
107
+ path = self._start_path(sp)
108
+ for drawing_operation in self:
109
+ drawing_operation.apply_operation_to(path)
110
+ return self._shapes._shape_factory(sp) # pyright: ignore[reportPrivateUsage]
111
+
112
+ def move_to(self, x: float, y: float):
113
+ """Move pen to (x, y) (local coordinates) without drawing line.
114
+
115
+ Returns this |FreeformBuilder| object so it can be used in chained calls.
116
+ """
117
+ self._drawing_operations.append(_MoveTo.new(self, x, y))
118
+ return self
119
+
120
+ @property
121
+ def shape_offset_x(self) -> Length:
122
+ """Return x distance of shape origin from local coordinate origin.
123
+
124
+ The returned integer represents the leftmost extent of the freeform shape, in local
125
+ coordinates. Note that the bounding box of the shape need not start at the local origin.
126
+ """
127
+ min_x = self._start_x
128
+ for drawing_operation in self:
129
+ if isinstance(drawing_operation, _Close):
130
+ continue
131
+ min_x = min(min_x, drawing_operation.x)
132
+ return Emu(min_x)
133
+
134
+ @property
135
+ def shape_offset_y(self) -> Length:
136
+ """Return y distance of shape origin from local coordinate origin.
137
+
138
+ The returned integer represents the topmost extent of the freeform shape, in local
139
+ coordinates. Note that the bounding box of the shape need not start at the local origin.
140
+ """
141
+ min_y = self._start_y
142
+ for drawing_operation in self:
143
+ if isinstance(drawing_operation, _Close):
144
+ continue
145
+ min_y = min(min_y, drawing_operation.y)
146
+ return Emu(min_y)
147
+
148
+ def _add_close(self):
149
+ """Add a close |_Close| operation to the drawing sequence."""
150
+ self._drawing_operations.append(_Close.new())
151
+
152
+ def _add_freeform_sp(self, origin_x: Length, origin_y: Length):
153
+ """Add a freeform `p:sp` element having no drawing elements.
154
+
155
+ `origin_x` and `origin_y` are specified in slide coordinates, and represent the location
156
+ of the local coordinates origin on the slide.
157
+ """
158
+ spTree = self._shapes._spTree # pyright: ignore[reportPrivateUsage]
159
+ return spTree.add_freeform_sp(
160
+ origin_x + self._left, origin_y + self._top, self._width, self._height
161
+ )
162
+
163
+ def _add_line_segment(self, x: float, y: float) -> None:
164
+ """Add a |_LineSegment| operation to the drawing sequence."""
165
+ self._drawing_operations.append(_LineSegment.new(self, x, y))
166
+
167
+ @lazyproperty
168
+ def _drawing_operations(self) -> list[DrawingOperation]:
169
+ """Return the sequence of drawing operation objects for freeform."""
170
+ return []
171
+
172
+ @property
173
+ def _dx(self) -> Length:
174
+ """Return width of this shape's path in local units."""
175
+ min_x = max_x = self._start_x
176
+ for drawing_operation in self:
177
+ if isinstance(drawing_operation, _Close):
178
+ continue
179
+ min_x = min(min_x, drawing_operation.x)
180
+ max_x = max(max_x, drawing_operation.x)
181
+ return Emu(max_x - min_x)
182
+
183
+ @property
184
+ def _dy(self) -> Length:
185
+ """Return integer height of this shape's path in local units."""
186
+ min_y = max_y = self._start_y
187
+ for drawing_operation in self:
188
+ if isinstance(drawing_operation, _Close):
189
+ continue
190
+ min_y = min(min_y, drawing_operation.y)
191
+ max_y = max(max_y, drawing_operation.y)
192
+ return Emu(max_y - min_y)
193
+
194
+ @property
195
+ def _height(self):
196
+ """Return vertical size of this shape's path in slide coordinates.
197
+
198
+ This value is based on the actual extents of the shape and does not include any
199
+ positioning offset.
200
+ """
201
+ return int(round(self._dy * self._y_scale))
202
+
203
+ @property
204
+ def _left(self):
205
+ """Return leftmost extent of this shape's path in slide coordinates.
206
+
207
+ Note that this value does not include any positioning offset; it assumes the drawing
208
+ (local) coordinate origin is at (0, 0) on the slide.
209
+ """
210
+ return int(round(self.shape_offset_x * self._x_scale))
211
+
212
+ def _local_to_shape(self, local_x: Length, local_y: Length) -> tuple[Length, Length]:
213
+ """Translate local coordinates point to shape coordinates.
214
+
215
+ Shape coordinates have the same unit as local coordinates, but are offset such that the
216
+ origin of the shape coordinate system (0, 0) is located at the top-left corner of the
217
+ shape bounding box.
218
+ """
219
+ return Emu(local_x - self.shape_offset_x), Emu(local_y - self.shape_offset_y)
220
+
221
+ def _start_path(self, sp: CT_Shape) -> CT_Path2D:
222
+ """Return a newly created `a:path` element added to `sp`.
223
+
224
+ The returned `a:path` element has an `a:moveTo` element representing the shape starting
225
+ point as its only child.
226
+ """
227
+ path = sp.add_path(w=self._dx, h=self._dy)
228
+ path.add_moveTo(*self._local_to_shape(self._start_x, self._start_y))
229
+ return path
230
+
231
+ @property
232
+ def _top(self):
233
+ """Return topmost extent of this shape's path in slide coordinates.
234
+
235
+ Note that this value does not include any positioning offset; it assumes the drawing
236
+ (local) coordinate origin is located at slide coordinates (0, 0) (top-left corner of
237
+ slide).
238
+ """
239
+ return int(round(self.shape_offset_y * self._y_scale))
240
+
241
+ @property
242
+ def _width(self):
243
+ """Return width of this shape's path in slide coordinates.
244
+
245
+ This value is based on the actual extents of the shape path and does not include any
246
+ positioning offset.
247
+ """
248
+ return int(round(self._dx * self._x_scale))
249
+
250
+
251
+ class _BaseDrawingOperation(object):
252
+ """Base class for freeform drawing operations.
253
+
254
+ A drawing operation has at least one location (x, y) in local coordinates.
255
+ """
256
+
257
+ def __init__(self, freeform_builder: FreeformBuilder, x: Length, y: Length):
258
+ super(_BaseDrawingOperation, self).__init__()
259
+ self._freeform_builder = freeform_builder
260
+ self._x = x
261
+ self._y = y
262
+
263
+ def apply_operation_to(self, path: CT_Path2D) -> CT_DrawingOperation:
264
+ """Add the XML element(s) implementing this operation to `path`.
265
+
266
+ Must be implemented by each subclass.
267
+ """
268
+ raise NotImplementedError("must be implemented by each subclass")
269
+
270
+ @property
271
+ def x(self) -> Length:
272
+ """Return the horizontal (x) target location of this operation.
273
+
274
+ The returned value is an integer in local coordinates.
275
+ """
276
+ return self._x
277
+
278
+ @property
279
+ def y(self) -> Length:
280
+ """Return the vertical (y) target location of this operation.
281
+
282
+ The returned value is an integer in local coordinates.
283
+ """
284
+ return self._y
285
+
286
+
287
+ class _Close(object):
288
+ """Specifies adding a `<a:close/>` element to the current contour."""
289
+
290
+ @classmethod
291
+ def new(cls) -> _Close:
292
+ """Return a new _Close object."""
293
+ return cls()
294
+
295
+ def apply_operation_to(self, path: CT_Path2D) -> CT_Path2DClose:
296
+ """Add `a:close` element to `path`."""
297
+ return path.add_close()
298
+
299
+
300
+ class _LineSegment(_BaseDrawingOperation):
301
+ """Specifies a straight line segment ending at the specified point."""
302
+
303
+ @classmethod
304
+ def new(cls, freeform_builder: FreeformBuilder, x: float, y: float) -> _LineSegment:
305
+ """Return a new _LineSegment object ending at point *(x, y)*.
306
+
307
+ Both `x` and `y` are rounded to the nearest integer before use.
308
+ """
309
+ return cls(freeform_builder, Emu(int(round(x))), Emu(int(round(y))))
310
+
311
+ def apply_operation_to(self, path: CT_Path2D) -> CT_Path2DLineTo:
312
+ """Add `a:lnTo` element to `path` for this line segment.
313
+
314
+ Returns the `a:lnTo` element newly added to the path.
315
+ """
316
+ return path.add_lnTo(
317
+ Emu(self._x - self._freeform_builder.shape_offset_x),
318
+ Emu(self._y - self._freeform_builder.shape_offset_y),
319
+ )
320
+
321
+
322
+ class _MoveTo(_BaseDrawingOperation):
323
+ """Specifies a new pen position."""
324
+
325
+ @classmethod
326
+ def new(cls, freeform_builder: FreeformBuilder, x: float, y: float) -> _MoveTo:
327
+ """Return a new _MoveTo object for move to point `(x, y)`.
328
+
329
+ Both `x` and `y` are rounded to the nearest integer before use.
330
+ """
331
+ return cls(freeform_builder, Emu(int(round(x))), Emu(int(round(y))))
332
+
333
+ def apply_operation_to(self, path: CT_Path2D) -> CT_Path2DMoveTo:
334
+ """Add `a:moveTo` element to `path` for this line segment."""
335
+ return path.add_moveTo(
336
+ Emu(self._x - self._freeform_builder.shape_offset_x),
337
+ Emu(self._y - self._freeform_builder.shape_offset_y),
338
+ )
tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/graphfrm.py ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Graphic Frame shape and related objects.
2
+
3
+ A graphic frame is a common container for table, chart, smart art, and media
4
+ objects.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from typing import TYPE_CHECKING, cast
10
+
11
+ from pptx.enum.shapes import MSO_SHAPE_TYPE
12
+ from pptx.shapes.base import BaseShape
13
+ from pptx.shared import ParentedElementProxy
14
+ from pptx.spec import (
15
+ GRAPHIC_DATA_URI_CHART,
16
+ GRAPHIC_DATA_URI_OLEOBJ,
17
+ GRAPHIC_DATA_URI_TABLE,
18
+ )
19
+ from pptx.table import Table
20
+ from pptx.util import lazyproperty
21
+
22
+ if TYPE_CHECKING:
23
+ from pptx.chart.chart import Chart
24
+ from pptx.dml.effect import ShadowFormat
25
+ from pptx.oxml.shapes.graphfrm import CT_GraphicalObjectData, CT_GraphicalObjectFrame
26
+ from pptx.parts.chart import ChartPart
27
+ from pptx.parts.slide import BaseSlidePart
28
+ from pptx.types import ProvidesPart
29
+
30
+
31
+ class GraphicFrame(BaseShape):
32
+ """Container shape for table, chart, smart art, and media objects.
33
+
34
+ Corresponds to a `p:graphicFrame` element in the shape tree.
35
+ """
36
+
37
+ def __init__(self, graphicFrame: CT_GraphicalObjectFrame, parent: ProvidesPart):
38
+ super().__init__(graphicFrame, parent)
39
+ self._graphicFrame = graphicFrame
40
+
41
+ @property
42
+ def chart(self) -> Chart:
43
+ """The |Chart| object containing the chart in this graphic frame.
44
+
45
+ Raises |ValueError| if this graphic frame does not contain a chart.
46
+ """
47
+ if not self.has_chart:
48
+ raise ValueError("shape does not contain a chart")
49
+ return self.chart_part.chart
50
+
51
+ @property
52
+ def chart_part(self) -> ChartPart:
53
+ """The |ChartPart| object containing the chart in this graphic frame."""
54
+ chart_rId = self._graphicFrame.chart_rId
55
+ if chart_rId is None:
56
+ raise ValueError("this graphic frame does not contain a chart")
57
+ return cast("ChartPart", self.part.related_part(chart_rId))
58
+
59
+ @property
60
+ def has_chart(self) -> bool:
61
+ """|True| if this graphic frame contains a chart object. |False| otherwise.
62
+
63
+ When |True|, the chart object can be accessed using the `.chart` property.
64
+ """
65
+ return self._graphicFrame.graphicData_uri == GRAPHIC_DATA_URI_CHART
66
+
67
+ @property
68
+ def has_table(self) -> bool:
69
+ """|True| if this graphic frame contains a table object, |False| otherwise.
70
+
71
+ When |True|, the table object can be accessed using the `.table` property.
72
+ """
73
+ return self._graphicFrame.graphicData_uri == GRAPHIC_DATA_URI_TABLE
74
+
75
+ @property
76
+ def ole_format(self) -> _OleFormat:
77
+ """_OleFormat object for this graphic-frame shape.
78
+
79
+ Raises `ValueError` on a GraphicFrame instance that does not contain an OLE object.
80
+
81
+ An shape that contains an OLE object will have `.shape_type` of either
82
+ `EMBEDDED_OLE_OBJECT` or `LINKED_OLE_OBJECT`.
83
+ """
84
+ if not self._graphicFrame.has_oleobj:
85
+ raise ValueError("not an OLE-object shape")
86
+ return _OleFormat(self._graphicFrame.graphicData, self._parent)
87
+
88
+ @lazyproperty
89
+ def shadow(self) -> ShadowFormat:
90
+ """Unconditionally raises |NotImplementedError|.
91
+
92
+ Access to the shadow effect for graphic-frame objects is content-specific (i.e. different
93
+ for charts, tables, etc.) and has not yet been implemented.
94
+ """
95
+ raise NotImplementedError("shadow property on GraphicFrame not yet supported")
96
+
97
+ @property
98
+ def shape_type(self) -> MSO_SHAPE_TYPE:
99
+ """Optional member of `MSO_SHAPE_TYPE` identifying the type of this shape.
100
+
101
+ Possible values are `MSO_SHAPE_TYPE.CHART`, `MSO_SHAPE_TYPE.TABLE`,
102
+ `MSO_SHAPE_TYPE.EMBEDDED_OLE_OBJECT`, `MSO_SHAPE_TYPE.LINKED_OLE_OBJECT`.
103
+
104
+ This value is `None` when none of these four types apply, for example when the shape
105
+ contains SmartArt.
106
+ """
107
+ graphicData_uri = self._graphicFrame.graphicData_uri
108
+ if graphicData_uri == GRAPHIC_DATA_URI_CHART:
109
+ return MSO_SHAPE_TYPE.CHART
110
+ elif graphicData_uri == GRAPHIC_DATA_URI_TABLE:
111
+ return MSO_SHAPE_TYPE.TABLE
112
+ elif graphicData_uri == GRAPHIC_DATA_URI_OLEOBJ:
113
+ return (
114
+ MSO_SHAPE_TYPE.EMBEDDED_OLE_OBJECT
115
+ if self._graphicFrame.is_embedded_ole_obj
116
+ else MSO_SHAPE_TYPE.LINKED_OLE_OBJECT
117
+ )
118
+ else:
119
+ return None # pyright: ignore[reportReturnType]
120
+
121
+ @property
122
+ def table(self) -> Table:
123
+ """The |Table| object contained in this graphic frame.
124
+
125
+ Raises |ValueError| if this graphic frame does not contain a table.
126
+ """
127
+ if not self.has_table:
128
+ raise ValueError("shape does not contain a table")
129
+ tbl = self._graphicFrame.graphic.graphicData.tbl
130
+ return Table(tbl, self)
131
+
132
+
133
+ class _OleFormat(ParentedElementProxy):
134
+ """Provides attributes on an embedded OLE object."""
135
+
136
+ part: BaseSlidePart # pyright: ignore[reportIncompatibleMethodOverride]
137
+
138
+ def __init__(self, graphicData: CT_GraphicalObjectData, parent: ProvidesPart):
139
+ super().__init__(graphicData, parent)
140
+ self._graphicData = graphicData
141
+
142
+ @property
143
+ def blob(self) -> bytes | None:
144
+ """Optional bytes of OLE object, suitable for loading or saving as a file.
145
+
146
+ This value is `None` if the embedded object does not represent a "file".
147
+ """
148
+ blob_rId = self._graphicData.blob_rId
149
+ if blob_rId is None:
150
+ return None
151
+ return self.part.related_part(blob_rId).blob
152
+
153
+ @property
154
+ def prog_id(self) -> str | None:
155
+ """str "progId" attribute of this embedded OLE object.
156
+
157
+ The progId is a str like "Excel.Sheet.12" that identifies the "file-type" of the embedded
158
+ object, or perhaps more precisely, the application (aka. "server" in OLE parlance) to be
159
+ used to open this object.
160
+ """
161
+ return self._graphicData.progId
162
+
163
+ @property
164
+ def show_as_icon(self) -> bool | None:
165
+ """True when OLE object should appear as an icon (rather than preview)."""
166
+ return self._graphicData.showAsIcon
tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/group.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """GroupShape and related objects."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ from pptx.dml.effect import ShadowFormat
8
+ from pptx.enum.shapes import MSO_SHAPE_TYPE
9
+ from pptx.shapes.base import BaseShape
10
+ from pptx.util import lazyproperty
11
+
12
+ if TYPE_CHECKING:
13
+ from pptx.action import ActionSetting
14
+ from pptx.oxml.shapes.groupshape import CT_GroupShape
15
+ from pptx.shapes.shapetree import GroupShapes
16
+ from pptx.types import ProvidesPart
17
+
18
+
19
+ class GroupShape(BaseShape):
20
+ """A shape that acts as a container for other shapes."""
21
+
22
+ def __init__(self, grpSp: CT_GroupShape, parent: ProvidesPart):
23
+ super().__init__(grpSp, parent)
24
+ self._grpSp = grpSp
25
+
26
+ @lazyproperty
27
+ def click_action(self) -> ActionSetting:
28
+ """Unconditionally raises `TypeError`.
29
+
30
+ A group shape cannot have a click action or hover action.
31
+ """
32
+ raise TypeError("a group shape cannot have a click action")
33
+
34
+ @property
35
+ def has_text_frame(self) -> bool:
36
+ """Unconditionally |False|.
37
+
38
+ A group shape does not have a textframe and cannot itself contain text. This does not
39
+ impact the ability of shapes contained by the group to each have their own text.
40
+ """
41
+ return False
42
+
43
+ @lazyproperty
44
+ def shadow(self) -> ShadowFormat:
45
+ """|ShadowFormat| object representing shadow effect for this group.
46
+
47
+ A |ShadowFormat| object is always returned, even when no shadow is explicitly defined on
48
+ this group shape (i.e. when the group inherits its shadow behavior).
49
+ """
50
+ return ShadowFormat(self._grpSp.grpSpPr)
51
+
52
+ @property
53
+ def shape_type(self) -> MSO_SHAPE_TYPE:
54
+ """Member of :ref:`MsoShapeType` identifying the type of this shape.
55
+
56
+ Unconditionally `MSO_SHAPE_TYPE.GROUP` in this case
57
+ """
58
+ return MSO_SHAPE_TYPE.GROUP
59
+
60
+ @lazyproperty
61
+ def shapes(self) -> GroupShapes:
62
+ """|GroupShapes| object for this group.
63
+
64
+ The |GroupShapes| object provides access to the group's member shapes and provides methods
65
+ for adding new ones.
66
+ """
67
+ from pptx.shapes.shapetree import GroupShapes
68
+
69
+ return GroupShapes(self._element, self)
tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/picture.py ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Shapes based on the `p:pic` element, including Picture and Movie."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ from pptx.dml.line import LineFormat
8
+ from pptx.enum.shapes import MSO_SHAPE, MSO_SHAPE_TYPE, PP_MEDIA_TYPE
9
+ from pptx.shapes.base import BaseShape
10
+ from pptx.shared import ParentedElementProxy
11
+ from pptx.util import lazyproperty
12
+
13
+ if TYPE_CHECKING:
14
+ from pptx.oxml.shapes.picture import CT_Picture
15
+ from pptx.oxml.shapes.shared import CT_LineProperties
16
+ from pptx.types import ProvidesPart
17
+
18
+
19
+ class _BasePicture(BaseShape):
20
+ """Base class for shapes based on a `p:pic` element."""
21
+
22
+ def __init__(self, pic: CT_Picture, parent: ProvidesPart):
23
+ super(_BasePicture, self).__init__(pic, parent)
24
+ self._pic = pic
25
+
26
+ @property
27
+ def crop_bottom(self) -> float:
28
+ """|float| representing relative portion cropped from shape bottom.
29
+
30
+ Read/write. 1.0 represents 100%. For example, 25% is represented by 0.25. Negative values
31
+ are valid as are values greater than 1.0.
32
+ """
33
+ return self._pic.srcRect_b
34
+
35
+ @crop_bottom.setter
36
+ def crop_bottom(self, value: float):
37
+ self._pic.srcRect_b = value
38
+
39
+ @property
40
+ def crop_left(self) -> float:
41
+ """|float| representing relative portion cropped from left of shape.
42
+
43
+ Read/write. 1.0 represents 100%. A negative value extends the side beyond the image
44
+ boundary.
45
+ """
46
+ return self._pic.srcRect_l
47
+
48
+ @crop_left.setter
49
+ def crop_left(self, value: float):
50
+ self._pic.srcRect_l = value
51
+
52
+ @property
53
+ def crop_right(self) -> float:
54
+ """|float| representing relative portion cropped from right of shape.
55
+
56
+ Read/write. 1.0 represents 100%.
57
+ """
58
+ return self._pic.srcRect_r
59
+
60
+ @crop_right.setter
61
+ def crop_right(self, value: float):
62
+ self._pic.srcRect_r = value
63
+
64
+ @property
65
+ def crop_top(self) -> float:
66
+ """|float| representing relative portion cropped from shape top.
67
+
68
+ Read/write. 1.0 represents 100%.
69
+ """
70
+ return self._pic.srcRect_t
71
+
72
+ @crop_top.setter
73
+ def crop_top(self, value: float):
74
+ self._pic.srcRect_t = value
75
+
76
+ def get_or_add_ln(self):
77
+ """Return the `a:ln` element for this `p:pic`-based image.
78
+
79
+ The `a:ln` element contains the line format properties XML.
80
+ """
81
+ return self._pic.get_or_add_ln()
82
+
83
+ @lazyproperty
84
+ def line(self) -> LineFormat:
85
+ """Provides access to properties of the picture outline, such as its color and width."""
86
+ return LineFormat(self)
87
+
88
+ @property
89
+ def ln(self) -> CT_LineProperties | None:
90
+ """The `a:ln` element for this `p:pic`.
91
+
92
+ Contains the line format properties such as line color and width. |None| if no `a:ln`
93
+ element is present.
94
+ """
95
+ return self._pic.ln
96
+
97
+
98
+ class Movie(_BasePicture):
99
+ """A movie shape, one that places a video on a slide.
100
+
101
+ Like |Picture|, a movie shape is based on the `p:pic` element. A movie is composed of a video
102
+ and a *poster frame*, the placeholder image that represents the video before it is played.
103
+ """
104
+
105
+ @lazyproperty
106
+ def media_format(self) -> _MediaFormat:
107
+ """The |_MediaFormat| object for this movie.
108
+
109
+ The |_MediaFormat| object provides access to formatting properties for the movie.
110
+ """
111
+ return _MediaFormat(self._pic, self)
112
+
113
+ @property
114
+ def media_type(self) -> PP_MEDIA_TYPE:
115
+ """Member of :ref:`PpMediaType` describing this shape.
116
+
117
+ The return value is unconditionally `PP_MEDIA_TYPE.MOVIE` in this case.
118
+ """
119
+ return PP_MEDIA_TYPE.MOVIE
120
+
121
+ @property
122
+ def poster_frame(self):
123
+ """Return |Image| object containing poster frame for this movie.
124
+
125
+ Returns |None| if this movie has no poster frame (uncommon).
126
+ """
127
+ slide_part, rId = self.part, self._pic.blip_rId
128
+ if rId is None:
129
+ return None
130
+ return slide_part.get_image(rId)
131
+
132
+ @property
133
+ def shape_type(self) -> MSO_SHAPE_TYPE:
134
+ """Return member of :ref:`MsoShapeType` describing this shape.
135
+
136
+ The return value is unconditionally `MSO_SHAPE_TYPE.MEDIA` in this
137
+ case.
138
+ """
139
+ return MSO_SHAPE_TYPE.MEDIA
140
+
141
+
142
+ class Picture(_BasePicture):
143
+ """A picture shape, one that places an image on a slide.
144
+
145
+ Based on the `p:pic` element.
146
+ """
147
+
148
+ @property
149
+ def auto_shape_type(self) -> MSO_SHAPE | None:
150
+ """Member of MSO_SHAPE indicating masking shape.
151
+
152
+ A picture can be masked by any of the so-called "auto-shapes" available in PowerPoint,
153
+ such as an ellipse or triangle. When a picture is masked by a shape, the shape assumes the
154
+ same dimensions as the picture and the portion of the picture outside the shape boundaries
155
+ does not appear. Note the default value for a newly-inserted picture is
156
+ `MSO_AUTO_SHAPE_TYPE.RECTANGLE`, which performs no cropping because the extents of the
157
+ rectangle exactly correspond to the extents of the picture.
158
+
159
+ The available shapes correspond to the members of :ref:`MsoAutoShapeType`.
160
+
161
+ The return value can also be |None|, indicating the picture either has no geometry (not
162
+ expected) or has custom geometry, like a freeform shape. A picture with no geometry will
163
+ have no visible representation on the slide, although it can be selected. This is because
164
+ without geometry, there is no "inside-the-shape" for it to appear in.
165
+ """
166
+ prstGeom = self._pic.spPr.prstGeom
167
+ if prstGeom is None: # ---generally means cropped with freeform---
168
+ return None
169
+ return prstGeom.prst
170
+
171
+ @auto_shape_type.setter
172
+ def auto_shape_type(self, member: MSO_SHAPE):
173
+ MSO_SHAPE.validate(member)
174
+ spPr = self._pic.spPr
175
+ prstGeom = spPr.prstGeom
176
+ if prstGeom is None:
177
+ spPr._remove_custGeom() # pyright: ignore[reportPrivateUsage]
178
+ prstGeom = spPr._add_prstGeom() # pyright: ignore[reportPrivateUsage]
179
+ prstGeom.prst = member
180
+
181
+ @property
182
+ def image(self):
183
+ """The |Image| object for this picture.
184
+
185
+ Provides access to the properties and bytes of the image in this picture shape.
186
+ """
187
+ slide_part, rId = self.part, self._pic.blip_rId
188
+ if rId is None:
189
+ raise ValueError("no embedded image")
190
+ return slide_part.get_image(rId)
191
+
192
+ @property
193
+ def shape_type(self) -> MSO_SHAPE_TYPE:
194
+ """Unconditionally `MSO_SHAPE_TYPE.PICTURE` in this case."""
195
+ return MSO_SHAPE_TYPE.PICTURE
196
+
197
+
198
+ class _MediaFormat(ParentedElementProxy):
199
+ """Provides access to formatting properties for a Media object.
200
+
201
+ Media format properties are things like start point, volume, and
202
+ compression type.
203
+ """
tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/placeholder.py ADDED
@@ -0,0 +1,407 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Placeholder-related objects.
2
+
3
+ Specific to shapes having a `p:ph` element. A placeholder has distinct behaviors
4
+ depending on whether it appears on a slide, layout, or master. Hence there is a
5
+ non-trivial class inheritance structure.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from typing import TYPE_CHECKING
11
+
12
+ from pptx.enum.shapes import MSO_SHAPE_TYPE, PP_PLACEHOLDER
13
+ from pptx.oxml.shapes.graphfrm import CT_GraphicalObjectFrame
14
+ from pptx.oxml.shapes.picture import CT_Picture
15
+ from pptx.shapes.autoshape import Shape
16
+ from pptx.shapes.graphfrm import GraphicFrame
17
+ from pptx.shapes.picture import Picture
18
+ from pptx.util import Emu
19
+
20
+ if TYPE_CHECKING:
21
+ from pptx.oxml.shapes.autoshape import CT_Shape
22
+
23
+
24
+ class _InheritsDimensions(object):
25
+ """
26
+ Mixin class that provides inherited dimension behavior. Specifically,
27
+ left, top, width, and height report the value from the layout placeholder
28
+ where they would have otherwise reported |None|. This behavior is
29
+ distinctive to placeholders. :meth:`_base_placeholder` must be overridden
30
+ by all subclasses to provide lookup of the appropriate base placeholder
31
+ to inherit from.
32
+ """
33
+
34
+ @property
35
+ def height(self):
36
+ """
37
+ The effective height of this placeholder shape; its directly-applied
38
+ height if it has one, otherwise the height of its parent layout
39
+ placeholder.
40
+ """
41
+ return self._effective_value("height")
42
+
43
+ @height.setter
44
+ def height(self, value):
45
+ self._element.cy = value
46
+
47
+ @property
48
+ def left(self):
49
+ """
50
+ The effective left of this placeholder shape; its directly-applied
51
+ left if it has one, otherwise the left of its parent layout
52
+ placeholder.
53
+ """
54
+ return self._effective_value("left")
55
+
56
+ @left.setter
57
+ def left(self, value):
58
+ self._element.x = value
59
+
60
+ @property
61
+ def shape_type(self):
62
+ """
63
+ Member of :ref:`MsoShapeType` specifying the type of this shape.
64
+ Unconditionally ``MSO_SHAPE_TYPE.PLACEHOLDER`` in this case.
65
+ Read-only.
66
+ """
67
+ return MSO_SHAPE_TYPE.PLACEHOLDER
68
+
69
+ @property
70
+ def top(self):
71
+ """
72
+ The effective top of this placeholder shape; its directly-applied
73
+ top if it has one, otherwise the top of its parent layout
74
+ placeholder.
75
+ """
76
+ return self._effective_value("top")
77
+
78
+ @top.setter
79
+ def top(self, value):
80
+ self._element.y = value
81
+
82
+ @property
83
+ def width(self):
84
+ """
85
+ The effective width of this placeholder shape; its directly-applied
86
+ width if it has one, otherwise the width of its parent layout
87
+ placeholder.
88
+ """
89
+ return self._effective_value("width")
90
+
91
+ @width.setter
92
+ def width(self, value):
93
+ self._element.cx = value
94
+
95
+ @property
96
+ def _base_placeholder(self):
97
+ """
98
+ Return the layout or master placeholder shape this placeholder
99
+ inherits from. Not to be confused with an instance of
100
+ |BasePlaceholder| (necessarily).
101
+ """
102
+ raise NotImplementedError("Must be implemented by all subclasses.")
103
+
104
+ def _effective_value(self, attr_name):
105
+ """
106
+ The effective value of *attr_name* on this placeholder shape; its
107
+ directly-applied value if it has one, otherwise the value on the
108
+ layout placeholder it inherits from.
109
+ """
110
+ directly_applied_value = getattr(super(_InheritsDimensions, self), attr_name)
111
+ if directly_applied_value is not None:
112
+ return directly_applied_value
113
+ return self._inherited_value(attr_name)
114
+
115
+ def _inherited_value(self, attr_name):
116
+ """
117
+ Return the attribute value, e.g. 'width' of the base placeholder this
118
+ placeholder inherits from.
119
+ """
120
+ base_placeholder = self._base_placeholder
121
+ if base_placeholder is None:
122
+ return None
123
+ inherited_value = getattr(base_placeholder, attr_name)
124
+ return inherited_value
125
+
126
+
127
+ class _BaseSlidePlaceholder(_InheritsDimensions, Shape):
128
+ """Base class for placeholders on slides.
129
+
130
+ Provides common behaviors such as inherited dimensions.
131
+ """
132
+
133
+ @property
134
+ def is_placeholder(self):
135
+ """
136
+ Boolean indicating whether this shape is a placeholder.
137
+ Unconditionally |True| in this case.
138
+ """
139
+ return True
140
+
141
+ @property
142
+ def shape_type(self):
143
+ """
144
+ Member of :ref:`MsoShapeType` specifying the type of this shape.
145
+ Unconditionally ``MSO_SHAPE_TYPE.PLACEHOLDER`` in this case.
146
+ Read-only.
147
+ """
148
+ return MSO_SHAPE_TYPE.PLACEHOLDER
149
+
150
+ @property
151
+ def _base_placeholder(self):
152
+ """
153
+ Return the layout placeholder this slide placeholder inherits from.
154
+ Not to be confused with an instance of |BasePlaceholder|
155
+ (necessarily).
156
+ """
157
+ layout, idx = self.part.slide_layout, self._element.ph_idx
158
+ return layout.placeholders.get(idx=idx)
159
+
160
+ def _replace_placeholder_with(self, element):
161
+ """
162
+ Substitute *element* for this placeholder element in the shapetree.
163
+ This placeholder's `._element` attribute is set to |None| and its
164
+ original element is free for garbage collection. Any attribute access
165
+ (including a method call) on this placeholder after this call raises
166
+ |AttributeError|.
167
+ """
168
+ element._nvXxPr.nvPr._insert_ph(self._element.ph)
169
+ self._element.addprevious(element)
170
+ self._element.getparent().remove(self._element)
171
+ self._element = None
172
+
173
+
174
+ class BasePlaceholder(Shape):
175
+ """
176
+ NOTE: This class is deprecated and will be removed from a future release
177
+ along with the properties *idx*, *orient*, *ph_type*, and *sz*. The *idx*
178
+ property will be available via the .placeholder_format property. The
179
+ others will be accessed directly from the oxml layer as they are only
180
+ used for internal purposes.
181
+
182
+ Base class for placeholder subclasses that differentiate the varying
183
+ behaviors of placeholders on a master, layout, and slide.
184
+ """
185
+
186
+ @property
187
+ def idx(self):
188
+ """
189
+ Integer placeholder 'idx' attribute, e.g. 0
190
+ """
191
+ return self._sp.ph_idx
192
+
193
+ @property
194
+ def orient(self):
195
+ """
196
+ Placeholder orientation, e.g. ST_Direction.HORZ
197
+ """
198
+ return self._sp.ph_orient
199
+
200
+ @property
201
+ def ph_type(self):
202
+ """
203
+ Placeholder type, e.g. PP_PLACEHOLDER.CENTER_TITLE
204
+ """
205
+ return self._sp.ph_type
206
+
207
+ @property
208
+ def sz(self):
209
+ """
210
+ Placeholder 'sz' attribute, e.g. ST_PlaceholderSize.FULL
211
+ """
212
+ return self._sp.ph_sz
213
+
214
+
215
+ class LayoutPlaceholder(_InheritsDimensions, Shape):
216
+ """Placeholder shape on a slide layout.
217
+
218
+ Provides differentiated behavior for slide layout placeholders, in particular, inheriting
219
+ shape properties from the master placeholder having the same type, when a matching one exists.
220
+ """
221
+
222
+ element: CT_Shape # pyright: ignore[reportIncompatibleMethodOverride]
223
+
224
+ @property
225
+ def _base_placeholder(self):
226
+ """
227
+ Return the master placeholder this layout placeholder inherits from.
228
+ """
229
+ base_ph_type = {
230
+ PP_PLACEHOLDER.BODY: PP_PLACEHOLDER.BODY,
231
+ PP_PLACEHOLDER.CHART: PP_PLACEHOLDER.BODY,
232
+ PP_PLACEHOLDER.BITMAP: PP_PLACEHOLDER.BODY,
233
+ PP_PLACEHOLDER.CENTER_TITLE: PP_PLACEHOLDER.TITLE,
234
+ PP_PLACEHOLDER.ORG_CHART: PP_PLACEHOLDER.BODY,
235
+ PP_PLACEHOLDER.DATE: PP_PLACEHOLDER.DATE,
236
+ PP_PLACEHOLDER.FOOTER: PP_PLACEHOLDER.FOOTER,
237
+ PP_PLACEHOLDER.MEDIA_CLIP: PP_PLACEHOLDER.BODY,
238
+ PP_PLACEHOLDER.OBJECT: PP_PLACEHOLDER.BODY,
239
+ PP_PLACEHOLDER.PICTURE: PP_PLACEHOLDER.BODY,
240
+ PP_PLACEHOLDER.SLIDE_NUMBER: PP_PLACEHOLDER.SLIDE_NUMBER,
241
+ PP_PLACEHOLDER.SUBTITLE: PP_PLACEHOLDER.BODY,
242
+ PP_PLACEHOLDER.TABLE: PP_PLACEHOLDER.BODY,
243
+ PP_PLACEHOLDER.TITLE: PP_PLACEHOLDER.TITLE,
244
+ }[self._element.ph_type]
245
+ slide_master = self.part.slide_master
246
+ return slide_master.placeholders.get(base_ph_type, None)
247
+
248
+
249
+ class MasterPlaceholder(BasePlaceholder):
250
+ """Placeholder shape on a slide master."""
251
+
252
+ element: CT_Shape # pyright: ignore[reportIncompatibleMethodOverride]
253
+
254
+
255
+ class NotesSlidePlaceholder(_InheritsDimensions, Shape):
256
+ """
257
+ Placeholder shape on a notes slide. Inherits shape properties from the
258
+ placeholder on the notes master that has the same type (e.g. 'body').
259
+ """
260
+
261
+ @property
262
+ def _base_placeholder(self):
263
+ """
264
+ Return the notes master placeholder this notes slide placeholder
265
+ inherits from, or |None| if no placeholder of the matching type is
266
+ present.
267
+ """
268
+ notes_master = self.part.notes_master
269
+ ph_type = self.element.ph_type
270
+ return notes_master.placeholders.get(ph_type=ph_type)
271
+
272
+
273
+ class SlidePlaceholder(_BaseSlidePlaceholder):
274
+ """
275
+ Placeholder shape on a slide. Inherits shape properties from its
276
+ corresponding slide layout placeholder.
277
+ """
278
+
279
+
280
+ class ChartPlaceholder(_BaseSlidePlaceholder):
281
+ """Placeholder shape that can only accept a chart."""
282
+
283
+ def insert_chart(self, chart_type, chart_data):
284
+ """
285
+ Return a |PlaceholderGraphicFrame| object containing a new chart of
286
+ *chart_type* depicting *chart_data* and having the same position and
287
+ size as this placeholder. *chart_type* is one of the
288
+ :ref:`XlChartType` enumeration values. *chart_data* is a |ChartData|
289
+ object populated with the categories and series values for the chart.
290
+ Note that the new |Chart| object is not returned directly. The chart
291
+ object may be accessed using the
292
+ :attr:`~.PlaceholderGraphicFrame.chart` property of the returned
293
+ |PlaceholderGraphicFrame| object.
294
+ """
295
+ rId = self.part.add_chart_part(chart_type, chart_data)
296
+ graphicFrame = self._new_chart_graphicFrame(
297
+ rId, self.left, self.top, self.width, self.height
298
+ )
299
+ self._replace_placeholder_with(graphicFrame)
300
+ return PlaceholderGraphicFrame(graphicFrame, self._parent)
301
+
302
+ def _new_chart_graphicFrame(self, rId, x, y, cx, cy):
303
+ """
304
+ Return a newly created `p:graphicFrame` element having the specified
305
+ position and size and containing the chart identified by *rId*.
306
+ """
307
+ id_, name = self.shape_id, self.name
308
+ return CT_GraphicalObjectFrame.new_chart_graphicFrame(id_, name, rId, x, y, cx, cy)
309
+
310
+
311
+ class PicturePlaceholder(_BaseSlidePlaceholder):
312
+ """Placeholder shape that can only accept a picture."""
313
+
314
+ def insert_picture(self, image_file):
315
+ """Return a |PlaceholderPicture| object depicting the image in `image_file`.
316
+
317
+ `image_file` may be either a path (string) or a file-like object. The image is
318
+ cropped to fill the entire space of the placeholder. A |PlaceholderPicture|
319
+ object has all the properties and methods of a |Picture| shape except that the
320
+ value of its :attr:`~._BaseSlidePlaceholder.shape_type` property is
321
+ `MSO_SHAPE_TYPE.PLACEHOLDER` instead of `MSO_SHAPE_TYPE.PICTURE`.
322
+ """
323
+ pic = self._new_placeholder_pic(image_file)
324
+ self._replace_placeholder_with(pic)
325
+ return PlaceholderPicture(pic, self._parent)
326
+
327
+ def _new_placeholder_pic(self, image_file):
328
+ """
329
+ Return a new `p:pic` element depicting the image in *image_file*,
330
+ suitable for use as a placeholder. In particular this means not
331
+ having an `a:xfrm` element, allowing its extents to be inherited from
332
+ its layout placeholder.
333
+ """
334
+ rId, desc, image_size = self._get_or_add_image(image_file)
335
+ shape_id, name = self.shape_id, self.name
336
+ pic = CT_Picture.new_ph_pic(shape_id, name, desc, rId)
337
+ pic.crop_to_fit(image_size, (self.width, self.height))
338
+ return pic
339
+
340
+ def _get_or_add_image(self, image_file):
341
+ """
342
+ Return an (rId, description, image_size) 3-tuple identifying the
343
+ related image part containing *image_file* and describing the image.
344
+ """
345
+ image_part, rId = self.part.get_or_add_image_part(image_file)
346
+ desc, image_size = image_part.desc, image_part._px_size
347
+ return rId, desc, image_size
348
+
349
+
350
+ class PlaceholderGraphicFrame(GraphicFrame):
351
+ """
352
+ Placeholder shape populated with a table, chart, or smart art.
353
+ """
354
+
355
+ @property
356
+ def is_placeholder(self):
357
+ """
358
+ Boolean indicating whether this shape is a placeholder.
359
+ Unconditionally |True| in this case.
360
+ """
361
+ return True
362
+
363
+
364
+ class PlaceholderPicture(_InheritsDimensions, Picture):
365
+ """
366
+ Placeholder shape populated with a picture.
367
+ """
368
+
369
+ @property
370
+ def _base_placeholder(self):
371
+ """
372
+ Return the layout placeholder this picture placeholder inherits from.
373
+ """
374
+ layout, idx = self.part.slide_layout, self._element.ph_idx
375
+ return layout.placeholders.get(idx=idx)
376
+
377
+
378
+ class TablePlaceholder(_BaseSlidePlaceholder):
379
+ """Placeholder shape that can only accept a table."""
380
+
381
+ def insert_table(self, rows, cols):
382
+ """Return |PlaceholderGraphicFrame| object containing a `rows` by `cols` table.
383
+
384
+ The position and width of the table are those of the placeholder and its height
385
+ is proportional to the number of rows. A |PlaceholderGraphicFrame| object has
386
+ all the properties and methods of a |GraphicFrame| shape except that the value
387
+ of its :attr:`~._BaseSlidePlaceholder.shape_type` property is unconditionally
388
+ `MSO_SHAPE_TYPE.PLACEHOLDER`. Note that the return value is not the new table
389
+ but rather *contains* the new table. The table can be accessed using the
390
+ :attr:`~.PlaceholderGraphicFrame.table` property of the returned
391
+ |PlaceholderGraphicFrame| object.
392
+ """
393
+ graphicFrame = self._new_placeholder_table(rows, cols)
394
+ self._replace_placeholder_with(graphicFrame)
395
+ return PlaceholderGraphicFrame(graphicFrame, self._parent)
396
+
397
+ def _new_placeholder_table(self, rows, cols):
398
+ """
399
+ Return a newly added `p:graphicFrame` element containing an empty
400
+ table with *rows* rows and *cols* columns, positioned at the location
401
+ of this placeholder and having its same width. The table's height is
402
+ determined by the number of rows.
403
+ """
404
+ shape_id, name, height = self.shape_id, self.name, Emu(rows * 370840)
405
+ return CT_GraphicalObjectFrame.new_table_graphicFrame(
406
+ shape_id, name, rows, cols, self.left, self.top, self.width, height
407
+ )
tasks/tasksmith-74f059424102/environment/source/src/pptx/shapes/shapetree.py ADDED
@@ -0,0 +1,1190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """The shape tree, the structure that holds a slide's shapes."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import io
6
+ import os
7
+ from typing import IO, TYPE_CHECKING, Callable, Iterable, Iterator, cast
8
+
9
+ from pptx.enum.shapes import PP_PLACEHOLDER, PROG_ID
10
+ from pptx.media import SPEAKER_IMAGE_BYTES, Video
11
+ from pptx.opc.constants import CONTENT_TYPE as CT
12
+ from pptx.oxml.ns import qn
13
+ from pptx.oxml.shapes.autoshape import CT_Shape
14
+ from pptx.oxml.shapes.graphfrm import CT_GraphicalObjectFrame
15
+ from pptx.oxml.shapes.picture import CT_Picture
16
+ from pptx.oxml.simpletypes import ST_Direction
17
+ from pptx.shapes.autoshape import AutoShapeType, Shape
18
+ from pptx.shapes.base import BaseShape
19
+ from pptx.shapes.connector import Connector
20
+ from pptx.shapes.freeform import FreeformBuilder
21
+ from pptx.shapes.graphfrm import GraphicFrame
22
+ from pptx.shapes.group import GroupShape
23
+ from pptx.shapes.picture import Movie, Picture
24
+ from pptx.shapes.placeholder import (
25
+ ChartPlaceholder,
26
+ LayoutPlaceholder,
27
+ MasterPlaceholder,
28
+ NotesSlidePlaceholder,
29
+ PicturePlaceholder,
30
+ PlaceholderGraphicFrame,
31
+ PlaceholderPicture,
32
+ SlidePlaceholder,
33
+ TablePlaceholder,
34
+ )
35
+ from pptx.shared import ParentedElementProxy
36
+ from pptx.util import Emu, lazyproperty
37
+
38
+ if TYPE_CHECKING:
39
+ from pptx.chart.chart import Chart
40
+ from pptx.chart.data import ChartData
41
+ from pptx.enum.chart import XL_CHART_TYPE
42
+ from pptx.enum.shapes import MSO_CONNECTOR_TYPE, MSO_SHAPE
43
+ from pptx.oxml.shapes import ShapeElement
44
+ from pptx.oxml.shapes.connector import CT_Connector
45
+ from pptx.oxml.shapes.groupshape import CT_GroupShape
46
+ from pptx.parts.image import ImagePart
47
+ from pptx.parts.slide import SlidePart
48
+ from pptx.slide import Slide, SlideLayout
49
+ from pptx.types import ProvidesPart
50
+ from pptx.util import Length
51
+
52
+ # +-- _BaseShapes
53
+ # | |
54
+ # | +-- _BaseGroupShapes
55
+ # | | |
56
+ # | | +-- GroupShapes
57
+ # | | |
58
+ # | | +-- SlideShapes
59
+ # | |
60
+ # | +-- LayoutShapes
61
+ # | |
62
+ # | +-- MasterShapes
63
+ # | |
64
+ # | +-- NotesSlideShapes
65
+ # | |
66
+ # | +-- BasePlaceholders
67
+ # | |
68
+ # | +-- LayoutPlaceholders
69
+ # | |
70
+ # | +-- MasterPlaceholders
71
+ # | |
72
+ # | +-- NotesSlidePlaceholders
73
+ # |
74
+ # +-- SlidePlaceholders
75
+
76
+
77
+ class _BaseShapes(ParentedElementProxy):
78
+ """Base class for a shape collection appearing in a slide-type object.
79
+
80
+ Subclasses include Slide, SlideLayout, and SlideMaster. Provides common methods.
81
+ """
82
+
83
+ def __init__(self, spTree: CT_GroupShape, parent: ProvidesPart):
84
+ super(_BaseShapes, self).__init__(spTree, parent)
85
+ self._spTree = spTree
86
+ self._cached_max_shape_id = None
87
+
88
+ def __getitem__(self, idx: int) -> BaseShape:
89
+ """Return shape at `idx` in sequence, e.g. `shapes[2]`."""
90
+ shape_elms = list(self._iter_member_elms())
91
+ try:
92
+ shape_elm = shape_elms[idx]
93
+ except IndexError:
94
+ raise IndexError("shape index out of range")
95
+ return self._shape_factory(shape_elm)
96
+
97
+ def __iter__(self) -> Iterator[BaseShape]:
98
+ """Generate a reference to each shape in the collection, in sequence."""
99
+ for shape_elm in self._iter_member_elms():
100
+ yield self._shape_factory(shape_elm)
101
+
102
+ def __len__(self) -> int:
103
+ """Return count of shapes in this shape tree.
104
+
105
+ A group shape contributes 1 to the total, without regard to the number of shapes contained
106
+ in the group.
107
+ """
108
+ shape_elms = list(self._iter_member_elms())
109
+ return len(shape_elms)
110
+
111
+ def clone_placeholder(self, placeholder: LayoutPlaceholder) -> None:
112
+ """Add a new placeholder shape based on `placeholder`."""
113
+ sp = placeholder.element
114
+ ph_type, orient, sz, idx = (sp.ph_type, sp.ph_orient, sp.ph_sz, sp.ph_idx)
115
+ id_ = self._next_shape_id
116
+ name = self._next_ph_name(ph_type, id_, orient)
117
+ self._spTree.add_placeholder(id_, name, ph_type, orient, sz, idx)
118
+
119
+ def ph_basename(self, ph_type: PP_PLACEHOLDER) -> str:
120
+ """Return the base name for a placeholder of `ph_type` in this shape collection.
121
+
122
+ There is some variance between slide types, for example a notes slide uses a different
123
+ name for the body placeholder, so this method can be overriden by subclasses.
124
+ """
125
+ return {
126
+ PP_PLACEHOLDER.BITMAP: "ClipArt Placeholder",
127
+ PP_PLACEHOLDER.BODY: "Text Placeholder",
128
+ PP_PLACEHOLDER.CENTER_TITLE: "Title",
129
+ PP_PLACEHOLDER.CHART: "Chart Placeholder",
130
+ PP_PLACEHOLDER.DATE: "Date Placeholder",
131
+ PP_PLACEHOLDER.FOOTER: "Footer Placeholder",
132
+ PP_PLACEHOLDER.HEADER: "Header Placeholder",
133
+ PP_PLACEHOLDER.MEDIA_CLIP: "Media Placeholder",
134
+ PP_PLACEHOLDER.OBJECT: "Content Placeholder",
135
+ PP_PLACEHOLDER.ORG_CHART: "SmartArt Placeholder",
136
+ PP_PLACEHOLDER.PICTURE: "Picture Placeholder",
137
+ PP_PLACEHOLDER.SLIDE_NUMBER: "Slide Number Placeholder",
138
+ PP_PLACEHOLDER.SUBTITLE: "Subtitle",
139
+ PP_PLACEHOLDER.TABLE: "Table Placeholder",
140
+ PP_PLACEHOLDER.TITLE: "Title",
141
+ }[ph_type]
142
+
143
+ @property
144
+ def turbo_add_enabled(self) -> bool:
145
+ """True if "turbo-add" mode is enabled. Read/Write.
146
+
147
+ EXPERIMENTAL: This feature can radically improve performance when adding large numbers
148
+ (hundreds of shapes) to a slide. It works by caching the last shape ID used and
149
+ incrementing that value to assign the next shape id. This avoids repeatedly searching all
150
+ shape ids in the slide each time a new ID is required.
151
+
152
+ Performance is not noticeably improved for a slide with a relatively small number of
153
+ shapes, but because the search time rises with the square of the shape count, this option
154
+ can be useful for optimizing generation of a slide composed of many shapes.
155
+
156
+ Shape-id collisions can occur (causing a repair error on load) if more than one |Slide|
157
+ object is used to interact with the same slide in the presentation. Note that the |Slides|
158
+ collection creates a new |Slide| object each time a slide is accessed (e.g. `slide =
159
+ prs.slides[0]`, so you must be careful to limit use to a single |Slide| object.
160
+ """
161
+ return self._cached_max_shape_id is not None
162
+
163
+ @turbo_add_enabled.setter
164
+ def turbo_add_enabled(self, value: bool):
165
+ enable = bool(value)
166
+ self._cached_max_shape_id = self._spTree.max_shape_id if enable else None
167
+
168
+ @staticmethod
169
+ def _is_member_elm(shape_elm: ShapeElement) -> bool:
170
+ """Return true if `shape_elm` represents a member of this collection, False otherwise."""
171
+ return True
172
+
173
+ def _iter_member_elms(self) -> Iterator[ShapeElement]:
174
+ """Generate each child of the `p:spTree` element that corresponds to a shape.
175
+
176
+ Items appear in XML document order.
177
+ """
178
+ for shape_elm in self._spTree.iter_shape_elms():
179
+ if self._is_member_elm(shape_elm):
180
+ yield shape_elm
181
+
182
+ def _next_ph_name(self, ph_type: PP_PLACEHOLDER, id: int, orient: str) -> str:
183
+ """Next unique placeholder name for placeholder shape of type `ph_type`.
184
+
185
+ Usually will be standard placeholder root name suffixed with id-1, e.g.
186
+ _next_ph_name(ST_PlaceholderType.TBL, 4, 'horz') ==> 'Table Placeholder 3'. The number is
187
+ incremented as necessary to make the name unique within the collection. If `orient` is
188
+ `'vert'`, the placeholder name is prefixed with `'Vertical '`.
189
+ """
190
+ basename = self.ph_basename(ph_type)
191
+
192
+ # prefix rootname with 'Vertical ' if orient is 'vert'
193
+ if orient == ST_Direction.VERT:
194
+ basename = "Vertical %s" % basename
195
+
196
+ # increment numpart as necessary to make name unique
197
+ numpart = id - 1
198
+ names = self._spTree.xpath("//p:cNvPr/@name")
199
+ while True:
200
+ name = "%s %d" % (basename, numpart)
201
+ if name not in names:
202
+ break
203
+ numpart += 1
204
+
205
+ return name
206
+
207
+ @property
208
+ def _next_shape_id(self) -> int:
209
+ """Return a unique shape id suitable for use with a new shape.
210
+
211
+ The returned id is 1 greater than the maximum shape id used so far. In practice, the
212
+ minimum id is 2 because the spTree element is always assigned id="1".
213
+ """
214
+ # ---presence of cached-max-shape-id indicates turbo mode is on---
215
+ if self._cached_max_shape_id is not None:
216
+ self._cached_max_shape_id += 1
217
+ return self._cached_max_shape_id
218
+
219
+ return self._spTree.max_shape_id + 1
220
+
221
+ def _shape_factory(self, shape_elm: ShapeElement) -> BaseShape:
222
+ """Return an instance of the appropriate shape proxy class for `shape_elm`."""
223
+ return BaseShapeFactory(shape_elm, self)
224
+
225
+
226
+ class _BaseGroupShapes(_BaseShapes):
227
+ """Base class for shape-trees that can add shapes."""
228
+
229
+ part: SlidePart # pyright: ignore[reportIncompatibleMethodOverride]
230
+ _element: CT_GroupShape
231
+
232
+ def __init__(self, grpSp: CT_GroupShape, parent: ProvidesPart):
233
+ super(_BaseGroupShapes, self).__init__(grpSp, parent)
234
+ self._grpSp = grpSp
235
+
236
+ def add_chart(
237
+ self,
238
+ chart_type: XL_CHART_TYPE,
239
+ x: Length,
240
+ y: Length,
241
+ cx: Length,
242
+ cy: Length,
243
+ chart_data: ChartData,
244
+ ) -> Chart:
245
+ """Add a new chart of `chart_type` to the slide.
246
+
247
+ The chart is positioned at (`x`, `y`), has size (`cx`, `cy`), and depicts `chart_data`.
248
+ `chart_type` is one of the :ref:`XlChartType` enumeration values. `chart_data` is a
249
+ |ChartData| object populated with the categories and series values for the chart.
250
+
251
+ Note that a |GraphicFrame| shape object is returned, not the |Chart| object contained in
252
+ that graphic frame shape. The chart object may be accessed using the :attr:`chart`
253
+ property of the returned |GraphicFrame| object.
254
+ """
255
+ rId = self.part.add_chart_part(chart_type, chart_data)
256
+ graphicFrame = self._add_chart_graphicFrame(rId, x, y, cx, cy)
257
+ self._recalculate_extents()
258
+ return cast("Chart", self._shape_factory(graphicFrame))
259
+
260
+ def add_connector(
261
+ self,
262
+ connector_type: MSO_CONNECTOR_TYPE,
263
+ begin_x: Length,
264
+ begin_y: Length,
265
+ end_x: Length,
266
+ end_y: Length,
267
+ ) -> Connector:
268
+ """Add a newly created connector shape to the end of this shape tree.
269
+
270
+ `connector_type` is a member of the :ref:`MsoConnectorType` enumeration and the end-point
271
+ values are specified as EMU values. The returned connector is of type `connector_type` and
272
+ has begin and end points as specified.
273
+ """
274
+ cxnSp = self._add_cxnSp(connector_type, begin_x, begin_y, end_x, end_y)
275
+ self._recalculate_extents()
276
+ return cast(Connector, self._shape_factory(cxnSp))
277
+
278
+ def add_group_shape(self, shapes: Iterable[BaseShape] = ()) -> GroupShape:
279
+ """Return a |GroupShape| object newly appended to this shape tree.
280
+
281
+ The group shape is empty and must be populated with shapes using methods on its shape
282
+ tree, available on its `.shapes` property. The position and extents of the group shape are
283
+ determined by the shapes it contains; its position and extents are recalculated each time
284
+ a shape is added to it.
285
+ """
286
+ shapes = tuple(shapes)
287
+ grpSp = self._element.add_grpSp()
288
+ for shape in shapes:
289
+ grpSp.insert_element_before(
290
+ shape._element, "p:extLst" # pyright: ignore[reportPrivateUsage]
291
+ )
292
+ if shapes:
293
+ grpSp.recalculate_extents()
294
+ return cast(GroupShape, self._shape_factory(grpSp))
295
+
296
+ def add_ole_object(
297
+ self,
298
+ object_file: str | IO[bytes],
299
+ prog_id: str,
300
+ left: Length,
301
+ top: Length,
302
+ width: Length | None = None,
303
+ height: Length | None = None,
304
+ icon_file: str | IO[bytes] | None = None,
305
+ icon_width: Length | None = None,
306
+ icon_height: Length | None = None,
307
+ ) -> GraphicFrame:
308
+ """Return newly-created GraphicFrame shape embedding `object_file`.
309
+
310
+ The returned graphic-frame shape contains `object_file` as an embedded OLE object. It is
311
+ displayed as an icon at `left`, `top` with size `width`, `height`. `width` and `height`
312
+ may be omitted when `prog_id` is a member of `PROG_ID`, in which case the default icon
313
+ size is used. This is advised for best appearance where applicable because it avoids an
314
+ icon with a "stretched" appearance.
315
+
316
+ `object_file` may either be a str path to a file or file-like object (such as
317
+ `io.BytesIO`) containing the bytes of the object to be embedded (such as an Excel file).
318
+
319
+ `prog_id` can be either a member of `pptx.enum.shapes.PROG_ID` or a str value like
320
+ `"Adobe.Exchange.7"` determined by inspecting the XML generated by PowerPoint for an
321
+ object of the desired type.
322
+
323
+ `icon_file` may either be a str path to an image file or a file-like object containing the
324
+ image. The image provided will be displayed in lieu of the OLE object; double-clicking on
325
+ the image opens the object (subject to operating-system limitations). The image file can
326
+ be any supported image file. Those produced by PowerPoint itself are generally EMF and can
327
+ be harvested from a PPTX package that embeds such an object. PNG and JPG also work fine.
328
+
329
+ `icon_width` and `icon_height` are `Length` values (e.g. Emu() or Inches()) that describe
330
+ the size of the icon image within the shape. These should be omitted unless a custom
331
+ `icon_file` is provided. The dimensions must be discovered by inspecting the XML.
332
+ Automatic resizing of the OLE-object shape can occur when the icon is double-clicked if
333
+ these values are not as set by PowerPoint. This behavior may only manifest in the Windows
334
+ version of PowerPoint.
335
+ """
336
+ graphicFrame = _OleObjectElementCreator.graphicFrame(
337
+ self,
338
+ self._next_shape_id,
339
+ object_file,
340
+ prog_id,
341
+ left,
342
+ top,
343
+ width,
344
+ height,
345
+ icon_file,
346
+ icon_width,
347
+ icon_height,
348
+ )
349
+ self._spTree.append(graphicFrame)
350
+ self._recalculate_extents()
351
+ return cast(GraphicFrame, self._shape_factory(graphicFrame))
352
+
353
+ def add_picture(
354
+ self,
355
+ image_file: str | IO[bytes],
356
+ left: Length,
357
+ top: Length,
358
+ width: Length | None = None,
359
+ height: Length | None = None,
360
+ ) -> Picture:
361
+ """Add picture shape displaying image in `image_file`.
362
+
363
+ `image_file` can be either a path to a file (a string) or a file-like object. The picture
364
+ is positioned with its top-left corner at (`top`, `left`). If `width` and `height` are
365
+ both |None|, the native size of the image is used. If only one of `width` or `height` is
366
+ used, the unspecified dimension is calculated to preserve the aspect ratio of the image.
367
+ If both are specified, the picture is stretched to fit, without regard to its native
368
+ aspect ratio.
369
+ """
370
+ image_part, rId = self.part.get_or_add_image_part(image_file)
371
+ pic = self._add_pic_from_image_part(image_part, rId, left, top, width, height)
372
+ self._recalculate_extents()
373
+ return cast(Picture, self._shape_factory(pic))
374
+
375
+ def add_shape(
376
+ self, autoshape_type_id: MSO_SHAPE, left: Length, top: Length, width: Length, height: Length
377
+ ) -> Shape:
378
+ """Return new |Shape| object appended to this shape tree.
379
+
380
+ `autoshape_type_id` is a member of :ref:`MsoAutoShapeType` e.g. `MSO_SHAPE.RECTANGLE`
381
+ specifying the type of shape to be added. The remaining arguments specify the new shape's
382
+ position and size.
383
+ """
384
+ autoshape_type = AutoShapeType(autoshape_type_id)
385
+ sp = self._add_sp(autoshape_type, left, top, width, height)
386
+ self._recalculate_extents()
387
+ return cast(Shape, self._shape_factory(sp))
388
+
389
+ def add_textbox(self, left: Length, top: Length, width: Length, height: Length) -> Shape:
390
+ """Return newly added text box shape appended to this shape tree.
391
+
392
+ The text box is of the specified size, located at the specified position on the slide.
393
+ """
394
+ sp = self._add_textbox_sp(left, top, width, height)
395
+ self._recalculate_extents()
396
+ return cast(Shape, self._shape_factory(sp))
397
+
398
+ def build_freeform(
399
+ self, start_x: float = 0, start_y: float = 0, scale: tuple[float, float] | float = 1.0
400
+ ) -> FreeformBuilder:
401
+ """Return |FreeformBuilder| object to specify a freeform shape.
402
+
403
+ The optional `start_x` and `start_y` arguments specify the starting pen position in local
404
+ coordinates. They will be rounded to the nearest integer before use and each default to
405
+ zero.
406
+
407
+ The optional `scale` argument specifies the size of local coordinates proportional to
408
+ slide coordinates (EMU). If the vertical scale is different than the horizontal scale
409
+ (local coordinate units are "rectangular"), a pair of numeric values can be provided as
410
+ the `scale` argument, e.g. `scale=(1.0, 2.0)`. In this case the first number is
411
+ interpreted as the horizontal (X) scale and the second as the vertical (Y) scale.
412
+
413
+ A convenient method for calculating scale is to divide a |Length| object by an equivalent
414
+ count of local coordinate units, e.g. `scale = Inches(1)/1000` for 1000 local units per
415
+ inch.
416
+ """
417
+ x_scale, y_scale = scale if isinstance(scale, tuple) else (scale, scale)
418
+
419
+ return FreeformBuilder.new(self, start_x, start_y, x_scale, y_scale)
420
+
421
+ def index(self, shape: BaseShape) -> int:
422
+ """Return the index of `shape` in this sequence.
423
+
424
+ Raises |ValueError| if `shape` is not in the collection.
425
+ """
426
+ shape_elms = list(self._element.iter_shape_elms())
427
+ return shape_elms.index(shape.element)
428
+
429
+ def _add_chart_graphicFrame(
430
+ self, rId: str, x: Length, y: Length, cx: Length, cy: Length
431
+ ) -> CT_GraphicalObjectFrame:
432
+ """Return new `p:graphicFrame` element appended to this shape tree.
433
+
434
+ The `p:graphicFrame` element has the specified position and size and refers to the chart
435
+ part identified by `rId`.
436
+ """
437
+ shape_id = self._next_shape_id
438
+ name = "Chart %d" % (shape_id - 1)
439
+ graphicFrame = CT_GraphicalObjectFrame.new_chart_graphicFrame(
440
+ shape_id, name, rId, x, y, cx, cy
441
+ )
442
+ self._spTree.append(graphicFrame)
443
+ return graphicFrame
444
+
445
+ def _add_cxnSp(
446
+ self,
447
+ connector_type: MSO_CONNECTOR_TYPE,
448
+ begin_x: Length,
449
+ begin_y: Length,
450
+ end_x: Length,
451
+ end_y: Length,
452
+ ) -> CT_Connector:
453
+ """Return a newly-added `p:cxnSp` element as specified.
454
+
455
+ The `p:cxnSp` element is for a connector of `connector_type` beginning at (`begin_x`,
456
+ `begin_y`) and extending to (`end_x`, `end_y`).
457
+ """
458
+ id_ = self._next_shape_id
459
+ name = "Connector %d" % (id_ - 1)
460
+
461
+ flipH, flipV = begin_x > end_x, begin_y > end_y
462
+ x, y = min(begin_x, end_x), min(begin_y, end_y)
463
+ cx, cy = abs(end_x - begin_x), abs(end_y - begin_y)
464
+
465
+ return self._element.add_cxnSp(id_, name, connector_type, x, y, cx, cy, flipH, flipV)
466
+
467
+ def _add_pic_from_image_part(
468
+ self,
469
+ image_part: ImagePart,
470
+ rId: str,
471
+ x: Length,
472
+ y: Length,
473
+ cx: Length | None,
474
+ cy: Length | None,
475
+ ) -> CT_Picture:
476
+ """Return a newly appended `p:pic` element as specified.
477
+
478
+ The `p:pic` element displays the image in `image_part` with size and position specified by
479
+ `x`, `y`, `cx`, and `cy`. The element is appended to the shape tree, causing it to be
480
+ displayed first in z-order on the slide.
481
+ """
482
+ id_ = self._next_shape_id
483
+ scaled_cx, scaled_cy = image_part.scale(cx, cy)
484
+ name = "Picture %d" % (id_ - 1)
485
+ desc = image_part.desc
486
+ pic = self._grpSp.add_pic(id_, name, desc, rId, x, y, scaled_cx, scaled_cy)
487
+ return pic
488
+
489
+ def _add_sp(
490
+ self, autoshape_type: AutoShapeType, x: Length, y: Length, cx: Length, cy: Length
491
+ ) -> CT_Shape:
492
+ """Return newly-added `p:sp` element as specified.
493
+
494
+ `p:sp` element is of `autoshape_type` at position (`x`, `y`) and of size (`cx`, `cy`).
495
+ """
496
+ id_ = self._next_shape_id
497
+ name = "%s %d" % (autoshape_type.basename, id_ - 1)
498
+ sp = self._grpSp.add_autoshape(id_, name, autoshape_type.prst, x, y, cx, cy)
499
+ return sp
500
+
501
+ def _add_textbox_sp(self, x: Length, y: Length, cx: Length, cy: Length) -> CT_Shape:
502
+ """Return newly-appended textbox `p:sp` element.
503
+
504
+ Element has position (`x`, `y`) and size (`cx`, `cy`).
505
+ """
506
+ id_ = self._next_shape_id
507
+ name = "TextBox %d" % (id_ - 1)
508
+ sp = self._spTree.add_textbox(id_, name, x, y, cx, cy)
509
+ return sp
510
+
511
+ def _recalculate_extents(self) -> None:
512
+ """Adjust position and size to incorporate all contained shapes.
513
+
514
+ This would typically be called when a contained shape is added, removed, or its position
515
+ or size updated.
516
+ """
517
+ # ---default behavior is to do nothing, GroupShapes overrides to
518
+ # produce the distinctive behavior of groups and subgroups.---
519
+ pass
520
+
521
+
522
+ class GroupShapes(_BaseGroupShapes):
523
+ """The sequence of child shapes belonging to a group shape.
524
+
525
+ Note that this collection can itself contain a group shape, making this part of a recursive,
526
+ tree data structure (acyclic graph).
527
+ """
528
+
529
+ def _recalculate_extents(self) -> None:
530
+ """Adjust position and size to incorporate all contained shapes.
531
+
532
+ This would typically be called when a contained shape is added, removed, or its position
533
+ or size updated.
534
+ """
535
+ self._grpSp.recalculate_extents()
536
+
537
+
538
+ class SlideShapes(_BaseGroupShapes):
539
+ """Sequence of shapes appearing on a slide.
540
+
541
+ The first shape in the sequence is the backmost in z-order and the last shape is topmost.
542
+ Supports indexed access, len(), index(), and iteration.
543
+ """
544
+
545
+ parent: Slide # pyright: ignore[reportIncompatibleMethodOverride]
546
+
547
+ def add_movie(
548
+ self,
549
+ movie_file: str | IO[bytes],
550
+ left: Length,
551
+ top: Length,
552
+ width: Length,
553
+ height: Length,
554
+ poster_frame_image: str | IO[bytes] | None = None,
555
+ mime_type: str = CT.VIDEO,
556
+ ) -> GraphicFrame:
557
+ """Return newly added movie shape displaying video in `movie_file`.
558
+
559
+ **EXPERIMENTAL.** This method has important limitations:
560
+
561
+ * The size must be specified; no auto-scaling such as that provided by :meth:`add_picture`
562
+ is performed.
563
+ * The MIME type of the video file should be specified, e.g. 'video/mp4'. The provided
564
+ video file is not interrogated for its type. The MIME type `video/unknown` is used by
565
+ default (and works fine in tests as of this writing).
566
+ * A poster frame image must be provided, it cannot be automatically extracted from the
567
+ video file. If no poster frame is provided, the default "media loudspeaker" image will
568
+ be used.
569
+
570
+ Return a newly added movie shape to the slide, positioned at (`left`, `top`), having size
571
+ (`width`, `height`), and containing `movie_file`. Before the video is started,
572
+ `poster_frame_image` is displayed as a placeholder for the video.
573
+ """
574
+ movie_pic = _MoviePicElementCreator.new_movie_pic(
575
+ self,
576
+ self._next_shape_id,
577
+ movie_file,
578
+ left,
579
+ top,
580
+ width,
581
+ height,
582
+ poster_frame_image,
583
+ mime_type,
584
+ )
585
+ self._spTree.append(movie_pic)
586
+ self._add_video_timing(movie_pic)
587
+ return cast(GraphicFrame, self._shape_factory(movie_pic))
588
+
589
+ def add_table(
590
+ self, rows: int, cols: int, left: Length, top: Length, width: Length, height: Length
591
+ ) -> GraphicFrame:
592
+ """Add a |GraphicFrame| object containing a table.
593
+
594
+ The table has the specified number of `rows` and `cols` and the specified position and
595
+ size. `width` is evenly distributed between the columns of the new table. Likewise,
596
+ `height` is evenly distributed between the rows. Note that the `.table` property on the
597
+ returned |GraphicFrame| shape must be used to access the enclosed |Table| object.
598
+ """
599
+ graphicFrame = self._add_graphicFrame_containing_table(rows, cols, left, top, width, height)
600
+ return cast(GraphicFrame, self._shape_factory(graphicFrame))
601
+
602
+ def clone_layout_placeholders(self, slide_layout: SlideLayout) -> None:
603
+ """Add placeholder shapes based on those in `slide_layout`.
604
+
605
+ Z-order of placeholders is preserved. Latent placeholders (date, slide number, and footer)
606
+ are not cloned.
607
+ """
608
+ for placeholder in slide_layout.iter_cloneable_placeholders():
609
+ self.clone_placeholder(placeholder)
610
+
611
+ @property
612
+ def placeholders(self) -> SlidePlaceholders:
613
+ """Sequence of placeholder shapes in this slide."""
614
+ return self.parent.placeholders
615
+
616
+ @property
617
+ def title(self) -> Shape | None:
618
+ """The title placeholder shape on the slide.
619
+
620
+ |None| if the slide has no title placeholder.
621
+ """
622
+ for elm in self._spTree.iter_ph_elms():
623
+ if elm.ph_idx == 0:
624
+ return cast(Shape, self._shape_factory(elm))
625
+ return None
626
+
627
+ def _add_graphicFrame_containing_table(
628
+ self, rows: int, cols: int, x: Length, y: Length, cx: Length, cy: Length
629
+ ) -> CT_GraphicalObjectFrame:
630
+ """Return a newly added `p:graphicFrame` element containing a table as specified."""
631
+ _id = self._next_shape_id
632
+ name = "Table %d" % (_id - 1)
633
+ graphicFrame = self._spTree.add_table(_id, name, rows, cols, x, y, cx, cy)
634
+ return graphicFrame
635
+
636
+ def _add_video_timing(self, pic: CT_Picture) -> None:
637
+ """Add a `p:video` element under `p:sld/p:timing`.
638
+
639
+ The element will refer to the specified `pic` element by its shape id, and cause the video
640
+ play controls to appear for that video.
641
+ """
642
+ sld = self._spTree.xpath("/p:sld")[0]
643
+ childTnLst = sld.get_or_add_childTnLst()
644
+ childTnLst.add_video(pic.shape_id)
645
+
646
+ def _shape_factory(self, shape_elm: ShapeElement) -> BaseShape:
647
+ """Return an instance of the appropriate shape proxy class for `shape_elm`."""
648
+ return SlideShapeFactory(shape_elm, self)
649
+
650
+
651
+ class LayoutShapes(_BaseShapes):
652
+ """Sequence of shapes appearing on a slide layout.
653
+
654
+ The first shape in the sequence is the backmost in z-order and the last shape is topmost.
655
+ Supports indexed access, len(), index(), and iteration.
656
+ """
657
+
658
+ def _shape_factory(self, shape_elm: ShapeElement) -> BaseShape:
659
+ """Return an instance of the appropriate shape proxy class for `shape_elm`."""
660
+ return _LayoutShapeFactory(shape_elm, self)
661
+
662
+
663
+ class MasterShapes(_BaseShapes):
664
+ """Sequence of shapes appearing on a slide master.
665
+
666
+ The first shape in the sequence is the backmost in z-order and the last shape is topmost.
667
+ Supports indexed access, len(), and iteration.
668
+ """
669
+
670
+ def _shape_factory(self, shape_elm: ShapeElement) -> BaseShape:
671
+ """Return an instance of the appropriate shape proxy class for `shape_elm`."""
672
+ return _MasterShapeFactory(shape_elm, self)
673
+
674
+
675
+ class NotesSlideShapes(_BaseShapes):
676
+ """Sequence of shapes appearing on a notes slide.
677
+
678
+ The first shape in the sequence is the backmost in z-order and the last shape is topmost.
679
+ Supports indexed access, len(), index(), and iteration.
680
+ """
681
+
682
+ def ph_basename(self, ph_type: PP_PLACEHOLDER) -> str:
683
+ """Return the base name for a placeholder of `ph_type` in this shape collection.
684
+
685
+ A notes slide uses a different name for the body placeholder and has some unique
686
+ placeholder types, so this method overrides the default in the base class.
687
+ """
688
+ return {
689
+ PP_PLACEHOLDER.BODY: "Notes Placeholder",
690
+ PP_PLACEHOLDER.DATE: "Date Placeholder",
691
+ PP_PLACEHOLDER.FOOTER: "Footer Placeholder",
692
+ PP_PLACEHOLDER.HEADER: "Header Placeholder",
693
+ PP_PLACEHOLDER.SLIDE_IMAGE: "Slide Image Placeholder",
694
+ PP_PLACEHOLDER.SLIDE_NUMBER: "Slide Number Placeholder",
695
+ }[ph_type]
696
+
697
+ def _shape_factory(self, shape_elm: ShapeElement) -> BaseShape:
698
+ """Return appropriate shape object for `shape_elm` appearing on a notes slide."""
699
+ return _NotesSlideShapeFactory(shape_elm, self)
700
+
701
+
702
+ class BasePlaceholders(_BaseShapes):
703
+ """Base class for placeholder collections.
704
+
705
+ Subclasses differentiate behaviors for a master, layout, and slide. By default, placeholder
706
+ shapes are constructed using |BaseShapeFactory|. Subclasses should override
707
+ :method:`_shape_factory` to use custom placeholder classes.
708
+ """
709
+
710
+ @staticmethod
711
+ def _is_member_elm(shape_elm: ShapeElement) -> bool:
712
+ """True if `shape_elm` is a placeholder shape, False otherwise."""
713
+ return shape_elm.has_ph_elm
714
+
715
+
716
+ class LayoutPlaceholders(BasePlaceholders):
717
+ """Sequence of |LayoutPlaceholder| instance for each placeholder shape on a slide layout."""
718
+
719
+ __iter__: Callable[ # pyright: ignore[reportIncompatibleMethodOverride]
720
+ [], Iterator[LayoutPlaceholder]
721
+ ]
722
+
723
+ def get(self, idx: int, default: LayoutPlaceholder | None = None) -> LayoutPlaceholder | None:
724
+ """The first placeholder shape with matching `idx` value, or `default` if not found."""
725
+ for placeholder in self:
726
+ if placeholder.element.ph_idx == idx:
727
+ return placeholder
728
+ return default
729
+
730
+ def _shape_factory(self, shape_elm: ShapeElement) -> BaseShape:
731
+ """Return an instance of the appropriate shape proxy class for `shape_elm`."""
732
+ return _LayoutShapeFactory(shape_elm, self)
733
+
734
+
735
+ class MasterPlaceholders(BasePlaceholders):
736
+ """Sequence of MasterPlaceholder representing the placeholder shapes on a slide master."""
737
+
738
+ __iter__: Callable[ # pyright: ignore[reportIncompatibleMethodOverride]
739
+ [], Iterator[MasterPlaceholder]
740
+ ]
741
+
742
+ def get(self, ph_type: PP_PLACEHOLDER, default: MasterPlaceholder | None = None):
743
+ """Return the first placeholder shape with type `ph_type` (e.g. 'body').
744
+
745
+ Returns `default` if no such placeholder shape is present in the collection.
746
+ """
747
+ for placeholder in self:
748
+ if placeholder.ph_type == ph_type:
749
+ return placeholder
750
+ return default
751
+
752
+ def _shape_factory( # pyright: ignore[reportIncompatibleMethodOverride]
753
+ self, placeholder_elm: CT_Shape
754
+ ) -> MasterPlaceholder:
755
+ """Return an instance of the appropriate shape proxy class for `shape_elm`."""
756
+ return cast(MasterPlaceholder, _MasterShapeFactory(placeholder_elm, self))
757
+
758
+
759
+ class NotesSlidePlaceholders(MasterPlaceholders):
760
+ """Sequence of placeholder shapes on a notes slide."""
761
+
762
+ __iter__: Callable[ # pyright: ignore[reportIncompatibleMethodOverride]
763
+ [], Iterator[NotesSlidePlaceholder]
764
+ ]
765
+
766
+ def _shape_factory( # pyright: ignore[reportIncompatibleMethodOverride]
767
+ self, placeholder_elm: CT_Shape
768
+ ) -> NotesSlidePlaceholder:
769
+ """Return an instance of the appropriate placeholder proxy class for `placeholder_elm`."""
770
+ return cast(NotesSlidePlaceholder, _NotesSlideShapeFactory(placeholder_elm, self))
771
+
772
+
773
+ class SlidePlaceholders(ParentedElementProxy):
774
+ """Collection of placeholder shapes on a slide.
775
+
776
+ Supports iteration, :func:`len`, and dictionary-style lookup on the `idx` value of the
777
+ placeholders it contains.
778
+ """
779
+
780
+ _element: CT_GroupShape
781
+
782
+ def __getitem__(self, idx: int):
783
+ """Access placeholder shape having `idx`.
784
+
785
+ Note that while this looks like list access, idx is actually a dictionary key and will
786
+ raise |KeyError| if no placeholder with that idx value is in the collection.
787
+ """
788
+ for e in self._element.iter_ph_elms():
789
+ if e.ph_idx == idx:
790
+ return SlideShapeFactory(e, self)
791
+ raise KeyError("no placeholder on this slide with idx == %d" % idx)
792
+
793
+ def __iter__(self):
794
+ """Generate placeholder shapes in `idx` order."""
795
+ ph_elms = sorted([e for e in self._element.iter_ph_elms()], key=lambda e: e.ph_idx)
796
+ return (SlideShapeFactory(e, self) for e in ph_elms)
797
+
798
+ def __len__(self) -> int:
799
+ """Return count of placeholder shapes."""
800
+ return len(list(self._element.iter_ph_elms()))
801
+
802
+
803
+ def BaseShapeFactory(shape_elm: ShapeElement, parent: ProvidesPart) -> BaseShape:
804
+ """Return an instance of the appropriate shape proxy class for `shape_elm`."""
805
+ tag = shape_elm.tag
806
+
807
+ if isinstance(shape_elm, CT_Picture):
808
+ videoFiles = shape_elm.xpath("./p:nvPicPr/p:nvPr/a:videoFile")
809
+ if videoFiles:
810
+ return Movie(shape_elm, parent)
811
+ return Picture(shape_elm, parent)
812
+
813
+ shape_cls = {
814
+ qn("p:cxnSp"): Connector,
815
+ qn("p:grpSp"): GroupShape,
816
+ qn("p:sp"): Shape,
817
+ qn("p:graphicFrame"): GraphicFrame,
818
+ }.get(tag, BaseShape)
819
+
820
+ return shape_cls(shape_elm, parent) # pyright: ignore[reportArgumentType]
821
+
822
+
823
+ def _LayoutShapeFactory(shape_elm: ShapeElement, parent: ProvidesPart) -> BaseShape:
824
+ """Return appropriate shape object for `shape_elm` on a slide layout."""
825
+ if isinstance(shape_elm, CT_Shape) and shape_elm.has_ph_elm:
826
+ return LayoutPlaceholder(shape_elm, parent)
827
+ return BaseShapeFactory(shape_elm, parent)
828
+
829
+
830
+ def _MasterShapeFactory(shape_elm: ShapeElement, parent: ProvidesPart) -> BaseShape:
831
+ """Return appropriate shape object for `shape_elm` on a slide master."""
832
+ if isinstance(shape_elm, CT_Shape) and shape_elm.has_ph_elm:
833
+ return MasterPlaceholder(shape_elm, parent)
834
+ return BaseShapeFactory(shape_elm, parent)
835
+
836
+
837
+ def _NotesSlideShapeFactory(shape_elm: ShapeElement, parent: ProvidesPart) -> BaseShape:
838
+ """Return appropriate shape object for `shape_elm` on a notes slide."""
839
+ if isinstance(shape_elm, CT_Shape) and shape_elm.has_ph_elm:
840
+ return NotesSlidePlaceholder(shape_elm, parent)
841
+ return BaseShapeFactory(shape_elm, parent)
842
+
843
+
844
+ def _SlidePlaceholderFactory(shape_elm: ShapeElement, parent: ProvidesPart):
845
+ """Return a placeholder shape of the appropriate type for `shape_elm`."""
846
+ tag = shape_elm.tag
847
+ if tag == qn("p:sp"):
848
+ Constructor = {
849
+ PP_PLACEHOLDER.BITMAP: PicturePlaceholder,
850
+ PP_PLACEHOLDER.CHART: ChartPlaceholder,
851
+ PP_PLACEHOLDER.PICTURE: PicturePlaceholder,
852
+ PP_PLACEHOLDER.TABLE: TablePlaceholder,
853
+ }.get(shape_elm.ph_type, SlidePlaceholder)
854
+ elif tag == qn("p:graphicFrame"):
855
+ Constructor = PlaceholderGraphicFrame
856
+ elif tag == qn("p:pic"):
857
+ Constructor = PlaceholderPicture
858
+ else:
859
+ Constructor = BaseShapeFactory
860
+ return Constructor(shape_elm, parent) # pyright: ignore[reportArgumentType]
861
+
862
+
863
+ def SlideShapeFactory(shape_elm: ShapeElement, parent: ProvidesPart) -> BaseShape:
864
+ """Return appropriate shape object for `shape_elm` on a slide."""
865
+ if shape_elm.has_ph_elm:
866
+ return _SlidePlaceholderFactory(shape_elm, parent)
867
+ return BaseShapeFactory(shape_elm, parent)
868
+
869
+
870
+ class _MoviePicElementCreator(object):
871
+ """Functional service object for creating a new movie p:pic element.
872
+
873
+ It's entire external interface is its :meth:`new_movie_pic` class method that returns a new
874
+ `p:pic` element containing the specified video. This class is not intended to be constructed
875
+ or an instance of it retained by the caller; it is a "one-shot" object, really a function
876
+ wrapped in a object such that its helper methods can be organized here.
877
+ """
878
+
879
+ def __init__(
880
+ self,
881
+ shapes: SlideShapes,
882
+ shape_id: int,
883
+ movie_file: str | IO[bytes],
884
+ x: Length,
885
+ y: Length,
886
+ cx: Length,
887
+ cy: Length,
888
+ poster_frame_file: str | IO[bytes] | None,
889
+ mime_type: str | None,
890
+ ):
891
+ super(_MoviePicElementCreator, self).__init__()
892
+ self._shapes = shapes
893
+ self._shape_id = shape_id
894
+ self._movie_file = movie_file
895
+ self._x, self._y, self._cx, self._cy = x, y, cx, cy
896
+ self._poster_frame_file = poster_frame_file
897
+ self._mime_type = mime_type
898
+
899
+ @classmethod
900
+ def new_movie_pic(
901
+ cls,
902
+ shapes: SlideShapes,
903
+ shape_id: int,
904
+ movie_file: str | IO[bytes],
905
+ x: Length,
906
+ y: Length,
907
+ cx: Length,
908
+ cy: Length,
909
+ poster_frame_image: str | IO[bytes] | None,
910
+ mime_type: str | None,
911
+ ) -> CT_Picture:
912
+ """Return a new `p:pic` element containing video in `movie_file`.
913
+
914
+ If `mime_type` is None, 'video/unknown' is used. If `poster_frame_file` is None, the
915
+ default "media loudspeaker" image is used.
916
+ """
917
+ return cls(shapes, shape_id, movie_file, x, y, cx, cy, poster_frame_image, mime_type)._pic
918
+
919
+ @property
920
+ def _media_rId(self) -> str:
921
+ """Return the rId of RT.MEDIA relationship to video part.
922
+
923
+ For historical reasons, there are two relationships to the same part; one is the video rId
924
+ and the other is the media rId.
925
+ """
926
+ return self._video_part_rIds[0]
927
+
928
+ @lazyproperty
929
+ def _pic(self) -> CT_Picture:
930
+ """Return the new `p:pic` element referencing the video."""
931
+ return CT_Picture.new_video_pic(
932
+ self._shape_id,
933
+ self._shape_name,
934
+ self._video_rId,
935
+ self._media_rId,
936
+ self._poster_frame_rId,
937
+ self._x,
938
+ self._y,
939
+ self._cx,
940
+ self._cy,
941
+ )
942
+
943
+ @lazyproperty
944
+ def _poster_frame_image_file(self) -> str | IO[bytes]:
945
+ """Return the image file for video placeholder image.
946
+
947
+ If no poster frame file is provided, the default "media loudspeaker" image is used.
948
+ """
949
+ poster_frame_file = self._poster_frame_file
950
+ if poster_frame_file is None:
951
+ return io.BytesIO(SPEAKER_IMAGE_BYTES)
952
+ return poster_frame_file
953
+
954
+ @lazyproperty
955
+ def _poster_frame_rId(self) -> str:
956
+ """Return the rId of relationship to poster frame image.
957
+
958
+ The poster frame is the image used to represent the video before it's played.
959
+ """
960
+ _, poster_frame_rId = self._slide_part.get_or_add_image_part(self._poster_frame_image_file)
961
+ return poster_frame_rId
962
+
963
+ @property
964
+ def _shape_name(self) -> str:
965
+ """Return the appropriate shape name for the p:pic shape.
966
+
967
+ A movie shape is named with the base filename of the video.
968
+ """
969
+ return self._video.filename
970
+
971
+ @property
972
+ def _slide_part(self) -> SlidePart:
973
+ """Return SlidePart object for slide containing this movie."""
974
+ return self._shapes.part
975
+
976
+ @lazyproperty
977
+ def _video(self) -> Video:
978
+ """Return a |Video| object containing the movie file."""
979
+ return Video.from_path_or_file_like(self._movie_file, self._mime_type)
980
+
981
+ @lazyproperty
982
+ def _video_part_rIds(self) -> tuple[str, str]:
983
+ """Return the rIds for relationships to media part for video.
984
+
985
+ This is where the media part and its relationships to the slide are actually created.
986
+ """
987
+ media_rId, video_rId = self._slide_part.get_or_add_video_media_part(self._video)
988
+ return media_rId, video_rId
989
+
990
+ @property
991
+ def _video_rId(self) -> str:
992
+ """Return the rId of RT.VIDEO relationship to video part.
993
+
994
+ For historical reasons, there are two relationships to the same part; one is the video rId
995
+ and the other is the media rId.
996
+ """
997
+ return self._video_part_rIds[1]
998
+
999
+
1000
+ class _OleObjectElementCreator(object):
1001
+ """Functional service object for creating a new OLE-object p:graphicFrame element.
1002
+
1003
+ It's entire external interface is its :meth:`graphicFrame` class method that returns a new
1004
+ `p:graphicFrame` element containing the specified embedded OLE-object shape. This class is not
1005
+ intended to be constructed or an instance of it retained by the caller; it is a "one-shot"
1006
+ object, really a function wrapped in a object such that its helper methods can be organized
1007
+ here.
1008
+ """
1009
+
1010
+ def __init__(
1011
+ self,
1012
+ shapes: _BaseGroupShapes,
1013
+ shape_id: int,
1014
+ ole_object_file: str | IO[bytes],
1015
+ prog_id: PROG_ID | str,
1016
+ x: Length,
1017
+ y: Length,
1018
+ cx: Length | None,
1019
+ cy: Length | None,
1020
+ icon_file: str | IO[bytes] | None,
1021
+ icon_width: Length | None,
1022
+ icon_height: Length | None,
1023
+ ):
1024
+ self._shapes = shapes
1025
+ self._shape_id = shape_id
1026
+ self._ole_object_file = ole_object_file
1027
+ self._prog_id_arg = prog_id
1028
+ self._x = x
1029
+ self._y = y
1030
+ self._cx_arg = cx
1031
+ self._cy_arg = cy
1032
+ self._icon_file_arg = icon_file
1033
+ self._icon_width_arg = icon_width
1034
+ self._icon_height_arg = icon_height
1035
+
1036
+ @classmethod
1037
+ def graphicFrame(
1038
+ cls,
1039
+ shapes: _BaseGroupShapes,
1040
+ shape_id: int,
1041
+ ole_object_file: str | IO[bytes],
1042
+ prog_id: PROG_ID | str,
1043
+ x: Length,
1044
+ y: Length,
1045
+ cx: Length | None,
1046
+ cy: Length | None,
1047
+ icon_file: str | IO[bytes] | None,
1048
+ icon_width: Length | None,
1049
+ icon_height: Length | None,
1050
+ ) -> CT_GraphicalObjectFrame:
1051
+ """Return new `p:graphicFrame` element containing embedded `ole_object_file`."""
1052
+ return cls(
1053
+ shapes,
1054
+ shape_id,
1055
+ ole_object_file,
1056
+ prog_id,
1057
+ x,
1058
+ y,
1059
+ cx,
1060
+ cy,
1061
+ icon_file,
1062
+ icon_width,
1063
+ icon_height,
1064
+ )._graphicFrame
1065
+
1066
+ @lazyproperty
1067
+ def _graphicFrame(self) -> CT_GraphicalObjectFrame:
1068
+ """Newly-created `p:graphicFrame` element referencing embedded OLE-object."""
1069
+ return CT_GraphicalObjectFrame.new_ole_object_graphicFrame(
1070
+ self._shape_id,
1071
+ self._shape_name,
1072
+ self._ole_object_rId,
1073
+ self._progId,
1074
+ self._icon_rId,
1075
+ self._x,
1076
+ self._y,
1077
+ self._cx,
1078
+ self._cy,
1079
+ self._icon_width,
1080
+ self._icon_height,
1081
+ )
1082
+
1083
+ @lazyproperty
1084
+ def _cx(self) -> Length:
1085
+ """Emu object specifying width of "show-as-icon" image for OLE shape."""
1086
+ # --- a user-specified width overrides any default ---
1087
+ if self._cx_arg is not None:
1088
+ return self._cx_arg
1089
+
1090
+ # --- the default width is specified by the PROG_ID member if prog_id is one,
1091
+ # --- otherwise it gets the default icon width.
1092
+ return (
1093
+ Emu(self._prog_id_arg.width) if isinstance(self._prog_id_arg, PROG_ID) else Emu(965200)
1094
+ )
1095
+
1096
+ @lazyproperty
1097
+ def _cy(self) -> Length:
1098
+ """Emu object specifying height of "show-as-icon" image for OLE shape."""
1099
+ # --- a user-specified width overrides any default ---
1100
+ if self._cy_arg is not None:
1101
+ return self._cy_arg
1102
+
1103
+ # --- the default height is specified by the PROG_ID member if prog_id is one,
1104
+ # --- otherwise it gets the default icon height.
1105
+ return (
1106
+ Emu(self._prog_id_arg.height) if isinstance(self._prog_id_arg, PROG_ID) else Emu(609600)
1107
+ )
1108
+
1109
+ @lazyproperty
1110
+ def _icon_height(self) -> Length:
1111
+ """Vertical size of enclosed EMF icon within the OLE graphic-frame.
1112
+
1113
+ This must be specified when a custom icon is used, to avoid stretching of the image and
1114
+ possible undesired resizing by PowerPoint when the OLE shape is double-clicked to open it.
1115
+
1116
+ The correct size can be determined by creating an example PPTX using PowerPoint and then
1117
+ inspecting the XML of the OLE graphics-frame (p:oleObj.imgH).
1118
+ """
1119
+ return self._icon_height_arg if self._icon_height_arg is not None else Emu(609600)
1120
+
1121
+ @lazyproperty
1122
+ def _icon_image_file(self) -> str | IO[bytes]:
1123
+ """Reference to image file containing icon to show in lieu of this object.
1124
+
1125
+ This can be either a str path or a file-like object (io.BytesIO typically).
1126
+ """
1127
+ # --- a user-specified icon overrides any default ---
1128
+ if self._icon_file_arg is not None:
1129
+ return self._icon_file_arg
1130
+
1131
+ # --- A prog_id belonging to PROG_ID gets its icon filename from there. A
1132
+ # --- user-specified (str) prog_id gets the default icon.
1133
+ icon_filename = (
1134
+ self._prog_id_arg.icon_filename
1135
+ if isinstance(self._prog_id_arg, PROG_ID)
1136
+ else "generic-icon.emf"
1137
+ )
1138
+
1139
+ _thisdir = os.path.split(__file__)[0]
1140
+ return os.path.abspath(os.path.join(_thisdir, "..", "templates", icon_filename))
1141
+
1142
+ @lazyproperty
1143
+ def _icon_rId(self) -> str:
1144
+ """str rId like "rId7" of rel to icon (image) representing OLE-object part."""
1145
+ _, rId = self._slide_part.get_or_add_image_part(self._icon_image_file)
1146
+ return rId
1147
+
1148
+ @lazyproperty
1149
+ def _icon_width(self) -> Length:
1150
+ """Width of enclosed EMF icon within the OLE graphic-frame.
1151
+
1152
+ This must be specified when a custom icon is used, to avoid stretching of the image and
1153
+ possible undesired resizing by PowerPoint when the OLE shape is double-clicked to open it.
1154
+ """
1155
+ return self._icon_width_arg if self._icon_width_arg is not None else Emu(965200)
1156
+
1157
+ @lazyproperty
1158
+ def _ole_object_rId(self) -> str:
1159
+ """str rId like "rId6" of relationship to embedded ole_object part.
1160
+
1161
+ This is where the ole_object part and its relationship to the slide are actually created.
1162
+ """
1163
+ return self._slide_part.add_embedded_ole_object_part(
1164
+ self._prog_id_arg, self._ole_object_file
1165
+ )
1166
+
1167
+ @lazyproperty
1168
+ def _progId(self) -> str:
1169
+ """str like "Excel.Sheet.12" identifying program used to open object.
1170
+
1171
+ This value appears in the `progId` attribute of the `p:oleObj` element for the object.
1172
+ """
1173
+ prog_id_arg = self._prog_id_arg
1174
+
1175
+ # --- member of PROG_ID enumeration knows its progId keyphrase, otherwise caller
1176
+ # --- has specified it explicitly (as str)
1177
+ return prog_id_arg.progId if isinstance(prog_id_arg, PROG_ID) else prog_id_arg
1178
+
1179
+ @lazyproperty
1180
+ def _shape_name(self) -> str:
1181
+ """str name like "Object 1" for the embedded ole_object shape.
1182
+
1183
+ The name is formed from the prefix "Object " and the shape-id decremented by 1.
1184
+ """
1185
+ return "Object %d" % (self._shape_id - 1)
1186
+
1187
+ @lazyproperty
1188
+ def _slide_part(self) -> SlidePart:
1189
+ """SlidePart object for this slide."""
1190
+ return self._shapes.part
tasks/tasksmith-74f059424102/environment/source/src/pptx/shared.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Objects shared by pptx modules."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ if TYPE_CHECKING:
8
+ from pptx.opc.package import XmlPart
9
+ from pptx.oxml.xmlchemy import BaseOxmlElement
10
+ from pptx.types import ProvidesPart
11
+
12
+
13
+ class ElementProxy(object):
14
+ """Base class for lxml element proxy classes.
15
+
16
+ An element proxy class is one whose primary responsibilities are fulfilled by manipulating the
17
+ attributes and child elements of an XML element. They are the most common type of class in
18
+ python-pptx other than custom element (oxml) classes.
19
+ """
20
+
21
+ def __init__(self, element: BaseOxmlElement):
22
+ self._element = element
23
+
24
+ def __eq__(self, other: object) -> bool:
25
+ """Return |True| if this proxy object refers to the same oxml element as does *other*.
26
+
27
+ ElementProxy objects are value objects and should maintain no mutable local state.
28
+ Equality for proxy objects is defined as referring to the same XML element, whether or not
29
+ they are the same proxy object instance.
30
+ """
31
+ if not isinstance(other, ElementProxy):
32
+ return False
33
+ return self._element is other._element
34
+
35
+ def __ne__(self, other: object) -> bool:
36
+ if not isinstance(other, ElementProxy):
37
+ return True
38
+ return self._element is not other._element
39
+
40
+ @property
41
+ def element(self):
42
+ """The lxml element proxied by this object."""
43
+ return self._element
44
+
45
+
46
+ class ParentedElementProxy(ElementProxy):
47
+ """Provides access to ancestor objects and part.
48
+
49
+ An ancestor may occasionally be required to provide a service, such as add or drop a
50
+ relationship. Provides the :attr:`_parent` attribute to subclasses and the public
51
+ :attr:`parent` read-only property.
52
+ """
53
+
54
+ def __init__(self, element: BaseOxmlElement, parent: ProvidesPart):
55
+ super(ParentedElementProxy, self).__init__(element)
56
+ self._parent = parent
57
+
58
+ @property
59
+ def parent(self):
60
+ """The ancestor proxy object to this one.
61
+
62
+ For example, the parent of a shape is generally the |SlideShapes| object that contains it.
63
+ """
64
+ return self._parent
65
+
66
+ @property
67
+ def part(self) -> XmlPart:
68
+ """The package part containing this object."""
69
+ return self._parent.part
70
+
71
+
72
+ class PartElementProxy(ElementProxy):
73
+ """Provides common members for proxy-objects that wrap a part's root element, e.g. `p:sld`."""
74
+
75
+ def __init__(self, element: BaseOxmlElement, part: XmlPart):
76
+ super(PartElementProxy, self).__init__(element)
77
+ self._part = part
78
+
79
+ @property
80
+ def part(self) -> XmlPart:
81
+ """The package part containing this object."""
82
+ return self._part
tasks/tasksmith-74f059424102/environment/source/src/pptx/slide.py ADDED
@@ -0,0 +1,498 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Slide-related objects, including masters, layouts, and notes."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Iterator, cast
6
+
7
+ from pptx.dml.fill import FillFormat
8
+ from pptx.enum.shapes import PP_PLACEHOLDER
9
+ from pptx.shapes.shapetree import (
10
+ LayoutPlaceholders,
11
+ LayoutShapes,
12
+ MasterPlaceholders,
13
+ MasterShapes,
14
+ NotesSlidePlaceholders,
15
+ NotesSlideShapes,
16
+ SlidePlaceholders,
17
+ SlideShapes,
18
+ )
19
+ from pptx.shared import ElementProxy, ParentedElementProxy, PartElementProxy
20
+ from pptx.util import lazyproperty
21
+
22
+ if TYPE_CHECKING:
23
+ from pptx.oxml.presentation import CT_SlideIdList, CT_SlideMasterIdList
24
+ from pptx.oxml.slide import (
25
+ CT_CommonSlideData,
26
+ CT_NotesSlide,
27
+ CT_Slide,
28
+ CT_SlideLayoutIdList,
29
+ CT_SlideMaster,
30
+ )
31
+ from pptx.parts.presentation import PresentationPart
32
+ from pptx.parts.slide import SlideLayoutPart, SlideMasterPart, SlidePart
33
+ from pptx.presentation import Presentation
34
+ from pptx.shapes.placeholder import LayoutPlaceholder, MasterPlaceholder
35
+ from pptx.shapes.shapetree import NotesSlidePlaceholder
36
+ from pptx.text.text import TextFrame
37
+
38
+
39
+ class _BaseSlide(PartElementProxy):
40
+ """Base class for slide objects, including masters, layouts and notes."""
41
+
42
+ _element: CT_Slide
43
+
44
+ @lazyproperty
45
+ def background(self) -> _Background:
46
+ """|_Background| object providing slide background properties.
47
+
48
+ This property returns a |_Background| object whether or not the
49
+ slide, master, or layout has an explicitly defined background.
50
+
51
+ The same |_Background| object is returned on every call for the same
52
+ slide object.
53
+ """
54
+ return _Background(self._element.cSld)
55
+
56
+ @property
57
+ def name(self) -> str:
58
+ """String representing the internal name of this slide.
59
+
60
+ Returns an empty string (`''`) if no name is assigned. Assigning an empty string or |None|
61
+ to this property causes any name to be removed.
62
+ """
63
+ return self._element.cSld.name
64
+
65
+ @name.setter
66
+ def name(self, value: str | None):
67
+ new_value = "" if value is None else value
68
+ self._element.cSld.name = new_value
69
+
70
+
71
+ class _BaseMaster(_BaseSlide):
72
+ """Base class for master objects such as |SlideMaster| and |NotesMaster|.
73
+
74
+ Provides access to placeholders and regular shapes.
75
+ """
76
+
77
+ @lazyproperty
78
+ def placeholders(self) -> MasterPlaceholders:
79
+ """|MasterPlaceholders| collection of placeholder shapes in this master.
80
+
81
+ Sequence sorted in `idx` order.
82
+ """
83
+ return MasterPlaceholders(self._element.spTree, self)
84
+
85
+ @lazyproperty
86
+ def shapes(self):
87
+ """
88
+ Instance of |MasterShapes| containing sequence of shape objects
89
+ appearing on this slide.
90
+ """
91
+ return MasterShapes(self._element.spTree, self)
92
+
93
+
94
+ class NotesMaster(_BaseMaster):
95
+ """Proxy for the notes master XML document.
96
+
97
+ Provides access to shapes, the most commonly used of which are placeholders.
98
+ """
99
+
100
+
101
+ class NotesSlide(_BaseSlide):
102
+ """Notes slide object.
103
+
104
+ Provides access to slide notes placeholder and other shapes on the notes handout
105
+ page.
106
+ """
107
+
108
+ element: CT_NotesSlide # pyright: ignore[reportIncompatibleMethodOverride]
109
+
110
+ def clone_master_placeholders(self, notes_master: NotesMaster) -> None:
111
+ """Selectively add placeholder shape elements from `notes_master`.
112
+
113
+ Selected placeholder shape elements from `notes_master` are added to the shapes
114
+ collection of this notes slide. Z-order of placeholders is preserved. Certain
115
+ placeholders (header, date, footer) are not cloned.
116
+ """
117
+
118
+ def iter_cloneable_placeholders() -> Iterator[MasterPlaceholder]:
119
+ """Generate a reference to each cloneable placeholder in `notes_master`.
120
+
121
+ These are the placeholders that should be cloned to a notes slide when the a new notes
122
+ slide is created.
123
+ """
124
+ cloneable = (
125
+ PP_PLACEHOLDER.SLIDE_IMAGE,
126
+ PP_PLACEHOLDER.BODY,
127
+ PP_PLACEHOLDER.SLIDE_NUMBER,
128
+ )
129
+ for placeholder in notes_master.placeholders:
130
+ if placeholder.element.ph_type in cloneable:
131
+ yield placeholder
132
+
133
+ shapes = self.shapes
134
+ for placeholder in iter_cloneable_placeholders():
135
+ shapes.clone_placeholder(cast("LayoutPlaceholder", placeholder))
136
+
137
+ @property
138
+ def notes_placeholder(self) -> NotesSlidePlaceholder | None:
139
+ """the notes placeholder on this notes slide, the shape that contains the actual notes text.
140
+
141
+ Return |None| if no notes placeholder is present; while this is probably uncommon, it can
142
+ happen if the notes master does not have a body placeholder, or if the notes placeholder
143
+ has been deleted from the notes slide.
144
+ """
145
+ for placeholder in self.placeholders:
146
+ if placeholder.placeholder_format.type == PP_PLACEHOLDER.BODY:
147
+ return placeholder
148
+ return None
149
+
150
+ @property
151
+ def notes_text_frame(self) -> TextFrame | None:
152
+ """The text frame of the notes placeholder on this notes slide.
153
+
154
+ |None| if there is no notes placeholder. This is a shortcut to accommodate the common case
155
+ of simply adding "notes" text to the notes "page".
156
+ """
157
+ notes_placeholder = self.notes_placeholder
158
+ if notes_placeholder is None:
159
+ return None
160
+ return notes_placeholder.text_frame
161
+
162
+ @lazyproperty
163
+ def placeholders(self) -> NotesSlidePlaceholders:
164
+ """Instance of |NotesSlidePlaceholders| for this notes-slide.
165
+
166
+ Contains the sequence of placeholder shapes in this notes slide.
167
+ """
168
+ return NotesSlidePlaceholders(self.element.spTree, self)
169
+
170
+ @lazyproperty
171
+ def shapes(self) -> NotesSlideShapes:
172
+ """Sequence of shape objects appearing on this notes slide."""
173
+ return NotesSlideShapes(self._element.spTree, self)
174
+
175
+
176
+ class Slide(_BaseSlide):
177
+ """Slide object. Provides access to shapes and slide-level properties."""
178
+
179
+ part: SlidePart # pyright: ignore[reportIncompatibleMethodOverride]
180
+
181
+ @property
182
+ def follow_master_background(self):
183
+ """|True| if this slide inherits the slide master background.
184
+
185
+ Assigning |False| causes background inheritance from the master to be
186
+ interrupted; if there is no custom background for this slide,
187
+ a default background is added. If a custom background already exists
188
+ for this slide, assigning |False| has no effect.
189
+
190
+ Assigning |True| causes any custom background for this slide to be
191
+ deleted and inheritance from the master restored.
192
+ """
193
+ return self._element.bg is None
194
+
195
+ @property
196
+ def has_notes_slide(self) -> bool:
197
+ """`True` if this slide has a notes slide, `False` otherwise.
198
+
199
+ A notes slide is created by :attr:`.notes_slide` when one doesn't exist; use this property
200
+ to test for a notes slide without the possible side effect of creating one.
201
+ """
202
+ return self.part.has_notes_slide
203
+
204
+ @property
205
+ def notes_slide(self) -> NotesSlide:
206
+ """The |NotesSlide| instance for this slide.
207
+
208
+ If the slide does not have a notes slide, one is created. The same single instance is
209
+ returned on each call.
210
+ """
211
+ return self.part.notes_slide
212
+
213
+ @lazyproperty
214
+ def placeholders(self) -> SlidePlaceholders:
215
+ """Sequence of placeholder shapes in this slide."""
216
+ return SlidePlaceholders(self._element.spTree, self)
217
+
218
+ @lazyproperty
219
+ def shapes(self) -> SlideShapes:
220
+ """Sequence of shape objects appearing on this slide."""
221
+ return SlideShapes(self._element.spTree, self)
222
+
223
+ @property
224
+ def slide_id(self) -> int:
225
+ """Integer value that uniquely identifies this slide within this presentation.
226
+
227
+ The slide id does not change if the position of this slide in the slide sequence is changed
228
+ by adding, rearranging, or deleting slides.
229
+ """
230
+ return self.part.slide_id
231
+
232
+ @property
233
+ def slide_layout(self) -> SlideLayout:
234
+ """|SlideLayout| object this slide inherits appearance from."""
235
+ return self.part.slide_layout
236
+
237
+
238
+ class Slides(ParentedElementProxy):
239
+ """Sequence of slides belonging to an instance of |Presentation|.
240
+
241
+ Has list semantics for access to individual slides. Supports indexed access, len(), and
242
+ iteration.
243
+ """
244
+
245
+ part: PresentationPart # pyright: ignore[reportIncompatibleMethodOverride]
246
+
247
+ def __init__(self, sldIdLst: CT_SlideIdList, prs: Presentation):
248
+ super(Slides, self).__init__(sldIdLst, prs)
249
+ self._sldIdLst = sldIdLst
250
+
251
+ def __getitem__(self, idx: int) -> Slide:
252
+ """Provide indexed access, (e.g. 'slides[0]')."""
253
+ try:
254
+ sldId = self._sldIdLst.sldId_lst[idx]
255
+ except IndexError:
256
+ raise IndexError("slide index out of range")
257
+ return self.part.related_slide(sldId.rId)
258
+
259
+ def __iter__(self) -> Iterator[Slide]:
260
+ """Support iteration, e.g. `for slide in slides:`."""
261
+ for sldId in self._sldIdLst.sldId_lst:
262
+ yield self.part.related_slide(sldId.rId)
263
+
264
+ def __len__(self) -> int:
265
+ """Support len() built-in function, e.g. `len(slides) == 4`."""
266
+ return len(self._sldIdLst)
267
+
268
+ def add_slide(self, slide_layout: SlideLayout) -> Slide:
269
+ """Return a newly added slide that inherits layout from `slide_layout`."""
270
+ rId, slide = self.part.add_slide(slide_layout)
271
+ slide.shapes.clone_layout_placeholders(slide_layout)
272
+ self._sldIdLst.add_sldId(rId)
273
+ return slide
274
+
275
+ def get(self, slide_id: int, default: Slide | None = None) -> Slide | None:
276
+ """Return the slide identified by int `slide_id` in this presentation.
277
+
278
+ Returns `default` if not found.
279
+ """
280
+ slide = self.part.get_slide(slide_id)
281
+ if slide is None:
282
+ return default
283
+ return slide
284
+
285
+ def index(self, slide: Slide) -> int:
286
+ """Map `slide` to its zero-based position in this slide sequence.
287
+
288
+ Raises |ValueError| on *slide* not present.
289
+ """
290
+ for idx, this_slide in enumerate(self):
291
+ if this_slide == slide:
292
+ return idx
293
+ raise ValueError("%s is not in slide collection" % slide)
294
+
295
+
296
+ class SlideLayout(_BaseSlide):
297
+ """Slide layout object.
298
+
299
+ Provides access to placeholders, regular shapes, and slide layout-level properties.
300
+ """
301
+
302
+ part: SlideLayoutPart # pyright: ignore[reportIncompatibleMethodOverride]
303
+
304
+ def iter_cloneable_placeholders(self) -> Iterator[LayoutPlaceholder]:
305
+ """Generate layout-placeholders on this slide-layout that should be cloned to a new slide.
306
+
307
+ Used when creating a new slide from this slide-layout.
308
+ """
309
+ latent_ph_types = (
310
+ PP_PLACEHOLDER.DATE,
311
+ PP_PLACEHOLDER.FOOTER,
312
+ PP_PLACEHOLDER.SLIDE_NUMBER,
313
+ )
314
+ for ph in self.placeholders:
315
+ if ph.element.ph_type not in latent_ph_types:
316
+ yield ph
317
+
318
+ @lazyproperty
319
+ def placeholders(self) -> LayoutPlaceholders:
320
+ """Sequence of placeholder shapes in this slide layout.
321
+
322
+ Placeholders appear in `idx` order.
323
+ """
324
+ return LayoutPlaceholders(self._element.spTree, self)
325
+
326
+ @lazyproperty
327
+ def shapes(self) -> LayoutShapes:
328
+ """Sequence of shapes appearing on this slide layout."""
329
+ return LayoutShapes(self._element.spTree, self)
330
+
331
+ @property
332
+ def slide_master(self) -> SlideMaster:
333
+ """Slide master from which this slide-layout inherits properties."""
334
+ return self.part.slide_master
335
+
336
+ @property
337
+ def used_by_slides(self):
338
+ """Tuple of slide objects based on this slide layout."""
339
+ # ---getting Slides collection requires going around the horn a bit---
340
+ slides = self.part.package.presentation_part.presentation.slides
341
+ return tuple(s for s in slides if s.slide_layout == self)
342
+
343
+
344
+ class SlideLayouts(ParentedElementProxy):
345
+ """Sequence of slide layouts belonging to a slide-master.
346
+
347
+ Supports indexed access, len(), iteration, index() and remove().
348
+ """
349
+
350
+ part: SlideMasterPart # pyright: ignore[reportIncompatibleMethodOverride]
351
+
352
+ def __init__(self, sldLayoutIdLst: CT_SlideLayoutIdList, parent: SlideMaster):
353
+ super(SlideLayouts, self).__init__(sldLayoutIdLst, parent)
354
+ self._sldLayoutIdLst = sldLayoutIdLst
355
+
356
+ def __getitem__(self, idx: int) -> SlideLayout:
357
+ """Provides indexed access, e.g. `slide_layouts[2]`."""
358
+ try:
359
+ sldLayoutId = self._sldLayoutIdLst.sldLayoutId_lst[idx]
360
+ except IndexError:
361
+ raise IndexError("slide layout index out of range")
362
+ return self.part.related_slide_layout(sldLayoutId.rId)
363
+
364
+ def __iter__(self) -> Iterator[SlideLayout]:
365
+ """Generate each |SlideLayout| in the collection, in sequence."""
366
+ for sldLayoutId in self._sldLayoutIdLst.sldLayoutId_lst:
367
+ yield self.part.related_slide_layout(sldLayoutId.rId)
368
+
369
+ def __len__(self) -> int:
370
+ """Support len() built-in function, e.g. `len(slides) == 4`."""
371
+ return len(self._sldLayoutIdLst)
372
+
373
+ def get_by_name(self, name: str, default: SlideLayout | None = None) -> SlideLayout | None:
374
+ """Return SlideLayout object having `name`, or `default` if not found."""
375
+ for slide_layout in self:
376
+ if slide_layout.name == name:
377
+ return slide_layout
378
+ return default
379
+
380
+ def index(self, slide_layout: SlideLayout) -> int:
381
+ """Return zero-based index of `slide_layout` in this collection.
382
+
383
+ Raises `ValueError` if `slide_layout` is not present in this collection.
384
+ """
385
+ for idx, this_layout in enumerate(self):
386
+ if slide_layout == this_layout:
387
+ return idx
388
+ raise ValueError("layout not in this SlideLayouts collection")
389
+
390
+ def remove(self, slide_layout: SlideLayout) -> None:
391
+ """Remove `slide_layout` from the collection.
392
+
393
+ Raises ValueError when `slide_layout` is in use; a slide layout which is the basis for one
394
+ or more slides cannot be removed.
395
+ """
396
+ # ---raise if layout is in use---
397
+ if slide_layout.used_by_slides:
398
+ raise ValueError("cannot remove slide-layout in use by one or more slides")
399
+
400
+ # ---target layout is identified by its index in this collection---
401
+ target_idx = self.index(slide_layout)
402
+
403
+ # --remove layout from p:sldLayoutIds of its master
404
+ # --this stops layout from showing up, but doesn't remove it from package
405
+ target_sldLayoutId = self._sldLayoutIdLst.sldLayoutId_lst[target_idx]
406
+ self._sldLayoutIdLst.remove(target_sldLayoutId)
407
+
408
+ # --drop relationship from master to layout
409
+ # --this removes layout from package, along with everything (only) it refers to,
410
+ # --including images (not used elsewhere) and hyperlinks
411
+ slide_layout.slide_master.part.drop_rel(target_sldLayoutId.rId)
412
+
413
+
414
+ class SlideMaster(_BaseMaster):
415
+ """Slide master object.
416
+
417
+ Provides access to slide layouts. Access to placeholders, regular shapes, and slide master-level
418
+ properties is inherited from |_BaseMaster|.
419
+ """
420
+
421
+ _element: CT_SlideMaster # pyright: ignore[reportIncompatibleVariableOverride]
422
+
423
+ @lazyproperty
424
+ def slide_layouts(self) -> SlideLayouts:
425
+ """|SlideLayouts| object providing access to this slide-master's layouts."""
426
+ return SlideLayouts(self._element.get_or_add_sldLayoutIdLst(), self)
427
+
428
+
429
+ class SlideMasters(ParentedElementProxy):
430
+ """Sequence of |SlideMaster| objects belonging to a presentation.
431
+
432
+ Has list access semantics, supporting indexed access, len(), and iteration.
433
+ """
434
+
435
+ part: PresentationPart # pyright: ignore[reportIncompatibleMethodOverride]
436
+
437
+ def __init__(self, sldMasterIdLst: CT_SlideMasterIdList, parent: Presentation):
438
+ super(SlideMasters, self).__init__(sldMasterIdLst, parent)
439
+ self._sldMasterIdLst = sldMasterIdLst
440
+
441
+ def __getitem__(self, idx: int) -> SlideMaster:
442
+ """Provides indexed access, e.g. `slide_masters[2]`."""
443
+ try:
444
+ sldMasterId = self._sldMasterIdLst.sldMasterId_lst[idx]
445
+ except IndexError:
446
+ raise IndexError("slide master index out of range")
447
+ return self.part.related_slide_master(sldMasterId.rId)
448
+
449
+ def __iter__(self):
450
+ """Generate each |SlideMaster| instance in the collection, in sequence."""
451
+ for smi in self._sldMasterIdLst.sldMasterId_lst:
452
+ yield self.part.related_slide_master(smi.rId)
453
+
454
+ def __len__(self):
455
+ """Support len() built-in function, e.g. `len(slide_masters) == 4`."""
456
+ return len(self._sldMasterIdLst)
457
+
458
+
459
+ class _Background(ElementProxy):
460
+ """Provides access to slide background properties.
461
+
462
+ Note that the presence of this object does not by itself imply an
463
+ explicitly-defined background; a slide with an inherited background still
464
+ has a |_Background| object.
465
+ """
466
+
467
+ def __init__(self, cSld: CT_CommonSlideData):
468
+ super(_Background, self).__init__(cSld)
469
+ self._cSld = cSld
470
+
471
+ @lazyproperty
472
+ def fill(self):
473
+ """|FillFormat| instance for this background.
474
+
475
+ This |FillFormat| object is used to interrogate or specify the fill
476
+ of the slide background.
477
+
478
+ Note that accessing this property is potentially destructive. A slide
479
+ background can also be specified by a background style reference and
480
+ accessing this property will remove that reference, if present, and
481
+ replace it with NoFill. This is frequently the case for a slide
482
+ master background.
483
+
484
+ This is also the case when there is no explicitly defined background
485
+ (background is inherited); merely accessing this property will cause
486
+ the background to be set to NoFill and the inheritance link will be
487
+ interrupted. This is frequently the case for a slide background.
488
+
489
+ Of course, if you are accessing this property in order to set the
490
+ fill, then these changes are of no consequence, but the existing
491
+ background cannot be reliably interrogated using this property unless
492
+ you have already established it is an explicit fill.
493
+
494
+ If the background is already a fill, then accessing this property
495
+ makes no changes to the current background.
496
+ """
497
+ bgPr = self._cSld.get_or_add_bgPr()
498
+ return FillFormat.from_fill_parent(bgPr)
tasks/tasksmith-74f059424102/environment/source/src/pptx/spec.py ADDED
@@ -0,0 +1,632 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Mappings from the ISO/IEC 29500 spec.
2
+
3
+ Some of these are inferred from PowerPoint application behavior
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import TYPE_CHECKING, TypedDict
9
+
10
+ from pptx.enum.shapes import MSO_SHAPE
11
+
12
+ GRAPHIC_DATA_URI_CHART = "http://schemas.openxmlformats.org/drawingml/2006/chart"
13
+ GRAPHIC_DATA_URI_OLEOBJ = "http://schemas.openxmlformats.org/presentationml/2006/ole"
14
+ GRAPHIC_DATA_URI_TABLE = "http://schemas.openxmlformats.org/drawingml/2006/table"
15
+
16
+ if TYPE_CHECKING:
17
+ from typing_extensions import TypeAlias
18
+
19
+ AdjustmentValue: TypeAlias = tuple[str, int]
20
+
21
+
22
+ class ShapeSpec(TypedDict):
23
+ basename: str
24
+ avLst: tuple[AdjustmentValue, ...]
25
+
26
+
27
+ # ============================================================================
28
+ # AutoShape type specs
29
+ # ============================================================================
30
+
31
+ autoshape_types: dict[MSO_SHAPE, ShapeSpec] = {
32
+ MSO_SHAPE.ACTION_BUTTON_BACK_OR_PREVIOUS: {
33
+ "basename": "Action Button: Back or Previous",
34
+ "avLst": (),
35
+ },
36
+ MSO_SHAPE.ACTION_BUTTON_BEGINNING: {
37
+ "basename": "Action Button: Beginning",
38
+ "avLst": (),
39
+ },
40
+ MSO_SHAPE.ACTION_BUTTON_CUSTOM: {"basename": "Action Button: Custom", "avLst": ()},
41
+ MSO_SHAPE.ACTION_BUTTON_DOCUMENT: {
42
+ "basename": "Action Button: Document",
43
+ "avLst": (),
44
+ },
45
+ MSO_SHAPE.ACTION_BUTTON_END: {"basename": "Action Button: End", "avLst": ()},
46
+ MSO_SHAPE.ACTION_BUTTON_FORWARD_OR_NEXT: {
47
+ "basename": "Action Button: Forward or Next",
48
+ "avLst": (),
49
+ },
50
+ MSO_SHAPE.ACTION_BUTTON_HELP: {"basename": "Action Button: Help", "avLst": ()},
51
+ MSO_SHAPE.ACTION_BUTTON_HOME: {"basename": "Action Button: Home", "avLst": ()},
52
+ MSO_SHAPE.ACTION_BUTTON_INFORMATION: {
53
+ "basename": "Action Button: Information",
54
+ "avLst": (),
55
+ },
56
+ MSO_SHAPE.ACTION_BUTTON_MOVIE: {"basename": "Action Button: Movie", "avLst": ()},
57
+ MSO_SHAPE.ACTION_BUTTON_RETURN: {"basename": "Action Button: Return", "avLst": ()},
58
+ MSO_SHAPE.ACTION_BUTTON_SOUND: {"basename": "Action Button: Sound", "avLst": ()},
59
+ MSO_SHAPE.ARC: {"basename": "Arc", "avLst": (("adj1", 16200000), ("adj2", 0))},
60
+ MSO_SHAPE.BALLOON: {
61
+ "basename": "Rounded Rectangular Callout",
62
+ "avLst": (("adj1", -20833), ("adj2", 62500), ("adj3", 16667)),
63
+ },
64
+ MSO_SHAPE.BENT_ARROW: {
65
+ "basename": "Bent Arrow",
66
+ "avLst": (("adj1", 25000), ("adj2", 25000), ("adj3", 25000), ("adj4", 43750)),
67
+ },
68
+ MSO_SHAPE.BENT_UP_ARROW: {
69
+ "basename": "Bent-Up Arrow",
70
+ "avLst": (("adj1", 25000), ("adj2", 25000), ("adj3", 25000)),
71
+ },
72
+ MSO_SHAPE.BEVEL: {"basename": "Bevel", "avLst": (("adj", 12500),)},
73
+ MSO_SHAPE.BLOCK_ARC: {
74
+ "basename": "Block Arc",
75
+ "avLst": (("adj1", 10800000), ("adj2", 0), ("adj3", 25000)),
76
+ },
77
+ MSO_SHAPE.CAN: {"basename": "Can", "avLst": (("adj", 25000),)},
78
+ MSO_SHAPE.CHART_PLUS: {"basename": "Chart Plus", "avLst": ()},
79
+ MSO_SHAPE.CHART_STAR: {"basename": "Chart Star", "avLst": ()},
80
+ MSO_SHAPE.CHART_X: {"basename": "Chart X", "avLst": ()},
81
+ MSO_SHAPE.CHEVRON: {"basename": "Chevron", "avLst": (("adj", 50000),)},
82
+ MSO_SHAPE.CHORD: {
83
+ "basename": "Chord",
84
+ "avLst": (("adj1", 2700000), ("adj2", 16200000)),
85
+ },
86
+ MSO_SHAPE.CIRCULAR_ARROW: {
87
+ "basename": "Circular Arrow",
88
+ "avLst": (
89
+ ("adj1", 12500),
90
+ ("adj2", 1142319),
91
+ ("adj3", 20457681),
92
+ ("adj4", 10800000),
93
+ ("adj5", 12500),
94
+ ),
95
+ },
96
+ MSO_SHAPE.CLOUD: {"basename": "Cloud", "avLst": ()},
97
+ MSO_SHAPE.CLOUD_CALLOUT: {
98
+ "basename": "Cloud Callout",
99
+ "avLst": (("adj1", -20833), ("adj2", 62500)),
100
+ },
101
+ MSO_SHAPE.CORNER: {
102
+ "basename": "Corner",
103
+ "avLst": (("adj1", 50000), ("adj2", 50000)),
104
+ },
105
+ MSO_SHAPE.CORNER_TABS: {"basename": "Corner Tabs", "avLst": ()},
106
+ MSO_SHAPE.CROSS: {"basename": "Cross", "avLst": (("adj", 25000),)},
107
+ MSO_SHAPE.CUBE: {"basename": "Cube", "avLst": (("adj", 25000),)},
108
+ MSO_SHAPE.CURVED_DOWN_ARROW: {
109
+ "basename": "Curved Down Arrow",
110
+ "avLst": (("adj1", 25000), ("adj2", 50000), ("adj3", 25000)),
111
+ },
112
+ MSO_SHAPE.CURVED_DOWN_RIBBON: {
113
+ "basename": "Curved Down Ribbon",
114
+ "avLst": (("adj1", 25000), ("adj2", 50000), ("adj3", 12500)),
115
+ },
116
+ MSO_SHAPE.CURVED_LEFT_ARROW: {
117
+ "basename": "Curved Left Arrow",
118
+ "avLst": (("adj1", 25000), ("adj2", 50000), ("adj3", 25000)),
119
+ },
120
+ MSO_SHAPE.CURVED_RIGHT_ARROW: {
121
+ "basename": "Curved Right Arrow",
122
+ "avLst": (("adj1", 25000), ("adj2", 50000), ("adj3", 25000)),
123
+ },
124
+ MSO_SHAPE.CURVED_UP_ARROW: {
125
+ "basename": "Curved Up Arrow",
126
+ "avLst": (("adj1", 25000), ("adj2", 50000), ("adj3", 25000)),
127
+ },
128
+ MSO_SHAPE.CURVED_UP_RIBBON: {
129
+ "basename": "Curved Up Ribbon",
130
+ "avLst": (("adj1", 25000), ("adj2", 50000), ("adj3", 12500)),
131
+ },
132
+ MSO_SHAPE.DECAGON: {"basename": "Decagon", "avLst": (("vf", 105146),)},
133
+ MSO_SHAPE.DIAGONAL_STRIPE: {
134
+ "basename": "Diagonal Stripe",
135
+ "avLst": (("adj", 50000),),
136
+ },
137
+ MSO_SHAPE.DIAMOND: {"basename": "Diamond", "avLst": ()},
138
+ MSO_SHAPE.DODECAGON: {"basename": "Dodecagon", "avLst": ()},
139
+ MSO_SHAPE.DONUT: {"basename": "Donut", "avLst": (("adj", 25000),)},
140
+ MSO_SHAPE.DOUBLE_BRACE: {"basename": "Double Brace", "avLst": (("adj", 8333),)},
141
+ MSO_SHAPE.DOUBLE_BRACKET: {
142
+ "basename": "Double Bracket",
143
+ "avLst": (("adj", 16667),),
144
+ },
145
+ MSO_SHAPE.DOUBLE_WAVE: {
146
+ "basename": "Double Wave",
147
+ "avLst": (("adj1", 6250), ("adj2", 0)),
148
+ },
149
+ MSO_SHAPE.DOWN_ARROW: {
150
+ "basename": "Down Arrow",
151
+ "avLst": (("adj1", 50000), ("adj2", 50000)),
152
+ },
153
+ MSO_SHAPE.DOWN_ARROW_CALLOUT: {
154
+ "basename": "Down Arrow Callout",
155
+ "avLst": (("adj1", 25000), ("adj2", 25000), ("adj3", 25000), ("adj4", 64977)),
156
+ },
157
+ MSO_SHAPE.DOWN_RIBBON: {
158
+ "basename": "Down Ribbon",
159
+ "avLst": (("adj1", 16667), ("adj2", 50000)),
160
+ },
161
+ MSO_SHAPE.EXPLOSION1: {"basename": "Explosion", "avLst": ()},
162
+ MSO_SHAPE.EXPLOSION2: {"basename": "Explosion", "avLst": ()},
163
+ MSO_SHAPE.FLOWCHART_ALTERNATE_PROCESS: {
164
+ "basename": "Alternate process",
165
+ "avLst": (),
166
+ },
167
+ MSO_SHAPE.FLOWCHART_CARD: {"basename": "Card", "avLst": ()},
168
+ MSO_SHAPE.FLOWCHART_COLLATE: {"basename": "Collate", "avLst": ()},
169
+ MSO_SHAPE.FLOWCHART_CONNECTOR: {"basename": "Connector", "avLst": ()},
170
+ MSO_SHAPE.FLOWCHART_DATA: {"basename": "Data", "avLst": ()},
171
+ MSO_SHAPE.FLOWCHART_DECISION: {"basename": "Decision", "avLst": ()},
172
+ MSO_SHAPE.FLOWCHART_DELAY: {"basename": "Delay", "avLst": ()},
173
+ MSO_SHAPE.FLOWCHART_DIRECT_ACCESS_STORAGE: {
174
+ "basename": "Direct Access Storage",
175
+ "avLst": (),
176
+ },
177
+ MSO_SHAPE.FLOWCHART_DISPLAY: {"basename": "Display", "avLst": ()},
178
+ MSO_SHAPE.FLOWCHART_DOCUMENT: {"basename": "Document", "avLst": ()},
179
+ MSO_SHAPE.FLOWCHART_EXTRACT: {"basename": "Extract", "avLst": ()},
180
+ MSO_SHAPE.FLOWCHART_INTERNAL_STORAGE: {"basename": "Internal Storage", "avLst": ()},
181
+ MSO_SHAPE.FLOWCHART_MAGNETIC_DISK: {"basename": "Magnetic Disk", "avLst": ()},
182
+ MSO_SHAPE.FLOWCHART_MANUAL_INPUT: {"basename": "Manual Input", "avLst": ()},
183
+ MSO_SHAPE.FLOWCHART_MANUAL_OPERATION: {"basename": "Manual Operation", "avLst": ()},
184
+ MSO_SHAPE.FLOWCHART_MERGE: {"basename": "Merge", "avLst": ()},
185
+ MSO_SHAPE.FLOWCHART_MULTIDOCUMENT: {"basename": "Multidocument", "avLst": ()},
186
+ MSO_SHAPE.FLOWCHART_OFFLINE_STORAGE: {"basename": "Offline Storage", "avLst": ()},
187
+ MSO_SHAPE.FLOWCHART_OFFPAGE_CONNECTOR: {
188
+ "basename": "Off-page Connector",
189
+ "avLst": (),
190
+ },
191
+ MSO_SHAPE.FLOWCHART_OR: {"basename": "Or", "avLst": ()},
192
+ MSO_SHAPE.FLOWCHART_PREDEFINED_PROCESS: {
193
+ "basename": "Predefined Process",
194
+ "avLst": (),
195
+ },
196
+ MSO_SHAPE.FLOWCHART_PREPARATION: {"basename": "Preparation", "avLst": ()},
197
+ MSO_SHAPE.FLOWCHART_PROCESS: {"basename": "Process", "avLst": ()},
198
+ MSO_SHAPE.FLOWCHART_PUNCHED_TAPE: {"basename": "Punched Tape", "avLst": ()},
199
+ MSO_SHAPE.FLOWCHART_SEQUENTIAL_ACCESS_STORAGE: {
200
+ "basename": "Sequential Access Storage",
201
+ "avLst": (),
202
+ },
203
+ MSO_SHAPE.FLOWCHART_SORT: {"basename": "Sort", "avLst": ()},
204
+ MSO_SHAPE.FLOWCHART_STORED_DATA: {"basename": "Stored Data", "avLst": ()},
205
+ MSO_SHAPE.FLOWCHART_SUMMING_JUNCTION: {"basename": "Summing Junction", "avLst": ()},
206
+ MSO_SHAPE.FLOWCHART_TERMINATOR: {"basename": "Terminator", "avLst": ()},
207
+ MSO_SHAPE.FOLDED_CORNER: {"basename": "Folded Corner", "avLst": ()},
208
+ MSO_SHAPE.FRAME: {"basename": "Frame", "avLst": (("adj1", 12500),)},
209
+ MSO_SHAPE.FUNNEL: {"basename": "Funnel", "avLst": ()},
210
+ MSO_SHAPE.GEAR_6: {
211
+ "basename": "Gear 6",
212
+ "avLst": (("adj1", 15000), ("adj2", 3526)),
213
+ },
214
+ MSO_SHAPE.GEAR_9: {
215
+ "basename": "Gear 9",
216
+ "avLst": (("adj1", 10000), ("adj2", 1763)),
217
+ },
218
+ MSO_SHAPE.HALF_FRAME: {
219
+ "basename": "Half Frame",
220
+ "avLst": (("adj1", 33333), ("adj2", 33333)),
221
+ },
222
+ MSO_SHAPE.HEART: {"basename": "Heart", "avLst": ()},
223
+ MSO_SHAPE.HEPTAGON: {
224
+ "basename": "Heptagon",
225
+ "avLst": (("hf", 102572), ("vf", 105210)),
226
+ },
227
+ MSO_SHAPE.HEXAGON: {
228
+ "basename": "Hexagon",
229
+ "avLst": (("adj", 25000), ("vf", 115470)),
230
+ },
231
+ MSO_SHAPE.HORIZONTAL_SCROLL: {
232
+ "basename": "Horizontal Scroll",
233
+ "avLst": (("adj", 12500),),
234
+ },
235
+ MSO_SHAPE.ISOSCELES_TRIANGLE: {
236
+ "basename": "Isosceles Triangle",
237
+ "avLst": (("adj", 50000),),
238
+ },
239
+ MSO_SHAPE.LEFT_ARROW: {
240
+ "basename": "Left Arrow",
241
+ "avLst": (("adj1", 50000), ("adj2", 50000)),
242
+ },
243
+ MSO_SHAPE.LEFT_ARROW_CALLOUT: {
244
+ "basename": "Left Arrow Callout",
245
+ "avLst": (("adj1", 25000), ("adj2", 25000), ("adj3", 25000), ("adj4", 64977)),
246
+ },
247
+ MSO_SHAPE.LEFT_BRACE: {
248
+ "basename": "Left Brace",
249
+ "avLst": (("adj1", 8333), ("adj2", 50000)),
250
+ },
251
+ MSO_SHAPE.LEFT_BRACKET: {"basename": "Left Bracket", "avLst": (("adj", 8333),)},
252
+ MSO_SHAPE.LEFT_CIRCULAR_ARROW: {
253
+ "basename": "Left Circular Arrow",
254
+ "avLst": (
255
+ ("adj1", 12500),
256
+ ("adj2", -1142319),
257
+ ("adj3", 1142319),
258
+ ("adj4", 10800000),
259
+ ("adj5", 12500),
260
+ ),
261
+ },
262
+ MSO_SHAPE.LEFT_RIGHT_ARROW: {
263
+ "basename": "Left-Right Arrow",
264
+ "avLst": (("adj1", 50000), ("adj2", 50000)),
265
+ },
266
+ MSO_SHAPE.LEFT_RIGHT_ARROW_CALLOUT: {
267
+ "basename": "Left-Right Arrow Callout",
268
+ "avLst": (("adj1", 25000), ("adj2", 25000), ("adj3", 25000), ("adj4", 48123)),
269
+ },
270
+ MSO_SHAPE.LEFT_RIGHT_CIRCULAR_ARROW: {
271
+ "basename": "Left Right Circular Arrow",
272
+ "avLst": (
273
+ ("adj1", 12500),
274
+ ("adj2", 1142319),
275
+ ("adj3", 20457681),
276
+ ("adj4", 11942319),
277
+ ("adj5", 12500),
278
+ ),
279
+ },
280
+ MSO_SHAPE.LEFT_RIGHT_RIBBON: {
281
+ "basename": "Left Right Ribbon",
282
+ "avLst": (("adj1", 50000), ("adj2", 50000), ("adj3", 16667)),
283
+ },
284
+ MSO_SHAPE.LEFT_RIGHT_UP_ARROW: {
285
+ "basename": "Left-Right-Up Arrow",
286
+ "avLst": (("adj1", 25000), ("adj2", 25000), ("adj3", 25000)),
287
+ },
288
+ MSO_SHAPE.LEFT_UP_ARROW: {
289
+ "basename": "Left-Up Arrow",
290
+ "avLst": (("adj1", 25000), ("adj2", 25000), ("adj3", 25000)),
291
+ },
292
+ MSO_SHAPE.LIGHTNING_BOLT: {"basename": "Lightning Bolt", "avLst": ()},
293
+ MSO_SHAPE.LINE_CALLOUT_1: {
294
+ "basename": "Line Callout 1",
295
+ "avLst": (("adj1", 18750), ("adj2", -8333), ("adj3", 112500), ("adj4", -38333)),
296
+ },
297
+ MSO_SHAPE.LINE_CALLOUT_1_ACCENT_BAR: {
298
+ "basename": "Line Callout 1 (Accent Bar)",
299
+ "avLst": (("adj1", 18750), ("adj2", -8333), ("adj3", 112500), ("adj4", -38333)),
300
+ },
301
+ MSO_SHAPE.LINE_CALLOUT_1_BORDER_AND_ACCENT_BAR: {
302
+ "basename": "Line Callout 1 (Border and Accent Bar)",
303
+ "avLst": (("adj1", 18750), ("adj2", -8333), ("adj3", 112500), ("adj4", -38333)),
304
+ },
305
+ MSO_SHAPE.LINE_CALLOUT_1_NO_BORDER: {
306
+ "basename": "Line Callout 1 (No Border)",
307
+ "avLst": (("adj1", 18750), ("adj2", -8333), ("adj3", 112500), ("adj4", -38333)),
308
+ },
309
+ MSO_SHAPE.LINE_CALLOUT_2: {
310
+ "basename": "Line Callout 2",
311
+ "avLst": (
312
+ ("adj1", 18750),
313
+ ("adj2", -8333),
314
+ ("adj3", 18750),
315
+ ("adj4", -16667),
316
+ ("adj5", 112500),
317
+ ("adj6", -46667),
318
+ ),
319
+ },
320
+ MSO_SHAPE.LINE_CALLOUT_2_ACCENT_BAR: {
321
+ "basename": "Line Callout 2 (Accent Bar)",
322
+ "avLst": (
323
+ ("adj1", 18750),
324
+ ("adj2", -8333),
325
+ ("adj3", 18750),
326
+ ("adj4", -16667),
327
+ ("adj5", 112500),
328
+ ("adj6", -46667),
329
+ ),
330
+ },
331
+ MSO_SHAPE.LINE_CALLOUT_2_BORDER_AND_ACCENT_BAR: {
332
+ "basename": "Line Callout 2 (Border and Accent Bar)",
333
+ "avLst": (
334
+ ("adj1", 18750),
335
+ ("adj2", -8333),
336
+ ("adj3", 18750),
337
+ ("adj4", -16667),
338
+ ("adj5", 112500),
339
+ ("adj6", -46667),
340
+ ),
341
+ },
342
+ MSO_SHAPE.LINE_CALLOUT_2_NO_BORDER: {
343
+ "basename": "Line Callout 2 (No Border)",
344
+ "avLst": (
345
+ ("adj1", 18750),
346
+ ("adj2", -8333),
347
+ ("adj3", 18750),
348
+ ("adj4", -16667),
349
+ ("adj5", 112500),
350
+ ("adj6", -46667),
351
+ ),
352
+ },
353
+ MSO_SHAPE.LINE_CALLOUT_3: {
354
+ "basename": "Line Callout 3",
355
+ "avLst": (
356
+ ("adj1", 18750),
357
+ ("adj2", -8333),
358
+ ("adj3", 18750),
359
+ ("adj4", -16667),
360
+ ("adj5", 100000),
361
+ ("adj6", -16667),
362
+ ("adj7", 112963),
363
+ ("adj8", -8333),
364
+ ),
365
+ },
366
+ MSO_SHAPE.LINE_CALLOUT_3_ACCENT_BAR: {
367
+ "basename": "Line Callout 3 (Accent Bar)",
368
+ "avLst": (
369
+ ("adj1", 18750),
370
+ ("adj2", -8333),
371
+ ("adj3", 18750),
372
+ ("adj4", -16667),
373
+ ("adj5", 100000),
374
+ ("adj6", -16667),
375
+ ("adj7", 112963),
376
+ ("adj8", -8333),
377
+ ),
378
+ },
379
+ MSO_SHAPE.LINE_CALLOUT_3_BORDER_AND_ACCENT_BAR: {
380
+ "basename": "Line Callout 3 (Border and Accent Bar)",
381
+ "avLst": (
382
+ ("adj1", 18750),
383
+ ("adj2", -8333),
384
+ ("adj3", 18750),
385
+ ("adj4", -16667),
386
+ ("adj5", 100000),
387
+ ("adj6", -16667),
388
+ ("adj7", 112963),
389
+ ("adj8", -8333),
390
+ ),
391
+ },
392
+ MSO_SHAPE.LINE_CALLOUT_3_NO_BORDER: {
393
+ "basename": "Line Callout 3 (No Border)",
394
+ "avLst": (
395
+ ("adj1", 18750),
396
+ ("adj2", -8333),
397
+ ("adj3", 18750),
398
+ ("adj4", -16667),
399
+ ("adj5", 100000),
400
+ ("adj6", -16667),
401
+ ("adj7", 112963),
402
+ ("adj8", -8333),
403
+ ),
404
+ },
405
+ MSO_SHAPE.LINE_CALLOUT_4: {
406
+ "basename": "Line Callout 3",
407
+ "avLst": (
408
+ ("adj1", 18750),
409
+ ("adj2", -8333),
410
+ ("adj3", 18750),
411
+ ("adj4", -16667),
412
+ ("adj5", 100000),
413
+ ("adj6", -16667),
414
+ ("adj7", 112963),
415
+ ("adj8", -8333),
416
+ ),
417
+ },
418
+ MSO_SHAPE.LINE_CALLOUT_4_ACCENT_BAR: {
419
+ "basename": "Line Callout 3 (Accent Bar)",
420
+ "avLst": (
421
+ ("adj1", 18750),
422
+ ("adj2", -8333),
423
+ ("adj3", 18750),
424
+ ("adj4", -16667),
425
+ ("adj5", 100000),
426
+ ("adj6", -16667),
427
+ ("adj7", 112963),
428
+ ("adj8", -8333),
429
+ ),
430
+ },
431
+ MSO_SHAPE.LINE_CALLOUT_4_BORDER_AND_ACCENT_BAR: {
432
+ "basename": "Line Callout 3 (Border and Accent Bar)",
433
+ "avLst": (
434
+ ("adj1", 18750),
435
+ ("adj2", -8333),
436
+ ("adj3", 18750),
437
+ ("adj4", -16667),
438
+ ("adj5", 100000),
439
+ ("adj6", -16667),
440
+ ("adj7", 112963),
441
+ ("adj8", -8333),
442
+ ),
443
+ },
444
+ MSO_SHAPE.LINE_CALLOUT_4_NO_BORDER: {
445
+ "basename": "Line Callout 3 (No Border)",
446
+ "avLst": (
447
+ ("adj1", 18750),
448
+ ("adj2", -8333),
449
+ ("adj3", 18750),
450
+ ("adj4", -16667),
451
+ ("adj5", 100000),
452
+ ("adj6", -16667),
453
+ ("adj7", 112963),
454
+ ("adj8", -8333),
455
+ ),
456
+ },
457
+ MSO_SHAPE.LINE_INVERSE: {"basename": "Straight Connector", "avLst": ()},
458
+ MSO_SHAPE.MATH_DIVIDE: {
459
+ "basename": "Division",
460
+ "avLst": (("adj1", 23520), ("adj2", 5880), ("adj3", 11760)),
461
+ },
462
+ MSO_SHAPE.MATH_EQUAL: {
463
+ "basename": "Equal",
464
+ "avLst": (("adj1", 23520), ("adj2", 11760)),
465
+ },
466
+ MSO_SHAPE.MATH_MINUS: {"basename": "Minus", "avLst": (("adj1", 23520),)},
467
+ MSO_SHAPE.MATH_MULTIPLY: {"basename": "Multiply", "avLst": (("adj1", 23520),)},
468
+ MSO_SHAPE.MATH_NOT_EQUAL: {
469
+ "basename": "Not Equal",
470
+ "avLst": (("adj1", 23520), ("adj2", 6600000), ("adj3", 11760)),
471
+ },
472
+ MSO_SHAPE.MATH_PLUS: {"basename": "Plus", "avLst": (("adj1", 23520),)},
473
+ MSO_SHAPE.MOON: {"basename": "Moon", "avLst": (("adj", 50000),)},
474
+ MSO_SHAPE.NON_ISOSCELES_TRAPEZOID: {
475
+ "basename": "Non-isosceles Trapezoid",
476
+ "avLst": (("adj1", 25000), ("adj2", 25000)),
477
+ },
478
+ MSO_SHAPE.NOTCHED_RIGHT_ARROW: {
479
+ "basename": "Notched Right Arrow",
480
+ "avLst": (("adj1", 50000), ("adj2", 50000)),
481
+ },
482
+ MSO_SHAPE.NO_SYMBOL: {"basename": '"No" Symbol', "avLst": (("adj", 18750),)},
483
+ MSO_SHAPE.OCTAGON: {"basename": "Octagon", "avLst": (("adj", 29289),)},
484
+ MSO_SHAPE.OVAL: {"basename": "Oval", "avLst": ()},
485
+ MSO_SHAPE.OVAL_CALLOUT: {
486
+ "basename": "Oval Callout",
487
+ "avLst": (("adj1", -20833), ("adj2", 62500)),
488
+ },
489
+ MSO_SHAPE.PARALLELOGRAM: {"basename": "Parallelogram", "avLst": (("adj", 25000),)},
490
+ MSO_SHAPE.PENTAGON: {"basename": "Pentagon", "avLst": (("adj", 50000),)},
491
+ MSO_SHAPE.PIE: {"basename": "Pie", "avLst": (("adj1", 0), ("adj2", 16200000))},
492
+ MSO_SHAPE.PIE_WEDGE: {"basename": "Pie", "avLst": ()},
493
+ MSO_SHAPE.PLAQUE: {"basename": "Plaque", "avLst": (("adj", 16667),)},
494
+ MSO_SHAPE.PLAQUE_TABS: {"basename": "Plaque Tabs", "avLst": ()},
495
+ MSO_SHAPE.QUAD_ARROW: {
496
+ "basename": "Quad Arrow",
497
+ "avLst": (("adj1", 22500), ("adj2", 22500), ("adj3", 22500)),
498
+ },
499
+ MSO_SHAPE.QUAD_ARROW_CALLOUT: {
500
+ "basename": "Quad Arrow Callout",
501
+ "avLst": (("adj1", 18515), ("adj2", 18515), ("adj3", 18515), ("adj4", 48123)),
502
+ },
503
+ MSO_SHAPE.RECTANGLE: {"basename": "Rectangle", "avLst": ()},
504
+ MSO_SHAPE.RECTANGULAR_CALLOUT: {
505
+ "basename": "Rectangular Callout",
506
+ "avLst": (("adj1", -20833), ("adj2", 62500)),
507
+ },
508
+ MSO_SHAPE.REGULAR_PENTAGON: {
509
+ "basename": "Regular Pentagon",
510
+ "avLst": (("hf", 105146), ("vf", 110557)),
511
+ },
512
+ MSO_SHAPE.RIGHT_ARROW: {
513
+ "basename": "Right Arrow",
514
+ "avLst": (("adj1", 50000), ("adj2", 50000)),
515
+ },
516
+ MSO_SHAPE.RIGHT_ARROW_CALLOUT: {
517
+ "basename": "Right Arrow Callout",
518
+ "avLst": (("adj1", 25000), ("adj2", 25000), ("adj3", 25000), ("adj4", 64977)),
519
+ },
520
+ MSO_SHAPE.RIGHT_BRACE: {
521
+ "basename": "Right Brace",
522
+ "avLst": (("adj1", 8333), ("adj2", 50000)),
523
+ },
524
+ MSO_SHAPE.RIGHT_BRACKET: {"basename": "Right Bracket", "avLst": (("adj", 8333),)},
525
+ MSO_SHAPE.RIGHT_TRIANGLE: {"basename": "Right Triangle", "avLst": ()},
526
+ MSO_SHAPE.ROUNDED_RECTANGLE: {
527
+ "basename": "Rounded Rectangle",
528
+ "avLst": (("adj", 16667),),
529
+ },
530
+ MSO_SHAPE.ROUNDED_RECTANGULAR_CALLOUT: {
531
+ "basename": "Rounded Rectangular Callout",
532
+ "avLst": (("adj1", -20833), ("adj2", 62500), ("adj3", 16667)),
533
+ },
534
+ MSO_SHAPE.ROUND_1_RECTANGLE: {
535
+ "basename": "Round Single Corner Rectangle",
536
+ "avLst": (("adj", 16667),),
537
+ },
538
+ MSO_SHAPE.ROUND_2_DIAG_RECTANGLE: {
539
+ "basename": "Round Diagonal Corner Rectangle",
540
+ "avLst": (("adj1", 16667), ("adj2", 0)),
541
+ },
542
+ MSO_SHAPE.ROUND_2_SAME_RECTANGLE: {
543
+ "basename": "Round Same Side Corner Rectangle",
544
+ "avLst": (("adj1", 16667), ("adj2", 0)),
545
+ },
546
+ MSO_SHAPE.SMILEY_FACE: {"basename": "Smiley Face", "avLst": (("adj", 4653),)},
547
+ MSO_SHAPE.SNIP_1_RECTANGLE: {
548
+ "basename": "Snip Single Corner Rectangle",
549
+ "avLst": (("adj", 16667),),
550
+ },
551
+ MSO_SHAPE.SNIP_2_DIAG_RECTANGLE: {
552
+ "basename": "Snip Diagonal Corner Rectangle",
553
+ "avLst": (("adj1", 0), ("adj2", 16667)),
554
+ },
555
+ MSO_SHAPE.SNIP_2_SAME_RECTANGLE: {
556
+ "basename": "Snip Same Side Corner Rectangle",
557
+ "avLst": (("adj1", 16667), ("adj2", 0)),
558
+ },
559
+ MSO_SHAPE.SNIP_ROUND_RECTANGLE: {
560
+ "basename": "Snip and Round Single Corner Rectangle",
561
+ "avLst": (("adj1", 16667), ("adj2", 16667)),
562
+ },
563
+ MSO_SHAPE.SQUARE_TABS: {"basename": "Square Tabs", "avLst": ()},
564
+ MSO_SHAPE.STAR_10_POINT: {
565
+ "basename": "10-Point Star",
566
+ "avLst": (("adj", 42533), ("hf", 105146)),
567
+ },
568
+ MSO_SHAPE.STAR_12_POINT: {"basename": "12-Point Star", "avLst": (("adj", 37500),)},
569
+ MSO_SHAPE.STAR_16_POINT: {"basename": "16-Point Star", "avLst": (("adj", 37500),)},
570
+ MSO_SHAPE.STAR_24_POINT: {"basename": "24-Point Star", "avLst": (("adj", 37500),)},
571
+ MSO_SHAPE.STAR_32_POINT: {"basename": "32-Point Star", "avLst": (("adj", 37500),)},
572
+ MSO_SHAPE.STAR_4_POINT: {"basename": "4-Point Star", "avLst": (("adj", 12500),)},
573
+ MSO_SHAPE.STAR_5_POINT: {
574
+ "basename": "5-Point Star",
575
+ "avLst": (("adj", 19098), ("hf", 105146), ("vf", 110557)),
576
+ },
577
+ MSO_SHAPE.STAR_6_POINT: {
578
+ "basename": "6-Point Star",
579
+ "avLst": (("adj", 28868), ("hf", 115470)),
580
+ },
581
+ MSO_SHAPE.STAR_7_POINT: {
582
+ "basename": "7-Point Star",
583
+ "avLst": (("adj", 34601), ("hf", 102572), ("vf", 105210)),
584
+ },
585
+ MSO_SHAPE.STAR_8_POINT: {"basename": "8-Point Star", "avLst": (("adj", 37500),)},
586
+ MSO_SHAPE.STRIPED_RIGHT_ARROW: {
587
+ "basename": "Striped Right Arrow",
588
+ "avLst": (("adj1", 50000), ("adj2", 50000)),
589
+ },
590
+ MSO_SHAPE.SUN: {"basename": "Sun", "avLst": (("adj", 25000),)},
591
+ MSO_SHAPE.SWOOSH_ARROW: {
592
+ "basename": "Swoosh Arrow",
593
+ "avLst": (("adj1", 25000), ("adj2", 16667)),
594
+ },
595
+ MSO_SHAPE.TEAR: {"basename": "Teardrop", "avLst": (("adj", 100000),)},
596
+ MSO_SHAPE.TRAPEZOID: {"basename": "Trapezoid", "avLst": (("adj", 25000),)},
597
+ MSO_SHAPE.UP_ARROW: {
598
+ "basename": "Up Arrow",
599
+ "avLst": (("adj1", 50000), ("adj2", 50000)),
600
+ },
601
+ MSO_SHAPE.UP_ARROW_CALLOUT: {
602
+ "basename": "Up Arrow Callout",
603
+ "avLst": (("adj1", 25000), ("adj2", 25000), ("adj3", 25000), ("adj4", 64977)),
604
+ },
605
+ MSO_SHAPE.UP_DOWN_ARROW: {
606
+ "basename": "Up-Down Arrow",
607
+ "avLst": (("adj1", 50000), ("adj1", 50000), ("adj2", 50000), ("adj2", 50000)),
608
+ },
609
+ MSO_SHAPE.UP_DOWN_ARROW_CALLOUT: {
610
+ "basename": "Up-Down Arrow Callout",
611
+ "avLst": (("adj1", 25000), ("adj2", 25000), ("adj3", 25000), ("adj4", 48123)),
612
+ },
613
+ MSO_SHAPE.UP_RIBBON: {
614
+ "basename": "Up Ribbon",
615
+ "avLst": (("adj1", 16667), ("adj2", 50000)),
616
+ },
617
+ MSO_SHAPE.U_TURN_ARROW: {
618
+ "basename": "U-Turn Arrow",
619
+ "avLst": (
620
+ ("adj1", 25000),
621
+ ("adj2", 25000),
622
+ ("adj3", 25000),
623
+ ("adj4", 43750),
624
+ ("adj5", 75000),
625
+ ),
626
+ },
627
+ MSO_SHAPE.VERTICAL_SCROLL: {
628
+ "basename": "Vertical Scroll",
629
+ "avLst": (("adj", 12500),),
630
+ },
631
+ MSO_SHAPE.WAVE: {"basename": "Wave", "avLst": (("adj1", 12500), ("adj2", 0))},
632
+ }
tasks/tasksmith-74f059424102/environment/source/src/pptx/table.py ADDED
@@ -0,0 +1,496 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Table-related objects such as Table and Cell."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Iterator
6
+
7
+ from pptx.dml.fill import FillFormat
8
+ from pptx.oxml.table import TcRange
9
+ from pptx.shapes import Subshape
10
+ from pptx.text.text import TextFrame
11
+ from pptx.util import Emu, lazyproperty
12
+
13
+ if TYPE_CHECKING:
14
+ from pptx.enum.text import MSO_VERTICAL_ANCHOR
15
+ from pptx.oxml.table import CT_Table, CT_TableCell, CT_TableCol, CT_TableRow
16
+ from pptx.parts.slide import BaseSlidePart
17
+ from pptx.shapes.graphfrm import GraphicFrame
18
+ from pptx.types import ProvidesPart
19
+ from pptx.util import Length
20
+
21
+
22
+ class Table(object):
23
+ """A DrawingML table object.
24
+
25
+ Not intended to be constructed directly, use
26
+ :meth:`.Slide.shapes.add_table` to add a table to a slide.
27
+ """
28
+
29
+ def __init__(self, tbl: CT_Table, graphic_frame: GraphicFrame):
30
+ super(Table, self).__init__()
31
+ self._tbl = tbl
32
+ self._graphic_frame = graphic_frame
33
+
34
+ def cell(self, row_idx: int, col_idx: int) -> _Cell:
35
+ """Return cell at `row_idx`, `col_idx`.
36
+
37
+ Return value is an instance of |_Cell|. `row_idx` and `col_idx` are zero-based, e.g.
38
+ cell(0, 0) is the top, left cell in the table.
39
+ """
40
+ return _Cell(self._tbl.tc(row_idx, col_idx), self)
41
+
42
+ @lazyproperty
43
+ def columns(self) -> _ColumnCollection:
44
+ """|_ColumnCollection| instance for this table.
45
+
46
+ Provides access to |_Column| objects representing the table's columns. |_Column| objects
47
+ are accessed using list notation, e.g. `col = tbl.columns[0]`.
48
+ """
49
+ return _ColumnCollection(self._tbl, self)
50
+
51
+ @property
52
+ def first_col(self) -> bool:
53
+ """When `True`, indicates first column should have distinct formatting.
54
+
55
+ Read/write. Distinct formatting is used, for example, when the first column contains row
56
+ headings (is a side-heading column).
57
+ """
58
+ return self._tbl.firstCol
59
+
60
+ @first_col.setter
61
+ def first_col(self, value: bool):
62
+ self._tbl.firstCol = value
63
+
64
+ @property
65
+ def first_row(self) -> bool:
66
+ """When `True`, indicates first row should have distinct formatting.
67
+
68
+ Read/write. Distinct formatting is used, for example, when the first row contains column
69
+ headings.
70
+ """
71
+ return self._tbl.firstRow
72
+
73
+ @first_row.setter
74
+ def first_row(self, value: bool):
75
+ self._tbl.firstRow = value
76
+
77
+ @property
78
+ def horz_banding(self) -> bool:
79
+ """When `True`, indicates rows should have alternating shading.
80
+
81
+ Read/write. Used to allow rows to be traversed more easily without losing track of which
82
+ row is being read.
83
+ """
84
+ return self._tbl.bandRow
85
+
86
+ @horz_banding.setter
87
+ def horz_banding(self, value: bool):
88
+ self._tbl.bandRow = value
89
+
90
+ def iter_cells(self) -> Iterator[_Cell]:
91
+ """Generate _Cell object for each cell in this table.
92
+
93
+ Each grid cell is generated in left-to-right, top-to-bottom order.
94
+ """
95
+ return (_Cell(tc, self) for tc in self._tbl.iter_tcs())
96
+
97
+ @property
98
+ def last_col(self) -> bool:
99
+ """When `True`, indicates the rightmost column should have distinct formatting.
100
+
101
+ Read/write. Used, for example, when a row totals column appears at the far right of the
102
+ table.
103
+ """
104
+ return self._tbl.lastCol
105
+
106
+ @last_col.setter
107
+ def last_col(self, value: bool):
108
+ self._tbl.lastCol = value
109
+
110
+ @property
111
+ def last_row(self) -> bool:
112
+ """When `True`, indicates the bottom row should have distinct formatting.
113
+
114
+ Read/write. Used, for example, when a totals row appears as the bottom row.
115
+ """
116
+ return self._tbl.lastRow
117
+
118
+ @last_row.setter
119
+ def last_row(self, value: bool):
120
+ self._tbl.lastRow = value
121
+
122
+ def notify_height_changed(self) -> None:
123
+ """Called by a row when its height changes.
124
+
125
+ Triggers the graphic frame to recalculate its total height (as the sum of the row
126
+ heights).
127
+ """
128
+ new_table_height = Emu(sum([row.height for row in self.rows]))
129
+ self._graphic_frame.height = new_table_height
130
+
131
+ def notify_width_changed(self) -> None:
132
+ """Called by a column when its width changes.
133
+
134
+ Triggers the graphic frame to recalculate its total width (as the sum of the column
135
+ widths).
136
+ """
137
+ new_table_width = Emu(sum([col.width for col in self.columns]))
138
+ self._graphic_frame.width = new_table_width
139
+
140
+ @property
141
+ def part(self) -> BaseSlidePart:
142
+ """The package part containing this table."""
143
+ return self._graphic_frame.part
144
+
145
+ @lazyproperty
146
+ def rows(self):
147
+ """|_RowCollection| instance for this table.
148
+
149
+ Provides access to |_Row| objects representing the table's rows. |_Row| objects are
150
+ accessed using list notation, e.g. `col = tbl.rows[0]`.
151
+ """
152
+ return _RowCollection(self._tbl, self)
153
+
154
+ @property
155
+ def vert_banding(self) -> bool:
156
+ """When `True`, indicates columns should have alternating shading.
157
+
158
+ Read/write. Used to allow columns to be traversed more easily without losing track of
159
+ which column is being read.
160
+ """
161
+ return self._tbl.bandCol
162
+
163
+ @vert_banding.setter
164
+ def vert_banding(self, value: bool):
165
+ self._tbl.bandCol = value
166
+
167
+
168
+ class _Cell(Subshape):
169
+ """Table cell"""
170
+
171
+ def __init__(self, tc: CT_TableCell, parent: ProvidesPart):
172
+ super(_Cell, self).__init__(parent)
173
+ self._tc = tc
174
+
175
+ def __eq__(self, other: object) -> bool:
176
+ """|True| if this object proxies the same element as `other`.
177
+
178
+ Equality for proxy objects is defined as referring to the same XML element, whether or not
179
+ they are the same proxy object instance.
180
+ """
181
+ if not isinstance(other, type(self)):
182
+ return False
183
+ return self._tc is other._tc
184
+
185
+ def __ne__(self, other: object) -> bool:
186
+ if not isinstance(other, type(self)):
187
+ return True
188
+ return self._tc is not other._tc
189
+
190
+ @lazyproperty
191
+ def fill(self) -> FillFormat:
192
+ """|FillFormat| instance for this cell.
193
+
194
+ Provides access to fill properties such as foreground color.
195
+ """
196
+ tcPr = self._tc.get_or_add_tcPr()
197
+ return FillFormat.from_fill_parent(tcPr)
198
+
199
+ @property
200
+ def is_merge_origin(self) -> bool:
201
+ """True if this cell is the top-left grid cell in a merged cell."""
202
+ return self._tc.is_merge_origin
203
+
204
+ @property
205
+ def is_spanned(self) -> bool:
206
+ """True if this cell is spanned by a merge-origin cell.
207
+
208
+ A merge-origin cell "spans" the other grid cells in its merge range, consuming their area
209
+ and "shadowing" the spanned grid cells.
210
+
211
+ Note this value is |False| for a merge-origin cell. A merge-origin cell spans other grid
212
+ cells, but is not itself a spanned cell.
213
+ """
214
+ return self._tc.is_spanned
215
+
216
+ @property
217
+ def margin_left(self) -> Length:
218
+ """Left margin of cells.
219
+
220
+ Read/write. If assigned |None|, the default value is used, 0.1 inches for left and right
221
+ margins and 0.05 inches for top and bottom.
222
+ """
223
+ return self._tc.marL
224
+
225
+ @margin_left.setter
226
+ def margin_left(self, margin_left: Length | None):
227
+ self._validate_margin_value(margin_left)
228
+ self._tc.marL = margin_left
229
+
230
+ @property
231
+ def margin_right(self) -> Length:
232
+ """Right margin of cell."""
233
+ return self._tc.marR
234
+
235
+ @margin_right.setter
236
+ def margin_right(self, margin_right: Length | None):
237
+ self._validate_margin_value(margin_right)
238
+ self._tc.marR = margin_right
239
+
240
+ @property
241
+ def margin_top(self) -> Length:
242
+ """Top margin of cell."""
243
+ return self._tc.marT
244
+
245
+ @margin_top.setter
246
+ def margin_top(self, margin_top: Length | None):
247
+ self._validate_margin_value(margin_top)
248
+ self._tc.marT = margin_top
249
+
250
+ @property
251
+ def margin_bottom(self) -> Length:
252
+ """Bottom margin of cell."""
253
+ return self._tc.marB
254
+
255
+ @margin_bottom.setter
256
+ def margin_bottom(self, margin_bottom: Length | None):
257
+ self._validate_margin_value(margin_bottom)
258
+ self._tc.marB = margin_bottom
259
+
260
+ def merge(self, other_cell: _Cell) -> None:
261
+ """Create merged cell from this cell to `other_cell`.
262
+
263
+ This cell and `other_cell` specify opposite corners of the merged cell range. Either
264
+ diagonal of the cell region may be specified in either order, e.g. self=bottom-right,
265
+ other_cell=top-left, etc.
266
+
267
+ Raises |ValueError| if the specified range already contains merged cells anywhere within
268
+ its extents or if `other_cell` is not in the same table as `self`.
269
+ """
270
+ tc_range = TcRange(self._tc, other_cell._tc)
271
+
272
+ if not tc_range.in_same_table:
273
+ raise ValueError("other_cell from different table")
274
+ if tc_range.contains_merged_cell:
275
+ raise ValueError("range contains one or more merged cells")
276
+
277
+ tc_range.move_content_to_origin()
278
+
279
+ row_count, col_count = tc_range.dimensions
280
+
281
+ for tc in tc_range.iter_top_row_tcs():
282
+ tc.rowSpan = row_count
283
+ for tc in tc_range.iter_left_col_tcs():
284
+ tc.gridSpan = col_count
285
+ for tc in tc_range.iter_except_left_col_tcs():
286
+ tc.hMerge = True
287
+ for tc in tc_range.iter_except_top_row_tcs():
288
+ tc.vMerge = True
289
+
290
+ @property
291
+ def span_height(self) -> int:
292
+ """int count of rows spanned by this cell.
293
+
294
+ The value of this property may be misleading (often 1) on cells where `.is_merge_origin`
295
+ is not |True|, since only a merge-origin cell contains complete span information. This
296
+ property is only intended for use on cells known to be a merge origin by testing
297
+ `.is_merge_origin`.
298
+ """
299
+ return self._tc.rowSpan
300
+
301
+ @property
302
+ def span_width(self) -> int:
303
+ """int count of columns spanned by this cell.
304
+
305
+ The value of this property may be misleading (often 1) on cells where `.is_merge_origin`
306
+ is not |True|, since only a merge-origin cell contains complete span information. This
307
+ property is only intended for use on cells known to be a merge origin by testing
308
+ `.is_merge_origin`.
309
+ """
310
+ return self._tc.gridSpan
311
+
312
+ def split(self) -> None:
313
+ """Remove merge from this (merge-origin) cell.
314
+
315
+ The merged cell represented by this object will be "unmerged", yielding a separate
316
+ unmerged cell for each grid cell previously spanned by this merge.
317
+
318
+ Raises |ValueError| when this cell is not a merge-origin cell. Test with
319
+ `.is_merge_origin` before calling.
320
+ """
321
+ if not self.is_merge_origin:
322
+ raise ValueError("not a merge-origin cell; only a merge-origin cell can be sp" "lit")
323
+
324
+ tc_range = TcRange.from_merge_origin(self._tc)
325
+
326
+ for tc in tc_range.iter_tcs():
327
+ tc.rowSpan = tc.gridSpan = 1
328
+ tc.hMerge = tc.vMerge = False
329
+
330
+ @property
331
+ def text(self) -> str:
332
+ """Textual content of cell as a single string.
333
+
334
+ The returned string will contain a newline character (`"\\n"`) separating each paragraph
335
+ and a vertical-tab (`"\\v"`) character for each line break (soft carriage return) in the
336
+ cell's text.
337
+
338
+ Assignment to `text` replaces all text currently contained in the cell. A newline
339
+ character (`"\\n"`) in the assigned text causes a new paragraph to be started. A
340
+ vertical-tab (`"\\v"`) character in the assigned text causes a line-break (soft
341
+ carriage-return) to be inserted. (The vertical-tab character appears in clipboard text
342
+ copied from PowerPoint as its encoding of line-breaks.)
343
+ """
344
+ return self.text_frame.text
345
+
346
+ @text.setter
347
+ def text(self, text: str):
348
+ self.text_frame.text = text
349
+
350
+ @property
351
+ def text_frame(self) -> TextFrame:
352
+ """|TextFrame| containing the text that appears in the cell."""
353
+ txBody = self._tc.get_or_add_txBody()
354
+ return TextFrame(txBody, self)
355
+
356
+ @property
357
+ def vertical_anchor(self) -> MSO_VERTICAL_ANCHOR | None:
358
+ """Vertical alignment of this cell.
359
+
360
+ This value is a member of the :ref:`MsoVerticalAnchor` enumeration or |None|. A value of
361
+ |None| indicates the cell has no explicitly applied vertical anchor setting and its
362
+ effective value is inherited from its style-hierarchy ancestors.
363
+
364
+ Assigning |None| to this property causes any explicitly applied vertical anchor setting to
365
+ be cleared and inheritance of its effective value to be restored.
366
+ """
367
+ return self._tc.anchor
368
+
369
+ @vertical_anchor.setter
370
+ def vertical_anchor(self, mso_anchor_idx: MSO_VERTICAL_ANCHOR | None):
371
+ self._tc.anchor = mso_anchor_idx
372
+
373
+ @staticmethod
374
+ def _validate_margin_value(margin_value: Length | None) -> None:
375
+ """Raise ValueError if `margin_value` is not a positive integer value or |None|."""
376
+ if not isinstance(margin_value, int) and margin_value is not None:
377
+ tmpl = "margin value must be integer or None, got '%s'"
378
+ raise TypeError(tmpl % margin_value)
379
+
380
+
381
+ class _Column(Subshape):
382
+ """Table column"""
383
+
384
+ def __init__(self, gridCol: CT_TableCol, parent: _ColumnCollection):
385
+ super(_Column, self).__init__(parent)
386
+ self._parent = parent
387
+ self._gridCol = gridCol
388
+
389
+ @property
390
+ def width(self) -> Length:
391
+ """Width of column in EMU."""
392
+ return self._gridCol.w
393
+
394
+ @width.setter
395
+ def width(self, width: Length):
396
+ self._gridCol.w = width
397
+ self._parent.notify_width_changed()
398
+
399
+
400
+ class _Row(Subshape):
401
+ """Table row"""
402
+
403
+ def __init__(self, tr: CT_TableRow, parent: _RowCollection):
404
+ super(_Row, self).__init__(parent)
405
+ self._parent = parent
406
+ self._tr = tr
407
+
408
+ @property
409
+ def cells(self):
410
+ """Read-only reference to collection of cells in row.
411
+
412
+ An individual cell is referenced using list notation, e.g. `cell = row.cells[0]`.
413
+ """
414
+ return _CellCollection(self._tr, self)
415
+
416
+ @property
417
+ def height(self) -> Length:
418
+ """Height of row in EMU."""
419
+ return self._tr.h
420
+
421
+ @height.setter
422
+ def height(self, height: Length):
423
+ self._tr.h = height
424
+ self._parent.notify_height_changed()
425
+
426
+
427
+ class _CellCollection(Subshape):
428
+ """Horizontal sequence of row cells"""
429
+
430
+ def __init__(self, tr: CT_TableRow, parent: _Row):
431
+ super(_CellCollection, self).__init__(parent)
432
+ self._parent = parent
433
+ self._tr = tr
434
+
435
+ def __getitem__(self, idx: int) -> _Cell:
436
+ """Provides indexed access, (e.g. 'cells[0]')."""
437
+ if idx < 0 or idx >= len(self._tr.tc_lst):
438
+ msg = "cell index [%d] out of range" % idx
439
+ raise IndexError(msg)
440
+ return _Cell(self._tr.tc_lst[idx], self)
441
+
442
+ def __iter__(self) -> Iterator[_Cell]:
443
+ """Provides iterability."""
444
+ return (_Cell(tc, self) for tc in self._tr.tc_lst)
445
+
446
+ def __len__(self) -> int:
447
+ """Supports len() function (e.g. 'len(cells) == 1')."""
448
+ return len(self._tr.tc_lst)
449
+
450
+
451
+ class _ColumnCollection(Subshape):
452
+ """Sequence of table columns."""
453
+
454
+ def __init__(self, tbl: CT_Table, parent: Table):
455
+ super(_ColumnCollection, self).__init__(parent)
456
+ self._parent = parent
457
+ self._tbl = tbl
458
+
459
+ def __getitem__(self, idx: int):
460
+ """Provides indexed access, (e.g. 'columns[0]')."""
461
+ if idx < 0 or idx >= len(self._tbl.tblGrid.gridCol_lst):
462
+ msg = "column index [%d] out of range" % idx
463
+ raise IndexError(msg)
464
+ return _Column(self._tbl.tblGrid.gridCol_lst[idx], self)
465
+
466
+ def __len__(self):
467
+ """Supports len() function (e.g. 'len(columns) == 1')."""
468
+ return len(self._tbl.tblGrid.gridCol_lst)
469
+
470
+ def notify_width_changed(self):
471
+ """Called by a column when its width changes. Pass along to parent."""
472
+ self._parent.notify_width_changed()
473
+
474
+
475
+ class _RowCollection(Subshape):
476
+ """Sequence of table rows"""
477
+
478
+ def __init__(self, tbl: CT_Table, parent: Table):
479
+ super(_RowCollection, self).__init__(parent)
480
+ self._parent = parent
481
+ self._tbl = tbl
482
+
483
+ def __getitem__(self, idx: int) -> _Row:
484
+ """Provides indexed access, (e.g. 'rows[0]')."""
485
+ if idx < 0 or idx >= len(self):
486
+ msg = "row index [%d] out of range" % idx
487
+ raise IndexError(msg)
488
+ return _Row(self._tbl.tr_lst[idx], self)
489
+
490
+ def __len__(self):
491
+ """Supports len() function (e.g. 'len(rows) == 1')."""
492
+ return len(self._tbl.tr_lst)
493
+
494
+ def notify_height_changed(self):
495
+ """Called by a row when its height changes. Pass along to parent."""
496
+ self._parent.notify_height_changed()
tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/default.pptx ADDED
Binary file (34 kB). View file
 
tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/docx-icon.emf ADDED

Git LFS Details

  • SHA256: cbfa051aa5f1ec1993f0ce056f67112ce4af3a8c3ac6fccfc219399ed6dc625d
  • Pointer size: 131 Bytes
  • Size of remote file: 127 kB
tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/generic-icon.emf ADDED
tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/notes.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
2
+ <p:notes xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
3
+ <p:cSld>
4
+ <p:spTree>
5
+ <p:nvGrpSpPr>
6
+ <p:cNvPr id="1" name=""/>
7
+ <p:cNvGrpSpPr/>
8
+ <p:nvPr/>
9
+ </p:nvGrpSpPr>
10
+ <p:grpSpPr>
11
+ <a:xfrm>
12
+ <a:off x="0" y="0"/>
13
+ <a:ext cx="0" cy="0"/>
14
+ <a:chOff x="0" y="0"/>
15
+ <a:chExt cx="0" cy="0"/>
16
+ </a:xfrm>
17
+ </p:grpSpPr>
18
+ </p:spTree>
19
+ </p:cSld>
20
+ <p:clrMapOvr>
21
+ <a:masterClrMapping/>
22
+ </p:clrMapOvr>
23
+ </p:notes>
tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/notesMaster.xml ADDED
@@ -0,0 +1,352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
2
+ <p:notesMaster
3
+ xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
4
+ xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"
5
+ xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
6
+ >
7
+ <p:cSld>
8
+ <p:bg>
9
+ <p:bgRef idx="1001">
10
+ <a:schemeClr val="bg1"/>
11
+ </p:bgRef>
12
+ </p:bg>
13
+ <p:spTree>
14
+ <p:nvGrpSpPr>
15
+ <p:cNvPr id="1" name=""/>
16
+ <p:cNvGrpSpPr/>
17
+ <p:nvPr/>
18
+ </p:nvGrpSpPr>
19
+ <p:grpSpPr>
20
+ <a:xfrm>
21
+ <a:off x="0" y="0"/>
22
+ <a:ext cx="0" cy="0"/>
23
+ <a:chOff x="0" y="0"/>
24
+ <a:chExt cx="0" cy="0"/>
25
+ </a:xfrm>
26
+ </p:grpSpPr>
27
+ <p:sp>
28
+ <p:nvSpPr>
29
+ <p:cNvPr id="2" name="Header Placeholder 1"/>
30
+ <p:cNvSpPr>
31
+ <a:spLocks noGrp="1"/>
32
+ </p:cNvSpPr>
33
+ <p:nvPr>
34
+ <p:ph type="hdr" sz="quarter"/>
35
+ </p:nvPr>
36
+ </p:nvSpPr>
37
+ <p:spPr>
38
+ <a:xfrm>
39
+ <a:off x="0" y="0"/>
40
+ <a:ext cx="2971800" cy="457200"/>
41
+ </a:xfrm>
42
+ <a:prstGeom prst="rect">
43
+ <a:avLst/>
44
+ </a:prstGeom>
45
+ </p:spPr>
46
+ <p:txBody>
47
+ <a:bodyPr vert="horz" lIns="91440" tIns="45720" rIns="91440" bIns="45720" rtlCol="0"/>
48
+ <a:lstStyle>
49
+ <a:lvl1pPr algn="l">
50
+ <a:defRPr sz="1200"/>
51
+ </a:lvl1pPr>
52
+ </a:lstStyle>
53
+ <a:p>
54
+ <a:endParaRPr lang="en-US"/>
55
+ </a:p>
56
+ </p:txBody>
57
+ </p:sp>
58
+ <p:sp>
59
+ <p:nvSpPr>
60
+ <p:cNvPr id="3" name="Date Placeholder 2"/>
61
+ <p:cNvSpPr>
62
+ <a:spLocks noGrp="1"/>
63
+ </p:cNvSpPr>
64
+ <p:nvPr>
65
+ <p:ph type="dt" idx="1"/>
66
+ </p:nvPr>
67
+ </p:nvSpPr>
68
+ <p:spPr>
69
+ <a:xfrm>
70
+ <a:off x="3884613" y="0"/>
71
+ <a:ext cx="2971800" cy="457200"/>
72
+ </a:xfrm>
73
+ <a:prstGeom prst="rect">
74
+ <a:avLst/>
75
+ </a:prstGeom>
76
+ </p:spPr>
77
+ <p:txBody>
78
+ <a:bodyPr vert="horz" lIns="91440" tIns="45720" rIns="91440" bIns="45720" rtlCol="0"/>
79
+ <a:lstStyle>
80
+ <a:lvl1pPr algn="r">
81
+ <a:defRPr sz="1200"/>
82
+ </a:lvl1pPr>
83
+ </a:lstStyle>
84
+ <a:p>
85
+ <a:fld id="{0F89C1C7-3DCD-1040-A9CF-14679D8B5DDD}" type="datetimeFigureOut">
86
+ <a:rPr lang="en-US" smtClean="0"/>
87
+ <a:t>10/17/16</a:t>
88
+ </a:fld>
89
+ <a:endParaRPr lang="en-US"/>
90
+ </a:p>
91
+ </p:txBody>
92
+ </p:sp>
93
+ <p:sp>
94
+ <p:nvSpPr>
95
+ <p:cNvPr id="4" name="Slide Image Placeholder 3"/>
96
+ <p:cNvSpPr>
97
+ <a:spLocks noGrp="1" noRot="1" noChangeAspect="1"/>
98
+ </p:cNvSpPr>
99
+ <p:nvPr>
100
+ <p:ph type="sldImg" idx="2"/>
101
+ </p:nvPr>
102
+ </p:nvSpPr>
103
+ <p:spPr>
104
+ <a:xfrm>
105
+ <a:off x="1143000" y="685800"/>
106
+ <a:ext cx="4572000" cy="3429000"/>
107
+ </a:xfrm>
108
+ <a:prstGeom prst="rect">
109
+ <a:avLst/>
110
+ </a:prstGeom>
111
+ <a:noFill/>
112
+ <a:ln w="12700">
113
+ <a:solidFill>
114
+ <a:prstClr val="black"/>
115
+ </a:solidFill>
116
+ </a:ln>
117
+ </p:spPr>
118
+ <p:txBody>
119
+ <a:bodyPr vert="horz" lIns="91440" tIns="45720" rIns="91440" bIns="45720" rtlCol="0" anchor="ctr"/>
120
+ <a:lstStyle/>
121
+ <a:p>
122
+ <a:endParaRPr lang="en-US"/>
123
+ </a:p>
124
+ </p:txBody>
125
+ </p:sp>
126
+ <p:sp>
127
+ <p:nvSpPr>
128
+ <p:cNvPr id="5" name="Notes Placeholder 4"/>
129
+ <p:cNvSpPr>
130
+ <a:spLocks noGrp="1"/>
131
+ </p:cNvSpPr>
132
+ <p:nvPr>
133
+ <p:ph type="body" sz="quarter" idx="3"/>
134
+ </p:nvPr>
135
+ </p:nvSpPr>
136
+ <p:spPr>
137
+ <a:xfrm>
138
+ <a:off x="685800" y="4343400"/>
139
+ <a:ext cx="5486400" cy="4114800"/>
140
+ </a:xfrm>
141
+ <a:prstGeom prst="rect">
142
+ <a:avLst/>
143
+ </a:prstGeom>
144
+ </p:spPr>
145
+ <p:txBody>
146
+ <a:bodyPr vert="horz" lIns="91440" tIns="45720" rIns="91440" bIns="45720" rtlCol="0"/>
147
+ <a:lstStyle/>
148
+ <a:p>
149
+ <a:pPr lvl="0"/>
150
+ <a:r>
151
+ <a:rPr lang="en-US" smtClean="0"/>
152
+ <a:t>Click to edit Master text styles</a:t>
153
+ </a:r>
154
+ </a:p>
155
+ <a:p>
156
+ <a:pPr lvl="1"/>
157
+ <a:r>
158
+ <a:rPr lang="en-US" smtClean="0"/>
159
+ <a:t>Second level</a:t>
160
+ </a:r>
161
+ </a:p>
162
+ <a:p>
163
+ <a:pPr lvl="2"/>
164
+ <a:r>
165
+ <a:rPr lang="en-US" smtClean="0"/>
166
+ <a:t>Third level</a:t>
167
+ </a:r>
168
+ </a:p>
169
+ <a:p>
170
+ <a:pPr lvl="3"/>
171
+ <a:r>
172
+ <a:rPr lang="en-US" smtClean="0"/>
173
+ <a:t>Fourth level</a:t>
174
+ </a:r>
175
+ </a:p>
176
+ <a:p>
177
+ <a:pPr lvl="4"/>
178
+ <a:r>
179
+ <a:rPr lang="en-US" smtClean="0"/>
180
+ <a:t>Fifth level</a:t>
181
+ </a:r>
182
+ <a:endParaRPr lang="en-US"/>
183
+ </a:p>
184
+ </p:txBody>
185
+ </p:sp>
186
+ <p:sp>
187
+ <p:nvSpPr>
188
+ <p:cNvPr id="6" name="Footer Placeholder 5"/>
189
+ <p:cNvSpPr>
190
+ <a:spLocks noGrp="1"/>
191
+ </p:cNvSpPr>
192
+ <p:nvPr>
193
+ <p:ph type="ftr" sz="quarter" idx="4"/>
194
+ </p:nvPr>
195
+ </p:nvSpPr>
196
+ <p:spPr>
197
+ <a:xfrm>
198
+ <a:off x="0" y="8685213"/>
199
+ <a:ext cx="2971800" cy="457200"/>
200
+ </a:xfrm>
201
+ <a:prstGeom prst="rect">
202
+ <a:avLst/>
203
+ </a:prstGeom>
204
+ </p:spPr>
205
+ <p:txBody>
206
+ <a:bodyPr vert="horz" lIns="91440" tIns="45720" rIns="91440" bIns="45720" rtlCol="0" anchor="b"/>
207
+ <a:lstStyle>
208
+ <a:lvl1pPr algn="l">
209
+ <a:defRPr sz="1200"/>
210
+ </a:lvl1pPr>
211
+ </a:lstStyle>
212
+ <a:p>
213
+ <a:endParaRPr lang="en-US"/>
214
+ </a:p>
215
+ </p:txBody>
216
+ </p:sp>
217
+ <p:sp>
218
+ <p:nvSpPr>
219
+ <p:cNvPr id="7" name="Slide Number Placeholder 6"/>
220
+ <p:cNvSpPr>
221
+ <a:spLocks noGrp="1"/>
222
+ </p:cNvSpPr>
223
+ <p:nvPr>
224
+ <p:ph type="sldNum" sz="quarter" idx="5"/>
225
+ </p:nvPr>
226
+ </p:nvSpPr>
227
+ <p:spPr>
228
+ <a:xfrm>
229
+ <a:off x="3884613" y="8685213"/>
230
+ <a:ext cx="2971800" cy="457200"/>
231
+ </a:xfrm>
232
+ <a:prstGeom prst="rect">
233
+ <a:avLst/>
234
+ </a:prstGeom>
235
+ </p:spPr>
236
+ <p:txBody>
237
+ <a:bodyPr vert="horz" lIns="91440" tIns="45720" rIns="91440" bIns="45720" rtlCol="0" anchor="b"/>
238
+ <a:lstStyle>
239
+ <a:lvl1pPr algn="r">
240
+ <a:defRPr sz="1200"/>
241
+ </a:lvl1pPr>
242
+ </a:lstStyle>
243
+ <a:p>
244
+ <a:fld id="{BB5E49A5-4136-284D-997B-48E1D791AD67}" type="slidenum">
245
+ <a:rPr lang="en-US" smtClean="0"/>
246
+ <a:t>‹#›</a:t>
247
+ </a:fld>
248
+ <a:endParaRPr lang="en-US"/>
249
+ </a:p>
250
+ </p:txBody>
251
+ </p:sp>
252
+ </p:spTree>
253
+ <p:extLst>
254
+ <p:ext uri="{BB962C8B-B14F-4D97-AF65-F5344CB8AC3E}">
255
+ <p14:creationId xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="2623252185"/>
256
+ </p:ext>
257
+ </p:extLst>
258
+ </p:cSld>
259
+ <p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>
260
+ <p:notesStyle>
261
+ <a:lvl1pPr marL="0" algn="l" defTabSz="457200" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
262
+ <a:defRPr sz="1200" kern="1200">
263
+ <a:solidFill>
264
+ <a:schemeClr val="tx1"/>
265
+ </a:solidFill>
266
+ <a:latin typeface="+mn-lt"/>
267
+ <a:ea typeface="+mn-ea"/>
268
+ <a:cs typeface="+mn-cs"/>
269
+ </a:defRPr>
270
+ </a:lvl1pPr>
271
+ <a:lvl2pPr marL="457200" algn="l" defTabSz="457200" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
272
+ <a:defRPr sz="1200" kern="1200">
273
+ <a:solidFill>
274
+ <a:schemeClr val="tx1"/>
275
+ </a:solidFill>
276
+ <a:latin typeface="+mn-lt"/>
277
+ <a:ea typeface="+mn-ea"/>
278
+ <a:cs typeface="+mn-cs"/>
279
+ </a:defRPr>
280
+ </a:lvl2pPr>
281
+ <a:lvl3pPr marL="914400" algn="l" defTabSz="457200" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
282
+ <a:defRPr sz="1200" kern="1200">
283
+ <a:solidFill>
284
+ <a:schemeClr val="tx1"/>
285
+ </a:solidFill>
286
+ <a:latin typeface="+mn-lt"/>
287
+ <a:ea typeface="+mn-ea"/>
288
+ <a:cs typeface="+mn-cs"/>
289
+ </a:defRPr>
290
+ </a:lvl3pPr>
291
+ <a:lvl4pPr marL="1371600" algn="l" defTabSz="457200" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
292
+ <a:defRPr sz="1200" kern="1200">
293
+ <a:solidFill>
294
+ <a:schemeClr val="tx1"/>
295
+ </a:solidFill>
296
+ <a:latin typeface="+mn-lt"/>
297
+ <a:ea typeface="+mn-ea"/>
298
+ <a:cs typeface="+mn-cs"/>
299
+ </a:defRPr>
300
+ </a:lvl4pPr>
301
+ <a:lvl5pPr marL="1828800" algn="l" defTabSz="457200" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
302
+ <a:defRPr sz="1200" kern="1200">
303
+ <a:solidFill>
304
+ <a:schemeClr val="tx1"/>
305
+ </a:solidFill>
306
+ <a:latin typeface="+mn-lt"/>
307
+ <a:ea typeface="+mn-ea"/>
308
+ <a:cs typeface="+mn-cs"/>
309
+ </a:defRPr>
310
+ </a:lvl5pPr>
311
+ <a:lvl6pPr marL="2286000" algn="l" defTabSz="457200" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
312
+ <a:defRPr sz="1200" kern="1200">
313
+ <a:solidFill>
314
+ <a:schemeClr val="tx1"/>
315
+ </a:solidFill>
316
+ <a:latin typeface="+mn-lt"/>
317
+ <a:ea typeface="+mn-ea"/>
318
+ <a:cs typeface="+mn-cs"/>
319
+ </a:defRPr>
320
+ </a:lvl6pPr>
321
+ <a:lvl7pPr marL="2743200" algn="l" defTabSz="457200" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
322
+ <a:defRPr sz="1200" kern="1200">
323
+ <a:solidFill>
324
+ <a:schemeClr val="tx1"/>
325
+ </a:solidFill>
326
+ <a:latin typeface="+mn-lt"/>
327
+ <a:ea typeface="+mn-ea"/>
328
+ <a:cs typeface="+mn-cs"/>
329
+ </a:defRPr>
330
+ </a:lvl7pPr>
331
+ <a:lvl8pPr marL="3200400" algn="l" defTabSz="457200" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
332
+ <a:defRPr sz="1200" kern="1200">
333
+ <a:solidFill>
334
+ <a:schemeClr val="tx1"/>
335
+ </a:solidFill>
336
+ <a:latin typeface="+mn-lt"/>
337
+ <a:ea typeface="+mn-ea"/>
338
+ <a:cs typeface="+mn-cs"/>
339
+ </a:defRPr>
340
+ </a:lvl8pPr>
341
+ <a:lvl9pPr marL="3657600" algn="l" defTabSz="457200" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
342
+ <a:defRPr sz="1200" kern="1200">
343
+ <a:solidFill>
344
+ <a:schemeClr val="tx1"/>
345
+ </a:solidFill>
346
+ <a:latin typeface="+mn-lt"/>
347
+ <a:ea typeface="+mn-ea"/>
348
+ <a:cs typeface="+mn-cs"/>
349
+ </a:defRPr>
350
+ </a:lvl9pPr>
351
+ </p:notesStyle>
352
+ </p:notesMaster>
tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/pptx-icon.emf ADDED
tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/theme.xml ADDED
@@ -0,0 +1,321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
2
+ <a:theme
3
+ xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
4
+ name="Office Theme"
5
+ >
6
+ <a:themeElements>
7
+ <a:clrScheme name="Office">
8
+ <a:dk1>
9
+ <a:sysClr val="windowText" lastClr="000000"/>
10
+ </a:dk1>
11
+ <a:lt1>
12
+ <a:sysClr val="window" lastClr="FFFFFF"/>
13
+ </a:lt1>
14
+ <a:dk2>
15
+ <a:srgbClr val="1F497D"/>
16
+ </a:dk2>
17
+ <a:lt2>
18
+ <a:srgbClr val="EEECE1"/>
19
+ </a:lt2>
20
+ <a:accent1>
21
+ <a:srgbClr val="4F81BD"/>
22
+ </a:accent1>
23
+ <a:accent2>
24
+ <a:srgbClr val="C0504D"/>
25
+ </a:accent2>
26
+ <a:accent3>
27
+ <a:srgbClr val="9BBB59"/>
28
+ </a:accent3>
29
+ <a:accent4>
30
+ <a:srgbClr val="8064A2"/>
31
+ </a:accent4>
32
+ <a:accent5>
33
+ <a:srgbClr val="4BACC6"/>
34
+ </a:accent5>
35
+ <a:accent6>
36
+ <a:srgbClr val="F79646"/>
37
+ </a:accent6>
38
+ <a:hlink>
39
+ <a:srgbClr val="0000FF"/>
40
+ </a:hlink>
41
+ <a:folHlink>
42
+ <a:srgbClr val="800080"/>
43
+ </a:folHlink>
44
+ </a:clrScheme>
45
+ <a:fontScheme name="Office">
46
+ <a:majorFont>
47
+ <a:latin typeface="Calibri"/>
48
+ <a:ea typeface=""/>
49
+ <a:cs typeface=""/>
50
+ <a:font script="Jpan" typeface="MS Pゴシック"/>
51
+ <a:font script="Hang" typeface="맑은 고딕"/>
52
+ <a:font script="Hans" typeface="宋体"/>
53
+ <a:font script="Hant" typeface="新細明體"/>
54
+ <a:font script="Arab" typeface="Times New Roman"/>
55
+ <a:font script="Hebr" typeface="Times New Roman"/>
56
+ <a:font script="Thai" typeface="Angsana New"/>
57
+ <a:font script="Ethi" typeface="Nyala"/>
58
+ <a:font script="Beng" typeface="Vrinda"/>
59
+ <a:font script="Gujr" typeface="Shruti"/>
60
+ <a:font script="Khmr" typeface="MoolBoran"/>
61
+ <a:font script="Knda" typeface="Tunga"/>
62
+ <a:font script="Guru" typeface="Raavi"/>
63
+ <a:font script="Cans" typeface="Euphemia"/>
64
+ <a:font script="Cher" typeface="Plantagenet Cherokee"/>
65
+ <a:font script="Yiii" typeface="Microsoft Yi Baiti"/>
66
+ <a:font script="Tibt" typeface="Microsoft Himalaya"/>
67
+ <a:font script="Thaa" typeface="MV Boli"/>
68
+ <a:font script="Deva" typeface="Mangal"/>
69
+ <a:font script="Telu" typeface="Gautami"/>
70
+ <a:font script="Taml" typeface="Latha"/>
71
+ <a:font script="Syrc" typeface="Estrangelo Edessa"/>
72
+ <a:font script="Orya" typeface="Kalinga"/>
73
+ <a:font script="Mlym" typeface="Kartika"/>
74
+ <a:font script="Laoo" typeface="DokChampa"/>
75
+ <a:font script="Sinh" typeface="Iskoola Pota"/>
76
+ <a:font script="Mong" typeface="Mongolian Baiti"/>
77
+ <a:font script="Viet" typeface="Times New Roman"/>
78
+ <a:font script="Uigh" typeface="Microsoft Uighur"/>
79
+ <a:font script="Geor" typeface="Sylfaen"/>
80
+ </a:majorFont>
81
+ <a:minorFont>
82
+ <a:latin typeface="Calibri"/>
83
+ <a:ea typeface=""/>
84
+ <a:cs typeface=""/>
85
+ <a:font script="Jpan" typeface="MS Pゴシック"/>
86
+ <a:font script="Hang" typeface="맑은 고딕"/>
87
+ <a:font script="Hans" typeface="宋体"/>
88
+ <a:font script="Hant" typeface="新細明體"/>
89
+ <a:font script="Arab" typeface="Arial"/>
90
+ <a:font script="Hebr" typeface="Arial"/>
91
+ <a:font script="Thai" typeface="Cordia New"/>
92
+ <a:font script="Ethi" typeface="Nyala"/>
93
+ <a:font script="Beng" typeface="Vrinda"/>
94
+ <a:font script="Gujr" typeface="Shruti"/>
95
+ <a:font script="Khmr" typeface="DaunPenh"/>
96
+ <a:font script="Knda" typeface="Tunga"/>
97
+ <a:font script="Guru" typeface="Raavi"/>
98
+ <a:font script="Cans" typeface="Euphemia"/>
99
+ <a:font script="Cher" typeface="Plantagenet Cherokee"/>
100
+ <a:font script="Yiii" typeface="Microsoft Yi Baiti"/>
101
+ <a:font script="Tibt" typeface="Microsoft Himalaya"/>
102
+ <a:font script="Thaa" typeface="MV Boli"/>
103
+ <a:font script="Deva" typeface="Mangal"/>
104
+ <a:font script="Telu" typeface="Gautami"/>
105
+ <a:font script="Taml" typeface="Latha"/>
106
+ <a:font script="Syrc" typeface="Estrangelo Edessa"/>
107
+ <a:font script="Orya" typeface="Kalinga"/>
108
+ <a:font script="Mlym" typeface="Kartika"/>
109
+ <a:font script="Laoo" typeface="DokChampa"/>
110
+ <a:font script="Sinh" typeface="Iskoola Pota"/>
111
+ <a:font script="Mong" typeface="Mongolian Baiti"/>
112
+ <a:font script="Viet" typeface="Arial"/>
113
+ <a:font script="Uigh" typeface="Microsoft Uighur"/>
114
+ <a:font script="Geor" typeface="Sylfaen"/>
115
+ </a:minorFont>
116
+ </a:fontScheme>
117
+ <a:fmtScheme name="Office">
118
+ <a:fillStyleLst>
119
+ <a:solidFill>
120
+ <a:schemeClr val="phClr"/>
121
+ </a:solidFill>
122
+ <a:gradFill rotWithShape="1">
123
+ <a:gsLst>
124
+ <a:gs pos="0">
125
+ <a:schemeClr val="phClr">
126
+ <a:tint val="50000"/>
127
+ <a:satMod val="300000"/>
128
+ </a:schemeClr>
129
+ </a:gs>
130
+ <a:gs pos="35000">
131
+ <a:schemeClr val="phClr">
132
+ <a:tint val="37000"/>
133
+ <a:satMod val="300000"/>
134
+ </a:schemeClr>
135
+ </a:gs>
136
+ <a:gs pos="100000">
137
+ <a:schemeClr val="phClr">
138
+ <a:tint val="15000"/>
139
+ <a:satMod val="350000"/>
140
+ </a:schemeClr>
141
+ </a:gs>
142
+ </a:gsLst>
143
+ <a:lin ang="16200000" scaled="1"/>
144
+ </a:gradFill>
145
+ <a:gradFill rotWithShape="1">
146
+ <a:gsLst>
147
+ <a:gs pos="0">
148
+ <a:schemeClr val="phClr">
149
+ <a:tint val="100000"/>
150
+ <a:shade val="100000"/>
151
+ <a:satMod val="130000"/>
152
+ </a:schemeClr>
153
+ </a:gs>
154
+ <a:gs pos="100000">
155
+ <a:schemeClr val="phClr">
156
+ <a:tint val="50000"/>
157
+ <a:shade val="100000"/>
158
+ <a:satMod val="350000"/>
159
+ </a:schemeClr>
160
+ </a:gs>
161
+ </a:gsLst>
162
+ <a:lin ang="16200000" scaled="0"/>
163
+ </a:gradFill>
164
+ </a:fillStyleLst>
165
+ <a:lnStyleLst>
166
+ <a:ln w="9525" cap="flat" cmpd="sng" algn="ctr">
167
+ <a:solidFill>
168
+ <a:schemeClr val="phClr">
169
+ <a:shade val="95000"/>
170
+ <a:satMod val="105000"/>
171
+ </a:schemeClr>
172
+ </a:solidFill>
173
+ <a:prstDash val="solid"/>
174
+ </a:ln>
175
+ <a:ln w="25400" cap="flat" cmpd="sng" algn="ctr">
176
+ <a:solidFill>
177
+ <a:schemeClr val="phClr"/>
178
+ </a:solidFill>
179
+ <a:prstDash val="solid"/>
180
+ </a:ln>
181
+ <a:ln w="38100" cap="flat" cmpd="sng" algn="ctr">
182
+ <a:solidFill>
183
+ <a:schemeClr val="phClr"/>
184
+ </a:solidFill>
185
+ <a:prstDash val="solid"/>
186
+ </a:ln>
187
+ </a:lnStyleLst>
188
+ <a:effectStyleLst>
189
+ <a:effectStyle>
190
+ <a:effectLst>
191
+ <a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0">
192
+ <a:srgbClr val="000000">
193
+ <a:alpha val="38000"/>
194
+ </a:srgbClr>
195
+ </a:outerShdw>
196
+ </a:effectLst>
197
+ </a:effectStyle>
198
+ <a:effectStyle>
199
+ <a:effectLst>
200
+ <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0">
201
+ <a:srgbClr val="000000">
202
+ <a:alpha val="35000"/>
203
+ </a:srgbClr>
204
+ </a:outerShdw>
205
+ </a:effectLst>
206
+ </a:effectStyle>
207
+ <a:effectStyle>
208
+ <a:effectLst>
209
+ <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0">
210
+ <a:srgbClr val="000000">
211
+ <a:alpha val="35000"/>
212
+ </a:srgbClr>
213
+ </a:outerShdw>
214
+ </a:effectLst>
215
+ <a:scene3d>
216
+ <a:camera prst="orthographicFront">
217
+ <a:rot lat="0" lon="0" rev="0"/>
218
+ </a:camera>
219
+ <a:lightRig rig="threePt" dir="t">
220
+ <a:rot lat="0" lon="0" rev="1200000"/>
221
+ </a:lightRig>
222
+ </a:scene3d>
223
+ <a:sp3d>
224
+ <a:bevelT w="63500" h="25400"/>
225
+ </a:sp3d>
226
+ </a:effectStyle>
227
+ </a:effectStyleLst>
228
+ <a:bgFillStyleLst>
229
+ <a:solidFill>
230
+ <a:schemeClr val="phClr"/>
231
+ </a:solidFill>
232
+ <a:gradFill rotWithShape="1">
233
+ <a:gsLst>
234
+ <a:gs pos="0">
235
+ <a:schemeClr val="phClr">
236
+ <a:tint val="40000"/>
237
+ <a:satMod val="350000"/>
238
+ </a:schemeClr>
239
+ </a:gs>
240
+ <a:gs pos="40000">
241
+ <a:schemeClr val="phClr">
242
+ <a:tint val="45000"/>
243
+ <a:shade val="99000"/>
244
+ <a:satMod val="350000"/>
245
+ </a:schemeClr>
246
+ </a:gs>
247
+ <a:gs pos="100000">
248
+ <a:schemeClr val="phClr">
249
+ <a:shade val="20000"/>
250
+ <a:satMod val="255000"/>
251
+ </a:schemeClr>
252
+ </a:gs>
253
+ </a:gsLst>
254
+ <a:path path="circle">
255
+ <a:fillToRect l="50000" t="-80000" r="50000" b="180000"/>
256
+ </a:path>
257
+ </a:gradFill>
258
+ <a:gradFill rotWithShape="1">
259
+ <a:gsLst>
260
+ <a:gs pos="0">
261
+ <a:schemeClr val="phClr">
262
+ <a:tint val="80000"/>
263
+ <a:satMod val="300000"/>
264
+ </a:schemeClr>
265
+ </a:gs>
266
+ <a:gs pos="100000">
267
+ <a:schemeClr val="phClr">
268
+ <a:shade val="30000"/>
269
+ <a:satMod val="200000"/>
270
+ </a:schemeClr>
271
+ </a:gs>
272
+ </a:gsLst>
273
+ <a:path path="circle">
274
+ <a:fillToRect l="50000" t="50000" r="50000" b="50000"/>
275
+ </a:path>
276
+ </a:gradFill>
277
+ </a:bgFillStyleLst>
278
+ </a:fmtScheme>
279
+ </a:themeElements>
280
+ <a:objectDefaults>
281
+ <a:spDef>
282
+ <a:spPr/>
283
+ <a:bodyPr/>
284
+ <a:lstStyle/>
285
+ <a:style>
286
+ <a:lnRef idx="1">
287
+ <a:schemeClr val="accent1"/>
288
+ </a:lnRef>
289
+ <a:fillRef idx="3">
290
+ <a:schemeClr val="accent1"/>
291
+ </a:fillRef>
292
+ <a:effectRef idx="2">
293
+ <a:schemeClr val="accent1"/>
294
+ </a:effectRef>
295
+ <a:fontRef idx="minor">
296
+ <a:schemeClr val="lt1"/>
297
+ </a:fontRef>
298
+ </a:style>
299
+ </a:spDef>
300
+ <a:lnDef>
301
+ <a:spPr/>
302
+ <a:bodyPr/>
303
+ <a:lstStyle/>
304
+ <a:style>
305
+ <a:lnRef idx="2">
306
+ <a:schemeClr val="accent1"/>
307
+ </a:lnRef>
308
+ <a:fillRef idx="0">
309
+ <a:schemeClr val="accent1"/>
310
+ </a:fillRef>
311
+ <a:effectRef idx="1">
312
+ <a:schemeClr val="accent1"/>
313
+ </a:effectRef>
314
+ <a:fontRef idx="minor">
315
+ <a:schemeClr val="tx1"/>
316
+ </a:fontRef>
317
+ </a:style>
318
+ </a:lnDef>
319
+ </a:objectDefaults>
320
+ <a:extraClrSchemeLst/>
321
+ </a:theme>
tasks/tasksmith-74f059424102/environment/source/src/pptx/templates/xlsx-icon.emf ADDED

Git LFS Details

  • SHA256: 14e52936cebdf16e5a6629ce707415c26122fe54af322872a2d25fec618a69ee
  • Pointer size: 131 Bytes
  • Size of remote file: 130 kB
tasks/tasksmith-74f059424102/environment/source/src/pptx/text/__init__.py ADDED
File without changes
tasks/tasksmith-74f059424102/environment/source/src/pptx/text/fonts.py ADDED
@@ -0,0 +1,399 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Objects related to system font file lookup."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import sys
7
+ from struct import calcsize, unpack_from
8
+
9
+ from pptx.util import lazyproperty
10
+
11
+
12
+ class FontFiles(object):
13
+ """A class-based singleton serving as a lazy cache for system font details."""
14
+
15
+ _font_files = None
16
+
17
+ @classmethod
18
+ def find(cls, family_name: str, is_bold: bool, is_italic: bool) -> str:
19
+ """Return the absolute path to an installed OpenType font.
20
+
21
+ File is matched by `family_name` and the styles `is_bold` and `is_italic`.
22
+ """
23
+ if cls._font_files is None:
24
+ cls._font_files = cls._installed_fonts()
25
+ return cls._font_files[(family_name, is_bold, is_italic)]
26
+
27
+ @classmethod
28
+ def _installed_fonts(cls):
29
+ """
30
+ Return a dict mapping a font descriptor to its font file path,
31
+ containing all the font files resident on the current machine. The
32
+ font descriptor is a (family_name, is_bold, is_italic) 3-tuple.
33
+ """
34
+ fonts = {}
35
+ for d in cls._font_directories():
36
+ for key, path in cls._iter_font_files_in(d):
37
+ fonts[key] = path
38
+ return fonts
39
+
40
+ @classmethod
41
+ def _font_directories(cls):
42
+ """
43
+ Return a sequence of directory paths likely to contain fonts on the
44
+ current platform.
45
+ """
46
+ if sys.platform.startswith("darwin"):
47
+ return cls._os_x_font_directories()
48
+ if sys.platform.startswith("win32"):
49
+ return cls._windows_font_directories()
50
+ raise OSError("unsupported operating system")
51
+
52
+ @classmethod
53
+ def _iter_font_files_in(cls, directory):
54
+ """
55
+ Generate the OpenType font files found in and under *directory*. Each
56
+ item is a key/value pair. The key is a (family_name, is_bold,
57
+ is_italic) 3-tuple, like ('Arial', True, False), and the value is the
58
+ absolute path to the font file.
59
+ """
60
+ for root, dirs, files in os.walk(directory):
61
+ for filename in files:
62
+ file_ext = os.path.splitext(filename)[1]
63
+ if file_ext.lower() not in (".otf", ".ttf"):
64
+ continue
65
+ path = os.path.abspath(os.path.join(root, filename))
66
+ with _Font.open(path) as f:
67
+ yield ((f.family_name, f.is_bold, f.is_italic), path)
68
+
69
+ @classmethod
70
+ def _os_x_font_directories(cls):
71
+ """
72
+ Return a sequence of directory paths on a Mac in which fonts are
73
+ likely to be located.
74
+ """
75
+ os_x_font_dirs = [
76
+ "/Library/Fonts",
77
+ "/Network/Library/Fonts",
78
+ "/System/Library/Fonts",
79
+ ]
80
+ home = os.environ.get("HOME")
81
+ if home is not None:
82
+ os_x_font_dirs.extend(
83
+ [os.path.join(home, "Library", "Fonts"), os.path.join(home, ".fonts")]
84
+ )
85
+ return os_x_font_dirs
86
+
87
+ @classmethod
88
+ def _windows_font_directories(cls):
89
+ """
90
+ Return a sequence of directory paths on Windows in which fonts are
91
+ likely to be located.
92
+ """
93
+ return [r"C:\Windows\Fonts"]
94
+
95
+
96
+ class _Font(object):
97
+ """
98
+ A wrapper around an OTF/TTF font file stream that knows how to parse it
99
+ for its name and style characteristics, e.g. bold and italic.
100
+ """
101
+
102
+ def __init__(self, stream):
103
+ self._stream = stream
104
+
105
+ def __enter__(self):
106
+ return self
107
+
108
+ def __exit__(self, exception_type, exception_value, exception_tb):
109
+ self._stream.close()
110
+
111
+ @property
112
+ def is_bold(self):
113
+ """
114
+ |True| if this font is marked as a bold style of its font family.
115
+ """
116
+ try:
117
+ return self._tables["head"].is_bold
118
+ except KeyError:
119
+ # some files don't have a head table
120
+ return False
121
+
122
+ @property
123
+ def is_italic(self):
124
+ """
125
+ |True| if this font is marked as an italic style of its font family.
126
+ """
127
+ try:
128
+ return self._tables["head"].is_italic
129
+ except KeyError:
130
+ # some files don't have a head table
131
+ return False
132
+
133
+ @classmethod
134
+ def open(cls, font_file_path):
135
+ """
136
+ Return a |_Font| instance loaded from *font_file_path*.
137
+ """
138
+ return cls(_Stream.open(font_file_path))
139
+
140
+ @property
141
+ def family_name(self):
142
+ """
143
+ The name of the typeface family for this font, e.g. 'Arial'. The full
144
+ typeface name includes optional style names, such as 'Regular' or
145
+ 'Bold Italic'. This attribute is only the common base name shared by
146
+ all fonts in the family.
147
+ """
148
+ return self._tables["name"].family_name
149
+
150
+ @lazyproperty
151
+ def _fields(self):
152
+ """5-tuple containing the fields read from the font file header.
153
+
154
+ Also known as the offset table.
155
+ """
156
+ # sfnt_version, tbl_count, search_range, entry_selector, range_shift
157
+ return self._stream.read_fields(">4sHHHH", 0)
158
+
159
+ def _iter_table_records(self):
160
+ """
161
+ Generate a (tag, offset, length) 3-tuple for each of the tables in
162
+ this font file.
163
+ """
164
+ count = self._table_count
165
+ bufr = self._stream.read(offset=12, length=count * 16)
166
+ tmpl = ">4sLLL"
167
+ for i in range(count):
168
+ offset = i * 16
169
+ tag, checksum, off, len_ = unpack_from(tmpl, bufr, offset)
170
+ yield tag.decode("utf-8"), off, len_
171
+
172
+ @lazyproperty
173
+ def _tables(self):
174
+ """
175
+ A mapping of OpenType table tag, e.g. 'name', to a table object
176
+ providing access to the contents of that table.
177
+ """
178
+ return dict(
179
+ (tag, _TableFactory(tag, self._stream, off, len_))
180
+ for tag, off, len_ in self._iter_table_records()
181
+ )
182
+
183
+ @property
184
+ def _table_count(self):
185
+ """
186
+ The number of tables in this OpenType font file.
187
+ """
188
+ return self._fields[1]
189
+
190
+
191
+ class _Stream(object):
192
+ """A thin wrapper around a binary file that facilitates reading C-struct values."""
193
+
194
+ def __init__(self, file):
195
+ self._file = file
196
+
197
+ @classmethod
198
+ def open(cls, path):
199
+ """Return |_Stream| providing binary access to contents of file at `path`."""
200
+ return cls(open(path, "rb"))
201
+
202
+ def close(self):
203
+ """
204
+ Close the wrapped file. Using the stream after closing raises an
205
+ exception.
206
+ """
207
+ self._file.close()
208
+
209
+ def read(self, offset, length):
210
+ """
211
+ Return *length* bytes from this stream starting at *offset*.
212
+ """
213
+ self._file.seek(offset)
214
+ return self._file.read(length)
215
+
216
+ def read_fields(self, template, offset=0):
217
+ """
218
+ Return a tuple containing the C-struct fields in this stream
219
+ specified by *template* and starting at *offset*.
220
+ """
221
+ self._file.seek(offset)
222
+ bufr = self._file.read(calcsize(template))
223
+ return unpack_from(template, bufr)
224
+
225
+
226
+ class _BaseTable(object):
227
+ """
228
+ Base class for OpenType font file table objects.
229
+ """
230
+
231
+ def __init__(self, tag, stream, offset, length):
232
+ self._tag = tag
233
+ self._stream = stream
234
+ self._offset = offset
235
+ self._length = length
236
+
237
+
238
+ class _HeadTable(_BaseTable):
239
+ """
240
+ OpenType font table having the tag 'head' and containing certain header
241
+ information for the font, including its bold and/or italic style.
242
+ """
243
+
244
+ def __init__(self, tag, stream, offset, length):
245
+ super(_HeadTable, self).__init__(tag, stream, offset, length)
246
+
247
+ @property
248
+ def is_bold(self):
249
+ """
250
+ |True| if this font is marked as having emboldened characters.
251
+ """
252
+ return bool(self._macStyle & 1)
253
+
254
+ @property
255
+ def is_italic(self):
256
+ """
257
+ |True| if this font is marked as having italicized characters.
258
+ """
259
+ return bool(self._macStyle & 2)
260
+
261
+ @lazyproperty
262
+ def _fields(self):
263
+ """
264
+ A 17-tuple containing the fields in this table.
265
+ """
266
+ return self._stream.read_fields(">4s4sLLHHqqhhhhHHHHH", self._offset)
267
+
268
+ @property
269
+ def _macStyle(self):
270
+ """
271
+ The unsigned short value of the 'macStyle' field in this head table.
272
+ """
273
+ return self._fields[12]
274
+
275
+
276
+ class _NameTable(_BaseTable):
277
+ """
278
+ An OpenType font table having the tag 'name' and containing the
279
+ name-related strings for the font.
280
+ """
281
+
282
+ def __init__(self, tag, stream, offset, length):
283
+ super(_NameTable, self).__init__(tag, stream, offset, length)
284
+
285
+ @property
286
+ def family_name(self):
287
+ """
288
+ The name of the typeface family for this font, e.g. 'Arial'.
289
+ """
290
+
291
+ def find_first(dict_, keys, default=None):
292
+ for key in keys:
293
+ value = dict_.get(key)
294
+ if value is not None:
295
+ return value
296
+ return default
297
+
298
+ # keys for Unicode, Mac, and Windows family name, respectively
299
+ return find_first(self._names, ((0, 1), (1, 1), (3, 1)))
300
+
301
+ @staticmethod
302
+ def _decode_name(raw_name, platform_id, encoding_id):
303
+ """
304
+ Return the unicode name decoded from *raw_name* using the encoding
305
+ implied by the combination of *platform_id* and *encoding_id*.
306
+ """
307
+ if platform_id == 1:
308
+ # reject non-Roman Mac font names
309
+ if encoding_id != 0:
310
+ return None
311
+ return raw_name.decode("mac-roman")
312
+ elif platform_id in (0, 3):
313
+ return raw_name.decode("utf-16-be")
314
+ else:
315
+ return None
316
+
317
+ def _iter_names(self):
318
+ """Generate a key/value pair for each name in this table.
319
+
320
+ The key is a (platform_id, name_id) 2-tuple and the value is the unicode text
321
+ corresponding to that key.
322
+ """
323
+ table_format, count, strings_offset = self._table_header
324
+ table_bytes = self._table_bytes
325
+
326
+ for idx in range(count):
327
+ platform_id, name_id, name = self._read_name(table_bytes, idx, strings_offset)
328
+ if name is None:
329
+ continue
330
+ yield ((platform_id, name_id), name)
331
+
332
+ @staticmethod
333
+ def _name_header(bufr, idx):
334
+ """
335
+ The (platform_id, encoding_id, language_id, name_id, length,
336
+ name_str_offset) 6-tuple encoded in each name record C-struct.
337
+ """
338
+ name_hdr_offset = 6 + idx * 12
339
+ return unpack_from(">HHHHHH", bufr, name_hdr_offset)
340
+
341
+ @staticmethod
342
+ def _raw_name_string(bufr, strings_offset, str_offset, length):
343
+ """
344
+ Return the *length* bytes comprising the encoded string in *bufr* at
345
+ *str_offset* in the strings area beginning at *strings_offset*.
346
+ """
347
+ offset = strings_offset + str_offset
348
+ tmpl = "%ds" % length
349
+ return unpack_from(tmpl, bufr, offset)[0]
350
+
351
+ def _read_name(self, bufr, idx, strings_offset):
352
+ """Return a (platform_id, name_id, name) 3-tuple for name at `idx` in `bufr`.
353
+
354
+ The triple looks like (0, 1, 'Arial'). `strings_offset` is the for the name at
355
+ `idx` position in `bufr`. `strings_offset` is the index into `bufr` where actual
356
+ name strings begin. The returned name is a unicode string.
357
+ """
358
+ platform_id, enc_id, lang_id, name_id, length, str_offset = self._name_header(bufr, idx)
359
+ name = self._read_name_text(bufr, platform_id, enc_id, strings_offset, str_offset, length)
360
+ return platform_id, name_id, name
361
+
362
+ def _read_name_text(
363
+ self, bufr, platform_id, encoding_id, strings_offset, name_str_offset, length
364
+ ):
365
+ """
366
+ Return the unicode name string at *name_str_offset* or |None| if
367
+ decoding its format is not supported.
368
+ """
369
+ raw_name = self._raw_name_string(bufr, strings_offset, name_str_offset, length)
370
+ return self._decode_name(raw_name, platform_id, encoding_id)
371
+
372
+ @lazyproperty
373
+ def _table_bytes(self):
374
+ """
375
+ The binary contents of this name table.
376
+ """
377
+ return self._stream.read(self._offset, self._length)
378
+
379
+ @property
380
+ def _table_header(self):
381
+ """
382
+ The (table_format, name_count, strings_offset) 3-tuple contained
383
+ in the header of this table.
384
+ """
385
+ return unpack_from(">HHH", self._table_bytes)
386
+
387
+ @lazyproperty
388
+ def _names(self):
389
+ """A mapping of (platform_id, name_id) keys to string names for this font."""
390
+ return dict(self._iter_names())
391
+
392
+
393
+ def _TableFactory(tag, stream, offset, length):
394
+ """
395
+ Return an instance of |Table| appropriate to *tag*, loaded from
396
+ *font_file* with content of *length* starting at *offset*.
397
+ """
398
+ TableClass = {"head": _HeadTable, "name": _NameTable}.get(tag, _BaseTable)
399
+ return TableClass(tag, stream, offset, length)
tasks/tasksmith-74f059424102/environment/source/src/pptx/text/layout.py ADDED
@@ -0,0 +1,325 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Objects related to layout of rendered text, such as TextFitter."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ from PIL import ImageFont
8
+
9
+ if TYPE_CHECKING:
10
+ from pptx.util import Length
11
+
12
+
13
+ class TextFitter(tuple):
14
+ """Value object that knows how to fit text into given rectangular extents."""
15
+
16
+ def __new__(cls, line_source, extents, font_file):
17
+ width, height = extents
18
+ return tuple.__new__(cls, (line_source, width, height, font_file))
19
+
20
+ @classmethod
21
+ def best_fit_font_size(
22
+ cls, text: str, extents: tuple[Length, Length], max_size: int, font_file: str
23
+ ) -> int:
24
+ """Return whole-number best fit point size less than or equal to `max_size`.
25
+
26
+ The return value is the largest whole-number point size less than or equal to
27
+ `max_size` that allows `text` to fit completely within `extents` when rendered
28
+ using font defined in `font_file`.
29
+ """
30
+ line_source = _LineSource(text)
31
+ text_fitter = cls(line_source, extents, font_file)
32
+ return text_fitter._best_fit_font_size(max_size)
33
+
34
+ def _best_fit_font_size(self, max_size):
35
+ """
36
+ Return the largest whole-number point size less than or equal to
37
+ *max_size* that this fitter can fit.
38
+ """
39
+ predicate = self._fits_inside_predicate
40
+ sizes = _BinarySearchTree.from_ordered_sequence(range(1, int(max_size) + 1))
41
+ return sizes.find_max(predicate)
42
+
43
+ def _break_line(self, line_source, point_size):
44
+ """
45
+ Return a (line, remainder) pair where *line* is the longest line in
46
+ *line_source* that will fit in this fitter's width and *remainder* is
47
+ a |_LineSource| object containing the text following the break point.
48
+ """
49
+ lines = _BinarySearchTree.from_ordered_sequence(line_source)
50
+ predicate = self._fits_in_width_predicate(point_size)
51
+ return lines.find_max(predicate)
52
+
53
+ def _fits_in_width_predicate(self, point_size):
54
+ """
55
+ Return a function taking a text string value and returns |True| if
56
+ that text fits in this fitter when rendered at *point_size*. Used as
57
+ predicate for _break_line()
58
+ """
59
+
60
+ def predicate(line):
61
+ """
62
+ Return |True| if *line* fits in this fitter when rendered at
63
+ *point_size*.
64
+ """
65
+ cx = _rendered_size(line.text, point_size, self._font_file)[0]
66
+ return cx <= self._width
67
+
68
+ return predicate
69
+
70
+ @property
71
+ def _fits_inside_predicate(self):
72
+ """Return function taking an integer point size argument.
73
+
74
+ The function returns |True| if the text in this fitter can be wrapped to fit
75
+ entirely within its extents when rendered at that point size.
76
+ """
77
+
78
+ def predicate(point_size):
79
+ """Return |True| when text in `line_source` can be wrapped to fit.
80
+
81
+ Fit means text can be broken into lines that fit entirely within `extents`
82
+ when rendered at `point_size` using the font defined in `font_file`.
83
+ """
84
+ text_lines = self._wrap_lines(self._line_source, point_size)
85
+ cy = _rendered_size("Ty", point_size, self._font_file)[1]
86
+ return (cy * len(text_lines)) <= self._height
87
+
88
+ return predicate
89
+
90
+ @property
91
+ def _font_file(self):
92
+ return self[3]
93
+
94
+ @property
95
+ def _height(self):
96
+ return self[2]
97
+
98
+ @property
99
+ def _line_source(self):
100
+ return self[0]
101
+
102
+ @property
103
+ def _width(self):
104
+ return self[1]
105
+
106
+ def _wrap_lines(self, line_source, point_size):
107
+ """
108
+ Return a sequence of str values representing the text in
109
+ *line_source* wrapped within this fitter when rendered at
110
+ *point_size*.
111
+ """
112
+ text, remainder = self._break_line(line_source, point_size)
113
+ lines = [text]
114
+ if remainder:
115
+ lines.extend(self._wrap_lines(remainder, point_size))
116
+ return lines
117
+
118
+
119
+ class _BinarySearchTree(object):
120
+ """
121
+ A node in a binary search tree. Uniform for root, subtree root, and leaf
122
+ nodes.
123
+ """
124
+
125
+ def __init__(self, value):
126
+ self._value = value
127
+ self._lesser = None
128
+ self._greater = None
129
+
130
+ def find_max(self, predicate, max_=None):
131
+ """
132
+ Return the largest item in or under this node that satisfies
133
+ *predicate*.
134
+ """
135
+ if predicate(self.value):
136
+ max_ = self.value
137
+ next_node = self._greater
138
+ else:
139
+ next_node = self._lesser
140
+ if next_node is None:
141
+ return max_
142
+ return next_node.find_max(predicate, max_)
143
+
144
+ @classmethod
145
+ def from_ordered_sequence(cls, iseq):
146
+ """
147
+ Return the root of a balanced binary search tree populated with the
148
+ values in iterable *iseq*.
149
+ """
150
+ seq = list(iseq)
151
+ # optimize for usually all fits by making longest first
152
+ bst = cls(seq.pop())
153
+ bst._insert_from_ordered_sequence(seq)
154
+ return bst
155
+
156
+ def insert(self, value):
157
+ """
158
+ Insert a new node containing *value* into this tree such that its
159
+ structure as a binary search tree is preserved.
160
+ """
161
+ side = "_lesser" if value < self.value else "_greater"
162
+ child = getattr(self, side)
163
+ if child is None:
164
+ setattr(self, side, _BinarySearchTree(value))
165
+ else:
166
+ child.insert(value)
167
+
168
+ def tree(self, level=0, prefix=""):
169
+ """
170
+ A string representation of the tree rooted in this node, useful for
171
+ debugging purposes.
172
+ """
173
+ text = "%s%s\n" % (prefix, self.value.text)
174
+ prefix = "%s└── " % (" " * level)
175
+ if self._lesser:
176
+ text += self._lesser.tree(level + 1, prefix)
177
+ if self._greater:
178
+ text += self._greater.tree(level + 1, prefix)
179
+ return text
180
+
181
+ @property
182
+ def value(self):
183
+ """
184
+ The value object contained in this node.
185
+ """
186
+ return self._value
187
+
188
+ @staticmethod
189
+ def _bisect(seq):
190
+ """
191
+ Return a (medial_value, greater_values, lesser_values) 3-tuple
192
+ obtained by bisecting sequence *seq*.
193
+ """
194
+ if len(seq) == 0:
195
+ return [], None, []
196
+ mid_idx = int(len(seq) / 2)
197
+ mid = seq[mid_idx]
198
+ greater = seq[mid_idx + 1 :]
199
+ lesser = seq[:mid_idx]
200
+ return mid, greater, lesser
201
+
202
+ def _insert_from_ordered_sequence(self, seq):
203
+ """
204
+ Insert the new values contained in *seq* into this tree such that
205
+ a balanced tree is produced.
206
+ """
207
+ if len(seq) == 0:
208
+ return
209
+ mid, greater, lesser = self._bisect(seq)
210
+ self.insert(mid)
211
+ self._insert_from_ordered_sequence(greater)
212
+ self._insert_from_ordered_sequence(lesser)
213
+
214
+
215
+ class _LineSource(object):
216
+ """
217
+ Generates all the possible even-word line breaks in a string of text,
218
+ each in the form of a (line, remainder) 2-tuple where *line* contains the
219
+ text before the break and *remainder* the text after as a |_LineSource|
220
+ object. Its boolean value is |True| when it contains text, |False| when
221
+ its text is the empty string or whitespace only.
222
+ """
223
+
224
+ def __init__(self, text):
225
+ self._text = text
226
+
227
+ def __bool__(self):
228
+ """
229
+ Gives this object boolean behaviors (in Python 3). bool(line_source)
230
+ is False if it contains the empty string or whitespace only.
231
+ """
232
+ return self._text.strip() != ""
233
+
234
+ def __eq__(self, other):
235
+ return self._text == other._text
236
+
237
+ def __iter__(self):
238
+ """
239
+ Generate a (text, remainder) pair for each possible even-word line
240
+ break in this line source, where *text* is a str value and remainder
241
+ is a |_LineSource| value.
242
+ """
243
+ words = self._text.split()
244
+ for idx in range(1, len(words) + 1):
245
+ line_text = " ".join(words[:idx])
246
+ remainder_text = " ".join(words[idx:])
247
+ remainder = _LineSource(remainder_text)
248
+ yield _Line(line_text, remainder)
249
+
250
+ def __nonzero__(self):
251
+ """
252
+ Gives this object boolean behaviors (in Python 2). bool(line_source)
253
+ is False if it contains the empty string or whitespace only.
254
+ """
255
+ return self._text.strip() != ""
256
+
257
+ def __repr__(self):
258
+ return "<_LineSource('%s')>" % self._text
259
+
260
+
261
+ class _Line(tuple):
262
+ """
263
+ A candidate line broken at an even word boundary from a string of text,
264
+ and a |_LineSource| value containing the text that remains after the line
265
+ is broken at this spot.
266
+ """
267
+
268
+ def __new__(cls, text, remainder):
269
+ return tuple.__new__(cls, (text, remainder))
270
+
271
+ def __gt__(self, other):
272
+ return len(self.text) > len(other.text)
273
+
274
+ def __lt__(self, other):
275
+ return not self.__gt__(other)
276
+
277
+ def __len__(self):
278
+ return len(self.text)
279
+
280
+ def __repr__(self):
281
+ return "'%s' => '%s'" % (self.text, self.remainder)
282
+
283
+ @property
284
+ def remainder(self):
285
+ return self[1]
286
+
287
+ @property
288
+ def text(self):
289
+ return self[0]
290
+
291
+
292
+ class _Fonts(object):
293
+ """
294
+ A memoizing cache for ImageFont objects.
295
+ """
296
+
297
+ fonts = {}
298
+
299
+ @classmethod
300
+ def font(cls, font_path, point_size):
301
+ if (font_path, point_size) not in cls.fonts:
302
+ cls.fonts[(font_path, point_size)] = ImageFont.truetype(font_path, point_size)
303
+ return cls.fonts[(font_path, point_size)]
304
+
305
+
306
+ def _rendered_size(text, point_size, font_file):
307
+ """
308
+ Return a (width, height) pair representing the size of *text* in English
309
+ Metric Units (EMU) when rendered at *point_size* in the font defined in
310
+ *font_file*.
311
+ """
312
+ emu_per_inch = 914400
313
+ px_per_inch = 72.0
314
+
315
+ font = _Fonts.font(font_file, point_size)
316
+ try:
317
+ px_width, px_height = font.getsize(text)
318
+ except AttributeError:
319
+ left, top, right, bottom = font.getbbox(text)
320
+ px_width, px_height = right - left, bottom - top
321
+
322
+ emu_width = int(px_width / px_per_inch * emu_per_inch)
323
+ emu_height = int(px_height / px_per_inch * emu_per_inch)
324
+
325
+ return emu_width, emu_height
tasks/tasksmith-74f059424102/environment/source/src/pptx/text/text.py ADDED
@@ -0,0 +1,681 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Text-related objects such as TextFrame and Paragraph."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Iterator, cast
6
+
7
+ from pptx.dml.fill import FillFormat
8
+ from pptx.enum.dml import MSO_FILL
9
+ from pptx.enum.lang import MSO_LANGUAGE_ID
10
+ from pptx.enum.text import MSO_AUTO_SIZE, MSO_UNDERLINE, MSO_VERTICAL_ANCHOR
11
+ from pptx.opc.constants import RELATIONSHIP_TYPE as RT
12
+ from pptx.oxml.simpletypes import ST_TextWrappingType
13
+ from pptx.shapes import Subshape
14
+ from pptx.text.fonts import FontFiles
15
+ from pptx.text.layout import TextFitter
16
+ from pptx.util import Centipoints, Emu, Length, Pt, lazyproperty
17
+
18
+ if TYPE_CHECKING:
19
+ from pptx.dml.color import ColorFormat
20
+ from pptx.enum.text import (
21
+ MSO_TEXT_UNDERLINE_TYPE,
22
+ MSO_VERTICAL_ANCHOR,
23
+ PP_PARAGRAPH_ALIGNMENT,
24
+ )
25
+ from pptx.oxml.action import CT_Hyperlink
26
+ from pptx.oxml.text import (
27
+ CT_RegularTextRun,
28
+ CT_TextBody,
29
+ CT_TextCharacterProperties,
30
+ CT_TextParagraph,
31
+ CT_TextParagraphProperties,
32
+ )
33
+ from pptx.types import ProvidesExtents, ProvidesPart
34
+
35
+
36
+ class TextFrame(Subshape):
37
+ """The part of a shape that contains its text.
38
+
39
+ Not all shapes have a text frame. Corresponds to the `p:txBody` element that can
40
+ appear as a child element of `p:sp`. Not intended to be constructed directly.
41
+ """
42
+
43
+ def __init__(self, txBody: CT_TextBody, parent: ProvidesPart):
44
+ super(TextFrame, self).__init__(parent)
45
+ self._element = self._txBody = txBody
46
+ self._parent = parent
47
+
48
+ def add_paragraph(self):
49
+ """
50
+ Return new |_Paragraph| instance appended to the sequence of
51
+ paragraphs contained in this text frame.
52
+ """
53
+ p = self._txBody.add_p()
54
+ return _Paragraph(p, self)
55
+
56
+ @property
57
+ def auto_size(self) -> MSO_AUTO_SIZE | None:
58
+ """Resizing strategy used to fit text within this shape.
59
+
60
+ Determins the type of automatic resizing used to fit the text of this shape within its
61
+ bounding box when the text would otherwise extend beyond the shape boundaries. May be
62
+ |None|, `MSO_AUTO_SIZE.NONE`, `MSO_AUTO_SIZE.SHAPE_TO_FIT_TEXT`, or
63
+ `MSO_AUTO_SIZE.TEXT_TO_FIT_SHAPE`.
64
+ """
65
+ return self._bodyPr.autofit
66
+
67
+ @auto_size.setter
68
+ def auto_size(self, value: MSO_AUTO_SIZE | None):
69
+ self._bodyPr.autofit = value
70
+
71
+ def clear(self):
72
+ """Remove all paragraphs except one empty one."""
73
+ for p in self._txBody.p_lst[1:]:
74
+ self._txBody.remove(p)
75
+ p = self.paragraphs[0]
76
+ p.clear()
77
+
78
+ def fit_text(
79
+ self,
80
+ font_family: str = "Calibri",
81
+ max_size: int = 18,
82
+ bold: bool = False,
83
+ italic: bool = False,
84
+ font_file: str | None = None,
85
+ ):
86
+ """Fit text-frame text entirely within bounds of its shape.
87
+
88
+ Make the text in this text frame fit entirely within the bounds of its shape by setting
89
+ word wrap on and applying the "best-fit" font size to all the text it contains.
90
+
91
+ :attr:`TextFrame.auto_size` is set to :attr:`MSO_AUTO_SIZE.NONE`. The font size will not
92
+ be set larger than `max_size` points. If the path to a matching TrueType font is provided
93
+ as `font_file`, that font file will be used for the font metrics. If `font_file` is |None|,
94
+ best efforts are made to locate a font file with matchhing `font_family`, `bold`, and
95
+ `italic` installed on the current system (usually succeeds if the font is installed).
96
+ """
97
+ # ---no-op when empty as fit behavior not defined for that case---
98
+ if self.text == "":
99
+ return # pragma: no cover
100
+
101
+ font_size = self._best_fit_font_size(font_family, max_size, bold, italic, font_file)
102
+ self._apply_fit(font_family, font_size, bold, italic)
103
+
104
+ @property
105
+ def margin_bottom(self) -> Length:
106
+ """|Length| value representing the inset of text from the bottom text frame border.
107
+
108
+ :meth:`pptx.util.Inches` provides a convenient way of setting the value, e.g.
109
+ `text_frame.margin_bottom = Inches(0.05)`.
110
+ """
111
+ return self._bodyPr.bIns
112
+
113
+ @margin_bottom.setter
114
+ def margin_bottom(self, emu: Length):
115
+ self._bodyPr.bIns = emu
116
+
117
+ @property
118
+ def margin_left(self) -> Length:
119
+ """Inset of text from left text frame border as |Length| value."""
120
+ return self._bodyPr.lIns
121
+
122
+ @margin_left.setter
123
+ def margin_left(self, emu: Length):
124
+ self._bodyPr.lIns = emu
125
+
126
+ @property
127
+ def margin_right(self) -> Length:
128
+ """Inset of text from right text frame border as |Length| value."""
129
+ return self._bodyPr.rIns
130
+
131
+ @margin_right.setter
132
+ def margin_right(self, emu: Length):
133
+ self._bodyPr.rIns = emu
134
+
135
+ @property
136
+ def margin_top(self) -> Length:
137
+ """Inset of text from top text frame border as |Length| value."""
138
+ return self._bodyPr.tIns
139
+
140
+ @margin_top.setter
141
+ def margin_top(self, emu: Length):
142
+ self._bodyPr.tIns = emu
143
+
144
+ @property
145
+ def paragraphs(self) -> tuple[_Paragraph, ...]:
146
+ """Sequence of paragraphs in this text frame.
147
+
148
+ A text frame always contains at least one paragraph.
149
+ """
150
+ return tuple([_Paragraph(p, self) for p in self._txBody.p_lst])
151
+
152
+ @property
153
+ def text(self) -> str:
154
+ """All text in this text-frame as a single string.
155
+
156
+ Read/write. The return value contains all text in this text-frame. A line-feed character
157
+ (`"\\n"`) separates the text for each paragraph. A vertical-tab character (`"\\v"`) appears
158
+ for each line break (aka. soft carriage-return) encountered.
159
+
160
+ The vertical-tab character is how PowerPoint represents a soft carriage return in clipboard
161
+ text, which is why that encoding was chosen.
162
+
163
+ Assignment replaces all text in the text frame. A new paragraph is added for each line-feed
164
+ character (`"\\n"`) encountered. A line-break (soft carriage-return) is inserted for each
165
+ vertical-tab character (`"\\v"`) encountered.
166
+
167
+ Any control character other than newline, tab, or vertical-tab are escaped as plain-text
168
+ like "_x001B_" (for ESC (ASCII 32) in this example).
169
+ """
170
+ return "\n".join(paragraph.text for paragraph in self.paragraphs)
171
+
172
+ @text.setter
173
+ def text(self, text: str):
174
+ txBody = self._txBody
175
+ txBody.clear_content()
176
+ for p_text in text.split("\n"):
177
+ p = txBody.add_p()
178
+ p.append_text(p_text)
179
+
180
+ @property
181
+ def vertical_anchor(self) -> MSO_VERTICAL_ANCHOR | None:
182
+ """Represents the vertical alignment of text in this text frame.
183
+
184
+ |None| indicates the effective value should be inherited from this object's style hierarchy.
185
+ """
186
+ return self._txBody.bodyPr.anchor
187
+
188
+ @vertical_anchor.setter
189
+ def vertical_anchor(self, value: MSO_VERTICAL_ANCHOR | None):
190
+ bodyPr = self._txBody.bodyPr
191
+ bodyPr.anchor = value
192
+
193
+ @property
194
+ def word_wrap(self) -> bool | None:
195
+ """`True` when lines of text in this shape are wrapped to fit within the shape's width.
196
+
197
+ Read-write. Valid values are True, False, or None. True and False turn word wrap on and
198
+ off, respectively. Assigning None to word wrap causes any word wrap setting to be removed
199
+ from the text frame, causing it to inherit this setting from its style hierarchy.
200
+ """
201
+ return {
202
+ ST_TextWrappingType.SQUARE: True,
203
+ ST_TextWrappingType.NONE: False,
204
+ None: None,
205
+ }[self._txBody.bodyPr.wrap]
206
+
207
+ @word_wrap.setter
208
+ def word_wrap(self, value: bool | None):
209
+ if value not in (True, False, None):
210
+ raise ValueError( # pragma: no cover
211
+ "assigned value must be True, False, or None, got %s" % value
212
+ )
213
+ self._txBody.bodyPr.wrap = {
214
+ True: ST_TextWrappingType.SQUARE,
215
+ False: ST_TextWrappingType.NONE,
216
+ None: None,
217
+ }[value]
218
+
219
+ def _apply_fit(self, font_family: str, font_size: int, is_bold: bool, is_italic: bool):
220
+ """Arrange text in this text frame to fit inside its extents.
221
+
222
+ This is accomplished by setting auto size off, wrap on, and setting the font of
223
+ all its text to `font_family`, `font_size`, `is_bold`, and `is_italic`.
224
+ """
225
+ self.auto_size = MSO_AUTO_SIZE.NONE
226
+ self.word_wrap = True
227
+ self._set_font(font_family, font_size, is_bold, is_italic)
228
+
229
+ def _best_fit_font_size(
230
+ self, family: str, max_size: int, bold: bool, italic: bool, font_file: str | None
231
+ ) -> int:
232
+ """Return font-size in points that best fits text in this text-frame.
233
+
234
+ The best-fit font size is the largest integer point size not greater than `max_size` that
235
+ allows all the text in this text frame to fit inside its extents when rendered using the
236
+ font described by `family`, `bold`, and `italic`. If `font_file` is specified, it is used
237
+ to calculate the fit, whether or not it matches `family`, `bold`, and `italic`.
238
+ """
239
+ if font_file is None:
240
+ font_file = FontFiles.find(family, bold, italic)
241
+ return TextFitter.best_fit_font_size(self.text, self._extents, max_size, font_file)
242
+
243
+ @property
244
+ def _bodyPr(self):
245
+ return self._txBody.bodyPr
246
+
247
+ @property
248
+ def _extents(self) -> tuple[Length, Length]:
249
+ """(cx, cy) 2-tuple representing the effective rendering area of this text-frame.
250
+
251
+ Margins are taken into account.
252
+ """
253
+ parent = cast("ProvidesExtents", self._parent)
254
+ return (
255
+ Length(parent.width - self.margin_left - self.margin_right),
256
+ Length(parent.height - self.margin_top - self.margin_bottom),
257
+ )
258
+
259
+ def _set_font(self, family: str, size: int, bold: bool, italic: bool):
260
+ """Set the font properties of all the text in this text frame."""
261
+
262
+ def iter_rPrs(txBody: CT_TextBody) -> Iterator[CT_TextCharacterProperties]:
263
+ for p in txBody.p_lst:
264
+ for elm in p.content_children:
265
+ yield elm.get_or_add_rPr()
266
+ # generate a:endParaRPr for each <a:p> element
267
+ yield p.get_or_add_endParaRPr()
268
+
269
+ def set_rPr_font(
270
+ rPr: CT_TextCharacterProperties, name: str, size: int, bold: bool, italic: bool
271
+ ):
272
+ f = Font(rPr)
273
+ f.name, f.size, f.bold, f.italic = family, Pt(size), bold, italic
274
+
275
+ txBody = self._element
276
+ for rPr in iter_rPrs(txBody):
277
+ set_rPr_font(rPr, family, size, bold, italic)
278
+
279
+
280
+ class Font(object):
281
+ """Character properties object, providing font size, font name, bold, italic, etc.
282
+
283
+ Corresponds to `a:rPr` child element of a run. Also appears as `a:defRPr` and
284
+ `a:endParaRPr` in paragraph and `a:defRPr` in list style elements.
285
+ """
286
+
287
+ def __init__(self, rPr: CT_TextCharacterProperties):
288
+ super(Font, self).__init__()
289
+ self._element = self._rPr = rPr
290
+
291
+ @property
292
+ def bold(self) -> bool | None:
293
+ """Get or set boolean bold value of |Font|, e.g. `paragraph.font.bold = True`.
294
+
295
+ If set to |None|, the bold setting is cleared and is inherited from an enclosing shape's
296
+ setting, or a setting in a style or master. Returns None if no bold attribute is present,
297
+ meaning the effective bold value is inherited from a master or the theme.
298
+ """
299
+ return self._rPr.b
300
+
301
+ @bold.setter
302
+ def bold(self, value: bool | None):
303
+ self._rPr.b = value
304
+
305
+ @lazyproperty
306
+ def color(self) -> ColorFormat:
307
+ """The |ColorFormat| instance that provides access to the color settings for this font."""
308
+ if self.fill.type != MSO_FILL.SOLID:
309
+ self.fill.solid()
310
+ return self.fill.fore_color
311
+
312
+ @lazyproperty
313
+ def fill(self) -> FillFormat:
314
+ """|FillFormat| instance for this font.
315
+
316
+ Provides access to fill properties such as fill color.
317
+ """
318
+ return FillFormat.from_fill_parent(self._rPr)
319
+
320
+ @property
321
+ def italic(self) -> bool | None:
322
+ """Get or set boolean italic value of |Font| instance.
323
+
324
+ Has the same behaviors as bold with respect to None values.
325
+ """
326
+ return self._rPr.i
327
+
328
+ @italic.setter
329
+ def italic(self, value: bool | None):
330
+ self._rPr.i = value
331
+
332
+ @property
333
+ def language_id(self) -> MSO_LANGUAGE_ID | None:
334
+ """Get or set the language id of this |Font| instance.
335
+
336
+ The language id is a member of the :ref:`MsoLanguageId` enumeration. Assigning |None|
337
+ removes any language setting, the same behavior as assigning `MSO_LANGUAGE_ID.NONE`.
338
+ """
339
+ lang = self._rPr.lang
340
+ if lang is None:
341
+ return MSO_LANGUAGE_ID.NONE
342
+ return self._rPr.lang
343
+
344
+ @language_id.setter
345
+ def language_id(self, value: MSO_LANGUAGE_ID | None):
346
+ if value == MSO_LANGUAGE_ID.NONE:
347
+ value = None
348
+ self._rPr.lang = value
349
+
350
+ @property
351
+ def name(self) -> str | None:
352
+ """Get or set the typeface name for this |Font| instance.
353
+
354
+ Causes the text it controls to appear in the named font, if a matching font is found.
355
+ Returns |None| if the typeface is currently inherited from the theme. Setting it to |None|
356
+ removes any override of the theme typeface.
357
+ """
358
+ latin = self._rPr.latin
359
+ if latin is None:
360
+ return None
361
+ return latin.typeface
362
+
363
+ @name.setter
364
+ def name(self, value: str | None):
365
+ if value is None:
366
+ self._rPr._remove_latin() # pyright: ignore[reportPrivateUsage]
367
+ else:
368
+ latin = self._rPr.get_or_add_latin()
369
+ latin.typeface = value
370
+
371
+ @property
372
+ def size(self) -> Length | None:
373
+ """Indicates the font height in English Metric Units (EMU).
374
+
375
+ Read/write. |None| indicates the font size should be inherited from its style hierarchy,
376
+ such as a placeholder or document defaults (usually 18pt). |Length| is a subclass of |int|
377
+ having properties for convenient conversion into points or other length units. Likewise,
378
+ the :class:`pptx.util.Pt` class allows convenient specification of point values::
379
+
380
+ >>> font.size = Pt(24)
381
+ >>> font.size
382
+ 304800
383
+ >>> font.size.pt
384
+ 24.0
385
+ """
386
+ sz = self._rPr.sz
387
+ if sz is None:
388
+ return None
389
+ return Centipoints(sz)
390
+
391
+ @size.setter
392
+ def size(self, emu: Length | None):
393
+ if emu is None:
394
+ self._rPr.sz = None
395
+ else:
396
+ sz = Emu(emu).centipoints
397
+ self._rPr.sz = sz
398
+
399
+ @property
400
+ def underline(self) -> bool | MSO_TEXT_UNDERLINE_TYPE | None:
401
+ """Indicaties the underline setting for this font.
402
+
403
+ Value is |True|, |False|, |None|, or a member of the :ref:`MsoTextUnderlineType`
404
+ enumeration. |None| is the default and indicates the underline setting should be inherited
405
+ from the style hierarchy, such as from a placeholder. |True| indicates single underline.
406
+ |False| indicates no underline. Other settings such as double and wavy underlining are
407
+ indicated with members of the :ref:`MsoTextUnderlineType` enumeration.
408
+ """
409
+ u = self._rPr.u
410
+ if u is MSO_UNDERLINE.NONE:
411
+ return False
412
+ if u is MSO_UNDERLINE.SINGLE_LINE:
413
+ return True
414
+ return u
415
+
416
+ @underline.setter
417
+ def underline(self, value: bool | MSO_TEXT_UNDERLINE_TYPE | None):
418
+ if value is True:
419
+ value = MSO_UNDERLINE.SINGLE_LINE
420
+ elif value is False:
421
+ value = MSO_UNDERLINE.NONE
422
+ self._element.u = value
423
+
424
+
425
+ class _Hyperlink(Subshape):
426
+ """Text run hyperlink object.
427
+
428
+ Corresponds to `a:hlinkClick` child element of the run's properties element (`a:rPr`).
429
+ """
430
+
431
+ def __init__(self, rPr: CT_TextCharacterProperties, parent: ProvidesPart):
432
+ super(_Hyperlink, self).__init__(parent)
433
+ self._rPr = rPr
434
+
435
+ @property
436
+ def address(self) -> str | None:
437
+ """The URL of the hyperlink.
438
+
439
+ Read/write. URL can be on http, https, mailto, or file scheme; others may work.
440
+ """
441
+ if self._hlinkClick is None:
442
+ return None
443
+ return self.part.target_ref(self._hlinkClick.rId)
444
+
445
+ @address.setter
446
+ def address(self, url: str | None):
447
+ # implements all three of add, change, and remove hyperlink
448
+ if self._hlinkClick is not None:
449
+ self._remove_hlinkClick()
450
+ if url:
451
+ self._add_hlinkClick(url)
452
+
453
+ def _add_hlinkClick(self, url: str):
454
+ rId = self.part.relate_to(url, RT.HYPERLINK, is_external=True)
455
+ self._rPr.add_hlinkClick(rId)
456
+
457
+ @property
458
+ def _hlinkClick(self) -> CT_Hyperlink | None:
459
+ return self._rPr.hlinkClick
460
+
461
+ def _remove_hlinkClick(self):
462
+ assert self._hlinkClick is not None
463
+ self.part.drop_rel(self._hlinkClick.rId)
464
+ self._rPr._remove_hlinkClick() # pyright: ignore[reportPrivateUsage]
465
+
466
+
467
+ class _Paragraph(Subshape):
468
+ """Paragraph object. Not intended to be constructed directly."""
469
+
470
+ def __init__(self, p: CT_TextParagraph, parent: ProvidesPart):
471
+ super(_Paragraph, self).__init__(parent)
472
+ self._element = self._p = p
473
+
474
+ def add_line_break(self):
475
+ """Add line break at end of this paragraph."""
476
+ self._p.add_br()
477
+
478
+ def add_run(self) -> _Run:
479
+ """Return a new run appended to the runs in this paragraph."""
480
+ r = self._p.add_r()
481
+ return _Run(r, self)
482
+
483
+ @property
484
+ def alignment(self) -> PP_PARAGRAPH_ALIGNMENT | None:
485
+ """Horizontal alignment of this paragraph.
486
+
487
+ The value |None| indicates the paragraph should 'inherit' its effective value from its
488
+ style hierarchy. Assigning |None| removes any explicit setting, causing its inherited
489
+ value to be used.
490
+ """
491
+ return self._pPr.algn
492
+
493
+ @alignment.setter
494
+ def alignment(self, value: PP_PARAGRAPH_ALIGNMENT | None):
495
+ self._pPr.algn = value
496
+
497
+ def clear(self):
498
+ """Remove all content from this paragraph.
499
+
500
+ Paragraph properties are preserved. Content includes runs, line breaks, and fields.
501
+ """
502
+ for elm in self._element.content_children:
503
+ self._element.remove(elm)
504
+ return self
505
+
506
+ @property
507
+ def font(self) -> Font:
508
+ """|Font| object containing default character properties for the runs in this paragraph.
509
+
510
+ These character properties override default properties inherited from parent objects such
511
+ as the text frame the paragraph is contained in and they may be overridden by character
512
+ properties set at the run level.
513
+ """
514
+ return Font(self._defRPr)
515
+
516
+ @property
517
+ def level(self) -> int:
518
+ """Indentation level of this paragraph.
519
+
520
+ Read-write. Integer in range 0..8 inclusive. 0 represents a top-level paragraph and is the
521
+ default value. Indentation level is most commonly encountered in a bulleted list, as is
522
+ found on a word bullet slide.
523
+ """
524
+ return self._pPr.lvl
525
+
526
+ @level.setter
527
+ def level(self, level: int):
528
+ self._pPr.lvl = level
529
+
530
+ @property
531
+ def line_spacing(self) -> int | float | Length | None:
532
+ """The space between baselines in successive lines of this paragraph.
533
+
534
+ A value of |None| indicates no explicit value is assigned and its effective value is
535
+ inherited from the paragraph's style hierarchy. A numeric value, e.g. `2` or `1.5`,
536
+ indicates spacing is applied in multiples of line heights. A |Length| value such as
537
+ `Pt(12)` indicates spacing is a fixed height. The |Pt| value class is a convenient way to
538
+ apply line spacing in units of points.
539
+ """
540
+ pPr = self._p.pPr
541
+ if pPr is None:
542
+ return None
543
+ return pPr.line_spacing
544
+
545
+ @line_spacing.setter
546
+ def line_spacing(self, value: int | float | Length | None):
547
+ pPr = self._p.get_or_add_pPr()
548
+ pPr.line_spacing = value
549
+
550
+ @property
551
+ def runs(self) -> tuple[_Run, ...]:
552
+ """Sequence of runs in this paragraph."""
553
+ return tuple(_Run(r, self) for r in self._element.r_lst)
554
+
555
+ @property
556
+ def space_after(self) -> Length | None:
557
+ """The spacing to appear between this paragraph and the subsequent paragraph.
558
+
559
+ A value of |None| indicates no explicit value is assigned and its effective value is
560
+ inherited from the paragraph's style hierarchy. |Length| objects provide convenience
561
+ properties, such as `.pt` and `.inches`, that allow easy conversion to various length
562
+ units.
563
+ """
564
+ pPr = self._p.pPr
565
+ if pPr is None:
566
+ return None
567
+ return pPr.space_after
568
+
569
+ @space_after.setter
570
+ def space_after(self, value: Length | None):
571
+ pPr = self._p.get_or_add_pPr()
572
+ pPr.space_after = value
573
+
574
+ @property
575
+ def space_before(self) -> Length | None:
576
+ """The spacing to appear between this paragraph and the prior paragraph.
577
+
578
+ A value of |None| indicates no explicit value is assigned and its effective value is
579
+ inherited from the paragraph's style hierarchy. |Length| objects provide convenience
580
+ properties, such as `.pt` and `.cm`, that allow easy conversion to various length units.
581
+ """
582
+ pPr = self._p.pPr
583
+ if pPr is None:
584
+ return None
585
+ return pPr.space_before
586
+
587
+ @space_before.setter
588
+ def space_before(self, value: Length | None):
589
+ pPr = self._p.get_or_add_pPr()
590
+ pPr.space_before = value
591
+
592
+ @property
593
+ def text(self) -> str:
594
+ """Text of paragraph as a single string.
595
+
596
+ Read/write. This value is formed by concatenating the text in each run and field making up
597
+ the paragraph, adding a vertical-tab character (`"\\v"`) for each line-break element
598
+ (`<a:br>`, soft carriage-return) encountered.
599
+
600
+ While the encoding of line-breaks as a vertical tab might be surprising at first, doing so
601
+ is consistent with PowerPoint's clipboard copy behavior and allows a line-break to be
602
+ distinguished from a paragraph boundary within the str return value.
603
+
604
+ Assignment causes all content in the paragraph to be replaced. Each vertical-tab character
605
+ (`"\\v"`) in the assigned str is translated to a line-break, as is each line-feed
606
+ character (`"\\n"`). Contrast behavior of line-feed character in `TextFrame.text` setter.
607
+ If line-feed characters are intended to produce new paragraphs, use `TextFrame.text`
608
+ instead. Any other control characters in the assigned string are escaped as a hex
609
+ representation like "_x001B_" (for ESC (ASCII 27) in this example).
610
+ """
611
+ return "".join(elm.text for elm in self._element.content_children)
612
+
613
+ @text.setter
614
+ def text(self, text: str):
615
+ self.clear()
616
+ self._element.append_text(text)
617
+
618
+ @property
619
+ def _defRPr(self) -> CT_TextCharacterProperties:
620
+ """The element that defines the default run properties for runs in this paragraph.
621
+
622
+ Causes the element to be added if not present.
623
+ """
624
+ return self._pPr.get_or_add_defRPr()
625
+
626
+ @property
627
+ def _pPr(self) -> CT_TextParagraphProperties:
628
+ """Contains the properties for this paragraph.
629
+
630
+ Causes the element to be added if not present.
631
+ """
632
+ return self._p.get_or_add_pPr()
633
+
634
+
635
+ class _Run(Subshape):
636
+ """Text run object. Corresponds to `a:r` child element in a paragraph."""
637
+
638
+ def __init__(self, r: CT_RegularTextRun, parent: ProvidesPart):
639
+ super(_Run, self).__init__(parent)
640
+ self._r = r
641
+
642
+ @property
643
+ def font(self):
644
+ """|Font| instance containing run-level character properties for the text in this run.
645
+
646
+ Character properties can be and perhaps most often are inherited from parent objects such
647
+ as the paragraph and slide layout the run is contained in. Only those specifically
648
+ overridden at the run level are contained in the font object.
649
+ """
650
+ rPr = self._r.get_or_add_rPr()
651
+ return Font(rPr)
652
+
653
+ @lazyproperty
654
+ def hyperlink(self) -> _Hyperlink:
655
+ """Proxy for any `a:hlinkClick` element under the run properties element.
656
+
657
+ Created on demand, the hyperlink object is available whether an `a:hlinkClick` element is
658
+ present or not, and creates or deletes that element as appropriate in response to actions
659
+ on its methods and attributes.
660
+ """
661
+ rPr = self._r.get_or_add_rPr()
662
+ return _Hyperlink(rPr, self)
663
+
664
+ @property
665
+ def text(self):
666
+ """Read/write. A unicode string containing the text in this run.
667
+
668
+ Assignment replaces all text in the run. The assigned value can be a 7-bit ASCII
669
+ string, a UTF-8 encoded 8-bit string, or unicode. String values are converted to
670
+ unicode assuming UTF-8 encoding.
671
+
672
+ Any other control characters in the assigned string other than tab or newline
673
+ are escaped as a hex representation. For example, ESC (ASCII 27) is escaped as
674
+ "_x001B_". Contrast the behavior of `TextFrame.text` and `_Paragraph.text` with
675
+ respect to line-feed and vertical-tab characters.
676
+ """
677
+ return self._r.text
678
+
679
+ @text.setter
680
+ def text(self, text: str):
681
+ self._r.text = text
tasks/tasksmith-74f059424102/environment/source/src/pptx/types.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Abstract types used by `python-pptx`."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ from typing_extensions import Protocol
8
+
9
+ if TYPE_CHECKING:
10
+ from pptx.opc.package import XmlPart
11
+ from pptx.util import Length
12
+
13
+
14
+ class ProvidesExtents(Protocol):
15
+ """An object that has width and height."""
16
+
17
+ @property
18
+ def height(self) -> Length:
19
+ """Distance between top and bottom extents of shape in EMUs."""
20
+ ...
21
+
22
+ @property
23
+ def width(self) -> Length:
24
+ """Distance between left and right extents of shape in EMUs."""
25
+ ...
26
+
27
+
28
+ class ProvidesPart(Protocol):
29
+ """An object that provides access to its XmlPart.
30
+
31
+ This type is for objects that need access to their part, possibly because they need access to
32
+ the package or related parts.
33
+ """
34
+
35
+ @property
36
+ def part(self) -> XmlPart: ...
tasks/tasksmith-74f059424102/environment/source/src/pptx/util.py ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Utility functions and classes."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import functools
6
+ from typing import Any, Callable, Generic, TypeVar, cast
7
+
8
+
9
+ class Length(int):
10
+ """Base class for length classes Inches, Emu, Cm, Mm, and Pt.
11
+
12
+ Provides properties for converting length values to convenient units.
13
+ """
14
+
15
+ _EMUS_PER_INCH = 914400
16
+ _EMUS_PER_CENTIPOINT = 127
17
+ _EMUS_PER_CM = 360000
18
+ _EMUS_PER_MM = 36000
19
+ _EMUS_PER_PT = 12700
20
+
21
+ def __new__(cls, emu: int):
22
+ return int.__new__(cls, emu)
23
+
24
+ @property
25
+ def inches(self) -> float:
26
+ """Floating point length in inches."""
27
+ return self / float(self._EMUS_PER_INCH)
28
+
29
+ @property
30
+ def centipoints(self) -> int:
31
+ """Integer length in hundredths of a point (1/7200 inch).
32
+
33
+ Used internally because PowerPoint stores font size in centipoints.
34
+ """
35
+ return self // self._EMUS_PER_CENTIPOINT
36
+
37
+ @property
38
+ def cm(self) -> float:
39
+ """Floating point length in centimeters."""
40
+ return self / float(self._EMUS_PER_CM)
41
+
42
+ @property
43
+ def emu(self) -> int:
44
+ """Integer length in English Metric Units."""
45
+ return self
46
+
47
+ @property
48
+ def mm(self) -> float:
49
+ """Floating point length in millimeters."""
50
+ return self / float(self._EMUS_PER_MM)
51
+
52
+ @property
53
+ def pt(self) -> float:
54
+ """Floating point length in points."""
55
+ return self / float(self._EMUS_PER_PT)
56
+
57
+
58
+ class Inches(Length):
59
+ """Convenience constructor for length in inches."""
60
+
61
+ def __new__(cls, inches: float):
62
+ emu = int(inches * Length._EMUS_PER_INCH)
63
+ return Length.__new__(cls, emu)
64
+
65
+
66
+ class Centipoints(Length):
67
+ """Convenience constructor for length in hundredths of a point."""
68
+
69
+ def __new__(cls, centipoints: int):
70
+ emu = int(centipoints * Length._EMUS_PER_CENTIPOINT)
71
+ return Length.__new__(cls, emu)
72
+
73
+
74
+ class Cm(Length):
75
+ """Convenience constructor for length in centimeters."""
76
+
77
+ def __new__(cls, cm: float):
78
+ emu = int(cm * Length._EMUS_PER_CM)
79
+ return Length.__new__(cls, emu)
80
+
81
+
82
+ class Emu(Length):
83
+ """Convenience constructor for length in english metric units."""
84
+
85
+ def __new__(cls, emu: int):
86
+ return Length.__new__(cls, int(emu))
87
+
88
+
89
+ class Mm(Length):
90
+ """Convenience constructor for length in millimeters."""
91
+
92
+ def __new__(cls, mm: float):
93
+ emu = int(mm * Length._EMUS_PER_MM)
94
+ return Length.__new__(cls, emu)
95
+
96
+
97
+ class Pt(Length):
98
+ """Convenience value class for specifying a length in points."""
99
+
100
+ def __new__(cls, points: float):
101
+ emu = int(points * Length._EMUS_PER_PT)
102
+ return Length.__new__(cls, emu)
103
+
104
+
105
+ _T = TypeVar("_T")
106
+
107
+
108
+ class lazyproperty(Generic[_T]):
109
+ """Decorator like @property, but evaluated only on first access.
110
+
111
+ Like @property, this can only be used to decorate methods having only a `self` parameter, and
112
+ is accessed like an attribute on an instance, i.e. trailing parentheses are not used. Unlike
113
+ @property, the decorated method is only evaluated on first access; the resulting value is
114
+ cached and that same value returned on second and later access without re-evaluation of the
115
+ method.
116
+
117
+ Like @property, this class produces a *data descriptor* object, which is stored in the __dict__
118
+ of the *class* under the name of the decorated method ('fget' nominally). The cached value is
119
+ stored in the __dict__ of the *instance* under that same name.
120
+
121
+ Because it is a data descriptor (as opposed to a *non-data descriptor*), its `__get__()` method
122
+ is executed on each access of the decorated attribute; the __dict__ item of the same name is
123
+ "shadowed" by the descriptor.
124
+
125
+ While this may represent a performance improvement over a property, its greater benefit may be
126
+ its other characteristics. One common use is to construct collaborator objects, removing that
127
+ "real work" from the constructor, while still only executing once. It also de-couples client
128
+ code from any sequencing considerations; if it's accessed from more than one location, it's
129
+ assured it will be ready whenever needed.
130
+
131
+ Loosely based on: https://stackoverflow.com/a/6849299/1902513.
132
+
133
+ A lazyproperty is read-only. There is no counterpart to the optional "setter" (or deleter)
134
+ behavior of an @property. This is critically important to maintaining its immutability and
135
+ idempotence guarantees. Attempting to assign to a lazyproperty raises AttributeError
136
+ unconditionally.
137
+
138
+ The parameter names in the methods below correspond to this usage example::
139
+
140
+ class Obj(object)
141
+
142
+ @lazyproperty
143
+ def fget(self):
144
+ return 'some result'
145
+
146
+ obj = Obj()
147
+
148
+ Not suitable for wrapping a function (as opposed to a method) because it is not callable.
149
+ """
150
+
151
+ def __init__(self, fget: Callable[..., _T]) -> None:
152
+ """*fget* is the decorated method (a "getter" function).
153
+
154
+ A lazyproperty is read-only, so there is only an *fget* function (a regular
155
+ @property can also have an fset and fdel function). This name was chosen for
156
+ consistency with Python's `property` class which uses this name for the
157
+ corresponding parameter.
158
+ """
159
+ # --- maintain a reference to the wrapped getter method
160
+ self._fget = fget
161
+ # --- and store the name of that decorated method
162
+ self._name = fget.__name__
163
+ # --- adopt fget's __name__, __doc__, and other attributes
164
+ functools.update_wrapper(self, fget) # pyright: ignore
165
+
166
+ def __get__(self, obj: Any, type: Any = None) -> _T:
167
+ """Called on each access of 'fget' attribute on class or instance.
168
+
169
+ *self* is this instance of a lazyproperty descriptor "wrapping" the property
170
+ method it decorates (`fget`, nominally).
171
+
172
+ *obj* is the "host" object instance when the attribute is accessed from an
173
+ object instance, e.g. `obj = Obj(); obj.fget`. *obj* is None when accessed on
174
+ the class, e.g. `Obj.fget`.
175
+
176
+ *type* is the class hosting the decorated getter method (`fget`) on both class
177
+ and instance attribute access.
178
+ """
179
+ # --- when accessed on class, e.g. Obj.fget, just return this descriptor
180
+ # --- instance (patched above to look like fget).
181
+ if obj is None:
182
+ return self # type: ignore
183
+
184
+ # --- when accessed on instance, start by checking instance __dict__ for
185
+ # --- item with key matching the wrapped function's name
186
+ value = obj.__dict__.get(self._name)
187
+ if value is None:
188
+ # --- on first access, the __dict__ item will be absent. Evaluate fget()
189
+ # --- and store that value in the (otherwise unused) host-object
190
+ # --- __dict__ value of same name ('fget' nominally)
191
+ value = self._fget(obj)
192
+ obj.__dict__[self._name] = value
193
+ return cast(_T, value)
194
+
195
+ def __set__(self, obj: Any, value: Any) -> None:
196
+ """Raises unconditionally, to preserve read-only behavior.
197
+
198
+ This decorator is intended to implement immutable (and idempotent) object
199
+ attributes. For that reason, assignment to this property must be explicitly
200
+ prevented.
201
+
202
+ If this __set__ method was not present, this descriptor would become a
203
+ *non-data descriptor*. That would be nice because the cached value would be
204
+ accessed directly once set (__dict__ attrs have precedence over non-data
205
+ descriptors on instance attribute lookup). The problem is, there would be
206
+ nothing to stop assignment to the cached value, which would overwrite the result
207
+ of `fget()` and break both the immutability and idempotence guarantees of this
208
+ decorator.
209
+
210
+ The performance with this __set__() method in place was roughly 0.4 usec per
211
+ access when measured on a 2.8GHz development machine; so quite snappy and
212
+ probably not a rich target for optimization efforts.
213
+ """
214
+ raise AttributeError("can't set attribute")
tasks/tasksmith-74f059424102/environment/source/src/python_pptx.egg-info/PKG-INFO ADDED
@@ -0,0 +1,599 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.4
2
+ Name: python-pptx
3
+ Version: 0.6.23
4
+ Summary: Generate and manipulate Open XML PowerPoint (.pptx) files
5
+ Home-page: https://github.com/scanny/python-pptx
6
+ Author: Steve Canny
7
+ Author-email: python-pptx@googlegroups.com
8
+ License: MIT
9
+ Keywords: powerpoint ppt pptx office open xml
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 2
17
+ Classifier: Programming Language :: Python :: 2.7
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.6
20
+ Classifier: Topic :: Office/Business :: Office Suites
21
+ Classifier: Topic :: Software Development :: Libraries
22
+ Description-Content-Type: text/x-rst
23
+ License-File: LICENSE
24
+ Requires-Dist: lxml>=3.1.0
25
+ Requires-Dist: Pillow>=3.3.2
26
+ Requires-Dist: XlsxWriter>=0.5.7
27
+ Dynamic: author
28
+ Dynamic: author-email
29
+ Dynamic: classifier
30
+ Dynamic: description
31
+ Dynamic: description-content-type
32
+ Dynamic: home-page
33
+ Dynamic: keywords
34
+ Dynamic: license
35
+ Dynamic: license-file
36
+ Dynamic: requires-dist
37
+ Dynamic: summary
38
+
39
+ *python-pptx* is a Python library for creating, reading, and updating PowerPoint (.pptx)
40
+ files.
41
+
42
+ A typical use would be generating a PowerPoint presentation from dynamic content such as
43
+ a database query, analytics output, or a JSON payload, perhaps in response to an HTTP
44
+ request and downloading the generated PPTX file in response. It runs on any Python
45
+ capable platform, including macOS and Linux, and does not require the PowerPoint
46
+ application to be installed or licensed.
47
+
48
+ It can also be used to analyze PowerPoint files from a corpus, perhaps to extract search
49
+ indexing text and images.
50
+
51
+ In can also be used to simply automate the production of a slide or two that would be
52
+ tedious to get right by hand, which is how this all got started.
53
+
54
+ More information is available in the `python-pptx documentation`_.
55
+
56
+ Browse `examples with screenshots`_ to get a quick idea what you can do with
57
+ python-pptx.
58
+
59
+ .. _`python-pptx documentation`:
60
+ https://python-pptx.readthedocs.org/en/latest/
61
+
62
+ .. _`examples with screenshots`:
63
+ https://python-pptx.readthedocs.org/en/latest/user/quickstart.html
64
+
65
+
66
+ .. :changelog:
67
+
68
+ Release History
69
+ ---------------
70
+
71
+ 0.6.24-dev0
72
+ +++++++++++++++++++
73
+
74
+ - fix: #943 remove mention of a Px Length subtype
75
+
76
+ 0.6.23 (2023-11-02)
77
+ +++++++++++++++++++
78
+
79
+ - fix: #912 Pillow<=9.5 constraint entails security vulnerability
80
+
81
+
82
+ 0.6.22 (2023-08-28)
83
+ +++++++++++++++++++
84
+
85
+ - Add #909 Add imgW, imgH params to `shapes.add_ole_object()`
86
+ - fix: #754 _Relationships.items() raises
87
+ - fix: #758 quote in autoshape name must be escaped
88
+ - fix: #746 update Python 3.x support in docs
89
+ - fix: #748 setup's `license` should be short string
90
+ - fix: #762 AttributeError: module 'collections' has no attribute 'abc'
91
+ (Windows Python 3.10+)
92
+
93
+
94
+ 0.6.21 (2021-09-20)
95
+ +++++++++++++++++++
96
+
97
+ - Fix #741 _DirPkgReader must implement .__contains__()
98
+
99
+
100
+ 0.6.20 (2021-09-14)
101
+ +++++++++++++++++++
102
+
103
+ - Fix #206 accommodate NULL target-references in relationships.
104
+ - Fix #223 escape image filename that appears as literal in XML.
105
+ - Fix #517 option to display chart categories/values in reverse order.
106
+ - Major refactoring of ancient package loading code.
107
+
108
+
109
+ 0.6.19 (2021-05-17)
110
+ +++++++++++++++++++
111
+
112
+ - Add shapes.add_ole_object(), allowing arbitrary Excel or other binary file to be
113
+ embedded as a shape on a slide. The OLE object is represented as an icon.
114
+
115
+
116
+ 0.6.18 (2019-05-02)
117
+ +++++++++++++++++++
118
+
119
+ - .text property getters encode line-break as a vertical-tab (VT, '\v', ASCII 11/x0B).
120
+ This is consistent with PowerPoint's copy/paste behavior and allows like-breaks (soft
121
+ carriage-return) to be distinguished from paragraph boundary. Previously, a line-break
122
+ was encoded as a newline ('\n') and was not distinguishable from a paragraph boundary.
123
+
124
+ .text properties include Shape.text, _Cell.text, TextFrame.text, _Paragraph.text and
125
+ _Run.text.
126
+
127
+ - .text property setters accept vertical-tab character and place a line-break element in
128
+ that location. All other control characters other than horizontal-tab ('\t') and
129
+ newline ('\n') in range \x00-\x1F are accepted and escaped with plain-text like
130
+ "_x001B" for ESC (ASCII 27).
131
+
132
+ Previously a control character other than tab or newline in an assigned string would
133
+ trigger an exception related to invalid XML character.
134
+
135
+
136
+ 0.6.17 (2018-12-16)
137
+ +++++++++++++++++++
138
+
139
+ - Add SlideLayouts.remove() - Delete unused slide-layout
140
+ - Add SlideLayout.used_by_slides - Get slides based on this slide-layout
141
+ - Add SlideLayouts.index() - Get index of slide-layout in master
142
+ - Add SlideLayouts.get_by_name() - Get slide-layout by its str name
143
+
144
+
145
+ 0.6.16 (2018-11-09)
146
+ +++++++++++++++++++
147
+
148
+ - Feature #395 DataLabels.show_* properties, e.g. .show_percentage
149
+ - Feature #453 Chart data tolerates None for labels
150
+
151
+
152
+ 0.6.15 (2018-09-24)
153
+ +++++++++++++++++++
154
+
155
+ - Fix #436 ValueAxis._cross_xAx fails on c:dateAxis
156
+
157
+
158
+ 0.6.14 (2018-09-24)
159
+ +++++++++++++++++++
160
+
161
+ - Add _Cell.merge()
162
+ - Add _Cell.split()
163
+ - Add _Cell.__eq__()
164
+ - Add _Cell.is_merge_origin
165
+ - Add _Cell.is_spanned
166
+ - Add _Cell.span_height
167
+ - Add _Cell.span_width
168
+ - Add _Cell.text getter
169
+ - Add Table.iter_cells()
170
+ - Move pptx.shapes.table module to pptx.table
171
+ - Add user documentation 'Working with tables'
172
+
173
+
174
+ 0.6.13 (2018-09-10)
175
+ +++++++++++++++++++
176
+
177
+ - Add Chart.font
178
+ - Fix #293 Can't hide title of single-series Chart
179
+ - Fix shape.width value is not type Emu
180
+ - Fix add a:defRPr with c:rich (fixes some font inheritance breakage)
181
+
182
+
183
+ 0.6.12 (2018-08-11)
184
+ +++++++++++++++++++
185
+
186
+ - Add Picture.auto_shape_type
187
+ - Remove Python 2.6 testing from build
188
+ - Update dependencies to avoid vulnerable Pillow version
189
+ - Fix #260, #301, #382, #401
190
+ - Add _Paragraph.add_line_break()
191
+ - Add Connector.line
192
+
193
+
194
+ 0.6.11 (2018-07-25)
195
+ +++++++++++++++++++
196
+
197
+ - Add gradient fill.
198
+ - Add experimental "turbo-add" option for producing large shape-count slides.
199
+
200
+
201
+ 0.6.10 (2018-06-11)
202
+ +++++++++++++++++++
203
+
204
+ - Add `shape.shadow` property to autoshape, connector, picture, and group
205
+ shape, returning a `ShadowFormat` object.
206
+ - Add `ShadowFormat` object with read/write (boolean) `.inherit` property.
207
+ - Fix #328 add support for 26+ series in a chart
208
+
209
+
210
+ 0.6.9 (2018-05-08)
211
+ ++++++++++++++++++
212
+
213
+ - Add `Picture.crop_x` setters, allowing picture cropping values to be set,
214
+ in addition to interrogated.
215
+ - Add `Slide.background` and `SlideMaster.background`, allowing the
216
+ background fill to be set for an individual slide or for all slides based
217
+ on a slide master.
218
+ - Add option `shapes` parameter to `Shapes.add_group_shape`, allowing a group
219
+ shape to be formed from a number of existing shapes.
220
+ - Improve efficiency of `Shapes._next_shape_id` property to improve
221
+ performance on high shape-count slides.
222
+
223
+
224
+ 0.6.8 (2018-04-18)
225
+ ++++++++++++++++++
226
+
227
+ - Add `GroupShape`, providing properties specific to a group shape, including
228
+ its `shapes` property.
229
+ - Add `GroupShapes`, providing access to shapes contained in a group shape.
230
+ - Add `SlideShapes.add_group_shape()`, allowing a group shape to be added to
231
+ a slide.
232
+ - Add `GroupShapes.add_group_shape()`, allowing a group shape to be added to
233
+ a group shape, enabling recursive, multi-level groups.
234
+ - Add support for adding jump-to-named-slide behavior to shape and run
235
+ hyperlinks.
236
+
237
+
238
+ 0.6.7 (2017-10-30)
239
+ ++++++++++++++++++
240
+
241
+ - Add `SlideShapes.build_freeform()`, allowing freeform shapes (such as maps)
242
+ to be specified and added to a slide.
243
+ - Add support for patterned fills.
244
+ - Add `LineFormat.dash_style` to allow interrogation and setting of dashed
245
+ line styles.
246
+
247
+
248
+ 0.6.6 (2017-06-17)
249
+ ++++++++++++++++++
250
+
251
+ - Add `SlideShapes.add_movie()`, allowing video media to be added to a slide.
252
+
253
+ - fix #190 Accommodate non-conforming part names having '00' index segment.
254
+ - fix #273 Accommodate non-conforming part names having no index segment.
255
+ - fix #277 ASCII/Unicode error on non-ASCII multi-level category names
256
+ - fix #279 BaseShape.id warning appearing on placeholder access.
257
+
258
+
259
+ 0.6.5 (2017-03-21)
260
+ ++++++++++++++++++
261
+
262
+ - #267 compensate for non-conforming PowerPoint behavior on c:overlay element
263
+
264
+ - compensate for non-conforming (to spec) PowerPoint behavior related to
265
+ c:dLbl/c:tx that results in "can't save" error when explicit data labels
266
+ are added to bubbles on a bubble chart.
267
+
268
+
269
+ 0.6.4 (2017-03-17)
270
+ ++++++++++++++++++
271
+
272
+ - add Chart.chart_title and ChartTitle object
273
+ - #263 Use Number type to test for numeric category
274
+
275
+
276
+ 0.6.3 (2017-02-28)
277
+ ++++++++++++++++++
278
+
279
+ - add DataLabel.font
280
+ - add Axis.axis_title
281
+
282
+
283
+ 0.6.2 (2017-01-03)
284
+ ++++++++++++++++++
285
+
286
+ - add support for NotesSlide (slide notes, aka. notes page)
287
+ - add support for arbitrary series ordering in XML
288
+ - add Plot.categories providing access to hierarchical categories in an
289
+ existing chart.
290
+ - add support for date axes on category charts, including writing a dateAx
291
+ element for the category axis when ChartData categories are date or
292
+ datetime.
293
+
294
+ **BACKWARD INCOMPATIBILITIES:**
295
+
296
+ Some changes were made to the boilerplate XML used to create new charts. This
297
+ was done to more closely adhere to the settings PowerPoint uses when creating
298
+ a chart using the UI. This may result in some appearance changes in charts
299
+ after upgrading. In particular:
300
+
301
+ * Chart.has_legend now defaults to True for Line charts.
302
+ * Plot.vary_by_categories now defaults to False for Line charts.
303
+
304
+
305
+ 0.6.1 (2016-10-09)
306
+ ++++++++++++++++++
307
+
308
+ - add Connector shape type
309
+
310
+
311
+ 0.6.0 (2016-08-18)
312
+ ++++++++++++++++++
313
+
314
+ - add XY chart types
315
+ - add Bubble chart types
316
+ - add Radar chart types
317
+ - add Area chart types
318
+ - add Doughnut chart types
319
+ - add Series.points and Point
320
+ - add Point.data_label
321
+ - add DataLabel.text_frame
322
+ - add DataLabel.position
323
+ - add Axis.major_gridlines
324
+ - add ChartFormat with .fill and .line
325
+ - add Axis.format (fill and line formatting)
326
+ - add ValueAxis.crosses and .crosses_at
327
+ - add Point.format (fill and line formatting)
328
+ - add Slide.slide_id
329
+ - add Slides.get() (by slide id)
330
+ - add Font.language_id
331
+ - support blank (None) data points in created charts
332
+ - add Series.marker
333
+ - add Point.marker
334
+ - add Marker.format, .style, and .size
335
+
336
+
337
+ 0.5.8 (2015-11-27)
338
+ ++++++++++++++++++
339
+
340
+ - add Shape.click_action (hyperlink on shape)
341
+ - fix: #128 Chart cat and ser names not escaped
342
+ - fix: #153 shapes.title raises on no title shape
343
+ - fix: #170 remove seek(0) from Image.from_file()
344
+
345
+
346
+ 0.5.7 (2015-01-17)
347
+ ++++++++++++++++++
348
+
349
+ - add PicturePlaceholder with .insert_picture() method
350
+ - add TablePlaceholder with .insert_table() method
351
+ - add ChartPlaceholder with .insert_chart() method
352
+ - add Picture.image property, returning Image object
353
+ - add Picture.crop_left, .crop_top, .crop_right, and .crop_bottom
354
+ - add Shape.placeholder_format and PlaceholderFormat object
355
+
356
+ **BACKWARD INCOMPATIBILITIES:**
357
+
358
+ Shape.shape_type is now unconditionally `MSO_SHAPE_TYPE.PLACEHOLDER` for all
359
+ placeholder shapes. Previously, some placeholder shapes reported
360
+ `MSO_SHAPE_TYPE.AUTO_SHAPE`, `MSO_SHAPE_TYPE.CHART`,
361
+ `MSO_SHAPE_TYPE.PICTURE`, or `MSO_SHAPE_TYPE.TABLE` for that property.
362
+
363
+
364
+ 0.5.6 (2014-12-06)
365
+ ++++++++++++++++++
366
+
367
+ - fix #138 - UnicodeDecodeError in setup.py on Windows 7 Python 3.4
368
+
369
+
370
+ 0.5.5 (2014-11-17)
371
+ ++++++++++++++++++
372
+
373
+ - feature #51 - add Python 3 support
374
+
375
+
376
+ 0.5.4 (2014-11-15)
377
+ ++++++++++++++++++
378
+
379
+ - feature #43 - image native size in shapes.add_picture() is now calculated
380
+ based on DPI attribute in image file, if present, defaulting to 72 dpi.
381
+ - feature #113 - Add Paragraph.space_before, Paragraph.space_after, and
382
+ Paragraph.line_spacing
383
+
384
+
385
+ 0.5.3 (2014-11-09)
386
+ ++++++++++++++++++
387
+
388
+ - add experimental feature TextFrame.fit_text()
389
+
390
+
391
+ 0.5.2 (2014-10-26)
392
+ ++++++++++++++++++
393
+
394
+ - fix #127 - Shape.text_frame fails on shape having no txBody
395
+
396
+
397
+ 0.5.1 (2014-09-22)
398
+ ++++++++++++++++++
399
+
400
+ - feature #120 - add Shape.rotation
401
+ - feature #97 - add Font.underline
402
+ - issue #117 - add BMP image support
403
+ - issue #95 - add BaseShape.name setter
404
+ - issue #107 - all .text properties should return unicode, not str
405
+ - feature #106 - add .text getters to Shape, TextFrame, and Paragraph
406
+
407
+ - Rename Shape.textframe to Shape.text_frame.
408
+ **Shape.textframe property (by that name) is deprecated.**
409
+
410
+
411
+ 0.5.0 (2014-09-13)
412
+ ++++++++++++++++++
413
+
414
+ - Add support for creating and manipulating bar, column, line, and pie charts
415
+ - Major refactoring of XML layer (oxml)
416
+ - Rationalized graphical object shape access
417
+ **Note backward incompatibilities below**
418
+
419
+ **BACKWARD INCOMPATIBILITIES:**
420
+
421
+ A table is no longer treated as a shape. Rather it is a graphical object
422
+ contained in a GraphicFrame shape, as are Chart and SmartArt objects.
423
+
424
+ Example::
425
+
426
+ table = shapes.add_table(...)
427
+
428
+ # becomes
429
+
430
+ graphic_frame = shapes.add_table(...)
431
+ table = graphic_frame.table
432
+
433
+ # or
434
+
435
+ table = shapes.add_table(...).table
436
+
437
+ As the enclosing shape, the id, name, shape type, position, and size are
438
+ attributes of the enclosing GraphicFrame object.
439
+
440
+ The contents of a GraphicFrame shape can be identified using three available
441
+ properties on a shape: has_table, has_chart, and has_smart_art. The enclosed
442
+ graphical object is obtained using the properties GraphicFrame.table and
443
+ GraphicFrame.chart. SmartArt is not yet supported. Accessing one of these
444
+ properties on a GraphicFrame not containing the corresponding object raises
445
+ an exception.
446
+
447
+
448
+ 0.4.2 (2014-04-29)
449
+ ++++++++++++++++++
450
+
451
+ - fix: issue #88 -- raises on supported image file having uppercase extension
452
+ - fix: issue #89 -- raises on add_slide() where non-contiguous existing ids
453
+
454
+
455
+ 0.4.1 (2014-04-29)
456
+ ++++++++++++++++++
457
+
458
+ - Rename Presentation.slidemasters to Presentation.slide_masters.
459
+ Presentation.slidemasters property is deprecated.
460
+ - Rename Presentation.slidelayouts to Presentation.slide_layouts.
461
+ Presentation.slidelayouts property is deprecated.
462
+ - Rename SlideMaster.slidelayouts to SlideMaster.slide_layouts.
463
+ SlideMaster.slidelayouts property is deprecated.
464
+ - Rename SlideLayout.slidemaster to SlideLayout.slide_master.
465
+ SlideLayout.slidemaster property is deprecated.
466
+ - Rename Slide.slidelayout to Slide.slide_layout. Slide.slidelayout property
467
+ is deprecated.
468
+ - Add SlideMaster.shapes to access shapes on slide master.
469
+ - Add SlideMaster.placeholders to access placeholder shapes on slide master.
470
+ - Add _MasterPlaceholder class.
471
+ - Add _LayoutPlaceholder class with position and size inheritable from master
472
+ placeholder.
473
+ - Add _SlidePlaceholder class with position and size inheritable from layout
474
+ placeholder.
475
+ - Add Table.left, top, width, and height read/write properties.
476
+ - Add rudimentary GroupShape with left, top, width, and height properties.
477
+ - Add rudimentary Connector with left, top, width, and height properties.
478
+ - Add TextFrame.auto_size property.
479
+ - Add Presentation.slide_width and .slide_height read/write properties.
480
+ - Add LineFormat class providing access to read and change line color and
481
+ width.
482
+ - Add AutoShape.line
483
+ - Add Picture.line
484
+
485
+ - Rationalize enumerations. **Note backward incompatibilities below**
486
+
487
+ **BACKWARD INCOMPATIBILITIES:**
488
+
489
+ The following enumerations were moved/renamed during the rationalization of
490
+ enumerations:
491
+
492
+ - ``pptx.enum.MSO_COLOR_TYPE`` --> ``pptx.enum.dml.MSO_COLOR_TYPE``
493
+ - ``pptx.enum.MSO_FILL`` --> ``pptx.enum.dml.MSO_FILL``
494
+ - ``pptx.enum.MSO_THEME_COLOR`` --> ``pptx.enum.dml.MSO_THEME_COLOR``
495
+ - ``pptx.constants.MSO.ANCHOR_*`` --> ``pptx.enum.text.MSO_ANCHOR.*``
496
+ - ``pptx.constants.MSO_SHAPE`` --> ``pptx.enum.shapes.MSO_SHAPE``
497
+ - ``pptx.constants.PP.ALIGN_*`` --> ``pptx.enum.text.PP_ALIGN.*``
498
+ - ``pptx.constants.MSO.{SHAPE_TYPES}`` -->
499
+ ``pptx.enum.shapes.MSO_SHAPE_TYPE.*``
500
+
501
+ Documentation for all enumerations is available in the Enumerations section
502
+ of the User Guide.
503
+
504
+
505
+ 0.3.2 (2014-02-07)
506
+ ++++++++++++++++++
507
+
508
+ - Hotfix: issue #80 generated presentations fail to load in Keynote and other
509
+ Apple applications
510
+
511
+
512
+ 0.3.1 (2014-01-10)
513
+ ++++++++++++++++++
514
+
515
+ - Hotfix: failed to load certain presentations containing images with
516
+ uppercase extension
517
+
518
+
519
+ 0.3.0 (2013-12-12)
520
+ ++++++++++++++++++
521
+
522
+ - Add read/write font color property supporting RGB, theme color, and inherit
523
+ color types
524
+ - Add font typeface and italic support
525
+ - Add text frame margins and word-wrap
526
+ - Add support for external relationships, e.g. linked spreadsheet
527
+ - Add hyperlink support for text run in shape and table cell
528
+ - Add fill color and brightness for shape and table cell, fill can also be set
529
+ to transparent (no fill)
530
+ - Add read/write position and size properties to shape and picture
531
+ - Replace PIL dependency with Pillow
532
+ - Restructure modules to better suit size of library
533
+
534
+
535
+ 0.2.6 (2013-06-22)
536
+ ++++++++++++++++++
537
+
538
+ - Add read/write access to core document properties
539
+ - Hotfix to accomodate connector shapes in _AutoShapeType
540
+ - Hotfix to allow customXml parts to load when present
541
+
542
+
543
+ 0.2.5 (2013-06-11)
544
+ ++++++++++++++++++
545
+
546
+ - Add paragraph alignment property (left, right, centered, etc.)
547
+ - Add vertical alignment within table cell (top, middle, bottom)
548
+ - Add table cell margin properties
549
+ - Add table boolean properties: first column (row header), first row (column
550
+ headings), last row (for e.g. totals row), last column (for e.g. row
551
+ totals), horizontal banding, and vertical banding.
552
+ - Add support for auto shape adjustment values, e.g. change radius of corner
553
+ rounding on rounded rectangle, position of callout arrow, etc.
554
+
555
+
556
+ 0.2.4 (2013-05-16)
557
+ ++++++++++++++++++
558
+
559
+ - Add support for auto shapes (e.g. polygons, flowchart symbols, etc.)
560
+
561
+
562
+ 0.2.3 (2013-05-05)
563
+ ++++++++++++++++++
564
+
565
+ - Add support for table shapes
566
+ - Add indentation support to textbox shapes, enabling multi-level bullets on
567
+ bullet slides.
568
+
569
+
570
+ 0.2.2 (2013-03-25)
571
+ ++++++++++++++++++
572
+
573
+ - Add support for opening and saving a presentation from/to a file-like
574
+ object.
575
+ - Refactor XML handling to use lxml objectify
576
+
577
+
578
+ 0.2.1 (2013-02-25)
579
+ ++++++++++++++++++
580
+
581
+ - Add support for Python 2.6
582
+ - Add images from a stream (e.g. StringIO) in addition to a path, allowing
583
+ images retrieved from a database or network resource to be inserted without
584
+ saving first.
585
+ - Expand text methods to accept unicode and UTF-8 encoded 8-bit strings.
586
+ - Fix potential install bug triggered by importing ``__version__`` from
587
+ package ``__init__.py`` file.
588
+
589
+
590
+ 0.2.0 (2013-02-10)
591
+ ++++++++++++++++++
592
+
593
+ First non-alpha release with basic capabilities:
594
+
595
+ - open presentation/template or use built-in default template
596
+ - add slide
597
+ - set placeholder text (e.g. bullet slides)
598
+ - add picture
599
+ - add text box
tasks/tasksmith-74f059424102/environment/source/src/python_pptx.egg-info/SOURCES.txt ADDED
@@ -0,0 +1,502 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ HISTORY.rst
2
+ LICENSE
3
+ MANIFEST.in
4
+ README.rst
5
+ pyproject.toml
6
+ setup.cfg
7
+ setup.py
8
+ tox.ini
9
+ features/act-action.feature
10
+ features/act-hyperlink.feature
11
+ features/cht-axis-props.feature
12
+ features/cht-axistitle-props.feature
13
+ features/cht-category-access.feature
14
+ features/cht-category-props.feature
15
+ features/cht-chart.feature
16
+ features/cht-charttitle-props.feature
17
+ features/cht-data-props.feature
18
+ features/cht-datalabels.feature
19
+ features/cht-gridlines-props.feature
20
+ features/cht-legend-access.feature
21
+ features/cht-legend-props.feature
22
+ features/cht-marker-props.feature
23
+ features/cht-plot-props.feature
24
+ features/cht-point-access.feature
25
+ features/cht-point-props.feature
26
+ features/cht-replace-data.feature
27
+ features/cht-series.feature
28
+ features/cht-ticklabels-props.feature
29
+ features/dml-color.feature
30
+ features/dml-effect.feature
31
+ features/dml-fill.feature
32
+ features/dml-line.feature
33
+ features/environment.py
34
+ features/ph-inherit-props.feature
35
+ features/ph-insert-shape.feature
36
+ features/ph-phfmt-props.feature
37
+ features/ph-placeholder-props.feature
38
+ features/prs-coreprops.feature
39
+ features/prs-default-template.feature
40
+ features/prs-open-save.feature
41
+ features/prs-presentation-props.feature
42
+ features/shp-autoshape.feature
43
+ features/shp-connector.feature
44
+ features/shp-freeform.feature
45
+ features/shp-graphicframe.feature
46
+ features/shp-groupshape.feature
47
+ features/shp-movie-props.feature
48
+ features/shp-picture.feature
49
+ features/shp-placeholder.feature
50
+ features/shp-shapes.feature
51
+ features/shp-shared.feature
52
+ features/sld-background.feature
53
+ features/sld-slide.feature
54
+ features/sld-slides.feature
55
+ features/tbl-cell.feature
56
+ features/tbl-column.feature
57
+ features/tbl-table.feature
58
+ features/txt-fit-text.feature
59
+ features/txt-font-color.feature
60
+ features/txt-font-props.feature
61
+ features/txt-paragraph.feature
62
+ features/txt-text.feature
63
+ features/txt-textframe.feature
64
+ features/steps/action.py
65
+ features/steps/axis.py
66
+ features/steps/background.py
67
+ features/steps/category.py
68
+ features/steps/chart.py
69
+ features/steps/chartdata.py
70
+ features/steps/color.py
71
+ features/steps/coreprops.py
72
+ features/steps/datalabel.py
73
+ features/steps/effect.py
74
+ features/steps/fill.py
75
+ features/steps/font.py
76
+ features/steps/font_color.py
77
+ features/steps/helpers.py
78
+ features/steps/legend.py
79
+ features/steps/line.py
80
+ features/steps/picture.py
81
+ features/steps/placeholder.py
82
+ features/steps/plot.py
83
+ features/steps/presentation.py
84
+ features/steps/series.py
85
+ features/steps/shape.py
86
+ features/steps/shapes.py
87
+ features/steps/slide.py
88
+ features/steps/slides.py
89
+ features/steps/table.py
90
+ features/steps/text.py
91
+ features/steps/text_frame.py
92
+ features/steps/test_files/72-dpi.tiff
93
+ features/steps/test_files/CVS_LOGO.WMF
94
+ features/steps/test_files/act-props.pptm
95
+ features/steps/test_files/calibriz.ttf
96
+ features/steps/test_files/cht-axis-props.pptx
97
+ features/steps/test_files/cht-category-access.pptx
98
+ features/steps/test_files/cht-chart-props.pptx
99
+ features/steps/test_files/cht-chart-type.pptx
100
+ features/steps/test_files/cht-charts.pptx
101
+ features/steps/test_files/cht-datalabels.pptx
102
+ features/steps/test_files/cht-gridlines-props.pptx
103
+ features/steps/test_files/cht-legend-props.pptx
104
+ features/steps/test_files/cht-legend.pptx
105
+ features/steps/test_files/cht-marker-props.pptx
106
+ features/steps/test_files/cht-plot-props.pptx
107
+ features/steps/test_files/cht-point-access.pptx
108
+ features/steps/test_files/cht-point-props.pptx
109
+ features/steps/test_files/cht-replace-data.pptx
110
+ features/steps/test_files/cht-series.pptx
111
+ features/steps/test_files/cht-ticklabels-props.pptx
112
+ features/steps/test_files/dml-effect.pptx
113
+ features/steps/test_files/dml-fill.pptx
114
+ features/steps/test_files/dml-line.pptx
115
+ features/steps/test_files/ext-rels.pptx
116
+ features/steps/test_files/font-color.pptx
117
+ features/steps/test_files/just-two-mice.mp4
118
+ features/steps/test_files/just-two-mice.png
119
+ features/steps/test_files/lyt-shapes.pptx
120
+ features/steps/test_files/minimal.pptx
121
+ features/steps/test_files/monty-truth.png
122
+ features/steps/test_files/mst-placeholders.pptx
123
+ features/steps/test_files/mst-shapes.pptx
124
+ features/steps/test_files/mst-slide-layouts.pptx
125
+ features/steps/test_files/ph-inherit-props.pptx
126
+ features/steps/test_files/ph-populated-placeholders.pptx
127
+ features/steps/test_files/ph-unpopulated-placeholders.pptx
128
+ features/steps/test_files/pic.emf
129
+ features/steps/test_files/prs-add-slide.pptx
130
+ features/steps/test_files/prs-notes.pptx
131
+ features/steps/test_files/prs-properties.pptx
132
+ features/steps/test_files/prs-slide-masters.pptx
133
+ features/steps/test_files/python-icon.jpeg
134
+ features/steps/test_files/python-powered.png
135
+ features/steps/test_files/python.bmp
136
+ features/steps/test_files/shp-access-chart.pptx
137
+ features/steps/test_files/shp-access-ole-object.pptx
138
+ features/steps/test_files/shp-autoshape-adjustments.pptx
139
+ features/steps/test_files/shp-autoshape-props.pptx
140
+ features/steps/test_files/shp-common-props.pptx
141
+ features/steps/test_files/shp-connector-props.pptx
142
+ features/steps/test_files/shp-embedded-docx.docx
143
+ features/steps/test_files/shp-embedded-pptx.pptx
144
+ features/steps/test_files/shp-embedded-xlsx.xlsx
145
+ features/steps/test_files/shp-freeform.pptx
146
+ features/steps/test_files/shp-groupshape.pptx
147
+ features/steps/test_files/shp-movie-props.pptx
148
+ features/steps/test_files/shp-picture.pptx
149
+ features/steps/test_files/shp-pos-and-size.pptx
150
+ features/steps/test_files/shp-shapes.pptx
151
+ features/steps/test_files/sld-background.pptx
152
+ features/steps/test_files/sld-blank.pptx
153
+ features/steps/test_files/sld-notes.pptx
154
+ features/steps/test_files/sld-slide.pptx
155
+ features/steps/test_files/sld-slides.pptx
156
+ features/steps/test_files/sonic.gif
157
+ features/steps/test_files/tbl-cell.pptx
158
+ features/steps/test_files/test.pptx
159
+ features/steps/test_files/txt-fit-text.pptx
160
+ features/steps/test_files/txt-font-props.pptx
161
+ features/steps/test_files/txt-font-typeface.pptx
162
+ features/steps/test_files/txt-paragraph-spacing.pptx
163
+ features/steps/test_files/txt-text-frame.pptx
164
+ features/steps/test_files/txt-text.pptx
165
+ features/steps/test_files/extracted-pptx/[Content_Types].xml
166
+ features/steps/test_files/extracted-pptx/_rels/.rels
167
+ features/steps/test_files/extracted-pptx/docProps/app.xml
168
+ features/steps/test_files/extracted-pptx/docProps/core.xml
169
+ features/steps/test_files/extracted-pptx/docProps/thumbnail.jpeg
170
+ features/steps/test_files/extracted-pptx/ppt/presProps.xml
171
+ features/steps/test_files/extracted-pptx/ppt/presentation.xml
172
+ features/steps/test_files/extracted-pptx/ppt/tableStyles.xml
173
+ features/steps/test_files/extracted-pptx/ppt/viewProps.xml
174
+ features/steps/test_files/extracted-pptx/ppt/_rels/presentation.xml.rels
175
+ features/steps/test_files/extracted-pptx/ppt/printerSettings/printerSettings1.bin
176
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/slideLayout1.xml
177
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/slideLayout10.xml
178
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/slideLayout11.xml
179
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/slideLayout2.xml
180
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/slideLayout3.xml
181
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/slideLayout4.xml
182
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/slideLayout5.xml
183
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/slideLayout6.xml
184
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/slideLayout7.xml
185
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/slideLayout8.xml
186
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/slideLayout9.xml
187
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/_rels/slideLayout1.xml.rels
188
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/_rels/slideLayout10.xml.rels
189
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/_rels/slideLayout11.xml.rels
190
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/_rels/slideLayout2.xml.rels
191
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/_rels/slideLayout3.xml.rels
192
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/_rels/slideLayout4.xml.rels
193
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/_rels/slideLayout5.xml.rels
194
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/_rels/slideLayout6.xml.rels
195
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/_rels/slideLayout7.xml.rels
196
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/_rels/slideLayout8.xml.rels
197
+ features/steps/test_files/extracted-pptx/ppt/slideLayouts/_rels/slideLayout9.xml.rels
198
+ features/steps/test_files/extracted-pptx/ppt/slideMasters/slideMaster1.xml
199
+ features/steps/test_files/extracted-pptx/ppt/slideMasters/_rels/slideMaster1.xml.rels
200
+ features/steps/test_files/extracted-pptx/ppt/slides/slide1.xml
201
+ features/steps/test_files/extracted-pptx/ppt/slides/_rels/slide1.xml.rels
202
+ features/steps/test_files/extracted-pptx/ppt/theme/theme1.xml
203
+ src/pptx/__init__.py
204
+ src/pptx/action.py
205
+ src/pptx/api.py
206
+ src/pptx/exc.py
207
+ src/pptx/media.py
208
+ src/pptx/package.py
209
+ src/pptx/presentation.py
210
+ src/pptx/shared.py
211
+ src/pptx/slide.py
212
+ src/pptx/spec.py
213
+ src/pptx/table.py
214
+ src/pptx/types.py
215
+ src/pptx/util.py
216
+ src/pptx/chart/__init__.py
217
+ src/pptx/chart/axis.py
218
+ src/pptx/chart/category.py
219
+ src/pptx/chart/chart.py
220
+ src/pptx/chart/data.py
221
+ src/pptx/chart/datalabel.py
222
+ src/pptx/chart/legend.py
223
+ src/pptx/chart/marker.py
224
+ src/pptx/chart/plot.py
225
+ src/pptx/chart/point.py
226
+ src/pptx/chart/series.py
227
+ src/pptx/chart/xlsx.py
228
+ src/pptx/chart/xmlwriter.py
229
+ src/pptx/dml/__init__.py
230
+ src/pptx/dml/chtfmt.py
231
+ src/pptx/dml/color.py
232
+ src/pptx/dml/effect.py
233
+ src/pptx/dml/fill.py
234
+ src/pptx/dml/line.py
235
+ src/pptx/enum/__init__.py
236
+ src/pptx/enum/action.py
237
+ src/pptx/enum/base.py
238
+ src/pptx/enum/chart.py
239
+ src/pptx/enum/dml.py
240
+ src/pptx/enum/lang.py
241
+ src/pptx/enum/shapes.py
242
+ src/pptx/enum/text.py
243
+ src/pptx/opc/__init__.py
244
+ src/pptx/opc/constants.py
245
+ src/pptx/opc/oxml.py
246
+ src/pptx/opc/package.py
247
+ src/pptx/opc/packuri.py
248
+ src/pptx/opc/serialized.py
249
+ src/pptx/opc/shared.py
250
+ src/pptx/opc/spec.py
251
+ src/pptx/oxml/__init__.py
252
+ src/pptx/oxml/action.py
253
+ src/pptx/oxml/coreprops.py
254
+ src/pptx/oxml/ns.py
255
+ src/pptx/oxml/presentation.py
256
+ src/pptx/oxml/simpletypes.py
257
+ src/pptx/oxml/slide.py
258
+ src/pptx/oxml/table.py
259
+ src/pptx/oxml/text.py
260
+ src/pptx/oxml/theme.py
261
+ src/pptx/oxml/xmlchemy.py
262
+ src/pptx/oxml/chart/__init__.py
263
+ src/pptx/oxml/chart/axis.py
264
+ src/pptx/oxml/chart/chart.py
265
+ src/pptx/oxml/chart/datalabel.py
266
+ src/pptx/oxml/chart/legend.py
267
+ src/pptx/oxml/chart/marker.py
268
+ src/pptx/oxml/chart/plot.py
269
+ src/pptx/oxml/chart/series.py
270
+ src/pptx/oxml/chart/shared.py
271
+ src/pptx/oxml/dml/__init__.py
272
+ src/pptx/oxml/dml/color.py
273
+ src/pptx/oxml/dml/fill.py
274
+ src/pptx/oxml/dml/line.py
275
+ src/pptx/oxml/shapes/__init__.py
276
+ src/pptx/oxml/shapes/autoshape.py
277
+ src/pptx/oxml/shapes/connector.py
278
+ src/pptx/oxml/shapes/graphfrm.py
279
+ src/pptx/oxml/shapes/groupshape.py
280
+ src/pptx/oxml/shapes/picture.py
281
+ src/pptx/oxml/shapes/shared.py
282
+ src/pptx/parts/__init__.py
283
+ src/pptx/parts/chart.py
284
+ src/pptx/parts/coreprops.py
285
+ src/pptx/parts/embeddedpackage.py
286
+ src/pptx/parts/image.py
287
+ src/pptx/parts/media.py
288
+ src/pptx/parts/presentation.py
289
+ src/pptx/parts/slide.py
290
+ src/pptx/shapes/__init__.py
291
+ src/pptx/shapes/autoshape.py
292
+ src/pptx/shapes/base.py
293
+ src/pptx/shapes/connector.py
294
+ src/pptx/shapes/freeform.py
295
+ src/pptx/shapes/graphfrm.py
296
+ src/pptx/shapes/group.py
297
+ src/pptx/shapes/picture.py
298
+ src/pptx/shapes/placeholder.py
299
+ src/pptx/shapes/shapetree.py
300
+ src/pptx/templates/default.pptx
301
+ src/pptx/templates/docx-icon.emf
302
+ src/pptx/templates/generic-icon.emf
303
+ src/pptx/templates/notes.xml
304
+ src/pptx/templates/notesMaster.xml
305
+ src/pptx/templates/pptx-icon.emf
306
+ src/pptx/templates/theme.xml
307
+ src/pptx/templates/xlsx-icon.emf
308
+ src/pptx/text/__init__.py
309
+ src/pptx/text/fonts.py
310
+ src/pptx/text/layout.py
311
+ src/pptx/text/text.py
312
+ src/python_pptx.egg-info/PKG-INFO
313
+ src/python_pptx.egg-info/SOURCES.txt
314
+ src/python_pptx.egg-info/dependency_links.txt
315
+ src/python_pptx.egg-info/not-zip-safe
316
+ src/python_pptx.egg-info/requires.txt
317
+ src/python_pptx.egg-info/top_level.txt
318
+ tests/__init__.py
319
+ tests/test_action.py
320
+ tests/test_api.py
321
+ tests/test_media.py
322
+ tests/test_package.py
323
+ tests/test_presentation.py
324
+ tests/test_shared.py
325
+ tests/test_slide.py
326
+ tests/test_table.py
327
+ tests/test_util.py
328
+ tests/unitdata.py
329
+ tests/chart/__init__.py
330
+ tests/chart/test_axis.py
331
+ tests/chart/test_category.py
332
+ tests/chart/test_chart.py
333
+ tests/chart/test_data.py
334
+ tests/chart/test_datalabel.py
335
+ tests/chart/test_legend.py
336
+ tests/chart/test_marker.py
337
+ tests/chart/test_plot.py
338
+ tests/chart/test_point.py
339
+ tests/chart/test_series.py
340
+ tests/chart/test_xlsx.py
341
+ tests/chart/test_xmlwriter.py
342
+ tests/dml/__init__.py
343
+ tests/dml/test_chtfmt.py
344
+ tests/dml/test_color.py
345
+ tests/dml/test_effect.py
346
+ tests/dml/test_fill.py
347
+ tests/dml/test_line.py
348
+ tests/enum/__init__.py
349
+ tests/enum/test_base.py
350
+ tests/enum/test_shapes.py
351
+ tests/opc/__init__.py
352
+ tests/opc/test_oxml.py
353
+ tests/opc/test_package.py
354
+ tests/opc/test_packuri.py
355
+ tests/opc/test_serialized.py
356
+ tests/oxml/__init__.py
357
+ tests/oxml/test___init__.py
358
+ tests/oxml/test_dml.py
359
+ tests/oxml/test_ns.py
360
+ tests/oxml/test_presentation.py
361
+ tests/oxml/test_simpletypes.py
362
+ tests/oxml/test_slide.py
363
+ tests/oxml/test_table.py
364
+ tests/oxml/test_theme.py
365
+ tests/oxml/test_xmlchemy.py
366
+ tests/oxml/shapes/__init__.py
367
+ tests/oxml/shapes/test_autoshape.py
368
+ tests/oxml/shapes/test_graphfrm.py
369
+ tests/oxml/shapes/test_groupshape.py
370
+ tests/oxml/shapes/test_picture.py
371
+ tests/oxml/unitdata/__init__.py
372
+ tests/oxml/unitdata/dml.py
373
+ tests/oxml/unitdata/shape.py
374
+ tests/oxml/unitdata/text.py
375
+ tests/parts/__init__.py
376
+ tests/parts/test_chart.py
377
+ tests/parts/test_coreprops.py
378
+ tests/parts/test_embeddedpackage.py
379
+ tests/parts/test_image.py
380
+ tests/parts/test_media.py
381
+ tests/parts/test_presentation.py
382
+ tests/parts/test_slide.py
383
+ tests/shapes/__init__.py
384
+ tests/shapes/test_autoshape.py
385
+ tests/shapes/test_base.py
386
+ tests/shapes/test_connector.py
387
+ tests/shapes/test_freeform.py
388
+ tests/shapes/test_graphfrm.py
389
+ tests/shapes/test_group.py
390
+ tests/shapes/test_picture.py
391
+ tests/shapes/test_placeholder.py
392
+ tests/shapes/test_shapetree.py
393
+ tests/test_files/calibriz.ttf
394
+ tests/test_files/cdw-logo.eps
395
+ tests/test_files/dummy.mp4
396
+ tests/test_files/minimal.pptx
397
+ tests/test_files/minimal_slide.xml
398
+ tests/test_files/missing_rels_item.pptx
399
+ tests/test_files/monty-truth.png
400
+ tests/test_files/no-core-props.pptx
401
+ tests/test_files/no-slides.pptx
402
+ tests/test_files/presentation.xml
403
+ tests/test_files/python-icon.jpeg
404
+ tests/test_files/python-powered.png
405
+ tests/test_files/python.bmp
406
+ tests/test_files/slideLayout1.xml
407
+ tests/test_files/test.pptx
408
+ tests/test_files/test_slides.pptx
409
+ tests/test_files/expanded_pptx/[Content_Types].xml
410
+ tests/test_files/expanded_pptx/_rels/.rels
411
+ tests/test_files/expanded_pptx/docProps/app.xml
412
+ tests/test_files/expanded_pptx/docProps/core.xml
413
+ tests/test_files/expanded_pptx/docProps/thumbnail.jpeg
414
+ tests/test_files/expanded_pptx/ppt/presProps.xml
415
+ tests/test_files/expanded_pptx/ppt/presentation.xml
416
+ tests/test_files/expanded_pptx/ppt/tableStyles.xml
417
+ tests/test_files/expanded_pptx/ppt/viewProps.xml
418
+ tests/test_files/expanded_pptx/ppt/_rels/presentation.xml.rels
419
+ tests/test_files/expanded_pptx/ppt/printerSettings/printerSettings1.bin
420
+ tests/test_files/expanded_pptx/ppt/slideLayouts/slideLayout1.xml
421
+ tests/test_files/expanded_pptx/ppt/slideLayouts/slideLayout10.xml
422
+ tests/test_files/expanded_pptx/ppt/slideLayouts/slideLayout11.xml
423
+ tests/test_files/expanded_pptx/ppt/slideLayouts/slideLayout2.xml
424
+ tests/test_files/expanded_pptx/ppt/slideLayouts/slideLayout3.xml
425
+ tests/test_files/expanded_pptx/ppt/slideLayouts/slideLayout4.xml
426
+ tests/test_files/expanded_pptx/ppt/slideLayouts/slideLayout5.xml
427
+ tests/test_files/expanded_pptx/ppt/slideLayouts/slideLayout6.xml
428
+ tests/test_files/expanded_pptx/ppt/slideLayouts/slideLayout7.xml
429
+ tests/test_files/expanded_pptx/ppt/slideLayouts/slideLayout8.xml
430
+ tests/test_files/expanded_pptx/ppt/slideLayouts/slideLayout9.xml
431
+ tests/test_files/expanded_pptx/ppt/slideLayouts/_rels/slideLayout1.xml.rels
432
+ tests/test_files/expanded_pptx/ppt/slideLayouts/_rels/slideLayout10.xml.rels
433
+ tests/test_files/expanded_pptx/ppt/slideLayouts/_rels/slideLayout11.xml.rels
434
+ tests/test_files/expanded_pptx/ppt/slideLayouts/_rels/slideLayout2.xml.rels
435
+ tests/test_files/expanded_pptx/ppt/slideLayouts/_rels/slideLayout3.xml.rels
436
+ tests/test_files/expanded_pptx/ppt/slideLayouts/_rels/slideLayout4.xml.rels
437
+ tests/test_files/expanded_pptx/ppt/slideLayouts/_rels/slideLayout5.xml.rels
438
+ tests/test_files/expanded_pptx/ppt/slideLayouts/_rels/slideLayout6.xml.rels
439
+ tests/test_files/expanded_pptx/ppt/slideLayouts/_rels/slideLayout7.xml.rels
440
+ tests/test_files/expanded_pptx/ppt/slideLayouts/_rels/slideLayout8.xml.rels
441
+ tests/test_files/expanded_pptx/ppt/slideLayouts/_rels/slideLayout9.xml.rels
442
+ tests/test_files/expanded_pptx/ppt/slideMasters/slideMaster1.xml
443
+ tests/test_files/expanded_pptx/ppt/slideMasters/_rels/slideMaster1.xml.rels
444
+ tests/test_files/expanded_pptx/ppt/slides/slide1.xml
445
+ tests/test_files/expanded_pptx/ppt/slides/_rels/slide1.xml.rels
446
+ tests/test_files/expanded_pptx/ppt/theme/theme1.xml
447
+ tests/test_files/snippets/2x2-area-date.txt
448
+ tests/test_files/snippets/2x2-area-float.txt
449
+ tests/test_files/snippets/2x2-area-stacked-100.txt
450
+ tests/test_files/snippets/2x2-area-stacked.txt
451
+ tests/test_files/snippets/2x2-area.txt
452
+ tests/test_files/snippets/2x2-bar-clustered-date.txt
453
+ tests/test_files/snippets/2x2-bar-clustered-float.txt
454
+ tests/test_files/snippets/2x2-bar-clustered.txt
455
+ tests/test_files/snippets/2x2-bar-stacked-100.txt
456
+ tests/test_files/snippets/2x2-bar-stacked.txt
457
+ tests/test_files/snippets/2x2-column-clustered.txt
458
+ tests/test_files/snippets/2x2-column-stacked-100.txt
459
+ tests/test_files/snippets/2x2-column-stacked.txt
460
+ tests/test_files/snippets/2x2-line-date.txt
461
+ tests/test_files/snippets/2x2-line-float.txt
462
+ tests/test_files/snippets/2x2-line-markers-stacked-100.txt
463
+ tests/test_files/snippets/2x2-line-markers-stacked.txt
464
+ tests/test_files/snippets/2x2-line-markers.txt
465
+ tests/test_files/snippets/2x2-line-stacked-100.txt
466
+ tests/test_files/snippets/2x2-line-stacked.txt
467
+ tests/test_files/snippets/2x2-line.txt
468
+ tests/test_files/snippets/2x3-bubble-3d.txt
469
+ tests/test_files/snippets/2x3-bubble.txt
470
+ tests/test_files/snippets/2x3-xy-lines-no-markers.txt
471
+ tests/test_files/snippets/2x3-xy-lines.txt
472
+ tests/test_files/snippets/2x3-xy-smooth-no-markers.txt
473
+ tests/test_files/snippets/2x3-xy-smooth.txt
474
+ tests/test_files/snippets/2x3-xy.txt
475
+ tests/test_files/snippets/2x5-radar.txt
476
+ tests/test_files/snippets/3x1-pie-exploded.txt
477
+ tests/test_files/snippets/3x1-pie.txt
478
+ tests/test_files/snippets/3x2-doughnut-exploded.txt
479
+ tests/test_files/snippets/3x2-doughnut.txt
480
+ tests/test_files/snippets/4x2-multi-cat-bar.txt
481
+ tests/test_files/snippets/adjust-ser-count.txt
482
+ tests/test_files/snippets/cat-labels.txt
483
+ tests/test_files/snippets/content-types-xml.txt
484
+ tests/test_files/snippets/default-notes.txt
485
+ tests/test_files/snippets/default-notesMaster.txt
486
+ tests/test_files/snippets/default-theme.txt
487
+ tests/test_files/snippets/freeform.txt
488
+ tests/test_files/snippets/package-rels-xml.txt
489
+ tests/test_files/snippets/placeholders.txt
490
+ tests/test_files/snippets/presentation-rels-xml.txt
491
+ tests/test_files/snippets/relationships.txt
492
+ tests/test_files/snippets/rels-load-from-xml.txt
493
+ tests/test_files/snippets/rewrite-ser.txt
494
+ tests/test_files/snippets/timing.txt
495
+ tests/text/__init__.py
496
+ tests/text/test_fonts.py
497
+ tests/text/test_layout.py
498
+ tests/text/test_text.py
499
+ tests/unitutil/__init__.py
500
+ tests/unitutil/cxml.py
501
+ tests/unitutil/file.py
502
+ tests/unitutil/mock.py
tasks/tasksmith-74f059424102/environment/source/src/python_pptx.egg-info/dependency_links.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
tasks/tasksmith-74f059424102/environment/source/src/python_pptx.egg-info/not-zip-safe ADDED
@@ -0,0 +1 @@
 
 
1
+
tasks/tasksmith-74f059424102/environment/source/src/python_pptx.egg-info/requires.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ lxml>=3.1.0
2
+ Pillow>=3.3.2
3
+ XlsxWriter>=0.5.7
tasks/tasksmith-74f059424102/environment/source/src/python_pptx.egg-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ pptx