Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TextWithShapeFormat to support fBehindDocument #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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