mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-14 02:44:58 +08:00
make Clipping internal
do not throw errors when CurrentPath is null modify tests to match
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
using UglyToad.PdfPig.Core;
|
using UglyToad.PdfPig.Core;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
public class PdfPathTests
|
public class PdfSubpathTests
|
||||||
{
|
{
|
||||||
private static readonly DoubleComparer DoubleComparer = new DoubleComparer(3);
|
private static readonly DoubleComparer DoubleComparer = new DoubleComparer(3);
|
||||||
private static readonly DoubleComparer PreciseDoubleComparer = new DoubleComparer(6);
|
private static readonly DoubleComparer PreciseDoubleComparer = new DoubleComparer(6);
|
||||||
@@ -373,8 +373,11 @@
|
|||||||
public void IsCounterClockwise(double[][] source, bool expected)
|
public void IsCounterClockwise(double[][] source, bool expected)
|
||||||
{
|
{
|
||||||
PdfSubpath pdfPath = new PdfSubpath();
|
PdfSubpath pdfPath = new PdfSubpath();
|
||||||
foreach (var point in source)
|
pdfPath.MoveTo(source[0][0], source[0][1]);
|
||||||
|
|
||||||
|
for (int i = 1; i < source.Length; i++)
|
||||||
{
|
{
|
||||||
|
var point = source[i];
|
||||||
pdfPath.LineTo(point[0], point[1]);
|
pdfPath.LineTo(point[0], point[1]);
|
||||||
}
|
}
|
||||||
pdfPath.LineTo(source[0][0], source[0][1]); // close path
|
pdfPath.LineTo(source[0][0], source[0][1]); // close path
|
@@ -63,7 +63,7 @@
|
|||||||
foreach (var charString in result.CharStrings.CharStrings)
|
foreach (var charString in result.CharStrings.CharStrings)
|
||||||
{
|
{
|
||||||
Assert.True(result.CharStrings.TryGenerate(charString.Key, out var path));
|
Assert.True(result.CharStrings.TryGenerate(charString.Key, out var path));
|
||||||
builder.AppendLine(path.ToFullSvg(double.NaN)); // TODO
|
builder.AppendLine(path.ToFullSvg(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.Append("</body></html>");
|
builder.Append("</body></html>");
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
using Xunit;
|
using Xunit;
|
||||||
using static UglyToad.PdfPig.Core.PdfSubpath;
|
using static UglyToad.PdfPig.Core.PdfSubpath;
|
||||||
|
|
||||||
public class PdfPathLineTests
|
public class PdfSubpathLineTests
|
||||||
{
|
{
|
||||||
private static readonly DoubleComparer DoubleComparer = new DoubleComparer(3);
|
private static readonly DoubleComparer DoubleComparer = new DoubleComparer(3);
|
||||||
private static readonly DoubleComparer PreciseDoubleComparer = new DoubleComparer(6);
|
private static readonly DoubleComparer PreciseDoubleComparer = new DoubleComparer(6);
|
@@ -92,6 +92,7 @@
|
|||||||
"UglyToad.PdfPig.Geometry.GeometryExtensions",
|
"UglyToad.PdfPig.Geometry.GeometryExtensions",
|
||||||
"UglyToad.PdfPig.Graphics.Colors.CMYKColor",
|
"UglyToad.PdfPig.Graphics.Colors.CMYKColor",
|
||||||
"UglyToad.PdfPig.Graphics.Colors.ColorSpace",
|
"UglyToad.PdfPig.Graphics.Colors.ColorSpace",
|
||||||
|
"UglyToad.PdfPig.Graphics.PdfPath",
|
||||||
"UglyToad.PdfPig.Graphics.Colors.ColorSpaceExtensions",
|
"UglyToad.PdfPig.Graphics.Colors.ColorSpaceExtensions",
|
||||||
"UglyToad.PdfPig.Graphics.Colors.ColorSpaceFamily",
|
"UglyToad.PdfPig.Graphics.Colors.ColorSpaceFamily",
|
||||||
"UglyToad.PdfPig.Graphics.Colors.GrayColor",
|
"UglyToad.PdfPig.Graphics.Colors.GrayColor",
|
||||||
@@ -110,15 +111,16 @@
|
|||||||
"UglyToad.PdfPig.Graphics.Operations.ClippingPaths.ModifyClippingByNonZeroWindingIntersect",
|
"UglyToad.PdfPig.Graphics.Operations.ClippingPaths.ModifyClippingByNonZeroWindingIntersect",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.Compatibility.BeginCompatibilitySection",
|
"UglyToad.PdfPig.Graphics.Operations.Compatibility.BeginCompatibilitySection",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.Compatibility.EndCompatibilitySection",
|
"UglyToad.PdfPig.Graphics.Operations.Compatibility.EndCompatibilitySection",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.CloseAndStrokePath",
|
"UglyToad.PdfPig.Graphics.Operations.PathPainting.CloseAndStrokePath",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.CloseFillPathEvenOddRuleAndStroke",
|
"UglyToad.PdfPig.Graphics.Operations.PathPainting.CloseFillPathEvenOddRuleAndStroke",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.CloseFillPathNonZeroWindingAndStroke",
|
"UglyToad.PdfPig.Graphics.Operations.PathPainting.CloseFillPathNonZeroWindingAndStroke",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.EndPath",
|
"UglyToad.PdfPig.Graphics.Operations.PathPainting.EndPath",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.FillPathEvenOddRule",
|
"UglyToad.PdfPig.Graphics.Operations.PathPainting.FillPathEvenOddRule",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.FillPathEvenOddRuleAndStroke",
|
"UglyToad.PdfPig.Graphics.Operations.PathPainting.FillPathEvenOddRuleAndStroke",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.FillPathNonZeroWinding",
|
"UglyToad.PdfPig.Graphics.Operations.PathPainting.FillPathNonZeroWinding",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.FillPathNonZeroWindingAndStroke",
|
"UglyToad.PdfPig.Graphics.Operations.PathPainting.FillPathNonZeroWindingAndStroke",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.FillPathNonZeroWindingCompatibility",
|
"UglyToad.PdfPig.Graphics.Operations.PathPainting.FillPathNonZeroWindingCompatibility",
|
||||||
|
"UglyToad.PdfPig.Graphics.Operations.PathPainting.StrokePath",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.General.SetColorRenderingIntent",
|
"UglyToad.PdfPig.Graphics.Operations.General.SetColorRenderingIntent",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.General.SetFlatnessTolerance",
|
"UglyToad.PdfPig.Graphics.Operations.General.SetFlatnessTolerance",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.General.SetLineCap",
|
"UglyToad.PdfPig.Graphics.Operations.General.SetLineCap",
|
||||||
@@ -160,7 +162,6 @@
|
|||||||
"UglyToad.PdfPig.Graphics.Operations.SpecialGraphicsState.Pop",
|
"UglyToad.PdfPig.Graphics.Operations.SpecialGraphicsState.Pop",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.SpecialGraphicsState.Push",
|
"UglyToad.PdfPig.Graphics.Operations.SpecialGraphicsState.Push",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.SpecialGraphicsState.SetGraphicsStateParametersFromDictionary",
|
"UglyToad.PdfPig.Graphics.Operations.SpecialGraphicsState.SetGraphicsStateParametersFromDictionary",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.StrokePath",
|
|
||||||
"UglyToad.PdfPig.Graphics.Operations.TextObjects.BeginText",
|
"UglyToad.PdfPig.Graphics.Operations.TextObjects.BeginText",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.TextObjects.EndText",
|
"UglyToad.PdfPig.Graphics.Operations.TextObjects.EndText",
|
||||||
"UglyToad.PdfPig.Graphics.Operations.TextPositioning.MoveToNextLine",
|
"UglyToad.PdfPig.Graphics.Operations.TextPositioning.MoveToNextLine",
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Clipping
|
internal static class Clipping
|
||||||
{
|
{
|
||||||
const double factor = 10_000.0;
|
const double factor = 10_000.0;
|
||||||
|
|
||||||
|
@@ -451,8 +451,7 @@
|
|||||||
{
|
{
|
||||||
if (CurrentPath == null)
|
if (CurrentPath == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("StrokePath(null)");
|
return;
|
||||||
//return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentPath.SetStroked();
|
CurrentPath.SetStroked();
|
||||||
@@ -469,8 +468,7 @@
|
|||||||
{
|
{
|
||||||
if (CurrentPath == null)
|
if (CurrentPath == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("FillPath(null)");
|
return;
|
||||||
//return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentPath.SetFilled(fillingRule);
|
CurrentPath.SetFilled(fillingRule);
|
||||||
@@ -487,8 +485,7 @@
|
|||||||
{
|
{
|
||||||
if (CurrentPath == null)
|
if (CurrentPath == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("FillStrokePath(null)");
|
return;
|
||||||
//return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentPath.SetFilled(fillingRule);
|
CurrentPath.SetFilled(fillingRule);
|
||||||
@@ -514,7 +511,7 @@
|
|||||||
{
|
{
|
||||||
if (!clipPaths)
|
if (!clipPaths)
|
||||||
{
|
{
|
||||||
// if we don't clip paths, add clipping paths
|
// if we don't clip paths, add clipping path to paths
|
||||||
paths.Add(CurrentPath);
|
paths.Add(CurrentPath);
|
||||||
markedContentStack.AddPath(CurrentPath);
|
markedContentStack.AddPath(CurrentPath);
|
||||||
}
|
}
|
||||||
@@ -573,24 +570,26 @@
|
|||||||
{
|
{
|
||||||
if (CurrentPath == null)
|
if (CurrentPath == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("ModifyClippingIntersect(null)");
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddCurrentSubpath();
|
AddCurrentSubpath();
|
||||||
|
|
||||||
CurrentPath.SetClipping(clippingRule);
|
CurrentPath.SetClipping(clippingRule);
|
||||||
var currentClipping = GetCurrentState().CurrentClippingPath;
|
|
||||||
currentClipping.SetClipping(clippingRule);
|
|
||||||
|
|
||||||
var newClippings = CurrentPath.Clip(currentClipping);
|
if (clipPaths)
|
||||||
if (newClippings == null)
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("ContentStreamProcessor.ModifyClippingIntersect(): Warning, empty clipping path found... Clipping path not updated.");
|
var currentClipping = GetCurrentState().CurrentClippingPath;
|
||||||
log.Warn("ModifyClippingIntersect(): Warning, empty clipping path found... Clipping path not updated.");
|
currentClipping.SetClipping(clippingRule);
|
||||||
}
|
|
||||||
else
|
var newClippings = CurrentPath.Clip(currentClipping);
|
||||||
{
|
if (newClippings == null)
|
||||||
GetCurrentState().CurrentClippingPath = newClippings;
|
{
|
||||||
|
log.Warn("Empty clipping path found. Clipping path not updated.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetCurrentState().CurrentClippingPath = newClippings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user