log.warn("Encountered table with no rows");
return;
}
// Req 1: Make sure the last row is not a header row
Tr lastRow = rows.get(numRows-1);
if (isHeaderRow(lastRow)) {
List<JAXBElement<?>> cnfStyleOrDivIdOrGridBefore = lastRow.getTrPr().getCnfStyleOrDivIdOrGridBefore();
JAXBElement tblHeader = getElement(cnfStyleOrDivIdOrGridBefore, "tblHeader");
cnfStyleOrDivIdOrGridBefore.remove(tblHeader);
}
// Req 2: All rows before last header row become header rows
// .. find last header row
int indexOfLastHeaderRow=-1;
for (int i = rows.size(); i>0; i--) {
Tr tr = rows.get(i-1);
if (isHeaderRow(tr)) {
indexOfLastHeaderRow = i-1;
break;
}
}
// .. now convert all rows up to that one
for (int i = 0; i<indexOfLastHeaderRow; i++) {
Tr tr = rows.get(i);
if (!isHeaderRow(tr)) {
// make it so...
TrPr trpr = null;
if (tr.getTrPr() == null) {
trpr = Context.getWmlObjectFactory().createTrPr();
tr.setTrPr(trpr);
}
// Create object for tblHeader (wrapped in JAXBElement)
BooleanDefaultTrue booleandefaulttrue = Context.getWmlObjectFactory().createBooleanDefaultTrue();
JAXBElement<org.docx4j.wml.BooleanDefaultTrue> booleandefaulttrueWrapped
= Context.getWmlObjectFactory().createCTTrPrBaseTblHeader(booleandefaulttrue);