Skip to content

Commit

Permalink
Merge pull request #591 from BiDuang/master
Browse files Browse the repository at this point in the history
Add `IPath` interface to store `XPath` infomation
  • Loading branch information
ashahabov committed Nov 10, 2023
2 parents 05fa8d5 + f9d3a90 commit f528377
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/ShapeCrawler/Extensions/CompositeElementExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ internal static P.ApplicationNonVisualDrawingProperties GetPNvPr(this OpenXmlCom
_ => throw new SCException()
};
}

internal static string GetXPath(this OpenXmlCompositeElement compositeElement) => new XmlPath(compositeElement).XPath;
}
13 changes: 13 additions & 0 deletions src/ShapeCrawler/Shapes/IPath.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// ReSharper disable CheckNamespace
namespace ShapeCrawler;

/// <summary>
/// Represents path information of the shape.
/// </summary>
public interface IPath
{
/// <summary>
/// Gets the shape's XPath in the slide.
/// </summary>
public string SDKXPath { get; }
}
2 changes: 1 addition & 1 deletion src/ShapeCrawler/Shapes/IShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ShapeCrawler;
/// <summary>
/// Represents a shape on a slide.
/// </summary>
public interface IShape
public interface IShape : IPath
{
/// <summary>
/// Gets or sets x-coordinate of the upper-left corner of the shape.
Expand Down
2 changes: 2 additions & 0 deletions src/ShapeCrawler/Shapes/SCShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ internal abstract class SCShape : IShape

public string Name => this.PShapeTreeChild.GetNonVisualDrawingProperties().Name!;

public string SDKXPath => this.PShapeTreeChild.GetXPath();

public bool Hidden =>
this.DefineHidden(); // TODO: the Shape is inherited by LayoutShape, hence do we need this property?

Expand Down
5 changes: 4 additions & 1 deletion src/ShapeCrawler/Texts/ITextFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using DocumentFormat.OpenXml;
using ShapeCrawler.Constants;
using ShapeCrawler.Exceptions;
using ShapeCrawler.Extensions;
using ShapeCrawler.Services;
using ShapeCrawler.Shared;
using ShapeCrawler.Texts;
Expand All @@ -17,7 +18,7 @@ namespace ShapeCrawler;
/// <summary>
/// Represents a text frame.
/// </summary>
public interface ITextFrame
public interface ITextFrame : IPath
{
/// <summary>
/// Gets collection of paragraphs.
Expand Down Expand Up @@ -89,6 +90,8 @@ internal sealed class SCTextFrame : ITextFrame
internal event Action? TextChanged;

public IParagraphCollection Paragraphs => this.paragraphs.Value;

public string SDKXPath => this.TextBodyElement.GetXPath();

public string Text
{
Expand Down

0 comments on commit f528377

Please sign in to comment.