1 | package pro.verron.officestamper.preset; | |
2 | ||
3 | import org.docx4j.openpackaging.exceptions.Docx4JException; | |
4 | import org.docx4j.openpackaging.packages.WordprocessingMLPackage; | |
5 | import pro.verron.officestamper.api.OfficeStamperConfiguration; | |
6 | import pro.verron.officestamper.api.OfficeStamperException; | |
7 | import pro.verron.officestamper.api.StreamStamper; | |
8 | import pro.verron.officestamper.core.DocxStamper; | |
9 | ||
10 | import java.io.InputStream; | |
11 | ||
12 | /// Main class of the docx-stamper library. | |
13 | /// | |
14 | /// This class can be used to create "stampers" that will open .docx templates | |
15 | /// to create a .docx document filled with custom data at runtime. | |
16 | /// | |
17 | /// @author Joseph Verron | |
18 | /// @version ${version} | |
19 | /// @since 1.6.4 | |
20 | public class OfficeStampers { | |
21 | ||
22 | ||
23 | private OfficeStampers() { | |
24 | throw new OfficeStamperException("OfficeStampers cannot be instantiated"); | |
25 | } | |
26 | ||
27 | /// Creates a new DocxStamper with the default configuration. | |
28 | /// Also adds the [Preprocessors#removeLanguageProof()] and [Preprocessors#mergeSimilarRuns()] | |
29 | /// preprocessors. | |
30 | /// | |
31 | /// @return a new DocxStamper | |
32 | public static StreamStamper<WordprocessingMLPackage> docxStamper() { | |
33 |
1
1. docxStamper : replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::docxStamper → NO_COVERAGE |
return docxStamper(OfficeStamperConfigurations.standardWithPreprocessing()); |
34 | } | |
35 | ||
36 | /// Creates a new instance of the [DocxStamper] class with the specified [OfficeStamperConfiguration]. | |
37 | /// | |
38 | /// @param config the configuration for the docx stamper | |
39 | /// | |
40 | /// @return a new instance of the [DocxStamper] class | |
41 | public static StreamStamper<WordprocessingMLPackage> docxStamper( | |
42 | OfficeStamperConfiguration config | |
43 | ) { | |
44 |
1
1. docxStamper : replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::docxStamper → KILLED |
return new StreamStamper<>( |
45 | OfficeStampers::loadWord, | |
46 | new DocxStamper(config) | |
47 | ); | |
48 | } | |
49 | ||
50 | private static WordprocessingMLPackage loadWord(InputStream is) { | |
51 | try { | |
52 |
1
1. loadWord : replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::loadWord → KILLED |
return WordprocessingMLPackage.load(is); |
53 | } catch (Docx4JException e) { | |
54 | throw new OfficeStamperException(e); | |
55 | } | |
56 | } | |
57 | ||
58 | } | |
Mutations | ||
33 |
1.1 |
|
44 |
1.1 |
|
52 |
1.1 |