mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-15 19:54:52 +08:00
#26 make all operation classes public and test
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
namespace UglyToad.PdfPig.Tests.Graphics.Operations
|
||||
{
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using PdfPig.Graphics.Operations;
|
||||
using Xunit;
|
||||
|
||||
public class GraphicsStateOperationTests
|
||||
{
|
||||
[Fact]
|
||||
public void AllOperationsArePublic()
|
||||
{
|
||||
var assembly = Assembly.GetAssembly(typeof(IGraphicsStateOperation));
|
||||
|
||||
var operationTypes = assembly.GetTypes().Where(x => typeof(IGraphicsStateOperation).IsAssignableFrom(x));
|
||||
|
||||
foreach (var operationType in operationTypes)
|
||||
{
|
||||
Assert.True(operationType.IsPublic, $"{operationType.Name} should be public.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -59,8 +59,11 @@
|
||||
"UglyToad.PdfPig.Graphics.Operations.ClippingPaths.ModifyClippingByEvenOddIntersect",
|
||||
"UglyToad.PdfPig.Graphics.Operations.ClippingPaths.ModifyClippingByNonZeroWindingIntersect",
|
||||
"UglyToad.PdfPig.Graphics.Operations.CloseAndStrokePath",
|
||||
"UglyToad.PdfPig.Graphics.Operations.CloseFillPathEvenOddRuleAndStroke",
|
||||
"UglyToad.PdfPig.Graphics.Operations.CloseFillPathNonZeroWindingAndStroke",
|
||||
"UglyToad.PdfPig.Graphics.Operations.EndPath",
|
||||
"UglyToad.PdfPig.Graphics.Operations.FillPathEvenOddRule",
|
||||
"UglyToad.PdfPig.Graphics.Operations.FillPathEvenOddRuleAndStroke",
|
||||
"UglyToad.PdfPig.Graphics.Operations.FillPathNonZeroWinding",
|
||||
"UglyToad.PdfPig.Graphics.Operations.FillPathNonZeroWindingAndStroke",
|
||||
"UglyToad.PdfPig.Graphics.Operations.FillPathNonZeroWindingCompatibility",
|
||||
@@ -81,7 +84,10 @@
|
||||
"UglyToad.PdfPig.Graphics.Operations.PathConstruction.BeginNewSubpath",
|
||||
"UglyToad.PdfPig.Graphics.Operations.PathConstruction.CloseSubpath",
|
||||
"UglyToad.PdfPig.Graphics.Operations.SetNonStrokeColorDeviceCmyk",
|
||||
"UglyToad.PdfPig.Graphics.Operations.SetNonStrokeColorDeviceGray",
|
||||
"UglyToad.PdfPig.Graphics.Operations.SetNonStrokeColorDeviceRgb",
|
||||
"UglyToad.PdfPig.Graphics.Operations.SetStrokeColorDeviceCmyk",
|
||||
"UglyToad.PdfPig.Graphics.Operations.SetStrokeColorDeviceGray",
|
||||
"UglyToad.PdfPig.Graphics.Operations.SetStrokeColorDeviceRgb",
|
||||
"UglyToad.PdfPig.Graphics.Operations.SpecialGraphicsState.ModifyCurrentTransformationMatrix",
|
||||
"UglyToad.PdfPig.Graphics.Operations.SpecialGraphicsState.Pop",
|
||||
@@ -90,9 +96,13 @@
|
||||
"UglyToad.PdfPig.Graphics.Operations.TextObjects.BeginText",
|
||||
"UglyToad.PdfPig.Graphics.Operations.TextObjects.EndText",
|
||||
"UglyToad.PdfPig.Graphics.Operations.TextPositioning.MoveToNextLine",
|
||||
"UglyToad.PdfPig.Graphics.Operations.TextPositioning.MoveToNextLineWithOffset",
|
||||
"UglyToad.PdfPig.Graphics.Operations.TextPositioning.MoveToNextLineWithOffsetSetLeading",
|
||||
"UglyToad.PdfPig.Graphics.Operations.TextPositioning.SetTextMatrix",
|
||||
"UglyToad.PdfPig.Graphics.Operations.TextShowing.MoveToNextLineShowText",
|
||||
"UglyToad.PdfPig.Graphics.Operations.TextShowing.MoveToNextLineShowTextWithSpacing",
|
||||
"UglyToad.PdfPig.Graphics.Operations.TextShowing.ShowText",
|
||||
"UglyToad.PdfPig.Graphics.Operations.TextShowing.ShowTextsWithPositioning",
|
||||
"UglyToad.PdfPig.Graphics.Operations.TextState.SetCharacterSpacing",
|
||||
"UglyToad.PdfPig.Graphics.Operations.TextState.SetFontAndSize",
|
||||
"UglyToad.PdfPig.Graphics.Operations.TextState.SetHorizontalScaling",
|
||||
@@ -127,7 +137,7 @@
|
||||
"UglyToad.PdfPig.Writer.TokenWriter",
|
||||
"UglyToad.PdfPig.XObjects.XObjectImage"
|
||||
};
|
||||
|
||||
|
||||
foreach (var publicTypeName in publicTypeNames)
|
||||
{
|
||||
Assert.True(expected.Contains(publicTypeName), $"Type should not be public: {publicTypeName}.");
|
||||
|
@@ -6,7 +6,7 @@
|
||||
/// <summary>
|
||||
/// Close, fill, and then stroke the path, using the even-odd rule to determine the region to fill.
|
||||
/// </summary>
|
||||
internal class CloseFillPathEvenOddRuleAndStroke : IGraphicsStateOperation
|
||||
public class CloseFillPathEvenOddRuleAndStroke : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
|
@@ -6,7 +6,7 @@
|
||||
/// <summary>
|
||||
/// Close, fill, and then stroke the path, using the nonzero winding number rule to determine the region to fill.
|
||||
/// </summary>
|
||||
internal class CloseFillPathNonZeroWindingAndStroke : IGraphicsStateOperation
|
||||
public class CloseFillPathNonZeroWindingAndStroke : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
|
@@ -6,7 +6,7 @@
|
||||
/// <summary>
|
||||
/// Fill and then stroke the path, using the even-odd rule to determine the region to fill.
|
||||
/// </summary>
|
||||
internal class FillPathEvenOddRuleAndStroke : IGraphicsStateOperation
|
||||
public class FillPathEvenOddRuleAndStroke : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
|
@@ -6,7 +6,7 @@
|
||||
/// <summary>
|
||||
/// Set the gray level for non-stroking operations.
|
||||
/// </summary>
|
||||
internal class SetNonStrokeColorDeviceGray : IGraphicsStateOperation
|
||||
public class SetNonStrokeColorDeviceGray : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
|
@@ -6,7 +6,7 @@
|
||||
/// <summary>
|
||||
/// Set the stroking color space to DeviceCMYK and set the color to use for stroking operations.
|
||||
/// </summary>
|
||||
internal class SetStrokeColorDeviceCmyk : IGraphicsStateOperation
|
||||
public class SetStrokeColorDeviceCmyk : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
|
@@ -6,7 +6,7 @@
|
||||
/// <summary>
|
||||
/// Set the gray level for stroking operations.
|
||||
/// </summary>
|
||||
internal class SetStrokeColorDeviceGray : IGraphicsStateOperation
|
||||
public class SetStrokeColorDeviceGray : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
|
@@ -13,7 +13,7 @@
|
||||
/// Tm = Tlm = 0 1 0 * Tlm<br />
|
||||
/// tx ty 1
|
||||
/// </remarks>
|
||||
internal class MoveToNextLineWithOffset : IGraphicsStateOperation
|
||||
public class MoveToNextLineWithOffset : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
|
@@ -8,7 +8,7 @@
|
||||
/// Move to the start of the next line, offset from the start of the current line by (tx, ty).
|
||||
/// This operator also sets the leading parameter in the text state.
|
||||
/// </summary>
|
||||
internal class MoveToNextLineWithOffsetSetLeading : IGraphicsStateOperation
|
||||
public class MoveToNextLineWithOffsetSetLeading : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
@@ -18,10 +18,21 @@
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The x value of the offset.
|
||||
/// </summary>
|
||||
public decimal Tx { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The y value of the offset and the inverse of the leading parameter.
|
||||
/// </summary>
|
||||
public decimal Ty { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="MoveToNextLineWithOffsetSetLeading"/>.
|
||||
/// </summary>
|
||||
/// <param name="tx">The x value of the offset.</param>
|
||||
/// <param name="ty">The y value of the offset and the inverse of the leading parameter.</param>
|
||||
public MoveToNextLineWithOffsetSetLeading(decimal tx, decimal ty)
|
||||
{
|
||||
Tx = tx;
|
||||
|
@@ -8,7 +8,7 @@
|
||||
/// <summary>
|
||||
/// Set the text matrix and the text line matrix.
|
||||
/// </summary>
|
||||
internal class SetTextMatrix : IGraphicsStateOperation
|
||||
public class SetTextMatrix : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
@@ -18,8 +18,15 @@
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The values of the text matrix.
|
||||
/// </summary>
|
||||
public decimal[] Value { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="SetTextMatrix"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The values of the text matrix.</param>
|
||||
public SetTextMatrix(decimal[] value)
|
||||
{
|
||||
if (value.Length != 6)
|
||||
|
@@ -4,6 +4,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Tokens;
|
||||
using Writer;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
@@ -12,7 +13,7 @@
|
||||
/// If the element is a string, this operator shows the string.
|
||||
/// If it is a number, the operator adjusts the text position by that amount
|
||||
/// </summary>
|
||||
internal class ShowTextsWithPositioning : IGraphicsStateOperation
|
||||
public class ShowTextsWithPositioning : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
@@ -59,7 +60,20 @@
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
stream.WriteText("[");
|
||||
for (var i = 0; i < Array.Count; i++)
|
||||
{
|
||||
TokenWriter.WriteToken(Array[i], stream);
|
||||
|
||||
if (i < Array.Count - 1)
|
||||
{
|
||||
stream.WriteWhiteSpace();
|
||||
}
|
||||
}
|
||||
stream.WriteText("]");
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user