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();
}
}
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;
}
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);
}
Aggregations