Skip to content

Commit

Permalink
Merge pull request #629 from veraPDF/tagged_content
Browse files Browse the repository at this point in the history
GFSEGroupedContent refactoring
  • Loading branch information
MaximPlusov authored Dec 27, 2023
2 parents 62f0edb + 516f455 commit 33d23f8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import org.verapdf.cos.COSObject;
import org.verapdf.gf.model.factory.operators.GraphicState;
import org.verapdf.gf.model.impl.operator.markedcontent.GFOpMarkedContent;
import org.verapdf.gf.model.impl.operator.markedcontent.GFOp_BDC;
import org.verapdf.gf.model.impl.operator.markedcontent.GFOp_BMC;
import org.verapdf.gf.model.impl.operator.markedcontent.GFOp_EMC;
Expand Down Expand Up @@ -104,7 +105,8 @@ private List<SEContentItem> getContentItem() {
if (!markedContentStack.empty()) {
markedContentIndex = markedContentStack.pop();
if (markedContentStack.empty()) {
list.add(new GFSEMarkedContent(operators.subList(markedContentIndex, i + 1), parentStructElem,
list.add(new GFSEMarkedContent((GFOpMarkedContent)operators.get(markedContentIndex),
operators.subList(markedContentIndex + 1, i + 1), parentStructElem,
parentsTags, defaultLang, isSignature));
markedContentIndex = i;
unmarkedContentIndex = i + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@

public abstract class GFSEGroupedContent extends GFSEContentItem implements SEGroupedContent {

List<Operator> operators;
protected COSObject parentStructElem;
protected String parentsTags;
protected final List<Operator> operators;
protected final COSObject parentStructElem;
protected final String parentsTags;
protected final boolean isSignature;
protected final String defaultLang;
private final Boolean isTaggedContent;
protected final Boolean isTaggedContent;

public GFSEGroupedContent(String objectType, COSObject parentStructElem, String parentsTags, String defaultLang,
public GFSEGroupedContent(String objectType, List<Operator> operators, COSObject parentStructElem, String parentsTags, String defaultLang,
boolean isSignature) {
super(objectType);
this.operators = operators;
this.parentStructElem = parentStructElem;
this.parentsTags = parentsTags;
this.defaultLang = defaultLang;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,11 @@ public class GFSEMarkedContent extends GFSEGroupedContent implements SEMarkedCon

private final GFOpMarkedContent operator;

public GFSEMarkedContent(List<Operator> operators, COSObject parentStructElem, String parentsTags, String defaultLang,
boolean isSignature) {
super(MARKED_CONTENT_TYPE, parentStructElem, parentsTags, defaultLang, isSignature);
this.operators = operators.subList(1, operators.size() - 1);
this.operator = (GFOpMarkedContent)operators.get(0);
COSObject structElem = operator.getParentStructElem();
if (structElem != null) {
this.parentStructElem = structElem;
}
public GFSEMarkedContent(GFOpMarkedContent operator, List<Operator> operators, COSObject parentStructElem,
String parentsTags, String defaultLang, boolean isSignature) {
super(MARKED_CONTENT_TYPE, operators, getParentStructElement(parentStructElem, operator), parentsTags, defaultLang,
isSignature);
this.operator = operator;
}

@Override
Expand Down Expand Up @@ -97,7 +93,8 @@ private List<SEContentItem> getContentItem() {
if (!markedContentStack.empty()) {
markedContentIndex = markedContentStack.pop();
if (markedContentStack.empty()) {
list.add(new GFSEMarkedContent(operators.subList(markedContentIndex, i + 1),
list.add(new GFSEMarkedContent((GFOpMarkedContent)operators.get(markedContentIndex),
operators.subList(markedContentIndex + 1, i + 1),
parentStructElem, parentsTags, defaultLang, isSignature));
}
}
Expand Down Expand Up @@ -201,4 +198,9 @@ public String getInheritedAlt() {
public Long getMCID() {
return operator.getMCID();
}

private static COSObject getParentStructElement(COSObject parentStructElem, GFOpMarkedContent markedOperator) {
COSObject structElem = markedOperator.getParentStructElem();
return structElem != null ? structElem : parentStructElem;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public class GFSEUnmarkedContent extends GFSEGroupedContent implements SEUnmarke

public GFSEUnmarkedContent(List<Operator> operators, COSObject parentStructElem, String parentsTags,
String defaultLang, boolean isSignature) {
super(UNMARKED_CONTENT_TYPE, parentStructElem, parentsTags, defaultLang, isSignature);
this.operators = operators;
super(UNMARKED_CONTENT_TYPE, operators, parentStructElem, parentsTags, defaultLang, isSignature);
}

@Override
Expand Down

0 comments on commit 33d23f8

Please sign in to comment.