Skip to content

Commit

Permalink
Merge pull request #56 from ASML-Labs/Fix_textbox_picture_bug
Browse files Browse the repository at this point in the history
Fix improper rId setting
  • Loading branch information
matthijscox-asml authored Oct 14, 2024
2 parents 316070f + a4e5d2d commit cf5f1d1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/Slide.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ function Slide(;
end

function new_rid(slide::Slide)
if isempty(shapes(slide))
# When there is no rid shapes the new rid should be 2
if isempty(slide.shapes)
return 2
else
return maximum(rid.(shapes(slide))) + 1
else # default 2, or it should be the at least 1 bigger than the shape with the higest rid
return max(2, maximum(rid.(shapes(slide))) + 1)
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/testConstructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ using Test
picture_path = joinpath(PPTX.ASSETS_DIR, "cauliflower.jpg")
p = Presentation([Slide([TextBox(),Picture(picture_path)])])
@test rid(p.slides[1].shapes[1]) == 0
@test rid(p.slides[1].shapes[2]) == 1
@test rid(p.slides[1].shapes[2]) == 2
end
@testset "Slide" begin
slide = Slide()
Expand Down
10 changes: 10 additions & 0 deletions test/testSlideXML.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ end
@test layout_relationship["Target"] == "../slideLayouts/slideLayout2.xml"
end

@testset "rId always bigger than 1 updating on push!" begin
s = Slide()
push!(s, TextBox("Some text"))
@test PPTX.rid(s.shapes[1]) == 0 # textboxes have no rid, so set to 0
push!(s, Picture(joinpath(PPTX.ASSETS_DIR,"julia_logo.png")))
@test PPTX.rid(s.shapes[2]) == 2
push!(s, Picture(joinpath(PPTX.ASSETS_DIR,"cauliflower.jpg")))
@test PPTX.rid(s.shapes[3]) == 3
end

@testset "update title in XML" begin
template = ZipBufferReader(read(joinpath(PPTX.TEMPLATE_DIR,"no-slides.pptx")))

Expand Down

0 comments on commit cf5f1d1

Please sign in to comment.