ddn.odf.draw
ODF drawing document body model.
Provides typed access to office:drawing content for creating and reading OpenDocument Drawing files (.odg).
Drawing constructs
Fully typed:
- Drawing pages (
draw:page) with name, style, and master-page - Layers (
draw:layer) with name and visibility - Basic shapes: rectangle, ellipse, line, polygon, polyline, path
- Connectors between shapes
- Frames with text boxes, images, and custom shapes
- Groups of shapes
- Builder helpers for all shape types (
rectangle(),ellipse(),line(),polygon(),polyline(),pathShape(),circle(),arc(),textBox(),captionShape(),measureShape(),imageShape(),customShape())
Preservation-first (raw XML retained):
- Custom shapes with complex geometry
- 3-D scene elements
- Extension drawing objects from third-party office suites
- Enhanced geometry and glue-point definitions
Coordinate and size parameters
Builder functions like rectangle, ellipse, textBox, etc. accept coordinates and dimensions as rather than numeric types. This is intentional: ODF stores these values in SVG-compatible XML attributes (e.g. svg:x, svg:width) that may include CSS length units — "10mm", "0.5in", "72pt", "50%" — or plain numbers. Passing them through as strings preserves the original unit on read/write round-trips and avoids mandating a default unit.
Types 5
Discriminant for the kind of drawing shape.
A single drawing shape (discriminated union).
Covers the core ODF draw:* shape elements. Fields that only apply to some DrawShapeKind values are left empty for other kinds.
DrawShapeKind kindstring styleNamestring textStyleNamestring drawIdstring layerstring namestring svgXstring svgYstring svgWidthstring svgHeightstring svgViewBoxstring svgDstring svgRxstring svgRystring cornerRadiusstring minWidthstring minHeightstring maxWidthstring maxHeightstring x1string y1string x2string y2string dKindstring pointsstring pathDatastring connectorTypestring startShapestring startGluePointstring endShapestring endGluePointstring imagePathstring hrefstring mimeTypestring frameNamestring anchorTypestring textContentDrawShape[] childrenXmlElement[] unknownChildrenstring[string] extraAttributesA single drawing layer (draw:layer).
string namestring displaystring protected_A single drawing page (draw:page).
A page is the primary container for shapes in an ODG document.
string namestring styleNamestring masterPageNamestring idDrawShape[] shapesDrawLayer[] layersXmlElement[] unknownElementsTop-level model for office:drawing body content.
Functions 30
OdfDrawingBody parseDrawingBody(XmlElement drawingElement)Parses an `office:drawing` XML element into an `OdfDrawingBody`.string serializeDrawingBody(const ref OdfDrawingBody body)Serialises an `OdfDrawingBody` to an XML fragment string (without the surrounding `<office:drawing>` tags).DrawPage drawPage(string name, DrawShape[] shapes...)Constructs a `DrawPage` with the given name and shapes.DrawShape rectangle(string x, string y, string width, string height,
string styleName = "")Constructs a rectangle shape.DrawShape ellipse(string x, string y, string width, string height,
string styleName = "")Constructs an ellipse shape.DrawShape line(string x1, string y1, string x2, string y2,
string styleName = "")Constructs a line shape.DrawShape frame(string x, string y, string width, string height,
string styleName = "")Constructs a frame shape for images or text boxes.DrawShape connector(string connectorType, string startShape,
string endShape, string styleName = "")Constructs a connector shape.DrawShape polygon(string points, string viewBox, string styleName = "")Constructs a polygon shape.DrawShape polyline(string points, string viewBox, string styleName = "")Constructs a polyline shape.DrawShape path(string pathData, string viewBox, string styleName = "")Constructs a path shape using SVG path data.DrawShape arc(string x, string y, string width, string height,
string dKind = "arc", string styleName = "")Constructs an arc shape.DrawShape textBox(string x, string y, string width, string height,
string textContent = "", string styleName = "")Constructs a text box shape.DrawShape caption(string x, string y, string width, string height,
string styleName = "")Constructs a caption shape.DrawShape measure(string x1, string y1, string x2, string y2,
string styleName = "")Constructs a measure shape (dimension line).DrawShape imageShape(string imagePath, string x, string y,
string width, string height, string mimeType = "",
string styleName = "")Constructs an image shape embedding a referenced image.DrawShape customShape(string x, string y, string width, string height,
string styleName = "")Constructs a custom shape.DrawLayer drawLayer(string name, string display = "true",
string protected_ = "false") @safe pure nothrowConstructs a draw layer.void serializeDrawPage(XmlElement parent, ref const DrawPage dp)void serializeDrawLayer(XmlElement parent, ref const DrawLayer dl)void serializeDrawShape(XmlElement parent, ref const DrawShape s)