From 1aa3887cc085acbf5bf418d293d600da826d75e4 Mon Sep 17 00:00:00 2001 From: Maxim Date: Thu, 11 Jul 2024 19:37:58 +0300 Subject: [PATCH] Improve table border detection --- .../consumers/LinesPreprocessingConsumer.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/verapdf/wcag/algorithms/semanticalgorithms/consumers/LinesPreprocessingConsumer.java b/src/main/java/org/verapdf/wcag/algorithms/semanticalgorithms/consumers/LinesPreprocessingConsumer.java index 8d9a60ee..4a107dc1 100644 --- a/src/main/java/org/verapdf/wcag/algorithms/semanticalgorithms/consumers/LinesPreprocessingConsumer.java +++ b/src/main/java/org/verapdf/wcag/algorithms/semanticalgorithms/consumers/LinesPreprocessingConsumer.java @@ -101,15 +101,17 @@ private List findTableBorders(Integer pageNumber) { private void mergeTableBorders(List tableBorders) { for (int i = tableBorders.size() - 2; i >= 0; i--) { TableBorderBuilder border = tableBorders.get(i); - for (int j = i + 1; j < tableBorders.size();) { + List indexes = new LinkedList<>(); + for (int j = tableBorders.size() - 1; j > i; j--) { TableBorderBuilder border2 = tableBorders.get(j); if (border.isConnectedBorder(border2)) { - border.mergeBorder(border2); - tableBorders.remove(j); - } else { - j++; + indexes.add(j); } } + for (Integer index : indexes) { + border.mergeBorder(tableBorders.get(index)); + tableBorders.remove((int)index); + } } }