From d668c4e892af10cd5929f68574e4e4e260623d8d Mon Sep 17 00:00:00 2001 From: Eliot Jones Date: Sun, 31 Dec 2017 14:23:36 +0000 Subject: [PATCH] make everything internal which does not need to be public --- src/UglyToad.Pdf/Content/Catalog.cs | 2 +- src/UglyToad.Pdf/Content/Pages.cs | 2 +- .../ContentStream/PdfDictionary.cs | 2 +- .../DictionaryValueAccessorExtensions.cs | 3 +- .../DictionaryValueSetterExtensions.cs | 2 +- src/UglyToad.Pdf/Cos/COSDocument.cs | 440 ------------------ src/UglyToad.Pdf/Cos/CosArray.cs | 3 +- src/UglyToad.Pdf/Cos/CosBase.cs | 10 +- src/UglyToad.Pdf/Cos/CosBoolean.cs | 2 +- src/UglyToad.Pdf/Cos/CosDictionary.cs | 63 ++- src/UglyToad.Pdf/Cos/CosFloat.cs | 2 +- src/UglyToad.Pdf/Cos/CosInt.cs | 2 +- src/UglyToad.Pdf/Cos/CosName.cs | 2 +- src/UglyToad.Pdf/Cos/CosNull.cs | 2 +- src/UglyToad.Pdf/Cos/CosObject.cs | 2 +- src/UglyToad.Pdf/Cos/CosObjectKey.cs | 2 +- src/UglyToad.Pdf/Cos/CosString.cs | 15 +- src/UglyToad.Pdf/Cos/CrossReferenceTable.cs | 2 +- .../Cos/CrossReferenceTablePart.cs | 2 +- src/UglyToad.Pdf/Cos/ICosVisitor.cs | 13 +- src/UglyToad.Pdf/Filters/Ascii85Filter.cs | 2 +- src/UglyToad.Pdf/Filters/FlateFilter.cs | 2 +- .../Filters/IDecodeParameterResolver.cs | 2 +- src/UglyToad.Pdf/Filters/IFilter.cs | 2 +- .../Parser/Handlers/TrueTypeFontHandler.cs | 6 + .../Parser/Parts/BruteForceSearcher.cs | 2 +- .../Parser/XrefTrailerResolver.cs | 10 +- .../Tokenization/Tokens/DictionaryToken.cs | 2 +- .../Tokenization/Tokens/NameToken.cs | 2 +- src/UglyToad.Pdf/Util/DateConverter.cs | 23 +- 30 files changed, 85 insertions(+), 541 deletions(-) delete mode 100644 src/UglyToad.Pdf/Cos/COSDocument.cs create mode 100644 src/UglyToad.Pdf/Fonts/Parser/Handlers/TrueTypeFontHandler.cs diff --git a/src/UglyToad.Pdf/Content/Catalog.cs b/src/UglyToad.Pdf/Content/Catalog.cs index cd207e49..9ee22fb0 100644 --- a/src/UglyToad.Pdf/Content/Catalog.cs +++ b/src/UglyToad.Pdf/Content/Catalog.cs @@ -4,7 +4,7 @@ using ContentStream; using Cos; - public class Catalog + internal class Catalog { private readonly PdfDictionary catalogDictionary; diff --git a/src/UglyToad.Pdf/Content/Pages.cs b/src/UglyToad.Pdf/Content/Pages.cs index 6d71566b..aa24a9ad 100644 --- a/src/UglyToad.Pdf/Content/Pages.cs +++ b/src/UglyToad.Pdf/Content/Pages.cs @@ -10,7 +10,7 @@ using Logging; using Parser; - public class Pages + internal class Pages { private readonly ILog log; private readonly Catalog catalog; diff --git a/src/UglyToad.Pdf/ContentStream/PdfDictionary.cs b/src/UglyToad.Pdf/ContentStream/PdfDictionary.cs index af454906..0d6f7834 100644 --- a/src/UglyToad.Pdf/ContentStream/PdfDictionary.cs +++ b/src/UglyToad.Pdf/ContentStream/PdfDictionary.cs @@ -7,7 +7,7 @@ using Cos; using Util.JetBrains.Annotations; - public class PdfDictionary : CosBase, IReadOnlyDictionary + internal class PdfDictionary : CosBase, IReadOnlyDictionary { private readonly Dictionary inner = new Dictionary(); diff --git a/src/UglyToad.Pdf/ContentStream/TypedAccessors/DictionaryValueAccessorExtensions.cs b/src/UglyToad.Pdf/ContentStream/TypedAccessors/DictionaryValueAccessorExtensions.cs index 4b5a87f5..6073b5df 100644 --- a/src/UglyToad.Pdf/ContentStream/TypedAccessors/DictionaryValueAccessorExtensions.cs +++ b/src/UglyToad.Pdf/ContentStream/TypedAccessors/DictionaryValueAccessorExtensions.cs @@ -2,10 +2,9 @@ { using System.Collections.Generic; using Cos; - using Util; using Util.JetBrains.Annotations; - public static class DictionaryValueAccessorExtensions + internal static class DictionaryValueAccessorExtensions { public static long GetLongOrDefault(this PdfDictionary dictionary, CosName key) { diff --git a/src/UglyToad.Pdf/ContentStream/TypedAccessors/DictionaryValueSetterExtensions.cs b/src/UglyToad.Pdf/ContentStream/TypedAccessors/DictionaryValueSetterExtensions.cs index 36df9e9c..2a3c57ce 100644 --- a/src/UglyToad.Pdf/ContentStream/TypedAccessors/DictionaryValueSetterExtensions.cs +++ b/src/UglyToad.Pdf/ContentStream/TypedAccessors/DictionaryValueSetterExtensions.cs @@ -2,7 +2,7 @@ { using Cos; - public static class DictionaryValueSetterExtensions + internal static class DictionaryValueSetterExtensions { public static void SetLong(this PdfDictionary dictionary, CosName key, long value) { diff --git a/src/UglyToad.Pdf/Cos/COSDocument.cs b/src/UglyToad.Pdf/Cos/COSDocument.cs deleted file mode 100644 index 2d5e525d..00000000 --- a/src/UglyToad.Pdf/Cos/COSDocument.cs +++ /dev/null @@ -1,440 +0,0 @@ -namespace UglyToad.Pdf.Cos -{ - using System; - using System.Collections.Generic; - using System.Linq; - using IO; - using Parser; - using Parser.Parts; - - /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - /** - * This is the in-memory representation of the PDF document. You need to call - * close() on this object when you are done using it!! - * - * @author Ben Litchfield - * - */ - public class COSDocument : CosBase, IDisposable - { - private float version = 1.4f; - - /** - * Maps ObjectKeys to a COSObject. Note that references to these objects - * are also stored in COSDictionary objects that map a name to a specific object. - */ - private readonly Dictionary objectPool = new Dictionary(); - - /** - * Maps object and generation id to object byte offsets. - */ - private readonly Dictionary xrefTable = new Dictionary(); - - /** - * Document trailer dictionary. - */ - public CosDictionary trailer; - - private bool warnMissingClose = true; - - /** - * Signal that document is already decrypted. - */ - - private bool closed = false; - - /** - * This will get the first dictionary object by type. - * - * @param type The type of the object. - * - * @return This will return an object with the specified type. - * @throws IOException If there is an error getting the object - */ - public CosObject getObjectByType(CosName type) - { - foreach (CosObject obj in objectPool.Values) - { - var realObject = obj.GetObject(); - if (realObject is CosDictionary dic) - { - try - { - var typeItem = dic.getItem(CosName.TYPE); - if (typeItem is CosName objectType) - { - if (objectType.Equals(type)) - { - return obj; - } - } - else if (typeItem != null) - { - //LOG.debug("Expected a /Name object after /Type, got '" + typeItem + "' instead"); - } - } - catch (InvalidCastException e) - { - //LOG.warn(e, e); - } - } - } - return null; - } - - /** - * This will get all dictionary objects by type. - * - * @param type The type of the object. - * - * @return This will return an object with the specified type. - * @throws IOException If there is an error getting the object - */ - public List getObjectsByType(String type) - { - return getObjectsByType(CosName.Create(type)); - } - - /** - * This will get a dictionary object by type. - * - * @param type The type of the object. - * - * @return This will return an object with the specified type. - * @throws IOException If there is an error getting the object - */ - public List getObjectsByType(CosName type) - { - var retval = new List(); - foreach (var obj in objectPool.Values) - { - var realObject = obj.GetObject(); - if (realObject is CosDictionary dic) - { - try - { - var typeItem = dic.getItem(CosName.TYPE); - if (typeItem is CosName objectType) - { - if (objectType.Equals(type)) - { - retval.Add(obj); - } - } - else if (typeItem != null) - { - //LOG.debug("Expected a /Name object after /Type, got '" + typeItem + "' instead"); - } - } - catch (InvalidCastException e) - { - //LOG.warn(e, e); - } - } - } - return retval; - } - - /** - * Returns the CosObjectKey for a given COS object, or null if there is none. - * This lookup iterates over all objects in a PDF, which may be slow for large files. - * - * @param object COS object - * @return key - */ - public CosObjectKey getKey(CosBase obj) - { - foreach (var entry in objectPool) - { - if (entry.Value.GetObject() == obj) - { - return entry.Key; - } - } - - return null; - } - - /** - * This will print contents to stdout. - */ - public void print() - { - foreach (CosObject obj in objectPool.Values) - { - Console.WriteLine(obj); - } - } - - public decimal Version { get; set; } - - - public bool IsDecrypted { get; set; } - /** - * This will tell if this is an encrypted document. - * - * @return true If this document is encrypted. - */ - public bool isEncrypted() - { - var encrypted = false; - if (trailer != null) - { - encrypted = trailer.getDictionaryObject(CosName.ENCRYPT) != null; - } - return encrypted; - } - - /** - * This will get the encryption dictionary if the document is encrypted or null - * if the document is not encrypted. - * - * @return The encryption dictionary. - */ - public CosDictionary getEncryptionDictionary() - { - return (CosDictionary)trailer.getDictionaryObject(CosName.ENCRYPT); - } - - /** - * This will set the encryption dictionary, this should only be called when - * encrypting the document. - * - * @param encDictionary The encryption dictionary. - */ - public void setEncryptionDictionary(CosDictionary encDictionary) - { - trailer.setItem(CosName.ENCRYPT, encDictionary); - } - - /** - * This will get the document ID. - * - * @return The document id. - */ - public COSArray getDocumentID() - { - return (COSArray)getTrailer().getDictionaryObject(CosName.ID); - } - - /** - * This will set the document ID. - * - * @param id The document id. - */ - public void setDocumentID(COSArray id) - { - getTrailer().setItem(CosName.ID, id); - } - - /** - * This will get the document catalog. - * - * @return @return The catalog is the root of the document; never null. - * - * @throws IOException If no catalog can be found. - */ - public CosObject getCatalog() - { - CosObject catalog = getObjectByType(CosName.CATALOG); - if (catalog == null) - { - throw new InvalidOperationException("Catalog cannot be found"); - } - return catalog; - } - - /** - * This will get a list of all available objects. - * - * @return A list of all objects, never null. - */ - public List getObjects() - { - return objectPool.Values.ToList(); - } - - /** - * This will get the document trailer. - * - * @return the document trailer dict - */ - public CosDictionary getTrailer() - { - return trailer; - } - - /** - * // MIT added, maybe this should not be supported as trailer is a persistence construct. - * This will set the document trailer. - * - * @param newTrailer the document trailer dictionary - */ - public void setTrailer(CosDictionary newTrailer) - { - trailer = newTrailer; - } - - /** - * visitor pattern double dispatch method. - * - * @param visitor The object to notify when visiting this object. - * @return any object, depending on the visitor implementation, or null - * @throws IOException If an error occurs while visiting this object. - */ - public override object Accept(ICosVisitor visitor) - { - return visitor.VisitFromDocument(this); - } - - /** - * This will close all storage and delete the tmp files. - * - * @throws IOException If there is an error close resources. - */ - public void Dispose() - { - if (!closed) - { - // close all open I/O streams - foreach (CosObject obj in getObjects()) - { - CosBase cosObject = obj.GetObject(); - } - closed = true; - } - } - - /** - * Returns true if this document has been closed. - */ - public bool isClosed() - { - return closed; - } - - /** - * Warn the user in the finalizer if he didn't close the PDF document. The method also - * closes the document just in case, to avoid abandoned temporary files. It's still a good - * idea for the user to close the PDF document at the earliest possible to conserve resources. - * @throws IOException if an error occurs while closing the temporary files - */ - ~COSDocument() - { - if (!closed) - { - if (warnMissingClose) - { - //LOG.warn("Warning: You did not close a PDF Document"); - } - Dispose(); - } - } - - /** - * Controls whether this instance shall issue a warning if the PDF document wasn't closed - * properly through a call to the {@link #close()} method. If the PDF document is held in - * a cache governed by soft references it is impossible to reliably close the document - * before the warning is raised. By default, the warning is enabled. - * @param warn true enables the warning, false disables it. - */ - public void setWarnMissingClose(bool warn) - { - this.warnMissingClose = warn; - } - - /** - * This will get an object from the pool. - * - * @param key The object key. - * - * @return The object in the pool or a new one if it has not been parsed yet. - * - * @throws IOException If there is an error getting the proxy object. - */ - public CosObject getObjectFromPool(CosObjectKey key) - { - if (key != null) - { - if (objectPool.TryGetValue(key, out var value)) - { - return value; - } - } - - // this was a forward reference, make "proxy" object - var obj = new CosObject(null); - if (key != null) - { - obj.SetObjectNumber(key.Number); - obj.SetGenerationNumber((int)key.Generation); - objectPool[key] = obj; - } - - return obj; - } - - /** - * Removes an object from the object pool. - * @param key the object key - * @return the object that was removed or null if the object was not found - */ - public CosObject removeObject(CosObjectKey key) - { - if (!objectPool.TryGetValue(key, out CosObject result)) - { - return null; - } - - objectPool.Remove(key); - - return result; - } - - /** - * Populate XRef HashMap with given values. - * Each entry maps ObjectKeys to byte offsets in the file. - * @param xrefTableValues xref table entries to be added - */ - public void addXRefTable(Dictionary xrefTableValues) - { - foreach (var value in xrefTableValues) - { - xrefTable[value.Key] = value.Value; - } - } - - /** - * Returns the xrefTable which is a mapping of ObjectKeys - * to byte offsets in the file. - * @return mapping of ObjectsKeys to byte offsets - */ - public Dictionary getXrefTable() - { - return xrefTable; - } - - - public long StartXRef { get; set; } - - public bool IsXRefStream { get; set; } - - } - -} diff --git a/src/UglyToad.Pdf/Cos/CosArray.cs b/src/UglyToad.Pdf/Cos/CosArray.cs index 06867b5e..a4a16b34 100644 --- a/src/UglyToad.Pdf/Cos/CosArray.cs +++ b/src/UglyToad.Pdf/Cos/CosArray.cs @@ -25,7 +25,8 @@ namespace UglyToad.Pdf.Cos using System; using System.Collections; using System.Collections.Generic; - public class COSArray : CosBase, IEnumerable, ICosUpdateInfo + + internal class COSArray : CosBase, IEnumerable, ICosUpdateInfo { private readonly List objects = new List(); public bool NeedsToBeUpdated { get; set; } diff --git a/src/UglyToad.Pdf/Cos/CosBase.cs b/src/UglyToad.Pdf/Cos/CosBase.cs index dec15e0e..9b0029a7 100644 --- a/src/UglyToad.Pdf/Cos/CosBase.cs +++ b/src/UglyToad.Pdf/Cos/CosBase.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace UglyToad.Pdf.Cos +namespace UglyToad.Pdf.Cos { - public abstract class CosBase : ICosObject + internal abstract class CosBase : ICosObject { public bool Direct { get; set; } @@ -16,7 +12,7 @@ namespace UglyToad.Pdf.Cos public abstract object Accept(ICosVisitor visitor); } - public interface ICosObject + internal interface ICosObject { CosBase GetCosObject(); } diff --git a/src/UglyToad.Pdf/Cos/CosBoolean.cs b/src/UglyToad.Pdf/Cos/CosBoolean.cs index 0d094481..82aa9c04 100644 --- a/src/UglyToad.Pdf/Cos/CosBoolean.cs +++ b/src/UglyToad.Pdf/Cos/CosBoolean.cs @@ -3,7 +3,7 @@ using System.IO; using Core; - public class CosBoolean : CosBase, ICosStreamWriter + internal class CosBoolean : CosBase, ICosStreamWriter { /** * The true boolean token. diff --git a/src/UglyToad.Pdf/Cos/CosDictionary.cs b/src/UglyToad.Pdf/Cos/CosDictionary.cs index 5b407f3b..9e49b871 100644 --- a/src/UglyToad.Pdf/Cos/CosDictionary.cs +++ b/src/UglyToad.Pdf/Cos/CosDictionary.cs @@ -1,13 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace UglyToad.Pdf.Cos +namespace UglyToad.Pdf.Cos { + using System; + using System.Collections.Generic; + using System.Text; using System.Linq; using Util; - public class CosDictionary : CosBase, ICosUpdateInfo + internal class CosDictionary : CosBase, ICosUpdateInfo { private static readonly string PATH_SEPARATOR = "/"; private bool needToBeUpdated; @@ -63,7 +62,7 @@ namespace UglyToad.Pdf.Cos var contains = items.Values.Any(x => ReferenceEquals(x, value)); if (!contains && value is CosObject) { - contains = items.ContainsValue(((CosObject) value).GetObject()); + contains = items.ContainsValue(((CosObject)value).GetObject()); } return contains; } @@ -80,7 +79,7 @@ namespace UglyToad.Pdf.Cos { Object nextValue = item.Value; if (nextValue.Equals(value) - || nextValue is CosObject && ((CosObject) nextValue).GetObject() + || nextValue is CosObject && ((CosObject)nextValue).GetObject() .Equals(value)) { return item.Key; @@ -176,7 +175,7 @@ namespace UglyToad.Pdf.Cos if (result is CosObject) { - result = ((CosObject) result).GetObject(); + result = ((CosObject)result).GetObject(); } if (result is CosNull) { @@ -239,7 +238,7 @@ namespace UglyToad.Pdf.Cos */ public void setbool(String key, bool value) { - setItem(CosName.Create(key), (CosBoolean) value); + setItem(CosName.Create(key), (CosBoolean)value); } /** @@ -250,7 +249,7 @@ namespace UglyToad.Pdf.Cos */ public void setbool(CosName key, bool value) { - setItem(key, (CosBoolean) value); + setItem(key, (CosBoolean)value); } /** @@ -336,7 +335,7 @@ namespace UglyToad.Pdf.Cos */ public void setEmbeddedDate(String embedded, CosName key, DateTime date) { - CosDictionary dic = (CosDictionary) getDictionaryObject(embedded); + CosDictionary dic = (CosDictionary)getDictionaryObject(embedded); if (dic == null) { dic = new CosDictionary(); @@ -397,7 +396,7 @@ namespace UglyToad.Pdf.Cos */ public void setEmbeddedString(String embedded, CosName key, String value) { - CosDictionary dic = (CosDictionary) getDictionaryObject(embedded); + CosDictionary dic = (CosDictionary)getDictionaryObject(embedded); if (dic == null && value != null) { dic = new CosDictionary(); @@ -475,7 +474,7 @@ namespace UglyToad.Pdf.Cos */ public void setEmbeddedInt(String embeddedDictionary, CosName key, int value) { - CosDictionary embedded = (CosDictionary) getDictionaryObject(embeddedDictionary); + CosDictionary embedded = (CosDictionary)getDictionaryObject(embeddedDictionary); if (embedded == null) { embedded = new CosDictionary(); @@ -540,7 +539,7 @@ namespace UglyToad.Pdf.Cos CosBase name = getDictionaryObject(key); if (name is CosName) { - return (CosName) name; + return (CosName)name; } return null; } @@ -558,7 +557,7 @@ namespace UglyToad.Pdf.Cos CosBase name = getDictionaryObject(key); if (name is CosName) { - return (CosName) name; + return (CosName)name; } return defaultValue; } @@ -588,11 +587,11 @@ namespace UglyToad.Pdf.Cos CosBase name = getDictionaryObject(key); if (name is CosName) { - retval = ((CosName) name).Name; + retval = ((CosName)name).Name; } else if (name is CosString) { - retval = ((CosString) name).GetString(); + retval = ((CosString)name).GetString(); } return retval; } @@ -653,7 +652,7 @@ namespace UglyToad.Pdf.Cos CosBase value = getDictionaryObject(key); if (value is CosString) { - retval = ((CosString) value).GetString(); + retval = ((CosString)value).GetString(); } return retval; } @@ -741,7 +740,7 @@ namespace UglyToad.Pdf.Cos public String getEmbeddedString(String embedded, CosName key, String defaultValue) { String retval = defaultValue; - CosDictionary dic = (CosDictionary) getDictionaryObject(embedded); + CosDictionary dic = (CosDictionary)getDictionaryObject(embedded); if (dic != null) { retval = dic.getString(key, defaultValue); @@ -773,7 +772,7 @@ namespace UglyToad.Pdf.Cos CosBase baseObj = getDictionaryObject(key); if (baseObj is CosString) { - return DateConverter.toCalendar((CosString) baseObj); + return DateConverter.toCalendar((CosString)baseObj); } return null; @@ -870,7 +869,7 @@ namespace UglyToad.Pdf.Cos { var retval = defaultValue; - CosDictionary eDic = (CosDictionary) getDictionaryObject(embedded); + CosDictionary eDic = (CosDictionary)getDictionaryObject(embedded); if (eDic != null) { retval = eDic.getDate(key, defaultValue); @@ -922,7 +921,7 @@ namespace UglyToad.Pdf.Cos CosBase boolValue = getDictionaryObject(firstKey, secondKey); if (boolValue is CosBoolean) { - retval = ((CosBoolean) boolValue).Value; + retval = ((CosBoolean)boolValue).Value; } return retval; @@ -980,7 +979,7 @@ namespace UglyToad.Pdf.Cos public int getEmbeddedInt(String embeddedDictionary, CosName key, int defaultValue) { int retval = defaultValue; - CosDictionary embedded = (CosDictionary) getDictionaryObject(embeddedDictionary); + CosDictionary embedded = (CosDictionary)getDictionaryObject(embeddedDictionary); if (embedded != null) { retval = embedded.getInt(key, defaultValue); @@ -1026,7 +1025,7 @@ namespace UglyToad.Pdf.Cos CosBase obj = getDictionaryObject(keyList); if (obj is ICosNumber) { - retval = ((ICosNumber) obj).AsInt(); + retval = ((ICosNumber)obj).AsInt(); } return retval; } @@ -1161,7 +1160,7 @@ namespace UglyToad.Pdf.Cos CosBase obj = getDictionaryObject(key); if (obj is ICosNumber) { - retval = ((ICosNumber) obj).AsLong(); + retval = ((ICosNumber)obj).AsLong(); } return retval; } @@ -1217,7 +1216,7 @@ namespace UglyToad.Pdf.Cos CosBase obj = getDictionaryObject(key); if (obj is ICosNumber) { - retval = ((ICosNumber) obj).AsFloat(); + retval = ((ICosNumber)obj).AsFloat(); } return retval; } @@ -1382,18 +1381,18 @@ namespace UglyToad.Pdf.Cos */ public CosBase getObjectFromPath(String objPath) { - String[] path = objPath.Split(new string[] {PATH_SEPARATOR}, StringSplitOptions.RemoveEmptyEntries); + String[] path = objPath.Split(new string[] { PATH_SEPARATOR }, StringSplitOptions.RemoveEmptyEntries); CosBase retval = this; foreach (var pathString in path) { if (retval is COSArray) { int idx = int.Parse(pathString.Replace("\\[", "").Replace("\\]", "")); - retval = ((COSArray) retval).getObject(idx); + retval = ((COSArray)retval).getObject(idx); } else if (retval is CosDictionary) { - retval = ((CosDictionary) retval).getDictionaryObject(pathString); + retval = ((CosDictionary)retval).getDictionaryObject(pathString); } } @@ -1408,7 +1407,7 @@ namespace UglyToad.Pdf.Cos public CosDictionary asUnmodifiableDictionary() { throw new NotImplementedException(); - // return new UnmodifiableCosDictionary(this); + // return new UnmodifiableCosDictionary(this); } /** @@ -1418,7 +1417,7 @@ namespace UglyToad.Pdf.Cos { try { - return getDictionaryString(this, new List()); + return getDictionaryString(this, new List()); } catch (Exception e) { diff --git a/src/UglyToad.Pdf/Cos/CosFloat.cs b/src/UglyToad.Pdf/Cos/CosFloat.cs index d22636b7..1ff7547c 100644 --- a/src/UglyToad.Pdf/Cos/CosFloat.cs +++ b/src/UglyToad.Pdf/Cos/CosFloat.cs @@ -7,7 +7,7 @@ using UglyToad.Pdf.Core; namespace UglyToad.Pdf.Cos { - public class CosFloat : CosBase, ICosNumber, ICosStreamWriter + internal class CosFloat : CosBase, ICosNumber, ICosStreamWriter { private readonly decimal value; private readonly string valueAsString; diff --git a/src/UglyToad.Pdf/Cos/CosInt.cs b/src/UglyToad.Pdf/Cos/CosInt.cs index 79a61c5c..a29b4b2c 100644 --- a/src/UglyToad.Pdf/Cos/CosInt.cs +++ b/src/UglyToad.Pdf/Cos/CosInt.cs @@ -4,7 +4,7 @@ using UglyToad.Pdf.Core; namespace UglyToad.Pdf.Cos { - public class CosInt : CosBase, ICosNumber, ICosStreamWriter + internal class CosInt : CosBase, ICosNumber, ICosStreamWriter { /** * The lowest integer to be kept in the {@link #STATIC} array. diff --git a/src/UglyToad.Pdf/Cos/CosName.cs b/src/UglyToad.Pdf/Cos/CosName.cs index 1da1b4bb..d36a3e3e 100644 --- a/src/UglyToad.Pdf/Cos/CosName.cs +++ b/src/UglyToad.Pdf/Cos/CosName.cs @@ -16,7 +16,7 @@ namespace UglyToad.Pdf.Cos * * @author Ben Litchfield */ - public class CosName : CosBase, IComparable, ICosStreamWriter + internal class CosName : CosBase, IComparable, ICosStreamWriter { // using ConcurrentHashMap because this can be accessed by multiple threads private static readonly ConcurrentDictionary NameMap = new ConcurrentDictionary(); diff --git a/src/UglyToad.Pdf/Cos/CosNull.cs b/src/UglyToad.Pdf/Cos/CosNull.cs index 8fadfc7e..3b05cb5c 100644 --- a/src/UglyToad.Pdf/Cos/CosNull.cs +++ b/src/UglyToad.Pdf/Cos/CosNull.cs @@ -5,7 +5,7 @@ namespace UglyToad.Pdf.Cos using System.IO; using Core; - public class CosNull : CosBase, ICosStreamWriter + internal class CosNull : CosBase, ICosStreamWriter { /// /// The Null Token diff --git a/src/UglyToad.Pdf/Cos/CosObject.cs b/src/UglyToad.Pdf/Cos/CosObject.cs index d18ca721..3d4279e1 100644 --- a/src/UglyToad.Pdf/Cos/CosObject.cs +++ b/src/UglyToad.Pdf/Cos/CosObject.cs @@ -2,7 +2,7 @@ { using ContentStream; - public class CosObject : CosBase, ICosUpdateInfo + internal class CosObject : CosBase, ICosUpdateInfo { private CosBase baseObject; private long objectNumber; diff --git a/src/UglyToad.Pdf/Cos/CosObjectKey.cs b/src/UglyToad.Pdf/Cos/CosObjectKey.cs index 26b959fe..e9500cb1 100644 --- a/src/UglyToad.Pdf/Cos/CosObjectKey.cs +++ b/src/UglyToad.Pdf/Cos/CosObjectKey.cs @@ -2,7 +2,7 @@ namespace UglyToad.Pdf.Cos { - public class CosObjectKey : IComparable + internal class CosObjectKey : IComparable { public long Number { get; } public long Generation { get; } diff --git a/src/UglyToad.Pdf/Cos/CosString.cs b/src/UglyToad.Pdf/Cos/CosString.cs index eda9b1fe..5bbf50ae 100644 --- a/src/UglyToad.Pdf/Cos/CosString.cs +++ b/src/UglyToad.Pdf/Cos/CosString.cs @@ -1,13 +1,12 @@ -using System; -using System.Text; -using System.IO; - -namespace UglyToad.Pdf.Cos +namespace UglyToad.Pdf.Cos { + using System; + using System.Text; + using System.IO; using System.Collections.Generic; using Util; - public class CosString : CosBase + internal class CosString : CosBase { public byte[] Bytes { get; } @@ -70,7 +69,7 @@ namespace UglyToad.Pdf.Cos } } } - + private static byte[] CloneBytes(IReadOnlyList bytes) { var result = new byte[bytes.Count]; @@ -181,7 +180,7 @@ namespace UglyToad.Pdf.Cos return ((Bytes != null ? Bytes.GetHashCode() : 0) * 397); } } - + public override object Accept(ICosVisitor visitor) { return visitor.VisitFromString(this); diff --git a/src/UglyToad.Pdf/Cos/CrossReferenceTable.cs b/src/UglyToad.Pdf/Cos/CrossReferenceTable.cs index 051809b0..01a9f44e 100644 --- a/src/UglyToad.Pdf/Cos/CrossReferenceTable.cs +++ b/src/UglyToad.Pdf/Cos/CrossReferenceTable.cs @@ -5,7 +5,7 @@ using ContentStream; using Util.JetBrains.Annotations; - public class CrossReferenceTable + internal class CrossReferenceTable { public CrossReferenceType Type { get; } diff --git a/src/UglyToad.Pdf/Cos/CrossReferenceTablePart.cs b/src/UglyToad.Pdf/Cos/CrossReferenceTablePart.cs index 4ce6c5b3..69148dd6 100644 --- a/src/UglyToad.Pdf/Cos/CrossReferenceTablePart.cs +++ b/src/UglyToad.Pdf/Cos/CrossReferenceTablePart.cs @@ -21,7 +21,7 @@ /// giving the number of bytes from the beginning of the file to the beginning of the /// object. /// - public class CrossReferenceTablePart + internal class CrossReferenceTablePart { public IReadOnlyDictionary ObjectOffsets { get; } diff --git a/src/UglyToad.Pdf/Cos/ICosVisitor.cs b/src/UglyToad.Pdf/Cos/ICosVisitor.cs index f5e536e3..e55ad2e5 100644 --- a/src/UglyToad.Pdf/Cos/ICosVisitor.cs +++ b/src/UglyToad.Pdf/Cos/ICosVisitor.cs @@ -5,7 +5,7 @@ * * @author Michael Traut */ - public interface ICosVisitor + internal interface ICosVisitor { /** * Notification of visit to Array object. @@ -33,16 +33,7 @@ * @throws IOException If there is an error while visiting this object. */ object VisitFromDictionary(CosDictionary obj); - - /** - * Notification of visit to document object. - * - * @param obj The Object that is being visited. - * @return any Object depending on the visitor implementation, or null - * @throws IOException If there is an error while visiting this object. - */ - object VisitFromDocument(COSDocument obj); - + /** * Notification of visit to float object. * diff --git a/src/UglyToad.Pdf/Filters/Ascii85Filter.cs b/src/UglyToad.Pdf/Filters/Ascii85Filter.cs index 088c723e..d640dfd9 100644 --- a/src/UglyToad.Pdf/Filters/Ascii85Filter.cs +++ b/src/UglyToad.Pdf/Filters/Ascii85Filter.cs @@ -7,7 +7,7 @@ /// /// ASCII 85 (Base85) is a binary to text encoding using 5 ASCII characters per 4 bytes of data. /// - public class Ascii85Filter : IFilter + internal class Ascii85Filter : IFilter { private const byte EmptyBlock = (byte)'z'; private const byte Offset = (byte)'!'; diff --git a/src/UglyToad.Pdf/Filters/FlateFilter.cs b/src/UglyToad.Pdf/Filters/FlateFilter.cs index f3f922ea..aafaa703 100644 --- a/src/UglyToad.Pdf/Filters/FlateFilter.cs +++ b/src/UglyToad.Pdf/Filters/FlateFilter.cs @@ -16,7 +16,7 @@ /// See section 3.3.3 of the spec (version 1.7) for details on the FlateDecode filter. /// The flate decode filter may have a predictor function to further compress the stream. /// - public class FlateFilter : IFilter + internal class FlateFilter : IFilter { // Defaults are from table 3.7 in the spec (version 1.7) private const int DefaultColors = 1; diff --git a/src/UglyToad.Pdf/Filters/IDecodeParameterResolver.cs b/src/UglyToad.Pdf/Filters/IDecodeParameterResolver.cs index 377844a1..a2c5b954 100644 --- a/src/UglyToad.Pdf/Filters/IDecodeParameterResolver.cs +++ b/src/UglyToad.Pdf/Filters/IDecodeParameterResolver.cs @@ -2,7 +2,7 @@ { using ContentStream; - public interface IDecodeParameterResolver + internal interface IDecodeParameterResolver { PdfDictionary GetFilterParameters(PdfDictionary streamDictionary, int index); } diff --git a/src/UglyToad.Pdf/Filters/IFilter.cs b/src/UglyToad.Pdf/Filters/IFilter.cs index 0337e80f..1cb7738d 100644 --- a/src/UglyToad.Pdf/Filters/IFilter.cs +++ b/src/UglyToad.Pdf/Filters/IFilter.cs @@ -2,7 +2,7 @@ { using ContentStream; - public interface IFilter + internal interface IFilter { byte[] Decode(byte[] input, PdfDictionary streamDictionary, int filterIndex); } diff --git a/src/UglyToad.Pdf/Fonts/Parser/Handlers/TrueTypeFontHandler.cs b/src/UglyToad.Pdf/Fonts/Parser/Handlers/TrueTypeFontHandler.cs new file mode 100644 index 00000000..ed7d2101 --- /dev/null +++ b/src/UglyToad.Pdf/Fonts/Parser/Handlers/TrueTypeFontHandler.cs @@ -0,0 +1,6 @@ +namespace UglyToad.Pdf.Fonts.Parser.Handlers +{ + internal class TrueTypeFontHandler + { + } +} diff --git a/src/UglyToad.Pdf/Parser/Parts/BruteForceSearcher.cs b/src/UglyToad.Pdf/Parser/Parts/BruteForceSearcher.cs index b9bce64a..8eddb99c 100644 --- a/src/UglyToad.Pdf/Parser/Parts/BruteForceSearcher.cs +++ b/src/UglyToad.Pdf/Parser/Parts/BruteForceSearcher.cs @@ -10,7 +10,7 @@ /// /// Store the results of a brute force search for all Cos Objects in the document so we only do it once. /// - public class BruteForceSearcher + internal class BruteForceSearcher { private const int MinimumSearchOffset = 6; diff --git a/src/UglyToad.Pdf/Parser/XrefTrailerResolver.cs b/src/UglyToad.Pdf/Parser/XrefTrailerResolver.cs index 3afd310a..733e1f3e 100644 --- a/src/UglyToad.Pdf/Parser/XrefTrailerResolver.cs +++ b/src/UglyToad.Pdf/Parser/XrefTrailerResolver.cs @@ -1,14 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace UglyToad.Pdf.Parser +namespace UglyToad.Pdf.Parser { - using System.Collections.ObjectModel; + using System.Collections.Generic; using System.Linq; using Cos; - public class XrefTrailerResolver + internal class XrefTrailerResolver { /** diff --git a/src/UglyToad.Pdf/Tokenization/Tokens/DictionaryToken.cs b/src/UglyToad.Pdf/Tokenization/Tokens/DictionaryToken.cs index f3512cb8..1fd982a0 100644 --- a/src/UglyToad.Pdf/Tokenization/Tokens/DictionaryToken.cs +++ b/src/UglyToad.Pdf/Tokenization/Tokens/DictionaryToken.cs @@ -6,7 +6,7 @@ using Cos; using Util.JetBrains.Annotations; - public class DictionaryToken : IDataToken> + internal class DictionaryToken : IDataToken> { [NotNull] public IReadOnlyDictionary Data { get; } diff --git a/src/UglyToad.Pdf/Tokenization/Tokens/NameToken.cs b/src/UglyToad.Pdf/Tokenization/Tokens/NameToken.cs index 98941d44..a0ae45e8 100644 --- a/src/UglyToad.Pdf/Tokenization/Tokens/NameToken.cs +++ b/src/UglyToad.Pdf/Tokenization/Tokens/NameToken.cs @@ -2,7 +2,7 @@ { using Cos; - public class NameToken : IDataToken + internal class NameToken : IDataToken { public CosName Data { get; } diff --git a/src/UglyToad.Pdf/Util/DateConverter.cs b/src/UglyToad.Pdf/Util/DateConverter.cs index ecf29a33..aea683d9 100644 --- a/src/UglyToad.Pdf/Util/DateConverter.cs +++ b/src/UglyToad.Pdf/Util/DateConverter.cs @@ -1,13 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace UglyToad.Pdf.Util +namespace UglyToad.Pdf.Util { + using System; using System.Globalization; using Cos; - public class DateConverter + internal class DateConverter { private DateConverter() { @@ -231,12 +228,12 @@ namespace UglyToad.Pdf.Util * package-private for testing */ private static string formatTZoffset(long millis, string sep) - { - //{ - // SimpleDateFormat sdf = new SimpleDateFormat("Z"); // #hhmm - // sdf.setTimeZone(new SimpleTimeZone(restrainTZoffset(millis), "unknown")); - // String tz = sdf.format(new Date()); - // return tz.substring(0, 3) + sep + tz.substring(3); + { + //{ + // SimpleDateFormat sdf = new SimpleDateFormat("Z"); // #hhmm + // sdf.setTimeZone(new SimpleTimeZone(restrainTZoffset(millis), "unknown")); + // String tz = sdf.format(new Date()); + // return tz.substring(0, 3) + sep + tz.substring(3); throw new NotImplementedException(); } @@ -627,7 +624,7 @@ namespace UglyToad.Pdf.Util if (whereLen == text.Length) { initialWhere.Index = whereLen; - // return retCal; + // return retCal; } if (whereLen > longestLen) {