Context ic = (Context) oc.clone();
ic.setInTable(true);
// Apply table style
boolean bApplyCellFormat = config.formatting()>=Config.CONVERT_MOST;
TableFormatter formatter = palette.getTableSc().getTableFormatter(table,
!ic.isInMulticols(), bApplyCellFormat);
// We may need a hyperlink target
if (!formatter.isSubtable()) {
palette.getFieldCv().addTarget(node,"|table",ldp);
}
// Export table declaration
BeforeAfter baTable = new BeforeAfter();
formatter.applyTableStyle(baTable);
ldp.append(baTable.getBefore()).nl();
// Export rows
if (bApplyCellFormat || !formatter.isLongtable()) { ic.setNoFootnotes(true); }
int nRowCount = table.getRowCount();
int nColCount = table.getColCount();
boolean bInHeader = false;
// Add interrow material before first row:
ldp.append(formatter.getInterrowMaterial(0)).nl();
for (int nRow=0; nRow<nRowCount; nRow++){
// Longtables may have headers:
if (formatter.isLongtable()) {
if (nRow==0 && table.getRow(nRow).isHeader()) {
bInHeader = true;
if (!bApplyCellFormat) { ic.setNoFootnotes(true); }
}
else if (bInHeader && !table.getRow(nRow).isHeader()) {
bInHeader = false;
if (!bApplyCellFormat) { ic.setNoFootnotes(false); }
palette.getNoteCv().flushFootnotes(ldp,oc);
ldp.append("\\endhead").nl();
}
}
// Export columns in this row
int nCol = 0;
while (nCol<nColCount) {
Element cell = (Element) table.getCell(nRow,nCol);
if (XMLString.TABLE_TABLE_CELL.equals(cell.getNodeName())) {
BeforeAfter baCell = new BeforeAfter();
formatter.applyCellStyle(nRow,nCol,baCell);
ldp.append(baCell.getBefore());
traverseBlockText(cell,ldp,ic);
ldp.append(baCell.getAfter());
}
// Otherwise ignore; the cell is covered by a \multicolumn entry.
// (table:covered-table-cell)
int nColSpan = Misc.getPosInteger(cell.getAttribute(
XMLString.TABLE_NUMBER_COLUMNS_SPANNED),1);
if (nCol+nColSpan<nColCount) { ldp.append("&").nl(); }
nCol+=nColSpan;
}
ldp.append("\\\\").append(formatter.getInterrowMaterial(nRow+1)).nl();
}
// End table
ldp.append(baTable.getAfter()).nl();
// Footnotes are now allowed
if (bApplyCellFormat || !formatter.isLongtable()) {
palette.getNoteCv().flushFootnotes(ldp,oc);
}
}