#2015

pptx: clean.py and add_slide.py leave p14:sectionLst out of sync with sldIdLst, and validate.py does not detect it

OpenDmitriyAlergantopened 17d ago

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.py removes slides that are no longer in <p:sldIdLst>, but it does not edit presentation.xml, so their <p14:sldId> entries stay in the section list.
  • scripts/add_slide.py adds the new slide to <p:sldIdLst> but not to any section.
  • scripts/office/validate.py reports All validations PASSED! for the result. validators/base.py lists sectionlst in EXCLUDED_ID_CONTAINERS, and nothing checks that the section ids match <p:sldIdLst>.

Repro

  1. Unpack a template with 11 slides in one section (the default "Default Section" is enough).
  2. python scripts/add_slide.py unpacked/ slideLayout3.xml
  3. Keep only the new slide in <p:sldIdLst>.
  4. Run scripts/clean.py, then scripts/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 --after slide, or into the last section.
  • Validator: fail when the set of section ids is not exactly the set of <p:sldIdLst> ids.

Activity

1
donaldzitzer406-lang15d ago

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.py removes slides that are no longer in <p:sldIdLst>, but it does not edit presentation.xml, so their <p14:sldId> entries stay in the section list.
  • scripts/add_slide.py adds the new slide to <p:sldIdLst> but not to any section.
  • scripts/office/validate.py reports All validations PASSED! for the result. validators/base.py lists sectionlst in EXCLUDED_ID_CONTAINERS, and nothing checks that the section ids match <p:sldIdLst>.

Repro

  1. Unpack a template with 11 slides in one section (the default "Default Section" is enough).
  2. python scripts/add_slide.py unpacked/ slideLayout3.xml
  3. Keep only the new slide in <p:sldIdLst>.
  4. Run scripts/clean.py, then scripts/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 --after slide, or into the last section.
  • Validator: fail when the set of section ids is not exactly the set of <p:sldIdLst> ids.