Aspose::Words::Drawing::GroupShape class

GroupShape class

Represents a group of shapes in a document. To learn more, visit the How to Add Group Shape into a Word Document documentation article.

class GroupShape : public Aspose::Words::Drawing::ShapeBase

Methods

MethodDescription
Accept(System::SharedPtr<Aspose::Words::DocumentVisitor>) overrideAccepts a visitor.
AcceptEnd(System::SharedPtr<Aspose::Words::DocumentVisitor>) override
AcceptStart(System::SharedPtr<Aspose::Words::DocumentVisitor>) override
AdjustWithEffects(System::Drawing::RectangleF)Adds to the source rectangle values of the effect extent and returns the final rectangle.
AppendChild(T)
Clone(bool)Creates a duplicate of the node.
get_AllowOverlap()Gets or sets a value that specifies whether this shape can overlap other shapes.
get_AlternativeText()Defines alternative text to be displayed instead of a graphic.
get_AnchorLocked()Specifies whether the shape’s anchor is locked.
get_AspectRatioLocked()Specifies whether the shape’s aspect ratio is locked.
get_BehindText()Specifies whether the shape is below or above text.
get_Bottom()Gets the position of the bottom edge of the containing block of the shape.
get_Bounds()Gets or sets the location and size of the containing block of the shape.
get_BoundsInPoints()Gets the location and size of the containing block of the shape in points, relative to the anchor of the topmost shape.
get_BoundsWithEffects()Gets final extent that this shape object has after applying drawing effects. Value is measured in points.
get_CanHaveImage()Returns true if the shape type allows the shape to have an image.
get_CoordOrigin()The coordinates at the top-left corner of the containing block of this shape.
get_CoordSize()The width and height of the coordinate space inside the containing block of this shape.
get_Count()Gets the number of immediate children of this node.
get_CustomNodeId() constSpecifies custom node identifier.
get_DistanceBottom()Returns or sets the distance (in points) between the document text and the bottom edge of the shape.
get_DistanceLeft()Returns or sets the distance (in points) between the document text and the left edge of the shape.
get_DistanceRight()Returns or sets the distance (in points) between the document text and the right edge of the shape.
get_DistanceTop()Returns or sets the distance (in points) between the document text and the top edge of the shape.
virtual get_Document() constGets the document to which this node belongs.
get_Fill()Gets fill formatting for the shape.
get_FirstChild() constGets the first child of the node.
get_FlipOrientation()Switches the orientation of a shape.
get_Font()Provides access to the font formatting of this object.
get_HasChildNodes()Returns true if this node has any child nodes.
get_Height()Gets or sets the height of the containing block of the shape.
get_HeightRelative()Gets the value that represents the percentage of shape’s relative height.
get_HorizontalAlignment()Specifies how the shape is positioned horizontally.
get_HRef()Gets or sets the full hyperlink address for a shape.
get_IsComposite() overrideReturns true as this node can have child nodes.
get_IsDecorative()Gets or sets the flag that specifies whether the shape is decorative in the document.
get_IsDeleteRevision()Returns true if this object was deleted in Microsoft Word while change tracking was enabled.
get_IsGroup()Returns true if this is a group shape.
get_IsHorizontalRule()Returns true if this shape is a horizontal rule.
get_IsImage()Returns true if this shape is an image shape.
get_IsInline()A quick way to determine if this shape is positioned inline with text.
get_IsInsertRevision()Returns true if this object was inserted in Microsoft Word while change tracking was enabled.
get_IsLayoutInCell()Gets or sets a flag indicating whether the shape is displayed inside a table or outside of it.
get_IsMoveFromRevision()Returns true if this object was moved (deleted) in Microsoft Word while change tracking was enabled.
get_IsMoveToRevision()Returns true if this object was moved (inserted) in Microsoft Word while change tracking was enabled.
get_IsSignatureLine()Indicates that shape is a SignatureLine.
get_IsTopLevel()Returns true if this shape is not a child of a group shape.
get_IsWordArt()Returns true if this shape is a WordArt object.
get_LastChild() constGets the last child of the node.
get_Left()Gets or sets the position of the left edge of the containing block of the shape.
get_LeftRelative()Gets the value that represents shape’s relative left position in percent.
get_MarkupLanguage() constGets MarkupLanguage used for this graphic object.
get_Name()Gets or sets the optional shape name.
get_NextNode() const
get_NextSibling()Gets the node immediately following this node.
get_NodeType() const overrideReturns GroupShape.
get_ParentNode()Gets the immediate parent of this node.
get_ParentParagraph()Returns the immediate parent paragraph.
get_PreviousSibling()Gets the node immediately preceding this node.
get_PrevNode() const
get_Range()Returns a Range object that represents the portion of a document that is contained in this node.
get_RelativeHorizontalPosition()Specifies relative to what the shape is positioned horizontally.
get_RelativeHorizontalSize()Gets or sets the value of shape’s relative size in horizontal direction.
get_RelativeVerticalPosition()Specifies relative to what the shape is positioned vertically.
get_RelativeVerticalSize()Gets or sets the value of shape’s relative size in vertical direction.
get_Right()Gets the position of the right edge of the containing block of the shape.
get_Rotation()Defines the angle (in degrees) that a shape is rotated. Positive value corresponds to clockwise rotation angle.
get_ScreenTip()Defines the text displayed when the mouse pointer moves over the shape.
get_ShadowFormat()Gets shadow formatting for the shape.
get_ShapeType()Gets the shape type.
get_SizeInPoints()Gets the size of the shape in points.
get_Target()Gets or sets the target frame for the shape hyperlink.
get_Title()Gets or sets the title (caption) of the current shape object.
get_Top()Gets or sets the position of the top edge of the containing block of the shape.
get_TopRelative()Gets the value that represents shape’s relative top position in percent.
get_VerticalAlignment()Specifies how the shape is positioned vertically.
get_Width()Gets or sets the width of the containing block of the shape.
get_WidthRelative()Gets the value that represents the percentage of shape’s relative width.
get_WrapSide()Specifies how the text is wrapped around the shape.
get_WrapType()Defines whether the shape is inline or floating. For floating shapes defines the wrapping mode for text around the shape.
get_ZOrder()Determines the display order of overlapping shapes.
GetAncestor(Aspose::Words::NodeType)Gets the first ancestor of the specified NodeType.
GetAncestorOf()
GetChild(Aspose::Words::NodeType, int32_t, bool)Returns an Nth child node that matches the specified type.
GetChildNodes(Aspose::Words::NodeType, bool)Returns a live collection of child nodes that match the specified type.
GetEnumerator() overrideProvides support for the for each style iteration over the child nodes of this node.
GetShapeRenderer()Creates and returns an object that can be used to render this shape into an image.
GetText() overrideGets the text of this node and of all its children.
GetType() const override
GroupShape(const System::SharedPtr<Aspose::Words::DocumentBase>&)Creates a new group shape.
IndexOf(const System::SharedPtr<Aspose::Words::Node>&)Returns the index of the specified child node in the child node array.
InsertAfter(T, const System::SharedPtr<Aspose::Words::Node>&)
InsertBefore(T, const System::SharedPtr<Aspose::Words::Node>&)
Is(const System::TypeInfo&) const override
IsAncestorNode(const System::SharedPtr<Aspose::Words::Node>&)
LocalToParent(System::Drawing::PointF)Converts a value from the local coordinate space into the coordinate space of the parent shape.
NextPreOrder(const System::SharedPtr<Aspose::Words::Node>&)Gets next node according to the pre-order tree traversal algorithm.
static NodeTypeToString(Aspose::Words::NodeType)A utility method that converts a node type enum value into a user friendly string.
PrependChild(T)
PreviousPreOrder(const System::SharedPtr<Aspose::Words::Node>&)Gets the previous node according to the pre-order tree traversal algorithm.
Remove()Removes itself from the parent.
RemoveAllChildren()Removes all the child nodes of the current node.
RemoveChild(T)
RemoveSmartTags()Removes all SmartTag descendant nodes of the current node.
SelectNodes(const System::String&)Selects a list of nodes matching the XPath expression.
SelectSingleNode(const System::String&)Selects the first Node that matches the XPath expression.
set_AllowOverlap(bool)Setter for Aspose::Words::Drawing::ShapeBase::get_AllowOverlap.
set_AlternativeText(const System::String&)Defines alternative text to be displayed instead of a graphic.
set_AnchorLocked(bool)Setter for Aspose::Words::Drawing::ShapeBase::get_AnchorLocked.
set_AspectRatioLocked(bool)Setter for Aspose::Words::Drawing::ShapeBase::get_AspectRatioLocked.
set_BehindText(bool)Setter for Aspose::Words::Drawing::ShapeBase::get_BehindText.
set_Bounds(System::Drawing::RectangleF)Setter for Aspose::Words::Drawing::ShapeBase::get_Bounds.
set_CoordOrigin(System::Drawing::Point)Setter for Aspose::Words::Drawing::ShapeBase::get_CoordOrigin.
set_CoordSize(System::Drawing::Size)Setter for Aspose::Words::Drawing::ShapeBase::get_CoordSize.
set_CustomNodeId(int32_t)Setter for Aspose::Words::Node::get_CustomNodeId.
set_DistanceBottom(double)Setter for Aspose::Words::Drawing::ShapeBase::get_DistanceBottom.
set_DistanceLeft(double)Setter for Aspose::Words::Drawing::ShapeBase::get_DistanceLeft.
set_DistanceRight(double)Setter for Aspose::Words::Drawing::ShapeBase::get_DistanceRight.
set_DistanceTop(double)Setter for Aspose::Words::Drawing::ShapeBase::get_DistanceTop.
set_FlipOrientation(Aspose::Words::Drawing::FlipOrientation)Setter for Aspose::Words::Drawing::ShapeBase::get_FlipOrientation.
set_Height(double)Setter for Aspose::Words::Drawing::ShapeBase::get_Height.
set_HeightRelative(float)Sets the value that represents the percentage of shape’s relative height.
set_HorizontalAlignment(Aspose::Words::Drawing::HorizontalAlignment)Setter for Aspose::Words::Drawing::ShapeBase::get_HorizontalAlignment.
set_HRef(const System::String&)Setter for Aspose::Words::Drawing::ShapeBase::get_HRef.
set_IsDecorative(bool)Setter for Aspose::Words::Drawing::ShapeBase::get_IsDecorative.
set_IsLayoutInCell(bool)Setter for Aspose::Words::Drawing::ShapeBase::get_IsLayoutInCell.
set_Left(double)Setter for Aspose::Words::Drawing::ShapeBase::get_Left.
set_LeftRelative(float)Sets the value that represents shape’s relative left position in percent.
set_Name(const System::String&)Setter for Aspose::Words::Drawing::ShapeBase::get_Name.
set_NextNode(const System::SharedPtr<Aspose::Words::Node>&)
set_PrevNode(const System::SharedPtr<Aspose::Words::Node>&)
set_RelativeHorizontalPosition(Aspose::Words::Drawing::RelativeHorizontalPosition)Setter for Aspose::Words::Drawing::ShapeBase::get_RelativeHorizontalPosition.
set_RelativeHorizontalSize(Aspose::Words::Drawing::RelativeHorizontalSize)Setter for Aspose::Words::Drawing::ShapeBase::get_RelativeHorizontalSize.
set_RelativeVerticalPosition(Aspose::Words::Drawing::RelativeVerticalPosition)Setter for Aspose::Words::Drawing::ShapeBase::get_RelativeVerticalPosition.
set_RelativeVerticalSize(Aspose::Words::Drawing::RelativeVerticalSize)Setter for Aspose::Words::Drawing::ShapeBase::get_RelativeVerticalSize.
set_Rotation(double)Setter for Aspose::Words::Drawing::ShapeBase::get_Rotation.
set_ScreenTip(const System::String&)Setter for Aspose::Words::Drawing::ShapeBase::get_ScreenTip.
set_Target(const System::String&)Setter for Aspose::Words::Drawing::ShapeBase::get_Target.
set_Title(const System::String&)Setter for Aspose::Words::Drawing::ShapeBase::get_Title.
set_Top(double)Setter for Aspose::Words::Drawing::ShapeBase::get_Top.
set_TopRelative(float)Sets the value that represents shape’s relative top position in percent.
set_VerticalAlignment(Aspose::Words::Drawing::VerticalAlignment)Setter for Aspose::Words::Drawing::ShapeBase::get_VerticalAlignment.
set_Width(double)Setter for Aspose::Words::Drawing::ShapeBase::get_Width.
set_WidthRelative(float)Sets the value that represents the percentage of shape’s relative width.
set_WrapSide(Aspose::Words::Drawing::WrapSide)Setter for Aspose::Words::Drawing::ShapeBase::get_WrapSide.
set_WrapType(Aspose::Words::Drawing::WrapType)Setter for Aspose::Words::Drawing::ShapeBase::get_WrapType.
set_ZOrder(int32_t)Setter for Aspose::Words::Drawing::ShapeBase::get_ZOrder.
SetParent(const System::SharedPtr<Aspose::Words::Node>&)
SetTemplateWeakPtr(uint32_t) override
ToString(Aspose::Words::SaveFormat)Exports the content of the node into a string in the specified format.
ToString(const System::SharedPtr<Aspose::Words::Saving::SaveOptions>&)Exports the content of the node into a string using the specified save options.
static Type()

