Skip to content

Commit

Permalink
Update GFPDDestination
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed May 3, 2024
1 parent 1aeebb3 commit 9ca7ded
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,8 @@
*/
package org.verapdf.gf.model.impl.pd;

import org.verapdf.as.ASAtom;
import org.verapdf.cos.COSObjType;
import org.verapdf.cos.COSObject;
import org.verapdf.model.pdlayer.PDDestination;
import org.verapdf.pd.PDNameTreeNode;
import org.verapdf.pd.PDNamesDictionary;
import org.verapdf.tools.StaticResources;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
Expand All @@ -40,46 +33,12 @@ public class GFPDDestination extends GFPDObject implements PDDestination {

public static final String DESTINATION_TYPE = "PDDestination";

public GFPDDestination(COSObject destination) {
public GFPDDestination(org.verapdf.pd.PDDestination destination) {
super(destination, DESTINATION_TYPE);
}

@Override
public Boolean getisStructDestination() {
COSObject destination = simpleCOSObject;
if (destination.getType() == COSObjType.COS_STRING) {
PDNamesDictionary namesDictionary = StaticResources.getDocument().getCatalog().getNamesDictionary();
if (namesDictionary == null) {
return false;
}
PDNameTreeNode dests = namesDictionary.getDests();
if (dests != null) {
COSObject dest = dests.getObject(destination.getString());
if (dest == null) {
LOGGER.log(Level.WARNING, "Named destination " + destination.getString() +
" not found in the Dests name tree in the Names dictionary");
return false;
}
destination = dest;
}
} else if (destination.getType() == COSObjType.COS_NAME) {
COSObject dests = StaticResources.getDocument().getCatalog().getDests();
if (dests != null) {
COSObject dest = dests.getKey(destination.getName());
if (dest == null) {
LOGGER.log(Level.WARNING, "Named destination " + destination.getName() +
" not found in the Dests dictionary in the catalog");
return false;
}
destination = dest;
}
}
if (destination.getType() == COSObjType.COS_DICT) {
return destination.knownKey(ASAtom.SD);
}
if (destination.getType() == COSObjType.COS_ARRAY && destination.size() > 0) {
return destination.at(0).knownKey(ASAtom.S);
}
return false;
return ((org.verapdf.pd.PDDestination)simplePDObject).getIsStructDestination();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private List<PDDestination> getOpenActionDestination() {
List<PDDestination> destinations = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS);
COSObject openAction = this.catalog.getKey(ASAtom.OPEN_ACTION);
if (openAction != null && openAction.getType() == COSObjType.COS_ARRAY) {
destinations.add(new GFPDDestination(openAction));
destinations.add(new GFPDDestination(new org.verapdf.pd.PDDestination(openAction)));
}
return Collections.unmodifiableList(destinations);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private List<PDDestination> getDestination() {
COSObject destination = ((PDOutlineItem) simplePDObject).getDestination();
if (!destination.empty() && !simplePDObject.knownKey(ASAtom.A)) {
List<PDDestination> destinations = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS);
destinations.add(new GFPDDestination(destination));
destinations.add(new GFPDDestination(new org.verapdf.pd.PDDestination(destination)));
return Collections.unmodifiableList(destinations);
}
return Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private List<PDDestination> getDestination() {
COSObject destination = ((PDAnnotation) simplePDObject).getDestination();
if (!destination.empty() && !simplePDObject.knownKey(ASAtom.A)) {
List<PDDestination> destinations = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS);
destinations.add(new GFPDDestination(destination));
destinations.add(new GFPDDestination(new org.verapdf.pd.PDDestination(destination)));
return Collections.unmodifiableList(destinations);
}
return Collections.emptyList();
Expand Down

0 comments on commit 9ca7ded

Please sign in to comment.