Expand description
Everything from word_ooxml — reading and writing .docx.
Structs§
- Bookmark
- A named bookmark (
w:bookmarkStart’sw:name,CT_Bookmark), attached to one or more runs viaRun.bookmarksto mark which run(s) fall within its range.Hyperlink::Internal’s anchor name is meant to match a bookmark’snamehere for the resulting link to actually go anywhere in Word — not validated when writing (same best-effort posture asParagraph.numbering_idreferencing a declaration that may not exist). - Color
Scheme - A theme’s 12-color palette (
<a:clrScheme>,CT_ColorScheme): two dark/ light pairs, six accents, and two hyperlink colors — the palette behind Word’s “Theme Colors” swatches andw:themeColor-based direct formatting (CT_Color’s theme-color choice, not modeled onRun/Styleitself, which only ever carry literal RGB colors). - Comment
- A single comment’s content (
<w:comment>,CT_Comment), declared inword/comments.xmland anchored to a range of the body viaRun.comment_ids— see that field’s doc comment for how the underlyingw:commentRangeStart/w:commentRangeEnd/w:commentReferencemarkers are derived automatically rather than modeled here. - Document
- A
.docxdocument: a sequence of block-level content (paragraphs and tables), in reading order, plus an optional default header/footer and a set of named styles (word/styles.xml) paragraphs/runs can refer to. - Document
Properties - This document’s core properties (
docProps/core.xml,CT_CoreProperties). Every field mirrors a Dublin Core / Dublin Core Terms element Word’s own File > Info panel shows and lets a user edit —Noneleaves the corresponding XML element out entirely (mirrors Word’s own behavior: an absent element is treated as an empty property, not a validation error). Dates (created/modified) are plain ISO-8601/W3CDTF strings (e.g."2026-07-17T10:00:00Z"), not a dedicated date/time type — this crate has no date/time dependency, and two optional metadata fields don’t justify adding one; the caller is responsible for supplying a valid W3CDTF string, not validated when writing (same best-effort posture asParagraph.numbering_idreferencing a declaration that may not exist). A handful ofCT_CoreProperties’ children are not modeled here (dc:identifier,dc:language,cp:lastPrinted,cp:version) — niche fields with no real demand seen yet, same scope-reduction posture as elsewhere in this crate. - Embedded
Chart - An inline chart (
<w:drawing><wp:inline>..), embedded in a run —RunContent::Chart’s payload. Structurally the samewp:inlineskeleton asImage(wp:extent/wp:docPr, wrapping ana:graphic/a:graphicData), but thea:graphicDatawraps a<c:chart r:id="..">graphic frame instead of apic:pic(seewriter.rs::write_embedded_chart) — its own graphic-frame wiring rather than a picture’s, even though both live underwp:inlineon the Word side. - Extended
Properties - This document’s extended properties (
docProps/app.xml,CT_Properties— confirmed via ECMA-376’s own schema fragment to be anxsd:allgroup, same “no fixed order” shape asCT_CoreProperties). OnlyCompany/Managerare modeled here: the two fields a user actually edits (shown right next to Title/Author/Category in Word’s own Summary tab, alongside thedocProps/core.xmlfields already modeled byDocumentProperties).CT_Propertieshas many more children (Words,Pages,Characters,Lines,Paragraphs,TotalTime,Application,AppVersion,DocSecurity,ScaleCrop,LinksUpToDate..) — these are statistics/environment fields Word itself computes when it saves a document, not meaningful for a generation library to set by hand, so they’re deliberately left out (this crate’swriter.rsstill always setsApplicationto identify itself as the producer, same as before this struct existed, but that value isn’t exposed as a settable field here). - Font
Scheme - A theme’s font scheme (
<a:fontScheme>,CT_FontScheme): a heading (“major”) and body (“minor”) typeface, behind Word’s “Theme Fonts” and built-in heading styles. - Header
Footer - The content of a header or footer: a sequence of block-level content (paragraphs and tables) —
the same content model WordprocessingML gives the document body (
CT_HdrFtrreusesEG_BlockLevelElts, the exact groupw:bodyuses), just without aw:bodywrapper or section properties of its own. - Image
- An inline image (
<w:drawing><wp:inline>..), embedded in a run. - List
Level - A single indent level of a
NumberingDefinition(w:lvl,CT_Lvl). - Note
- A single footnote or endnote’s content (
CT_FtnEdn) — the same block-level content model as the document body (EG_BlockLevelElts, the same groupw:body/HeaderFooteruse), referenced from the body by id viaNoteReference. - Numbering
Definition - A numbering (list) definition declared in
word/numbering.xml, referenced from paragraphs (Paragraph.numbering_id) by id. - Page
Setup - A document’s page setup (
w:sectPr’spgSz/pgMar/cols,CT_PageSz/CT_PageMar/CT_Columns) — size, orientation, margins, and an optional equal-width multi-column layout. SeeDocument.page_setup’s doc comment for why only one, document-wide page setup is modeled (no mid-document section breaks). - Paragraph
- A paragraph: a sequence of runs, plus paragraph-level formatting.
- Run
- A run: a contiguous span of content (text, an inline image, or a field) sharing the same formatting.
- Structured
Document Tag - A block-level structured document tag / content control (
<w:sdt>,CT_SdtBlock), wrapping one or more paragraphs/tables — one of the three alternativesEG_ContentBlockContentallows anywhere aBlockcan appear (body, header/footer, table cell content, a note’s or comment’s own content..), hence aBlockvariant rather than its own separate top-level list the wayNote/Commentare. - Style
- A named style declared in
word/styles.xml(CT_Style), applied to paragraphs or runs by id (Paragraph.style_id/Run.style_id). - TabStop
- A single custom tab stop (
w:tab,CT_TabStop), one entry ofParagraph.tabs. - Table
- A table: a sequence of rows.
- Table
Cell - A table cell: a sequence of blocks (paragraphs, and optionally a nested table).
CT_Tcreuses the same block-level content model as the document body —w:tblis a valid child ofw:tcper the schema — so aBlock::Tablehere nests a table inside the cell, and aBlock::StructuredDocumentTagwraps more blocks the same way it does anywhere else aBlockis valid. - Table
Row - A table row: a sequence of cells.
- Theme
- A document’s theme (
word/theme/theme1.xml,CT_OfficeStyleSheet, root element<a:theme>) — the combination of color scheme and font scheme behind Word’s own “Theme Colors”/“Theme Fonts” palettes, and behind what Word’s built-in heading styles (Heading 1-9, Title..) resolve to, since those are defined in terms of theme slots inside Word’s own built-in style definitions rather than anything inDocument.styles. This crate’s ownStyle/Runformatting never references a theme slot —color/highlight/underline_colorare always literal values, neverw:themeColor— so aThememainly matters for controlling those built-in styles’ appearance and for round-tripping a document’s existing theme unchanged.
Enums§
- Alignment
- A paragraph’s horizontal alignment (WordprocessingML
CT_Jc/ST_Jc). - Block
- A single block-level element of a document body: a paragraph, a table, or a structured document
tag (content control) wrapping more blocks. Real WordprocessingML documents freely interleave
these (e.g. a paragraph, then a table, then another paragraph), so this is modeled as a sequence
of blocks rather than separate lists per kind — matching
EG_ContentBlockContent/EG_BlockLevelElts, the actual schema groupw:body/w:sdtContent/etc. share. - Break
Kind - The kind of an explicit break (
<w:br w:type="..">,CT_Br,ST_BrType), seeRunContent::Break. - Cell
Vertical Align - A table cell’s vertical alignment of its content (
w:tcPr/w:vAlign,CT_VerticalJc,ST_VerticalJc) — where the cell’s paragraphs sit within the cell’s full height, when that height exceeds the content’s natural height (e.g. because a neighboring cell in the same row is taller, orTableRow.height_twipsforces extra height). Distinct fromParagraph.alignment/Table.alignment(both horizontal). - Custom
Property Value - A single custom document property’s value (
docProps/custom.xml,CT_Property’s valuexsd:choice— this crate models 4 of its many variant types:vt:lpwstr(Text),vt:bool(Bool),vt:i4(Int),vt:r8(Number)).CT_Propertyalso allows a date variant (vt:filetime) and several others (vectors, blobs, currency..) not modeled here — same “simple case first” scope reduction asDocumentProperties.created/.modifiednot getting a dedicated date/time type either (nochronodependency for this crate). - Error
- Errors that can occur while reading or writing a
.docxdocument. - Field
- A WordprocessingML “simple field” (
<w:fldSimple w:instr="..">,CT_SimpleField) — a value Word computes and keeps up to date, most commonly a page number. - Highlight
- A run’s text highlight color (
<w:highlight w:val="..">,CT_Highlight,ST_HighlightColor) — a fixed palette of “highlighter” colors applied as a background behind a run’s text, distinct fromRun.color(an arbitrary literal RGB text color) and from an arbitrary shaded background fill (w:shd, not modeled). - Hyperlink
- A hyperlink attached to a run (
w:hyperlink,CT_Hyperlink): either a link to an external URL, or a link to a bookmark elsewhere in the same document. - Image
Format - An image’s file format, also determining its media content type.
- Note
Kind - Which kind of note a
RunContent::NoteMarkerrenders the number of (<w:footnoteRef/>/<w:endnoteRef/>, bothCT_Empty). - Note
Reference - A reference to a footnote or endnote (
<w:footnoteReference>/<w:endnoteReference>, bothCT_FtnEdnRef), placed in the document body to point at aNotedeclared inDocument.footnotes/Document.endnotesby id. - Number
Format - How a
ListLevel’s number/bullet is formatted (w:numFmt,ST_NumberFormat). - Orientation
- A page’s orientation (
w:pgSz/@orient,ST_PageOrientation— exactly 2 values). - Protection
Kind - Which editing restrictions are enforced on a document (
w:documentProtection/@w:edit,ST_DocProtect) onceDocument.protectionisSome.ST_DocProtect’s"none"value isn’t modeled as its own variant —Document.protection: Option::Nonealready expresses “no restriction”, same convention asHighlight’s"none"/VerticalAlign’s"baseline"/UnderlineStyle’s"none"elsewhere in this crate. - RunContent
- The content of a
Run: text, a single inline image, a field (e.g. a page number), a reference to a footnote/endnote, or a footnote/endnote’s own number marker. - Style
Kind - Which kind of content a
Styleapplies to (ST_StyleType). - TabLeader
- A
TabStop’s leader character (w:tab/@leader,ST_TabTlc) — repeated between the preceding text and the tab stop itself (e.g. dotted leaders in a table of contents). - TabStop
Alignment - How text is aligned relative to a
TabStop(w:tab/@val,ST_TabJc). - Text
Direction - A table cell’s text flow direction (
w:tcPr/w:textDirection,CT_TextDirection,ST_TextDirection) — used to rotate a cell’s text 90 degrees, a common way to fit a narrow column header (e.g. a label running down a data table’s leftmost column). - Underline
Style - A run’s underline style (
<w:u w:val="..">,CT_Underline,ST_Underline) — the pattern of the line drawn beneath a run’s text (single, double, thick, dotted, dashed, wavy, and combinations of those), distinct fromRun.underline_color(the line’s color, a separate attribute on the samew:uelement). - Vertical
Align - A run’s vertical alignment (
<w:vertAlign w:val="..">,CT_VerticalAlignRun,ST_VerticalAlignRun) — superscript or subscript text, rendered smaller and shifted above/below the normal baseline without otherwise altering the run’s own font size. - Vertical
Merge - A table cell’s role in a vertical merge (
w:vMerge,CT_VMerge’svalattribute,ST_Merge— exactly 2 values).
Constants§
- EMU_
PER_ INCH - The number of EMUs (English Metric Units) per inch, used to convert pixel dimensions to the EMU units WordprocessingML expects.