Next / Previous / Contents / TCC Help System / NM Tech homepage

45.6. PhysRow._rowAttributes(): Decorate a physical row

The purpose of this method is to assemble a set of attributes to be added to the table-row element depending on this physical row's position within the set of physical rows in a logical row.

Also, all physical rows but the first carry a keep-with-previous='within-page' attribute so that in multi-page tables the page breaks will fall between logical rows.

We'll build a dictionary named attrs dictionary with these attributes.

cbchistlib.py
# - - -   P h y s R o w . _ r o w A t t r i b u t e s

    def _rowAttributes(self, rowx, nRows):
        '''Compute physical row attributes by its position in the set.

          [ (0 <= rowx < nRows) ->
              return the set of XSL-FO attributes appropriate for the
              table-row element that has position (rowx) within a set
              of (nRows) physical rows comprising a logical row ]
        '''
        #-- 1
        attrs = {}

        #-- 2
        # [ if rowx is zero ->
        #     attrs  +:=  a border-top-width=FO_THICK_DIM attribute
        #   else if rowx is a multiple of ROW_GROUPING ->
        #     attrs  +:=  a border-top-width=FO_MED_DIM attribute
        #   else -> I ]
        if rowx==0:
            attrs.update(fo.dash(borderTopWidth=FO_THICK_DIM))
        elif (rowx % ROW_GROUPING) == 0:
            attrs.update(fo.dash(borderTopWidth=FO_MED_DIM))

        #-- 3
        # [ if rowx == (nRows-1) ->
        #     attrs  +:=  a border-bottom-width]=FO_THICK_DIM
        #   else -> I ]
        if rowx == (nRows-1):
            attrs.update(fo.dash(borderBottomWidth=FO_THICK_DIM))

        #-- 4
        # [ if rowx is positive ->
        #     attrs  +:=  keep-with-previous.within-page='always'
        #   else -> I ]
        if rowx > 0:
            attrs['keep-with-previous.within-page'] = '1'

        #-- 5
        return attrs