Next / Previous / Contents / Shipman's homepage

24. class OverflowBlock: Overflow continuation block

This class represents an output block that is indented because it is an overflow line. It is derived from Section 22, “class OutBlock: One output block”. The constructor requires no goodBreak argument; this argument applies only to the first block for each input line.

listext2
# - - - - -   c l a s s   O v e r f l o w B l o c k

class OverflowBlock(OutBlock):
    '''Represents an output block for an overflow line.
    '''
    def __init__(self, text, bodyLayout):
        '''Constructor
        '''
        OutBlock.__init__(self, text, False, bodyLayout)

24.1. OverflowBlock.render(): Render an overflow block as XSL-FO

Overflow blocks start with a leader of color OVERFLOW_COLOR; the size is specified by self.bodyLayout.indent.

To implement this colored indent, the author tried and discarded several approaches. A leader element with leader-pattern='space' and a given leader-length attribute does a good job of indenting, but attaching a background-color or color attribute did not work. Wrapping the leader in an inline with an appropriate background-color does work.

listext2
# - - -   O v e r f l o w B l o c k . r e n d e r

    def render(self, parent):
        '''Render the text of an indented overflow block.
        '''
        #-- 1
        # [ parent  +:=  a block element with OUT_BLOCK_PROPS
        #       and additional properties as specified by
        #       Args() and self.__isBreak ]
        block = self.makeBlock(parent)

        #-- 2
        # [ block  +:=  an inline with background color OVERFLOW_COLOR
        #       containing a blank leader of size
        #       self.bodyLayout.indent ]
        block.append(
            E.inline(h.dash(backgroundColor=OVERFLOW_COLOR),
                h.leader(length=str(self.bodyLayout.indent),
                         pattern='space')))

        #-- 3
        # [ block  :=  block with self.text added, rendered as XSL-FO ]
        self.renderLine(block )