Skip to content

Commit

Permalink
Merge pull request #625 from veraPDF/embedded_file_specification
Browse files Browse the repository at this point in the history
Add getpresentInEmbeddedFiles to GFCosFileSpecification
  • Loading branch information
MaximPlusov authored Dec 20, 2023
2 parents ec791e2 + 6a415aa commit efd2438
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ private void getNamesEmbeddedFiles(List<CosFileSpecification> files, PDNameTreeN
Map<String, COSObject> names = node.getNames();
for (COSObject value : names.values()) {
if (value != null && value.getType().isDictionaryBased()) {
files.add(new GFCosFileSpecification((COSDictionary) value.getDirectBase()));
files.add(new GFCosFileSpecification((COSDictionary) value.getDirectBase(), true));
}
}
for (PDNameTreeNode kid : node.getKids()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,21 @@ public class GFCosFileSpecification extends GFCosDict implements CosFileSpecific
private final String f;
private final String uf;
private final String afrelationship;

private final boolean presentInEmbeddedFiles;

/**
* Default constructor
*
* @param dictionary
* greenfield COSDictionary
*/
public GFCosFileSpecification(COSDictionary dictionary) {
public GFCosFileSpecification(COSDictionary dictionary, boolean presentInEmbeddedFiles) {
super(dictionary, COS_FILE_SPECIFICATION_TYPE);
this.f = this.baseObject.getStringKey(ASAtom.F);
this.uf = this.baseObject.getStringKey(ASAtom.UF);
this.afrelationship = dictionary.getNameKeyStringValue(ASAtom.AF_RELATIONSHIP);
this.presentInEmbeddedFiles = presentInEmbeddedFiles;
}

@Override
Expand All @@ -83,6 +86,11 @@ public Boolean getisAssociatedFile() {
&& StaticContainers.getFileSpecificationKeys().contains(this.baseObject.getObjectKey());
}

@Override
public Boolean getpresentInEmbeddedFiles() {
return this.presentInEmbeddedFiles;
}

@Override
public Boolean getcontainsEF() {
return baseObject != null && this.baseObject.knownKey(ASAtom.EF);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Object visitFromBoolean(COSBoolean obj) {
public Object visitFromDictionary(COSDictionary obj) {
ASAtom type = obj.getNameKey(ASAtom.TYPE);
boolean isFileSpec = ASAtom.FILESPEC.equals(type);
return isFileSpec ? new GFCosFileSpecification(obj) : new GFCosDict(obj);
return isFileSpec ? new GFCosFileSpecification(obj, false) : new GFCosDict(obj);
}

/** {@inheritDoc} Create a GFCosDocument for corresponding COSDocument.
Expand Down

0 comments on commit efd2438

Please sign in to comment.