Search in sources :

Example 1 with CTAbstractNum

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTAbstractNum in project poi by apache.

the class XWPFNumbering method onDocumentRead.

/**
     * read numbering form an existing package
     */
@Override
protected void onDocumentRead() throws IOException {
    NumberingDocument numberingDoc = null;
    InputStream is;
    is = getPackagePart().getInputStream();
    try {
        numberingDoc = NumberingDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
        ctNumbering = numberingDoc.getNumbering();
        //get any Nums
        for (CTNum ctNum : ctNumbering.getNumArray()) {
            nums.add(new XWPFNum(ctNum, this));
        }
        for (CTAbstractNum ctAbstractNum : ctNumbering.getAbstractNumArray()) {
            abstractNums.add(new XWPFAbstractNum(ctAbstractNum, this));
        }
        isNew = false;
    } catch (XmlException e) {
        throw new POIXMLException();
    } finally {
        is.close();
    }
}
Also used : CTNum(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTNum) InputStream(java.io.InputStream) XmlException(org.apache.xmlbeans.XmlException) POIXMLException(org.apache.poi.POIXMLException) NumberingDocument(org.openxmlformats.schemas.wordprocessingml.x2006.main.NumberingDocument) CTAbstractNum(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTAbstractNum)

Example 2 with CTAbstractNum

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTAbstractNum in project poi by apache.

the class XWPFNumbering method getIdOfAbstractNum.

/**
     * Compare AbstractNum with abstractNums of this numbering document.
     * If the content of abstractNum equals with an abstractNum of the List in numbering
     * the BigInteger Value of it will be returned.
     * If no equal abstractNum is existing null will be returned
     *
     * @param abstractNum
     * @return BigInteger
     */
public BigInteger getIdOfAbstractNum(XWPFAbstractNum abstractNum) {
    CTAbstractNum copy = (CTAbstractNum) abstractNum.getCTAbstractNum().copy();
    XWPFAbstractNum newAbstractNum = new XWPFAbstractNum(copy, this);
    int i;
    for (i = 0; i < abstractNums.size(); i++) {
        newAbstractNum.getCTAbstractNum().setAbstractNumId(BigInteger.valueOf(i));
        newAbstractNum.setNumbering(this);
        if (newAbstractNum.getCTAbstractNum().valueEquals(abstractNums.get(i).getCTAbstractNum())) {
            return newAbstractNum.getCTAbstractNum().getAbstractNumId();
        }
    }
    return null;
}
Also used : CTAbstractNum(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTAbstractNum)

Example 3 with CTAbstractNum

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTAbstractNum in project tika by apache.

the class XWPFListManager method loadLevelTuples.

private ParagraphLevelCounter loadLevelTuples(CTDecimalNumber abNum) {
    //Unfortunately, we need to go this far into the underlying structure
    //to get the abstract num information for the edge case where
    //someone skips a level and the format is not context-free, e.g. "1.B.i".
    XWPFAbstractNum abstractNum = numbering.getAbstractNum(abNum.getVal());
    CTAbstractNum ctAbstractNum = abstractNum.getCTAbstractNum();
    LevelTuple[] levels = new LevelTuple[ctAbstractNum.sizeOfLvlArray()];
    for (int i = 0; i < levels.length; i++) {
        levels[i] = buildTuple(i, ctAbstractNum.getLvlArray(i));
    }
    return new ParagraphLevelCounter(levels);
}
Also used : XWPFAbstractNum(org.apache.poi.xwpf.usermodel.XWPFAbstractNum) CTAbstractNum(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTAbstractNum)

Aggregations

CTAbstractNum (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTAbstractNum)3 InputStream (java.io.InputStream)1 POIXMLException (org.apache.poi.POIXMLException)1 XWPFAbstractNum (org.apache.poi.xwpf.usermodel.XWPFAbstractNum)1 XmlException (org.apache.xmlbeans.XmlException)1 CTNum (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTNum)1 NumberingDocument (org.openxmlformats.schemas.wordprocessingml.x2006.main.NumberingDocument)1