| 1 | package pro.verron.officestamper.utils.wml; | |
| 2 | ||
| 3 | import org.docx4j.dml.wordprocessingDrawing.Inline; | |
| 4 | import org.docx4j.openpackaging.exceptions.InvalidFormatException; | |
| 5 | import org.docx4j.openpackaging.packages.WordprocessingMLPackage; | |
| 6 | import org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage; | |
| 7 | import org.docx4j.openpackaging.parts.WordprocessingML.CommentsPart; | |
| 8 | import org.docx4j.wml.*; | |
| 9 | import org.docx4j.wml.Comments.Comment; | |
| 10 | import org.jspecify.annotations.Nullable; | |
| 11 | import pro.verron.officestamper.utils.UtilsException; | |
| 12 | ||
| 13 | import java.math.BigInteger; | |
| 14 | import java.util.ArrayList; | |
| 15 | import java.util.Arrays; | |
| 16 | import java.util.List; | |
| 17 | import java.util.Random; | |
| 18 | ||
| 19 | import static java.util.Arrays.asList; | |
| 20 | import static java.util.stream.Collectors.toCollection; | |
| 21 | ||
| 22 | /// Utility class for creating and configuring various WordML (WML) elements. Provides static methods to generate | |
| 23 | /// paragraphs, runs, comments, text, and other WML structures. This is intended for handling Office Open XML documents | |
| 24 | /// programmatically. | |
| 25 | public class WmlFactory { | |
| 26 | private static final Random RANDOM = new Random(); | |
| 27 | ||
| 28 | private WmlFactory() { | |
| 29 | throw new UtilsException("Utility class shouldn't be instantiated"); | |
| 30 | } | |
| 31 | ||
| 32 | /// Creates a new comment with the provided value. | |
| 33 | /// | |
| 34 | /// @param id The ID to assign to the comment. | |
| 35 | /// @param value The string value to be included in the comment. | |
| 36 | /// | |
| 37 | /// @return A new [Comment] object containing the provided value. | |
| 38 | public static Comment newComment(BigInteger id, String value) { | |
| 39 | var comment = new Comment(); | |
| 40 |
1
1. newComment : removed call to org/docx4j/wml/Comments$Comment::setId → NO_COVERAGE |
comment.setId(id); |
| 41 | var commentContent = comment.getContent(); | |
| 42 | commentContent.add(newParagraph(value)); | |
| 43 |
1
1. newComment : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newComment → NO_COVERAGE |
return comment; |
| 44 | } | |
| 45 | ||
| 46 | /// Creates a new paragraph containing the provided string value. | |
| 47 | /// | |
| 48 | /// @param value The string value to be added to the new paragraph. | |
| 49 | /// | |
| 50 | /// @return A new [P] containing the provided string value. | |
| 51 | public static P newParagraph(String value) { | |
| 52 |
1
1. newParagraph : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newParagraph → NO_COVERAGE |
return newParagraph(newRun(value)); |
| 53 | } | |
| 54 | ||
| 55 | /// Creates a new paragraph containing the provided run. | |
| 56 | /// | |
| 57 | /// @param run The [R] object (run) to be included in the new paragraph. | |
| 58 | /// | |
| 59 | /// @return A new [P] containing the provided run. | |
| 60 | public static P newParagraph(R run) { | |
| 61 |
1
1. newParagraph : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newParagraph → NO_COVERAGE |
return newParagraph(List.of(run)); |
| 62 | } | |
| 63 | ||
| 64 | /// Creates a new run containing the provided string value. | |
| 65 | /// | |
| 66 | /// @param value The string value to be included in the new run. | |
| 67 | /// | |
| 68 | /// @return A new [R] containing the provided string value. | |
| 69 | public static R newRun(String value) { | |
| 70 |
1
1. newRun : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newRun → NO_COVERAGE |
return newRun(newText(value)); |
| 71 | } | |
| 72 | ||
| 73 | /// Creates a new paragraph containing the provided list of values. | |
| 74 | /// | |
| 75 | /// @param values A list of objects to be added to the new paragraph. These objects populate the content of | |
| 76 | /// the paragraph. | |
| 77 | /// | |
| 78 | /// @return A new [P] containing the provided values. | |
| 79 | public static P newParagraph(List<?> values) { | |
| 80 | var paragraph = new P(); | |
| 81 | var paragraphContent = paragraph.getContent(); | |
| 82 | paragraphContent.addAll(values); | |
| 83 |
1
1. newParagraph : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newParagraph → NO_COVERAGE |
return paragraph; |
| 84 | } | |
| 85 | ||
| 86 | /// Creates a new run containing a single text object. | |
| 87 | /// | |
| 88 | /// @param value The [Text] object to be included in the new run. | |
| 89 | /// | |
| 90 | /// @return A new [R] encapsulating the provided text object. | |
| 91 | public static R newRun(Text value) { | |
| 92 |
1
1. newRun : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newRun → NO_COVERAGE |
return newRun(List.of(value)); |
| 93 | } | |
| 94 | ||
| 95 | /// Creates a new [Text] object with the specified value, preserving spaces. | |
| 96 | /// | |
| 97 | /// @param value The string value to be set in the new [Text] object. | |
| 98 | /// | |
| 99 | /// @return A new [Text] object containing the provided value with space preserved. | |
| 100 | public static Text newText(String value) { | |
| 101 | var text = new Text(); | |
| 102 |
1
1. newText : removed call to org/docx4j/wml/Text::setValue → NO_COVERAGE |
text.setValue(value); |
| 103 |
1
1. newText : removed call to org/docx4j/wml/Text::setSpace → NO_COVERAGE |
text.setSpace("preserve"); |
| 104 |
1
1. newText : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newText → NO_COVERAGE |
return text; |
| 105 | } | |
| 106 | ||
| 107 | /// Creates a new run containing the provided values deemed worth keeping. | |
| 108 | /// | |
| 109 | /// @param values A list of objects to be added to the new run. Objects are filtered based on a predefined | |
| 110 | /// criteria to determine if they are worth keeping. | |
| 111 | /// | |
| 112 | /// @return A new [R] containing the filtered values. | |
| 113 | public static R newRun(List<Object> values) { | |
| 114 | var run = new R(); | |
| 115 | var runContent = run.getContent(); | |
| 116 | runContent.addAll(values.stream() | |
| 117 | .filter(WmlFactory::worthKeeping) | |
| 118 | .collect(toCollection(ArrayList::new))); | |
| 119 |
1
1. newRun : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newRun → NO_COVERAGE |
return run; |
| 120 | } | |
| 121 | ||
| 122 | private static boolean worthKeeping(Object o) { | |
| 123 |
3
1. worthKeeping : negated conditional → NO_COVERAGE 2. worthKeeping : replaced boolean return with true for pro/verron/officestamper/utils/wml/WmlFactory::worthKeeping → NO_COVERAGE 3. worthKeeping : replaced boolean return with false for pro/verron/officestamper/utils/wml/WmlFactory::worthKeeping → NO_COVERAGE |
if (o instanceof Text text) return worthKeeping(text); |
| 124 |
1
1. worthKeeping : replaced boolean return with false for pro/verron/officestamper/utils/wml/WmlFactory::worthKeeping → NO_COVERAGE |
else return true; |
| 125 | } | |
| 126 | ||
| 127 | private static boolean worthKeeping(Text text) { | |
| 128 | var textValue = text.getValue(); | |
| 129 |
2
1. worthKeeping : negated conditional → NO_COVERAGE 2. worthKeeping : replaced boolean return with true for pro/verron/officestamper/utils/wml/WmlFactory::worthKeeping → NO_COVERAGE |
return !textValue.isEmpty(); |
| 130 | } | |
| 131 | ||
| 132 | /// Creates a new [Body] object containing the provided elements. | |
| 133 | /// | |
| 134 | /// @param elements A list of objects to be added to the new [Body]. | |
| 135 | /// | |
| 136 | /// @return A new [Body] containing the provided elements. | |
| 137 | public static Body newBody(List<Object> elements) { | |
| 138 | Body body = new Body(); | |
| 139 | var bodyContent = body.getContent(); | |
| 140 | bodyContent.addAll(elements); | |
| 141 |
1
1. newBody : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newBody → NO_COVERAGE |
return body; |
| 142 | } | |
| 143 | ||
| 144 | /// Creates a new paragraph containing the provided text values. | |
| 145 | /// | |
| 146 | /// @param texts The array of string values to be included in the new paragraph. | |
| 147 | /// | |
| 148 | /// @return A new [P] containing the provided text values. | |
| 149 | public static P newParagraph(String... texts) { | |
| 150 |
1
1. newParagraph : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newParagraph → NO_COVERAGE |
return newParagraph(Arrays.stream(texts) |
| 151 | .map(WmlFactory::newRun) | |
| 152 | .toList()); | |
| 153 | } | |
| 154 | ||
| 155 | /// Creates a new [PPr] (paragraph properties) object. | |
| 156 | /// | |
| 157 | /// @return A new [PPr] object. | |
| 158 | public static PPr newPPr() { | |
| 159 |
1
1. newPPr : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newPPr → NO_COVERAGE |
return new PPr(); |
| 160 | } | |
| 161 | ||
| 162 | /// Creates a new [Comments] object and populates it with a list of [Comment] objects. | |
| 163 | /// | |
| 164 | /// @param list A list of [Comment] objects to be added to the new [Comments] object. | |
| 165 | /// | |
| 166 | /// @return A new [Comments] object containing the provided [Comment] objects. | |
| 167 | public static Comments newComments(List<Comment> list) { | |
| 168 | Comments comments = new Comments(); | |
| 169 | List<Comment> commentList = comments.getComment(); | |
| 170 | commentList.addAll(list); | |
| 171 |
1
1. newComments : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newComments → NO_COVERAGE |
return comments; |
| 172 | } | |
| 173 | ||
| 174 | /// Creates a new run containing an image with the specified attributes. | |
| 175 | /// | |
| 176 | /// @param maxWidth The maximum width of the image, it can be null. | |
| 177 | /// @param abstractImage The binary part abstract image to be included in the run. | |
| 178 | /// @param filenameHint The filename hint for the image. | |
| 179 | /// @param altText The alternative text for the image. | |
| 180 | /// | |
| 181 | /// @return A new [R] element containing the image. | |
| 182 | public static R newRun( | |
| 183 | @Nullable Integer maxWidth, | |
| 184 | BinaryPartAbstractImage abstractImage, | |
| 185 | String filenameHint, | |
| 186 | String altText | |
| 187 | ) { | |
| 188 | var inline = newInline(abstractImage, filenameHint, altText, maxWidth); | |
| 189 |
1
1. newRun : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newRun → NO_COVERAGE |
return newRun(newDrawing(inline)); |
| 190 | } | |
| 191 | ||
| 192 | /// Creates a new [Inline] object for the given image part, filename hint, and alt text. | |
| 193 | /// | |
| 194 | /// @param imagePart The binary part abstract image to be used. | |
| 195 | /// @param filenameHint A hint for the filename of the image. | |
| 196 | /// @param altText Alternative text for the image. | |
| 197 | /// @param maxWidth The image width not to exceed, in points. | |
| 198 | /// | |
| 199 | /// @return A new [Inline] object containing the specified image information. | |
| 200 | /// | |
| 201 | /// @throws UtilsException If there is an error creating the image inline. | |
| 202 | public static Inline newInline( | |
| 203 | BinaryPartAbstractImage imagePart, | |
| 204 | String filenameHint, | |
| 205 | String altText, | |
| 206 | @Nullable Integer maxWidth | |
| 207 | ) { | |
| 208 | // creating random ids assuming they are unique, | |
| 209 | // id must not be too large | |
| 210 | // otherwise Word cannot open the document | |
| 211 | var id1 = RANDOM.nextLong(100_000L); | |
| 212 | var id2 = RANDOM.nextInt(100_000); | |
| 213 | try { | |
| 214 |
2
1. newInline : negated conditional → NO_COVERAGE 2. newInline : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newInline → NO_COVERAGE |
return maxWidth == null |
| 215 | ? imagePart.createImageInline(filenameHint, altText, id1, id2, false) | |
| 216 | : imagePart.createImageInline(filenameHint, altText, id1, id2, false, maxWidth); | |
| 217 | } catch (Exception e) { | |
| 218 | throw new UtilsException(e); | |
| 219 | } | |
| 220 | } | |
| 221 | ||
| 222 | /// Creates a new run containing a single drawing. | |
| 223 | /// | |
| 224 | /// @param value The [Drawing] object to be included in the new run. | |
| 225 | /// | |
| 226 | /// @return A new [R] encapsulating the provided drawing. | |
| 227 | public static R newRun(Drawing value) { | |
| 228 |
1
1. newRun : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newRun → NO_COVERAGE |
return newRun(List.of(value)); |
| 229 | } | |
| 230 | ||
| 231 | /// Creates a new [Drawing] object containing the provided [Inline] object. | |
| 232 | /// | |
| 233 | /// @param inline The [Inline] object to be contained within the new [Drawing]. | |
| 234 | /// | |
| 235 | /// @return A new [Drawing] object encapsulating the provided inline object. | |
| 236 | public static Drawing newDrawing(Inline inline) { | |
| 237 | var drawing = new Drawing(); | |
| 238 | var anchorOrInline = drawing.getAnchorOrInline(); | |
| 239 | anchorOrInline.add(inline); | |
| 240 |
1
1. newDrawing : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newDrawing → NO_COVERAGE |
return drawing; |
| 241 | } | |
| 242 | ||
| 243 | /// Creates a new [CommentRangeStart] object with the specified ID and parent. | |
| 244 | /// | |
| 245 | /// @param id The unique identifier for the [CommentRangeStart] object. | |
| 246 | /// @param parent The parent element ([P]) to which this [CommentRangeStart] belongs. | |
| 247 | /// | |
| 248 | /// @return A new [CommentRangeStart] object with the specified ID and parent. | |
| 249 | public static CommentRangeStart newCommentRangeStart(BigInteger id, ContentAccessor parent) { | |
| 250 | var commentRangeStart = new CommentRangeStart(); | |
| 251 |
1
1. newCommentRangeStart : removed call to org/docx4j/wml/CommentRangeStart::setId → NO_COVERAGE |
commentRangeStart.setId(id); |
| 252 |
1
1. newCommentRangeStart : removed call to org/docx4j/wml/CommentRangeStart::setParent → NO_COVERAGE |
commentRangeStart.setParent(parent); |
| 253 |
1
1. newCommentRangeStart : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newCommentRangeStart → NO_COVERAGE |
return commentRangeStart; |
| 254 | } | |
| 255 | ||
| 256 | /// Creates a new [CommentRangeEnd] object with the specified ID and parent. | |
| 257 | /// | |
| 258 | /// @param id The unique identifier for the [CommentRangeEnd] object. | |
| 259 | /// @param parent The parent element ([P]) to which this [CommentRangeEnd] belongs. | |
| 260 | /// | |
| 261 | /// @return A new [CommentRangeEnd] object with the specified ID and parent. | |
| 262 | public static CommentRangeEnd newCommentRangeEnd(BigInteger id, ContentAccessor parent) { | |
| 263 | var commentRangeEnd = new CommentRangeEnd(); | |
| 264 |
1
1. newCommentRangeEnd : removed call to org/docx4j/wml/CommentRangeEnd::setId → NO_COVERAGE |
commentRangeEnd.setId(id); |
| 265 |
1
1. newCommentRangeEnd : removed call to org/docx4j/wml/CommentRangeEnd::setParent → NO_COVERAGE |
commentRangeEnd.setParent(parent); |
| 266 |
1
1. newCommentRangeEnd : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newCommentRangeEnd → NO_COVERAGE |
return commentRangeEnd; |
| 267 | } | |
| 268 | ||
| 269 | /// Creates a new [R.CommentReference] object with the specified ID and parent. | |
| 270 | /// | |
| 271 | /// @param id The unique identifier for the [R.CommentReference]. | |
| 272 | /// @param parent The parent element ([P]) to which this [R.CommentReference] belongs. | |
| 273 | /// | |
| 274 | /// @return A new [R.CommentReference] object with the specified ID and parent. | |
| 275 | public static R.CommentReference newCommentReference(BigInteger id, ContentAccessor parent) { | |
| 276 | var commentReference = new R.CommentReference(); | |
| 277 |
1
1. newCommentReference : removed call to org/docx4j/wml/R$CommentReference::setId → NO_COVERAGE |
commentReference.setId(id); |
| 278 |
1
1. newCommentReference : removed call to org/docx4j/wml/R$CommentReference::setParent → NO_COVERAGE |
commentReference.setParent(parent); |
| 279 |
1
1. newCommentReference : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newCommentReference → NO_COVERAGE |
return commentReference; |
| 280 | } | |
| 281 | ||
| 282 | /// Creates a new table object. | |
| 283 | /// | |
| 284 | /// @return A new instance of [Tbl]. | |
| 285 | public static Tbl newTbl() { | |
| 286 |
1
1. newTbl : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newTbl → NO_COVERAGE |
return new Tbl(); |
| 287 | } | |
| 288 | ||
| 289 | /// Creates a new cell object. | |
| 290 | /// | |
| 291 | /// @return A new instance of [Tc]. | |
| 292 | public static Tc newCell() { | |
| 293 |
1
1. newCell : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newCell → NO_COVERAGE |
return new Tc(); |
| 294 | } | |
| 295 | ||
| 296 | /// Creates a new row object. | |
| 297 | /// | |
| 298 | /// @return A new instance of [Tr]. | |
| 299 | public static Tr newRow() { | |
| 300 |
1
1. newRow : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newRow → NO_COVERAGE |
return new Tr(); |
| 301 | } | |
| 302 | ||
| 303 | /// Creates a new [WordprocessingMLPackage] object initialized with a main document part, and an empty comments | |
| 304 | /// part. | |
| 305 | /// | |
| 306 | /// @return A new instance of [WordprocessingMLPackage]. | |
| 307 | public static WordprocessingMLPackage newWord() { | |
| 308 | try { | |
| 309 | var aPackage = WordprocessingMLPackage.createPackage(); | |
| 310 | var mainDocumentPart = aPackage.getMainDocumentPart(); | |
| 311 | var cp = newCommentsPart(); | |
| 312 |
1
1. newWord : removed call to org/docx4j/openpackaging/parts/WordprocessingML/CommentsPart::init → NO_COVERAGE |
cp.init(); |
| 313 |
1
1. newWord : removed call to org/docx4j/openpackaging/parts/WordprocessingML/CommentsPart::setJaxbElement → NO_COVERAGE |
cp.setJaxbElement(newComments()); |
| 314 | mainDocumentPart.addTargetPart(cp); | |
| 315 |
1
1. newWord : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newWord → NO_COVERAGE |
return aPackage; |
| 316 | } catch (InvalidFormatException e) { | |
| 317 | throw new UtilsException(e); | |
| 318 | } | |
| 319 | } | |
| 320 | ||
| 321 | /// Creates a new [CommentsPart] object. This method attempts to create a new instance of [CommentsPart]. If an | |
| 322 | /// [InvalidFormatException] occurs during the creation process, it wraps the exception in an [UtilsException] and | |
| 323 | /// throws it. | |
| 324 | /// | |
| 325 | /// @return A new instance of [CommentsPart]. | |
| 326 | public static CommentsPart newCommentsPart() { | |
| 327 | try { | |
| 328 |
1
1. newCommentsPart : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newCommentsPart → NO_COVERAGE |
return new CommentsPart(); |
| 329 | } catch (InvalidFormatException e) { | |
| 330 | throw new UtilsException(e); | |
| 331 | } | |
| 332 | } | |
| 333 | ||
| 334 | private static Comments newComments() { | |
| 335 |
1
1. newComments : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newComments → NO_COVERAGE |
return new Comments(); |
| 336 | } | |
| 337 | ||
| 338 | /// Creates a new [Br] (break) object with text wrapping enabled. | |
| 339 | /// | |
| 340 | /// @return A new [Br] object with text wrapping type and no clear attribute set. | |
| 341 | public static Br newBr() { | |
| 342 | var br = new Br(); | |
| 343 |
1
1. newBr : removed call to org/docx4j/wml/Br::setType → NO_COVERAGE |
br.setType(STBrType.TEXT_WRAPPING); |
| 344 |
1
1. newBr : removed call to org/docx4j/wml/Br::setClear → NO_COVERAGE |
br.setClear(null); |
| 345 |
1
1. newBr : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newBr → NO_COVERAGE |
return br; |
| 346 | } | |
| 347 | ||
| 348 | /// Creates a new smart tag run with the specified element, run and attribute. | |
| 349 | /// | |
| 350 | /// @param element The element name for the smart tag. | |
| 351 | /// @param attribute The [CTAttr] to add to the smart tag properties. | |
| 352 | /// @param object The [Object] to include in the smart tag content. | |
| 353 | /// | |
| 354 | /// @return A new [CTSmartTagRun] object configured with the specified parameters. | |
| 355 | public static CTSmartTagRun newSmartTag(String element, CTAttr attribute, Object... object) { | |
| 356 | var smartTag = new CTSmartTagRun(); | |
| 357 |
1
1. newSmartTag : removed call to org/docx4j/wml/CTSmartTagRun::setElement → NO_COVERAGE |
smartTag.setElement(element); |
| 358 | ||
| 359 | var smartTagPr = new CTSmartTagPr(); | |
| 360 |
1
1. newSmartTag : removed call to org/docx4j/wml/CTSmartTagRun::setSmartTagPr → NO_COVERAGE |
smartTag.setSmartTagPr(smartTagPr); |
| 361 | ||
| 362 | var smartTagPrAttr = smartTagPr.getAttr(); | |
| 363 | smartTagPrAttr.add(attribute); | |
| 364 | ||
| 365 | var smartTagContent = smartTag.getContent(); | |
| 366 | smartTagContent.addAll(asList(object)); | |
| 367 |
1
1. newSmartTag : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newSmartTag → NO_COVERAGE |
return smartTag; |
| 368 | } | |
| 369 | ||
| 370 | /// Creates a new [CTAttr] object with the specified name and value. | |
| 371 | /// | |
| 372 | /// @param name The name of the attribute. | |
| 373 | /// @param value The value of the attribute. | |
| 374 | /// | |
| 375 | /// @return A new [CTAttr] object with the specified name and value. | |
| 376 | public static CTAttr newCtAttr(String name, String value) { | |
| 377 | var ctAttr = new CTAttr(); | |
| 378 |
1
1. newCtAttr : removed call to org/docx4j/wml/CTAttr::setName → NO_COVERAGE |
ctAttr.setName(name); |
| 379 |
1
1. newCtAttr : removed call to org/docx4j/wml/CTAttr::setVal → NO_COVERAGE |
ctAttr.setVal(value); |
| 380 |
1
1. newCtAttr : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newCtAttr → NO_COVERAGE |
return ctAttr; |
| 381 | } | |
| 382 | ||
| 383 | /// Creates a new [Pict] object containing the provided inner object. | |
| 384 | /// | |
| 385 | /// @param innerObj The object to be included in the new pict element. | |
| 386 | /// | |
| 387 | /// @return A new [Pict] object containing the provided inner object. | |
| 388 | public static Object newPict(Object innerObj) { | |
| 389 | var pict = new Pict(); | |
| 390 | pict.getAnyAndAny() | |
| 391 | .add(innerObj); | |
| 392 |
1
1. newPict : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newPict → KILLED |
return pict; |
| 393 | } | |
| 394 | ||
| 395 | /// Creates a new [SdtBlock] object containing the provided inner object. | |
| 396 | /// | |
| 397 | /// @param innerObj The object to be included in the new structured document tag block. | |
| 398 | /// | |
| 399 | /// @return A new [SdtBlock] object containing the provided inner object. | |
| 400 | public static SdtBlock newSdtBlock(Object innerObj) { | |
| 401 | var block = new SdtContentBlock(); | |
| 402 | var blockContent = block.getContent(); | |
| 403 | blockContent.add(innerObj); | |
| 404 | var sdtBlock = new SdtBlock(); | |
| 405 |
1
1. newSdtBlock : removed call to org/docx4j/wml/SdtBlock::setSdtContent → KILLED |
sdtBlock.setSdtContent(block); |
| 406 |
1
1. newSdtBlock : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newSdtBlock → KILLED |
return sdtBlock; |
| 407 | } | |
| 408 | ||
| 409 | /// Creates a new [SdtRun] object containing the provided inner object. | |
| 410 | /// | |
| 411 | /// @param innerObj The object to be included in the new structured document tag run. | |
| 412 | /// | |
| 413 | /// @return A new [SdtRun] object containing the provided inner object. | |
| 414 | public static SdtRun newSdtRun(Object innerObj) { | |
| 415 | var sdtContentRun = new CTSdtContentRun(); | |
| 416 | var sdtContentRunContent = sdtContentRun.getContent(); | |
| 417 | sdtContentRunContent.add(innerObj); | |
| 418 | var sdtRun = new SdtRun(); | |
| 419 |
1
1. newSdtRun : removed call to org/docx4j/wml/SdtRun::setSdtContent → KILLED |
sdtRun.setSdtContent(sdtContentRun); |
| 420 |
1
1. newSdtRun : replaced return value with null for pro/verron/officestamper/utils/wml/WmlFactory::newSdtRun → KILLED |
return sdtRun; |
| 421 | } | |
| 422 | } | |
Mutations | ||
| 40 |
1.1 |
|
| 43 |
1.1 |
|
| 52 |
1.1 |
|
| 61 |
1.1 |
|
| 70 |
1.1 |
|
| 83 |
1.1 |
|
| 92 |
1.1 |
|
| 102 |
1.1 |
|
| 103 |
1.1 |
|
| 104 |
1.1 |
|
| 119 |
1.1 |
|
| 123 |
1.1 2.2 3.3 |
|
| 124 |
1.1 |
|
| 129 |
1.1 2.2 |
|
| 141 |
1.1 |
|
| 150 |
1.1 |
|
| 159 |
1.1 |
|
| 171 |
1.1 |
|
| 189 |
1.1 |
|
| 214 |
1.1 2.2 |
|
| 228 |
1.1 |
|
| 240 |
1.1 |
|
| 251 |
1.1 |
|
| 252 |
1.1 |
|
| 253 |
1.1 |
|
| 264 |
1.1 |
|
| 265 |
1.1 |
|
| 266 |
1.1 |
|
| 277 |
1.1 |
|
| 278 |
1.1 |
|
| 279 |
1.1 |
|
| 286 |
1.1 |
|
| 293 |
1.1 |
|
| 300 |
1.1 |
|
| 312 |
1.1 |
|
| 313 |
1.1 |
|
| 315 |
1.1 |
|
| 328 |
1.1 |
|
| 335 |
1.1 |
|
| 343 |
1.1 |
|
| 344 |
1.1 |
|
| 345 |
1.1 |
|
| 357 |
1.1 |
|
| 360 |
1.1 |
|
| 367 |
1.1 |
|
| 378 |
1.1 |
|
| 379 |
1.1 |
|
| 380 |
1.1 |
|
| 392 |
1.1 |
|
| 405 |
1.1 |
|
| 406 |
1.1 |
|
| 419 |
1.1 |
|
| 420 |
1.1 |