Add more classes to the Public API (#717)

* Made interfaces and classes public

* Made NamedDestinations public and fixed namespace

* Fixed NamedDestinationsProvider namespace

* Expose more internal classes as public

* Update PublicApiScannerTests

* Make setters internal
This commit is contained in:
BobLd
2023-10-22 17:34:47 +01:00
committed by GitHub
parent 96ba82ad4e
commit 7ab3a6a2cd
18 changed files with 97 additions and 39 deletions

View File

@@ -88,6 +88,7 @@
"UglyToad.PdfPig.Content.Page", "UglyToad.PdfPig.Content.Page",
"UglyToad.PdfPig.Content.PageRotationDegrees", "UglyToad.PdfPig.Content.PageRotationDegrees",
"UglyToad.PdfPig.Content.PageSize", "UglyToad.PdfPig.Content.PageSize",
"UglyToad.PdfPig.Content.PageTreeMembers",
"UglyToad.PdfPig.Content.PageTreeNode", "UglyToad.PdfPig.Content.PageTreeNode",
"UglyToad.PdfPig.Content.Word", "UglyToad.PdfPig.Content.Word",
"UglyToad.PdfPig.Content.TextOrientation", "UglyToad.PdfPig.Content.TextOrientation",
@@ -99,6 +100,7 @@
"UglyToad.PdfPig.Filters.DefaultFilterProvider", "UglyToad.PdfPig.Filters.DefaultFilterProvider",
"UglyToad.PdfPig.Filters.IFilter", "UglyToad.PdfPig.Filters.IFilter",
"UglyToad.PdfPig.Filters.IFilterProvider", "UglyToad.PdfPig.Filters.IFilterProvider",
"UglyToad.PdfPig.Filters.ILookupFilterProvider",
"UglyToad.PdfPig.Functions.FunctionTypes", "UglyToad.PdfPig.Functions.FunctionTypes",
"UglyToad.PdfPig.Functions.PdfFunction", "UglyToad.PdfPig.Functions.PdfFunction",
"UglyToad.PdfPig.PdfFonts.CharacterBoundingBox", "UglyToad.PdfPig.PdfFonts.CharacterBoundingBox",
@@ -109,9 +111,11 @@
"UglyToad.PdfPig.PdfFonts.FontStretch", "UglyToad.PdfPig.PdfFonts.FontStretch",
"UglyToad.PdfPig.PdfFonts.IFont", "UglyToad.PdfPig.PdfFonts.IFont",
"UglyToad.PdfPig.Geometry.GeometryExtensions", "UglyToad.PdfPig.Geometry.GeometryExtensions",
"UglyToad.PdfPig.Geometry.UserSpaceUnit",
"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.PdfPath",
"UglyToad.PdfPig.Graphics.Colors.ResourceColorSpace",
"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",
@@ -152,6 +156,7 @@
"UglyToad.PdfPig.Graphics.CurrentFontState", "UglyToad.PdfPig.Graphics.CurrentFontState",
"UglyToad.PdfPig.Graphics.CurrentGraphicsState", "UglyToad.PdfPig.Graphics.CurrentGraphicsState",
"UglyToad.PdfPig.Graphics.IColorSpaceContext", "UglyToad.PdfPig.Graphics.IColorSpaceContext",
"UglyToad.PdfPig.Graphics.InlineImageBuilder",
"UglyToad.PdfPig.Graphics.IOperationContext", "UglyToad.PdfPig.Graphics.IOperationContext",
"UglyToad.PdfPig.Graphics.Operations.ClippingPaths.ModifyClippingByEvenOddIntersect", "UglyToad.PdfPig.Graphics.Operations.ClippingPaths.ModifyClippingByEvenOddIntersect",
"UglyToad.PdfPig.Graphics.Operations.ClippingPaths.ModifyClippingByNonZeroWindingIntersect", "UglyToad.PdfPig.Graphics.Operations.ClippingPaths.ModifyClippingByNonZeroWindingIntersect",
@@ -227,6 +232,7 @@
"UglyToad.PdfPig.Graphics.Operations.TextState.SetWordSpacing", "UglyToad.PdfPig.Graphics.Operations.TextState.SetWordSpacing",
"UglyToad.PdfPig.Graphics.Operations.TextState.Type3SetGlyphWidth", "UglyToad.PdfPig.Graphics.Operations.TextState.Type3SetGlyphWidth",
"UglyToad.PdfPig.Graphics.Operations.TextState.Type3SetGlyphWidthAndBoundingBox", "UglyToad.PdfPig.Graphics.Operations.TextState.Type3SetGlyphWidthAndBoundingBox",
"UglyToad.PdfPig.Graphics.PerformantRectangleTransformer",
"UglyToad.PdfPig.Graphics.TextMatrices", "UglyToad.PdfPig.Graphics.TextMatrices",
"UglyToad.PdfPig.Graphics.XObjectContentRecord", "UglyToad.PdfPig.Graphics.XObjectContentRecord",
"UglyToad.PdfPig.Images.ColorSpaceDetailsByteConverter", "UglyToad.PdfPig.Images.ColorSpaceDetailsByteConverter",
@@ -240,12 +246,15 @@
"UglyToad.PdfPig.Outline.Destinations.ExplicitDestination", "UglyToad.PdfPig.Outline.Destinations.ExplicitDestination",
"UglyToad.PdfPig.Outline.Destinations.ExplicitDestinationCoordinates", "UglyToad.PdfPig.Outline.Destinations.ExplicitDestinationCoordinates",
"UglyToad.PdfPig.Outline.Destinations.ExplicitDestinationType", "UglyToad.PdfPig.Outline.Destinations.ExplicitDestinationType",
"UglyToad.PdfPig.Outline.Destinations.NamedDestinations",
"UglyToad.PdfPig.ParsingOptions", "UglyToad.PdfPig.ParsingOptions",
"UglyToad.PdfPig.Parser.IPageContentParser",
"UglyToad.PdfPig.PdfDocument", "UglyToad.PdfPig.PdfDocument",
"UglyToad.PdfPig.PdfExtensions", "UglyToad.PdfPig.PdfExtensions",
"UglyToad.PdfPig.Rendering.IPageImageRenderer", "UglyToad.PdfPig.Rendering.IPageImageRenderer",
"UglyToad.PdfPig.Rendering.PdfRendererImageFormat", "UglyToad.PdfPig.Rendering.PdfRendererImageFormat",
"UglyToad.PdfPig.Structure", "UglyToad.PdfPig.Structure",
"UglyToad.PdfPig.Tokenization.Scanner.IPdfTokenScanner",
"UglyToad.PdfPig.Util.Adler32Checksum", "UglyToad.PdfPig.Util.Adler32Checksum",
"UglyToad.PdfPig.Util.IWordExtractor", "UglyToad.PdfPig.Util.IWordExtractor",
"UglyToad.PdfPig.Util.DefaultWordExtractor", "UglyToad.PdfPig.Util.DefaultWordExtractor",

View File

@@ -1,7 +1,7 @@
namespace UglyToad.PdfPig.Content namespace UglyToad.PdfPig.Content
{ {
using System; using System;
using Outline; using Outline.Destinations;
using Tokens; using Tokens;
using Util.JetBrains.Annotations; using Util.JetBrains.Annotations;
@@ -9,7 +9,7 @@
/// The root of the document's object hierarchy. Contains references to objects defining the contents, /// The root of the document's object hierarchy. Contains references to objects defining the contents,
/// outline, named destinations and more. /// outline, named destinations and more.
/// </summary> /// </summary>
public class Catalog public sealed class Catalog
{ {
/// <summary> /// <summary>
/// The catalog dictionary containing assorted information. /// The catalog dictionary containing assorted information.

View File

@@ -1,6 +1,6 @@
namespace UglyToad.PdfPig.Content namespace UglyToad.PdfPig.Content
{ {
using Outline; using Outline.Destinations;
using Tokens; using Tokens;
internal interface IPageFactory internal interface IPageFactory

View File

@@ -6,17 +6,26 @@
/// <summary> /// <summary>
/// Contains the values inherited from the Page Tree for this page. /// Contains the values inherited from the Page Tree for this page.
/// </summary> /// </summary>
internal class PageTreeMembers public sealed class PageTreeMembers
{ {
public CropBox GetCropBox() internal CropBox GetCropBox()
{ {
return null; return null;
} }
public MediaBox MediaBox { get; set; } /// <summary>
/// The page media box.
/// </summary>
public MediaBox MediaBox { get; internal set; }
public int Rotation { get; set; } /// <summary>
/// The page rotation.
/// </summary>
public int Rotation { get; internal set; }
/// <summary>
/// The page parent resources.
/// </summary>
public Queue<DictionaryToken> ParentResources { get; } = new Queue<DictionaryToken>(); public Queue<DictionaryToken> ParentResources { get; } = new Queue<DictionaryToken>();
} }
} }

View File

@@ -1,7 +1,7 @@
namespace UglyToad.PdfPig.Content namespace UglyToad.PdfPig.Content
{ {
using Core; using Core;
using Outline; using Outline.Destinations;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Tokenization.Scanner; using Tokenization.Scanner;

View File

@@ -25,8 +25,14 @@
IReadOnlyList<IFilter> GetAllFilters(); IReadOnlyList<IFilter> GetAllFilters();
} }
internal interface ILookupFilterProvider : IFilterProvider /// <summary>
/// Gets filter implementations (<see cref="IFilter"/>) for decoding PDF data.
/// </summary>
public interface ILookupFilterProvider : IFilterProvider
{ {
/// <summary>
/// Get the filters specified in this dictionary, using the <see cref="IPdfTokenScanner"/>.
/// </summary>
IReadOnlyList<IFilter> GetFilters(DictionaryToken dictionary, IPdfTokenScanner scanner); IReadOnlyList<IFilter> GetFilters(DictionaryToken dictionary, IPdfTokenScanner scanner);
} }
} }

View File

@@ -7,8 +7,11 @@
/// By default user space units correspond to 1/72nd of an inch (a typographic point). /// By default user space units correspond to 1/72nd of an inch (a typographic point).
/// The UserUnit entry in a page dictionary can define the space units as a different multiple of 1/72 (1 point). /// The UserUnit entry in a page dictionary can define the space units as a different multiple of 1/72 (1 point).
/// </summary> /// </summary>
internal readonly struct UserSpaceUnit public readonly struct UserSpaceUnit
{ {
/// <summary>
/// Default user space units with <see cref="PointMultiples"/> set to <c>1</c>.
/// </summary>
public static readonly UserSpaceUnit Default = new UserSpaceUnit(1); public static readonly UserSpaceUnit Default = new UserSpaceUnit(1);
/// <summary> /// <summary>
@@ -19,7 +22,7 @@
/// <summary> /// <summary>
/// Create a new unit specification for a page. /// Create a new unit specification for a page.
/// </summary> /// </summary>
public UserSpaceUnit(int pointMultiples) internal UserSpaceUnit(int pointMultiples)
{ {
if (pointMultiples <= 0) if (pointMultiples <= 0)
{ {
@@ -29,6 +32,7 @@
PointMultiples = pointMultiples; PointMultiples = pointMultiples;
} }
/// <inheritdoc/>
public override string ToString() public override string ToString()
{ {
return PointMultiples.ToString(CultureInfo.InvariantCulture); return PointMultiples.ToString(CultureInfo.InvariantCulture);

View File

@@ -5,18 +5,24 @@
/// <summary> /// <summary>
/// A color space definition from a resource dictionary. /// A color space definition from a resource dictionary.
/// </summary> /// </summary>
internal readonly struct ResourceColorSpace public readonly struct ResourceColorSpace
{ {
/// <summary>
/// The color space name.
/// </summary>
public NameToken Name { get; } public NameToken Name { get; }
/// <summary>
/// The color space data.
/// </summary>
public IToken Data { get; } public IToken Data { get; }
public ResourceColorSpace(NameToken name, IToken data) internal ResourceColorSpace(NameToken name, IToken data)
{ {
Name = name; Name = name;
Data = data; Data = data;
} }
public ResourceColorSpace(NameToken name) : this(name, null) { } internal ResourceColorSpace(NameToken name) : this(name, null) { }
} }
} }

View File

@@ -3,22 +3,29 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Colors;
using Content; using Content;
using Core; using Core;
using Filters; using Filters;
using PdfPig.Core; using PdfPig.Core;
using Tokenization.Scanner; using Tokenization.Scanner;
using Tokens; using Tokens;
using Util;
internal class InlineImageBuilder /// <summary>
/// Inline Image Builder.
/// </summary>
public sealed class InlineImageBuilder
{ {
public IReadOnlyDictionary<NameToken, IToken> Properties { get; set; } /// <summary>
/// Inline image properties.
/// </summary>
public IReadOnlyDictionary<NameToken, IToken> Properties { get; internal set; }
public IReadOnlyList<byte> Bytes { get; set; } /// <summary>
/// Inline image bytes.
/// </summary>
public IReadOnlyList<byte> Bytes { get; internal set; }
public InlineImage CreateInlineImage(TransformationMatrix transformationMatrix, ILookupFilterProvider filterProvider, internal InlineImage CreateInlineImage(TransformationMatrix transformationMatrix, ILookupFilterProvider filterProvider,
IPdfTokenScanner tokenScanner, IPdfTokenScanner tokenScanner,
RenderingIntent defaultRenderingIntent, RenderingIntent defaultRenderingIntent,
IResourceStore resourceStore) IResourceStore resourceStore)

View File

@@ -2,8 +2,14 @@
{ {
using PdfPig.Core; using PdfPig.Core;
internal static class PerformantRectangleTransformer /// <summary>
/// Performant rectangle transformer.
/// </summary>
public static class PerformantRectangleTransformer
{ {
/// <summary>
/// Transform the rectangle using the matrices.
/// </summary>
public static PdfRectangle Transform(TransformationMatrix first, TransformationMatrix second, TransformationMatrix third, PdfRectangle rectangle) public static PdfRectangle Transform(TransformationMatrix first, TransformationMatrix second, TransformationMatrix third, PdfRectangle rectangle)
{ {
var tl = rectangle.TopLeft; var tl = rectangle.TopLeft;

View File

@@ -1,15 +1,14 @@
namespace UglyToad.PdfPig.Outline namespace UglyToad.PdfPig.Outline.Destinations
{ {
using Content;
using Destinations;
using Logging;
using System.Collections.Generic; using System.Collections.Generic;
using Content;
using Logging;
using Tokens; using Tokens;
/// <summary> /// <summary>
/// Named destinations in a PDF document /// Named destinations in a PDF document
/// </summary> /// </summary>
internal class NamedDestinations public class NamedDestinations
{ {
/// <summary> /// <summary>
/// Dictionary containing explicit destinations, keyed by name /// Dictionary containing explicit destinations, keyed by name

View File

@@ -1,11 +1,9 @@
namespace UglyToad.PdfPig.Outline namespace UglyToad.PdfPig.Outline.Destinations
{ {
using System.Collections.Generic;
using Content; using Content;
using Destinations;
using Logging; using Logging;
using Parser.Parts; using Parser.Parts;
using System.Collections.Generic;
using System.Diagnostics;
using Tokenization.Scanner; using Tokenization.Scanner;
using Tokens; using Tokens;

View File

@@ -4,7 +4,7 @@
using Content; using Content;
using Core; using Core;
using Logging; using Logging;
using Outline; using Outline.Destinations;
using Parts; using Parts;
using Tokenization.Scanner; using Tokenization.Scanner;
using Tokens; using Tokens;

View File

@@ -5,8 +5,14 @@
using Graphics.Operations; using Graphics.Operations;
using Logging; using Logging;
internal interface IPageContentParser /// <summary>
/// Page content parser interface.
/// </summary>
public interface IPageContentParser
{ {
/// <summary>
/// Parse the <see cref="IInputBytes"/> into <see cref="IGraphicsStateOperation"/>s.
/// </summary>
IReadOnlyList<IGraphicsStateOperation> Parse(int pageNumber, IInputBytes inputBytes, IReadOnlyList<IGraphicsStateOperation> Parse(int pageNumber, IInputBytes inputBytes,
ILog log); ILog log);
} }

View File

@@ -11,6 +11,7 @@
using Graphics.Operations; using Graphics.Operations;
using Logging; using Logging;
using Outline; using Outline;
using Outline.Destinations;
using Parts; using Parts;
using Tokenization.Scanner; using Tokenization.Scanner;
using Tokens; using Tokens;

View File

@@ -14,6 +14,7 @@
using Tokenization.Scanner; using Tokenization.Scanner;
using Tokens; using Tokens;
using Outline; using Outline;
using Outline.Destinations;
using Util.JetBrains.Annotations; using Util.JetBrains.Annotations;
/// <inheritdoc /> /// <inheritdoc />

View File

@@ -15,7 +15,7 @@
/// <summary> /// <summary>
/// Try and get the entry with a given name and type or look-up the object if it's an indirect reference. /// Try and get the entry with a given name and type or look-up the object if it's an indirect reference.
/// </summary> /// </summary>
internal static bool TryGet<T>(this DictionaryToken dictionary, NameToken name, IPdfTokenScanner tokenScanner, out T token) where T : IToken public static bool TryGet<T>(this DictionaryToken dictionary, NameToken name, IPdfTokenScanner tokenScanner, out T token) where T : IToken
{ {
token = default(T); token = default(T);
if (!dictionary.TryGet(name, out var t) || !(t is T typedToken)) if (!dictionary.TryGet(name, out var t) || !(t is T typedToken))
@@ -32,7 +32,10 @@
return true; return true;
} }
internal static T Get<T>(this DictionaryToken dictionary, NameToken name, IPdfTokenScanner scanner) where T : class, IToken /// <summary>
/// Get the entry with a given name and type or look-up the object if it's an indirect reference.
/// </summary>
public static T Get<T>(this DictionaryToken dictionary, NameToken name, IPdfTokenScanner scanner) where T : class, IToken
{ {
if (!dictionary.TryGet(name, out var token) || !(token is T typedToken)) if (!dictionary.TryGet(name, out var token) || !(token is T typedToken))
{ {
@@ -63,7 +66,10 @@
return transform; return transform;
} }
internal static IReadOnlyList<byte> Decode(this StreamToken stream, ILookupFilterProvider filterProvider, IPdfTokenScanner scanner) /// <summary>
/// Get the decoded data from this stream.
/// </summary>
public static IReadOnlyList<byte> Decode(this StreamToken stream, ILookupFilterProvider filterProvider, IPdfTokenScanner scanner)
{ {
var filters = filterProvider.GetFilters(stream.StreamDictionary, scanner); var filters = filterProvider.GetFilters(stream.StreamDictionary, scanner);

View File

@@ -7,7 +7,7 @@
/// <summary> /// <summary>
/// Tokenizes objects from bytes in a PDF file. /// Tokenizes objects from bytes in a PDF file.
/// </summary> /// </summary>
internal interface IPdfTokenScanner : ISeekableTokenScanner, IDisposable public interface IPdfTokenScanner : ISeekableTokenScanner, IDisposable
{ {
/// <summary> /// <summary>
/// Tokenize the object with a given object number. /// Tokenize the object with a given object number.