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

Types 5

Discriminant for the kind of drawing shape.

RECTANGLE
ELLIPSE
LINE
POLYGON
POLYLINE
PATH
CONNECTOR
GROUP
FRAME
IMAGE
TEXT_BOX
MEASURE
CAPTION
CIRCLE
ARC
CUSTOM
CONTROL
OLE_OBJECT
PLUGIN
FLOATING_FRAME
THREED_SCENE
UNKNOWN
structDrawShape

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.

Fields
string styleName
string textStyleName
string drawId
string layer
string name
string svgX
string svgY
string svgWidth
string svgHeight
string svgViewBox
string svgD
string svgRx
string svgRy
string cornerRadius
string minWidth
string minHeight
string maxWidth
string maxHeight
string x1
string y1
string x2
string y2
string dKind
string points
string pathData
string connectorType
string startShape
string startGluePoint
string endShape
string endGluePoint
string imagePath
string href
string mimeType
string frameName
string anchorType
string textContent
DrawShape[] children
XmlElement[] unknownChildren
string[string] extraAttributes
Methods
bool isContainer() const @safe pure nothrowReturns `true` when this shape can contain child shapes.
bool isEmpty() const @safe pure nothrowReturns `true` when this shape has no meaningful geometry.
structDrawLayer

A single drawing layer (draw:layer).

Fields
string name
string display
string protected_
structDrawPage

A single drawing page (draw:page).

A page is the primary container for shapes in an ODG document.

Fields
string name
string styleName
string masterPageName
string id
DrawShape[] shapes
DrawLayer[] layers
XmlElement[] unknownElements
Methods
size_t shapeCount() const @safe pure nothrowReturns the number of top-level shapes on this page.
bool isEmpty() const @safe pure nothrowReturns `true` when the page has no shapes.

Top-level model for office:drawing body content.

Fields
DrawPage[] pages
XmlElement[] unknownElements
Methods
size_t length() const @safe pure nothrowReturns the number of pages.
bool isEmpty() const @safe pure nothrowReturns `true` when the body has no pages.
const(DrawPage) * findPage(string name) const @trusted nothrowFinds a page by name.

Functions 30

fnDrawPage parseDrawPage(XmlElement pageElement)Parses a `draw:page` XML element into a `DrawPage`.
fnOdfDrawingBody parseDrawingBody(XmlElement drawingElement)Parses an `office:drawing` XML element into an `OdfDrawingBody`.
fnOdfDrawingBody emptyDrawingBody() @safe pure nothrowReturns an empty `OdfDrawingBody`.
fnstring serializeDrawingBody(const ref OdfDrawingBody body)Serialises an `OdfDrawingBody` to an XML fragment string (without the surrounding `<office:drawing>` tags).
fnDrawPage drawPage(string name, DrawShape[] shapes...)Constructs a `DrawPage` with the given name and shapes.
fnDrawShape rectangle(string x, string y, string width, string height, string styleName = "")Constructs a rectangle shape.
fnDrawShape ellipse(string x, string y, string width, string height, string styleName = "")Constructs an ellipse shape.
fnDrawShape line(string x1, string y1, string x2, string y2, string styleName = "")Constructs a line shape.
fnDrawShape groupShape(DrawShape[] children...)Constructs a group shape containing child shapes.
fnDrawShape frame(string x, string y, string width, string height, string styleName = "")Constructs a frame shape for images or text boxes.
fnDrawShape connector(string connectorType, string startShape, string endShape, string styleName = "")Constructs a connector shape.
fnDrawShape polygon(string points, string viewBox, string styleName = "")Constructs a polygon shape.
fnDrawShape polyline(string points, string viewBox, string styleName = "")Constructs a polyline shape.
fnDrawShape path(string pathData, string viewBox, string styleName = "")Constructs a path shape using SVG path data.
fnDrawShape circle(string x, string y, string r, string styleName = "")Constructs a circle shape.
fnDrawShape arc(string x, string y, string width, string height, string dKind = "arc", string styleName = "")Constructs an arc shape.
fnDrawShape textBox(string x, string y, string width, string height, string textContent = "", string styleName = "")Constructs a text box shape.
fnDrawShape caption(string x, string y, string width, string height, string styleName = "")Constructs a caption shape.
fnDrawShape measure(string x1, string y1, string x2, string y2, string styleName = "")Constructs a measure shape (dimension line).
fnDrawShape imageShape(string imagePath, string x, string y, string width, string height, string mimeType = "", string styleName = "")Constructs an image shape embedding a referenced image.
fnDrawShape customShape(string x, string y, string width, string height, string styleName = "")Constructs a custom shape.
fnDrawLayer drawLayer(string name, string display = "true", string protected_ = "false") @safe pure nothrowConstructs a draw layer.
fnstring getDrawAttr(XmlElement el, string qName) @trusted nothrow
fnDrawShapeKind drawShapeKindFromLocal(string local) @safe pure nothrow
fnbool isShapeLocal(string local) @safe pure nothrow
fnstring shapeTag(DrawShapeKind kind) @safe pure nothrow
fnvoid serializeDrawPage(XmlElement parent, ref const DrawPage dp)
fnvoid serializeDrawLayer(XmlElement parent, ref const DrawLayer dl)
fnvoid serializeDrawShape(XmlElement parent, ref const DrawShape s)