Skip to content

Commit

Permalink
Merge pull request #280 from BezrukovM/fix-902
Browse files Browse the repository at this point in the history
FIX 902
  • Loading branch information
carlwilson authored Jun 10, 2019
2 parents 976f73f + 230eba4 commit 22a00fb
Showing 1 changed file with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class GFPDDeviceN extends GFPDColorSpace implements PDDeviceN {
public static final String ALTERNATE = "alternate";
public static final String COLORANT_NAMES = "colorantNames";
public static final String COLORANTS = "Colorants";
public static final String PROCESS_COLOR = "processColor";

public static final Set<ASAtom> IGNORED_COLORANTS;

Expand All @@ -69,7 +70,7 @@ private static boolean areColorantsPresent(org.verapdf.pd.colors.PDDeviceN simpl
if (attributes != null && attributes.getType() == COSObjType.COS_DICT) {
COSObject colorantsDict = attributes.getKey(ASAtom.COLORANTS);
List<COSObject> colorantsArray = simplePDObject.getNames();
Set<ASAtom> componentNames = new TreeSet<>();
Set<ASAtom> componentNames = new HashSet<>();
if (colorantsDict != null && colorantsDict.getType() == COSObjType.COS_DICT) {
componentNames.addAll(colorantsDict.getKeySet());
}
Expand Down Expand Up @@ -98,11 +99,11 @@ private static COSArray getProcessComponents(COSObject attributes) {
}

private static boolean areColorantsPresent(Set<ASAtom> colorantDictionaryEntries,
List<COSObject> colorantsArray) {
List<COSObject> colorantsArray) {
for (int i = 0; i < colorantsArray.size(); ++i) {
COSObject object = colorantsArray.get(i);
if (object != null && !isNone(object) && !IGNORED_COLORANTS.contains(object.getName()) &&
!colorantDictionaryEntries.contains(object.getName())) {
!colorantDictionaryEntries.contains(object.getName())) {
return false;
}
}
Expand All @@ -127,11 +128,33 @@ public List<? extends Object> getLinkedObjects(String link) {
return this.getColorantNames();
case COLORANTS:
return this.getColorants();
case PROCESS_COLOR:
return this.getProcessColor();
default:
return super.getLinkedObjects(link);
}
}

private List<PDColorSpace> getProcessColor() {
COSObject attributes = ((org.verapdf.pd.colors.PDDeviceN) this.simplePDObject).getAttributes();
if (isNullOrNotDictionary(attributes)) {
return Collections.emptyList();
}
COSObject processDict = attributes.getKey(ASAtom.PROCESS);
if (isNullOrNotDictionary(processDict)) {
return Collections.emptyList();
}
COSObject cs = processDict.getKey(ASAtom.COLORSPACE);
org.verapdf.pd.colors.PDColorSpace colorSpace = org.verapdf.factory.colors.ColorSpaceFactory
.getColorSpace(cs);

if (colorSpace == null) {
return Collections.emptyList();
}

return Collections.singletonList(ColorSpaceFactory.getColorSpace(colorSpace));
}

private List<PDColorSpace> getAlternate() {
org.verapdf.pd.colors.PDColorSpace alternateColorSpace = ((org.verapdf.pd.colors.PDDeviceN) this.simplePDObject)
.getAlternateSpace();
Expand Down Expand Up @@ -180,4 +203,8 @@ private static List<PDSeparation> getColorants(COSObject colorantsDict) {
}
return Collections.unmodifiableList(list);
}

private boolean isNullOrNotDictionary(COSObject toCheck) {
return toCheck == null || toCheck.getType() != COSObjType.COS_DICT;
}
}

0 comments on commit 22a00fb

Please sign in to comment.