a:grpSp (Group Shape)
Represents a container for grouping multiple shapes together, allowing them to be manipulated as a single unit.
Description
a:grpSp is the DrawingML group shape element that acts as a container for multiple shapes. It is defined in ECMA-376 Part 1 §20.1.2.4.1.
Group shapes allow multiple objects to be:
- Grouped together as a single visual unit
- Moved, resized, and formatted together
- Nested to create complex hierarchies
- Managed with collective properties while maintaining individual formatting
Group shapes are essential for:
- Creating complex diagrams with related elements
- Organizing shapes in hierarchical structures
- Building reusable components and layouts
- Managing large sets of objects efficiently
- Creating flowcharts and structured diagrams
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
| (none) | - | - | All properties defined through child elements. |
Examples
Simple Group with Two Shapes
<p:grpSp xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<p:nvGrpSpPr>
<p:cNvPr id="1" name="Group 1"/>
<p:cNvGrpSpPr/>
<p:nvPr/>
</p:nvGrpSpPr>
<p:grpSpPr>
<a:xfrm>
<a:off x="1000000" y="1000000"/>
<a:ext cx="5000000" cy="3000000"/>
<a:chOff x="0" y="0"/>
<a:chExt cx="5000000" cy="3000000"/>
</a:xfrm>
</p:grpSpPr>
<p:sp>
<p:nvSpPr>
<p:cNvPr id="2" name="Rectangle"/>
<p:cNvSpPr/>
<p:nvPr/>
</p:nvSpPr>
<p:spPr>
<a:xfrm>
<a:off x="1000000" y="1000000"/>
<a:ext cx="2000000" cy="1000000"/>
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst/>
</a:prstGeom>
<a:solidFill>
<a:srgbClr val="0070C0"/>
</a:solidFill>
</p:spPr>
<p:txBody>
<a:bodyPr/>
<a:lstStyle/>
<a:p/>
</p:txBody>
</p:sp>
</p:grpSp>
using DocumentFormat.OpenXml.Presentation;
using DocumentFormat.OpenXml.Drawing;
var grpSp = new GroupShape();
// Non-visual group properties
var nvGrpSpPr = new NonVisualGroupShapeProperties();
nvGrpSpPr.Append(new NonVisualDrawingProperties { Id = 1, Name = "Group 1" });
nvGrpSpPr.Append(new NonVisualGroupShapeDrawingProperties());
nvGrpSpPr.Append(new GroupShapeNonVisualProperties());
grpSp.Append(nvGrpSpPr);
// Group shape properties with transform
var grpSpPr = new GroupShapeProperties();
var xfrm = new Transform2D();
xfrm.Append(new Offset { X = 1000000, Y = 1000000 });
xfrm.Append(new Extents { Cx = 5000000, Cy = 3000000 });
xfrm.Append(new ChildOffset { X = 0, Y = 0 });
xfrm.Append(new ChildExtents { Cx = 5000000, Cy = 3000000 });
grpSpPr.Append(xfrm);
grpSp.Append(grpSpPr);
// Add shape to group
var sp = new Shape();
var nvSpPr = new NonVisualShapeProperties();
nvSpPr.Append(new NonVisualDrawingProperties { Id = 2, Name = "Rectangle" });
nvSpPr.Append(new NonVisualShapeDrawingProperties());
nvSpPr.Append(new ShapeNonVisualProperties());
sp.Append(nvSpPr);
var spPr = new ShapeProperties();
var spXfrm = new Transform2D();
spXfrm.Append(new Offset { X = 1000000, Y = 1000000 });
spXfrm.Append(new Extents { Cx = 2000000, Cy = 1000000 });
spPr.Append(spXfrm);
var prstGeom = new PresetGeometry { Preset = ShapeTypeValues.Rectangle };
prstGeom.Append(new AdjustmentValueList());
spPr.Append(prstGeom);
var fill = new SolidFill();
fill.Append(new RgbColorModelHex { Val = "0070C0" });
spPr.Append(fill);
sp.Append(spPr);
var txBody = new TextBody();
txBody.Append(new BodyProperties());
txBody.Append(new ListStyle());
txBody.Append(new Paragraph());
sp.Append(txBody);
grpSp.Append(sp);
Nested Groups (Hierarchical Structure)
<p:grpSp xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<p:nvGrpSpPr>
<p:cNvPr id="1" name="Parent Group"/>
<p:cNvGrpSpPr/>
<p:nvPr/>
</p:nvGrpSpPr>
<p:grpSpPr>
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="10000000" cy="6000000"/>
<a:chOff x="0" y="0"/>
<a:chExt cx="10000000" cy="6000000"/>
</a:xfrm>
</p:grpSpPr>
<!-- Can contain nested groups and shapes -->
<p:grpSp>
<p:nvGrpSpPr>
<p:cNvPr id="2" name="Child Group"/>
<p:cNvGrpSpPr/>
<p:nvPr/>
</p:nvGrpSpPr>
<p:grpSpPr>
<a:xfrm>
<a:off x="1000000" y="1000000"/>
<a:ext cx="4000000" cy="4000000"/>
<a:chOff x="0" y="0"/>
<a:chExt cx="4000000" cy="4000000"/>
</a:xfrm>
</p:grpSpPr>
</p:grpSp>
</p:grpSp>
// Create parent group
var parentGrp = new GroupShape();
var parentNvGrpSpPr = new NonVisualGroupShapeProperties();
parentNvGrpSpPr.Append(new NonVisualDrawingProperties { Id = 1, Name = "Parent Group" });
parentNvGrpSpPr.Append(new NonVisualGroupShapeDrawingProperties());
parentNvGrpSpPr.Append(new GroupShapeNonVisualProperties());
parentGrp.Append(parentNvGrpSpPr);
var parentGrpSpPr = new GroupShapeProperties();
var parentXfrm = new Transform2D();
parentXfrm.Append(new Offset { X = 0, Y = 0 });
parentXfrm.Append(new Extents { Cx = 10000000, Cy = 6000000 });
parentXfrm.Append(new ChildOffset { X = 0, Y = 0 });
parentXfrm.Append(new ChildExtents { Cx = 10000000, Cy = 6000000 });
parentGrpSpPr.Append(parentXfrm);
parentGrp.Append(parentGrpSpPr);
// Create nested child group
var childGrp = new GroupShape();
var childNvGrpSpPr = new NonVisualGroupShapeProperties();
childNvGrpSpPr.Append(new NonVisualDrawingProperties { Id = 2, Name = "Child Group" });
childNvGrpSpPr.Append(new NonVisualGroupShapeDrawingProperties());
childNvGrpSpPr.Append(new GroupShapeNonVisualProperties());
childGrp.Append(childNvGrpSpPr);
var childGrpSpPr = new GroupShapeProperties();
var childXfrm = new Transform2D();
childXfrm.Append(new Offset { X = 1000000, Y = 1000000 });
childXfrm.Append(new Extents { Cx = 4000000, Cy = 4000000 });
childXfrm.Append(new ChildOffset { X = 0, Y = 0 });
childXfrm.Append(new ChildExtents { Cx = 4000000, Cy = 4000000 });
childGrpSpPr.Append(childXfrm);
childGrp.Append(childGrpSpPr);
parentGrp.Append(childGrp);
Notes
- Group shapes have child offset and child extent for coordinate space transformation
- Groups can be nested to any depth for complex hierarchies
- Moving or resizing a group affects all contained shapes proportionally
- Group shapes can contain shapes, pictures, text shapes, and other groups
- Each child shape maintains its own positioning within the group’s coordinate space
- Non-visual properties essential for naming and identifying groups
- Child extents define the coordinate space for contained shapes
- Groups improve document organization and maintainability