Aspose::Words::Drawing::Shape Class Referencefinal

Detailed Description

Represents an object in the drawing layer, such as an AutoShape, textbox, freeform, OLE object, ActiveX control, or picture.

Using the Shape class you can create or modify shapes in a Microsoft Word document.

An important property of a shape is its ShapeType. Shapes of different types can have different capabilities in a Word document. For example, only image and OLE shapes can have images inside them. Most of the shapes can have text, but not all.

Shapes that can have text, can contain Paragraph and Table nodes as children.

See also
Aspose::Words::Drawing::ShapeBase
Aspose::Words::Drawing::GroupShape
Examples

Shows how to extract images from a document and save them as files.

auto doc = MakeObject<Document>(MyDir + u"Images.docx");
SharedPtr<NodeCollection> shapes = doc->GetChildNodes(NodeType::Shape, true);
ASSERT_EQ(9, shapes->LINQ_Count([](SharedPtr<Node> s) { return (System::DynamicCast<Shape>(s))->get_HasImage(); }));
int imageIndex = 0;
for (auto shape : System::IterateOver(shapes->LINQ_OfType<SharedPtr<Shape> >()))
{
if (shape->get_HasImage())
{
String imageFileName = String::Format(u"File.ExtractImagesToFiles.{0}{1}", imageIndex, FileFormatUtil::ImageTypeToExtension(shape->get_ImageData()->get_ImageType()));
shape->get_ImageData()->Save(ArtifactsDir + imageFileName);
imageIndex++;
}
}

Shows how to insert a floating image in the middle of a page.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// By default, the image is inline
SharedPtr<Shape> shape = builder->InsertImage(ImageDir + u"Logo.jpg");
// Make the image float, put it behind text and center on the page
shape->set_WrapType(WrapType::None);
shape->set_BehindText(true);
shape->set_RelativeHorizontalPosition(RelativeHorizontalPosition::Page);
shape->set_RelativeVerticalPosition(RelativeVerticalPosition::Page);
shape->set_HorizontalAlignment(HorizontalAlignment::Center);
shape->set_VerticalAlignment(VerticalAlignment::Center);
doc->Save(ArtifactsDir + u"Image.CreateFloatingPageCenter.docx");

Shows how to delete all shapes from a document.

// Here we get all shapes from the document node, but you can do this for any smaller
// node too, for example delete shapes from a single section or a paragraph
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert 2 shapes
builder->InsertShape(ShapeType::Rectangle, 400, 200);
builder->InsertShape(ShapeType::Star, 300, 300);
// Insert a GroupShape with an inner shape
auto group = MakeObject<GroupShape>(doc);
group->set_Bounds(System::Drawing::RectangleF(100.0f, 50.0f, 200.0f, 100.0f));
group->set_CoordOrigin(System::Drawing::Point(-1000, -500));
auto subShape = MakeObject<Shape>(doc, ShapeType::Cube);
subShape->set_Width(500);
subShape->set_Height(700);
subShape->set_Left(0);
subShape->set_Top(0);
group->AppendChild(subShape);
builder->InsertNode(group);
ASSERT_EQ(3, doc->GetChildNodes(NodeType::Shape, true)->get_Count());
ASSERT_EQ(1, doc->GetChildNodes(NodeType::GroupShape, true)->get_Count());
// Delete all Shape nodes
SharedPtr<NodeCollection> shapes = doc->GetChildNodes(NodeType::Shape, true);
shapes->Clear();
// The GroupShape node is still present even though there are no sub Shapes
ASSERT_EQ(1, doc->GetChildNodes(NodeType::GroupShape, true)->get_Count());
ASSERT_EQ(0, doc->GetChildNodes(NodeType::Shape, true)->get_Count());
// GroupShapes also have to be deleted manually
SharedPtr<NodeCollection> groupShapes = doc->GetChildNodes(NodeType::GroupShape, true);
groupShapes->Clear();
ASSERT_EQ(0, doc->GetChildNodes(NodeType::GroupShape, true)->get_Count());
ASSERT_EQ(0, doc->GetChildNodes(NodeType::Shape, true)->get_Count());

#include <Aspose.Words.Cpp/Model/Drawing/Shape.h>

+ Inheritance diagram for Aspose::Words::Drawing::Shape:

Public Member Functions

 Shape (SharedPtr< DocumentBase > doc, ShapeType shapeType)
 Creates a new shape object. More...
 
bool Accept (SharedPtr< DocumentVisitor > visitor) override
 Accepts a visitor. More...
 
SharedPtr< Chartget_Chart ()
 Provides access to the chart properties if this shape has a Chart. More...
 
bool get_ExtrusionEnabled ()
 Returns true if an extrusion effect is enabled. More...
 
SharedPtr< Fillget_Fill ()
 Defines a fill for a shape. More...
 
Color get_FillColor ()
 Defines the brush color that fills the closed path of the shape. More...
 
bool get_Filled ()
 Determines whether the closed path of the shape will be filled. More...
 
SharedPtr< Paragraphget_FirstParagraph ()
 Gets the first paragraph in the shape. More...
 
bool get_HasChart ()
 Returns true if this Shape has a Chart. More...
 
bool get_HasImage ()
 Returns true if the shape has image bytes or links an image. More...
 
bool get_HasSmartArt ()
 Returns true if this Shape has a SmartArt object. More...
 
bool get_HasVerticalTextFlow_ITextBox () override
 
SharedPtr< HorizontalRuleFormatget_HorizontalRuleFormat ()
 Provides access to the properties of the horizontal rule shape. For a shape that is not a horizontal rule, returns null. More...
 
SharedPtr< ImageDataget_ImageData ()
 Provides access to the image of the shape. Returns null if the shape cannot have an image. More...
 
SharedPtr< Paragraphget_LastParagraph ()
 Gets the last paragraph in the shape. More...
 
ShapeMarkupLanguage get_MarkupLanguage_ITextBox () override
 
NodeType get_NodeType () const override
 Returns Shape. More...
 
SharedPtr< OleFormatget_OleFormat ()
 Provides access to the OLE data of a shape. For a shape that is not an OLE object or ActiveX control, returns null. More...
 
bool get_ShadowEnabled ()
 Returns true if a shadow effect is enabled. More...
 
SharedPtr< SignatureLineget_SignatureLine ()
 Gets SignatureLine object if the shape is a signature line. Returns null otherwise. More...
 
StoryType get_StoryType ()
 Returns Textbox. More...
 
SharedPtr< Strokeget_Stroke ()
 Defines a stroke for a shape. More...
 
Color get_StrokeColor ()
 Defines the color of a stroke. More...
 
bool get_Stroked ()
 Defines whether the path will be stroked. More...
 
double get_StrokeWeight ()
 Defines the brush thickness that strokes the path of a shape in points. More...
 
SharedPtr< TextBoxget_TextBox ()
 Defines attributes that specify how text is displayed in a shape. More...
 
LayoutFlow get_TextboxLayoutFlow_ITextBox () override
 
TextBoxWrapMode get_TextBoxWrapMode_ITextBox () override
 
SharedPtr< TextPathget_TextPath ()
 Defines the text of the text path (of a WordArt object). More...
 
float GetHorizontalMargins_ITextBox () override
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_FillColor (Color value)
 Setter for get_FillColor. More...
 
void set_Filled (bool value)
 Setter for get_Filled. More...
 
void set_StrokeColor (Color value)
 Setter for get_StrokeColor. More...
 
void set_Stroked (bool value)
 Setter for get_Stroked. More...
 
void set_StrokeWeight (double value)
 Setter for get_StrokeWeight. More...
 
- Public Member Functions inherited from ShapeBase
RectangleF AdjustWithEffects (RectangleF source)
 Adds to the source rectangle values of the effect extent and returns the final rectangle. More...
 
bool get_AllowOverlap ()
 Gets or sets a value that specifies whether this shape can overlap other shapes. More...
 
String get_AlternativeText ()
 Defines alternative text to be displayed instead of a graphic. More...
 
bool get_AnchorLocked ()
 Specifies whether the shape's anchor is locked. More...
 
bool get_AspectRatioLocked ()
 Specifies whether the shape's aspect ratio is locked. More...
 
bool get_BehindText ()
 Specifies whether the shape is below or above text. More...
 
double get_Bottom ()
 Gets the position of the bottom edge of the containing block of the shape. More...
 
RectangleF get_Bounds ()
 Gets or sets the location and size of the containing block of the shape. More...
 
RectangleF get_BoundsInPoints ()
 Gets the location and size of the containing block of the shape in points, relative to the anchor of the topmost shape. More...
 
RectangleF get_BoundsWithEffects ()
 Gets final extent that this shape object has after applying drawing effects. Value is measured in points. More...
 
bool get_CanHaveImage ()
 Returns true if the shape type allows the shape to have an image. More...
 
Point get_CoordOrigin ()
 The coordinates at the top-left corner of the containing block of this shape. More...
 
Size get_CoordSize ()
 The width and height of the coordinate space inside the containing block of this shape. More...
 
double get_DistanceBottom ()
 Returns or sets the distance (in points) between the document text and the bottom edge of the shape. More...
 
double get_DistanceLeft ()
 Returns or sets the distance (in points) between the document text and the left edge of the shape. More...
 
double get_DistanceRight ()
 Returns or sets the distance (in points) between the document text and the right edge of the shape. More...
 
double get_DistanceTop ()
 Returns or sets the distance (in points) between the document text and the top edge of the shape. More...
 
FlipOrientation get_FlipOrientation ()
 Switches the orientation of a shape. More...
 
SharedPtr< Fontget_Font ()
 Provides access to the font formatting of this object. More...
 
double get_Height ()
 Gets or sets the height of the containing block of the shape. More...
 
HorizontalAlignment get_HorizontalAlignment ()
 Specifies how the shape is positioned horizontally. More...
 
String get_HRef ()
 Gets or sets the full hyperlink address for a shape. More...
 
bool get_IsDeleteRevision ()
 Returns true if this object was deleted in Microsoft Word while change tracking was enabled. More...
 
bool get_IsGroup ()
 Returns true if this is a group shape. More...
 
bool get_IsHorizontalRule ()
 Returns true if this shape is a horizontal rule. More...
 
bool get_IsImage ()
 Returns true if this shape is an image shape. More...
 
bool get_IsInline ()
 A quick way to determine if this shape is positioned inline with text. More...
 
bool get_IsInsertRevision ()
 Returns true if this object was inserted in Microsoft Word while change tracking was enabled. More...
 
bool get_IsLayoutInCell ()
 Gets or sets a flag indicating whether the shape is displayed inside a table or outside of it. More...
 
bool get_IsMoveFromRevision ()
 Returns true if this object was moved (deleted) in Microsoft Word while change tracking was enabled. More...
 
bool get_IsMoveToRevision ()
 Returns true if this object was moved (inserted) in Microsoft Word while change tracking was enabled. More...
 
bool get_IsSignatureLine ()
 Indicates that shape is a SignatureLine. More...
 
bool get_IsTopLevel ()
 Returns true if this shape is not a child of a group shape. More...
 
bool get_IsWordArt ()
 Returns true if this shape is a WordArt object. More...
 
double get_Left ()
 Gets or sets the position of the left edge of the containing block of the shape. More...
 
ShapeMarkupLanguage get_MarkupLanguage () const
 Gets MarkupLanguage used for this graphic object. More...
 
String get_Name ()
 Gets or sets the optional shape name. More...
 
SharedPtr< Paragraphget_ParentParagraph ()
 Returns the immediate parent paragraph. More...
 
RelativeHorizontalPosition get_RelativeHorizontalPosition ()
 Specifies relative to what the shape is positioned horizontally. More...
 
RelativeVerticalPosition get_RelativeVerticalPosition ()
 Specifies relative to what the shape is positioned vertically. More...
 
double get_Right ()
 Gets the position of the right edge of the containing block of the shape. More...
 
double get_Rotation ()
 Defines the angle (in degrees) that a shape is rotated. Positive value corresponds to clockwise rotation angle. More...
 
String get_ScreenTip ()
 Defines the text displayed when the mouse pointer moves over the shape. More...
 
ShapeType get_ShapeType ()
 Gets the shape type. More...
 
SizeF get_SizeInPoints ()
 Gets the size of the shape in points. More...
 
String get_Target ()
 Gets or sets the target frame for the shape hyperlink. More...
 
String get_Title ()
 Gets or sets the title (caption) of the current shape object. More...
 
double get_Top ()
 Gets or sets the position of the top edge of the containing block of the shape. More...
 
VerticalAlignment get_VerticalAlignment ()
 Specifies how the shape is positioned vertically. More...
 
double get_Width ()
 Gets or sets the width of the containing block of the shape. More...
 
WrapSide get_WrapSide ()
 Specifies how the text is wrapped around the shape. More...
 
WrapType get_WrapType ()
 Defines whether the shape is inline or floating. For floating shapes defines the wrapping mode for text around the shape. More...
 
int32_t get_ZOrder ()
 Determines the display order of overlapping shapes. More...
 
int32_t get_ZOrder_IShape () override
 
SharedPtr< ShapeRendererGetShapeRenderer ()
 Creates and returns an object that can be used to render this shape into an image. More...
 
PointF LocalToParent (PointF value)
 Converts a value from the local coordinate space into the coordinate space of the parent shape. More...
 
void set_AllowOverlap (bool value)
 Setter for get_AllowOverlap. More...
 
void set_AlternativeText (String value)
 Setter for get_AlternativeText. More...
 
void set_AnchorLocked (bool value)
 Setter for get_AnchorLocked. More...
 
void set_AspectRatioLocked (bool value)
 Setter for get_AspectRatioLocked. More...
 
void set_BehindText (bool value)
 Setter for get_BehindText. More...
 
void set_Bounds (RectangleF value)
 Setter for get_Bounds. More...
 
void set_CoordOrigin (Point value)
 Setter for get_CoordOrigin. More...
 
void set_CoordSize (Size value)
 Setter for get_CoordSize. More...
 
void set_DistanceBottom (double value)
 Setter for get_DistanceBottom. More...
 
void set_DistanceLeft (double value)
 Setter for get_DistanceLeft. More...
 
void set_DistanceRight (double value)
 Setter for get_DistanceRight. More...
 
void set_DistanceTop (double value)
 Setter for get_DistanceTop. More...
 
void set_FlipOrientation (FlipOrientation value)
 Setter for get_FlipOrientation. More...
 
void set_Height (double value)
 Setter for get_Height. More...
 
void set_HorizontalAlignment (HorizontalAlignment value)
 Setter for get_HorizontalAlignment. More...
 
void set_HRef (String value)
 Setter for get_HRef. More...
 
void set_IsLayoutInCell (bool value)
 Setter for get_IsLayoutInCell. More...
 
void set_Left (double value)
 Setter for get_Left. More...
 
void set_Name (String value)
 Setter for get_Name. More...
 
void set_RelativeHorizontalPosition (RelativeHorizontalPosition value)
 Setter for get_RelativeHorizontalPosition. More...
 
void set_RelativeVerticalPosition (RelativeVerticalPosition value)
 Setter for get_RelativeVerticalPosition. More...
 
void set_Rotation (double value)
 Setter for get_Rotation. More...
 
void set_ScreenTip (String value)
 Setter for get_ScreenTip. More...
 
void set_Target (String value)
 Setter for get_Target. More...
 
void set_Title (String value)
 Setter for get_Title. More...
 
void set_Top (double value)
 Setter for get_Top. More...
 
void set_VerticalAlignment (VerticalAlignment value)
 Setter for get_VerticalAlignment. More...
 
void set_Width (double value)
 Setter for get_Width. More...
 
void set_WrapSide (WrapSide value)
 Setter for get_WrapSide. More...
 
void set_WrapType (WrapType value)
 Setter for get_WrapType. More...
 
void set_ZOrder (int32_t value)
 Setter for get_ZOrder. More...
 
void set_ZOrder_IShape (int32_t value) override
 
- Public Member Functions inherited from CompositeNode
SharedPtr< NodeAppendChild (SharedPtr< Node > newChild)
 Adds the specified node to the end of the list of child nodes for this node. More...
 
SharedPtr< NodeCollectionget_ChildNodes ()
 Gets all immediate child nodes of this node. More...
 
SharedPtr< CompositeNodeget_Container () override
 
int32_t get_Count ()
 Gets the number of immediate children of this node. More...
 
SharedPtr< Nodeget_FirstChild () const
 Gets the first child of the node. More...
 
bool get_HasChildNodes ()
 Returns true if this node has any child nodes. More...
 
bool get_IsComposite () override
 Returns true as this node can have child nodes. More...
 
SharedPtr< Nodeget_LastChild () const
 Gets the last child of the node. More...
 
SharedPtr< NodeGetChild (NodeType nodeType, int32_t index, bool isDeep)
 Returns an Nth child node that matches the specified type. More...
 
SharedPtr< NodeCollectionGetChildNodes (NodeType nodeType, bool isDeep)
 Returns a live collection of child nodes that match the specified type. More...
 
SharedPtr< NodeGetCurrentNode () override
 
SharedPtr< IEnumerator< SharedPtr< Node > > > GetEnumerator () override
 Provides support for the for each style iteration over the child nodes of this node. More...
 
SharedPtr< NodeGetNextMatchingNode (SharedPtr< Node > curNode) override
 
String GetText () override
 Gets the text of this node and of all its children. More...
 
int32_t IndexOf (SharedPtr< Node > child)
 Returns the index of the specified child node in the child node array. More...
 
SharedPtr< NodeInsertAfter (SharedPtr< Node > newChild, SharedPtr< Node > refChild)
 Inserts the specified node immediately after the specified reference node. More...
 
SharedPtr< NodeInsertBefore (SharedPtr< Node > newChild, SharedPtr< Node > refChild)
 Inserts the specified node immediately before the specified reference node. More...
 
SharedPtr< NodePrependChild (SharedPtr< Node > newChild)
 Adds the specified node to the beginning of the list of child nodes for this node. More...
 
void RemoveAllChildren ()
 Removes all the child nodes of the current node. More...
 
SharedPtr< NodeRemoveChild (SharedPtr< Node > oldChild)
 Removes the specified child node. More...
 
void RemoveSmartTags ()
 Removes all SmartTag descendant nodes of the current node. More...
 
SharedPtr< NodeListSelectNodes (String xpath)
 Selects a list of nodes matching the XPath expression. More...
 
SharedPtr< NodeSelectSingleNode (String xpath)
 Selects the first Node that matches the XPath expression. More...
 
- Public Member Functions inherited from Node
SharedPtr< NodeClone (bool isCloneChildren)
 
virtual SharedPtr< DocumentBaseget_Document () const
 Gets the document to which this node belongs. More...
 
SharedPtr< Nodeget_NextSibling ()
 Gets the node immediately following this node. More...
 
SharedPtr< CompositeNodeget_ParentNode ()
 Gets the immediate parent of this node. More...
 
SharedPtr< Nodeget_PreviousSibling ()
 Gets the node immediately preceding this node. More...
 
SharedPtr< Rangeget_Range ()
 Returns a Range object that represents the portion of a document that is contained in this node. More...
 
SharedPtr< CompositeNodeGetAncestor (NodeType ancestorType)
 Gets the first ancestor of the specified NodeType. More...
 
template<typename T >
GetAncestorOf ()
 
SharedPtr< NodeNextPreOrder (SharedPtr< Node > rootNode)
 Gets next node according to the pre-order tree traversal algorithm. More...
 
SharedPtr< NodePreviousPreOrder (SharedPtr< Node > rootNode)
 Gets the previous node according to the pre-order tree traversal algorithm. More...
 
void Remove ()
 Removes itself from the parent. More...
 
String ToString (SaveFormat saveFormat)
 Exports the content of the node into a string in the specified format. More...
 
String ToString (SharedPtr< SaveOptions > saveOptions)
 Exports the content of the node into a string using the specified save options. More...
 
- Public Member Functions inherited from Object
ASPOSECPP_SHARED_API Object ()
 
ASPOSECPP_SHARED_API Object (Object const &x)
 
virtual ASPOSECPP_SHARED_API ~Object ()
 
virtual ASPOSECPP_SHARED_API bool Equals (ptr obj)
 
Detail::SmartPtrCounter * GetCounter ()
 
virtual ASPOSECPP_SHARED_API int GetHashCode () const
 
ASPOSECPP_SHARED_API void Lock ()
 
virtual ASPOSECPP_SHARED_API ptr MemberwiseClone () const
 
Objectoperator= (Object const &x)
 
bool ReferenceEquals (String const &str, std::nullptr_t)
 
bool ReferenceEquals (String const &str1, String const &str2)
 
int RemovedSharedRefs (int count)
 
virtual ASPOSECPP_SHARED_API void SetTemplateWeakPtr (unsigned int argument)
 
int SharedCount () const
 
ObjectSharedRefAdded ()
 
int SharedRefRemovedSafe ()
 
virtual ASPOSECPP_SHARED_API String ToString () const
 
ASPOSECPP_SHARED_API void Unlock ()
 
Detail::SmartPtrCounter * WeakRefAdded ()
 
void WeakRefRemoved ()
 
- Public Member Functions inherited from System::Collections::Generic::IEnumerable< System::SharedPtr< Aspose::Words::Node > >
EnumeratorBasedIterator< T, IEnumerator< T > > begin () noexcept
 
EnumeratorBasedIterator< T, IEnumerator< T > > cbegin () noexcept
 
EnumeratorBasedIterator< T, IEnumerator< T > > cend () noexcept
 
EnumeratorBasedIterator< T, IEnumerator< T > > end () noexcept
 
bool LINQ_All (std::function< bool(T)> predicate)
 
bool LINQ_Any ()
 
bool LINQ_Any (std::function< bool(T)> predicate)
 
SharedPtr< IEnumerable< ResultType > > LINQ_Cast ()
 
SharedPtr< IEnumerable< Result > > LINQ_Cast ()
 
bool LINQ_Contains (T value)
 
int LINQ_Count ()
 
int LINQ_Count (const Func< T, bool > &predicate)
 
LINQ_ElementAt (int index)
 
LINQ_First ()
 
LINQ_First (const Func< T, bool > &predicate)
 
LINQ_FirstOrDefault ()
 
LINQ_FirstOrDefault (std::function< bool(T)> predicate)
 
LINQ_Last ()
 
LINQ_LastOrDefault ()
 
SharedPtr< IEnumerable< ResultType > > LINQ_OfType ()
 
SharedPtr< IEnumerable< Result > > LINQ_OfType ()
 
SharedPtr< IEnumerable< Source > > LINQ_OrderBy (const Func< Source, Key > &keySelector)
 
SharedPtr< IEnumerable< T > > LINQ_OrderBy (const Func< T, Key > &keySelector)
 
SharedPtr< IEnumerable< Result > > LINQ_Select (const Func< Source, Result > &selector)
 
SharedPtr< IEnumerable< ResultType > > LINQ_Select (const Func< T, ResultType > &selector)
 
ArrayPtr< T > LINQ_ToArray ()
 
SharedPtr< List< T > > LINQ_ToList ()
 
SharedPtr< IEnumerable< T > > LINQ_Where (std::function< bool(T)> predicate)
 

Static Public Member Functions

static const TypeInfoType ()
 
- Static Public Member Functions inherited from ShapeBase
static const TypeInfoType ()
 
- Static Public Member Functions inherited from CompositeNode
static const TypeInfoType ()
 
- Static Public Member Functions inherited from Node
static String NodeTypeToString (NodeType nodeType)
 A utility method that converts a node type enum value into a user friendly string. More...
 
static const TypeInfoType ()
 
- Static Public Member Functions inherited from Object
bool Equals (double const &objA, double const &objB)
 
bool Equals (float const &objA, float const &objB)
 
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 
static const TypeInfoType ()
 

Additional Inherited Members

- Public Types inherited from Object
typedef SmartPtr< Objectptr
 
typedef System::Details::SharedMembersType shared_members_type
 
- Public Types inherited from System::Collections::Generic::IEnumerable< System::SharedPtr< Aspose::Words::Node > >
typedef IEnumerator< T > IEnumeratorType
 
typedef T ValueType
 

Constructor & Destructor Documentation

◆ Shape()

Aspose::Words::Drawing::Shape::Shape ( System::SharedPtr< Aspose::Words::DocumentBase doc,
Aspose::Words::Drawing::ShapeType  shapeType 
)

Creates a new shape object.

You should specify desired shape properties after you created a shape.

Parameters
docThe owner document.
shapeTypeThe type of the shape to create.
Examples

Shows how to add a shape with an image to a document.

auto doc = MakeObject<Document>();
// Public constructor of "Shape" class creates shape with "ShapeMarkupLanguage.Vml" markup type
// If you need to create non-primitive shapes, such as SingleCornerSnipped, TopCornersSnipped, DiagonalCornersSnipped,
// TopCornersOneRoundedOneSnipped, SingleCornerRounded, TopCornersRounded, DiagonalCornersRounded
// please use DocumentBuilder.InsertShape
auto shape = MakeObject<Shape>(doc, ShapeType::Image);
shape->get_ImageData()->SetImage(ImageDir + u"Windows MetaFile.wmf");
shape->set_Width(100);
shape->set_Height(100);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(shape);
doc->Save(ArtifactsDir + u"Image.CreateImageDirectly.docx");

Shows how to create a textbox with some text and different formatting options in a new document.

auto doc = MakeObject<Document>();
// Create a new shape of type TextBox
auto textBox = MakeObject<Shape>(doc, ShapeType::TextBox);
// Set some settings of the textbox itself
// Set the wrap of the textbox to inline
textBox->set_WrapType(WrapType::None);
// Set the horizontal and vertical alignment of the text inside the shape
textBox->set_HorizontalAlignment(HorizontalAlignment::Center);
textBox->set_VerticalAlignment(VerticalAlignment::Top);
// Set the textbox height and width
textBox->set_Height(50);
textBox->set_Width(200);
// Set the textbox in front of other shapes with a lower ZOrder
textBox->set_ZOrder(2);
// Let's create a new paragraph for the textbox manually and align it in the center
// Make sure we add the new nodes to the textbox as well
textBox->AppendChild(MakeObject<Paragraph>(doc));
SharedPtr<Paragraph> para = textBox->get_FirstParagraph();
para->get_ParagraphFormat()->set_Alignment(ParagraphAlignment::Center);
// Add some text to the paragraph
auto run = MakeObject<Run>(doc);
run->set_Text(u"Hello world!");
para->AppendChild(run);
// Append the textbox to the first paragraph in the body
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(textBox);
doc->Save(ArtifactsDir + u"Shape.CreateTextBox.docx");

