dml

package
v0.0.0-...-c46cdd7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package dml provides functionality for working with DrawingML (Drawing Markup Language) which is part of the Office Open XML (OOXML) standard. DrawingML is used to represent graphics and drawings in WordprocessingML, SpreadsheetML, and PresentationML documents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Anchor

type Anchor struct {
	/// Specifies that this object shall be positioned using the positioning information in the
	/// simplePos child element (§20.4.2.13). This positioning, when specified, positions the
	/// object on the page by placing its top left point at the x-y coordinates specified by that
	/// element.
	/// Reference: http://officeopenxml.com/drwPicFloating-position.php
	//Page Positioning
	SimplePosAttr *int `xml:"simplePos,attr,omitempty"`

	/// Specifies the minimum distance which shall be maintained between the top edge of this drawing object and any subsequent text within the document when this graphical object is displayed within the document's contents.,
	/// The distance shall be measured in EMUs (English Mektric Units).,
	//Distance From Text on Top Edge
	DistT uint `xml:"distT,attr,omitempty"`
	//Distance From Text on Bottom Edge
	DistB uint `xml:"distB,attr,omitempty"`
	//Distance From Text on Left Edge
	DistL uint `xml:"distL,attr,omitempty"`
	//Distance From Text on Right Edge
	DistR uint `xml:"distR,attr,omitempty"`

	//Relative Z-Ordering Position
	RelativeHeight int `xml:"relativeHeight,attr"`

	//Layout In Table Cell
	LayoutInCell int `xml:"layoutInCell,attr"`

	//Display Behind Document Text
	BehindDoc int `xml:"behindDoc,attr"`

	//Lock Anchor
	Locked int `xml:"locked,attr"`

	//Allow Objects to Overlap
	AllowOverlap int `xml:"allowOverlap,attr"`

	Hidden *int `xml:"hidden,attr,omitempty"`

	// Child elements:
	// 1. Simple Positioning Coordinates
	SimplePos dmlct.Point2D `xml:"simplePos"`

	// 2. Horizontal Positioning
	PositionH PoistionH `xml:"positionH"`

	// 3. Vertical Positioning
	PositionV PoistionV `xml:"positionV"`

	// 4. Inline Drawing Object Extents
	Extent dmlct.PSize2D `xml:"extent"`

	// 5. EffectExtent
	EffectExtent *EffectExtent `xml:"effectExtent,omitempty"`

	// 6. Wrapping
	// 6.1 .wrapNone
	WrapNone *WrapNone `xml:"wrapNone,omitempty"`

	// 6.2. wrapSquare
	WrapSquare *WrapSquare `xml:"wrapSquare,omitempty"`

	// 6.3. wrapThrough
	WrapThrough *WrapThrough `xml:"wrapThrough,omitempty"`

	// 6.4. wrapTopAndBottom
	WrapTopBtm *WrapTopBtm `xml:"wrapTopAndBottom,omitempty"`

	// 7. Drawing Object Non-Visual Properties
	DocProp DocProp `xml:"docPr"`

	// 8. Common DrawingML Non-Visual Properties
	CNvGraphicFramePr *NonVisualGraphicFrameProp `xml:"cNvGraphicFramePr,omitempty"`

	// 9. Graphic Object
	Graphic Graphic `xml:"graphic"`
}

func NewAnchor

func NewAnchor() *Anchor

func (*Anchor) MarshalWrap

func (a *Anchor) MarshalWrap(e *xml.Encoder) error

func (Anchor) MarshalXML

func (a Anchor) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Anchor) UnmarshalXML

func (a *Anchor) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type DocProp

type DocProp struct {
	ID          uint64 `xml:"id,attr,omitempty"`
	Name        string `xml:"name,attr,omitempty"`
	Description string `xml:"descr,attr,omitempty"`
}

func (DocProp) MarshalXML

func (d DocProp) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*DocProp) UnmarshalXML

func (d *DocProp) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error

type Drawing

type Drawing struct {
	Inline []Inline  `xml:"inline,omitempty"`
	Anchor []*Anchor `xml:"anchor,omitempty"`
	Shape  []*Shape  `xml:"shape,omitempty"`
}

func (Drawing) MarshalXML

func (dr Drawing) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Drawing) UnmarshalXML

func (dr *Drawing) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type DrawingPositionType

