Skip to content

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

Merged
ska-sleepy merged 3 commits into
masterfrom
feat/move-duplicate-copy-shape
Jun 30, 2026
Merged

feat: add move_slide, duplicate_slide, and SlideShapes.add_copy_of()#1
ska-sleepy merged 3 commits into
masterfrom
feat/move-duplicate-copy-shape

Conversation

@ska-sleepy

Copy link
Copy Markdown
Owner

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)

@ska-sleepy ska-sleepy merged commit 2bed5ec into master Jun 30, 2026
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