Member Function Documentation

◆ Accept()

bool Aspose::Words::Drawing::Shape::Accept ( System::SharedPtr< Aspose::Words::DocumentVisitor visitor)
overridevirtual

Accepts a visitor.

Enumerates over this node and all of its children. Each node calls a corresponding method on DocumentVisitor.

For more info see the Visitor design pattern.

Parameters
visitorThe visitor that will visit the nodes.
Returns
True if all nodes were visited; false if DocumentVisitor stopped the operation before visiting all nodes.

Implements Aspose::Words::Node.

◆ get_Chart()

System::SharedPtr<Aspose::Words::Drawing::Charts::Chart> Aspose::Words::Drawing::Shape::get_Chart ( )

Provides access to the chart properties if this shape has a Chart.

◆ get_ExtrusionEnabled()

bool Aspose::Words::Drawing::Shape::get_ExtrusionEnabled ( )

Returns true if an extrusion effect is enabled.

◆ get_Fill()

System::SharedPtr<Aspose::Words::Drawing::Fill> Aspose::Words::Drawing::Shape::get_Fill ( )

Defines a fill for a shape.

Examples

Demonstrates how to create shapes with fill.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln();
builder->Writeln();
builder->Writeln();
builder->Write(u"Some text under the shape.");
// Create a red balloon, semitransparent
// The shape is floating and its coordinates are (0,0) by default, relative to the current paragraph
auto shape = MakeObject<Shape>(builder->get_Document(), ShapeType::Balloon);
shape->set_FillColor(System::Drawing::Color::get_Red());
shape->get_Fill()->set_Opacity(0.3);
shape->set_Width(100);
shape->set_Height(100);
shape->set_Top(-100);
builder->InsertNode(shape);
doc->Save(ArtifactsDir + u"Shape.Fill.docx");

◆ get_FillColor()

System::Drawing::Color Aspose::Words::Drawing::Shape::get_FillColor ( )

Defines the brush color that fills the closed path of the shape.

This is a shortcut to the Color property.

The default value is White.

Examples

Demonstrates how to create shapes with fill.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln();
builder->Writeln();
builder->Writeln();
builder->Write(u"Some text under the shape.");
// Create a red balloon, semitransparent
// The shape is floating and its coordinates are (0,0) by default, relative to the current paragraph
auto shape = MakeObject<Shape>(builder->get_Document(), ShapeType::Balloon);
shape->set_FillColor(System::Drawing::Color::get_Red());
shape->get_Fill()->set_Opacity(0.3);
shape->set_Width(100);
shape->set_Height(100);
shape->set_Top(-100);
builder->InsertNode(shape);
doc->Save(ArtifactsDir + u"Shape.Fill.docx");

◆ get_Filled()

bool Aspose::Words::Drawing::Shape::get_Filled ( )

Determines whether the closed path of the shape will be filled.

This is a shortcut to the On property.

The default value is true.

◆ get_FirstParagraph()

System::SharedPtr<Aspose::Words::Paragraph> Aspose::Words::Drawing::Shape::get_FirstParagraph ( )

Gets the first paragraph in the shape.

Examples

Shows how to create a textbox with some text and different formatting options in a new document.

auto doc = MakeObject<Document>();
// Create a new shape of type TextBox
auto textBox = MakeObject<Shape>(doc, ShapeType::TextBox);
// Set some settings of the textbox itself
// Set the wrap of the textbox to inline
textBox->set_WrapType(WrapType::None);
// Set the horizontal and vertical alignment of the text inside the shape
textBox->set_HorizontalAlignment(HorizontalAlignment::Center);
textBox->set_VerticalAlignment(VerticalAlignment::Top);
// Set the textbox height and width
textBox->set_Height(50);
textBox->set_Width(200);
// Set the textbox in front of other shapes with a lower ZOrder
textBox->set_ZOrder(2);
// Let's create a new paragraph for the textbox manually and align it in the center
// Make sure we add the new nodes to the textbox as well
textBox->AppendChild(MakeObject<Paragraph>(doc));
SharedPtr<Paragraph> para = textBox->get_FirstParagraph();
para->get_ParagraphFormat()->set_Alignment(ParagraphAlignment::Center);
// Add some text to the paragraph
auto run = MakeObject<Run>(doc);
run->set_Text(u"Hello world!");
para->AppendChild(run);
// Append the textbox to the first paragraph in the body
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(textBox);
doc->Save(ArtifactsDir + u"Shape.CreateTextBox.docx");

◆ get_HasChart()

bool Aspose::Words::Drawing::Shape::get_HasChart ( )

Returns true if this Shape has a Chart.

◆ get_HasImage()

bool Aspose::Words::Drawing::Shape::get_HasImage ( )

Returns true if the shape has image bytes or links an image.

Examples

Shows how to extract images from a document and save them as files.

auto doc = MakeObject<Document>(MyDir + u"Images.docx");
SharedPtr<NodeCollection> shapes = doc->GetChildNodes(NodeType::Shape, true);
ASSERT_EQ(9, shapes->LINQ_Count([](SharedPtr<Node> s) { return (System::DynamicCast<Shape>(s))->get_HasImage(); }));
int imageIndex = 0;
for (auto shape : System::IterateOver(shapes->LINQ_OfType<SharedPtr<Shape> >()))
{
if (shape->get_HasImage())
{
String imageFileName = String::Format(u"File.ExtractImagesToFiles.{0}{1}", imageIndex, FileFormatUtil::ImageTypeToExtension(shape->get_ImageData()->get_ImageType()));
shape->get_ImageData()->Save(ArtifactsDir + imageFileName);
imageIndex++;
}
}

Shows how to delete all images from a document.

auto doc = MakeObject<Document>(MyDir + u"Images.docx");
ASSERT_EQ(10, doc->GetChildNodes(NodeType::Shape, true)->get_Count());
// Here we get all shapes from the document node, but you can do this for any smaller
// node too, for example delete shapes from a single section or a paragraph
SharedPtr<NodeCollection> shapes = doc->GetChildNodes(NodeType::Shape, true);
// We cannot delete shape nodes while we enumerate through the collection
// One solution is to add nodes that we want to delete to a temporary array and delete afterwards
SharedPtr<System::Collections::Generic::List<SharedPtr<Shape>>> shapesToDelete = MakeObject<System::Collections::Generic::List<SharedPtr<Shape>>>();
// Several shape types can have an image including image shapes and OLE objects
for (auto shape : System::IterateOver(shapes->LINQ_OfType<SharedPtr<Shape> >()))
{
if (shape->get_HasImage())
{
shapesToDelete->Add(shape);
}
}
// Now we can delete shapes
for (auto shape : shapesToDelete)
{
shape->Remove();
}
// The only remaining shape doesn't have an image
ASSERT_EQ(1, doc->GetChildNodes(NodeType::Shape, true)->get_Count());
ASSERT_FALSE((System::DynamicCast<Shape>(doc->GetChild(NodeType::Shape, 0, true)))->get_HasImage());

