FOConversionContext context,
NodeIterator pPrNodeIt,
String pStyleVal, NodeIterator childResults,
boolean sdt) {
PropertyResolver propertyResolver = context.getPropertyResolver();
// Note that this is invoked for every paragraph with a pPr node.
// incoming objects are org.apache.xml.dtm.ref.DTMNodeIterator
// which implements org.w3c.dom.traversal.NodeIterator
Style defaultParagraphStyle =
(context.getWmlPackage().getMainDocumentPart().getStyleDefinitionsPart(false) != null ?
context.getWmlPackage().getMainDocumentPart().getStyleDefinitionsPart(false).getDefaultParagraphStyle() :
null);
String defaultParagraphStyleId;
if (defaultParagraphStyle==null) // possible, for non MS source docx
defaultParagraphStyleId = "Normal";
else defaultParagraphStyleId = defaultParagraphStyle.getStyleId();
if ( pStyleVal ==null || pStyleVal.equals("") ) {
// pStyleVal = "Normal";
pStyleVal = defaultParagraphStyleId;
}
if (log.isDebugEnabled()) {
log.debug("style '" + pStyleVal );
}
// log.info("pPrNode:" + pPrNodeIt.getClass().getName() ); // org.apache.xml.dtm.ref.DTMNodeIterator
// log.info("childResults:" + childResults.getClass().getName() );
try {
PPr pPrDirect = null;
// Get the pPr node as a JAXB object,
// so we can read it using our standard
// methods. Its a bit sad that we
// can't just adorn our DOM tree with the
// original JAXB objects?
PPr pPr = null;
RPr rPr = null;
RPr rPrParagraphMark = null; // required for list item label
if (pPrNodeIt==null) { // Never happens?
if (log.isDebugEnabled()) {
log.debug("Here after all!!");
}
pPr = propertyResolver.getEffectivePPr(defaultParagraphStyleId);
rPr = propertyResolver.getEffectiveRPr(defaultParagraphStyleId);
rPrParagraphMark = rPr;
} else {
Node n = pPrNodeIt.nextNode();
if (n==null) {
if (log.isDebugEnabled()) {
log.debug("pPrNodeIt.nextNode() was null (ie there is no pPr in this p)");
}
pPr = propertyResolver.getEffectivePPr(defaultParagraphStyleId);
rPr = propertyResolver.getEffectiveRPr(defaultParagraphStyleId);
// TODO - in this case, we should be able to compute once,
// and on subsequent calls, just return pre computed value
} else {
if (log.isDebugEnabled()) {
log.debug( "P actual pPr: "+ XmlUtils.w3CDomNodeToString(n) );
}
Unmarshaller u = Context.jc.createUnmarshaller();
u.setEventHandler(new org.docx4j.jaxb.JaxbValidationEventHandler());
Object jaxb = u.unmarshal(n);
pPrDirect = (PPr)jaxb;
pPr = propertyResolver.getEffectivePPr(pPrDirect);
if ((pPr==null) && (log.isDebugEnabled())) {
log.debug("pPr null; obtained from: " + XmlUtils.w3CDomNodeToString(n) );
}
// On the block representing the w:p, we want to put both
// pPr and rPr attributes.
if (log.isDebugEnabled()) {
log.debug("getting rPr for paragraph style");
}
rPr = propertyResolver.getEffectiveRPr(null, pPrDirect);
// 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
rPrParagraphMark = XmlUtils.deepCopy(rPr);