*/
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();
}
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")) {