1 | package pro.verron.officestamper.api; | |
2 | ||
3 | import org.docx4j.openpackaging.packages.WordprocessingMLPackage; | |
4 | import org.docx4j.wml.P; | |
5 | import org.docx4j.wml.R; | |
6 | import org.springframework.lang.Nullable; | |
7 | ||
8 | /** | |
9 | * Represents a comment processor for handling context-specific processing and operations | |
10 | * on comments, paragraphs, and runs within a document. | |
11 | * This interface serves as a contract | |
12 | * for implementing custom comment processors. | |
13 | */ | |
14 | public interface CommentProcessor { | |
15 | ||
16 | /** | |
17 | * Sets the processing context for the comment processor. | |
18 | * This method serves to pass relevant contextual information, such as the | |
19 | * current paragraph, run, comment, and placeholder being processed. | |
20 | * It's always invoked before any custom methods of the custom | |
21 | * {@link CommentProcessor} interface. | |
22 | * | |
23 | * @param processorContext the context in which the processor operates, | |
24 | * containing details about the paragraph, run, | |
25 | * comment, and placeholder being processed. | |
26 | */ | |
27 | void setProcessorContext(ProcessorContext processorContext); | |
28 | ||
29 | /** | |
30 | * Sets the currently processed run in the comment processor. | |
31 | * This method should be called to specify the current run | |
32 | * within the context of processing a document. | |
33 | * | |
34 | * @param run the run object that is currently being processed, | |
35 | * or null if there is no specific run to set | |
36 | */ | |
37 | void setCurrentRun(@Nullable R run); | |
38 | ||
39 | /** | |
40 | * Finalizes the processing of a {@link DocxPart} document and commits any changes made to it. | |
41 | * This method is used to ensure that all modifications performed during the processing | |
42 | * of comments or other operations in the DocxPart are applied to the underlying document. | |
43 | * | |
44 | * @param docxPart the {@link DocxPart} instance representing a part of the document | |
45 | * that is being processed; contains the underlying WordprocessingMLPackage | |
46 | * document to which the changes are committed | |
47 | */ | |
48 | default void commitChanges(DocxPart docxPart) { | |
49 |
1
1. commitChanges : removed call to pro/verron/officestamper/api/CommentProcessor::commitChanges → NO_COVERAGE |
commitChanges(docxPart.document()); |
50 | } | |
51 | ||
52 | /** | |
53 | * Commits changes to the provided WordprocessingMLPackage document. | |
54 | * This method is deprecated and should not be used in new implementations. | |
55 | * It is retained only for compatibility with legacy implementations. | |
56 | * | |
57 | * @param document the WordprocessingMLPackage document to which changes were made | |
58 | * @throws OfficeStamperException always thrown, as this method should no longer be called | |
59 | * @deprecated since 2.3; for removal in future versions. Use updated methods or processes instead. | |
60 | */ | |
61 | @Deprecated(since = "2.3", forRemoval = true) default void commitChanges(WordprocessingMLPackage document) { | |
62 | throw new OfficeStamperException("Should not be called since deprecation, only legacy implementations have a " | |
63 | + "reason to keep implementing this"); | |
64 | } | |
65 | ||
66 | /** | |
67 | * Retrieves the current paragraph being processed. | |
68 | * | |
69 | * @return the current {@code Paragraph} object associated with the comment processor | |
70 | */ | |
71 | Paragraph getParagraph(); | |
72 | ||
73 | /** | |
74 | * Sets the current paragraph being processed in the comment processor. | |
75 | * This method is deprecated and scheduled for removal in a future version. | |
76 | * | |
77 | * @param paragraph the paragraph to set as the current paragraph being processed | |
78 | */ | |
79 | @Deprecated(since = "2.6", forRemoval = true) | |
80 | void setParagraph(P paragraph); | |
81 | ||
82 | /** | |
83 | * Sets the current comment being processed in the comment processor. | |
84 | * This method is typically invoked to specify the comment object | |
85 | * associated with the current processing context. | |
86 | * | |
87 | * @param comment the comment object that is currently being processed | |
88 | */ | |
89 | void setCurrentCommentWrapper(Comment comment); | |
90 | ||
91 | /** | |
92 | * Resets the internal state of the comment processor to its initial state. | |
93 | * This method is intended to clear any stored context or settings, | |
94 | * allowing the processor to be reused for a new processing task. | |
95 | */ | |
96 | void reset(); | |
97 | } | |
Mutations | ||
49 |
1.1 |