|
1
|
|
package pro.verron.officestamper.preset.preprocessors.similarrun; |
|
2
|
|
|
|
3
|
|
import org.docx4j.openpackaging.packages.WordprocessingMLPackage; |
|
4
|
|
import org.docx4j.wml.ContentAccessor; |
|
5
|
|
import pro.verron.officestamper.api.PreProcessor; |
|
6
|
|
import pro.verron.officestamper.utils.wml.WmlUtils; |
|
7
|
|
|
|
8
|
|
import java.util.LinkedHashSet; |
|
9
|
|
|
|
10
|
|
/// Merges consecutive runs with the same styling into a single run. |
|
11
|
|
/// |
|
12
|
|
/// This preprocessor analyzes the document and identifies adjacent runs that share identical styling properties. It |
|
13
|
|
/// then merges these runs into a single run to reduce document complexity and improve processing efficiency. |
|
14
|
|
/// |
|
15
|
|
/// The merging process preserves all content from the original runs while maintaining the formatting of the first run |
|
16
|
|
/// in each sequence of similar runs. |
|
17
|
|
/// |
|
18
|
|
/// @author Joseph Verron |
|
19
|
|
public class MergeSameStyleRuns |
|
20
|
|
implements PreProcessor { |
|
21
|
|
|
|
22
|
|
@Override |
|
23
|
|
public void process(WordprocessingMLPackage document) { |
|
24
|
|
var visitor = new SimilarRunVisitor(); |
|
25
|
1
1. process : removed call to pro/verron/officestamper/utils/wml/WmlUtils::visitDocument → SURVIVED
|
WmlUtils.visitDocument(document, visitor); |
|
26
|
|
for (var similarStyleRuns : visitor.getSimilarStyleRuns()) { |
|
27
|
|
var firstRun = similarStyleRuns.getFirst(); |
|
28
|
|
var runContent = firstRun.getContent(); |
|
29
|
|
var firstRunContent = new LinkedHashSet<>(runContent); |
|
30
|
|
var firstRunParentContent = ((ContentAccessor) firstRun.getParent()).getContent(); |
|
31
|
|
for (var r : similarStyleRuns.subList(1, similarStyleRuns.size())) { |
|
32
|
|
firstRunParentContent.remove(r); |
|
33
|
|
firstRunContent.addAll(r.getContent()); |
|
34
|
|
} |
|
35
|
1
1. process : removed call to java/util/List::clear → KILLED
|
runContent.clear(); |
|
36
|
|
runContent.addAll(firstRunContent); |
|
37
|
|
} |
|
38
|
|
} |
|
39
|
|
} |
| | Mutations |
| 25 |
|
1.1 Location : process Killed by : none removed call to pro/verron/officestamper/utils/wml/WmlUtils::visitDocument → SURVIVED
Covering tests
Covered by tests:
- 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.SpelInstantiationTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.SpelInstantiationTest]/[test-template:testDateInstantiationAndResolution(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
- 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]/[test-template:testDateInstantiationAndResolution(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
- 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:#3]
- pro.verron.officestamper.test.ProcessorReplaceWithTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorReplaceWithTest]/[method:notWorking1()]
- 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.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:#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.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, org.docx4j.openpackaging.packages.WordprocessingMLPackage, java.lang.String)]/[test-template-invocation:#27]
- pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, org.docx4j.openpackaging.packages.WordprocessingMLPackage, java.lang.String)]/[test-template-invocation:#19]
- pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, org.docx4j.openpackaging.packages.WordprocessingMLPackage, java.lang.String)]/[test-template-invocation:#10]
- pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, org.docx4j.openpackaging.packages.WordprocessingMLPackage, java.lang.String)]/[test-template-invocation:#2]
- pro.verron.officestamper.test.ProcessorRepeatTableRowTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorRepeatTableRowTest]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, org.docx4j.openpackaging.packages.WordprocessingMLPackage, java.lang.String)]/[test-template-invocation:#1]
- pro.verron.officestamper.test.ProcessorRepeatTableRowTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorRepeatTableRowTest]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, org.docx4j.openpackaging.packages.WordprocessingMLPackage, java.lang.String)]/[test-template-invocation:#2]
- pro.verron.officestamper.test.ProcessorRepeatTableRowTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorRepeatTableRowTest]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, org.docx4j.openpackaging.packages.WordprocessingMLPackage, java.lang.String)]/[test-template-invocation:#4]
- pro.verron.officestamper.test.ProcessorRepeatDocPartTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorRepeatDocPartTest]/[test-template:shouldReplicateImageFromTheMainDocumentInTheSubTemplate(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
- pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfEndnotes(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
- pro.verron.officestamper.test.ProcessorRepeatTableRowTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorRepeatTableRowTest]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, org.docx4j.openpackaging.packages.WordprocessingMLPackage, java.lang.String)]/[test-template-invocation:#6]
- pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfEndnotes(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
- pro.verron.officestamper.test.ProcessorRepeatTableRowTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorRepeatTableRowTest]/[method:shouldAcceptList()]
- pro.verron.officestamper.test.ProcessorRepeatDocPartTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorRepeatDocPartTest]/[test-template:shouldReplicateImageFromTheMainDocumentInTheSubTemplate(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
- pro.verron.officestamper.test.ProcessorRepeatTableRowTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorRepeatTableRowTest]/[method:shouldAcceptQueue()]
- pro.verron.officestamper.test.ProcessorRepeatTableRowTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorRepeatTableRowTest]/[method:shouldAcceptSet()]
- pro.verron.officestamper.test.ProcessorRepeatTableRowTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorRepeatTableRowTest]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, org.docx4j.openpackaging.packages.WordprocessingMLPackage, java.lang.String)]/[test-template-invocation:#3]
- pro.verron.officestamper.test.ProcessorRepeatTableRowTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorRepeatTableRowTest]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, org.docx4j.openpackaging.packages.WordprocessingMLPackage, java.lang.String)]/[test-template-invocation:#5]
- pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfFootnotes(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
- pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfFootnotes(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
- pro.verron.officestamper.test.ProcessorRepeatDocPartTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorRepeatDocPartTest]/[method:shouldResolveListOfLists()]
- pro.verron.officestamper.test.BasicWordTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicWordTest]/[method:testStamper()]
- pro.verron.officestamper.test.ProcessorRepeatDocPartTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorRepeatDocPartTest]/[test-template:repeatDocPartNestingTest(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
- pro.verron.officestamper.test.ProcessorRepeatDocPartTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorRepeatDocPartTest]/[test-template:repeatDocPartNestingTest(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
|
| 35 |
|
1.1 Location : process Killed by : 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] removed call to java/util/List::clear → KILLED
|