From f3bf31ac5da946ea8009fdf8eb85709fed0796ba Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Tue, 15 Jul 2025 14:08:14 +0100 Subject: [PATCH] avoid creating CTUnderline --- .../apache/poi/xwpf/usermodel/XWPFRun.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java index 3c0ac9eb89..29339e1453 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java @@ -600,16 +600,17 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun { * @since 4.0.0 */ public String getUnderlineColor() { - CTUnderline underline = getCTUnderline(true); - assert(underline != null); String colorName = "auto"; - Object rawValue = underline.getColor(); - if (rawValue != null) { - if (rawValue instanceof String) { - colorName = (String)rawValue; - } else { - byte[] rgbColor = (byte[])rawValue; - colorName = HexDump.toHex(rgbColor[0]) + HexDump.toHex(rgbColor[1]) + HexDump.toHex(rgbColor[2]); + CTUnderline underline = getCTUnderline(false); + if (underline != null) { + Object rawValue = underline.getColor(); + if (rawValue != null) { + if (rawValue instanceof String) { + colorName = (String) rawValue; + } else { + byte[] rgbColor = (byte[]) rawValue; + colorName = HexDump.toHex(rgbColor[0]) + HexDump.toHex(rgbColor[1]) + HexDump.toHex(rgbColor[2]); + } } } return colorName;