[github-151] XWPFRun: allow style retrieval. This closes #151

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1860464 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2019-06-01 01:09:40 +00:00
parent 8638dbf9b8
commit 5e33bd4b29
2 changed files with 21 additions and 0 deletions

View File

@ -1213,6 +1213,25 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
style.setVal(styleId);
}
/**
* Return this run's style ID. If this run has no style (no run properties or properties without a style),
* an empty string is returned.
*
* @since 4.1.1
*/
public String getStyle() {
CTRPr pr = getCTR().getRPr();
if (pr == null) {
return "";
}
CTString style = pr.getRStyle();
if (style == null) {
return "";
}
return style.getVal();
}
/**

View File

@ -783,6 +783,8 @@ public class TestXWPFRun {
assertNotNull("Expected to find a run style ID", candStyleId);
assertEquals(styleId, candStyleId);
assertEquals(styleId, run.getStyle());
document.close();
}