Skip to content

Commit 0b1557c

Browse files
committed
Creating Group Shapes Connected with Connector
closes #18
1 parent 68b0dd2 commit 0b1557c

File tree

6 files changed

+779
-13
lines changed

6 files changed

+779
-13
lines changed

FileFormat.Words.IElements.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ public Shape()
522522
/// <param name="y">y position of the shape.</param>
523523
/// <param name="width">Width of the shape.</param>
524524
/// <param name="height">Height of the shape.</param>
525+
/// <param name="shapeType">Type of the shape (e.g rectangle, ellipse etc).</param>
525526
public Shape(int x,int y,int width,int height,ShapeType shapeType)
526527
{
527528
X = x;
@@ -532,11 +533,64 @@ public Shape(int x,int y,int width,int height,ShapeType shapeType)
532533
}
533534
}
534535

536+
/// <summary>
537+
/// Represents a grouped shapes element in a Word document.
538+
/// </summary>
539+
public class GroupShape : IElement
540+
{
541+
/// <summary>
542+
/// Gets the unique identifier of the group shape.
543+
/// </summary>
544+
public int ElementId { get; internal set; }
545+
546+
/// <summary>
547+
/// Gets or sets the type of the first shape in the group.
548+
/// </summary>
549+
public Shape Shape1 { get; set; }
550+
551+
/// <summary>
552+
/// Gets or sets the type of the second shape in the group.
553+
/// </summary>
554+
public Shape Shape2 { get; set; }
555+
556+
/// <summary>
557+
/// Initializes a new instance of the <see cref="GroupShape"/> class.
558+
/// </summary>
559+
public GroupShape()
560+
{
561+
Shape1 = new Shape();
562+
Shape2 = new Shape();
563+
}
564+
565+
/// <summary>
566+
/// Initializes a new instance of the <see cref="GroupShape"/> class with specified values.
567+
/// </summary>
568+
/// <param name="shape1">Firs shape in the group.</param>
569+
/// <param name="shape2">Second shape in the group.</param>
570+
public GroupShape(Shape shape1,Shape shape2)
571+
{
572+
Shape1 = shape1;
573+
//Shape1.ElementId = ElementId + 1;
574+
Shape2 = shape2;
575+
//Shape2.ElementId = ElementId + 2;
576+
}
577+
}
578+
535579
/// <summary>
536580
/// Specifies the type of a shape within the word document.
537581
/// </summary>
538582
public enum ShapeType
539583
{
584+
/// <summary>
585+
/// Ellipse or Oval shape.
586+
/// </summary>
587+
Rectangle,
588+
589+
/// <summary>
590+
/// Ellipse or Oval shape.
591+
/// </summary>
592+
Triangle,
593+
540594
/// <summary>
541595
/// Ellipse or Oval shape.
542596
/// </summary>

FileFormat.Words.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,11 @@ public int InsertBefore(IElement newElement, IElement element)
401401
case Shape shape:
402402
shape.ElementId = newElementId;
403403
break;
404+
case GroupShape groupShape:
405+
groupShape.ElementId = newElementId;
406+
groupShape.Shape1.ElementId = newElementId*50 + 1;
407+
groupShape.Shape2.ElementId = newElementId*50 + 2;
408+
break;
404409
}
405410

406411
try
@@ -462,6 +467,11 @@ public int InsertBefore(IElement newElement, int elementId)
462467
case Shape shape:
463468
shape.ElementId = newElementId;
464469
break;
470+
case GroupShape groupShape:
471+
groupShape.ElementId = newElementId;
472+
groupShape.Shape1.ElementId = newElementId*50 + 1;
473+
groupShape.Shape2.ElementId = newElementId*50 + 2;
474+
break;
465475
}
466476

467477
try
@@ -505,6 +515,11 @@ internal int Append(IElement newElement)
505515
case Shape shape:
506516
shape.ElementId = newElementId;
507517
break;
518+
case GroupShape groupShape:
519+
groupShape.ElementId = newElementId;
520+
groupShape.Shape1.ElementId = newElementId*50 + 1;
521+
groupShape.Shape2.ElementId = newElementId*50 + 2;
522+
break;
508523
}
509524

