mirror of https://github.com/apache/poi.git
[github-163] Add set level numbering on XWPFParagraph. Thanks to Mi Guoliang. This closes #163
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1871999 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
40da053a4a
commit
d240fb1378
|
@ -264,6 +264,25 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
|
|||
paragraph.getPPr().getNumPr().getNumId().setVal(numPos);
|
||||
}
|
||||
|
||||
/**
|
||||
* setNumILvl of Paragraph
|
||||
*
|
||||
* @param iLvl
|
||||
* @since 4.1.2
|
||||
*/
|
||||
public void setNumILvl(BigInteger iLvl) {
|
||||
if (paragraph.getPPr() == null) {
|
||||
paragraph.addNewPPr();
|
||||
}
|
||||
if (paragraph.getPPr().getNumPr() == null) {
|
||||
paragraph.getPPr().addNewNumPr();
|
||||
}
|
||||
if (paragraph.getPPr().getNumPr().getIlvl() == null) {
|
||||
paragraph.getPPr().getNumPr().addNewIlvl();
|
||||
}
|
||||
paragraph.getPPr().getNumPr().getIlvl().setVal(iLvl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Ilvl of the numeric style for this paragraph.
|
||||
* Returns null if this paragraph does not have numeric style.
|
||||
|
|
|
@ -299,6 +299,16 @@ public final class TestXWPFParagraph {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSetILvl() throws IOException {
|
||||
try (XWPFDocument doc = new XWPFDocument()) {
|
||||
XWPFParagraph p = doc.createParagraph();
|
||||
|
||||
p.setNumILvl(new BigInteger("1"));
|
||||
assertEquals("1", p.getNumIlvl().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddingRuns() throws IOException {
|
||||
try (XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("sample.docx")) {
|
||||
|
|
Loading…
Reference in New Issue