davidgohel / officer

:cop: officer: office documents from R
https://ardata-fr.github.io/officeverse/
Other
594 stars 107 forks source link

bug: ph_location_type(): generates corrupted .pptx when selecting an id that does exist #602

Closed markheckmann closed 3 weeks ago

markheckmann commented 3 weeks ago

When providing an id in ph_location_type() that exceeds the number of phs of that type, no warning or error is thrown. However, when creating the .pptx file, it is corrupted. PPTX tries to repair it but does not succeed.

Probably, it would be best to throw an error, if id is out of range.

x <- read_pptx()
x <- x |> add_slide("Two Content")
x |> ph_with("unknown id", ph_location_type("body", id = 3))   # 3 does not exists => no error or warning
print(x, "corrupted.pptx")

x <- read_pptx()
x <- x |> add_slide("Two Content")
x |> ph_with("unknown id", ph_location_type("title", id = 2))   # 2 does not exists => no error or warning
print(x, "corrupted.pptx")
davidgohel commented 3 weeks ago

Agree, let me know if you want to PR or if you want me to do it

markheckmann commented 3 weeks ago

I will do it.