Remarks

A GroupShape is a composite node and can have Shape and GroupShape nodes as children.

Each GroupShape defines a new coordinate system for its child shapes. The coordinate system is defined using the CoordSize and CoordOrigin properties.

Examples

Shows how to create a group of shapes, and print its contents using a document visitor.

void GroupOfShapes()
{
    auto doc = MakeObject<Document>();
    auto builder = MakeObject<DocumentBuilder>(doc);

    // If you need to create "NonPrimitive" shapes, such as SingleCornerSnipped, TopCornersSnipped, DiagonalCornersSnipped,
    // TopCornersOneRoundedOneSnipped, SingleCornerRounded, TopCornersRounded, DiagonalCornersRounded
    // please use DocumentBuilder.InsertShape methods.
    auto balloon = MakeObject<Shape>(doc, ShapeType::Balloon);
    balloon->set_Width(200);
    balloon->set_Height(200);
    balloon->get_Stroke()->set_Color(System::Drawing::Color::get_Red());

    auto cube = MakeObject<Shape>(doc, ShapeType::Cube);
    cube->set_Width(100);
    cube->set_Height(100);
    cube->get_Stroke()->set_Color(System::Drawing::Color::get_Blue());

    auto group = MakeObject<GroupShape>(doc);
    group->AppendChild(balloon);
    group->AppendChild(cube);

    ASSERT_TRUE(group->get_IsGroup());

    builder->InsertNode(group);

    auto printer = MakeObject<ExDrawing::ShapeGroupPrinter>();
    group->Accept(printer);

    std::cout << printer->GetText() << std::endl;
}

