Skip to content

feat: add move_slide, duplicate_slide, and SlideShapes.add_copy_of()#1141

Open
ska-sleepy wants to merge 4 commits into
scanny:masterfrom
ska-sleepy:master
Open

feat: add move_slide, duplicate_slide, and SlideShapes.add_copy_of()#1141
ska-sleepy wants to merge 4 commits into
scanny:masterfrom
ska-sleepy:master

Conversation

@ska-sleepy

Copy link
Copy Markdown

Summary

Three slide/shape operations that have no native equivalent in the current API:

  • Slides.move_slide(slide, position) — reorder a slide to any 0-based position in the sequence
  • Slides.duplicate_slide(slide, position=None) — clone a slide; new slide lands after the source by default; related OPC parts (images, charts) are shared, not deep-copied
  • SlideShapes.add_copy_of(source_shape) — append a deep copy of a shape from any slide onto this slide's shape tree; shapes with embedded parts share those parts with the source

Internals

  • SlidePart.clone(source, package) — creates a new SlidePart from a deep copy of the source element, reproducing relationships in ascending rId order so XML rId references remain valid
  • PresentationPart.duplicate_slide(source_slide_part) — delegates to SlidePart.clone and registers the new part

Limitations

  • duplicate_slide: Notes slides attached to the source are not duplicated
  • add_copy_of: For picture/chart shapes the underlying OPC parts are shared; editing the image or chart data affects both the original and the copy

Test plan

  • tests/test_slide.py::DescribeSlides::it_can_move_a_slide
  • tests/test_slide.py::DescribeSlides::it_does_nothing_when_move_slide_target_equals_current_position
  • tests/test_slide.py::DescribeSlides::it_can_duplicate_a_slide
  • tests/shapes/test_shapetree.py::DescribeSlideShapes::it_can_add_a_copy_of_a_shape_from_another_slide
  • Full suite: 2688 passed (16 pre-existing errors unrelated to this PR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant