fix narrow space case for ImageAndFlowables
authorrgbecker
Wed, 19 Jul 2006 13:36:26 +0000
changeset 2662 0a5217162c3f
parent 2661 e179247ffea3
child 2663 927cc273c5a5
fix narrow space case for ImageAndFlowables
reportlab/platypus/flowables.py
reportlab/test/test_platypus_paragraphs.py
--- a/reportlab/platypus/flowables.py	Wed Jul 19 11:25:24 2006 +0000
+++ b/reportlab/platypus/flowables.py	Wed Jul 19 13:36:26 2006 +0000
@@ -968,8 +968,11 @@
         self._iW = availWidth - irpad - wI - ilpad
         aH = itpad + hI + ibpad
         W,H0,self._C0,self._C1 = self._findSplit(canv,self._iW,aH)
+        if W>self._iW+_FUZZ:
+            self._C0 = None
+            self._C1 = self._content
+        aH = self._aH = max(aH,H0)
         self.width = availWidth
-        aH = self._aH = max(aH,H0)
         if not self._C1:
             self.height = aH
         else:
@@ -1007,7 +1010,8 @@
             Ix = x + self.width-self._wI-self._irpad - self._ilpad
             Fx = x
         self._I.drawOn(canv,Ix,y+self.height-self._itpad-self._hI)
-        _Container.drawOn(self, canv, Fx, y, content=self._C0, aW=self._iW)
+        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)
 
--- a/reportlab/test/test_platypus_paragraphs.py	Wed Jul 19 11:25:24 2006 +0000
+++ b/reportlab/test/test_platypus_paragraphs.py	Wed Jul 19 13:36:26 2006 +0000
@@ -22,7 +22,7 @@
 from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
 from reportlab.platypus.paragraph import Paragraph
 from reportlab.platypus.frames import Frame
-from reportlab.platypus.doctemplate import PageTemplate, BaseDocTemplate
+from reportlab.platypus.doctemplate import PageTemplate, BaseDocTemplate, PageBreak, NextPageTemplate
 from reportlab.platypus import tableofcontents
 from reportlab.platypus.tableofcontents import TableOfContents
 from reportlab.platypus.tables import TableStyle, Table
@@ -48,10 +48,12 @@
 
     def __init__(self, filename, **kw):
         frame1 = Frame(2.5*cm, 2.5*cm, 15*cm, 25*cm, id='F1')
+        frame2 = Frame(2.5*cm, 2.5*cm, 310, 25*cm, id='F2')
         self.allowSplitting = 0
         apply(BaseDocTemplate.__init__, (self, filename), kw)
         template = PageTemplate('normal', [frame1], myMainPageFrame)
-        self.addPageTemplates(template)
+        template1 = PageTemplate('special', [frame2], myMainPageFrame)
+        self.addPageTemplates([template,template1])
 
 
 class ParagraphCorners(unittest.TestCase):
@@ -143,8 +145,55 @@
         phrase = 'This should be a paragraph spanning at least three pages. '
         description = ''.join([('%d: '%i)+phrase for i in xrange(250)])
         story.append(ImageAndFlowables(Image(gif),[heading,Paragraph(description, bt)],imageSide='left'))
+        story.append(NextPageTemplate('special'))
+        story.append(PageBreak())
+        story.append(ImageAndFlowables(
+                        Image(gif,width=280,height=120),
+                        Paragraph('''The concept of an integrated one box solution for advanced voice and
+data applications began with the introduction of the IMACS. The
+IMACS 200 carries on that tradition with an integrated solution
+optimized for smaller port size applications that the IMACS could not
+economically address. An array of the most popular interfaces and
+features from the IMACS has been bundled into a small 2U chassis
+providing the ultimate in ease of installation.''',
+                        style=ParagraphStyle(
+                                name="base",
+                                fontName="Helvetica",
+                                leading=12,
+                                leftIndent=0,
+                                firstLineIndent=0,
+                                spaceBefore = 9.5,
+                                fontSize=9.5,
+                                )
+                            ),
+                    imageSide='left',
+                    )
+                )
+        story.append(ImageAndFlowables(
+                        Image(gif,width=240,height=120),
+                        Paragraph('''The concept of an integrated one box solution for advanced voice and
+data applications began with the introduction of the IMACS. The
+IMACS 200 carries on that tradition with an integrated solution
+optimized for smaller port size applications that the IMACS could not
+economically address. An array of the most popular interfaces and
+features from the IMACS has been bundled into a small 2U chassis
+providing the ultimate in ease of installation.''',
+                        style=ParagraphStyle(
+                                name="base",
+                                fontName="Helvetica",
+                                leading=12,
+                                leftIndent=0,
+                                firstLineIndent=0,
+                                spaceBefore = 9.5,
+                                fontSize=9.5,
+                                )
+                            ),
+                    imageSide='left',
+                    )
+                )
 
-        doc = MyDocTemplate(outputfile('test_platypus_imageandflowables.pdf'))
+        
+        doc = MyDocTemplate(outputfile('test_platypus_imageandflowables.pdf'),showBoundary=1)
         doc.multiBuild(story)
 
 class FragmentTestCase(unittest.TestCase):