git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1889259 13f79535-47bb-0310-9956-ffa450edef68tags/REL_5_1_0
@@ -1248,16 +1248,11 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun { | |||
*/ | |||
public String getStyle() { | |||
CTRPr pr = getCTR().getRPr(); | |||
if (pr == null) { | |||
if (pr == null || pr.sizeOfRStyleArray() <= 0) { | |||
return ""; | |||
} | |||
CTString style = pr.getRStyleArray(0); | |||
if (style == null) { | |||
return ""; | |||
} | |||
return style.getVal(); | |||
return null == style ? "" : style.getVal(); | |||
} | |||
@@ -788,6 +788,17 @@ class TestXWPFRun { | |||
document.close(); | |||
} | |||
@Test | |||
void testGetEmptyStyle() throws IOException { | |||
XWPFDocument document = new XWPFDocument(); | |||
final XWPFRun run = document.createParagraph().createRun(); | |||
assertEquals("", run.getStyle()); | |||
run.getCTR().addNewRPr(); | |||
assertEquals("", run.getStyle()); | |||
document.close(); | |||
} | |||
@Test | |||
void testGetDepthWidth() throws IOException, InvalidFormatException { | |||
try (XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("TestDocument.docx")) { |