Skip to content

Phase D.14: Content controls (structured document tags) #27

@loadfix

Description

@loadfix

Add read/write support for content controls (structured document tags / SDT). Upstream python-openxml#155 (15 comments), python-openxml#224 (15 comments).

API Design

Read:

  • document.content_controls — iterate all SDTs in the document body
  • paragraph.content_controls — SDTs within a paragraph
  • ContentControl: .tag, .title, .type (plainText, richText, checkbox, comboBox, dropDown, date, picture)
  • ContentControl.text — get/set the current value
  • ContentControl.checked — for checkbox type

Write:

  • paragraph.add_content_control(type, tag, title) — add an inline SDT
  • body.add_content_control(type, tag, title) — add a block-level SDT

XML

  • Block-level: w:sdt > w:sdtPr (properties) + w:sdtContent (content paragraphs)
  • Inline: w:sdt within w:p > w:sdtPr + w:sdtContent (runs)
  • w:sdtPr children: w:tag, w:alias (title), w:lock, w14:checkbox, w:comboBox, w:dropDownList, w:date

Upstream issues: python-openxml#155, python-openxml#224

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentTriggers the developer agentenhancementNew feature or requestphase-dQuality of Life

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions