Manage Connectors in Presentations Using C++
Overview
A connector is a line that can remain attached to two shapes when either shape moves. Its ends attach to connection sites, represented by green dots in PowerPoint. Some bent and curved connectors also expose adjustment points, represented by orange dots, that control the position of individual connector segments.
Aspose.Slides represents connectors through the IConnector interface. You can create them, attach their ends to shapes, choose connection sites, reroute them, and modify the geometry of connectors that have adjustment points.
Connector Types
The ShapeType enumeration includes straight, bent, and curved connector presets. The following table shows the available connector geometries and the number of adjustment points defined by each preset.
| Connector | Image | Number of adjustment points |
|---|---|---|
ShapeType::Line |
![]() |
0 |
ShapeType::StraightConnector1 |
![]() |
0 |
ShapeType::BentConnector2 |
![]() |
0 |
ShapeType::BentConnector3 |
![]() |
1 |
ShapeType::BentConnector4 |
![]() |
2 |
ShapeType::BentConnector5 |
![]() |
3 |
ShapeType::CurvedConnector2 |
![]() |
0 |
ShapeType::CurvedConnector3 |
![]() |
1 |
ShapeType::CurvedConnector4 |
![]() |
2 |
ShapeType::CurvedConnector5 |
![]() |
3 |
The number and meaning of adjustment points are part of the selected connector preset. Do not assume that two different connector types expose the same collection layout.
Connect Two Shapes
Use IShapeCollection::AddConnector to add a connector, and call IConnector::set_StartShapeConnectedTo and IConnector::set_EndShapeConnectedTo to attach its ends. After both ends are attached, IConnector::Reroute selects a short route between the shapes.
The following example connects an ellipse and a rectangle with a bent connector:
#include <DOM/IAutoShape.h>
#include <DOM/IConnector.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/Presentation.h>
#include <DOM/ShapeType.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
System::SharedPtr<Presentation> presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto shapes = slide->get_Shapes();
auto ellipse = shapes->AddAutoShape(ShapeType::Ellipse, 40, 80, 120, 80);
auto rectangle = shapes->AddAutoShape(ShapeType::Rectangle, 320, 240, 140, 80);
auto connector = shapes->AddConnector(ShapeType::BentConnector2, 0, 0, 10, 10);
connector->set_StartShapeConnectedTo(ellipse);
connector->set_EndShapeConnectedTo(rectangle);
connector->Reroute();
presentation->Save(u"connected-shapes.pptx", SaveFormat::Pptx);
Warning
CallingIConnector::Reroute can change the IConnector::set_StartShapeConnectionSiteIndex and IConnector::set_EndShapeConnectionSiteIndex values. Assign specific connection sites after rerouting if those sites must remain fixed.
Choose a Connection Site
Each connectable shape reports its number of sites through IShape::get_ConnectionSiteCount. Validate a preferred zero-based site index before assigning it to a connector end; site counts vary by shape geometry.
This example attaches the connector to a particular site on the ellipse when that site exists:
#include <DOM/IAutoShape.h>
#include <DOM/IConnector.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/Presentation.h>
#include <DOM/ShapeType.h>
#include <Export/SaveFormat.h>
#include <system/console.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace System;
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto shapes = slide->get_Shapes();
auto ellipse = shapes->AddAutoShape(ShapeType::Ellipse, 40, 80, 120, 80);
auto rectangle = shapes->AddAutoShape(ShapeType::Rectangle, 320, 240, 140, 80);
auto connector = shapes->AddConnector(ShapeType::BentConnector3, 0, 0, 10, 10);
connector->set_StartShapeConnectedTo(ellipse);
connector->set_EndShapeConnectedTo(rectangle);
int32_t preferredSiteIndex = 2;
if (preferredSiteIndex < ellipse->get_ConnectionSiteCount())
{
connector->set_StartShapeConnectionSiteIndex(preferredSiteIndex);
}
else
{
Console::WriteLine(u"The ellipse has only {0} connection sites.", ellipse->get_ConnectionSiteCount());
}
presentation->Save(u"specific-connection-site.pptx", SaveFormat::Pptx);
Adjust a Connector Point
Connectors with adjustment points expose them through IGeometryShape::get_Adjustments. Inspect every IAdjustValue and check its IAdjustValue::get_Type before changing its IAdjustValue::set_RawValue. The general rules for identifying preset shape adjustments are described in Shape Manipulation.
The number, order, meaning, and valid value range of connector adjustments depend on the connector preset. The type returned by IAdjustValue::get_Type is read-only, while the raw adjustment value is writable. The read-only IAdjustValue::get_Name method provides additional identification when a connector contains more than one adjustment of the same semantic type.
Route Around an Obstacle
In the following layout, a ShapeType::BentConnector5 connector between two shapes passes through a third shape:

This code creates the obstructed connector:
#include <DOM/FillType.h>
#include <DOM/IAutoShape.h>
#include <DOM/IColorFormat.h>
#include <DOM/IConnector.h>
#include <DOM/ILineFillFormat.h>
#include <DOM/ILineFormat.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/LineArrowheadStyle.h>
#include <DOM/Presentation.h>
#include <DOM/ShapeType.h>
#include <Export/SaveFormat.h>
#include <drawing/color.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace System::Drawing;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto shapes = slide->get_Shapes();
shapes->AddAutoShape(ShapeType::Rectangle, 300, 150, 150, 75);
auto sourceShape = shapes->AddAutoShape(ShapeType::Rectangle, 500, 400, 100, 50);
auto targetShape = shapes->AddAutoShape(ShapeType::Rectangle, 100, 100, 70, 30);
auto connector = shapes->AddConnector(ShapeType::BentConnector5, 20, 20, 400, 300);
auto lineFormat = connector->get_LineFormat();
lineFormat->set_EndArrowheadStyle(LineArrowheadStyle::Triangle);
auto lineFillFormat = lineFormat->get_FillFormat();
lineFillFormat->set_FillType(FillType::Solid);
lineFillFormat->get_SolidFillColor()->set_Color(Color::get_Black());
connector->set_StartShapeConnectedTo(sourceShape);
connector->set_EndShapeConnectedTo(targetShape);
connector->set_StartShapeConnectionSiteIndex(2);
presentation->Save(u"connector-obstruction.pptx", SaveFormat::Pptx);
Moving the vertical bend changes the route so that the connector bypasses the obstacle:

Instead of assuming that collection index 1 always represents the vertical bend, this example searches for ShapeAdjustmentType::ConnectorBendPositionY and changes it only when the expected semantic type is present:
#include <DOM/FillType.h>
#include <DOM/IAdjustValue.h>
#include <DOM/IAdjustValueCollection.h>
#include <DOM/IAutoShape.h>
#include <DOM/IColorFormat.h>
#include <DOM/IConnector.h>
#include <DOM/ILineFillFormat.h>
#include <DOM/ILineFormat.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/LineArrowheadStyle.h>
#include <DOM/Presentation.h>
#include <DOM/ShapeAdjustmentType.h>
#include <DOM/ShapeType.h>
#include <Export/SaveFormat.h>
#include <drawing/color.h>
#include <system/console.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace System;
using namespace System::Drawing;
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto shapes = slide->get_Shapes();
shapes->AddAutoShape(ShapeType::Rectangle, 300, 150, 150, 75);
auto sourceShape = shapes->AddAutoShape(ShapeType::Rectangle, 500, 400, 100, 50);
auto targetShape = shapes->AddAutoShape(ShapeType::Rectangle, 100, 100, 70, 30);
auto connector = shapes->AddConnector(ShapeType::BentConnector5, 20, 20, 400, 300);
auto lineFormat = connector->get_LineFormat();
lineFormat->set_EndArrowheadStyle(LineArrowheadStyle::Triangle);
auto lineFillFormat = lineFormat->get_FillFormat();
lineFillFormat->set_FillType(FillType::Solid);
lineFillFormat->get_SolidFillColor()->set_Color(Color::get_Black());
connector->set_StartShapeConnectedTo(sourceShape);
connector->set_EndShapeConnectedTo(targetShape);
connector->set_StartShapeConnectionSiteIndex(2);
SharedPtr<IAdjustValue> verticalBend;
auto adjustments = connector->get_Adjustments();
for (int32_t adjustmentIndex = 0; adjustmentIndex < adjustments->get_Count(); ++adjustmentIndex)
{
auto adjustment = adjustments->idx_get(adjustmentIndex);
Console::WriteLine(u"{0}: type = {1}, raw value = {2}", adjustment->get_Name(), static_cast<int32_t>(adjustment->get_Type()), adjustment->get_RawValue());
if (adjustment->get_Type() == ShapeAdjustmentType::ConnectorBendPositionY)
{
verticalBend = adjustment;
break;
}
}
if (verticalBend == nullptr)
{
Console::WriteLine(u"The connector does not expose a vertical bend adjustment.");
}
else
{
verticalBend->set_RawValue(60000);
presentation->Save(u"connector-obstruction-fixed.pptx", SaveFormat::Pptx);
}
A ShapeType::BentConnector5 has two ShapeAdjustmentType::ConnectorBendPositionX adjustments and one ShapeAdjustmentType::ConnectorBendPositionY adjustment. If the type you need occurs more than once, inspect IAdjustValue::get_Name and the known geometry of that preset before selecting one. If an adjustment reports ShapeAdjustmentType::Custom, treat its meaning and range as preset-specific and do not change it until that contract is known.
Relate Adjustment Values to Connector Geometry
For bent connectors, adjustment values can be used to estimate the positions of individual segments. These calculations are specific to the connector preset:
ShapeType::BentConnector4normally exposes oneShapeAdjustmentType::ConnectorBendPositionXand oneShapeAdjustmentType::ConnectorBendPositionYadjustment.- For these bend positions,
RawValue / 100000.0fproduces the fraction of the connector frame width or height used by the examples below. - A connector frame can be rotated or flipped, so frame coordinates must be transformed before they are compared with slide coordinates.
The following examples use IAdjustValue::get_Type to identify the adjustments first. They do not treat collection indexes as portable identifiers.
Unrotated Connector
The initial layout contains two text shapes connected by a ShapeType::BentConnector4:

This example inspects the connector and obtains its horizontal and vertical bend adjustments:
#include <DOM/FillType.h>
#include <DOM/IAdjustValue.h>
#include <DOM/IAdjustValueCollection.h>
#include <DOM/IAutoShape.h>
#include <DOM/IColorFormat.h>
#include <DOM/IConnector.h>
#include <DOM/ILineFillFormat.h>
#include <DOM/ILineFormat.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/LineArrowheadStyle.h>
#include <DOM/Presentation.h>
#include <DOM/ShapeAdjustmentType.h>
#include <DOM/ShapeType.h>
#include <drawing/color.h>
#include <system/console.h>
using namespace Aspose::Slides;
using namespace System;
using namespace System::Drawing;
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto shapes = slide->get_Shapes();
auto sourceShape = shapes->AddAutoShape(ShapeType::Rectangle, 100, 100, 60, 25);
sourceShape->get_TextFrame()->set_Text(u"From");
auto targetShape = shapes->AddAutoShape(ShapeType::Rectangle, 500, 100, 60, 25);
targetShape->get_TextFrame()->set_Text(u"To");
auto connector = shapes->AddConnector(ShapeType::BentConnector4, 20, 20, 400, 300);
auto lineFormat = connector->get_LineFormat();
lineFormat->set_EndArrowheadStyle(LineArrowheadStyle::Triangle);
auto lineFillFormat = lineFormat->get_FillFormat();
lineFillFormat->set_FillType(FillType::Solid);
lineFillFormat->get_SolidFillColor()->set_Color(Color::get_Crimson());
lineFormat->set_Width(3);
connector->set_StartShapeConnectedTo(sourceShape);
connector->set_StartShapeConnectionSiteIndex(3);
connector->set_EndShapeConnectedTo(targetShape);
connector->set_EndShapeConnectionSiteIndex(2);
auto adjustments = connector->get_Adjustments();
for (int32_t adjustmentIndex = 0; adjustmentIndex < adjustments->get_Count(); ++adjustmentIndex)
{
auto adjustment = adjustments->idx_get(adjustmentIndex);
Console::WriteLine(u"{0}: type = {1}, raw value = {2}", adjustment->get_Name(), static_cast<int32_t>(adjustment->get_Type()), adjustment->get_RawValue());
}
To change both bends, locate each expected type and modify the values only after both have been found:
#include <DOM/IAdjustValue.h>
#include <DOM/IAdjustValueCollection.h>
#include <DOM/IAutoShape.h>
#include <DOM/IConnector.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/Presentation.h>
#include <DOM/ShapeAdjustmentType.h>
#include <DOM/ShapeType.h>
#include <Export/SaveFormat.h>
#include <system/console.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace System;
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto shapes = slide->get_Shapes();
auto sourceShape = shapes->AddAutoShape(ShapeType::Rectangle, 100, 100, 60, 25);
auto targetShape = shapes->AddAutoShape(ShapeType::Rectangle, 500, 100, 60, 25);
auto connector = shapes->AddConnector(ShapeType::BentConnector4, 20, 20, 400, 300);
connector->set_StartShapeConnectedTo(sourceShape);
connector->set_StartShapeConnectionSiteIndex(3);
connector->set_EndShapeConnectedTo(targetShape);
connector->set_EndShapeConnectionSiteIndex(2);
SharedPtr<IAdjustValue> horizontalBend;
SharedPtr<IAdjustValue> verticalBend;
auto adjustments = connector->get_Adjustments();
for (int32_t adjustmentIndex = 0; adjustmentIndex < adjustments->get_Count(); ++adjustmentIndex)
{
auto adjustment = adjustments->idx_get(adjustmentIndex);
if (adjustment->get_Type() == ShapeAdjustmentType::ConnectorBendPositionX)
{
horizontalBend = adjustment;
}
else if (adjustment->get_Type() == ShapeAdjustmentType::ConnectorBendPositionY)
{
verticalBend = adjustment;
}
}
if (horizontalBend == nullptr || verticalBend == nullptr)
{
Console::WriteLine(u"The connector does not expose the expected bend adjustments.");
}
else
{
horizontalBend->set_RawValue(horizontalBend->get_RawValue() + 20000);
verticalBend->set_RawValue(verticalBend->get_RawValue() + 200000);
presentation->Save(u"connector-adjusted.pptx", SaveFormat::Pptx);
}
The result is a connector whose horizontal and vertical segments have moved:

Once the semantic types are known, their values can be converted into connector-frame coordinates. This example draws a thin rectangle over the vertical segment controlled by the two bend adjustments:
#include <DOM/IAdjustValue.h>
#include <DOM/IAdjustValueCollection.h>
#include <DOM/IAutoShape.h>
#include <DOM/IConnector.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/Presentation.h>
#include <DOM/ShapeAdjustmentType.h>
#include <DOM/ShapeType.h>
#include <Export/SaveFormat.h>
#include <system/console.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace System;
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto shapes = slide->get_Shapes();
auto sourceShape = shapes->AddAutoShape(ShapeType::Rectangle, 100, 100, 60, 25);
auto targetShape = shapes->AddAutoShape(ShapeType::Rectangle, 500, 100, 60, 25);
auto connector = shapes->AddConnector(ShapeType::BentConnector4, 20, 20, 400, 300);
connector->set_StartShapeConnectedTo(sourceShape);
connector->set_StartShapeConnectionSiteIndex(3);
connector->set_EndShapeConnectedTo(targetShape);
connector->set_EndShapeConnectionSiteIndex(2);
SharedPtr<IAdjustValue> horizontalBend;
SharedPtr<IAdjustValue> verticalBend;
auto adjustments = connector->get_Adjustments();
for (int32_t adjustmentIndex = 0; adjustmentIndex < adjustments->get_Count(); ++adjustmentIndex)
{
auto adjustment = adjustments->idx_get(adjustmentIndex);
if (adjustment->get_Type() == ShapeAdjustmentType::ConnectorBendPositionX)
{
horizontalBend = adjustment;
}
else if (adjustment->get_Type() == ShapeAdjustmentType::ConnectorBendPositionY)
{
verticalBend = adjustment;
}
}
if (horizontalBend == nullptr || verticalBend == nullptr)
{
Console::WriteLine(u"The connector does not expose the expected bend adjustments.");
}
else
{
float x = connector->get_X() + connector->get_Width() * horizontalBend->get_RawValue() / 100000.0f;
float y = connector->get_Y();
float height = connector->get_Height() * verticalBend->get_RawValue() / 100000.0f;
shapes->AddAutoShape(ShapeType::Rectangle, x, y, 1, height);
presentation->Save(u"connector-segment-guide.pptx", SaveFormat::Pptx);
}
The guide shape marks the calculated segment:

Rotated or Flipped Connector
When the same connector geometry is oriented vertically, its IShape::get_Frame, IShapeFrame::get_FlipH, and IShapeFrame::get_FlipV values affect the conversion from connector-frame coordinates to slide coordinates.
This example creates and adjusts the vertically oriented connector:
#include <DOM/FillType.h>
#include <DOM/IAdjustValue.h>
#include <DOM/IAdjustValueCollection.h>
#include <DOM/IAutoShape.h>
#include <DOM/IColorFormat.h>
#include <DOM/IConnector.h>
#include <DOM/ILineFillFormat.h>
#include <DOM/ILineFormat.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/LineArrowheadStyle.h>
#include <DOM/Presentation.h>
#include <DOM/ShapeAdjustmentType.h>
#include <DOM/ShapeType.h>
#include <Export/SaveFormat.h>
#include <drawing/color.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace System::Drawing;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto shapes = slide->get_Shapes();
auto sourceShape = shapes->AddAutoShape(ShapeType::Rectangle, 100, 100, 60, 25);
sourceShape->get_TextFrame()->set_Text(u"From");
auto targetShape = shapes->AddAutoShape(ShapeType::Rectangle, 100, 400, 60, 25);
targetShape->get_TextFrame()->set_Text(u"To 1");
auto connector = shapes->AddConnector(ShapeType::BentConnector4, 20, 20, 400, 300);
auto lineFormat = connector->get_LineFormat();
lineFormat->set_EndArrowheadStyle(LineArrowheadStyle::Triangle);
auto lineFillFormat = lineFormat->get_FillFormat();
lineFillFormat->set_FillType(FillType::Solid);
lineFillFormat->get_SolidFillColor()->set_Color(Color::get_MediumAquamarine());
lineFormat->set_Width(3);
connector->set_StartShapeConnectedTo(sourceShape);
connector->set_StartShapeConnectionSiteIndex(2);
connector->set_EndShapeConnectedTo(targetShape);
connector->set_EndShapeConnectionSiteIndex(3);
auto adjustments = connector->get_Adjustments();
for (int32_t adjustmentIndex = 0; adjustmentIndex < adjustments->get_Count(); ++adjustmentIndex)
{
auto adjustment = adjustments->idx_get(adjustmentIndex);
if (adjustment->get_Type() == ShapeAdjustmentType::ConnectorBendPositionX)
{
adjustment->set_RawValue(adjustment->get_RawValue() + 20000);
}
else if (adjustment->get_Type() == ShapeAdjustmentType::ConnectorBendPositionY)
{
adjustment->set_RawValue(adjustment->get_RawValue() + 200000);
}
}
presentation->Save(u"vertical-connector-adjusted.pptx", SaveFormat::Pptx);
The adjusted connector appears vertically between the shapes:

