Global sequencer put in the 'story builder'.
authorandy_robinson
Mon, 19 Jun 2000 11:14:03 +0000
changeset 279 e7d8b3631d5c
parent 278 1a14ccd29e70
child 280 84d0233ea5e7
Global sequencer put in the 'story builder'.
reportlab/demos/py2pdf/demo.py
reportlab/demos/py2pdf/py2pdf.py
reportlab/lib/sequencer.py
reportlab/platypus/doctemplate.py
reportlab/platypus/paragraph.py
reportlab/platypus/paraparser.py
--- a/reportlab/demos/py2pdf/demo.py	Sat Jun 17 07:48:41 2000 +0000
+++ b/reportlab/demos/py2pdf/demo.py	Mon Jun 19 11:14:03 2000 +0000
@@ -37,14 +37,14 @@
         # Define a PDF form containing an image frame
         # that will be included on every page, but 
         # stored only once in the resulting file.
-        c.beginForm0("imageFrame")
+        c.beginForm("imageFrame")
         c.saveState()
         x, y = 219.0, 655.0 # Known size of the picture.
         c.scale((lm - 1*cm)/x, height/y)
         path = 'vertpython.jpg'
         c.drawInlineImage(path, 0, 0)
         c.restoreState()        
-        c.endForm0()
+        c.endForm()
 
     
     def putPageDecoration(self):
@@ -62,7 +62,7 @@
         c.drawCentredString(x, y, label)
 
         # Call the previously stored form.
-        c.doForm0("imageFrame")
+        c.doForm("imageFrame")
                 
 
 ### Helpers.
--- a/reportlab/demos/py2pdf/py2pdf.py	Sat Jun 17 07:48:41 2000 +0000
+++ b/reportlab/demos/py2pdf/py2pdf.py	Mon Jun 19 11:14:03 2000 +0000
@@ -1017,7 +1017,7 @@
                 c = self.canvas
                 i = self.startPositions.index(self.startPos)
                 c.bookmarkHorizontalAbsolute(nameTag, pos)
-                c.addOutlineEntry0('%s %s' % (item, t), nameTag, i)
+                c.addOutlineEntry('%s %s' % (item, t), nameTag, i)
 
     
     def addParam(self, t):
--- a/reportlab/lib/sequencer.py	Sat Jun 17 07:48:41 2000 +0000
+++ b/reportlab/lib/sequencer.py	Mon Jun 19 11:14:03 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: sequencer.py,v $
+#	Revision 1.5  2000/06/19 11:14:03  andy_robinson
+#	Global sequencer put in the 'story builder'.
+#
 #	Revision 1.4  2000/06/12 11:27:17  andy_robinson
 #	Added Sequencer and associated XML tags
-#
+#	
 #	Revision 1.3  2000/06/11 21:34:01  andy_robinson
 #	Largely complete class for numbering lists, figures and chapters
 #	
@@ -43,7 +46,7 @@
 #	Revision 1.1  2000/06/01 15:23:06  rgbecker
 #	Platypus re-organisation
 #	
-__version__=''' $Id: sequencer.py,v 1.4 2000/06/12 11:27:17 andy_robinson Exp $ '''
+__version__=''' $Id: sequencer.py,v 1.5 2000/06/19 11:14:03 andy_robinson Exp $ '''
 """This module defines a single public class, Sequencer, which aids in
 numbering and formatting lists."""
 
@@ -223,6 +226,21 @@
 		for (key, counter) in counters:
 			print '    %s: value = %d, base = %d, format example = %s' % (
 				key, counter.this(), counter._base, counter.thisf())
+
+
+"""Your story builder needs to set this to"""
+_sequencer = None
+def getSequencer():
+	global _sequencer
+	if _sequencer is None:
+		_sequencer = Sequencer()
+	return	_sequencer
+
+def setSequencer(seq):
+	s = _sequencer
+	_sequencer = seq
+	return s
+
 def test():
 	s = Sequencer()
 	print 'Counting using default sequence: %d %d %d' % (s.next(),s.next(), s.next())
--- a/reportlab/platypus/doctemplate.py	Sat Jun 17 07:48:41 2000 +0000
+++ b/reportlab/platypus/doctemplate.py	Mon Jun 19 11:14:03 2000 +0000
@@ -31,11 +31,14 @@
 #
 ###############################################################################
 #	$Log: doctemplate.py,v $
+#	Revision 1.17  2000/06/19 11:14:03  andy_robinson
+#	Global sequencer put in the 'story builder'.
+#
 #	Revision 1.16  2000/06/16 13:49:20  aaron_watters
 #	new build parameters to allow alternate filename and canvas implementation
 #	(in order to support slideshow summary mode, for example, or embedding one
 #	document in another).
-#
+#	
 #	Revision 1.15  2000/06/13 13:03:31  aaron_watters
 #	more documentation changes
 #	
@@ -81,7 +84,7 @@
 #	Revision 1.1  2000/05/12 12:53:33  rgbecker
 #	Initial try at a document template class
 #	
-__version__=''' $Id: doctemplate.py,v 1.16 2000/06/16 13:49:20 aaron_watters Exp $ '''
+__version__=''' $Id: doctemplate.py,v 1.17 2000/06/19 11:14:03 andy_robinson Exp $ '''
 __doc__="""
 This module contains the core structure of platypus.
 
@@ -105,8 +108,10 @@
 the page template for the next page (which by default is the one being used
 for the current frame).
 """
-from flowables import *
-from frames import Frame
+from reportlab.platypus.flowables import *
+from reportlab.platypus.paragraph import Paragraph
+from reportlab.platypus.frames import Frame
+import reportlab.lib.sequencer
 from types import *
 import sys
 
@@ -256,6 +261,9 @@
 		self.addPageTemplates(p)
 		self._calc()
 
+		self.seq = reportlab.lib.sequencer.Sequencer()
+		
+
 	def _calc(self):
 		self._rightMargin = self.pagesize[0] - self.rightMargin
 		self._topMargin = self.pagesize[1] - self.topMargin
@@ -405,6 +413,7 @@
 					flowables.insert(0,f)			# put the flowable back
 					self.handle_frameEnd()
 
+
 	#these are provided so that deriving classes can refer to them
 	_handle_documentBegin = handle_documentBegin
 	_handle_pageBegin = handle_pageBegin
--- a/reportlab/platypus/paragraph.py	Sat Jun 17 07:48:41 2000 +0000
+++ b/reportlab/platypus/paragraph.py	Mon Jun 19 11:14:03 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: paragraph.py,v $
+#	Revision 1.13  2000/06/19 11:14:03  andy_robinson
+#	Global sequencer put in the 'story builder'.
+#
 #	Revision 1.12  2000/06/13 13:03:31  aaron_watters
 #	more documentation changes
-#
+#	
 #	Revision 1.11  2000/06/01 15:23:06  rgbecker
 #	Platypus re-organisation
 #	
@@ -67,12 +70,12 @@
 #	Revision 1.1  2000/04/14 13:21:52  rgbecker
 #	Removed from layout.py
 #	
-__version__=''' $Id: paragraph.py,v 1.12 2000/06/13 13:03:31 aaron_watters Exp $ '''
+__version__=''' $Id: paragraph.py,v 1.13 2000/06/19 11:14:03 andy_robinson Exp $ '''
 import string
 import types
 from reportlab.pdfbase.pdfmetrics import stringWidth
-from paraparser import ParaParser, ParaFrag
-from flowables import Flowable
+from reportlab.platypus.paraparser import ParaParser, ParaFrag
+from reportlab.platypus.flowables import Flowable
 from reportlab.lib.colors import Color
 from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
 from copy import deepcopy
@@ -273,6 +276,10 @@
 				raise "xml parser error (%s) in paragraph beginning\n'%s'"\
 					% (_parser.errors[0],text[:min(30,len(text))])
 			if bFrags: bulletText = bFrags
+
+		#AR hack
+		self.text = text
+		
 		self.frags = frags
 		self.style = style
 		self.bulletText = bulletText
--- a/reportlab/platypus/paraparser.py	Sat Jun 17 07:48:41 2000 +0000
+++ b/reportlab/platypus/paraparser.py	Mon Jun 19 11:14:03 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: paraparser.py,v $
+#	Revision 1.24  2000/06/19 11:14:03  andy_robinson
+#	Global sequencer put in the 'story builder'.
+#
 #	Revision 1.23  2000/06/13 04:11:49  aaron_watters
 #	noted replication of XML markup comment between paraparser.py and paragraph.py
-#
+#	
 #	Revision 1.22  2000/06/12 11:27:17  andy_robinson
 #	Added Sequencer and associated XML tags
 #	
@@ -64,7 +67,7 @@
 #	Revision 1.13  2000/04/25 13:07:57  rgbecker
 #	Added license
 #	
-__version__=''' $Id: paraparser.py,v 1.23 2000/06/13 04:11:49 aaron_watters Exp $ '''
+__version__=''' $Id: paraparser.py,v 1.24 2000/06/19 11:14:03 andy_robinson Exp $ '''
 import string
 import re
 from types import TupleType
@@ -72,6 +75,7 @@
 import os
 import copy
 
+import reportlab.lib.sequencer
 #try:
 #	from xml.parsers import xmllib
 #	_xmllib_newStyle = 1
@@ -374,20 +378,13 @@
 
 
 	#---------------------------------------------------------------
-	def setSequencer(self, seq):
-		self._seq = seq
-
-	def getSequencer(self):
-		if self._seq is None:
-			self._seq = Sequencer()
-		return self._seq
 		
 	def start_seqdefault(self, attr):
 		try:
 			default = attr['id']
 		except KeyError:
 			default = None
-		self.getSequencer().setDefaultCounter(default)
+		self._seq.setDefaultCounter(default)
 
 	def end_seqdefault(self):
 		pass
@@ -401,7 +398,7 @@
 			base = math.atoi(attr['base'])
 		except:
 			base=1
-		self.getSequencer().reset(id, base)
+		self._seq.reset(id, base)
 
 	def end_seqreset(self):
 		pass
@@ -417,7 +414,7 @@
 			id = attr['id']
 		else: 
 			id = None
-		output = self.getSequencer().nextf(id)
+		output = self._seq.nextf(id)
 		self.handle_data(output)
 		
 	def end_seq(self):
@@ -545,11 +542,13 @@
 		# the xmlparser requires that all text be surrounded by xml
 		# tags, therefore we must throw some unused flags around the
 		# given string
+		self._seq = reportlab.lib.sequencer.getSequencer()
 		self._reset(style)	# reinitialise the parser
 		if not(len(text)>=6 and text[0]=='<' and _re_para.match(text)):
 			text = "<para>"+text+"</para>"
 		self.feed(text)
 		self.close()	# force parsing to complete
+		del self._seq
 		style = self._style
 		del self._style
 		if len(self.errors)==0: