Next / Previous / Contents / Shipman's homepage

13. buildPageSequenceMaster()

The element we build here is a page-sequence-master; it defines which simple page master is used in which conditions. In general, the child of this element may be either a single-page-master-reference (for one page total), a repeatable-page-master-reference (to use the same master for every page), or a repeatable-page-master-alternatives for the general case where different page masters are used in different cases.

Although simplex printing could be implemented with a repeatable-page-master-reference, to simplify the logic here, we always use a repeatable-page-master-alternatives. This node in turn has one or more conditional-page-master-reference children; we will use two for duplex printing, and only one for simplex.

# - - -   b u i l d P a g e S e q u e n c e M a s t e r

def buildPageSequenceMaster(tree, bodyLayout):
    '''Set up the rules that select a simple page master.

      [ (tree is an h.FlowTree instance) and
        (bodyLayout is a BodyLayout instance) ->
          tree.masters  +:=  a page-sequence-master named REPEAT_MASTER
              representing Args() and bodyLayout ]
    #-- 1
    # [ if Args().duplex ->
    #     condList  :=  two conditional-page-master-reference
    #         elements, for ODD_MASTER on odd pages and EVEN_MASTER
    #         on even pages
    #   else ->
    #     condList  +:=  a list of one conditional-page-master-reference
    #         for ODD_MASTER ]
    if Args().duplex:
        condList = [ h.conditionalMaster(ODD_MASTER, oddEven='odd'),
                     h.conditionalMaster(EVEN_MASTER, oddEven='even') ]
        condList = [ h.conditionalMaster(ODD_MASTER) ]

    #-- 2
    # [ tree.masters  +:=  a new page-sequence-master node named
    #       REPEAT_MASTER with child nodes [condList ] ]
        h.repeatMaster(REPEAT_MASTER, *condList))