in freemarker-docgen-core/src/main/java/org/freemarker/docgen/core/TableSimplifier.java [425:483]
private void decorateCell(
Element cell, Alignment trAlign, VAlignment trVAlign)
throws SAXException, DocgenException {
Alignment cellAlign = null;
VAlignment cellVAlign = null;
int rowSpan = 1;
int colSpan = 1;
String elemName = cell.getLocalName();
NamedNodeMap atts = cell.getAttributes();
int attCnt = atts.getLength();
fetchAtts: for (int attIdx = 0; attIdx < attCnt; attIdx++) {
Attr att = (Attr) atts.item(attIdx);
String attNS = att.getNamespaceURI();
if (attNS != null && attNS.length() != 0) {
continue fetchAtts;
}
String attName = att.getLocalName();
String attValue = att.getValue().trim();
if (attName.equals(A_ALIGN)) {
cellAlign = parseAlignAttribute(attValue, elemName);
} else if (attName.equals(A_VALIGN)) {
cellVAlign = parseVAlignAttribute(attValue, elemName);
} else if (attName.equals(A_ROWSPAN)) {
rowSpan = parseSpanAttribute(attValue, A_ROWSPAN, elemName);
} else if (attName.equals(A_COLSPAN)) {
colSpan = parseSpanAttribute(attValue, A_COLSPAN, elemName);
} else {
throw new DocgenException("The \"" + attName
+ "\" attribute of the \"" + elemName
+ "\" element is not supported by Docgen.");
}
} // fetchAtts
int visualCol = addCellToCellMatrix(rowSpan, colSpan);
if (cellAlign == null) {
Alignment colGroupAlign = colGroupAligns.size() > visualCol
? colGroupAligns.get(visualCol)
: null;
// Column-scope horizontal alignment has precedence over row-scope
if (colGroupAlign != null && trAlign != colGroupAlign) {
cell.setAttribute(A_ALIGN, colGroupAlign.toString());
}
}
// Row-scope vertical alignment has precedence over column-scope
if (cellVAlign == null && trVAlign == null) {
VAlignment colGroupVAlign = colGroupVAligns.size() > visualCol
? colGroupVAligns.get(visualCol)
: null;
if (colGroupVAlign != null) {
cell.setAttribute(A_VALIGN, colGroupVAlign.toString());
}
}
}