◆ get_HasSmartArt()

bool Aspose::Words::Drawing::Shape::get_HasSmartArt ( )

Returns true if this Shape has a SmartArt object.

Examples

Shows how to detect that Shape has a SmartArt object.

auto doc = MakeObject<Document>(MyDir + u"SmartArt.docx");
int count = doc->GetChildNodes(NodeType::Shape, true)->LINQ_Cast<SharedPtr<Shape>>()->LINQ_Count([](SharedPtr<Shape> shape) { return shape->get_HasSmartArt(); });
System::Console::WriteLine(u"The document has {0} shapes with SmartArt.", count);

◆ get_HasVerticalTextFlow_ITextBox()

bool Aspose::Words::Drawing::Shape::get_HasVerticalTextFlow_ITextBox ( )
override

◆ get_HorizontalRuleFormat()

System::SharedPtr<Aspose::Words::Drawing::HorizontalRuleFormat> Aspose::Words::Drawing::Shape::get_HorizontalRuleFormat ( )

Provides access to the properties of the horizontal rule shape. For a shape that is not a horizontal rule, returns null.

Examples

Shows how to insert horizontal rule shape in a document and customize the formatting.

// Use a document builder to insert a horizontal rule
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Shape> shape = builder->InsertHorizontalRule();
SharedPtr<HorizontalRuleFormat> horizontalRuleFormat = shape->get_HorizontalRuleFormat();
horizontalRuleFormat->set_Alignment(HorizontalRuleAlignment::Center);
horizontalRuleFormat->set_WidthPercent(70);
horizontalRuleFormat->set_Height(3);
horizontalRuleFormat->set_Color(System::Drawing::Color::get_Blue());
horizontalRuleFormat->set_NoShade(true);
ASSERT_TRUE(shape->get_IsHorizontalRule());
ASSERT_TRUE(shape->get_HorizontalRuleFormat()->get_NoShade());

◆ get_ImageData()

System::SharedPtr<Aspose::Words::Drawing::ImageData> Aspose::Words::Drawing::Shape::get_ImageData ( )

Provides access to the image of the shape. Returns null if the shape cannot have an image.

Examples

Shows how to extract images from a document and save them as files.

auto doc = MakeObject<Document>(MyDir + u"Images.docx");
SharedPtr<NodeCollection> shapes = doc->GetChildNodes(NodeType::Shape, true);
ASSERT_EQ(9, shapes->LINQ_Count([](SharedPtr<Node> s) { return (System::DynamicCast<Shape>(s))->get_HasImage(); }));
int imageIndex = 0;
for (auto shape : System::IterateOver(shapes->LINQ_OfType<SharedPtr<Shape> >()))
{
if (shape->get_HasImage())
{
String imageFileName = String::Format(u"File.ExtractImagesToFiles.{0}{1}", imageIndex, FileFormatUtil::ImageTypeToExtension(shape->get_ImageData()->get_ImageType()));
shape->get_ImageData()->Save(ArtifactsDir + imageFileName);
imageIndex++;
}
}

Shows how to insert a linked image into a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
String imageFileName = ImageDir + u"Windows MetaFile.wmf";
builder->Write(u"Image linked, not stored in the document: ");
auto shape = MakeObject<Shape>(builder->get_Document(), ShapeType::Image);
shape->set_WrapType(WrapType::Inline);
shape->get_ImageData()->set_SourceFullName(imageFileName);
builder->InsertNode(shape);
builder->Writeln();
builder->Write(u"Image linked and stored in the document: ");
shape = MakeObject<Shape>(builder->get_Document(), ShapeType::Image);
shape->set_WrapType(WrapType::Inline);
shape->get_ImageData()->set_SourceFullName(imageFileName);
shape->get_ImageData()->SetImage(imageFileName);
builder->InsertNode(shape);
builder->Writeln();
builder->Write(u"Image stored in the document, but not linked: ");
shape = MakeObject<Shape>(builder->get_Document(), ShapeType::Image);
shape->set_WrapType(WrapType::Inline);
shape->get_ImageData()->SetImage(imageFileName);
builder->InsertNode(shape);
builder->Writeln();
doc->Save(ArtifactsDir + u"Image.CreateLinkedImage.docx");

◆ get_LastParagraph()

System::SharedPtr<Aspose::Words::Paragraph> Aspose::Words::Drawing::Shape::get_LastParagraph ( )

Gets the last paragraph in the shape.

Examples

Shows how to insert text boxes and arrange their text.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a shape that contains a TextBox
SharedPtr<Shape> textBoxShape = builder->InsertShape(ShapeType::TextBox, 150, 100);
SharedPtr<TextBox> textBox = textBoxShape->get_TextBox();
// Move the document builder to inside the TextBox and write text
builder->MoveTo(textBoxShape->get_LastParagraph());
builder->Write(u"Vertical text");
// Text is displayed vertically, written top to bottom
textBox->set_LayoutFlow(LayoutFlow::TopToBottomIdeographic);
// Move the builder out of the shape and back into the main document body
builder->MoveTo(textBoxShape->get_ParentParagraph());
// Insert another TextBox
textBoxShape = builder->InsertShape(ShapeType::TextBox, 150, 100);
textBox = textBoxShape->get_TextBox();
// Apply these values to both these members to get the parent shape to defy the dimensions we set to fit tightly around the TextBox's text
textBox->set_FitShapeToText(true);
textBox->set_TextBoxWrapMode(TextBoxWrapMode::None);
builder->MoveTo(textBoxShape->get_LastParagraph());
builder->Write(u"Text fit tightly inside textbox");
builder->MoveTo(textBoxShape->get_ParentParagraph());
textBoxShape = builder->InsertShape(ShapeType::TextBox, 100, 100);
textBox = textBoxShape->get_TextBox();
// Set margins for the textbox
textBox->set_InternalMarginTop(15);
textBox->set_InternalMarginBottom(15);
textBox->set_InternalMarginLeft(15);
textBox->set_InternalMarginRight(15);
builder->MoveTo(textBoxShape->get_LastParagraph());
builder->Write(u"Text placed according to textbox margins");
doc->Save(ArtifactsDir + u"Shape.TextBox.docx");

◆ get_MarkupLanguage_ITextBox()

Aspose::Words::Drawing::ShapeMarkupLanguage Aspose::Words::Drawing::Shape::get_MarkupLanguage_ITextBox ( )
override

