Pictures and shapes sit inside runs. Modern ones are w:drawing elements in
DrawingML; older ones are w:pict in VML, which files keep alongside DrawingML
for compatibility. The picture’s bytes are a part of their own, usually in
word/media/, reached by a relationship.
A picture in DrawingML
<w:r>
<w:drawing>
<wp:inline distT="0" distB="0" distL="0" distR="0">
<wp:extent cx="1828800" cy="1371600"/>
<wp:docPr id="1" name="Picture 1" descr="A chart of sales"/>
<a:graphic>
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:pic>
<pic:nvPicPr>
<pic:cNvPr id="0" name="image1.png"/>
<pic:cNvPicPr/>
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="rId4"/>
<a:stretch><a:fillRect/></a:stretch>
</pic:blipFill>
<pic:spPr>
<a:xfrm><a:off x="0" y="0"/><a:ext cx="1828800" cy="1371600"/></a:xfrm>
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
</pic:spPr>
</pic:pic>
</a:graphicData>
</a:graphic>
</wp:inline>
</w:drawing>
</w:r>
| Element | Meaning |
|---|---|
wp:inline | The picture sits in the line of text, like a large character. |
wp:anchor | The picture floats, placed relative to the page, margin or paragraph: wp:positionH, wp:positionV, wrapping elements, behindDoc. |
wp:extent | The size: cx and cy in EMU, 914,400 to the inch. |
wp:docPr | Identity and alternative text: name, descr, title. |
a:blip | The image: r:embed for a part in the package, r:link for an external file. |
Common image parts are PNG, JPEG, GIF, TIFF and BMP. Word also writes EMF and WMF
pictures, and SVG with a PNG beside it as an extension of the blip. An r:link points outside
the file, and the viewer on this site never loads it.
VML
VML is the older drawing language, in the namespaces with prefixes v and
o. It appears in older documents, and in the fallback of
mc:AlternateContent.
<w:pict>
<v:shape style="width:144pt;height:108pt" type="#_x0000_t75">
<v:imagedata r:id="rId5" o:title="Picture"/>
</v:shape>
</w:pict>
VML is defined in ECMA-376 Part 4 (chapter 19, transitional only). The pieces a reader meets most:
v:shape(§19.1.2.19) is the core object. If itstypenames av:shapetype(§19.1.2.20), the attributes of the shape override those of the shape type.adjis a comma list of up to eight adjustment values that formulas read as#0to#7.altis the alternative text.fillcolor,stroked,strokecolorandstrokeweight(default 1 point; a bare number is EMU) set the look, and thev:fill,v:stroke,v:shadowandv:pathchildren override them.- The
styleattribute is a CSS2 list ofname:valuepairs separated by semicolons. Sizes are numbers withcm,mm,in,pt,pc,px,emorex, or percentages; with no unit the value is pixels. Inside a group they are in the coordinate system of the group instead. The properties areposition(static,absoluteorrelative; absolute inside a group; the default is static, which for an inline shape means the flow),left,top,width,height,margin-left,margin-top(and right, bottom),z-index,rotation(degrees, clockwise),flip(x,y,xy,yx),visibility(onlyhiddenandinherit), and for Word the placement propertiesmso-position-horizontal,mso-position-horizontal-relative,mso-position-vertical,mso-position-vertical-relative,mso-wrap-distance-*,mso-wrap-style(squareornone) andmso-wrap-edited. A text box addslayout-flow,direction,v-text-anchor,mso-fit-shape-to-text,mso-fit-text-to-shape,mso-next-textbox(linked text boxes),mso-rotateandmso-text-scale.
What the viewer does with VML
In the Pages section, v:shape, v:rect, v:roundrect and
v:oval (at most twenty in one run) are drawn as an inline box of the size given by the
width and height of style, with the units above except
em, ex and percentages. A v:imagedata picture is shown at that
size; a v:textbox shows its w:txbxContent in a box outlined with the stroke
weight and colour (unless stroked is false) and filled with the fill colour; a
visibility:hidden shape leaves its space empty.
Vector shapes are drawn as SVG (module vmlshape.js), following Part 4:
- Shape type:
v:shapetypeattributes and children (path, formulas, fill, stroke) apply under the shape's own (§19.1.2.19). - Coordinates:
coordsize(default 1000,1000) andcoordoriginmap path units onto the width and height of the shape. - Path commands (§19.1.2.14):
mmove,lline,cBezier curve,xclose,eend,t,randvrelative moves, lines and curves,nf/nsno fill / no stroke,qx,qy,qbquarter ellipses and splines, and the arcswaandwr(clockwise) andatandar(counter-clockwise). The direction of these path arcs is read from the text and not compared with a real Word file (the direction of thev:arcelement is fixed by a spec example, below). - Formulas (§19.1.2.4): the operations of the table, with 32-bit integer results,
#nadjustments,@nearlier formulas and the named values (width,heightand the others the table lists). The arrow example of the spec draws as the arrow it describes (a test checks the first path coordinates). - Fill and stroke:
fillcolor,filled,strokecolor,strokeweight(a bare number is EMU),stroked,v:fill colorandv:strokecolour, weight,on,endcap, numericdashstylestrings. Colours are the sixteen names of §20.1.2.3 and#rrggbb.v:roundrectcorners usearcsizeas a fraction of half the shorter side (default 20%, §19.1.2.17). - Groups (§19.1.2.7): the children's
left,top,widthandheightare in the group'scoordsize/coordoriginspace and are scaled to the group's size, up to six levels deep.rotationandflipare applied. - Text paths (§19.1.2.23): the
stringis set as plain text fitted to the shape; the warp of the preset (fitpath,fitshape) is not applied, and the path outline is then not drawn.
- Other shape elements (§19.1.2.12, §19.1.2.15, §19.1.2.3, §19.1.2.1):
v:line(from,to),v:polyline(points),v:curve(from,control1,control2,to) are drawn in the bounding box of their points (the style position and size are ignored, as the spec says for a curve), andv:arcfrom the width and height of the style withstartAngle(default 0) andendAngle(default 90), measured clockwise from the vertical, the arc running clockwise: the spec example with 90 and 270 is the half circle open at the top. The schema spells the attributes in camel case, the prose in lower case; both are read. - Gradient fills (§19.1.2.5):
type="gradient"withangle,colorsandfocus, andgradientradialwithfocuspositionare drawn on shapes and on the page background. The spec describes focus 0, 50%, -50% and +-100%; the drawing follows one model that fits those (for a positive focus the second colour sits at 1 minus the focus, for a negative focus the first colour sits at its absolute value), so other focus values are an extension that the page notes.focussizeandmethodare not applied: the standard gives no size rule for the radial centre and no curve for the defaultsigmablend (19.1.2.5), so the colours run linearly. - Dash names and arrowheads (§19.1.2.21): the ten dash names are drawn with the usual ratios (the
spec names them but gives no lengths), and
startarrow/endarrow(block,classic,diamond,oval,open) withnarrow/medium/wideandshort/medium/longare drawn as SVG markers 2, 3 or 5 line widths in size (the spec gives no sizes), on paths that are not closed.
Angle ellipses: the path commands al and ae (19.1.2.14: centre, the two
radii, start and end angle in 1/65536 degree) are drawn; the full circle 0 to 23592960 is exact.
The standard does not say which way a partial angle grows; the viewer lets it grow clockwise on screen and says so in a page note.
Compound lines: thinThin (two thin lines) and thickBetweenThin are drawn by cutting
gaps out of the stroke with an SVG mask. The standard (19.1.3.12) gives no proportions: one third each, and 1:1:3:1:1, are the viewer's choice and a note says so.
Picture fills: v:fill of type frame stretches the picture over the
shape and tile repeats it at size (lengths or percentages, 19.1.2.5); a tile without
size is drawn stretched, with a note.
Not drawn, and said in a note on the page: bitmap pattern fills,
the compound line styles thickThin and thinThick (drawn as a single line), extrusion, palette colour names. A v:shadow of type single or double
is drawn as offset copies of the shape in color and color2 (19.1.2.18);
perspective, emboss, matrix and origin are drawn as a plain offset shadow with a note. Not applied
to the layout: left, top, position and the
mso-position-* properties of top-level shapes (a floating VML shape is drawn inline,
where Word places it on the page or the margin), mso-wrap-*, z-index,
layout-flow, v-text-anchor and linked text boxes. Any other shape is drawn
as a labelled empty box.
Divergence from programs: LibreOffice (headless PDF export, tried here) draws the spec's arrow path and a quarter-arc
path as a tiny shape in the corner (its import of coordsize with formulas differs from the
text of §19.1.2.4), while its rectangle, rounded rectangle and ellipse agree with this drawing. The
viewer follows the spec text. Spec inconsistencies met: the gradient angle examples contradict the
prose, and the preset dash ratios are not given.
Shapes, text boxes and charts
Word 2010 and later shapes use wps:wsp inside w:drawing, and
are usually in the Choice of an mc:AlternateContent with VML in the
Fallback. A text box holds w:txbxContent, whose children are ordinary
block-level content: paragraphs and tables. A chart has a
c:chart element whose relationship points to a chart part, normally in
word/charts/, which has an embedded workbook of its data. SmartArt uses
dgm:relIds and several diagram parts.
What the viewer does with charts
The chart code is shared with the PowerPoint viewer (pptx/chart.js), read from the code,
not from a spec comparison. In the Pages section a c:chart reference is drawn from the chart
part's cached values (c:numCache, c:strCache); the embedded workbook is not
opened. Only the first plot element inside c:plotArea whose name ends in
Chart is drawn, so a combined chart (bars with a line, or a secondary axis) shows its first
group only. Bar and column (also 3-D, drawn flat; clustered, stacked and percent stacked), line, area,
scatter and bubble (drawn as scatter), pie, doughnut and pie-of-pie (drawn as one pie), radar and stock
(drawn as lines) are drawn; a 3-D surface chart (c:surface3DChart) is drawn through c:view3D by the same code as in the spreadsheet viewer (see the xlsx charts page for the projection and the Divergence notes; measured in Microsoft Excel, assumed for Word). Titles, legends at
right, left, top or bottom, series colours and markers are drawn. If the part cannot be read or has no
series, a labelled empty box is shown. The simple-type values of section 21.2.3 are listed below and
were compared with what pptx/chart.js reads; the gaps are listed under "Viewer coverage".
In the Pages section of a .docx three more things are drawn. A title with c:layout/c:manualLayout (21.2.2.95) sits
at its x and y, as fractions of the chart when xMode and yMode are edge and as a shift from the
default place otherwise; a data label with a manual layout is moved the same way. A c:dateAx (21.2.2.39) puts the
categories on a time scale on line and area charts: the base unit is c:baseTimeUnit (or, when absent, chosen from the smallest gap between
dates: years, months or days), the ticks fall every c:majorUnit of c:majorTimeUnit, and labels use the axis number format,
else the format code of the categories; the specification gives no rule for the automatic base unit, so that choice is the viewer’s own.
The style numbers c:style and c14:style colour axes, gridlines and areas (see Divergence from spec on the DOCX page). Bar
charts and the other kinds still treat a date axis as a text axis.
Chart colours without a theme part. a:schemeClr in a chart (accent1 to accent6, tx1, bg1 and so on) names a colour of the document’s theme, and a WordprocessingML package has
zero or one theme part (ECMA-376 Part 1, 14.2.7). c:clrMapOvr (21.2.2.30) only remaps the scheme slots (“to override the application’s colour mapping if the user has selected keep source formatting
after a copy-paste”); it supplies no colours. Divergence from spec: the specification says nothing about a package that has no theme part, so the viewer uses the Office colour scheme
(dk1 000000, lt1 FFFFFF, dk2 44546A, lt2 E7E6E6, accent1 4472C4, accent2 ED7D31, accent3 A5A5A5, accent4 FFC000, accent5 5B9BD5, accent6 70AD47), the scheme a new Office document carries, instead of the grey it drew before.
This is an assumption: a probe of Microsoft Word for Mac on such a document (research/docx/word/notheme.applescript) stalled with an Apple event time-out before it saved a PDF, so Word’s own choice is not measured.
A document with a theme part is unaffected.
Stock chart axis (behaviour taken from Microsoft Excel). A c:stockChart in the Pages section gets the same automatic value axis as in the
spreadsheet viewer, because the chart code is shared: Excel for Mac’s automatic axis of an Open-High-Low-Close chart was read in nine cases
(research/xlsx/excel/stock-axis-excel.txt). With the lowest value lo and the highest hi, both above 0, the axis starts at 0 when lo / hi is under 5/6, else at
lo − (hi − lo) / 2; it ends at hi + (hi − lo) / 20; the major unit is the smallest of 1, 2 and 5 times a power of ten that gives at most 10 intervals, and
the limits are rounded outwards. The measurements were made in Excel on charts written by Excel, not in Word, so that Word draws a stock chart in a .docx the same way
is an assumption (both use Office’s chart engine). Divergence from spec: ECMA-376 does not say how an automatic axis is scaled; a c:min or
c:max in the axis still wins, and values at or below 0 keep the general rule.
Chart values (ECMA-376 Part 1, 21.2.3)
The root of a chart part is c:chartSpace; c:chart holds the title, the
c:plotArea (one or more *Chart groups, then the axes) and the legend. Values read
from section 21.2.3 of the specification:
ST_BarDir:bar(horizontal rectangles) orcol(vertical).ST_BarGrouping:clustered,percentStacked,stacked,standard(series along the depth axis).ST_Grouping(line and area charts):percentStacked,stacked,standard.ST_AxPos:b,l,r,t.ST_LegendPos:b,l,r,t,tr.ST_Orientation:minMax(usual order) ormaxMin(axis reversed).ST_CrossBetween:betweenormidCat.ST_Crosses:autoZero,max,min.ST_TickLblPos:high,low,nextTo,none.ST_TickMark:cross,in,none,out.ST_TimeUnit:days,months,years.ST_BuiltInUnitdivides axis values by 100 (hundreds) up to 1012 (trillions): hundreds, thousands, tenThousands, hundredThousands, millions, tenMillions, hundredMillions, billions, trillions.ST_DispBlanksAs:gap,span,zero.ST_DLblPos:b,bestFit,ctr,inBase,inEnd,l,outEnd,r,t.ST_ErrBarType:both,minus,plus.ST_ErrDir:x,y.ST_ErrValType:cust,fixedVal,percentage,stdDev,stdErr.ST_MarkerStyle: circle, dash, diamond, dot, none, picture, plus, square, star, triangle, x;ST_MarkerSize2 to 72 points.ST_RadarStyle:filled(lines and fill, no markers),marker(lines and markers, no fill),standard(lines only).ST_ScatterStyle: line, lineMarker, marker, none, smooth, smoothMarker.ST_TrendlineType: exp, linear, log (natural logarithm), movingAvg (ST_Periodat least 2), poly (ST_Order2 to 6), power.ST_SizeRepresents:areaorw(radius proportional).- Ranges:
ST_FirstSliceAng0 to 360;ST_HoleSize1% to 90%;ST_GapAmount0% to 500%;ST_Overlap-100% to 100%;ST_BubbleScale0% to 300%;ST_SecondPieSize5% to 200%;ST_LblOffset0% to 1000%;ST_LogBase2 to 1000;ST_RotX-90 to 90;ST_RotY0 to 360;ST_DepthPercent20% to 2000%;ST_HPercent5% to 500%;ST_Style1 to 48 (default formatting tables 1 to 4 in 21.2.3.46). ST_OfPieType:pieorbar;ST_SplitType: auto, cust, percent, pos, val.ST_Shape(3-D markers): box, cone, coneToMax, cylinder, pyramid, pyramidToMax.ST_PictureFormat: stack, stackScale, stretch.ST_LayoutMode:edgeorfactor;ST_LayoutTarget:innerorouter.
Chart child orders (dml-chart.xsd)
Read from research/ooxml/ecma376/p4/xsd-transitional/dml-chart.xsd (all 1499 lines). Every
element is optional unless marked required; c:extLst is last wherever it is allowed. Most
leaf elements are one of three types: CT_Boolean (val, default true),
CT_Double and CT_UnsignedInt (val required).
| Element | Children, in this order |
|---|---|
c:chartSpace | date1904, lang, roundedCorners, style, clrMapOvr, pivotSource, protection, chart (required), spPr, txPr, externalData (required r:id; child autoUpdate), printSettings (headerFooter, pageMargins, pageSetup, legacyDrawingHF), userShapes (r:id), extLst. |
c:chart | title, autoTitleDeleted, pivotFmts, view3D, floor, sideWall, backWall, plotArea (required), legend, plotVisOnly, dispBlanksAs (default zero), showDLblsOverMax, extLst. |
c:title | tx (strRef or rich), layout, overlay, spPr, txPr, extLst. |
c:view3D | rotX (default 0), hPercent (100%), rotY (0), depthPercent (100%), rAngAx, perspective (default 30, 0 to 240), extLst. |
c:floor, c:sideWall, c:backWall (CT_Surface) | thickness (unsigned integer or percent), spPr, pictureOptions (applyToFront, applyToSides, applyToEnd, pictureFormat, pictureStackUnit), extLst. |
c:layout / c:manualLayout | layout: manualLayout, extLst. manualLayout: layoutTarget (default outer), xMode, yMode, wMode, hMode (default factor), x, y, w, h, extLst. |
c:plotArea | layout, then one or more chart groups in any order (areaChart, area3DChart, lineChart, line3DChart, stockChart, radarChart, scatterChart, pieChart, pie3DChart, doughnutChart, barChart, bar3DChart, ofPieChart, surfaceChart, surface3DChart, bubbleChart), then any number of axes (valAx, catAx, dateAx, serAx), dTable, spPr, extLst. |
c:dTable | showHorzBorder, showVertBorder, showOutline, showKeys, spPr, txPr, extLst. |
| Shared axis group | axId (required), scaling (required), delete, axPos (required), majorGridlines, minorGridlines, title, numFmt, majorTickMark (default cross), minorTickMark, tickLblPos (default nextTo), spPr, txPr, crossAx (required), then one of crosses or crossesAt. |
c:scaling | logBase (2 to 1000), orientation (default minMax), max, min, extLst. |
c:catAx | shared axis group, auto, lblAlgn, lblOffset (default 100%), tickLblSkip, tickMarkSkip, noMultiLvlLbl, extLst. |
c:dateAx | shared axis group, auto, lblOffset, baseTimeUnit, majorUnit, majorTimeUnit, minorUnit, minorTimeUnit, extLst. |
c:serAx | shared axis group, tickLblSkip, tickMarkSkip, extLst. |
c:valAx | shared axis group, crossBetween, majorUnit, minorUnit, dispUnits (custUnit or builtInUnit, then dispUnitsLbl with layout, tx, spPr, txPr), extLst. |
c:barChart | barDir (required), grouping (default clustered), varyColors, ser*, dLbls, gapWidth (default 150%), overlap (0%), serLines*, axId (exactly 2), extLst. |
c:bar3DChart | barDir, grouping, varyColors, ser*, dLbls, gapWidth, gapDepth, shape (default box), axId (2 or 3), extLst. |
c:lineChart | grouping (required), varyColors, ser*, dLbls, dropLines, hiLowLines, upDownBars (gapWidth, upBars, downBars), marker, smooth, axId (exactly 2), extLst. c:line3DChart: grouping, varyColors, ser*, dLbls, dropLines, gapDepth, axId (exactly 3), extLst. |
c:stockChart | ser (3 or 4 line series), dLbls, dropLines, hiLowLines, upDownBars, axId (exactly 2), extLst. |
c:areaChart | grouping, varyColors, ser*, dLbls, dropLines, axId (exactly 2), extLst. c:area3DChart: same shared part, gapDepth, axId (2 or 3), extLst. |
c:scatterChart | scatterStyle (required, default marker), varyColors, ser*, dLbls, axId (exactly 2), extLst. |
c:radarChart | radarStyle (required, default standard), varyColors, ser*, dLbls, axId (exactly 2), extLst. |
c:pieChart | varyColors, ser*, dLbls, firstSliceAng, extLst. c:pie3DChart: varyColors, ser*, dLbls, extLst (no axes, no angle). c:doughnutChart: varyColors, ser*, dLbls, firstSliceAng, holeSize (default 10%), extLst. |
c:ofPieChart | ofPieType (required, default pie), varyColors, ser*, dLbls, gapWidth, splitType (default auto), splitPos, custSplit (secondPiePt*), secondPieSize (default 75%), serLines*, extLst. |
c:bubbleChart | varyColors, ser*, dLbls, bubble3D, bubbleScale (default 100%), showNegBubbles, sizeRepresents (default area), axId (exactly 2), extLst. |
c:surfaceChart | wireframe, ser*, bandFmts (bandFmt: idx, spPr), axId (2 or 3), extLst. c:surface3DChart: same, axId exactly 3. |
| Series (all kinds) | idx and order (both required), tx (strRef or literal v), spPr, then by kind. Line: marker, dPt*, dLbls, trendline*, errBars, cat, val, smooth. Scatter: marker, dPt*, dLbls, trendline*, errBars (up to 2), xVal, yVal, smooth. Radar: marker, dPt*, dLbls, cat, val. Bar: invertIfNegative, pictureOptions, dPt*, dLbls, trendline*, errBars, cat, val, shape. Area: pictureOptions, dPt*, dLbls, trendline*, errBars (up to 2), cat, val. Pie: explosion, dPt*, dLbls, cat, val. Bubble: invertIfNegative, dPt*, dLbls, trendline*, errBars (up to 2), xVal, yVal, bubbleSize, bubble3D. Surface: cat, val. Every series ends with extLst. |
| Data sources | cat/xVal: one of multiLvlStrRef, numRef, numLit, strRef, strLit. val/yVal/bubbleSize: numRef or numLit. numRef/strRef: f (required), cache (numCache, strCache), extLst. numCache: formatCode, ptCount, pt* (each with required idx and one v), extLst. multiLvlStrCache: ptCount, lvl* (pt*), extLst. |
c:dPt | idx (required), invertIfNegative, marker (symbol, size 2 to 72 default 5, spPr, extLst), bubble3D, explosion, spPr, pictureOptions, extLst. |
c:dLbls | dLbl*, then either delete or the group: numFmt, spPr, txPr, dLblPos, showLegendKey, showVal, showCatName, showSerName, showPercent, showBubbleSize, separator, showLeaderLines, leaderLines; extLst. c:dLbl: idx (required), then delete or (layout, tx, and the same shared group from numFmt to separator), extLst. |
c:trendline | name, spPr, trendlineType (required, default linear), order (2 to 6), period (at least 2), forward, backward, intercept, dispRSqr, dispEq, trendlineLbl (layout, tx, numFmt, spPr, txPr, extLst), extLst. |
c:errBars | errDir, errBarType (required, default both), errValType (required, default fixedVal), noEndCap, plus, minus, val, spPr, extLst. |
c:legend | legendPos (default r), legendEntry* (idx, then delete or txPr, extLst), layout, overlay, spPr, txPr, extLst. |
Viewer coverage of charts
The chart code (pptx/chart.js) is shared with other formats. The Word viewer turns on two
options of it, so the output for the other callers is unchanged. The first (extras) is the
one the spreadsheet viewers use: the axis c:min, c:max and c:majorUnit,
axis number formats, gridlines only where c:majorGridlines exists, markers, data labels,
trend lines, error bars, the oblique 3-D columns of c:view3D, surface charts seen from above,
and further bar, line and area groups sharing the first group's axes. The second
(chartOptions) draws the following, each from the clause named:
- the pie and doughnut first-slice angle (
c:firstSliceAng, degrees clockwise from twelve o'clock) and the doughnut hole size (c:holeSize, 1 to 90 percent of the diameter; 55 percent without it); - data labels:
c:numFmt(formatCode, unlesssourceLinkedis 1) formats the values, andc:dLblPos(21.2.2.48) places each label:tabove (the default),bbelow,landrbeside the point,ctr,inEnd,inBaseandoutEndagainst a bar;c:dTable(21.2.2.54) adds a table of the category names and series values under the plot; c:style(ST_Style, 21.2.3.46): only the series colours of Table 5 are applied, for styles 3 to 8 and the same positions of each further group of eight (a fade of accent1 to accent6, shade for the first series to tint for the last, from −70 + 140 × idx / (highest idx + 1) percent); a series with a fill of its own keeps it. The chart area, wall, axis and gridline defaults of Tables 2 to 4, the patterns of styles 1, 2, 9, 10, 17, 18, 25, 26 and the effects are not applied (anmc:AlternateContentc14:styleis not read either);- date axes:
c:dateAxis drawn as a text category axis, equally spaced, without the date scale (c:baseTimeUnit,c:majorUnit,c:majorTimeUnit); of manual layouts (c:layout) the plot area’s and the legend’s (position only, not its size) are read; those of titles and data labels are not; - line charts:
c:smooth(21.2.2.194) as a Catmull-Rom spline through the points;c:dispBlanksAs(21.2.2.42) asgap(a break in the line),zero(the blank plotted as 0) orspan(joined, also used when the element is absent);c:dropLines(21.2.2.53, from every point to the category axis),c:hiLowLines(21.2.2.80, per category from the highest to the lowest point) andc:upDownBars(21.2.2.218, per category from the first series to the last,c:upBarswhen the last is higher,c:downBarsotherwise; the bar width followsc:gapWidth, default 150 percent); - line and column charts: the value axis
c:orientationmaxMin(21.2.3.30) reverses the scale, and the category axis one reverses the categories;c:logBase(21.2.2.98, 2 to 1000) gives a logarithmic axis from a power of the base below the smallest positive value to the power above the largest;c:dispUnits(21.2.2.45) divides the axis labels byc:builtInUnit(21.2.3.6: hundreds to trillions) orc:custUnit; - column and line charts: series data labels (
c:dLbls, 21.2.2.49) with the flagsshowVal,showCatName,showSerNameandshowPercent, and a point's ownc:dLbl(its flags, or hidden byc:delete); the label sits above the point,c:dLblPosand the number format of the labels are not read; - trend lines (
c:trendline: linear, polynomial, exponential, logarithmic, power, moving average) and error bars (c:errBars: fixed, percentage, standard deviation, standard error, custom) on column and line series, drawn as in the spreadsheet viewer, which compared them with LibreOffice; - the plot area's
c:manualLayout(x, y, w, h as fractions of the chart;xModeandyModeedge or factor;wModeandhModeedge or factor;layoutTargetinner or outer) for charts with axes.
Not drawn: secondary axes (a second value axis is not drawn on its own scale), date axes and time units
(a date category is shown as its text), data tables (c:dTable), the position and number
format of data labels, the legend entries of trend lines, the chart styles of ST_Style, the display-unit label text, the
move of the other axis to the opposite side when an axis is reversed, maxMin on horizontal
bars, the manual layout of pie charts, and the manual layout of titles, legends and labels. These stay
Not described items for the viewer, so the DOCX count stays partial. There is no Word-rendered or LibreOffice
picture of these cases on this site; the tests check that each option changes the drawing as the clause says.
Embedded objects
w:object holds a preview picture in VML and an o:OLEObject
element whose ProgID names the program and whose r:id points to
the data, usually a part in word/embeddings/. Embedded Office documents are
whole files of their own: a .xlsx or .docx inside the package.
A .bin part holds other OLE objects.
wp:inline and wp:anchor in detail
Compared with ECMA-376 Part 1, 20.4.2 and 20.4.3 (research/ooxml/ecma376/p1/part1.txt) and the
Transitional schema dml-wordprocessingDrawing.xsd (CT_Inline, CT_Anchor).
Child order
| Element | Children, in this order |
|---|---|
wp:inline (CT_Inline) | wp:extent (required), wp:effectExtent (optional), wp:docPr (required), wp:cNvGraphicFramePr (optional), a:graphic (required). Attributes distT distB distL distR, all optional. |
wp:anchor (CT_Anchor) | wp:simplePos (required), wp:positionH, wp:positionV, wp:extent, wp:effectExtent (optional), one wrapping element (wrapNone, wrapSquare, wrapTight, wrapThrough or wrapTopAndBottom), wp:docPr, wp:cNvGraphicFramePr (optional), a:graphic. Required attributes: relativeHeight, behindDoc, locked, layoutInCell; optional: distT/B/L/R, simplePos, hidden, allowOverlap. |
wp:positionH, wp:positionV | Required attribute relativeFrom; exactly one child, either wp:align or wp:posOffset (an int, in EMU, measured from the top-left of the base). |
wp:effectExtent | No children; l t r b all required, ST_Coordinate in EMU. The extra size added on each edge for shadows and reflections (20.4.2.6); it sizes the wrap box for wraps without a polygon and the line height of an inline object. |
wp:wrapSquare | Optional wp:effectExtent; wrapText required; distT/B/L/R optional. |
wp:wrapTight, wp:wrapThrough | One wp:wrapPolygon (required); wrapText required; distL, distR optional. |
wp:wrapPolygon (CT_WrapPath) | One wp:start, then at least two wp:lineTo (each an x, y point); attribute edited (boolean). If the last point is not the start point, one closing line is inferred (20.4.2.16). |
wp:wrapNone, wp:wrapTopAndBottom | wrapNone has no attributes (the object is in front of the text when behindDoc is false, behind it when true); wrapTopAndBottom has distT and distB only. |
wps:wsp (CT_WordprocessingShape) | optional cNvPr; cNvSpPr or cNvCnPr; spPr (required); optional style, extLst; then optionally one of txbx or linkedTxbx, then bodyPr (required). Attribute normalEastAsianFlow ignores the vert value of bodyPr and flows as tbV when true (20.4.2.42). |
wps:txbx / wps:linkedTxbx | txbx holds w:txbxContent; its id (unsignedShort, default 0) names the text box story and must be unique in the document. linkedTxbx has required id and seq and starts no story of its own (20.4.2.34, 20.4.2.37). w:txbxContent must not contain references to comments, footnotes or endnotes, VML, or another txbxContent (20.4.2.38). |
wpg:wgp (CT_WordprocessingGroup) | optional cNvPr; cNvGrpSpPr and grpSpPr (required); then any number of wps:wsp, nested wpg:grpSp, wpg:graphicFrame, pic:pic and wpg:contentPart; optional extLst. |
wpg:contentPart | A reference to XML in another format (the standard names MathML, SMIL, SVG), through r:id, with relationship type customXml and internal target (20.4.2.29). An application that cannot read the part should go on and, if it can, say that content was left out. |
Values
| Type | Values |
|---|---|
ST_RelFromH (20.4.3.4) | character (the anchor's position in its run), column, insideMargin (left margin on odd pages, right on even), leftMargin, margin, outsideMargin (right on odd, left on even), page, rightMargin. |
ST_RelFromV (20.4.3.5) | bottomMargin, insideMargin, line, margin, outsideMargin, page, paragraph, topMargin. |
ST_AlignH (20.4.3.1) | center, inside, left, outside, right. |
ST_AlignV (20.4.3.2) | bottom, center, inside, outside, top. |
ST_WrapText (20.4.3.7) | bothSides, left, right, largest (the larger side only; at the exact centre of the page, the side where text is first met: left for a left-to-right first line, right for right-to-left). |
ST_WrapDistance (20.4.3.6) | unsignedInt, EMU. The distance on the wrap element wins over the one on the anchor; on wp:inline it has no effect but is kept in case the object becomes floating. |
Rules
wp:docPridmust be unique in the document, or the file is non-conformant (20.4.2.5);nameis typically the original file name,descris the alternative text,titlethe caption,hidden(default false) hides the object.relativeHeightorders only objects with the samebehindDocvalue, and every object withbehindDoc="false"lies above those withtrue(20.4.2.3).simplePoson the anchor is a boolean: only when it is true is thewp:simplePoselement used, putting the top-left of the object at that point of the page (20.4.2.3, 20.4.2.13). The element is required in the schema even when unused.layoutInCelltrue: the object is placed inside the table cell, resizing the cell, and positions are relative to the cell; false: positions are relative to the line on which the table is, and the table is moved or resized to suit (20.4.2.3).allowOverlapfalse: an object that would overlap another is moved.lockedtrue: an application must not move the anchor while editing.cNvSpPrtxBoxmarks a shape as a text box; a shape without it can still hold text (20.4.2.28).
Divergence from spec
- hidden: the standard says an anchor or
docPrwithhidden="true"is not displayed; Word does not support the attribute and does not keep it on save (MS-OI29500 2.1.1350). This site's viewer ignores it and draws the object. - docPr id: the standard allows 0 and any unsigned integer; Word will not load a file whose
idis 0 or above 2147483646 (MS-OI29500 2.1.1351). python-docx writes the id 666 in its template and replaces it by the shape id; Apache POI takes ids fromgetDrawingIdManager().reserveNew()and uses 0 only for the innerpic:cNvPr(XWPFRun.java1416-1439, citing 20.2.2.3). - effectExtent: the text of the standard says all four attributes add to the bottom edge; Word uses
l,randtfor the left, right and top edges (MS-OI29500 2.1.1352). The viewer does not use effectExtent. - extent: the standard allows 0 for
cxorcyand inverts the words width and height; Word readscxas the width andcyas the height, and when either is 0 it uses the object's transform instead, or shows nothing if that is invalid (MS-OI29500 2.1.1353, 2.1.1604). - wrap polygon points: the standard says
startandlineTocoordinates are in EMU; Word reads them in a fixed space of 21600 by 21600 across the object (MS-OI29500 2.1.1354, 2.1.1357). - positionV: the standard lists
paragraphas a value ofrelativeFrom; MS-OI29500 2.1.1355 says Word does not allow it. The viewer accepts it and treats a missingrelativeFromasparagraphvertically andcolumnhorizontally (pages.js1029-1030).
What other libraries do
- python-docx (
research/docx/src/pydocx-oxml-shape.py): knows onlywp:inline(extent, docPr, graphic as required single children, lines 68-77;CT_Anchoris an empty class, line 29). Its template inline has extent, docPr,wp:cNvGraphicFramePrwitha:graphicFrameLocks noChangeAspect="1", and the graphic withurihttp://schemas.openxmlformats.org/drawingml/2006/picture (lines 105-118). A newpic:pichasnvPicPr,blipFill(blip, stretch, fillRect),spPrwithxfrmandprstGeom rect(lines 157-179). - Apache POI (
research/docx/src/poi-XWPFRun.java1393-1471):addPicturewrites an inline with all four distances 0,docPrid and name "Drawing n" with the file name asdescr, anoChangeAspectpicture lock, a stretch fill and a rectangle preset; it never writes an anchor.
What the viewer draws
The Pages view (docx/pages.js drawing(), lines 996-1066) draws inline objects in the line, makes the line as tall as the object, and draws an anchored object either as a float (square, tight and through wrapping with the paragraph as vertical base: left or right by alignment or by which half of the column the offset is in, with the distances as margins; wrapText="left" puts the object at the right edge and "right" at the left, as 20.4.3.7 says; for tight and through wrapping the wrapPolygon becomes a CSS shape-outside polygon, its points taken in the 21600 by 21600 space above, so the lines follow the polygon in the browser; compared with a LibreOffice PDF of a 2 inch picture, scripts/ooxml/wrap-compare.mjs: wrapText="right" with the picture at the left margin puts the text right of it and "left" with the picture at the right margin puts it left, the same as the viewer; Divergence from programs: with a triangle polygon (apex up) at the left margin LibreOffice also sets text lines into the empty corner left of the slanted edge, while a CSS float starts every line right of the polygon, so the viewer leaves that corner empty), as its own block (top and bottom wrapping), or at its position (a square, tight or through wrapped object whose vertical base is not the paragraph is also drawn here, with no wrapping of the text, and the page says so in its notes; the same notes name layoutInCell false and allowOverlap false, which are not applied: wrapping around an object at a fixed page position would need the text layout to know every object of the page before it breaks lines, and the viewer breaks lines in the browser per paragraph) (page, margin, column and paragraph bases; align centre, right and outside; behindDoc picks the layer). relativeHeight orders the objects that are drawn at a position (larger in front; behind-text objects stay behind). Also applied (20.4.2.3, 20.4.2.13, 20.4.2.5, 20.4.2.6): simplePos true places the object at the wp:simplePos coordinates from the page corner (no wrapping float), docPr hidden true draws nothing, and effectExtent adds its four lengths to the float margins and to the size an inline object takes in its line. Objects drawn at their position (no wrapping, or a base other than the paragraph) now take every base of 20.4.3.4 and 20.4.3.5: for the horizontal one page, margin, column, leftMargin, rightMargin, insideMargin and outsideMargin (inside is the left margin on odd pages and the right on even pages, as the spec words it) and character (the place of the anchor in its line); for the vertical one page, margin, topMargin, bottomMargin, insideMargin and outsideMargin, with paragraph and line both measured from the paragraph's top. Alignments left, center, right, inside, outside, top and bottom go to the edges of that base (tested with an A4 page and hand-worked pixel values in test-docx-built). wrapText="largest" with a column or margin base puts the text on the larger side and, at the exact middle, on the left (20.4.3.7; LibreOffice does the same, compared with a picture in the middle of the column, scripts/ooxml/wrap-compare.mjs with the argument both; tests "pages: wrapText largest ..."). Divergence from programs: for bothSides with the object away from both edges LibreOffice sets text on both sides of the picture, while a CSS float sits at one edge and cannot leave a column of text on its far side, so the viewer puts the object at the nearer edge and the text on the other side only. Not applied: wrapText bothSides with an object in the middle (above), a polygon on an object whose vertical base is not the paragraph, layoutInCell, allowOverlap (the viewer never moves an object off another), line measured from the line itself (the paragraph's top is used), the inside and outside vertical margins as anything but top and bottom (the spec only says "inside margin" and "outside margin" for them), anchors in a table cell relative to the cell, and linked text boxes. These are listed in Not described on the overview. No LibreOffice comparison was made for the new bases.
Revision balloons also name formatting changes: a w:pPrChange in the paragraph properties (17.13.5.29) gives a "Formatted paragraph" balloon and a w:rPrChange in a run's properties (17.13.5.31) a "Formatted" balloon with the run's text (test "pages: balloons for a run and a paragraph property change"). The same holds for w:sectPrChange inside a paragraph's section properties (17.13.5.32, "Formatted section"), w:tblPrChange (17.13.5.34), w:trPrChange (17.13.5.37) and w:tcPrChange (17.13.5.36); the table balloons sit at the top of the table, and a sectPrChange on the final body-level w:sectPr gets none (test "pages: balloons for section, table, row and cell property changes"). The old properties inside the change element are not compared with the new ones, so the balloon does not say what changed. Move range marks (w:moveFromRangeStart and so on, 17.13.5.23 to 17.13.5.28) draw nothing of their own; the moved text is already shown through its w:moveFrom and w:moveTo wrappers.