reportlab/platypus/doctemplate.py
changeset 2200 be0cfccc662a
parent 2196 c04e09c8635e
child 2216 aadcd9dc9480
equal deleted inserted replaced
2199:a103025414f5 2200:be0cfccc662a
     1 #copyright ReportLab Inc. 2000
     1 #copyright ReportLab Inc. 2000
     2 #see license.txt for license details
     2 #see license.txt for license details
     3 #history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/platypus/doctemplate.py?cvsroot=reportlab
     3 #history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/platypus/doctemplate.py?cvsroot=reportlab
     4 #$Header: /tmp/reportlab/reportlab/platypus/doctemplate.py,v 1.71 2004/01/13 11:20:45 rgbecker Exp $
     4 #$Header: /tmp/reportlab/reportlab/platypus/doctemplate.py,v 1.72 2004/01/20 22:50:31 andy_robinson Exp $
     5 
     5 
     6 __version__=''' $Id: doctemplate.py,v 1.71 2004/01/13 11:20:45 rgbecker Exp $ '''
     6 __version__=''' $Id: doctemplate.py,v 1.72 2004/01/20 22:50:31 andy_robinson Exp $ '''
     7 
     7 
     8 __doc__="""
     8 __doc__="""
     9 This module contains the core structure of platypus.
     9 This module contains the core structure of platypus.
    10 
    10 
    11 Platypus constructs documents.  Document styles are determined by DocumentTemplates.
    11 Platypus constructs documents.  Document styles are determined by DocumentTemplates.
   113     def __call__(self):
   113     def __call__(self):
   114         return self
   114         return self
   115 
   115 
   116     def identity(self, maxLen=None):
   116     def identity(self, maxLen=None):
   117         return "ActionFlowable: %s" % str(self.action)
   117         return "ActionFlowable: %s" % str(self.action)
   118     
   118 
   119 class NextFrameFlowable(ActionFlowable):
   119 class NextFrameFlowable(ActionFlowable):
   120     def __init__(self,ix,resume=0):
   120     def __init__(self,ix,resume=0):
   121         ActionFlowable.__init__(self,('nextFrame',ix,resume))
   121         ActionFlowable.__init__(self,('nextFrame',ix,resume))
   122 
   122 
   123 class CurrentFrameFlowable(ActionFlowable):
   123 class CurrentFrameFlowable(ActionFlowable):
   145 class Indenter(ActionFlowable):
   145 class Indenter(ActionFlowable):
   146     """Increases or decreases left and right margins of frame.
   146     """Increases or decreases left and right margins of frame.
   147 
   147 
   148     This allows one to have a 'context-sensitive' indentation
   148     This allows one to have a 'context-sensitive' indentation
   149     and makes nested lists way easier.
   149     and makes nested lists way easier.
   150     """    
   150     """
   151 
   151 
   152     def __init__(self, left=0, right=0):
   152     def __init__(self, left=0, right=0):
   153         self.left = left
   153         self.left = left
   154         self.right = right
   154         self.right = right
   155 
   155 
   156     def apply(self, doc):
   156     def apply(self, doc):
   157         doc.frame._leftExtraIndent = doc.frame._leftExtraIndent + self.left
   157         doc.frame._leftExtraIndent = doc.frame._leftExtraIndent + self.left
   158         doc.frame._rightExtraIndent = doc.frame._rightExtraIndent + self.right
   158         doc.frame._rightExtraIndent = doc.frame._rightExtraIndent + self.right
   159         
   159 
   160 
   160 
   161 class NextPageTemplate(ActionFlowable):
   161 class NextPageTemplate(ActionFlowable):
   162     """When you get to the next page, use the template specified (change to two column, for example)  """
   162     """When you get to the next page, use the template specified (change to two column, for example)  """
   163     def __init__(self,pt):
   163     def __init__(self,pt):
   164         ActionFlowable.__init__(self,('nextPageTemplate',pt))
   164         ActionFlowable.__init__(self,('nextPageTemplate',pt))
   318         self._emptyPagesAllowed = 10
   318         self._emptyPagesAllowed = 10
   319 
   319 
   320         #context sensitive margins - set by story, not from outside
   320         #context sensitive margins - set by story, not from outside
   321         self._leftExtraIndent = 0.0
   321         self._leftExtraIndent = 0.0
   322         self._rightExtraIndent = 0.0
   322         self._rightExtraIndent = 0.0
   323         
   323 
   324         self._calc()
   324         self._calc()
   325         self.afterInit()
   325         self.afterInit()
   326 
   326 
   327     def _calc(self):
   327     def _calc(self):
   328         self._rightMargin = self.pagesize[0] - self.rightMargin
   328         self._rightMargin = self.pagesize[0] - self.rightMargin
   424 
   424 
   425     def handle_frameEnd(self,resume=0):
   425     def handle_frameEnd(self,resume=0):
   426         ''' Handles the semantics of the end of a frame. This includes the selection of
   426         ''' Handles the semantics of the end of a frame. This includes the selection of
   427             the next frame or if this is the last frame then invoke pageEnd.
   427             the next frame or if this is the last frame then invoke pageEnd.
   428         '''
   428         '''
   429         
   429 
   430         self._leftExtraIndent = self.frame._leftExtraIndent
   430         self._leftExtraIndent = self.frame._leftExtraIndent
   431         self._rightExtraIndent = self.frame._rightExtraIndent
   431         self._rightExtraIndent = self.frame._rightExtraIndent
   432 
   432 
   433         if hasattr(self,'_nextFrameIndex'):
   433         if hasattr(self,'_nextFrameIndex'):
   434             frame = self.pageTemplate.frames[self._nextFrameIndex]
   434             frame = self.pageTemplate.frames[self._nextFrameIndex]