type DrawingPositionType string
const (
	DrawingPositionAnchor DrawingPositionType = "wp:anchor"
	DrawingPositionInline DrawingPositionType = "wp:inline"
)

type EffectExtent

type EffectExtent struct {
	LeftEdge   int64 `xml:"l,attr,omitempty"`
	TopEdge    int64 `xml:"t,attr,omitempty"`
	RightEdge  int64 `xml:"r,attr,omitempty"`
	BottomEdge int64 `xml:"b,attr,omitempty"`
}

func NewEffectExtent

func NewEffectExtent(left, top, right, bottom int64) *EffectExtent

func (EffectExtent) MarshalXML

func (x EffectExtent) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Graphic

type Graphic struct {
	Data *GraphicData `xml:"graphicData,omitempty"`
}

func DefaultGraphic

func DefaultGraphic() *Graphic

func NewGraphic

func NewGraphic(data *GraphicData) *Graphic

func NewPicGraphic

func NewPicGraphic(pic *dmlpic.Pic) *Graphic

func (Graphic) MarshalXML

func (g Graphic) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Graphic) UnmarshalXML

func (g *Graphic) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type GraphicData

type GraphicData struct {
	URI string      `xml:"uri,attr,omitempty"`
	Pic *dmlpic.Pic `xml:"pic,omitempty"`
}

func (GraphicData) MarshalXML

func (gd GraphicData) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*GraphicData) UnmarshalXML

func (gd *GraphicData) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type GraphicFrameLocks

type GraphicFrameLocks struct {
	//Disallow Aspect Ratio Change
	NoChangeAspect dmlst.OptBool
}

func (GraphicFrameLocks) MarshalXML

func (g GraphicFrameLocks) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*GraphicFrameLocks) UnmarshalXML

func (g *GraphicFrameLocks) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error

type Inline

type Inline struct {

	//Distance From Text on Top Edge
	DistT uint `xml:"distT,attr,omitempty"`

	//Distance From Text on Bottom Edge
	DistB uint `xml:"distB,attr,omitempty"`

	//Distance From Text on Left Edge
	DistL uint `xml:"distL,attr,omitempty"`

	//Distance From Text on Right Edge
	DistR uint `xml:"distR,attr,omitempty"`

	// Child elements:
	// 1. Drawing Object Size
	Extent dmlct.PSize2D `xml:"extent,omitempty"`

	// 2. Inline Wrapping Extent
	EffectExtent *EffectExtent `xml:"effectExtent,omitempty"`

	// 3. Drawing Object Non-Visual Properties
	DocProp DocProp `xml:"docPr,omitempty"`

	//4.Common DrawingML Non-Visual Properties
	CNvGraphicFramePr *NonVisualGraphicFrameProp `xml:"cNvGraphicFramePr,omitempty"`

	//5.Graphic Object
	Graphic Graphic `xml:"graphic,omitempty"`
}

func NewInline

func NewInline(extent dmlct.PSize2D, docProp DocProp, graphic Graphic) Inline

func (Inline) MarshalXML

func (i Inline) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Inline) UnmarshalXML

func (i *Inline) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type NonVisualGraphicFrameProp

type NonVisualGraphicFrameProp struct {
	GraphicFrameLocks *GraphicFrameLocks `xml:"graphicFrameLocks,omitempty"`
}

func (NonVisualGraphicFrameProp) MarshalXML

func (n NonVisualGraphicFrameProp) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*NonVisualGraphicFrameProp) UnmarshalXML

func (n *NonVisualGraphicFrameProp) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type PoistionH

type PoistionH struct {
	RelativeFrom dmlst.RelFromH `xml:"relativeFrom,attr"`
	PosOffset    int            `xml:"posOffset"`
}

func (PoistionH) MarshalXML

func (p PoistionH) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*PoistionH) UnmarshalXML

func (p *PoistionH) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type PoistionV

type PoistionV struct {
	RelativeFrom dmlst.RelFromV `xml:"relativeFrom,attr"`
	PosOffset    int            `xml:"posOffset"`
}

func (PoistionV) MarshalXML

func (p PoistionV) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*PoistionV) UnmarshalXML

func (p *PoistionV) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Shape

