mirror of https://github.com/apache/poi.git
[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:
parent
8638dbf9b8
commit
5e33bd4b29
|
@ -1213,6 +1213,25 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
|
||||||
style.setVal(styleId);
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -783,6 +783,8 @@ public class TestXWPFRun {
|
||||||
assertNotNull("Expected to find a run style ID", candStyleId);
|
assertNotNull("Expected to find a run style ID", candStyleId);
|
||||||
assertEquals(styleId, candStyleId);
|
assertEquals(styleId, candStyleId);
|
||||||
|
|
||||||
|
assertEquals(styleId, run.getStyle());
|
||||||
|
|
||||||
document.close();
|
document.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue