minor twitching on Indenter
authorrgbecker
Fri, 20 Aug 2004 16:12:33 +0000
changeset 2366 7dd247980b7d
parent 2365 cda528e430aa
child 2367 ff834913c5e2
minor twitching on Indenter
reportlab/platypus/__init__.py
reportlab/platypus/doctemplate.py
reportlab/platypus/paragraph.py
reportlab/test/test_paragraphs.py
--- a/reportlab/platypus/__init__.py	Thu Aug 19 22:17:05 2004 +0000
+++ b/reportlab/platypus/__init__.py	Fri Aug 20 16:12:33 2004 +0000
@@ -10,5 +10,5 @@
 from reportlab.platypus.tables import Table, TableStyle, CellStyle
 from reportlab.platypus.frames import Frame
 from reportlab.platypus.doctemplate import BaseDocTemplate, NextPageTemplate, PageTemplate, ActionFlowable, \
-                        SimpleDocTemplate, FrameBreak, PageBegin
-from xpreformatted import XPreformatted
\ No newline at end of file
+                        SimpleDocTemplate, FrameBreak, PageBegin, Indenter
+from xpreformatted import XPreformatted
--- a/reportlab/platypus/doctemplate.py	Thu Aug 19 22:17:05 2004 +0000
+++ b/reportlab/platypus/doctemplate.py	Fri Aug 20 16:12:33 2004 +0000
@@ -141,6 +141,13 @@
 FrameBreak = _FrameBreak('frameEnd')
 PageBegin = ActionFlowable('pageBegin')
 
+def _evalMeasurement(n):
+    if type(n) is type(''):
+        from paraparser import _num
+        n = _num(n)
+        if type(n) is type(()): n = n[1]
+    return n
+
 class Indenter(ActionFlowable):
     """Increases or decreases left and right margins of frame.
 
@@ -149,8 +156,8 @@
     """
 
     def __init__(self, left=0, right=0):
-        self.left = left
-        self.right = right
+        self.left = _evalMeasurement(left)
+        self.right = _evalMeasurement(right)
 
     def apply(self, doc):
         doc.frame._leftExtraIndent = doc.frame._leftExtraIndent + self.left
--- a/reportlab/platypus/paragraph.py	Thu Aug 19 22:17:05 2004 +0000
+++ b/reportlab/platypus/paragraph.py	Fri Aug 20 16:12:33 2004 +0000
@@ -255,11 +255,11 @@
             tx2.setFillColor(f.textColor)
             tx2.textOut(f.text)
 
+    canvas.drawText(tx2)
     #AR making definition lists a bit less ugly
     #bulletEnd = tx2.getX()
     bulletEnd = tx2.getX() + style.bulletFontSize * 0.6
-    offset = max(offset, bulletEnd - style.leftIndent)
-    canvas.drawText(tx2)
+    offset = max(offset,bulletEnd - style.leftIndent)
     return offset
 
 def _handleBulletWidth(bulletText,style,maxWidths):
@@ -512,7 +512,7 @@
         #for bullets, work out width and ensure we wrap the right amount onto line one
         _handleBulletWidth(self.bulletText,style,maxWidths)
 
-        maxWidth = maxWidths[lineno]
+        maxWidth = maxWidths[0]
 
         self.height = 0
         frags = self.frags
--- a/reportlab/test/test_paragraphs.py	Thu Aug 19 22:17:05 2004 +0000
+++ b/reportlab/test/test_paragraphs.py	Fri Aug 20 16:12:33 2004 +0000
@@ -6,7 +6,7 @@
 from reportlab.test import unittest
 from reportlab.test.utils import makeSuiteForClasses, outputfile
 
-from reportlab.platypus import Paragraph, SimpleDocTemplate, XBox
+from reportlab.platypus import Paragraph, SimpleDocTemplate, XBox, Indenter
 from reportlab.lib.styles import ParagraphStyle
 from reportlab.lib.units import inch
 from reportlab.lib.colors import red, black, navy, white
@@ -124,6 +124,12 @@
         story.append(Paragraph('''This one uses fonts with size "14pt" and also uses the em and strong tags: Here comes <font face="Helvetica" size="14pt">Helvetica 14</font> with <Strong>strong</Strong> <em>emphasis</em>.''', styNormal, caseSensitive=0))
         story.append(Paragraph('''This uses a font size of 3cm: Here comes <font face="Courier" size="3cm">Courier 3cm</font> and normal again.''', styNormal, caseSensitive=0))
         story.append(Paragraph('''This is just a very long silly text to see if the <FONT face="Courier">caseSensitive</FONT> flag also works if the paragraph is <EM>very</EM> long. '''*20, styNormal, caseSensitive=0))
+        story.append(Indenter("1cm"))
+        story.append(Paragraph("<para leftIndent='0'><bullet bulletIndent='-0.9cm'><seq id='s3'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
+        story.append(Paragraph("<para leftIndent='0'><bullet bulletIndent='-0.9cm'><seq id='s3'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
+        story.append(Paragraph("<para leftIndent='0'><bullet bulletIndent='-0.9cm'><seq id='s3'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
+        story.append(Paragraph("<para leftIndent='0'><bullet bulletIndent='-0.9cm'><seq id='s3'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
+        story.append(Indenter("-1cm"))
 
         template = SimpleDocTemplate(outputfile('test_paragraphs.pdf'),
                                      showBoundary=1)