Skip to content

Commit

Permalink
Add TextWithShapeFormat to support fBehindDocument
Browse files Browse the repository at this point in the history
  • Loading branch information
supergibbs committed Oct 7, 2024
1 parent 5fbf6ed commit f6ed8d7
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ public FillFormat FillFormat
}
}

/// <summary>
/// Gets the text in front or behind format of the shape.
/// </summary>
public TextWithShapeFormat TextWithShapeFormat
{
get => Values.TextWithShapeFormat ??= new TextWithShapeFormat(this);
set
{
SetParent(value);
Values.TextWithShapeFormat = value;
}
}

/// <summary>
/// Gets or sets the height of the shape.
/// </summary>
Expand Down Expand Up @@ -234,6 +247,12 @@ internal ShapeValues(DocumentObject owner) : base(owner)
/// </summary>
public FillFormat? FillFormat { get; set; }

/// <summary>
/// Gets or sets the internal nullable implementation value of the enclosing document object property.
/// See enclosing document object class for documentation of this property.
/// </summary>
public TextWithShapeFormat? TextWithShapeFormat { get; set; }

/// <summary>
/// Gets or sets the internal nullable implementation value of the enclosing document object property.
/// See enclosing document object class for documentation of this property.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// MigraDoc - Creating Documents on the Fly
// See the LICENSE file in the solution root for more information.

namespace MigraDoc.DocumentObjectModel.Shapes
{
/// <summary>
/// A TextWithShapeFormat object
/// Defines the background filling of the shape.
/// </summary>
public class TextWithShapeFormat : DocumentObject
{
/// <summary>
/// Initializes a new instance of the FillFormat class.
/// </summary>
public TextWithShapeFormat() { }

/// <summary>
/// Initializes a new instance of the FillFormat class with the specified parent.
/// </summary>
internal TextWithShapeFormat(DocumentObject parent) : base(parent) { }

/// <summary>
/// Creates a deep copy of this object.
/// </summary>
public new TextWithShapeFormat Clone()
=> (TextWithShapeFormat)DeepCopy();

/// <summary>
/// Gets or sets a value indicating whether the text should be in front of the shape.
/// </summary>
public bool? TextInFront { get; set; }

/// <summary>
/// Converts FillFormat into DDL.
/// </summary>
internal override void Serialize(Serializer serializer)
{
int pos = serializer.BeginContent("TextWithShapeFormat");
if (this.TextInFront.HasValue)
serializer.WriteSimpleAttribute("TextInFront", this.TextInFront.Value);

serializer.EndContent();
}

/// <summary>
/// Returns the meta object of this instance.
/// </summary>
internal override Meta Meta => TheMeta;

static readonly Meta TheMeta = new(typeof(TextWithShapeFormat));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void RenderShapeAttributes()
}
RenderLineFormat();
RenderFillFormat();
RenderTextWithShapeFormat();
}

/// <summary>
Expand All @@ -74,6 +75,15 @@ protected void RenderFillFormat()
RenderNameValuePair("fFilled", "0");
}

protected void RenderTextWithShapeFormat()
{
var tf = GetValueAsIntended("TextWithShapeFormat") as TextWithShapeFormat;
if (tf != null && tf.TextInFront.HasValue && tf.TextInFront.Value)
RenderNameValuePair("fBehindDocument", "0");
else
RenderNameValuePair("fBehindDocument", "1");
}

protected Unit GetLineWidth()
{
var lf = GetValueAsIntended("LineFormat") as LineFormat;
Expand Down

0 comments on commit f6ed8d7

Please sign in to comment.