List of usage examples for org.apache.poi.xwpf.usermodel XWPFAbstractNum getAbstractNum
public CTAbstractNum getAbstractNum()
From source file:fr.opensagres.poi.xwpf.converter.core.XWPFDocumentVisitor.java
License:Open Source License
/** * Visit the given paragraph.//from w w w . j av a 2 s . c o m * * @param paragraph * @param index * @param container * @throws Exception */ protected void visitParagraph(XWPFParagraph paragraph, int index, T container) throws Exception { if (isWordDocumentPartParsing()) { // header/footer is not parsing. // It's the word/document.xml which is parsing // test if the current paragraph define a <w:sectPr // to update the header/footer declared in the <w:headerReference/<w:footerReference masterPageManager.update(paragraph.getCTP()); } if (pageBreakOnNextParagraph) { pageBreak(); } this.pageBreakOnNextParagraph = false; ListItemContext itemContext = null; CTNumPr originalNumPr = stylesDocument.getParagraphNumPr(paragraph); CTNumPr numPr = getNumPr(originalNumPr); if (numPr != null) { // paragraph is a numbered/bullet list // see http://msdn.microsoft.com/en-us/library/office/ee922775%28v=office.14%29.aspx // - <w:p> // - <w:pPr> // <w:pStyle w:val="style0" /> // - <w:numPr> // <w:ilvl w:val="0" /> // <w:numId w:val="2" /> // </w:numPr> // get numbering.xml/w:num /** * <w:num w:numId="2"> <w:abstractNumId w:val="1" /> </w:num> */ XWPFNum num = getXWPFNum(numPr); if (num != null) { // get the abstractNum by usisng abstractNumId /** * <w:abstractNum w:abstractNumId="1"> <w:nsid w:val="3CBA6E67" /> <w:multiLevelType * w:val="hybridMultilevel" /> <w:tmpl w:val="7416D4FA" /> - <w:lvl w:ilvl="0" w:tplc="040C0001"> * <w:start w:val="1" /> <w:numFmt w:val="bullet" /> <w:lvlText w:val="o" /> <w:lvlJc w:val="left" /> - * <w:pPr> <w:ind w:left="720" w:hanging="360" /> </w:pPr> - <w:rPr> <w:rFonts w:ascii="Symbol" * w:hAnsi="Symbol" w:hint="default" /> </w:rPr> </w:lvl> */ XWPFAbstractNum abstractNum = getXWPFAbstractNum(num); // get the <w:lvl by using abstractNum and numPr level /** * <w:num w:numId="2"> <w:abstractNumId w:val="1" /> </w:num> */ CTDecimalNumber ilvl = numPr.getIlvl(); int level = ilvl != null ? ilvl.getVal().intValue() : 0; CTLvl lvl = abstractNum.getAbstractNum().getLvlArray(level); if (lvl != null) { ListContext listContext = getListContext(originalNumPr.getNumId().getVal().intValue()); itemContext = listContext.addItem(lvl); } } } T paragraphContainer = startVisitParagraph(paragraph, itemContext, container); visitParagraphBody(paragraph, index, paragraphContainer); endVisitParagraph(paragraph, container, paragraphContainer); }
From source file:fr.opensagres.poi.xwpf.converter.core.XWPFDocumentVisitor.java
License:Open Source License
private CTNumPr getNumPr(CTNumPr numPr) { if (numPr != null) { XWPFNum num = getXWPFNum(numPr); if (num != null) { // get the abstractNum by usisng abstractNumId /**//from ww w . java 2 s .c om * <w:abstractNum w:abstractNumId="1"> <w:nsid w:val="3CBA6E67" /> <w:multiLevelType * w:val="hybridMultilevel" /> <w:tmpl w:val="7416D4FA" /> - <w:lvl w:ilvl="0" w:tplc="040C0001"> * <w:start w:val="1" /> <w:numFmt w:val="bullet" /> <w:lvlText w:val="o" /> <w:lvlJc w:val="left" /> - * <w:pPr> <w:ind w:left="720" w:hanging="360" /> </w:pPr> - <w:rPr> <w:rFonts w:ascii="Symbol" * w:hAnsi="Symbol" w:hint="default" /> </w:rPr> </w:lvl> */ XWPFAbstractNum abstractNum = getXWPFAbstractNum(num); CTString numStyleLink = abstractNum.getAbstractNum().getNumStyleLink(); String styleId = numStyleLink != null ? numStyleLink.getVal() : null; if (styleId != null) { // has w:numStyleLink which reference other style /* * <w:abstractNum w:abstractNumId="0"> <w:nsid w:val="03916EF0"/> <w:multiLevelType * w:val="multilevel"/> <w:tmpl w:val="0409001D"/> <w:numStyleLink w:val="EricsListStyle"/> * </w:abstractNum> */ CTStyle style = stylesDocument.getStyle(styleId); CTPPr ppr = style.getPPr(); if (ppr == null) { return null; } return getNumPr(ppr.getNumPr()); } } } return numPr; }