flowables.py: fix _Container.wrapOn (I hope)
authorrobin
Thu, 04 Jul 2013 15:04:50 +0100
changeset 3708 057515c78270
parent 3707 961300bcfe84
child 3709 092eb2ed1695
flowables.py: fix _Container.wrapOn (I hope)
src/reportlab/platypus/flowables.py
tests/test_platypus_paragraphs.py
--- a/src/reportlab/platypus/flowables.py	Thu Jul 04 13:17:39 2013 +0100
+++ b/src/reportlab/platypus/flowables.py	Thu Jul 04 15:04:50 2013 +0100
@@ -575,7 +575,7 @@
                 if isinstance(f,Indenter):
                     availWidth -= f.left+f.right
                 continue
-            w,h = f.wrapOn(canv,availWidth,0xfffffff)
+            w,h = cdeepcopy(f).wrapOn(canv,availWidth,0xfffffff)
             if dims is not None: dims.append((w,h))
             if cframe:
                 _addGeneratedContent(F,cframe)
@@ -1228,7 +1228,8 @@
         if self._C0:
             _Container.drawOn(self, canv, Fx, y, content=self._C0, aW=self._iW)
         if self._C1:
-            _Container.drawOn(self, canv, x, y-self._aH,content=self._C1)
+            aW, aH = self._wrapArgs
+            _Container.drawOn(self, canv, x, y-self._aH,content=self._C1, aW=aW)
 
     def _findSplit(self,canv,availWidth,availHeight,mergeSpace=1,obj=None):
         '''return max width, required height for a list of flowables F'''
--- a/tests/test_platypus_paragraphs.py	Thu Jul 04 13:17:39 2013 +0100
+++ b/tests/test_platypus_paragraphs.py	Thu Jul 04 15:04:50 2013 +0100
@@ -50,7 +50,8 @@
         BaseDocTemplate.__init__(self, filename, **kw)
         template = PageTemplate('normal', [frame1], myMainPageFrame)
         template1 = PageTemplate('special', [frame2], myMainPageFrame)
-        self.addPageTemplates([template,template1])
+        template2 = PageTemplate('template2', [Frame(395, 108, 165, 645, id='second2')])
+        self.addPageTemplates([template,template1,template2])
 
 class ParagraphCorners(unittest.TestCase):
     "some corner cases which should parse"
@@ -286,8 +287,27 @@
                     imageSide='left',
                     )
                 )
-
-        
+        text = '''With this clarification, an important property of these three types of
+EC can be defined in such a way as to impose problems of phonemic and
+morphological analysis.  Another superficial similarity is the interest
+in simulation of behavior, this analysis of a formative as a pair of
+sets of features does not readily tolerate a stipulation to place the
+constructions into these various categories.  We will bring evidence in
+favor of the following thesis:  the earlier discussion of deviance is
+not to be considered in determining the extended c-command discussed in
+connection with (34).  Another superficial similarity is the interest in
+simulation of behavior, relational information may remedy and, at the
+same time, eliminate a descriptive fact.  There is also a different
+approach to the [unification] problem, the descriptive power of the base
+component delimits the traditional practice of grammarians.'''
+        from reportlab.platypus.flowables import ImageAndFlowables, Image
+        from reportlab.lib.testutils import testsFolder
+        gif = os.path.join(testsFolder,'pythonpowered.gif')
+        heading = Paragraph('This is a heading',h3)
+        story.append(NextPageTemplate('template2'))
+        story.append(PageBreak())
+        story.append(heading)
+        story.append(ImageAndFlowables(Image(gif,width=66,height=81),[Paragraph(text,bt)],imageSide='left',imageRightPadding=10))
         doc = MyDocTemplate(outputfile('test_platypus_imageandflowables.pdf'),showBoundary=1)
         doc.multiBuild(story)