1
|
|
package pro.verron.officestamper.preset.preprocessors.similarrun; |
2
|
|
|
3
|
|
import org.docx4j.TraversalUtil; |
4
|
|
import org.docx4j.openpackaging.packages.WordprocessingMLPackage; |
5
|
|
import org.docx4j.wml.ContentAccessor; |
6
|
|
import org.docx4j.wml.R; |
7
|
|
import pro.verron.officestamper.api.PreProcessor; |
8
|
|
|
9
|
|
import java.util.LinkedHashSet; |
10
|
|
import java.util.List; |
11
|
|
|
12
|
|
public class MergeSameStyleRuns |
13
|
|
implements PreProcessor { |
14
|
|
|
15
|
|
/** |
16
|
|
* {@inheritDoc} |
17
|
|
*/ |
18
|
|
@Override |
19
|
|
public void process(WordprocessingMLPackage document) { |
20
|
|
var mainDocumentPart = document.getMainDocumentPart(); |
21
|
|
var visitor = new SimilarRunVisitor(); |
22
|
1
1. process : removed call to org/docx4j/TraversalUtil::visit → SURVIVED
|
TraversalUtil.visit(mainDocumentPart, visitor); |
23
|
|
for (List<R> similarStyleRuns : visitor.getSimilarStyleRuns()) { |
24
|
|
R firstRun = similarStyleRuns.getFirst(); |
25
|
|
var runContent = firstRun.getContent(); |
26
|
|
var firstRunContent = new LinkedHashSet<>(runContent); |
27
|
|
var firstRunParentContent = ((ContentAccessor) firstRun.getParent()).getContent(); |
28
|
|
for (R r : similarStyleRuns.subList(1, similarStyleRuns.size())) { |
29
|
|
firstRunParentContent.remove(r); |
30
|
|
firstRunContent.addAll(r.getContent()); |
31
|
|
} |
32
|
1
1. process : removed call to java/util/List::clear → KILLED
|
runContent.clear(); |
33
|
|
runContent.addAll(firstRunContent); |
34
|
|
} |
35
|
|
} |
36
|
|
} |
| | Mutations |
22 |
|
1.1 Location : process Killed by : none removed call to org/docx4j/TraversalUtil::visit → SURVIVED
Covering tests
Covered by tests:
- pro.verron.officestamper.test.RegressionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.RegressionTests]/[method:test64()]
- pro.verron.officestamper.test.SpelInstantiationTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.SpelInstantiationTest]/[method:testDateInstantiationAndResolution()]
- pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]/[test-template-invocation:#4]
- pro.verron.officestamper.test.RegressionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.RegressionTests]/[test-template:test52(pro.verron.officestamper.test.RegressionTests$Conditions, java.lang.String)]/[test-template-invocation:#1]
- pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]/[test-template-invocation:#30]
- pro.verron.officestamper.test.RegressionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.RegressionTests]/[test-template:test52(pro.verron.officestamper.test.RegressionTests$Conditions, java.lang.String)]/[test-template-invocation:#3]
- pro.verron.officestamper.test.RegressionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.RegressionTests]/[test-template:test52(pro.verron.officestamper.test.RegressionTests$Conditions, java.lang.String)]/[test-template-invocation:#7]
- pro.verron.officestamper.test.RegressionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.RegressionTests]/[test-template:test52(pro.verron.officestamper.test.RegressionTests$Conditions, java.lang.String)]/[test-template-invocation:#2]
- pro.verron.officestamper.test.RegressionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.RegressionTests]/[test-template:test52(pro.verron.officestamper.test.RegressionTests$Conditions, java.lang.String)]/[test-template-invocation:#5]
- pro.verron.officestamper.test.RegressionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.RegressionTests]/[test-template:test52(pro.verron.officestamper.test.RegressionTests$Conditions, java.lang.String)]/[test-template-invocation:#6]
- pro.verron.officestamper.test.RegressionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.RegressionTests]/[test-template:test52(pro.verron.officestamper.test.RegressionTests$Conditions, java.lang.String)]/[test-template-invocation:#4]
- pro.verron.officestamper.test.BasicWordTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicWordTest]/[method:testStamper()]
- pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]/[test-template-invocation:#11]
|
32 |
|
1.1 Location : process Killed by : pro.verron.officestamper.test.SpelInstantiationTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.SpelInstantiationTest]/[method:testDateInstantiationAndResolution()] removed call to java/util/List::clear → KILLED
|