ddn.odf.style

Style model for ODF documents.

Covers style containers, font-face declarations, text and paragraph styles, table and cell styles, page layouts, master pages, list styles, and number styles.

Preservation-first: unknown style families, properties, attributes, and child elements are retained for round-trip fidelity.

Types 21

ODF style-family identifiers used to categorise style definitions.

Maps the style:family attribute values found in ODF XML to a typed enumeration. An UNKNOWN sentinel captures families not yet covered by this model.

TEXT
PARAGRAPH
SECTION
TABLE
TABLE_COLUMN
TABLE_ROW
TABLE_CELL
GRAPHIC
DRAWING_PAGE
PAGE_LAYOUT
CHART
PRESENTATION
RUBY
LIST
UNKNOWN
structFontFace

Represents a single <style:font-face> declaration from office:font-face-decls.

Fields
string name
string family
string familyGeneric
string style
string pitch
string charset
string svgFontFamily

Key-value attribute map used for style property containers (text-properties, paragraph-properties, etc.).

Fields
string[string] attributes
Methods
string get(string name, string defaultValue = "") const @safe pure nothrowReturns the value of attribute `name`, or `defaultValue` when absent.
void set(string name, string value) @safe pure nothrowSets `name` to `value`, overwriting any existing entry.
bool has(string name) const @safe pure nothrowReturns `true` if an attribute named `name` exists.
void remove(string name) @safe pure nothrowRemoves the attribute named `name` if present.
structTextStyle

Typed view over common ODF text properties (font, colour, underline, etc.).

Fields
string fontFamily
string fontSize
string fontWeight
string fontStyle
string textDecoration
string textColor
string textUnderlineStyle
string textUnderlineColor
string textPosition
Methods
TextStyle fromProperties(ref const StyleProperties props) @safe pure nothrowConstructs a `TextStyle` from the given property map.
void applyTo(ref StyleProperties props) @safe pure nothrowWrites non-empty fields back into `props`.

Typed view over common ODF paragraph properties (alignment, margins, indentation, spacing, breaks, etc.).

Fields
string textAlign
string textAlignSource
string marginTop
string marginBottom
string marginLeft
string marginRight
string textIndent
string lineHeight
string lineSpacing
string breakBefore
string breakAfter
string keepTogether
string keepWithNext
string widowOrphans
Methods
ParagraphStyle fromProperties(ref const StyleProperties props) @safe pure nothrowConstructs a `ParagraphStyle` from the given property map.
void applyTo(ref StyleProperties props) @safe pure nothrowWrites non-empty fields back into `props`.

Typed accessor for ODF <style:graphic-properties> elements.

Covers frame/image properties such as width, height, position, wrap mode, clipping, and border.

Fields
string width
string height
string minWidth
string minHeight
string relWidth
string relHeight
string horizontalPos
string horizontalRel
string verticalPos
string verticalRel
string anchorType
string wrap
string wrapDynamicThreshold
string runThrough
string clip
string marginRight
string marginLeft
string marginTop
string marginBottom
string border
string backgroundColor
string opacity
string protect
Methods
GraphicStyle fromProperties(ref const StyleProperties props) @safe pure nothrowConstructs a `GraphicStyle` from the given property map.
void applyTo(ref StyleProperties props) @safe pure nothrowApplies typed fields back to a property map.

Typed accessor for ODF <style:drawing-page-properties> elements.

Covers drawing page / presentation master-page properties such as background fill, fill color, and page usage.

Fields
string fillColor
string fill
string fillGradientName
string fillHatchName
string fillImageName
string backgroundSize
string backgroundRepeat
string backgroundNoFill
string opacity
string pageUsage
string displayName
Methods
DrawingPageStyle fromProperties(ref const StyleProperties props) @safe pure nothrowConstructs a `DrawingPageStyle` from the given property map.
void applyTo(ref StyleProperties props) @safe pure nothrowApplies typed fields back to a property map.

Typed accessor for ODF <style:chart-properties> elements.

Covers chart-specific style properties such as symbol type, symbol width/ height, interpolation, link-data-style, data-label-number, label-position, percentage, error-category, error-upper-indicator, error-lower-indicator, error-upper-limit, error-lower-limit, error-margin, series-source, dimension, rotation-angle, gap-width, overlap, deep, lines, solid-type, stacked, vertical, three-dimensional, right-angled-axes, japenese-candle-stick, interpolation, symbol-name, symbol-width, symbol-height.

Fields
string symbolType
string symbolName
string symbolWidth
string symbolHeight
string interpolation
string linkDataStyle
string dataLabelNumber
string labelPosition
string labelPositionNegative
string percentage
string errorCategory
string errorUpperIndicator
string errorLowerIndicator
string errorUpperLimit
string errorLowerLimit
string errorMargin
string seriesSource
string dimension
string rotationAngle
string gapWidth
string overlap
string deep
string lines
string solidType
string stacked
string vertical
string threeDimensional
string rightAngledAxes
string japaneseCandleStick
Methods
ChartStyle fromProperties(ref const StyleProperties props) @safe pure nothrowConstructs a `ChartStyle` from the given property map.
void applyTo(ref StyleProperties props) @safe pure nothrowApplies typed fields back to a property map.

Typed accessor for ODF <style:presentation-properties> elements.

Covers presentation-specific style properties such as transitions, timing, and placeholder settings.

Fields
string transitionType
string transitionStyle
string transitionSpeed
string duration
string visibility
string placeholder
string userTransformed
string fitToSize
string showUnit
string decimalPlaces
Methods
PresentationStyle fromProperties(ref const StyleProperties props) @safe pure nothrowConstructs a `PresentationStyle` from the given property map.
void applyTo(ref StyleProperties props) @safe pure nothrowApplies typed fields back to a property map.

Typed accessor for ODF <style:section-properties> elements.

Covers section-level properties such as background, columns, protection, and writing mode.

Fields
string backgroundColor
string backgroundTransparentColor
string protect
string writingMode
string textColumns
string columnGap
string dontBalanceTextColumns
string editable
Methods
SectionStyle fromProperties(ref const StyleProperties props) @safe pure nothrowConstructs a `SectionStyle` from the given property map.
void applyTo(ref StyleProperties props) @safe pure nothrowApplies typed fields back to a property map.
structRubyStyle

Typed accessor for ODF <style:ruby-properties> elements.

Covers ruby text positioning and alignment.

Fields
string position
string alignment
Methods
RubyStyle fromProperties(ref const StyleProperties props) @safe pure nothrowConstructs a `RubyStyle` from the given property map.
void applyTo(ref StyleProperties props) @safe pure nothrowApplies typed fields back to a property map.

Typed accessor for ODF <style:table-properties> elements.

Covers table-wide properties such as width, background, border model, writing mode, and display/visibility.

Fields
string width
string relWidth
string backgroundColor
string borderModel
string writingMode
string display
string mayBreakBetweenRows
string pageNumber
Methods
TableStyle fromProperties(ref const StyleProperties props) @safe pure nothrowConstructs a `TableStyle` from the given property map.
void applyTo(ref StyleProperties props) @safe pure nothrowApplies typed fields back to a property map.
structCellStyle

Typed accessor for ODF <style:table-cell-properties> elements.

Covers cell-specific properties such as padding, borders, vertical alignment, wrap option, rotation, and data style name.

Fields
string paddingTop
string paddingBottom
string paddingLeft
string paddingRight
string border
string borderTop
string borderBottom
string borderLeft
string borderRight
string verticalAlign
string wrapOption
string rotationAngle
string rotationAlign
string dataStyleName
string backgroundColor
string repeatContent
Methods
CellStyle fromProperties(ref const StyleProperties props) @safe pure nothrowConstructs a `CellStyle` from the given property map.
void applyTo(ref StyleProperties props) @safe pure nothrowApplies typed fields back to a property map.

Typed accessor for ODF <style:table-row-properties> elements.

Covers row height, minimum height, background, break controls, and keep-together.

Fields
string rowHeight
string minHeight
string backgroundColor
string breakBefore
string breakAfter
string keepTogether
string windowHeight
Methods
TableRowStyle fromProperties(ref const StyleProperties props) @safe pure nothrowConstructs a `TableRowStyle` from the given property map.
void applyTo(ref StyleProperties props) @safe pure nothrowApplies typed fields back to a property map.

Typed accessor for ODF <style:table-column-properties> elements.

Covers column width, relative width, break controls, and visibility.

Fields
string columnWidth
string relColumnWidth
string breakBefore
string breakAfter
string visibility
Methods
TableColumnStyle fromProperties(ref const StyleProperties props) @safe pure nothrowConstructs a `TableColumnStyle` from the given property map.
void applyTo(ref StyleProperties props) @safe pure nothrowApplies typed fields back to a property map.

A single ODF <style:style> or <style:default-style> element, carrying its name, family, parent reference, and per-family property maps.

Fields
string name
string parentStyleName
string displayName
bool isDefault
bool isAutomatic
StyleProperties textProperties
StyleProperties paragraphProperties
StyleProperties sectionProperties
StyleProperties tableProperties
StyleProperties tableColumnProperties
StyleProperties tableRowProperties
StyleProperties tableCellProperties
StyleProperties graphicProperties
StyleProperties drawingPageProperties
StyleProperties chartProperties
StyleProperties presentationProperties
StyleProperties rubyProperties
StyleProperties unknownProperties
XmlElement[] unknownChildren

A <style:page-layout> with its page, header, and footer property maps.

Fields
string name
StyleProperties pageProperties
StyleProperties headerProperties
StyleProperties footerProperties

A <style:master-page> element linking a page layout to a master page name.

Fields
string name
string pageLayoutName
string displayName
structListStyle

A <text:list-style> element capturing list-level formatting.

Fields
string name
bool isDefault
string styleName

A data-style element (number:number-style, number:currency-style, etc.) with locale information.

Fields
string name
string numberLanguage
string numberCountry
structOdfStyles

Top-level container for all style information parsed from an ODF document-styles.xml part.

Holds font-face declarations, named styles, automatic styles, default styles, page layouts, master pages, list styles, number styles, and any unrecognised elements.

Fields
FontFace[] fontFaces
StyleDefinition[] automaticStyles
StyleDefinition[] defaultStyles
PageLayout[] pageLayouts
MasterPage[] masterPages
ListStyle[] listStyles
NumberStyle[] numberStyles
XmlElement[] unknownElements

Functions 26

fnOdfStyleFamily parseStyleFamily(string family) @safe pure nothrowConverts an ODF `style:family` attribute string to an `OdfStyleFamily` enum value.
fnstring styleFamilyString(OdfStyleFamily family) @safe pure nothrowConverts an `OdfStyleFamily` enum value back to the corresponding ODF attribute string.
fnOdfStyles parseStyles(const(ubyte)[] xmlBytes)Parses raw `document-styles.xml` bytes into an `OdfStyles` container.
fnOdfStyles parseStylesString(string xml)Parses a `document-styles.xml` string into an `OdfStyles` container.
fnstring serializeStyles(const ref OdfStyles styles)Serialises an `OdfStyles` container back to a well-formed `office:document-styles` XML string.
fnconst(StyleDefinition) * findStyle(const ref OdfStyles styles, string name, bool automatic = false)Looks up a named style in `styles` or `automaticStyles`.
fnconst(StyleDefinition) * findDefaultStyle(const ref OdfStyles styles, OdfStyleFamily family)Looks up a default style by family.
fnOdfDiagnosticCollector validateStyleReferences(const ref OdfStyles styles)Validates internal consistency of an `OdfStyles` container.
fnbool hasStyleName(const ref OdfStyles styles, string name)Returns `true` if any style container (styles, automatic, or default) contains a definition with the given `name`.
fnvoid validateNoDuplicateNames(const ref OdfStyles styles, ref OdfDiagnosticCollector collector)
fnvoid validateParentReferences(const ref OdfStyles styles, ref OdfDiagnosticCollector collector)
fnvoid validateNoCycles(const ref OdfStyles styles, ref OdfDiagnosticCollector collector)
fnvoid validatePageLayoutReferences(const ref OdfStyles styles, ref OdfDiagnosticCollector collector)
fnvoid parseFontFaceDecls(XmlElement el, ref OdfStyles styles)
fnvoid parseStyleContainer(XmlElement el, ref OdfStyles styles, bool isAutomatic)
fnvoid parseMasterStyles(XmlElement el, ref OdfStyles styles)
fnvoid serializeFontFace(XmlElement parent, ref const FontFace ff)
fnvoid serializeStyleDef(XmlElement parent, ref const StyleDefinition s)
fnvoid serializeProps(XmlElement parent, string tagName, ref const StyleProperties props)
fnsize_t findColon(string s) @safe pure nothrow
fnvoid serializePageLayout(XmlElement parent, ref const PageLayout pl)
fnvoid serializeMasterPage(XmlElement parent, ref const MasterPage mp)
fnvoid serializeListStyle(XmlElement parent, ref const ListStyle ls)
fnvoid serializeNumberStyle(XmlElement parent, ref const NumberStyle ns)