use of org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart in project flexmark-java by vsch.
the class CoreNodeDocxRenderer method renderListItem.
private void renderListItem(final ListItem node, final DocxRendererContext docx) {
final int nesting = node.countDirectAncestorsOfType(ListItem.class, BulletList.class, OrderedList.class);
final DocxRendererOptions options = docx.getDocxRendererOptions();
final String listTextStyle = listOptions.isTightListItem(node) ? options.TIGHT_PARAGRAPH_STYLE : options.LOOSE_PARAGRAPH_STYLE;
final boolean inBlockQuote = node.getAncestorOfType(BlockQuote.class) != null;
final boolean wantNumbered = node instanceof OrderedListItem;
// + (inBlockQuote ? 2 : 0);
long numId = (wantNumbered ? 3 : 2);
int newNum = 1;
final int listLevel = nesting - 1;
final NumberingDefinitionsPart ndp = docx.getDocxDocument().getNumberingDefinitionsPart();
if (node.getParent() instanceof OrderedList) {
if (node == node.getParent().getFirstChild()) {
newNum = listOptions.isOrderedListManualStart() ? ((OrderedList) node.getParent()).getStartNumber() : 1;
numId = ndp.restart(numId, listLevel, newNum);
ensureNumberedListLength(listLevel);
numberedLists[listLevel] = numId;
} else {
numId = numberedLists[listLevel];
}
} else if (node.getParent() instanceof BulletList) {
if (node == node.getParent().getFirstChild()) {
newNum = 1;
numId = ndp.restart(numId, listLevel, newNum);
ensureBulletListLength(listLevel);
bulletLists[listLevel] = numId;
} else {
numId = bulletLists[listLevel];
}
}
final long idNum = numId;
docx.setBlockFormatProvider(new ListItemBlockFormatProvider<Node>(docx, listTextStyle, idNum, listLevel, ListItem.class, ListBlock.class));
docx.renderChildren(node);
}
Aggregations