class ShapeGroupPrinter : public DocumentVisitor
{
public:
    ShapeGroupPrinter()
    {
        mBuilder = MakeObject<System::Text::StringBuilder>();
    }

    String GetText()
    {
        return mBuilder->ToString();
    }

    VisitorAction VisitGroupShapeStart(SharedPtr<GroupShape> groupShape) override
    {
        mBuilder->AppendLine(u"Shape group started:");
        return VisitorAction::Continue;
    }

    VisitorAction VisitGroupShapeEnd(SharedPtr<GroupShape> groupShape) override
    {
        mBuilder->AppendLine(u"End of shape group");
        return VisitorAction::Continue;
    }

    VisitorAction VisitShapeStart(SharedPtr<Shape> shape) override
    {
        mBuilder->AppendLine(String(u"\tShape - ") + System::ObjectExt::ToString(shape->get_ShapeType()) + u":");
        mBuilder->AppendLine(String(u"\t\tWidth: ") + shape->get_Width());
        mBuilder->AppendLine(String(u"\t\tHeight: ") + shape->get_Height());
        mBuilder->AppendLine(String(u"\t\tStroke color: ") + shape->get_Stroke()->get_Color());
        mBuilder->AppendLine(String(u"\t\tFill color: ") + shape->get_Fill()->get_ForeColor());
        return VisitorAction::Continue;
    }

    VisitorAction VisitShapeEnd(SharedPtr<Shape> shape) override
    {
        mBuilder->AppendLine(u"\tEnd of shape");
        return VisitorAction::Continue;
    }

private:
    SharedPtr<System::Text::StringBuilder> mBuilder;
};

See Also