src/reportlab/platypus/paraparser.py
changeset 3165 cbda9e7d0ee3
parent 3137 a9d20c542ed9
child 3187 2d5a6655556e
--- a/src/reportlab/platypus/paraparser.py	Tue Jun 02 12:31:27 2009 +0000
+++ b/src/reportlab/platypus/paraparser.py	Tue Jun 02 14:30:06 2009 +0000
@@ -26,6 +26,8 @@
 subFraction = 0.5   # fraction of font size that a sub script should be lowered
 superFraction = 0.5 # fraction of font size that a super script should be raised
 
+DEFAULT_INDEX_NAME='_indexAdd'
+
 
 def _convnum(s, unit=1):
     if s[0] in ['+','-']:
@@ -171,6 +173,10 @@
                 'height':('height',_num),
                 'valign':('valign',_valignpc),
                 }
+_indexAttrMap = {
+                'name': ('name',None),
+                'item': ('item',None),
+                }
 
 def _addAttributeNames(m):
     K = m.keys()
@@ -496,7 +502,8 @@
 #       < sub > < /sub > - subscript
 #       <font name=fontfamily/fontname color=colorname size=float>
 #       < bullet > </bullet> - bullet text (at head of para only)
-#       <onDraw name=callable label="a label">
+#       <onDraw name=callable label="a label"/>
+#       <index [name="callablecanvasattribute"] label="a label"/>
 #       <link>link text</link>
 #           attributes of links 
 #               size/fontSize=num
@@ -883,9 +890,25 @@
         self._push(cbDefn=defn)
         self.handle_data('')
         self._pop()
-
     end_onDraw=end_seq
 
+    def start_index(self,attr):
+        attr=self.getAttributes(attr,_indexAttrMap)
+        defn = ABag()
+        if attr.has_key('item'):
+            defn.label = attr['item']
+        else:
+            self._syntax_error('<index> needs at least an item attribute')
+        if attr.has_key('name'):
+            name = attr['name']
+        else:
+            name = DEFAULT_INDEX_NAME
+        defn.name = name
+        defn.kind='index'
+        self._push(cbDefn=defn)
+        self.handle_data('')
+        self._pop()
+    end_index=end_seq
 
     #---------------------------------------------------------------
     def _push(self,**attr):