Skip to main content

Module word

Module word 

Source
Expand description

Everything from word_ooxml — reading and writing .docx.

Structs§

Bookmark
A named bookmark (w:bookmarkStart’s w:name, CT_Bookmark), attached to one or more runs via Run.bookmarks to mark which run(s) fall within its range. Hyperlink::Internal’s anchor name is meant to match a bookmark’s name here for the resulting link to actually go anywhere in Word — not validated when writing (same best-effort posture as Paragraph.numbering_id referencing a declaration that may not exist).
ColorScheme
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 and w:themeColor-based direct formatting (CT_Color’s theme-color choice, not modeled on Run/ Style itself, which only ever carry literal RGB colors).
Comment
A single comment’s content (<w:comment>, CT_Comment), declared in word/comments.xml and anchored to a range of the body via Run.comment_ids — see that field’s doc comment for how the underlying w:commentRangeStart/w:commentRangeEnd/w:commentReference markers are derived automatically rather than modeled here.
Document
A .docx document: 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.
DocumentProperties
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 — None leaves 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 as Paragraph.numbering_id referencing a declaration that may not exist). A handful of CT_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.
EmbeddedChart
An inline chart (<w:drawing><wp:inline>..), embedded in a run — RunContent::Chart’s payload. Structurally the same wp:inline skeleton as Image (wp:extent/wp:docPr, wrapping an a:graphic/a:graphicData), but the a:graphicData wraps a <c:chart r:id=".."> graphic frame instead of a pic:pic (see writer.rs::write_embedded_chart) — its own graphic-frame wiring rather than a picture’s, even though both live under wp:inline on the Word side.
ExtendedProperties
This document’s extended properties (docProps/app.xml, CT_Properties — confirmed via ECMA-376’s own schema fragment to be an xsd:all group, same “no fixed order” shape as CT_CoreProperties). Only Company/Manager are modeled here: the two fields a user actually edits (shown right next to Title/Author/Category in Word’s own Summary tab, alongside the docProps/core.xml fields already modeled by DocumentProperties). CT_Properties has 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’s writer.rs still always sets Application to identify itself as the producer, same as before this struct existed, but that value isn’t exposed as a settable field here).
FontScheme
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.
HeaderFooter
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_HdrFtr reuses EG_BlockLevelElts, the exact group w:body uses), just without a w:body wrapper or section properties of its own.
Image
An inline image (<w:drawing><wp:inline>..), embedded in a run.
ListLevel
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 group w:body/HeaderFooter use), referenced from the body by id via NoteReference.
NumberingDefinition
A numbering (list) definition declared in word/numbering.xml, referenced from paragraphs (Paragraph.numbering_id) by id.
PageSetup
A document’s page setup (w:sectPr’s pgSz/pgMar/cols, CT_PageSz/ CT_PageMar/CT_Columns) — size, orientation, margins, and an optional equal-width multi-column layout. See Document.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.
StructuredDocumentTag
A block-level structured document tag / content control (<w:sdt>, CT_SdtBlock), wrapping one or more paragraphs/tables — one of the three alternatives EG_ContentBlockContent allows anywhere a Block can appear (body, header/footer, table cell content, a note’s or comment’s own content..), hence a Block variant rather than its own separate top-level list the way Note/Comment are.
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 of Paragraph.tabs.
Table
A table: a sequence of rows.
TableCell
A table cell: a sequence of blocks (paragraphs, and optionally a nested table). CT_Tc reuses the same block-level content model as the document body — w:tbl is a valid child of w:tc per the schema — so a Block::Table here nests a table inside the cell, and a Block::StructuredDocumentTag wraps more blocks the same way it does anywhere else a Block is valid.
TableRow
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 in Document.styles. This crate’s own Style/Run formatting never references a theme slot — color/highlight/underline_color are always literal values, never w:themeColor — so a Theme mainly 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 group w:body/w:sdtContent/etc. share.
BreakKind
The kind of an explicit break (<w:br w:type="..">, CT_Br, ST_BrType), see RunContent::Break.
CellVerticalAlign
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, or TableRow.height_twips forces extra height). Distinct from Paragraph.alignment/Table.alignment (both horizontal).
CustomPropertyValue
A single custom document property’s value (docProps/custom.xml, CT_Property’s value xsd:choice — this crate models 4 of its many variant types: vt:lpwstr (Text), vt:bool (Bool), vt:i4 (Int), vt:r8 (Number)). CT_Property also allows a date variant (vt:filetime) and several others (vectors, blobs, currency..) not modeled here — same “simple case first” scope reduction as DocumentProperties.created/.modified not getting a dedicated date/time type either (no chrono dependency for this crate).
Error
Errors that can occur while reading or writing a .docx document.
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 from Run.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.
ImageFormat
An image’s file format, also determining its media content type.
NoteKind
Which kind of note a RunContent::NoteMarker renders the number of (<w:footnoteRef/>/<w:endnoteRef/>, both CT_Empty).
NoteReference
A reference to a footnote or endnote (<w:footnoteReference>/ <w:endnoteReference>, both CT_FtnEdnRef), placed in the document body to point at a Note declared in Document.footnotes/ Document.endnotes by id.
NumberFormat
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).
ProtectionKind
Which editing restrictions are enforced on a document (w:documentProtection/@w:edit, ST_DocProtect) once Document.protection is Some. ST_DocProtect’s "none" value isn’t modeled as its own variant — Document.protection: Option::None already expresses “no restriction”, same convention as Highlight’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.
StyleKind
Which kind of content a Style applies 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).
TabStopAlignment
How text is aligned relative to a TabStop (w:tab/@val, ST_TabJc).
TextDirection
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).
UnderlineStyle
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 from Run.underline_color (the line’s color, a separate attribute on the same w:u element).
VerticalAlign
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.
VerticalMerge
A table cell’s role in a vertical merge (w:vMerge, CT_VMerge’s val attribute, 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.

Type Aliases§

Result
A Result alias using [Error] as the error type.