// rPr in pPr direct formatting only applies to paragraph mark,
// and by virtue of that, to list item label,
// so pass null here
// Now, work out the value for list item label
RPr rPrParagraphMark = XmlUtils.deepCopy(rPr);
// System.out.println("p rpr-->" + XmlUtils.marshaltoString(pPrDirect.getRPr()));
if (pPrDirect!=null) {
StyleUtil.apply(pPrDirect.getRPr(), rPrParagraphMark);
}
if (getLog().isDebugEnabled() && pPr!=null) {
getLog().debug(XmlUtils.marshaltoString(pPr, true, true));
}
boolean inlist = false;
boolean indentHandledByNumbering = false;
Element foBlockElement = null;
Element foListBlock = null;
// if (pPr!=null && pPr.getNumPr()!=null ) {
if (pPr!=null
&& pPr.getNumPr()!=null
&& pPr.getNumPr().getNumId()!=null
&& pPr.getNumPr().getNumId().getVal().longValue()!=0 //zero means no numbering
) {
inlist = true;
// Its a list item. At present we make a new list-block for
// each list-item. This is not great; DocumentModel will ultimately
// allow us to use fo:list-block properly.
foListBlock = document.createElementNS(XSL_FO,
"list-block");
currentParent.appendChild(foListBlock);
// That's different to XSL.
// Here we end up with block/list-block
// cf XSL, where the logic avoids creating 2 elements.
// May be easy to fix, if instead of passing in
// currentParent, we return block or list-block
// from here, and appendChild in the calling code.
// foListBlock.setAttribute("provisional-distance-between-starts", "0.5in");
// Need to apply shading at fo:list-block level
if (pPr.getShd()!=null) {
PShading pShading = new PShading(pPr.getShd());
pShading.setXslFO(foListBlock);
}
Element foListItem = document.createElementNS(XSL_FO,
"list-item");
foListBlock.appendChild(foListItem);
Element foListItemLabel = document.createElementNS(XSL_FO,
"list-item-label");
foListItem.appendChild(foListItemLabel);
Element foListItemLabelBody = document.createElementNS(XSL_FO,
"block");
foListItemLabel.appendChild(foListItemLabelBody);
Element foListItemBody = document.createElementNS("http://www.w3.org/1999/XSL/Format",
"fo:list-item-body");
foListItem.appendChild(foListItemBody);
foListItemBody.setAttribute(Indent.FO_NAME, "body-start()");
ResultTriple triple;
if (pPrDirect!=null && pPrDirect.getNumPr()!=null) {
triple = org.docx4j.model.listnumbering.Emulator.getNumber(
conversionContext.getWmlPackage(), pStyleVal,
pPrDirect.getNumPr().getNumId().getVal().toString(),
pPrDirect.getNumPr().getIlvl().getVal().toString() );
} else {
// Get the effective values; since we already know this,
// save the effort of doing this again in Emulator
Ilvl ilvl = pPr.getNumPr().getIlvl();
String ilvlString = ilvl == null ? "0" : ilvl.getVal().toString();
triple = null;
if (pPr.getNumPr().getNumId()!=null) {
triple = org.docx4j.model.listnumbering.Emulator.getNumber(
conversionContext.getWmlPackage(), pStyleVal,
pPr.getNumPr().getNumId().getVal().toString(),
ilvlString );
}
}
if (triple==null) {
getLog().warn("computed number ResultTriple was null");
if (getLog().isDebugEnabled() ) {
foListItemLabelBody.setTextContent("nrt");
}
} else {
/* Format the list item label
*
* Since it turns out (in FOP at least) that the label and the body
* don't have the same vertical alignment
* unless font size is applied at the same level
* (ie to both -label and -body, or to the block inside each),
* we have to format the list-item-body as well.
* This issue only manifests itself if the font size on
* the outer list-block is larger than the font sizes
* set inside it.
*/
// OK just to override specific values
// Values come from numbering rPr, unless overridden in p-level rpr
if(triple.getRPr()==null) {
if (pPr.getRPr()==null) {
// do nothing, since we're already inheriting the formatting in the style
// (as opposed to the paragraph mark formatting)
// EXCEPT for font
XsltFOFunctions.setFont( conversionContext, foListItemLabelBody, pPr, rPr, triple.getNumString());
} else {
createFoAttributes(conversionContext.getWmlPackage(), rPrParagraphMark, foListItemLabel );
createFoAttributes(conversionContext.getWmlPackage(), rPrParagraphMark, foListItemBody );
XsltFOFunctions.setFont( conversionContext, foListItemLabelBody, pPr, rPrParagraphMark, triple.getNumString());
}
} else {
RPr actual = XmlUtils.deepCopy(triple.getRPr()); // clone, so the ilvl rpr is not altered
// System.out.println(XmlUtils.marshaltoString(rPrParagraphMark));
// pMark overrides numbering, except for font
// (which makes sense, since that would change the bullet)
// so set the font