◆ get_NodeType()

Aspose::Words::NodeType Aspose::Words::Drawing::Shape::get_NodeType ( ) const
overridevirtual

Returns Shape.

Implements Aspose::Words::Node.

◆ get_OleFormat()

System::SharedPtr<Aspose::Words::Drawing::OleFormat> Aspose::Words::Drawing::Shape::get_OleFormat ( )

Provides access to the OLE data of a shape. For a shape that is not an OLE object or ActiveX control, returns null.

◆ get_ShadowEnabled()

bool Aspose::Words::Drawing::Shape::get_ShadowEnabled ( )

Returns true if a shadow effect is enabled.

◆ get_SignatureLine()

System::SharedPtr<Aspose::Words::Drawing::SignatureLine> Aspose::Words::Drawing::Shape::get_SignatureLine ( )

Gets SignatureLine object if the shape is a signature line. Returns null otherwise.

See also
Aspose::Words::DocumentBuilder::InsertSignatureLine(System::SharedPtr<Aspose::Words::SignatureLineOptions>, Aspose::Words::Drawing::RelativeHorizontalPosition, double, Aspose::Words::Drawing::RelativeVerticalPosition, double, Aspose::Words::Drawing::WrapType)
Examples

Shows how to create a line for a signature and insert it into a document.

// Create a blank document and its DocumentBuilder
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// The SignatureLineOptions will contain all the data that the signature line will display
auto options = MakeObject<SignatureLineOptions>();
options->set_AllowComments(true);
options->set_DefaultInstructions(true);
options->set_Email(u"john.doe@management.com");
options->set_Instructions(u"Please sign here");
options->set_ShowDate(true);
options->set_Signer(u"John Doe");
options->set_SignerTitle(u"Senior Manager");
// Insert the signature line, applying our SignatureLineOptions
// We can control where the signature line will appear on the page using a combination of left/top indents and margin-relative positions
// Since we're placing the signature line at the bottom right of the page, we will need to use negative indents to move it into view
SharedPtr<Shape> shape = builder->InsertSignatureLine(options, RelativeHorizontalPosition::RightMargin, -170.0, RelativeVerticalPosition::BottomMargin, -60.0, WrapType::None);
ASSERT_TRUE(shape->get_IsSignatureLine());
// The SignatureLine object is a member of the shape that contains it
SharedPtr<SignatureLine> signatureLine = shape->get_SignatureLine();
ASSERT_EQ(u"john.doe@management.com", signatureLine->get_Email());
ASSERT_EQ(u"John Doe", signatureLine->get_Signer());
ASSERT_EQ(u"Senior Manager", signatureLine->get_SignerTitle());
ASSERT_EQ(u"Please sign here", signatureLine->get_Instructions());
ASSERT_TRUE(signatureLine->get_ShowDate());
ASSERT_TRUE(signatureLine->get_AllowComments());
ASSERT_TRUE(signatureLine->get_DefaultInstructions());
// We will be prompted to sign it when we open the document
ASSERT_FALSE(signatureLine->get_IsSigned());
// The object may be valid, but the signature itself isn't until it is signed
ASSERT_FALSE(signatureLine->get_IsValid());
doc->Save(ArtifactsDir + u"Shape.SignatureLine.docx");

◆ get_StoryType()

Aspose::Words::StoryType Aspose::Words::Drawing::Shape::get_StoryType ( )

Returns Textbox.

◆ get_Stroke()

System::SharedPtr<Aspose::Words::Drawing::Stroke> Aspose::Words::Drawing::Shape::get_Stroke ( )

Defines a stroke for a shape.

Examples

Shows to create a variety of shapes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Draw a dotted horizontal half-transparent red line with an arrow on the left end and a diamond on the other
auto arrow = MakeObject<Shape>(doc, ShapeType::Line);
arrow->set_Width(200);
arrow->get_Stroke()->set_Color(System::Drawing::Color::get_Red());
arrow->get_Stroke()->set_StartArrowType(ArrowType::Arrow);
arrow->get_Stroke()->set_StartArrowLength(ArrowLength::Long);
arrow->get_Stroke()->set_StartArrowWidth(ArrowWidth::Wide);
arrow->get_Stroke()->set_EndArrowType(ArrowType::Diamond);
arrow->get_Stroke()->set_EndArrowLength(ArrowLength::Long);
arrow->get_Stroke()->set_EndArrowWidth(ArrowWidth::Wide);
arrow->get_Stroke()->set_DashStyle(DashStyle::Dash);
arrow->get_Stroke()->set_Opacity(0.5);
ASSERT_EQ(JoinStyle::Miter, arrow->get_Stroke()->get_JoinStyle());
builder->InsertNode(arrow);
// Draw a thick black diagonal line with rounded ends
auto line = MakeObject<Shape>(doc, ShapeType::Line);
line->set_Top(40);
line->set_Width(200);
line->set_Height(20);
line->set_StrokeWeight(5.0);
line->get_Stroke()->set_EndCap(EndCap::Round);
builder->InsertNode(line);
// Draw an arrow with a green fill
auto filledInArrow = MakeObject<Shape>(doc, ShapeType::Arrow);
filledInArrow->set_Width(200);
filledInArrow->set_Height(40);
filledInArrow->set_Top(100);
filledInArrow->get_Fill()->set_Color(System::Drawing::Color::get_Green());
filledInArrow->get_Fill()->set_On(true);
builder->InsertNode(filledInArrow);
// Draw an arrow filled in with the Aspose logo and flip its orientation
auto filledInArrowImg = MakeObject<Shape>(doc, ShapeType::Arrow);
filledInArrowImg->set_Width(200);
filledInArrowImg->set_Height(40);
filledInArrowImg->set_Top(160);
filledInArrowImg->set_FlipOrientation(FlipOrientation::Both);
{
auto webClient = MakeObject<System::Net::WebClient>();
ArrayPtr<uint8_t> imageBytes = webClient->DownloadData(AsposeLogoUrl);
{
auto stream = MakeObject<System::IO::MemoryStream>(imageBytes);
SharedPtr<System::Drawing::Image> image = System::Drawing::Image::FromStream(stream);
// When we flipped the orientation of our arrow, the image content was flipped too
// If we want it to be displayed the right side up, we have to reverse the arrow flip on the image
filledInArrowImg->get_ImageData()->SetImage(image);
filledInArrowImg->get_Stroke()->set_JoinStyle(JoinStyle::Round);
builder->InsertNode(filledInArrowImg);
}
}
doc->Save(ArtifactsDir + u"Drawing.VariousShapes.docx");

◆ get_StrokeColor()

System::Drawing::Color Aspose::Words::Drawing::Shape::get_StrokeColor ( )

Defines the color of a stroke.

This is a shortcut to the Color property.