type Shape struct {
	// Required attributes
	ID   *string `xml:"id,attr,omitempty"`
	Type *string `xml:"type,attr,omitempty"`

	// Optional attributes
	Style        *string `xml:"style,attr,omitempty"`
	FillColor    *string `xml:"fillcolor,attr,omitempty"`
	StrokeColor  *string `xml:"strokecolor,attr,omitempty"`
	StrokeWeight *string `xml:"strokeweight,attr,omitempty"`

	// Child elements
	Path      *ShapePath      `xml:"path,omitempty"`
	TextBox   *ShapeTextBox   `xml:"textbox,omitempty"`
	ImageData *ShapeImageData `xml:"imagedata,omitempty"`
	Fill      *ShapeFill      `xml:"fill,omitempty"`
	Stroke    *ShapeStroke    `xml:"stroke,omitempty"`
}

Shape represents a wp:shape element for drawing shapes in Word documents

func NewShape

func NewShape(id, shapeType string) *Shape

NewShape creates a new Shape with the specified ID and type

func (Shape) MarshalXML

func (s Shape) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML marshals the Shape to XML

func (*Shape) UnmarshalXML

func (s *Shape) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals the Shape from XML

func (*Shape) WithFillColor

func (s *Shape) WithFillColor(color string) *Shape

WithFillColor sets the fill color for the shape

func (*Shape) WithImageData

func (s *Shape) WithImageData(relationshipID string) *Shape

WithImageData adds image data to the shape

func (*Shape) WithPath

func (s *Shape) WithPath(v string) *Shape

WithPath adds a path element to the shape

func (*Shape) WithStrokeColor

func (s *Shape) WithStrokeColor(color string) *Shape

WithStrokeColor sets the stroke color for the shape

func (*Shape) WithStrokeWeight

func (s *Shape) WithStrokeWeight(weight string) *Shape

WithStrokeWeight sets the stroke weight for the shape

func (*Shape) WithStyle

func (s *Shape) WithStyle(style string) *Shape

WithStyle sets the style attribute for the shape

func (*Shape) WithTextBox

func (s *Shape) WithTextBox(content string) *Shape

WithTextBox adds a textbox element to the shape

type ShapeFill

type ShapeFill struct {
	Type    *string `xml:"type,attr,omitempty"`
	Color   *string `xml:"color,attr,omitempty"`
	Opacity *string `xml:"opacity,attr,omitempty"`
}

ShapeFill represents fill properties for shapes

func (ShapeFill) MarshalXML

func (sf ShapeFill) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML for ShapeFill

func (*ShapeFill) UnmarshalXML

func (sf *ShapeFill) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML for ShapeFill

type ShapeImageData

type ShapeImageData struct {
	ID    *string `xml:"r:id,attr,omitempty"`
	Title *string `xml:"title,attr,omitempty"`
}

ShapeImageData represents imagedata element for shapes containing images

func (ShapeImageData) MarshalXML

func (sid ShapeImageData) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML for ShapeImageData

func (*ShapeImageData) UnmarshalXML

func (sid *ShapeImageData) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML for ShapeImageData

type ShapePath

type ShapePath struct {
	V           *string `xml:"v,attr,omitempty"`
	ConnectType *string `xml:"connecttype,attr,omitempty"`
	ConnectLocs *string `xml:"connectlocs,attr,omitempty"`
}

ShapePath represents the path element for vector shapes

func (ShapePath) MarshalXML

func (sp ShapePath) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML for ShapePath

func (*ShapePath) UnmarshalXML

func (sp *ShapePath) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML for ShapePath

type ShapeStroke

type ShapeStroke struct {
	Color     *string `xml:"color,attr,omitempty"`
	Weight    *string `xml:"weight,attr,omitempty"`
	DashStyle *string `xml:"dashstyle,attr,omitempty"`
}

ShapeStroke represents stroke properties for shapes

func (ShapeStroke) MarshalXML

func (ss ShapeStroke) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML for ShapeStroke

func (*ShapeStroke) UnmarshalXML

func (ss *ShapeStroke) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML for ShapeStroke

type ShapeTextBox

type ShapeTextBox struct {
	Style *string `xml:"style,attr,omitempty"`
	// Text content would be WordprocessingML paragraphs
	Content string `xml:",innerxml"`
}

ShapeTextBox represents the textbox element for shapes containing text

func (ShapeTextBox) MarshalXML

func (stb ShapeTextBox) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML for ShapeTextBox to set the correct element name

type WrapNone

type WrapNone struct {
	XMLName xml.Name `xml:"wrapNone"`
}

func (WrapNone) MarshalXML

func (w WrapNone) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*WrapNone) UnmarshalXML

func (w *WrapNone) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type WrapPolygon

type WrapPolygon struct {
	Start  dmlct.Point2D   `xml:"start"`
	LineTo []dmlct.Point2D `xml:"lineTo"`
	Edited *bool           `xml:"edited,attr,omitempty"`
}

func (WrapPolygon) MarshalXML

func (wp WrapPolygon) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*WrapPolygon) UnmarshalXML

func (wp *WrapPolygon) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type WrapSquare

type WrapSquare struct {
	XMLName xml.Name `xml:"wrapSquare"`

	//Text Wrapping Location
	WrapText dmlst.WrapText `xml:"wrapText,attr"`

	//Distance From Text (Top)
	DistT *uint `xml:"distT,attr,omitempty"`

	//Distance From Text on Bottom Edge
	DistB *uint `xml:"distB,attr,omitempty"`

	//Distance From Text on Left Edge
	DistL *uint `xml:"distL,attr,omitempty"`

	//Distance From Text on Right Edge
	DistR *uint `xml:"distR,attr,omitempty"`

	EffectExtent *EffectExtent `xml:"effectExtent,omitempty"`
}

func (WrapSquare) MarshalXML

func (ws WrapSquare) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*WrapSquare) UnmarshalXML

func (ws *WrapSquare) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type WrapThrough

type WrapThrough struct {
	XMLName xml.Name `xml:"wrapThrough"`

	//Tight Wrapping Extents Polygon
	WrapPolygon WrapPolygon `xml:"wrapPolygon"`

	// Text Wrapping Location
	WrapText dmlst.WrapText `xml:"wrapText,attr"`

	// Distance From Text on Left Edge
	DistL *uint `xml:"distL,attr,omitempty"`

	// Distance From Text on Right Edge
	DistR *uint `xml:"distR,attr,omitempty"`
}

Through Wrapping

func (WrapThrough) MarshalXML

func (w WrapThrough) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*WrapThrough) UnmarshalXML

func (w *WrapThrough) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type WrapTight

type WrapTight struct {
	XMLName xml.Name `xml:"wrapTight"`

	//Tight Wrapping Extents Polygon
	WrapPolygon WrapPolygon `xml:"wrapPolygon"`

	// Text Wrapping Location
	WrapText dmlst.WrapText `xml:"wrapText,attr"`

	// Distance From Text on Left Edge
	DistL *uint `xml:"distL,attr,omitempty"`

	// Distance From Text on Right Edge
	DistR *uint `xml:"distR,attr,omitempty"`
}

Tight Wrapping

func (WrapTight) MarshalXML

func (w WrapTight) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*WrapTight) UnmarshalXML

func (w *WrapTight) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type WrapTopBtm

type WrapTopBtm struct {
	XMLName xml.Name `xml:"wrapTopAndBottom"`

	//Distance From Text (Top)
	DistT *uint `xml:"distT,attr,omitempty"`

	//Distance From Text on Bottom Edge
	DistB *uint `xml:"distB,attr,omitempty"`

	//Wrapping Boundaries
	EffectExtent *EffectExtent `xml:"effectExtent,omitempty"`
}

Top and Bottom Wrapping

func (WrapTopBtm) MarshalXML

func (w WrapTopBtm) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*WrapTopBtm) UnmarshalXML

func (w *WrapTopBtm) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

Directories

Path Synopsis
Package dmlct provides complex types related to DrawingML (Drawing Markup Language), which is part of the Office Open XML (OOXML) standard.
Package dmlct provides complex types related to DrawingML (Drawing Markup Language), which is part of the Office Open XML (OOXML) standard.
These elements encompass the definition of pictures within the DrawingML framework.
These elements encompass the definition of pictures within the DrawingML framework.
Package dml provides simple types used in DrawingML (Drawing Markup Language), part of the Office Open XML (OOXML) standard for representing graphical elements in documents.
Package dml provides simple types used in DrawingML (Drawing Markup Language), part of the Office Open XML (OOXML) standard for representing graphical elements in documents.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL