python-pptx2 2.13.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pptx2/__init__.py +152 -0
- pptx2/_color.py +75 -0
- pptx2/_slide_importer.py +597 -0
- pptx2/_svg.py +155 -0
- pptx2/_template_applier.py +292 -0
- pptx2/_textstyle.py +187 -0
- pptx2/accessibility.py +365 -0
- pptx2/action.py +270 -0
- pptx2/animation.py +2237 -0
- pptx2/api.py +49 -0
- pptx2/audit.py +258 -0
- pptx2/chart/__init__.py +0 -0
- pptx2/chart/analytics.py +381 -0
- pptx2/chart/axis.py +543 -0
- pptx2/chart/category.py +200 -0
- pptx2/chart/chart.py +670 -0
- pptx2/chart/data.py +864 -0
- pptx2/chart/datalabel.py +406 -0
- pptx2/chart/legend.py +86 -0
- pptx2/chart/marker.py +70 -0
- pptx2/chart/palettes.py +129 -0
- pptx2/chart/plot.py +462 -0
- pptx2/chart/point.py +101 -0
- pptx2/chart/quick_layouts.py +325 -0
- pptx2/chart/series.py +334 -0
- pptx2/chart/xlsx.py +272 -0
- pptx2/chart/xmlwriter.py +1845 -0
- pptx2/compose/__init__.py +28 -0
- pptx2/compose/from_spec.py +1094 -0
- pptx2/design/__init__.py +8 -0
- pptx2/design/components.py +607 -0
- pptx2/design/figures.py +389 -0
- pptx2/design/layout.py +370 -0
- pptx2/design/recipes.py +1967 -0
- pptx2/design/style.py +209 -0
- pptx2/design/tokens.py +915 -0
- pptx2/diagrams.py +754 -0
- pptx2/dml/__init__.py +0 -0
- pptx2/dml/chtfmt.py +40 -0
- pptx2/dml/color.py +496 -0
- pptx2/dml/effect.py +909 -0
- pptx2/dml/fill.py +691 -0
- pptx2/dml/line.py +287 -0
- pptx2/dml/picture.py +212 -0
- pptx2/dml/three_d.py +381 -0
- pptx2/enum/__init__.py +0 -0
- pptx2/enum/action.py +71 -0
- pptx2/enum/animation.py +31 -0
- pptx2/enum/base.py +218 -0
- pptx2/enum/chart.py +574 -0
- pptx2/enum/dml.py +740 -0
- pptx2/enum/lang.py +685 -0
- pptx2/enum/presentation.py +133 -0
- pptx2/enum/shapes.py +1029 -0
- pptx2/enum/text.py +230 -0
- pptx2/exc.py +42 -0
- pptx2/formats.py +139 -0
- pptx2/geometry.py +420 -0
- pptx2/inherit.py +109 -0
- pptx2/lint.py +2256 -0
- pptx2/math.py +177 -0
- pptx2/media.py +197 -0
- pptx2/opc/__init__.py +0 -0
- pptx2/opc/constants.py +332 -0
- pptx2/opc/oxml.py +188 -0
- pptx2/opc/package.py +762 -0
- pptx2/opc/packuri.py +109 -0
- pptx2/opc/serialized.py +296 -0
- pptx2/opc/shared.py +20 -0
- pptx2/opc/spec.py +45 -0
- pptx2/oxml/__init__.py +555 -0
- pptx2/oxml/action.py +53 -0
- pptx2/oxml/chart/__init__.py +0 -0
- pptx2/oxml/chart/axis.py +337 -0
- pptx2/oxml/chart/chart.py +481 -0
- pptx2/oxml/chart/datalabel.py +253 -0
- pptx2/oxml/chart/legend.py +72 -0
- pptx2/oxml/chart/marker.py +61 -0
- pptx2/oxml/chart/plot.py +365 -0
- pptx2/oxml/chart/series.py +425 -0
- pptx2/oxml/chart/shared.py +220 -0
- pptx2/oxml/coreprops.py +288 -0
- pptx2/oxml/dml/__init__.py +0 -0
- pptx2/oxml/dml/color.py +135 -0
- pptx2/oxml/dml/effect.py +213 -0
- pptx2/oxml/dml/fill.py +316 -0
- pptx2/oxml/dml/line.py +12 -0
- pptx2/oxml/dml/three_d.py +110 -0
- pptx2/oxml/ns.py +135 -0
- pptx2/oxml/presentation.py +313 -0
- pptx2/oxml/shapes/__init__.py +19 -0
- pptx2/oxml/shapes/autoshape.py +467 -0
- pptx2/oxml/shapes/connector.py +107 -0
- pptx2/oxml/shapes/graphfrm.py +347 -0
- pptx2/oxml/shapes/groupshape.py +329 -0
- pptx2/oxml/shapes/picture.py +270 -0
- pptx2/oxml/shapes/shared.py +577 -0
- pptx2/oxml/simpletypes.py +1027 -0
- pptx2/oxml/slide.py +563 -0
- pptx2/oxml/table.py +650 -0
- pptx2/oxml/text.py +815 -0
- pptx2/oxml/theme.py +36 -0
- pptx2/oxml/xmlchemy.py +717 -0
- pptx2/package.py +222 -0
- pptx2/parts/__init__.py +0 -0
- pptx2/parts/chart.py +95 -0
- pptx2/parts/coreprops.py +167 -0
- pptx2/parts/diagram.py +37 -0
- pptx2/parts/embeddedpackage.py +93 -0
- pptx2/parts/image.py +275 -0
- pptx2/parts/media.py +37 -0
- pptx2/parts/presentation.py +136 -0
- pptx2/parts/slide.py +371 -0
- pptx2/presentation.py +408 -0
- pptx2/py.typed +0 -0
- pptx2/render.py +586 -0
- pptx2/section.py +272 -0
- pptx2/shapes/__init__.py +26 -0
- pptx2/shapes/autoshape.py +442 -0
- pptx2/shapes/base.py +1078 -0
- pptx2/shapes/connector.py +297 -0
- pptx2/shapes/freeform.py +337 -0
- pptx2/shapes/graphfrm.py +316 -0
- pptx2/shapes/group.py +264 -0
- pptx2/shapes/picture.py +422 -0
- pptx2/shapes/placeholder.py +468 -0
- pptx2/shapes/shapetree.py +2027 -0
- pptx2/shared.py +82 -0
- pptx2/skill/SKILL.md +450 -0
- pptx2/skill/__init__.py +78 -0
- pptx2/skill/__main__.py +64 -0
- pptx2/skill/references/animations.md +189 -0
- pptx2/skill/references/basics.md +421 -0
- pptx2/skill/references/charts.md +254 -0
- pptx2/skill/references/compose.md +234 -0
- pptx2/skill/references/design.md +366 -0
- pptx2/skill/references/effects.md +249 -0
- pptx2/skill/references/end-to-end-deck.md +231 -0
- pptx2/skill/references/geometry-and-arrows.md +334 -0
- pptx2/skill/references/lint.md +275 -0
- pptx2/skill/references/math.md +86 -0
- pptx2/skill/references/picture-effects.md +129 -0
- pptx2/skill/references/render.md +151 -0
- pptx2/skill/references/smart-art.md +75 -0
- pptx2/skill/references/space-aware-authoring.md +249 -0
- pptx2/skill/references/tables.md +244 -0
- pptx2/skill/references/theme.md +127 -0
- pptx2/skill/references/three-d.md +109 -0
- pptx2/skill/references/transitions.md +100 -0
- pptx2/slide.py +1244 -0
- pptx2/smart_art.py +220 -0
- pptx2/spec.py +633 -0
- pptx2/table.py +1181 -0
- pptx2/table_styles.py +184 -0
- pptx2/templates/default.pptx +0 -0
- pptx2/templates/docx-icon.emf +0 -0
- pptx2/templates/generic-icon.emf +0 -0
- pptx2/templates/notes.xml +23 -0
- pptx2/templates/notesMaster.xml +352 -0
- pptx2/templates/pptx-icon.emf +0 -0
- pptx2/templates/theme.xml +321 -0
- pptx2/templates/xlsx-icon.emf +0 -0
- pptx2/text/__init__.py +0 -0
- pptx2/text/fonts.py +482 -0
- pptx2/text/layout.py +374 -0
- pptx2/text/text.py +1272 -0
- pptx2/theme.py +721 -0
- pptx2/types.py +36 -0
- pptx2/util.py +263 -0
- python_pptx2-2.13.0.dist-info/METADATA +351 -0
- python_pptx2-2.13.0.dist-info/RECORD +175 -0
- python_pptx2-2.13.0.dist-info/WHEEL +5 -0
- python_pptx2-2.13.0.dist-info/entry_points.txt +3 -0
- python_pptx2-2.13.0.dist-info/licenses/LICENSE +22 -0
- python_pptx2-2.13.0.dist-info/top_level.txt +1 -0
pptx2/opc/constants.py
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
"""Constant values related to the Open Packaging Convention.
|
|
2
|
+
|
|
3
|
+
In particular, this includes content (MIME) types and relationship types.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class CONTENT_TYPE:
|
|
10
|
+
"""Content type URIs (like MIME-types) that specify a part's format."""
|
|
11
|
+
|
|
12
|
+
ASF = "video/x-ms-asf"
|
|
13
|
+
AVI = "video/avi"
|
|
14
|
+
BMP = "image/bmp"
|
|
15
|
+
DML_CHART = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"
|
|
16
|
+
DML_CHARTSHAPES = "application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml"
|
|
17
|
+
DML_DIAGRAM_COLORS = "application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml"
|
|
18
|
+
DML_DIAGRAM_DATA = "application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml"
|
|
19
|
+
DML_DIAGRAM_DRAWING = "application/vnd.ms-office.drawingml.diagramDrawing+xml"
|
|
20
|
+
DML_DIAGRAM_LAYOUT = "application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml"
|
|
21
|
+
DML_DIAGRAM_STYLE = "application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml"
|
|
22
|
+
GIF = "image/gif"
|
|
23
|
+
INK = "application/inkml+xml"
|
|
24
|
+
JPEG = "image/jpeg"
|
|
25
|
+
MOV = "video/quicktime"
|
|
26
|
+
MP4 = "video/mp4"
|
|
27
|
+
MPG = "video/mpeg"
|
|
28
|
+
MS_PHOTO = "image/vnd.ms-photo"
|
|
29
|
+
MS_VIDEO = "video/msvideo"
|
|
30
|
+
OFC_CHART_COLORS = "application/vnd.ms-office.chartcolorstyle+xml"
|
|
31
|
+
OFC_CHART_EX = "application/vnd.ms-office.chartex+xml"
|
|
32
|
+
OFC_CHART_STYLE = "application/vnd.ms-office.chartstyle+xml"
|
|
33
|
+
OFC_CUSTOM_PROPERTIES = "application/vnd.openxmlformats-officedocument.custom-properties+xml"
|
|
34
|
+
OFC_CUSTOM_XML_PROPERTIES = (
|
|
35
|
+
"application/vnd.openxmlformats-officedocument.customXmlProperties+xml"
|
|
36
|
+
)
|
|
37
|
+
OFC_DRAWING = "application/vnd.openxmlformats-officedocument.drawing+xml"
|
|
38
|
+
OFC_EXTENDED_PROPERTIES = (
|
|
39
|
+
"application/vnd.openxmlformats-officedocument.extended-properties+xml"
|
|
40
|
+
)
|
|
41
|
+
OFC_OLE_OBJECT = "application/vnd.openxmlformats-officedocument.oleObject"
|
|
42
|
+
OFC_PACKAGE = "application/vnd.openxmlformats-officedocument.package"
|
|
43
|
+
OFC_THEME = "application/vnd.openxmlformats-officedocument.theme+xml"
|
|
44
|
+
SVG = "image/svg+xml"
|
|
45
|
+
OFC_THEME_OVERRIDE = "application/vnd.openxmlformats-officedocument.themeOverride+xml"
|
|
46
|
+
OFC_VML_DRAWING = "application/vnd.openxmlformats-officedocument.vmlDrawing"
|
|
47
|
+
OPC_CORE_PROPERTIES = "application/vnd.openxmlformats-package.core-properties+xml"
|
|
48
|
+
OPC_DIGITAL_SIGNATURE_CERTIFICATE = (
|
|
49
|
+
"application/vnd.openxmlformats-package.digital-signature-certificate"
|
|
50
|
+
)
|
|
51
|
+
OPC_DIGITAL_SIGNATURE_ORIGIN = "application/vnd.openxmlformats-package.digital-signature-origin"
|
|
52
|
+
OPC_DIGITAL_SIGNATURE_XMLSIGNATURE = (
|
|
53
|
+
"application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml"
|
|
54
|
+
)
|
|
55
|
+
OPC_RELATIONSHIPS = "application/vnd.openxmlformats-package.relationships+xml"
|
|
56
|
+
PML_COMMENTS = "application/vnd.openxmlformats-officedocument.presentationml.comments+xml"
|
|
57
|
+
PML_COMMENT_AUTHORS = (
|
|
58
|
+
"application/vnd.openxmlformats-officedocument.presentationml.commentAuthors+xml"
|
|
59
|
+
)
|
|
60
|
+
PML_HANDOUT_MASTER = (
|
|
61
|
+
"application/vnd.openxmlformats-officedocument.presentationml.handoutMaster+xml"
|
|
62
|
+
)
|
|
63
|
+
PML_NOTES_MASTER = (
|
|
64
|
+
"application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml"
|
|
65
|
+
)
|
|
66
|
+
PML_NOTES_SLIDE = "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml"
|
|
67
|
+
PML_PRESENTATION = "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
|
68
|
+
PML_PRESENTATION_MAIN = (
|
|
69
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"
|
|
70
|
+
)
|
|
71
|
+
PML_PRES_MACRO_MAIN = "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml"
|
|
72
|
+
PML_PRES_PROPS = "application/vnd.openxmlformats-officedocument.presentationml.presProps+xml"
|
|
73
|
+
PML_PRINTER_SETTINGS = (
|
|
74
|
+
"application/vnd.openxmlformats-officedocument.presentationml.printerSettings"
|
|
75
|
+
)
|
|
76
|
+
PML_SLIDE = "application/vnd.openxmlformats-officedocument.presentationml.slide+xml"
|
|
77
|
+
PML_SLIDESHOW_MAIN = (
|
|
78
|
+
"application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml"
|
|
79
|
+
)
|
|
80
|
+
PML_SLIDE_LAYOUT = (
|
|
81
|
+
"application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"
|
|
82
|
+
)
|
|
83
|
+
PML_SLIDE_MASTER = (
|
|
84
|
+
"application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"
|
|
85
|
+
)
|
|
86
|
+
PML_SLIDE_UPDATE_INFO = (
|
|
87
|
+
"application/vnd.openxmlformats-officedocument.presentationml.slideUpdateInfo+xml"
|
|
88
|
+
)
|
|
89
|
+
PML_TABLE_STYLES = (
|
|
90
|
+
"application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml"
|
|
91
|
+
)
|
|
92
|
+
PML_TAGS = "application/vnd.openxmlformats-officedocument.presentationml.tags+xml"
|
|
93
|
+
PML_TEMPLATE_MAIN = (
|
|
94
|
+
"application/vnd.openxmlformats-officedocument.presentationml.template.main+xml"
|
|
95
|
+
)
|
|
96
|
+
PML_VIEW_PROPS = "application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml"
|
|
97
|
+
PNG = "image/png"
|
|
98
|
+
SML_CALC_CHAIN = "application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml"
|
|
99
|
+
SML_CHARTSHEET = "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml"
|
|
100
|
+
SML_COMMENTS = "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"
|
|
101
|
+
SML_CONNECTIONS = "application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml"
|
|
102
|
+
SML_CUSTOM_PROPERTY = (
|
|
103
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.customProperty"
|
|
104
|
+
)
|
|
105
|
+
SML_DIALOGSHEET = "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml"
|
|
106
|
+
SML_EXTERNAL_LINK = (
|
|
107
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml"
|
|
108
|
+
)
|
|
109
|
+
SML_PIVOT_CACHE_DEFINITION = (
|
|
110
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml"
|
|
111
|
+
)
|
|
112
|
+
SML_PIVOT_CACHE_RECORDS = (
|
|
113
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml"
|
|
114
|
+
)
|
|
115
|
+
SML_PIVOT_TABLE = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml"
|
|
116
|
+
SML_PRINTER_SETTINGS = (
|
|
117
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings"
|
|
118
|
+
)
|
|
119
|
+
SML_QUERY_TABLE = "application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml"
|
|
120
|
+
SML_REVISION_HEADERS = (
|
|
121
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml"
|
|
122
|
+
)
|
|
123
|
+
SML_REVISION_LOG = "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml"
|
|
124
|
+
SML_SHARED_STRINGS = (
|
|
125
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"
|
|
126
|
+
)
|
|
127
|
+
SML_SHEET = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
128
|
+
SML_SHEET_MAIN = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"
|
|
129
|
+
SML_SHEET_METADATA = (
|
|
130
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml"
|
|
131
|
+
)
|
|
132
|
+
SML_STYLES = "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"
|
|
133
|
+
SML_TABLE = "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"
|
|
134
|
+
SML_TABLE_SINGLE_CELLS = (
|
|
135
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml"
|
|
136
|
+
)
|
|
137
|
+
SML_TEMPLATE_MAIN = (
|
|
138
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml"
|
|
139
|
+
)
|
|
140
|
+
SML_USER_NAMES = "application/vnd.openxmlformats-officedocument.spreadsheetml.userNames+xml"
|
|
141
|
+
SML_VOLATILE_DEPENDENCIES = (
|
|
142
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.volatileDependencies+xml"
|
|
143
|
+
)
|
|
144
|
+
SML_WORKSHEET = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"
|
|
145
|
+
SWF = "application/x-shockwave-flash"
|
|
146
|
+
TIFF = "image/tiff"
|
|
147
|
+
VIDEO = "video/unknown"
|
|
148
|
+
WML_COMMENTS = "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"
|
|
149
|
+
WML_DOCUMENT = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
150
|
+
WML_DOCUMENT_GLOSSARY = (
|
|
151
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml"
|
|
152
|
+
)
|
|
153
|
+
WML_DOCUMENT_MAIN = (
|
|
154
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"
|
|
155
|
+
)
|
|
156
|
+
WML_ENDNOTES = "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"
|
|
157
|
+
WML_FONT_TABLE = "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"
|
|
158
|
+
WML_FOOTER = "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml"
|
|
159
|
+
WML_FOOTNOTES = "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"
|
|
160
|
+
WML_HEADER = "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml"
|
|
161
|
+
WML_NUMBERING = "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"
|
|
162
|
+
WML_PRINTER_SETTINGS = (
|
|
163
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.printerSettings"
|
|
164
|
+
)
|
|
165
|
+
WML_SETTINGS = "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"
|
|
166
|
+
WML_STYLES = "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"
|
|
167
|
+
WML_WEB_SETTINGS = (
|
|
168
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml"
|
|
169
|
+
)
|
|
170
|
+
WMV = "video/x-ms-wmv"
|
|
171
|
+
XML = "application/xml"
|
|
172
|
+
X_EMF = "image/x-emf"
|
|
173
|
+
X_FONTDATA = "application/x-fontdata"
|
|
174
|
+
X_FONT_TTF = "application/x-font-ttf"
|
|
175
|
+
X_MS_VIDEO = "video/x-msvideo"
|
|
176
|
+
X_WMF = "image/x-wmf"
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class NAMESPACE:
|
|
180
|
+
"""Constant values for OPC XML namespaces"""
|
|
181
|
+
|
|
182
|
+
DML_WORDPROCESSING_DRAWING = (
|
|
183
|
+
"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
|
|
184
|
+
)
|
|
185
|
+
OFC_RELATIONSHIPS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
|
186
|
+
OPC_RELATIONSHIPS = "http://schemas.openxmlformats.org/package/2006/relationships"
|
|
187
|
+
OPC_CONTENT_TYPES = "http://schemas.openxmlformats.org/package/2006/content-types"
|
|
188
|
+
WML_MAIN = "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
class RELATIONSHIP_TARGET_MODE:
|
|
192
|
+
"""Open XML relationship target modes"""
|
|
193
|
+
|
|
194
|
+
EXTERNAL = "External"
|
|
195
|
+
INTERNAL = "Internal"
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
class RELATIONSHIP_TYPE:
|
|
199
|
+
AUDIO = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio"
|
|
200
|
+
A_F_CHUNK = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk"
|
|
201
|
+
CALC_CHAIN = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain"
|
|
202
|
+
CERTIFICATE = (
|
|
203
|
+
"http://schemas.openxmlformats.org/package/2006/relationships/digital-signatu"
|
|
204
|
+
"re/certificate"
|
|
205
|
+
)
|
|
206
|
+
CHART = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"
|
|
207
|
+
CHARTSHEET = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet"
|
|
208
|
+
CHART_COLOR_STYLE = "http://schemas.microsoft.com/office/2011/relationships/chartColorStyle"
|
|
209
|
+
CHART_USER_SHAPES = (
|
|
210
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes"
|
|
211
|
+
)
|
|
212
|
+
COMMENTS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"
|
|
213
|
+
COMMENT_AUTHORS = (
|
|
214
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors"
|
|
215
|
+
)
|
|
216
|
+
CONNECTIONS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/connections"
|
|
217
|
+
CONTROL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/control"
|
|
218
|
+
CORE_PROPERTIES = (
|
|
219
|
+
"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"
|
|
220
|
+
)
|
|
221
|
+
CUSTOM_PROPERTIES = (
|
|
222
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties"
|
|
223
|
+
)
|
|
224
|
+
CUSTOM_PROPERTY = (
|
|
225
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customProperty"
|
|
226
|
+
)
|
|
227
|
+
CUSTOM_XML = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"
|
|
228
|
+
CUSTOM_XML_PROPS = (
|
|
229
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps"
|
|
230
|
+
)
|
|
231
|
+
DIAGRAM_COLORS = (
|
|
232
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors"
|
|
233
|
+
)
|
|
234
|
+
DIAGRAM_DATA = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData"
|
|
235
|
+
DIAGRAM_LAYOUT = (
|
|
236
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout"
|
|
237
|
+
)
|
|
238
|
+
DIAGRAM_QUICK_STYLE = (
|
|
239
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle"
|
|
240
|
+
)
|
|
241
|
+
DIALOGSHEET = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/dialogsheet"
|
|
242
|
+
DRAWING = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing"
|
|
243
|
+
ENDNOTES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes"
|
|
244
|
+
EXTENDED_PROPERTIES = (
|
|
245
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"
|
|
246
|
+
)
|
|
247
|
+
EXTERNAL_LINK = (
|
|
248
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink"
|
|
249
|
+
)
|
|
250
|
+
FONT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font"
|
|
251
|
+
FONT_TABLE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable"
|
|
252
|
+
FOOTER = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"
|
|
253
|
+
FOOTNOTES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"
|
|
254
|
+
GLOSSARY_DOCUMENT = (
|
|
255
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument"
|
|
256
|
+
)
|
|
257
|
+
HANDOUT_MASTER = (
|
|
258
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/handoutMaster"
|
|
259
|
+
)
|
|
260
|
+
HEADER = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"
|
|
261
|
+
HYPERLINK = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
|
|
262
|
+
IMAGE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
|
|
263
|
+
MEDIA = "http://schemas.microsoft.com/office/2007/relationships/media"
|
|
264
|
+
NOTES_MASTER = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster"
|
|
265
|
+
NOTES_SLIDE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide"
|
|
266
|
+
NUMBERING = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"
|
|
267
|
+
OFFICE_DOCUMENT = (
|
|
268
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
|
|
269
|
+
)
|
|
270
|
+
OLE_OBJECT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"
|
|
271
|
+
ORIGIN = "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin"
|
|
272
|
+
PACKAGE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"
|
|
273
|
+
PIVOT_CACHE_DEFINITION = (
|
|
274
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCac"
|
|
275
|
+
"heDefinition"
|
|
276
|
+
)
|
|
277
|
+
PIVOT_CACHE_RECORDS = (
|
|
278
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/spreadsh"
|
|
279
|
+
"eetml/pivotCacheRecords"
|
|
280
|
+
)
|
|
281
|
+
PIVOT_TABLE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable"
|
|
282
|
+
PRES_PROPS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps"
|
|
283
|
+
PRINTER_SETTINGS = (
|
|
284
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings"
|
|
285
|
+
)
|
|
286
|
+
QUERY_TABLE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/queryTable"
|
|
287
|
+
REVISION_HEADERS = (
|
|
288
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/revisionHeaders"
|
|
289
|
+
)
|
|
290
|
+
REVISION_LOG = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/revisionLog"
|
|
291
|
+
SETTINGS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"
|
|
292
|
+
SHARED_STRINGS = (
|
|
293
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"
|
|
294
|
+
)
|
|
295
|
+
SHEET_METADATA = (
|
|
296
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sheetMetadata"
|
|
297
|
+
)
|
|
298
|
+
SIGNATURE = (
|
|
299
|
+
"http://schemas.openxmlformats.org/package/2006/relationships/digital-signatu"
|
|
300
|
+
"re/signature"
|
|
301
|
+
)
|
|
302
|
+
SLIDE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"
|
|
303
|
+
SLIDE_LAYOUT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout"
|
|
304
|
+
SLIDE_MASTER = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster"
|
|
305
|
+
SLIDE_UPDATE_INFO = (
|
|
306
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideUpdateInfo"
|
|
307
|
+
)
|
|
308
|
+
STYLES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"
|
|
309
|
+
TABLE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table"
|
|
310
|
+
TABLE_SINGLE_CELLS = (
|
|
311
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableSingleCells"
|
|
312
|
+
)
|
|
313
|
+
TABLE_STYLES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles"
|
|
314
|
+
TAGS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tags"
|
|
315
|
+
THEME = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"
|
|
316
|
+
THEME_OVERRIDE = (
|
|
317
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/themeOverride"
|
|
318
|
+
)
|
|
319
|
+
THUMBNAIL = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"
|
|
320
|
+
USERNAMES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/usernames"
|
|
321
|
+
VIDEO = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video"
|
|
322
|
+
VIEW_PROPS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps"
|
|
323
|
+
VML_DRAWING = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing"
|
|
324
|
+
VOLATILE_DEPENDENCIES = (
|
|
325
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/volatile"
|
|
326
|
+
"Dependencies"
|
|
327
|
+
)
|
|
328
|
+
WEB_SETTINGS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings"
|
|
329
|
+
WORKSHEET_SOURCE = (
|
|
330
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheetSource"
|
|
331
|
+
)
|
|
332
|
+
XML_MAPS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/xmlMaps"
|
pptx2/opc/oxml.py
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"""OPC-local oxml module to handle OPC-local concerns like relationship parsing."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, Callable, cast
|
|
6
|
+
|
|
7
|
+
from lxml import etree
|
|
8
|
+
|
|
9
|
+
from pptx2.opc.constants import NAMESPACE as NS
|
|
10
|
+
from pptx2.opc.constants import RELATIONSHIP_TARGET_MODE as RTM
|
|
11
|
+
from pptx2.oxml import parse_xml, register_element_cls
|
|
12
|
+
from pptx2.oxml.simpletypes import (
|
|
13
|
+
ST_ContentType,
|
|
14
|
+
ST_Extension,
|
|
15
|
+
ST_TargetMode,
|
|
16
|
+
XsdAnyUri,
|
|
17
|
+
XsdId,
|
|
18
|
+
)
|
|
19
|
+
from pptx2.oxml.xmlchemy import (
|
|
20
|
+
BaseOxmlElement,
|
|
21
|
+
OptionalAttribute,
|
|
22
|
+
RequiredAttribute,
|
|
23
|
+
ZeroOrMore,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
if TYPE_CHECKING:
|
|
27
|
+
from pptx2.opc.packuri import PackURI
|
|
28
|
+
|
|
29
|
+
nsmap = {
|
|
30
|
+
"ct": NS.OPC_CONTENT_TYPES,
|
|
31
|
+
"pr": NS.OPC_RELATIONSHIPS,
|
|
32
|
+
"r": NS.OFC_RELATIONSHIPS,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def oxml_to_encoded_bytes(
|
|
37
|
+
element: BaseOxmlElement,
|
|
38
|
+
encoding: str = "utf-8",
|
|
39
|
+
pretty_print: bool = False,
|
|
40
|
+
standalone: bool | None = None,
|
|
41
|
+
) -> bytes:
|
|
42
|
+
return etree.tostring(
|
|
43
|
+
element, encoding=encoding, pretty_print=pretty_print, standalone=standalone
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def oxml_tostring(
|
|
48
|
+
elm: BaseOxmlElement,
|
|
49
|
+
encoding: str | None = None,
|
|
50
|
+
pretty_print: bool = False,
|
|
51
|
+
standalone: bool | None = None,
|
|
52
|
+
):
|
|
53
|
+
return etree.tostring(elm, encoding=encoding, pretty_print=pretty_print, standalone=standalone)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def serialize_part_xml(part_elm: BaseOxmlElement) -> bytes:
|
|
57
|
+
"""Produce XML-file bytes for `part_elm`, suitable for writing directly to a `.xml` file.
|
|
58
|
+
|
|
59
|
+
Includes XML-declaration header.
|
|
60
|
+
"""
|
|
61
|
+
return etree.tostring(part_elm, encoding="UTF-8", standalone=True)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class CT_Default(BaseOxmlElement):
|
|
65
|
+
"""`<Default>` element.
|
|
66
|
+
|
|
67
|
+
Specifies the default content type to be applied to a part with the specified extension.
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
extension: str = RequiredAttribute( # pyright: ignore[reportAssignmentType]
|
|
71
|
+
"Extension", ST_Extension
|
|
72
|
+
)
|
|
73
|
+
contentType: str = RequiredAttribute( # pyright: ignore[reportAssignmentType]
|
|
74
|
+
"ContentType", ST_ContentType
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class CT_Override(BaseOxmlElement):
|
|
79
|
+
"""`<Override>` element.
|
|
80
|
+
|
|
81
|
+
Specifies the content type to be applied for a part with the specified partname.
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
partName: str = RequiredAttribute( # pyright: ignore[reportAssignmentType]
|
|
85
|
+
"PartName", XsdAnyUri
|
|
86
|
+
)
|
|
87
|
+
contentType: str = RequiredAttribute( # pyright: ignore[reportAssignmentType]
|
|
88
|
+
"ContentType", ST_ContentType
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class CT_Relationship(BaseOxmlElement):
|
|
93
|
+
"""`<Relationship>` element.
|
|
94
|
+
|
|
95
|
+
Represents a single relationship from a source to a target part.
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
rId: str = RequiredAttribute("Id", XsdId) # pyright: ignore[reportAssignmentType]
|
|
99
|
+
reltype: str = RequiredAttribute("Type", XsdAnyUri) # pyright: ignore[reportAssignmentType]
|
|
100
|
+
target_ref: str = RequiredAttribute( # pyright: ignore[reportAssignmentType]
|
|
101
|
+
"Target", XsdAnyUri
|
|
102
|
+
)
|
|
103
|
+
targetMode: str = OptionalAttribute( # pyright: ignore[reportAssignmentType]
|
|
104
|
+
"TargetMode", ST_TargetMode, default=RTM.INTERNAL
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
@classmethod
|
|
108
|
+
def new(
|
|
109
|
+
cls, rId: str, reltype: str, target_ref: str, target_mode: str = RTM.INTERNAL
|
|
110
|
+
) -> CT_Relationship:
|
|
111
|
+
"""Return a new `<Relationship>` element.
|
|
112
|
+
|
|
113
|
+
`target_ref` is either a partname or a URI.
|
|
114
|
+
"""
|
|
115
|
+
relationship = cast(CT_Relationship, parse_xml(f'<Relationship xmlns="{nsmap["pr"]}"/>'))
|
|
116
|
+
relationship.rId = rId
|
|
117
|
+
relationship.reltype = reltype
|
|
118
|
+
relationship.target_ref = target_ref
|
|
119
|
+
relationship.targetMode = target_mode
|
|
120
|
+
return relationship
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class CT_Relationships(BaseOxmlElement):
|
|
124
|
+
"""`<Relationships>` element, the root element in a .rels file."""
|
|
125
|
+
|
|
126
|
+
relationship_lst: list[CT_Relationship]
|
|
127
|
+
_insert_relationship: Callable[[CT_Relationship], CT_Relationship]
|
|
128
|
+
|
|
129
|
+
relationship = ZeroOrMore("pr:Relationship")
|
|
130
|
+
|
|
131
|
+
def add_rel(
|
|
132
|
+
self, rId: str, reltype: str, target: str, is_external: bool = False
|
|
133
|
+
) -> CT_Relationship:
|
|
134
|
+
"""Add a child `<Relationship>` element with attributes set as specified."""
|
|
135
|
+
target_mode = RTM.EXTERNAL if is_external else RTM.INTERNAL
|
|
136
|
+
relationship = CT_Relationship.new(rId, reltype, target, target_mode)
|
|
137
|
+
return self._insert_relationship(relationship)
|
|
138
|
+
|
|
139
|
+
@classmethod
|
|
140
|
+
def new(cls) -> CT_Relationships:
|
|
141
|
+
"""Return a new `<Relationships>` element."""
|
|
142
|
+
return cast(CT_Relationships, parse_xml(f'<Relationships xmlns="{nsmap["pr"]}"/>'))
|
|
143
|
+
|
|
144
|
+
@property
|
|
145
|
+
def xml_file_bytes(self) -> bytes:
|
|
146
|
+
"""Return XML bytes, with XML-declaration, for this `<Relationships>` element.
|
|
147
|
+
|
|
148
|
+
Suitable for saving in a .rels stream, not pretty printed and with an XML declaration at
|
|
149
|
+
the top.
|
|
150
|
+
"""
|
|
151
|
+
return oxml_to_encoded_bytes(self, encoding="UTF-8", standalone=True)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
class CT_Types(BaseOxmlElement):
|
|
155
|
+
"""`<Types>` element.
|
|
156
|
+
|
|
157
|
+
The container element for Default and Override elements in [Content_Types].xml.
|
|
158
|
+
"""
|
|
159
|
+
|
|
160
|
+
default_lst: list[CT_Default]
|
|
161
|
+
override_lst: list[CT_Override]
|
|
162
|
+
|
|
163
|
+
_add_default: Callable[..., CT_Default]
|
|
164
|
+
_add_override: Callable[..., CT_Override]
|
|
165
|
+
|
|
166
|
+
default = ZeroOrMore("ct:Default")
|
|
167
|
+
override = ZeroOrMore("ct:Override")
|
|
168
|
+
|
|
169
|
+
def add_default(self, ext: str, content_type: str) -> CT_Default:
|
|
170
|
+
"""Add a child `<Default>` element with attributes set to parameter values."""
|
|
171
|
+
return self._add_default(extension=ext, contentType=content_type)
|
|
172
|
+
|
|
173
|
+
def add_override(self, partname: PackURI, content_type: str) -> CT_Override:
|
|
174
|
+
"""Add a child `<Override>` element with attributes set to parameter values."""
|
|
175
|
+
return self._add_override(partName=partname, contentType=content_type)
|
|
176
|
+
|
|
177
|
+
@classmethod
|
|
178
|
+
def new(cls) -> CT_Types:
|
|
179
|
+
"""Return a new `<Types>` element."""
|
|
180
|
+
return cast(CT_Types, parse_xml(f'<Types xmlns="{nsmap["ct"]}"/>'))
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
register_element_cls("ct:Default", CT_Default)
|
|
184
|
+
register_element_cls("ct:Override", CT_Override)
|
|
185
|
+
register_element_cls("ct:Types", CT_Types)
|
|
186
|
+
|
|
187
|
+
register_element_cls("pr:Relationship", CT_Relationship)
|
|
188
|
+
register_element_cls("pr:Relationships", CT_Relationships)
|