The default value is Black.

◆ get_Stroked()

bool Aspose::Words::Drawing::Shape::get_Stroked ( )

Defines whether the path will be stroked.

This is a shortcut to the On property.

The default value is true.

◆ get_StrokeWeight()

double Aspose::Words::Drawing::Shape::get_StrokeWeight ( )

Defines the brush thickness that strokes the path of a shape in points.

This is a shortcut to the Weight property.

The default value is 0.75.

◆ get_TextBox()

System::SharedPtr<Aspose::Words::Drawing::TextBox> Aspose::Words::Drawing::Shape::get_TextBox ( )

Defines attributes that specify how text is displayed in a shape.

Examples

Shows how to insert text boxes and arrange their text.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a shape that contains a TextBox
SharedPtr<Shape> textBoxShape = builder->InsertShape(ShapeType::TextBox, 150, 100);
SharedPtr<TextBox> textBox = textBoxShape->get_TextBox();
// Move the document builder to inside the TextBox and write text
builder->MoveTo(textBoxShape->get_LastParagraph());
builder->Write(u"Vertical text");
// Text is displayed vertically, written top to bottom
textBox->set_LayoutFlow(LayoutFlow::TopToBottomIdeographic);
// Move the builder out of the shape and back into the main document body
builder->MoveTo(textBoxShape->get_ParentParagraph());
// Insert another TextBox
textBoxShape = builder->InsertShape(ShapeType::TextBox, 150, 100);
textBox = textBoxShape->get_TextBox();
// Apply these values to both these members to get the parent shape to defy the dimensions we set to fit tightly around the TextBox's text
textBox->set_FitShapeToText(true);
textBox->set_TextBoxWrapMode(TextBoxWrapMode::None);
builder->MoveTo(textBoxShape->get_LastParagraph());
builder->Write(u"Text fit tightly inside textbox");
builder->MoveTo(textBoxShape->get_ParentParagraph());
textBoxShape = builder->InsertShape(ShapeType::TextBox, 100, 100);
textBox = textBoxShape->get_TextBox();
// Set margins for the textbox
textBox->set_InternalMarginTop(15);
textBox->set_InternalMarginBottom(15);
textBox->set_InternalMarginLeft(15);
textBox->set_InternalMarginRight(15);
builder->MoveTo(textBoxShape->get_LastParagraph());
builder->Write(u"Text placed according to textbox margins");
doc->Save(ArtifactsDir + u"Shape.TextBox.docx");

◆ get_TextboxLayoutFlow_ITextBox()

Aspose::Words::Drawing::LayoutFlow Aspose::Words::Drawing::Shape::get_TextboxLayoutFlow_ITextBox ( )
override

◆ get_TextBoxWrapMode_ITextBox()

Aspose::Words::Drawing::TextBoxWrapMode Aspose::Words::Drawing::Shape::get_TextBoxWrapMode_ITextBox ( )
override

◆ get_TextPath()

System::SharedPtr<Aspose::Words::Drawing::TextPath> Aspose::Words::Drawing::Shape::get_TextPath ( )

Defines the text of the text path (of a WordArt object).

◆ GetHorizontalMargins_ITextBox()

float Aspose::Words::Drawing::Shape::GetHorizontalMargins_ITextBox ( )
override

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Drawing::Shape::GetType ( ) const
overridevirtual

Reimplemented from Aspose::Words::Drawing::ShapeBase.

◆ Is()

virtual bool Aspose::Words::Drawing::Shape::Is ( const System::TypeInfo target) const
overridevirtual

Reimplemented from Aspose::Words::Drawing::ShapeBase.

◆ set_FillColor()

void Aspose::Words::Drawing::Shape::set_FillColor ( System::Drawing::Color  value)

◆ set_Filled()

void Aspose::Words::Drawing::Shape::set_Filled ( bool  value)

◆ set_StrokeColor()

void Aspose::Words::Drawing::Shape::set_StrokeColor ( System::Drawing::Color  value)

◆ set_Stroked()

void Aspose::Words::Drawing::Shape::set_Stroked ( bool  value)

◆ set_StrokeWeight()

void Aspose::Words::Drawing::Shape::set_StrokeWeight ( double  value)

◆ Type()

static const System::TypeInfo& Aspose::Words::Drawing::Shape::Type ( )
static
@ Arrow
The arrow is a solid triangle.
String
@ Rectangle
@ Shape
A drawing object, such as an OfficeArt shape, image or an OLE object. A Shape node can contain Paragr...
@ Cube
@ TopToBottomIdeographic
Ideographic text is displayed vertically.
@ Wide
@ None
Text does not wrap inside a shape.
@ GroupShape
A group of shapes, images, OLE objects or other group shapes. A GroupShape node can contain other Sha...
@ Inline
The shape remains on the same layer as text and treated as a character.
@ Image
The shape is an image.
static ASPOSECPP_SHARED_API SharedPtr< Image > FromStream(const SharedPtr< System::IO::Stream > &stream, bool use_embedded_color_management=false, bool validate_image_data=1)
@ Page
The object is positioned relative to the top edge of the page.
@ None
No text wrapping around the shape. The shape is placed behind or in front of text.
@ Both
Flip along both the y- and x-axis.
@ Round
Draw an arc between the two edges.
@ Dash
Dash style.
@ Arrow
@ Center
Aligned to the center.
static ASPOSECPP_SHARED_API void WriteLine()
std::enable_if_t<!Details::IsIterable< Enumerable >::value, Details::EnumeratorAdapter< Enumerable, T > > IterateOver(System::SmartPtr< Enumerable > enumerable)
@ RotateNoneFlipXY
@ Page
The object is positioned relative to the left edge of the page.
@ BottomMargin
Specifies that the vertical positioning shall be relative to the bottom margin of the current page.
@ TextBox
The shape is a textbox. Note that shapes of many other types can also have text inside them too....
@ Diamond
The line end is a solid diamond.
@ Line
@ RightMargin
Specifies that the horizontal positioning shall be relative to the right margin of the page.
static System::String ImageTypeToExtension(Aspose::Words::Drawing::ImageType imageType)
Converts an Aspose.Words image type enumerated value into a file extension. The returned extension is...
static ASPOSECPP_SHARED_API Color get_Green()
@ Miter
Extend edges until they join.
@ Balloon
@ Star
@ Center
Specifies that the object shall be centered with respect to the horizontal alignment base.
static ASPOSECPP_SHARED_API Color get_Blue()
@ Long
@ Center
Specifies that the object shall be centered with respect to the vertical alignment base.
static ASPOSECPP_SHARED_API Color get_Red()
@ Top
Specifies that the object shall be at the top of the vertical alignment base.
@ Round
Rounded ends.
int LINQ_Count()
@ Center
Text is centered horizontally.