ddn.odf.text
Packaged .odt text document model and APIs.
This module provides the text document facade and typed text body model for reading, writing, and creating OpenDocument Text files.
Text constructs
Fully typed:
- Paragraphs (
text:p), headings (text:h), text spans (text:span) - Line breaks (
text:line-break), tabs (text:tab) - Hyperlinks (
text:a), bookmarks (text:bookmark,text:bookmark-start/end) - Ordered/unordered lists (
text:list,text:list-item) - Simple tables (
table:table,table:row,table:cell) - Images in frames (
draw:frame>draw:image) - Footnotes/endnotes (
text:note) - Sections (
text:section) - Common fields (
text:date,text:time,text:page-number, etc.) - Soft page breaks (
text:soft-page-break)
Preservation-first (raw XML retained):
- Tracked changes, form controls, shapes, annotations
- Extension elements from third-party office suites
- Complex draw:frame content beyond simple images
Types 3
Identifies the kind of a text node in the document body.
Used to dispatch on node type without dynamic_cast or class hierarchies.
Discriminated union representing a single inline or block-level text content element.
Each node carries a kind tag and relevant fields depending on the kind. Child nodes are stored in the children array for container nodes (paragraphs, headings, spans, hyperlinks, list items, table cells, sections, notes).
TextNodeKind kindstring styleNamestring textTextNode[] childrenXmlElement rawElementint outlineLevelstring classNamestring hrefstring targetFrameNamestring bookmarkNamestring noteClassstring noteIdstring fieldNamestring formulastring numberColumnsRepeatedstring numberRowsRepeatedstring tableNamestring imagePathstring anchorTypestring frameWidthstring frameHeightstring frameNamestring sectionNamestring sectionConditionbool isContainer() @safe pure nothrow constReturns `true` if this is a container node (paragraph, heading, span, hyperlink, list item, table cell, section, note).string plainText() @safe pure nothrow constExtracts the plain text content from this node and its children.Represents the office:text body of an ODT document.
Contains the top-level block-level nodes (paragraphs, headings, lists, tables, sections, frames, etc.) and provides access to plain text extraction.
string plainText() @safe pure nothrow constExtracts the plain text content from all top-level nodes.Functions 26
void collectParagraphs(const TextNode[] nodes,
ref TextNode[] result) @trusted pure nothrowOdfTextBody parseTextBody(XmlElement textElement)Parses an `office:text` XML element into an `OdfTextBody`.string serializeTextBody(const ref OdfTextBody body)Serialises an `OdfTextBody` to an `office:text` XML element string.TextNode paragraph(string text, string styleName = "") @safe pure nothrowCreates a paragraph node with the given style and text content.TextNode heading(string text, int level, string styleName = "") @safe pure nothrowCreates a heading node with the given outline level and text.TextNode hyperlink(string text, string href, string styleName = "") @safe pure nothrowCreates a hyperlink node.TextNode list(TextNode[] items...) @safe pure nothrowCreates a list node containing the given items.TextNode tableCell(string text, string styleName = "") @safe pure nothrowCreates a table cell node.TextNode imageFrame(string imagePath, string width = "",
string height = "", string anchorType = "paragraph") @safe pure nothrowCreates an image frame node.