RemoveLang.java

1
package pro.verron.officestamper.preset.preprocessors.rmlang;
2
3
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
4
import pro.verron.officestamper.api.PreProcessor;
5
6
import static pro.verron.officestamper.utils.wml.WmlUtils.visitDocument;
7
8
/// The [RemoveLang] preprocessor removes language settings from paragraphs and runs within a Word document. This is
9
/// useful when working with templates where language-specific formatting might interfere with the stamping process.
10
///
11
/// This preprocessor specifically targets and removes `w:lang` elements from both run properties (`w:rPr`) and
12
/// paragraph properties (`w:pPr`) throughout the document.
13
///
14
/// @author Joseph Verron
15
public class RemoveLang
16
        implements PreProcessor {
17
18
    @Override
19
    public void process(WordprocessingMLPackage document) {
20 1 1. process : removed call to pro/verron/officestamper/preset/preprocessors/rmlang/RemoveLang::removeRprLang → SURVIVED
        removeRprLang(document);
21 1 1. process : removed call to pro/verron/officestamper/preset/preprocessors/rmlang/RemoveLang::removePprLang → SURVIVED
        removePprLang(document);
22
    }
23
24
    private static void removeRprLang(WordprocessingMLPackage document) {
25
        var visitor = new RprLangVisitor();
26 1 1. removeRprLang : removed call to pro/verron/officestamper/utils/wml/WmlUtils::visitDocument → SURVIVED
        visitDocument(document, visitor);
27
        for (var rPr : visitor.getrPrs()) {
28 1 1. removeRprLang : removed call to org/docx4j/wml/RPr::setLang → NO_COVERAGE
            rPr.setLang(null);
29
        }
30
    }
31
32
    private static void removePprLang(WordprocessingMLPackage document) {
33
        var visitor2 = new PprLangVisitor();
34 1 1. removePprLang : removed call to pro/verron/officestamper/utils/wml/WmlUtils::visitDocument → SURVIVED
        visitDocument(document, visitor2);
35
        for (var rPr : visitor2.getParaPrs()) {
36 1 1. removePprLang : removed call to org/docx4j/wml/ParaRPr::setLang → SURVIVED
            rPr.setLang(null);
37
        }
38
    }
39
}

Mutations

20

1.1
Location : process
Killed by : none
removed call to pro/verron/officestamper/preset/preprocessors/rmlang/RemoveLang::removeRprLang → SURVIVED
Covering tests

21

1.1
Location : process
Killed by : none
removed call to pro/verron/officestamper/preset/preprocessors/rmlang/RemoveLang::removePprLang → SURVIVED
Covering tests

26

1.1
Location : removeRprLang
Killed by : none
removed call to pro/verron/officestamper/utils/wml/WmlUtils::visitDocument → SURVIVED
Covering tests

28

1.1
Location : removeRprLang
Killed by : none
removed call to org/docx4j/wml/RPr::setLang → NO_COVERAGE

34

1.1
Location : removePprLang
Killed by : none
removed call to pro/verron/officestamper/utils/wml/WmlUtils::visitDocument → SURVIVED
Covering tests

36

1.1
Location : removePprLang
Killed by : none
removed call to org/docx4j/wml/ParaRPr::setLang → SURVIVED
Covering tests

Active mutators

Tests examined


Report generated by PIT 1.25.5 support