| 1 | package pro.verron.officestamper.preset.preprocessors.similarrun; | |
| 2 | ||
| 3 | import org.docx4j.utils.TraversalUtilVisitor; | |
| 4 | import org.docx4j.wml.R; | |
| 5 | ||
| 6 | import java.util.ArrayList; | |
| 7 | import java.util.List; | |
| 8 | import java.util.Objects; | |
| 9 | ||
| 10 | /// A visitor implementation for traversing and identifying runs with similar styling in a DOCX document. This class | |
| 11 | /// extends [TraversalUtilVisitor] to process Run elements ([R]) and group consecutive runs that share the same | |
| 12 | /// formatting properties together. | |
| 13 | public class SimilarRunVisitor | |
| 14 | extends TraversalUtilVisitor<R> { | |
| 15 | ||
| 16 | private final List<List<R>> similarStyleRuns = new ArrayList<>(); | |
| 17 | ||
| 18 | ||
| 19 | /// Retrieves the list of grouped runs that have similar styling. Each inner list contains consecutive runs that | |
| 20 | /// share the same formatting properties. | |
| 21 | /// | |
| 22 | /// @return A list of lists, where each inner list contains runs with similar styling. | |
| 23 | public List<List<R>> getSimilarStyleRuns() { | |
| 24 |
1
1. getSimilarStyleRuns : replaced return value with Collections.emptyList for pro/verron/officestamper/preset/preprocessors/similarrun/SimilarRunVisitor::getSimilarStyleRuns → TIMED_OUT |
return similarStyleRuns; |
| 25 | } | |
| 26 | ||
| 27 | @Override | |
| 28 | public void apply(R element, Object parent, List<Object> siblings) { | |
| 29 | var rPr = element.getRPr(); | |
| 30 | var currentIndex = siblings.indexOf(element); | |
| 31 | var similarRuns = siblings.stream() | |
| 32 | .skip(currentIndex) | |
| 33 |
3
1. lambda$apply$0 : negated conditional → TIMED_OUT 2. lambda$apply$0 : negated conditional → TIMED_OUT 3. lambda$apply$0 : replaced boolean return with true for pro/verron/officestamper/preset/preprocessors/similarrun/SimilarRunVisitor::lambda$apply$0 → KILLED |
.takeWhile(o -> o instanceof R run && Objects.equals(run.getRPr(), rPr)) |
| 34 | .map(R.class::cast) | |
| 35 | .toList(); | |
| 36 |
2
1. apply : changed conditional boundary → TIMED_OUT 2. apply : negated conditional → TIMED_OUT |
if (similarRuns.size() > 1) similarStyleRuns.add(similarRuns); |
| 37 | } | |
| 38 | } | |
Mutations | ||
| 24 |
1.1 |
|
| 33 |
1.1 2.2 3.3 |
|
| 36 |
1.1 2.2 |