src/reportlab/platypus/doctemplate.py
changeset 4121 3b9e6fa286ad
parent 4067 712e1822ca31
child 4145 f14cb807aa3d
equal deleted inserted replaced
4120:27c73fa46235 4121:3b9e6fa286ad
   289         this page."""
   289         this page."""
   290         pass
   290         pass
   291 
   291 
   292 def _addGeneratedContent(flowables,frame):
   292 def _addGeneratedContent(flowables,frame):
   293     S = getattr(frame,'_generated_content',None)
   293     S = getattr(frame,'_generated_content',None)
   294     if S: 
   294     if S:
   295         flowables[0:0] = S
   295         flowables[0:0] = S
   296         del frame._generated_content
   296         del frame._generated_content
   297 
   297 
   298 
   298 
   299 class onDrawStr(str):
   299 class onDrawStr(str):
   370 class BaseDocTemplate:
   370 class BaseDocTemplate:
   371     """
   371     """
   372     First attempt at defining a document template class.
   372     First attempt at defining a document template class.
   373 
   373 
   374     The basic idea is simple.
   374     The basic idea is simple.
   375     
   375 
   376     1)  The document has a list of data associated with it
   376     1)  The document has a list of data associated with it
   377         this data should derive from flowables. We'll have
   377         this data should derive from flowables. We'll have
   378         special classes like PageBreak, FrameBreak to do things
   378         special classes like PageBreak, FrameBreak to do things
   379         like forcing a page end etc.
   379         like forcing a page end etc.
   380 
   380 
   415     - rightMargin:
   415     - rightMargin:
   416     - topMargin:
   416     - topMargin:
   417     - bottomMargin:  Margin sizes in points (default 1 inch).  These margins may be
   417     - bottomMargin:  Margin sizes in points (default 1 inch).  These margins may be
   418       overridden by the pageTemplates.  They are primarily of interest for the
   418       overridden by the pageTemplates.  They are primarily of interest for the
   419       SimpleDocumentTemplate subclass.
   419       SimpleDocumentTemplate subclass.
   420     
   420 
   421     - allowSplitting:  If set flowables (eg, paragraphs) may be split across frames or pages
   421     - allowSplitting:  If set flowables (eg, paragraphs) may be split across frames or pages
   422       (default: 1)
   422       (default: 1)
   423     - title: Internal title for document (does not automatically display on any page)
   423     - title: Internal title for document (does not automatically display on any page)
   424     - author: Internal author for document (does not automatically display on any page)
   424     - author: Internal author for document (does not automatically display on any page)
   425     """
   425     """
   830                                 pagesize=self.pagesize,
   830                                 pagesize=self.pagesize,
   831                                 invariant=self.invariant,
   831                                 invariant=self.invariant,
   832                                 pageCompression=self.pageCompression,
   832                                 pageCompression=self.pageCompression,
   833                                 enforceColorSpace=self.enforceColorSpace,
   833                                 enforceColorSpace=self.enforceColorSpace,
   834                                 )
   834                                 )
   835  
   835 
   836         getattr(self.canv,'setEncrypt',lambda x: None)(self.encrypt)
   836         getattr(self.canv,'setEncrypt',lambda x: None)(self.encrypt)
   837 
   837 
   838         self.canv._cropMarks = self.cropMarks
   838         self.canv._cropMarks = self.cropMarks
   839         self.canv.setAuthor(self.author)
   839         self.canv.setAuthor(self.author)
   840         self.canv.setTitle(self.title)
   840         self.canv.setTitle(self.title)
   927         return allHappy
   927         return allHappy
   928 
   928 
   929     def notify(self, kind, stuff):
   929     def notify(self, kind, stuff):
   930         """Forward to any listeners"""
   930         """Forward to any listeners"""
   931         for l in self._indexingFlowables:
   931         for l in self._indexingFlowables:
   932             l.notify(kind, stuff)
   932             _canv = getattr(l,'_canv',self)
       
   933             try:
       
   934                 if _canv==self:
       
   935                     l._canv = self.canv
       
   936                 l.notify(kind, stuff)
       
   937             finally:
       
   938                 if _canv==self:
       
   939                     del l._canv
   933 
   940 
   934     def pageRef(self, label):
   941     def pageRef(self, label):
   935         """hook to register a page number"""
   942         """hook to register a page number"""
   936         if verbose: print("pageRef called with label '%s' on page %d" % (
   943         if verbose: print("pageRef called with label '%s' on page %d" % (
   937             label, self.page))
   944             label, self.page))
   941                    maxPasses = 10,
   948                    maxPasses = 10,
   942                    **buildKwds
   949                    **buildKwds
   943                    ):
   950                    ):
   944         """Makes multiple passes until all indexing flowables
   951         """Makes multiple passes until all indexing flowables
   945         are happy.
   952         are happy.
   946         
   953 
   947         Returns number of passes"""
   954         Returns number of passes"""
   948         self._indexingFlowables = []
   955         self._indexingFlowables = []
   949         #scan the story and keep a copy
   956         #scan the story and keep a copy
   950         for thing in story:
   957         for thing in story:
   951             if thing.isIndexing():
   958             if thing.isIndexing():
   988                 e[0](*e[1:])
   995                 e[0](*e[1:])
   989 
   996 
   990         del self._multiBuildEdits
   997         del self._multiBuildEdits
   991         if verbose: print('saved')
   998         if verbose: print('saved')
   992         return passes
   999         return passes
   993         
  1000 
   994     #these are pure virtuals override in derived classes
  1001     #these are pure virtuals override in derived classes
   995     #NB these get called at suitable places by the base class
  1002     #NB these get called at suitable places by the base class
   996     #so if you derive and override the handle_xxx methods
  1003     #so if you derive and override the handle_xxx methods
   997     #it's up to you to ensure that they maintain the needed consistency
  1004     #it's up to you to ensure that they maintain the needed consistency
   998     def afterInit(self):
  1005     def afterInit(self):