#2015
pptx: clean.py and add_slide.py leave p14:sectionLst out of sync with sldIdLst, and validate.py does not detect it
When a deck is built from a template that has sections, the pptx scripts leave <p14:sectionLst> in ppt/presentation.xml out of sync with <p:sldIdLst>, and the validator does not notice.
Behaviour (checked on main at dbd4588)
scripts/clean.pyremoves slides that are no longer in<p:sldIdLst>, but it does not editpresentation.xml, so their<p14:sldId>entries stay in the section list.scripts/add_slide.pyadds the new slide to<p:sldIdLst>but not to any section.scripts/office/validate.pyreportsAll validations PASSED!for the result.validators/base.pylistssectionlstinEXCLUDED_ID_CONTAINERS, and nothing checks that the section ids match<p:sldIdLst>.
Repro
- Unpack a template with 11 slides in one section (the default "Default Section" is enough).
python scripts/add_slide.py unpacked/ slideLayout3.xml- Keep only the new slide in
<p:sldIdLst>. - Run
scripts/clean.py, thenscripts/office/validate.py(with or without--original).
Result: validation passes, but the section list still names the 11 deleted slide ids and omits the new slide. PowerPoint may then offer to repair the file. Corporate templates almost always have at least one section, so most template-based builds hit this.
Suggested fix
clean.py: drop<p14:sldId>entries whose ids are not in<p:sldIdLst>, and drop sections that become empty.add_slide.py: insert the new id into the section that contains the--afterslide, or into the last section.- Validator: fail when the set of section ids is not exactly the set of
<p:sldIdLst>ids.