From 6592dfb0821b5674df2851ab031ed6eaca7d4c8f Mon Sep 17 00:00:00 2001 From: Tuong Nguyen Manh Date: Sun, 30 Nov 2025 13:17:34 +0100 Subject: pptx writer: Handle reference doc without slides (#11310) An empty `sldIdLst` is now added if the reference doc is missing one so that `modifySldIdLst` can replace it. To ensure PowerPoint doesn't say that the file will need fixing, the `sldIdLst` has to be placed after the `sldMasterIdLst`. I also added a test to ensure that if there are notes, they will be placed between the `sldMasterIdLst` and `sldIdLst`. Otherwise PowerPoint wouldn't show the slide of a note when viewing Notes Pages. Closes #7536. --- test/Tests/Writers/Powerpoint.hs | 12 ++++ test/pptx/reference-no-slides.pptx | Bin 0 -> 30988 bytes .../reference-no-slides/add-slides/input.native | 14 +++++ .../reference-no-slides/add-slides/output.pptx | Bin 0 -> 28888 bytes .../reference-no-slides/with-notes/input.native | 70 +++++++++++++++++++++ .../reference-no-slides/with-notes/output.pptx | Bin 0 -> 33927 bytes 6 files changed, 96 insertions(+) create mode 100644 test/pptx/reference-no-slides.pptx create mode 100644 test/pptx/reference-no-slides/add-slides/input.native create mode 100644 test/pptx/reference-no-slides/add-slides/output.pptx create mode 100644 test/pptx/reference-no-slides/with-notes/input.native create mode 100644 test/pptx/reference-no-slides/with-notes/output.pptx (limited to 'test') diff --git a/test/Tests/Writers/Powerpoint.hs b/test/Tests/Writers/Powerpoint.hs index ab8b49314..35269205b 100644 --- a/test/Tests/Writers/Powerpoint.hs +++ b/test/Tests/Writers/Powerpoint.hs @@ -276,5 +276,17 @@ tests = let def {writerReferenceDoc = Just "pptx/reference-deleted-layouts.pptx"} "pptx/layouts/input.native" "pptx/layouts/deleted.pptx" + , ooxmlTest + writePowerpoint + "Slides can be missing from the reference doc" + def {writerReferenceDoc = Just "pptx/reference-no-slides.pptx"} + "pptx/reference-no-slides/add-slides/input.native" + "pptx/reference-no-slides/add-slides/output.pptx" + , ooxmlTest + writePowerpoint + "Notes are placed at the right position with a reference doc without slides" + def {writerReferenceDoc = Just "pptx/reference-no-slides.pptx"} + "pptx/reference-no-slides/with-notes/input.native" + "pptx/reference-no-slides/with-notes/output.pptx" ] in regularTests <> referenceSpecificTests diff --git a/test/pptx/reference-no-slides.pptx b/test/pptx/reference-no-slides.pptx new file mode 100644 index 000000000..2c4d77184 Binary files /dev/null and b/test/pptx/reference-no-slides.pptx differ diff --git a/test/pptx/reference-no-slides/add-slides/input.native b/test/pptx/reference-no-slides/add-slides/input.native new file mode 100644 index 000000000..de1250533 --- /dev/null +++ b/test/pptx/reference-no-slides/add-slides/input.native @@ -0,0 +1,14 @@ +[ Header + 2 + ( "first-slide" , [] , [] ) + [ Str "First" , Space , Str "Slide" ] +, Para [ Str "Title" ] +, Header + 2 + ( "second-slide" , [] , [] ) + [ Str "Second" , Space , Str "Slide" ] +, BulletList + [ [ Plain [ Str "First" , Space , Str "item" ] ] + , [ Plain [ Str "Second" , Space , Str "item" ] ] + ] +] diff --git a/test/pptx/reference-no-slides/add-slides/output.pptx b/test/pptx/reference-no-slides/add-slides/output.pptx new file mode 100644 index 000000000..35c0c5869 Binary files /dev/null and b/test/pptx/reference-no-slides/add-slides/output.pptx differ diff --git a/test/pptx/reference-no-slides/with-notes/input.native b/test/pptx/reference-no-slides/with-notes/input.native new file mode 100644 index 000000000..f671a2b0b --- /dev/null +++ b/test/pptx/reference-no-slides/with-notes/input.native @@ -0,0 +1,70 @@ +[ Header + 2 + ( "first-slide" , [] , [] ) + [ Str "First" , Space , Str "Slide" ] +, Para + [ Str "First" + , Space + , Str "slide" + , Space + , Str "with" + , Space + , Str "notes" + ] +, Div + ( "" , [ "notes" ] , [] ) + [ Para + [ Str "Notes" + , Space + , Str "for" + , Space + , Str "the" + , Space + , Str "first" + , Space + , Str "slide" + ] + ] +, Header + 2 + ( "second-slide" , [] , [] ) + [ Str "Second" , Space , Str "Slide" ] +, Para + [ Str "Slide" + , Space + , Str "without" + , Space + , Str "notes" + ] +, Header + 2 + ( "third-slide" , [] , [] ) + [ Str "Third" , Space , Str "Slide" ] +, Para + [ Str "Slide" + , Space + , Str "with" + , Space + , Str "notes" + , Space + , Str "again" + ] +, BulletList + [ [ Plain [ Str "First" , Space , Str "item" ] ] + , [ Plain [ Str "Second" , Space , Str "item" ] ] + ] +, Div + ( "" , [ "notes" ] , [] ) + [ Para + [ Str "Notes" + , Space + , Str "for" + , Space + , Str "the" + , Space + , Str "third" + , Space + , Str "slides" + ] + ] +] diff --git a/test/pptx/reference-no-slides/with-notes/output.pptx b/test/pptx/reference-no-slides/with-notes/output.pptx new file mode 100644 index 000000000..448d866bf Binary files /dev/null and b/test/pptx/reference-no-slides/with-notes/output.pptx differ -- cgit v1.2.3