emitRow method
Prints a single line —— regardless of whether it comes from the main report, or from a sub-report at any nesting level (device="sub").
A WML sub-report "rides along with" the main report: it has no output device of its own, and its rows are merged directly into the main report's page flow. So every row must go through this single exit point, which handles everything uniformly:
- If the current page is full (wapLineNo >= wapLpp) → close the page, break, and reprint the page header and column headers
- Increment the line count
- Emit this row
This way, no matter how many levels of sub-reports are nested, pagination stays correct — every level just calls emitRow() and never has to manage wapLineNo or page breaks itself.
Note: a page break can land in the middle of a sub-report (a single main record's sub-report can get split across two pages). This is the price of "exact lines per page", and is also the default behavior of most reporting tools.
Implementation
void emitRow(String html, {bool isHeader = false, bool isFooter = false}) {
if (wap.wapLineNo >= wap.wapLpp) {
_newPageEnd();
wap.wapBlockId = 'PAGEBREAK';
parseBlock('PAGEBREAK');
_newPageStart(); // includes wapLineNo = 0 + reprinting the page header/column headers
}
wap.wapLineNo++;
emit(html, isHeader: isHeader, isFooter: isFooter);
}