platypus: FrameBG related stuff ifrom default that got lost somehow py33
authorrobin
Wed, 31 Jul 2013 16:22:27 +0100
branchpy33
changeset 3760 674899ebab37
parent 3759 0196beaeea9e
child 3761 7c6245b62827
platypus: FrameBG related stuff ifrom default that got lost somehow
src/reportlab/platypus/__init__.py
src/reportlab/platypus/doctemplate.py
tests/test_platypus_tables.py
--- a/src/reportlab/platypus/__init__.py	Wed Jul 31 16:21:34 2013 +0100
+++ b/src/reportlab/platypus/__init__.py	Wed Jul 31 16:22:27 2013 +0100
@@ -6,7 +6,7 @@
 
 from reportlab.platypus.flowables import Flowable, Image, Macro, PageBreak, Preformatted, Spacer, XBox, \
                         CondPageBreak, KeepTogether, TraceInfo, FailOnWrap, FailOnDraw, PTOContainer, \
-                        KeepInFrame, ParagraphAndImage, ImageAndFlowables, ListFlowable, ListItem
+                        KeepInFrame, ParagraphAndImage, ImageAndFlowables, ListFlowable, ListItem, FrameBG
 from reportlab.platypus.paragraph import Paragraph, cleanBlockQuotedText, ParaLines
 from reportlab.platypus.paraparser import ParaFrag
 from reportlab.platypus.tables import Table, TableStyle, CellStyle, LongTable
--- a/src/reportlab/platypus/doctemplate.py	Wed Jul 31 16:21:34 2013 +0100
+++ b/src/reportlab/platypus/doctemplate.py	Wed Jul 31 16:22:27 2013 +0100
@@ -496,6 +496,7 @@
         #context sensitive margins - set by story, not from outside
         self._leftExtraIndent = 0.0
         self._rightExtraIndent = 0.0
+        self._frameBGs = []
 
         self._calc()
         self.afterInit()
@@ -561,6 +562,7 @@
         self._removeVars(('page','frame'))
         self._leftExtraIndent = self.frame._leftExtraIndent
         self._rightExtraIndent = self.frame._rightExtraIndent
+        self._frameBGs = self.frame._frameBGs
         #detect infinite loops...
         if self._curPageFlowableCount == 0:
             self._emptyPages += 1
@@ -613,6 +615,7 @@
                 self.frame.drawBoundary(self.canv)
         f._leftExtraIndent = self._leftExtraIndent
         f._rightExtraIndent = self._rightExtraIndent
+        f._frameBGs = self._frameBGs
 
     def handle_frameEnd(self,resume=0):
         ''' Handles the semantics of the end of a frame. This includes the selection of
@@ -621,6 +624,7 @@
         self._removeVars(('frame',))
         self._leftExtraIndent = self.frame._leftExtraIndent
         self._rightExtraIndent = self.frame._rightExtraIndent
+        self._frameBGs = self.frame._frameBGs
 
         f = self.frame
         if hasattr(self,'_nextFrameIndex'):
--- a/tests/test_platypus_tables.py	Wed Jul 31 16:21:34 2013 +0100
+++ b/tests/test_platypus_tables.py	Wed Jul 31 16:22:27 2013 +0100
@@ -6,7 +6,7 @@
 from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation
 setOutDir(__name__)
 import os,unittest
-from reportlab.platypus import Spacer, SimpleDocTemplate, Table, TableStyle
+from reportlab.platypus import Spacer, SimpleDocTemplate, Table, TableStyle, FrameBG
 from reportlab.platypus.paragraph import Paragraph
 from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
 from reportlab.lib.units import inch, cm
@@ -16,7 +16,7 @@
 from reportlab.graphics.charts.barcharts import VerticalBarChart
 
 styleSheet = getSampleStyleSheet()
-    
+
 def getTable():
     t = Table((('','North','South','East','West'),
              ('Quarter 1',100,200,300,400),
@@ -50,6 +50,7 @@
     styNormal = styleSheet['Normal']
     styBackground = ParagraphStyle('background', parent=styNormal, backColor=colors.pink)
     styH1 = styleSheet['Heading1']
+    lst.append(FrameBG(color=colors.red))
     lst.append(Paragraph("First, a test of how tables align their content...", styH1))
     lst.append(Paragraph("""Generated with version %s""" % Version,
                         styNormal))
@@ -57,6 +58,7 @@
                          text differently to cells with Paragraphs using the
                          same font.  Hopefully now they are back on the same baseline""",
                         styNormal))
+    lst.append(FrameBG(color=colors.blue))
     ts1 = TableStyle([
                 ('ALIGN', (0,0), (-1,0), 'RIGHT'),
                 ('BACKGROUND', (0,0), (-1,0), colors.lightgrey),
@@ -75,8 +77,10 @@
         ])
     t1.setStyle(ts1)
     lst.append(t1)
+    lst.append(FrameBG(start=False))
     lst.append(Spacer(0,10))
     lst.append(Paragraph("Now we make a table with just one cell containing a string...note how the text sits low", styNormal))
+    lst.append(FrameBG(start=False))
     
     tsGrid = TableStyle([
                 ('GRID', (0,0), (-1,-1), 0.25, colors.black),