510525
var originalCount = _lstStructure.Count;
@@ -588,6 +603,11 @@ public int InsertAfter(IElement newElement, IElement element)
588603
case Shape shape:
589604
shape.ElementId = newElementId;
590605
break;
606+
case GroupShape groupShape:
607+
groupShape.ElementId = newElementId;
608+
groupShape.Shape1.ElementId = newElementId*50 + 1;
609+
groupShape.Shape2.ElementId = newElementId*50 + 2;
610+
break;
591611
}
592612

593613
try
@@ -648,6 +668,11 @@ public int InsertAfter(IElement newElement, int elementId)
648668
case Shape shape:
649669
shape.ElementId = newElementId;
650670
break;
671+
case GroupShape groupShape:
672+
groupShape.ElementId = newElementId;
673+
groupShape.Shape1.ElementId = newElementId*50 + 1;
674+
groupShape.Shape2.ElementId = newElementId*50 + 2;
675+
break;
651676
}
652677

653678
try
@@ -931,6 +956,10 @@ public class Body
931956
/// </summary>
932957
public List<Shape> Shapes { get; internal set; }
933958
/// <summary>
959+
/// Gets the list of shapes in the body.
960+
/// </summary>
961+
public List<GroupShape> GroupShapes { get; internal set; }
962+
/// <summary>
934963
/// Gets the list of sections in the body.
935964
/// </summary>
936965
public List<Section> Sections { get; internal set; }
@@ -947,6 +976,7 @@ public Body(Document doc)
947976
Tables = new List<Table>();
948977
Images = new List<Image>();
949978
Shapes = new List<Shape>();
979+
GroupShapes = new List<GroupShape>();
950980
Sections = new List<Section>();
951981
foreach (var element in doc.GetElements())
952982
{
@@ -970,6 +1000,11 @@ public Body(Document doc)
9701000
Shapes.Add((Shape)element);
9711001
}
9721002

1003+
if (element is GroupShape)
1004+
{
1005+
GroupShapes.Add((GroupShape)element);
1006+
}
1007+
9731008
if (element is Section section)
9741009
{
9751010
Sections.Add(section);

FileFormat.Words.csproj

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,29 @@
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp3.1</TargetFramework>
5-
<ReleaseVersion>24.6.0</ReleaseVersion>
5+
<AssemblyVersion>24.9.0</AssemblyVersion>
6+
<ReleaseVersion>24.9.0</ReleaseVersion>
67
<SynchReleaseVersion>false</SynchReleaseVersion>
7-
<PackageVersion>24.6.0</PackageVersion>
8+
<PackageVersion>24.9.0</PackageVersion>
89
<Authors>Openize</Authors>
910
<Copyright>(C) Openize Pty Ltd 2024. All Rights Reserved.</Copyright>
1011
<Owners>Openize</Owners>
1112
<Description>Written in native C#, Openize.Words for .NET is a free, open-source SDK designed to easily create, load, and modify Microsoft Word documents with just a few lines of code.</Description>
12-
<PackageId>Openize.Words</PackageId>
13-
<PackageLicenseUrl>https://github.com/openize-words/Openize.Words-for-.NET/blob/main/LICENSE</PackageLicenseUrl>
13+
<PackageId>FileFormat.Words</PackageId>
14+
<PackageLicenseUrl>https://github.com/fileformat-words/FileFormat.Words-for-.NET/blob/main/LICENSE</PackageLicenseUrl>
1415
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1516
<PackageProjectUrl>https://www.openize.com</PackageProjectUrl>
1617
<Summary>A C# library to work with word documents without requiring MS word be installed.</Summary>
1718
<PackageTags>openxml document word-documents word-processing word-processing-file-api word-processing-document-api document-automation word-api word-document-api word-sdk word-document-sdk word-document-library word-processing-sdk word-processing-library open-source-word-sdk</PackageTags>
18-
<Title>Openize.Words for .NET</Title>
19+
<Title>FileFormat.Words for .NET</Title>
1920
<DevelopmentDependency>true</DevelopmentDependency>
2021
<PackOnBuild>true</PackOnBuild>
2122
</PropertyGroup>
2223

24+
<PropertyGroup>
25+
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
26+
</PropertyGroup>
27+
2328
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2429
<DocumentationFile>bin\Debug\netcoreapp3.1\Openize.Words.xml</DocumentationFile>
2530
</PropertyGroup>

0 commit comments

Comments
 (0)