Skip to content

Commit

Permalink
WCAG. Fix duplicated mcids processing
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Feb 20, 2024
1 parent 0797788 commit cb0049c
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class ChunkParser {

private final Deque<GraphicsState> graphicsStateStack = new ArrayDeque<>();
private final Stack<Long> markedContentStack = new Stack<>();

private final Set<Long> processedMCIDs = new HashSet<>();

private final Integer pageNumber;
private final COSKey objectKey;
private Matrix textMatrix = null;
Expand Down Expand Up @@ -89,7 +92,15 @@ public void parseChunk(Operator rawOperator, List<COSBase> arguments) {
switch (operatorName) {
case Operators.BMC:
case Operators.BDC:
markedContentStack.push(getMCID(arguments, resourceHandler));
Long mcid = getMCID(arguments, resourceHandler);
if (mcid != null) {
if (processedMCIDs.contains(mcid)) {
mcid = null;
} else {
processedMCIDs.add(mcid);
}
}
markedContentStack.push(mcid);
break;
case Operators.EMC:
markedContentStack.pop();
Expand Down

0 comments on commit cb0049c

Please sign in to comment.