For an arbitrary rotation angle alpha, rotate a connector-frame point (x, y) around the frame center (x0, y0):
X = (x - x0) * cos(alpha) - (y - y0) * sin(alpha) + x0
Y = (x - x0) * sin(alpha) + (y - y0) * cos(alpha) + y0
The following code handles the 90-degree orientation used in this example and draws a red guide over the corresponding connector segment:
#include <DOM/FillType.h>
#include <DOM/IAdjustValue.h>
#include <DOM/IAdjustValueCollection.h>
#include <DOM/IAutoShape.h>
#include <DOM/IColorFormat.h>
#include <DOM/IConnector.h>
#include <DOM/ILineFillFormat.h>
#include <DOM/ILineFormat.h>
#include <DOM/IShapeCollection.h>
#include <DOM/IShapeFrame.h>
#include <DOM/ISlide.h>
#include <DOM/NullableBool.h>
#include <DOM/Presentation.h>
#include <DOM/ShapeAdjustmentType.h>
#include <DOM/ShapeType.h>
#include <Export/SaveFormat.h>
#include <drawing/color.h>
#include <system/console.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace System;
using namespace System::Drawing;
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto shapes = slide->get_Shapes();
auto sourceShape = shapes->AddAutoShape(ShapeType::Rectangle, 100, 100, 60, 25);
auto targetShape = shapes->AddAutoShape(ShapeType::Rectangle, 100, 400, 60, 25);
auto connector = shapes->AddConnector(ShapeType::BentConnector4, 20, 20, 400, 300);
connector->set_StartShapeConnectedTo(sourceShape);
connector->set_StartShapeConnectionSiteIndex(2);
connector->set_EndShapeConnectedTo(targetShape);
connector->set_EndShapeConnectionSiteIndex(3);
SharedPtr<IAdjustValue> horizontalBend;
SharedPtr<IAdjustValue> verticalBend;
auto adjustments = connector->get_Adjustments();
for (int32_t adjustmentIndex = 0; adjustmentIndex < adjustments->get_Count(); ++adjustmentIndex)
{
auto adjustment = adjustments->idx_get(adjustmentIndex);
if (adjustment->get_Type() == ShapeAdjustmentType::ConnectorBendPositionX)
{
horizontalBend = adjustment;
}
else if (adjustment->get_Type() == ShapeAdjustmentType::ConnectorBendPositionY)
{
verticalBend = adjustment;
}
}
if (horizontalBend == nullptr || verticalBend == nullptr)
{
Console::WriteLine(u"The connector does not expose the expected bend adjustments.");
}
else
{
horizontalBend->set_RawValue(horizontalBend->get_RawValue() + 20000);
verticalBend->set_RawValue(verticalBend->get_RawValue() + 200000);
float x = connector->get_X();
float y = connector->get_Y();
auto frame = connector->get_Frame();
if (frame->get_FlipH() == NullableBool::True)
{
x += connector->get_Width();
}
if (frame->get_FlipV() == NullableBool::True)
{
y += connector->get_Height();
}
x += connector->get_Width() * horizontalBend->get_RawValue() / 100000.0f;
float rotatedX = frame->get_CenterX() - y + frame->get_CenterY();
float rotatedY = x - frame->get_CenterX() + frame->get_CenterY();
float segmentWidth = connector->get_Height() * verticalBend->get_RawValue() / 100000.0f;
auto guide = shapes->AddAutoShape(ShapeType::Rectangle, rotatedX, rotatedY, segmentWidth, 1);
auto guideLineFillFormat = guide->get_LineFormat()->get_FillFormat();
guideLineFillFormat->set_FillType(FillType::Solid);
guideLineFillFormat->get_SolidFillColor()->set_Color(Color::get_Red());
presentation->Save(u"rotated-connector-segment-guide.pptx", SaveFormat::Pptx);
}
The red guide marks the calculated segment after the coordinate transformation:

These formulas describe the presets used in the examples, not a universal connector model. Validate the adjustment types, frame orientation, and value ranges before applying the same calculation to a different preset.
Find a Connector Direction Angle
The direction of a straight connector can be calculated from its width and height, with horizontal and vertical flips applied. The following example reports the clockwise angle from the positive horizontal axis in slide coordinates:
#include <DOM/IConnector.h>
#include <DOM/IShapeCollection.h>
#include <DOM/IShapeFrame.h>
#include <DOM/ISlide.h>
#include <DOM/NullableBool.h>
#include <DOM/Presentation.h>
#include <DOM/ShapeType.h>
#include <system/console.h>
#include <system/math.h>
using namespace Aspose::Slides;
using namespace System;
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto connector = slide->get_Shapes()->AddConnector(ShapeType::StraightConnector1, 100, 100, 200, 100);
auto frame = connector->get_Frame();
bool flipH = frame->get_FlipH() == NullableBool::True;
bool flipV = frame->get_FlipV() == NullableBool::True;
float deltaX = connector->get_Width() * (flipH ? -1 : 1);
float deltaY = connector->get_Height() * (flipV ? -1 : 1);
double angle = Math::Atan2(deltaY, deltaX) * 180.0 / Math::PI;
if (angle < 0)
{
angle += 360;
}
Console::WriteLine(u"Connector direction: {0:F2} degrees", angle);
FAQ
How can I tell whether a connector can attach to a shape?
Check the shape’s IShape::get_ConnectionSiteCount value. A positive count means the shape exposes connection sites. Validate the selected site index before assigning it to either connector end.
Can I identify a connector adjustment by its collection index?
An index is meaningful only for a known connector preset and collection layout. Check IAdjustValue::get_Type before modifying a value, and use IAdjustValue::get_Name as additional information when the same semantic type occurs more than once.
What happens when a connected shape is deleted?
The corresponding connector end becomes detached. The connector remains on the slide and can be deleted, positioned as a free line, or attached to another shape.
Are connector bindings preserved when a slide is copied?
Bindings are generally preserved when the connected shapes are copied with the slide. If a connector is copied without one of its target shapes, the affected end must be attached again.









