-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the ability to set the spacing before and after a paragraph
- Loading branch information
Showing
11 changed files
with
428 additions
and
14 deletions.
There are no files selected for viewing
21 changes: 14 additions & 7 deletions
21
src/Word/OfficeFlow.Word.Core/Elements/Paragraphs/ParagraphFormat.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/Word/OfficeFlow.Word.Core/Elements/Paragraphs/Spacing/AtLeastSpacing.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using OfficeFlow.MeasureUnits.Absolute; | ||
using OfficeFlow.Word.Core.Elements.Paragraphs.Spacing.Interfaces; | ||
|
||
namespace OfficeFlow.Word.Core.Elements.Paragraphs.Spacing; | ||
|
||
public sealed class AtLeastSpacing : ILineSpacing, IEquatable<AtLeastSpacing> | ||
{ | ||
public AbsoluteValue<Points> Value { get; } | ||
|
||
internal AtLeastSpacing(AbsoluteValue<Points> value) | ||
=> Value = value; | ||
|
||
public bool Equals(AtLeastSpacing? other) | ||
{ | ||
if (ReferenceEquals(null, other)) | ||
{ | ||
return false; | ||
} | ||
|
||
if (ReferenceEquals(this, other)) | ||
{ | ||
return true; | ||
} | ||
|
||
return Value.Equals(other.Value); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override bool Equals(object? other) | ||
{ | ||
if (ReferenceEquals(null, other)) | ||
{ | ||
return false; | ||
} | ||
|
||
if (ReferenceEquals(this, other)) | ||
{ | ||
return true; | ||
} | ||
|
||
if (other.GetType() != GetType()) | ||
{ | ||
return false; | ||
} | ||
|
||
return Equals((AtLeastSpacing)other); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override int GetHashCode() | ||
=> Value.GetHashCode(); | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Word/OfficeFlow.Word.Core/Elements/Paragraphs/Spacing/AutoSpacing.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using OfficeFlow.Word.Core.Elements.Paragraphs.Spacing.Interfaces; | ||
|
||
namespace OfficeFlow.Word.Core.Elements.Paragraphs.Spacing; | ||
|
||
public sealed class AutoSpacing : IParagraphSpacing, ILineSpacing | ||
{ | ||
internal AutoSpacing() | ||
{ } | ||
} |
53 changes: 53 additions & 0 deletions
53
src/Word/OfficeFlow.Word.Core/Elements/Paragraphs/Spacing/ExactSpacing.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using OfficeFlow.MeasureUnits.Absolute; | ||
using OfficeFlow.Word.Core.Elements.Paragraphs.Spacing.Interfaces; | ||
|
||
namespace OfficeFlow.Word.Core.Elements.Paragraphs.Spacing; | ||
|
||
public sealed class ExactSpacing : IParagraphSpacing, ILineSpacing, IEquatable<ExactSpacing> | ||
{ | ||
public AbsoluteValue<Points> Value { get; } | ||
|
||
internal ExactSpacing(AbsoluteValue<Points> value) | ||
=> Value = value; | ||
|
||
public bool Equals(ExactSpacing? other) | ||
{ | ||
if (ReferenceEquals(null, other)) | ||
{ | ||
return false; | ||
} | ||
|
||
if (ReferenceEquals(this, other)) | ||
{ | ||
return true; | ||
} | ||
|
||
return Value.Equals(other.Value); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override bool Equals(object? other) | ||
{ | ||
if (ReferenceEquals(null, other)) | ||
{ | ||
return false; | ||
} | ||
|
||
if (ReferenceEquals(this, other)) | ||
{ | ||
return true; | ||
} | ||
|
||
if (other.GetType() != GetType()) | ||
{ | ||
return false; | ||
} | ||
|
||
return Equals((ExactSpacing)other); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override int GetHashCode() | ||
=> Value.GetHashCode(); | ||
} |
4 changes: 4 additions & 0 deletions
4
src/Word/OfficeFlow.Word.Core/Elements/Paragraphs/Spacing/Interfaces/ILineSpacing.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace OfficeFlow.Word.Core.Elements.Paragraphs.Spacing.Interfaces; | ||
|
||
public interface ILineSpacing | ||
{ } |
4 changes: 4 additions & 0 deletions
4
src/Word/OfficeFlow.Word.Core/Elements/Paragraphs/Spacing/Interfaces/IParagraphSpacing.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace OfficeFlow.Word.Core.Elements.Paragraphs.Spacing.Interfaces; | ||
|
||
public interface IParagraphSpacing | ||
{ } |
30 changes: 30 additions & 0 deletions
30
src/Word/OfficeFlow.Word.Core/Elements/Paragraphs/Spacing/LineSpacing.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using OfficeFlow.MeasureUnits.Absolute; | ||
using OfficeFlow.Word.Core.Elements.Paragraphs.Spacing.Interfaces; | ||
|
||
namespace OfficeFlow.Word.Core.Elements.Paragraphs.Spacing; | ||
|
||
public static class LineSpacing | ||
{ | ||
public static ILineSpacing Exactly<TUnits>(AbsoluteValue<TUnits> value) | ||
where TUnits : AbsoluteUnits, new() | ||
=> new ExactSpacing( | ||
value.To<Points>()); | ||
|
||
public static ILineSpacing Exactly<TUnits>(double value) | ||
where TUnits : AbsoluteUnits, new() | ||
=> Exactly( | ||
AbsoluteValue<TUnits>.From(value)); | ||
|
||
public static ILineSpacing AtLeast<TUnits>(AbsoluteValue<TUnits> value) | ||
where TUnits : AbsoluteUnits, new() | ||
=> new AtLeastSpacing( | ||
value.To<Points>()); | ||
|
||
public static ILineSpacing AtLeast<TUnits>(double value) | ||
where TUnits : AbsoluteUnits, new() | ||
=> AtLeast( | ||
AbsoluteValue<TUnits>.From(value)); | ||
|
||
public static readonly ILineSpacing Auto | ||
= new AutoSpacing(); | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Word/OfficeFlow.Word.Core/Elements/Paragraphs/Spacing/ParagraphSpacing.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using OfficeFlow.MeasureUnits.Absolute; | ||
using OfficeFlow.Word.Core.Elements.Paragraphs.Spacing.Interfaces; | ||
|
||
namespace OfficeFlow.Word.Core.Elements.Paragraphs.Spacing; | ||
|
||
public static class ParagraphSpacing | ||
{ | ||
public static IParagraphSpacing Exactly<TUnits>(AbsoluteValue<TUnits> value) | ||
where TUnits : AbsoluteUnits, new() | ||
=> new ExactSpacing( | ||
value.To<Points>()); | ||
|
||
public static IParagraphSpacing Exactly<TUnits>(double value) | ||
where TUnits : AbsoluteUnits, new() | ||
=> Exactly( | ||
AbsoluteValue<TUnits>.From(value)); | ||
|
||
public static readonly IParagraphSpacing Auto | ||
= new AutoSpacing(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.