Slide part. Corresponds to package files ppt/slides/slide[1-9][0-9]*.xml.
| 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) |
no outgoing calls
searching dependent graphs…