Podium.OPC.PresentationXml (Podium v0.3.0)

Copy Markdown View Source

Surgery on an existing ppt/presentation.xml string.

Podium builds presentations on top of a template package rather than writing presentation.xml from scratch, so everything the template declares (notes size, default text style, embedded fonts, custom show properties) survives. These functions edit the parts Podium owns: the slide size, the slide id list, the notes master id list, and PowerPoint's section list.

Editing is regex-based, matching the rest of Podium's runtime XML handling.

Summary

Functions

Inserts a <p:notesMasterIdLst> naming rid, unless the XML already has one.

Replaces the <p:sldIdLst> with one listing entries, a list of {slide_id, rid} tuples.

Replaces <p:sldSz/> with one of the given size.

Returns {cx, cy} from <p:sldSz/>, or nil when the element is absent or malformed.

Removes PowerPoint's section list extension, and the <p:extLst> around it when that leaves it empty.

Functions

put_notes_master_id(xml, rid)

@spec put_notes_master_id(String.t(), String.t()) :: String.t()

Inserts a <p:notesMasterIdLst> naming rid, unless the XML already has one.

put_slide_id_list(xml, entries)

@spec put_slide_id_list(String.t(), [{pos_integer(), String.t()}]) :: String.t()

Replaces the <p:sldIdLst> with one listing entries, a list of {slide_id, rid} tuples.

An empty list leaves no list at all, which is what a slide-less template wants. A new list is inserted in schema order: after the handout master list if there is one, else after the notes master list, else after the slide master list.

put_slide_size(xml, cx, cy)

@spec put_slide_size(String.t(), non_neg_integer(), non_neg_integer()) :: String.t()

Replaces <p:sldSz/> with one of the given size.

Any other attribute (notably type="screen4x3") is dropped, since it would contradict the new dimensions.

slide_size(xml)

@spec slide_size(String.t()) :: {non_neg_integer(), non_neg_integer()} | nil

Returns {cx, cy} from <p:sldSz/>, or nil when the element is absent or malformed.

strip_section_list(xml)

@spec strip_section_list(String.t()) :: String.t()

Removes PowerPoint's section list extension, and the <p:extLst> around it when that leaves it empty.