Skip to content

Commit

Permalink
Merge pull request #611 from veraPDF/marked_content
Browse files Browse the repository at this point in the history
Update getTag and getMCID for GFOpMarkedContent
  • Loading branch information
MaximPlusov authored and Git User committed Nov 15, 2023
1 parent 911960b commit 0d9fd1d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,25 @@ public List<? extends Object> getLinkedObjects(String link) {
}
}

public List<CosName> getTag() {
if (this.arguments.size() > 1) {
COSBase name = this.arguments.get(this.arguments.size() - 2);
if (name.getType() == COSObjType.COS_NAME) {
List<CosName> list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS);
list.add(new GFCosName((COSName) name));
return Collections.unmodifiableList(list);
}
public List<CosName> getLinkTag() {
COSName tag = getTag();
if (tag != null) {
List<CosName> list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS);
list.add(new GFCosName(tag));
return Collections.unmodifiableList(list);
}
return Collections.emptyList();
}

public COSName getTag() {
if (this.arguments.size() > 1) {
COSBase name = this.arguments.get(this.arguments.size() - 2);
if (name.getType() == COSObjType.COS_NAME) {
return (COSName) name;
}
}
return null;
}

protected List<CosDict> getPropertiesDict() {
if (this.propertiesDict != null) {
Expand All @@ -122,10 +130,10 @@ public List<CosLang> getLang() {
}

public String getParentsTags() {
List<CosName> tagList = getTag();
COSName tagName = getTag();
String tag = "";
if (tagList.size() != 0) {
tag = tagList.get(0).getinternalRepresentation();
if (tagName != null) {
tag = tagName.getString();
}
String parentsTags = "";
if (markedContent != null) {
Expand Down Expand Up @@ -241,13 +249,7 @@ public COSString getInheritedStringAttribute(ASAtom key) {
if (string != null) {
return string;
}
if (markedContent != null) {
string = markedContent.getInheritedStringAttribute(key);
if (string != null) {
return string;
}
}
return null;
return markedContent != null ? markedContent.getInheritedStringAttribute(key) : null;
}

public COSString getStringAttribute(ASAtom key) {
Expand All @@ -261,13 +263,7 @@ public Long getInheritedMCID() {
if (mcid != null) {
return mcid;
}
if (markedContent != null) {
mcid = markedContent.getInheritedMCID();
if (mcid != null) {
return mcid;
}
}
return null;
return markedContent != null ? markedContent.getInheritedMCID() : null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public List<? extends Object> getLinkedObjects(
String link) {
switch (link) {
case TAG:
return this.getTag();
return this.getLinkTag();
case PROPERTIES:
return this.getPropertiesDict();
case LANG:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public GFOp_BMC(List<COSBase> arguments, GFOpMarkedContent markedContent, String
public List<? extends Object> getLinkedObjects(String link) {
switch (link) {
case TAG:
return this.getTag();
return this.getLinkTag();
case PROPERTIES:
return this.getPropertiesDict();
default:
Expand All @@ -58,16 +58,14 @@ public List<? extends Object> getLinkedObjects(String link) {
}

@Override
public List<CosName> getTag() {
if (!this.arguments.isEmpty()) {
COSBase name = this.arguments.get(this.arguments.size() - 1);
if (name.getType() == COSObjType.COS_NAME) {
List<CosName> list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS);
list.add(new GFCosName((COSName) name));
return Collections.unmodifiableList(list);
}
}
return Collections.emptyList();
}
public COSName getTag() {
if (!this.arguments.isEmpty()) {
COSBase name = this.arguments.get(this.arguments.size() - 1);
if (name.getType() == COSObjType.COS_NAME) {
return (COSName) name;
}
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public List<? extends Object> getLinkedObjects(
String link) {
switch (link) {
case TAG:
return this.getTag();
return this.getLinkTag();
case PROPERTIES:
return this.getPropertiesDict();
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,21 @@ public GFOp_MP(List<COSBase> arguments) {
}

@Override
public List<? extends Object> getLinkedObjects(
String link) {
public List<? extends Object> getLinkedObjects(String link) {
if (TAG.equals(link)) {
return this.getTag();
return this.getLinkTag();
}
return super.getLinkedObjects(link);
}

@Override
public List<CosName> getTag() {
public COSName getTag() {
if (!this.arguments.isEmpty()) {
COSBase name = this.arguments.get(this.arguments.size() - 1);
if (name.getType() == COSObjType.COS_NAME) {
List<CosName> list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS);
list.add(new GFCosName((COSName) name));
return Collections.unmodifiableList(list);
return (COSName) name;
}
}
return Collections.emptyList();
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.verapdf.gf.model.impl.pd.gfse.contents;

import org.verapdf.as.ASAtom;
import org.verapdf.cos.COSName;
import org.verapdf.cos.COSObject;
import org.verapdf.cos.COSString;
import org.verapdf.gf.model.impl.operator.inlineimage.GFOp_EI;
Expand Down Expand Up @@ -140,11 +141,8 @@ public String getExtraContext() {

@Override
public String gettag() {
List<CosName> tag = operator.getTag();
if (tag != null && tag.size() != 0) {
return tag.get(0).getinternalRepresentation();
}
return null;
COSName tag = operator.getTag();
return tag != null ? tag.getString() : null;
}

@Override
Expand Down

0 comments on commit 0d9fd1d

Please sign in to comment.