diff options
author | Nick Burch <nick@apache.org> | 2013-06-12 18:04:16 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2013-06-12 18:04:16 +0000 |
commit | 9228ac464deee5655f08438b8099ca0fd0595c60 (patch) | |
tree | bd6c61a40efeeb4f113f8246c0b0db65952b0cc9 /src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java | |
parent | 7341e677fbd49cbf691cbd6471b73252122a106b (diff) | |
download | poi-9228ac464deee5655f08438b8099ca0fd0595c60.tar.gz poi-9228ac464deee5655f08438b8099ca0fd0595c60.zip |
Patch from akhikhl from github pull #4 - Expose from XWPFParagraph the number level and format, if applied
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1492312 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java')
-rw-r--r-- | src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java index 383fa13e68..ff2ef88181 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java @@ -25,11 +25,13 @@ import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.util.Internal; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlObject; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTAbstractNum; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdnRef; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHyperlink; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTInd; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTJc; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLvl; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPBdr; @@ -217,6 +219,50 @@ public class XWPFParagraph implements IBodyElement { } /** + * Returns Ilvl of the numeric style for this paragraph. + * Returns null if this paragraph does not have numeric style. + * @return Ilvl as BigInteger + */ + public BigInteger getNumIlvl() { + if(paragraph.getPPr()!=null){ + if(paragraph.getPPr().getNumPr()!=null){ + if(paragraph.getPPr().getNumPr().getIlvl()!=null) + return paragraph.getPPr().getNumPr().getIlvl().getVal(); + } + } + return null; + } + + /** + * Returns numbering format for this paragraph, eg bullet or + * lowerLetter. + * Returns null if this paragraph does not have numeric style. + */ + public String getNumFmt() { + BigInteger numID = getNumID(); + XWPFNumbering numbering = document.getNumbering(); + if(numID != null && numbering != null) { + XWPFNum num = numbering.getNum(numID); + if(num != null) { + BigInteger ilvl = getNumIlvl(); + BigInteger abstractNumId = num.getCTNum().getAbstractNumId().getVal(); + CTAbstractNum anum = numbering.getAbstractNum(abstractNumId).getAbstractNum(); + CTLvl level = null; + for(int i = 0; i < anum.sizeOfLvlArray(); i++) { + CTLvl lvl = anum.getLvlArray(i); + if(lvl.getIlvl().equals(ilvl)) { + level = lvl; + break; + } + } + if(level != null) + return level.getNumFmt().getVal().toString(); + } + } + return null; + } + + /** * setNumID of Paragraph * @param numPos */ @@ -1300,4 +1346,4 @@ public class XWPFParagraph implements IBodyElement { return null; } -}//end class
\ No newline at end of file +} |