# - - - f o r m a t L i n e def formatLine ( flow, depth, sectionId, titleInline ): '''Build the block containing one line of the report. [ (flow is an et.Element) and (depth is a nonnegative int) and (sectionId is the section ID as a string) and (titleInline is an FO inline) -> flow +:= a block displaying sectionId and titleInline, indented by (depth) levels ] '''
For notes on the design of this block element, see Section 5.4, “The report format”. Our first task is to compute the
text-indent dimensions for the block. These computations are
functions of the indentation depth and the constants
Section 6.3.20, “
INDENT_PER_LEVEL” and Section 6.3.21, “
#-- 1 # [ startIndent := an h.FoDim instance representing # (CONTINUED_INDENT + depth * INDENT_PER_LEVEL) # textIndent := an h.FoDim instance representing # (- CONTINUED_INDENT) ] startIndent = CONTINUED_INDENT + INDENT_PER_LEVEL*depth textIndent = - CONTINUED_INDENT #-- 2 # [ flow +:= a new block element with font BODY_FONT # block := that block element ] block = subElement(flow, h.block(BODY_FONT, h.dash(startIndent=str(startIndent), textIndent=str(textIndent))))
sectionId is wrapped in an inline that
uses a monospaced font. The offset
PRE_TITLE between that inline and the following
text is implemented as a
property on the inline.
#-- 3 # [ block +:= an inline containing sectionId in monospaced # font, with PRE_TITLE right padding ] idInline = subElement(block, h.inline(ID_FONT, sectionId, h.dash(paddingRight=str(PRE_TITLE))))
Finally, add the FO-rendered title text.
#-- 3 block.append(titleInline)