Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referring to slide layouts by name #35

Open
jaakkor2 opened this issue Jul 27, 2023 · 1 comment
Open

Referring to slide layouts by name #35

jaakkor2 opened this issue Jul 27, 2023 · 1 comment

Comments

@jaakkor2
Copy link
Contributor

At the moment (v0.6) PPTX.Slide argument for layout is defined like layout::Int=1 ie as an integer.

For convenience, would be nice to be able to refer to the layout by name as well.

Code sketch to extract name to number map

    layoutnamemap = Dict{String,Int}()
    layouts = readdir(raw"ppt/slideLayouts", join=true)
    for layout in layouts
        m = match(r"slideLayout(?<id>\d*).xml$", layout)
        isnothing(m) && continue
        id = parse(Int, m[:id])
        doc = readxml(layout)
        r = root(doc)
        n = findfirst("//p:cSld", r)
        push!(layoutnamemap, n["name"] => id)
    end
@matthijscox-asml
Copy link
Collaborator

I agree this would be more intuitive to users.

Quick brainstorm

  • Make the Slide.layout field a Union{Integer, String}.
  • Upon writing the PPTX, create this layoutnamemap.
  • Pass this layoutnamemap through write_slides! to the make_slide_relationships function
  • create something like: id = get_slide_layout_id(s::Slide, layoutnamemap)

I wonder if we should make this layoutnamemap a property of the Presentation, since it's kinda part of the global state of the presentation.

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

No branches or pull requests

2 participants