Example usage for org.apache.poi.xwpf.usermodel XWPFParagraph getNumID

List of usage examples for org.apache.poi.xwpf.usermodel XWPFParagraph getNumID

Introduction

In this page you can find the example usage for org.apache.poi.xwpf.usermodel XWPFParagraph getNumID.

Prototype

public BigInteger getNumID() 

Source Link

Document

If style exist for this paragraph NumId of the paragraph will be returned.

Usage

From source file:org.apache.tika.parser.microsoft.ooxml.XWPFListManager.java

License:Apache License

/**
 *
 * @param paragraph paragraph//from www.java  2 s  . c o  m
 * @return the formatted number or an empty string if something went wrong
 */
public String getFormattedNumber(final XWPFParagraph paragraph) {
    if (numbering == null) {
        return "";
    }

    int currNumId = paragraph.getNumID().intValue();
    XWPFNum xwpfNum = numbering.getNum(paragraph.getNumID());
    if (xwpfNum == null) {
        return "";
    }
    CTNum ctNum = xwpfNum.getCTNum();
    CTDecimalNumber abNum = ctNum.getAbstractNumId();
    int currAbNumId = abNum.getVal().intValue();

    ParagraphLevelCounter lc = listLevelMap.get(currAbNumId);
    LevelTuple[] overrideTuples = overrideTupleMap.get(currNumId);
    if (lc == null) {
        lc = loadLevelTuples(abNum);
    }
    if (overrideTuples == null) {
        overrideTuples = loadOverrideTuples(ctNum, lc.getNumberOfLevels());
    }

    String formattedString = lc.incrementLevel(paragraph.getNumIlvl().intValue(), overrideTuples);

    listLevelMap.put(currAbNumId, lc);
    overrideTupleMap.put(currNumId, overrideTuples);

    return formattedString;
}