added seqchain/format tags
authorrgbecker
Tue, 24 Aug 2004 11:36:22 +0000
changeset 2368 791a362e9cae
parent 2367 ff834913c5e2
child 2369 f3cc620c14ed
added seqchain/format tags
reportlab/lib/sequencer.py
reportlab/platypus/paraparser.py
reportlab/test/test_paragraphs.py
--- a/reportlab/lib/sequencer.py	Mon Aug 23 15:54:25 2004 +0000
+++ b/reportlab/lib/sequencer.py	Tue Aug 24 11:36:22 2004 +0000
@@ -126,7 +126,9 @@
             # the formats it knows initially
             '1':_format_123,
             'A':_format_ABC,
-            'a':_format_abc
+            'a':_format_abc,
+            'I':_format_I,
+            'i':_format_i,
             }
 
     def _getCounter(self, counter=None):
--- a/reportlab/platypus/paraparser.py	Mon Aug 23 15:54:25 2004 +0000
+++ b/reportlab/platypus/paraparser.py	Tue Aug 24 11:36:22 2004 +0000
@@ -614,7 +614,7 @@
         except KeyError:
             id = None
         try:
-            base = math.atoi(attr['base'])
+            base = int(attr['base'])
         except:
             base=0
         self._seq.reset(id, base)
@@ -622,20 +622,39 @@
     def end_seqreset(self):
         pass
 
+    def start_seqchain(self, attr):
+        try:
+            order = attr['order']
+        except KeyError:
+            order = ''
+        order = order.split()
+        seq = self._seq
+        for p,c in zip(order[:-1],order[1:]):
+            seq.chain(p, c)
+    end_seqchain = end_seqreset
+
+    def start_seqformat(self, attr):
+        try:
+            id = attr['id']
+        except KeyError:
+            id = None
+        try:
+            value = attr['value']
+        except KeyError:
+            value = '1'
+        self._seq.setFormat(id,value)
+    end_seqformat = end_seqreset
+
     # AR hacking in aliases to allow the proper casing for RML.
     # the above ones should be deprecated over time. 2001-03-22
-    def start_seqDefault(self, attr):
-        self.start_seqdefault(attr)
-
-    def end_seqDefault(self):
-        self.end_seqdefault()
-
-    def start_seqReset(self, attr):
-        self.start_seqreset(attr)
-
-    def end_seqReset(self):
-        self.end_seqreset()
-
+    start_seqDefault = start_seqdefault
+    end_seqDefault = end_seqdefault
+    start_seqReset = start_seqreset
+    end_seqReset = end_seqreset
+    start_seqChain = start_seqchain
+    end_seqChain = end_seqchain
+    start_seqFormat = start_seqformat
+    end_seqFormat = end_seqformat
 
     def start_seq(self, attr):
         #if it has a template, use that; otherwise try for id;
--- a/reportlab/test/test_paragraphs.py	Mon Aug 23 15:54:25 2004 +0000
+++ b/reportlab/test/test_paragraphs.py	Tue Aug 24 11:36:22 2004 +0000
@@ -125,14 +125,33 @@
         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='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
-        story.append(Paragraph("<para leftIndent='0'><bullet bulletIndent='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
-        story.append(Paragraph("<para leftIndent='0'><bullet bulletIndent='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
+        story.append(Paragraph("<para><bullet bulletIndent='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
+        story.append(Paragraph("<para><bullet bulletIndent='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
+        story.append(Paragraph("<para><bullet bulletIndent='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
         story.append(Indenter("1cm"))
         story.append(XPreformatted("<para leftIndent='0.5cm' backcolor=pink><bullet bulletIndent='-1cm'><seq id='s1'/>)</bullet>Indented list.</para>", styNormal))
         story.append(XPreformatted("<para leftIndent='0.5cm' backcolor=palegreen><bullet bulletIndent='-1cm'><seq id='s1'/>)</bullet>Indented list.</para>", styNormal))
         story.append(Indenter("-1cm"))
-        story.append(Paragraph("<para leftIndent='0'><bullet bulletIndent='-9cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
+        story.append(Paragraph("<para><bullet bulletIndent='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
+        story.append(Indenter("-1cm"))
+        story.append(Paragraph("<para>Indented list using seqChain/Format<seqChain order='s0 s1 s2 s3 s4'/><seqReset id='s0'/><seqFormat id='s0' value='1'/><seqFormat id='s1' value='a'/><seqFormat id='s2' value='i'/><seqFormat id='s3' value='A'/><seqFormat id='s4' value='I'/></para>", stySpaced))
+        story.append(Indenter("1cm"))
+        story.append(Paragraph("<para><bullet bulletIndent='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
+        story.append(Paragraph("<para><bullet bulletIndent='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
+        story.append(Paragraph("<para><bullet bulletIndent='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
+        story.append(Indenter("1cm"))
+        story.append(XPreformatted("<para backcolor=pink><bullet bulletIndent='-1cm'><seq id='s1'/>)</bullet>Indented list.</para>", styNormal))
+        story.append(XPreformatted("<para backcolor=pink><bullet bulletIndent='-1cm'><seq id='s1'/>)</bullet>Indented list.</para>", styNormal))
+        story.append(Indenter("-1cm"))
+        story.append(Paragraph("<para><bullet bulletIndent='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
+        story.append(Indenter("1cm"))
+        story.append(XPreformatted("<para backcolor=palegreen><bullet bulletIndent='-1cm'><seq id='s1'/>)</bullet>Indented list.</para>", styNormal))
+        story.append(Indenter("1cm"))
+        story.append(XPreformatted("<para><bullet bulletIndent='-1cm'><seq id='s2'/>)</bullet>Indented list. line1</para>", styNormal))
+        story.append(XPreformatted("<para><bullet bulletIndent='-1cm'><seq id='s2'/>)</bullet>Indented list. line2</para>", styNormal))
+        story.append(Indenter("-1cm"))
+        story.append(XPreformatted("<para backcolor=palegreen><bullet bulletIndent='-1cm'><seq id='s1'/>)</bullet>Indented list.</para>", styNormal))
+        story.append(Indenter("-1cm"))
         story.append(Indenter("-1cm"))
 
         template = SimpleDocTemplate(outputfile('test_paragraphs.pdf'),