Platypus re-organisation
authorrgbecker
Thu, 01 Jun 2000 15:23:06 +0000
changeset 253 cfcf8d555a2c
parent 252 04d4a765d934
child 254 adc041d2e4b9
Platypus re-organisation
reportlab/demos/gadflypaper/gfe.py
reportlab/demos/odyssey/dodyssey.py
reportlab/demos/odyssey/fodyssey.py
reportlab/demos/pythonpoint/pythonpoint.py
reportlab/demos/pythonpoint/stdparser.py
reportlab/demos/pythonpoint/styles_horrible.py
reportlab/demos/pythonpoint/styles_modern.py
reportlab/lib/sequencer.py
reportlab/pdfgen/canvas.py
reportlab/platypus/__init__.py
reportlab/platypus/doctemplate.py
reportlab/platypus/flowables.py
reportlab/platypus/frames.py
reportlab/platypus/layout.py
reportlab/platypus/paragraph.py
reportlab/platypus/paraparser.py
reportlab/platypus/tables.py
reportlab/platypus/test/testplatypus.py
reportlab/platypus/test/testtables.py
--- a/reportlab/demos/gadflypaper/gfe.py	Thu Jun 01 09:44:26 2000 +0000
+++ b/reportlab/demos/gadflypaper/gfe.py	Thu Jun 01 15:23:06 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: gfe.py,v $
+#	Revision 1.10  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
 #	Revision 1.9  2000/05/17 15:37:33  rgbecker
 #	Changes related to removal of SimpleFlowDocument
-#
+#	
 #	Revision 1.8  2000/05/11 13:51:21  rgbecker
 #	Fixes for xml<
 #	
@@ -58,14 +61,15 @@
 #	Revision 1.1.1.1  2000/02/15 15:15:57  rgbecker
 #	Initial setup of demos directory and contents.
 #	
-__version__=''' $Id: gfe.py,v 1.9 2000/05/17 15:37:33 rgbecker Exp $ '''
+__version__=''' $Id: gfe.py,v 1.10 2000/06/01 15:23:06 rgbecker Exp $ '''
 __doc__=''
 
 #REPORTLAB_TEST_SCRIPT
 import sys
-from reportlab.platypus.paragraph import Paragraph
-from reportlab.platypus.doctemplate import *
+from reportlab.platypus import *
 from reportlab.lib.styles import getSampleStyleSheet
+from reportlab.lib.pagesizes import DEFAULT_PAGE_SIZE
+PAGE_HEIGHT=DEFAULT_PAGE_SIZE[1]
 
 styles = getSampleStyleSheet()
 
@@ -114,7 +118,7 @@
     
 def go():
     Elements.insert(0,Spacer(0,inch))
-    doc = SimpleDocTemplate('gfe.pdf',DEFAULT_PAGE_SIZE)
+    doc = SimpleDocTemplate('gfe.pdf',pageSize=DEFAULT_PAGE_SIZE)
     doc.build(Elements,onFirstPage=myFirstPage, onLaterPages=myLaterPages)
 
 Elements = []
--- a/reportlab/demos/odyssey/dodyssey.py	Thu Jun 01 09:44:26 2000 +0000
+++ b/reportlab/demos/odyssey/dodyssey.py	Thu Jun 01 15:23:06 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: dodyssey.py,v $
+#	Revision 1.7  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
 #	Revision 1.6  2000/06/01 09:41:11  rgbecker
 #	test filename case fix
-#
+#	
 #	Revision 1.5  2000/05/17 22:15:58  rgbecker
 #	Renamed BasicFrame to Frame
 #	
@@ -61,13 +64,12 @@
 #	Revision 1.1  2000/04/06 08:58:09  rgbecker
 #	Paragraph formatting version of odyssey.py
 #	
-__version__=''' $Id: dodyssey.py,v 1.6 2000/06/01 09:41:11 rgbecker Exp $ '''
+__version__=''' $Id: dodyssey.py,v 1.7 2000/06/01 15:23:06 rgbecker Exp $ '''
 __doc__=''
 
 #REPORTLAB_TEST_SCRIPT
 import sys, copy, string, os
-from reportlab.platypus import doctemplate
-from reportlab.platypus.paragraph import Paragraph
+from reportlab.platypus import *
 from reportlab.lib.units import inch
 from reportlab.lib.styles import getSampleStyleSheet
 from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
@@ -88,18 +90,18 @@
 	canvas.restoreState()
 	
 def go():
-	doc = doctemplate.BaseDocTemplate('dodyssey.pdf',showBoundary=0)
+	doc = BaseDocTemplate('dodyssey.pdf',showBoundary=0)
 
 	#normal frame as for SimpleFlowDocument
-	frameT = doctemplate.Frame(doc.leftMargin, doc.bottomMargin, doc.width, doc.height, id='normal')
+	frameT = Frame(doc.leftMargin, doc.bottomMargin, doc.width, doc.height, id='normal')
 
 	#Two Columns
-	frame1 = doctemplate.Frame(doc.leftMargin, doc.bottomMargin, doc.width/2-6, doc.height, id='col1')
-	frame2 = doctemplate.Frame(doc.leftMargin+doc.width/2+6, doc.bottomMargin, doc.width/2-6,
+	frame1 = Frame(doc.leftMargin, doc.bottomMargin, doc.width/2-6, doc.height, id='col1')
+	frame2 = Frame(doc.leftMargin+doc.width/2+6, doc.bottomMargin, doc.width/2-6,
 						doc.height, id='col2')
-	doc.addPageTemplates([doctemplate.PageTemplate(id='First',frames=frameT, onPage=myTitlePage),
-						doctemplate.PageTemplate(id='OneCol',frames=frameT, onPage=myLaterPages),
-						doctemplate.PageTemplate(id='TwoCol',frames=[frame1,frame2], onPage=myLaterPages),
+	doc.addPageTemplates([PageTemplate(id='First',frames=frameT, onPage=myTitlePage),
+						PageTemplate(id='OneCol',frames=frameT, onPage=myLaterPages),
+						PageTemplate(id='TwoCol',frames=[frame1,frame2], onPage=myLaterPages),
 						])
 	doc.build(Elements)
 
@@ -114,15 +116,15 @@
 PreStyle = styles["Code"] 
 
 def newPage():
-	Elements.append(doctemplate.PageBreak())
+	Elements.append(PageBreak())
 
 def chapter(txt, style=ChapterStyle):
-	Elements.append(doctemplate.NextPageTemplate('OneCol'))
+	Elements.append(NextPageTemplate('OneCol'))
 	newPage()
 	Elements.append(Paragraph(txt, style))
-	Elements.append(doctemplate.Spacer(0.2*inch, 0.3*inch))
+	Elements.append(Spacer(0.2*inch, 0.3*inch))
 	if useTwoCol:
-		Elements.append(doctemplate.NextPageTemplate('TwoCol'))
+		Elements.append(NextPageTemplate('TwoCol'))
 
 def fTitle(txt,style=InitialStyle):
 	Elements.append(Paragraph(txt, style))
@@ -143,7 +145,7 @@
 useTwoCol = 'notwocol' not in sys.argv 
 
 def spacer(inches):
-	Elements.append(doctemplate.Spacer(0.1*inch, inches*inch))
+	Elements.append(Spacer(0.1*inch, inches*inch))
 
 def p(txt, style=ParaStyle):
 	Elements.append(Paragraph(txt, style))
@@ -152,12 +154,12 @@
 def pre(txt, style=PreStyle):
 	global firstPre
 	if firstPre:
-		Elements.append(doctemplate.NextPageTemplate('OneCol'))
+		Elements.append(NextPageTemplate('OneCol'))
 		newPage()
 		firstPre = 0
 
 	spacer(0.1)
-	p = doctemplate.Preformatted(txt, style)
+	p = Preformatted(txt, style)
 	Elements.append(p)
 
 def parseOdyssey(fn):
--- a/reportlab/demos/odyssey/fodyssey.py	Thu Jun 01 09:44:26 2000 +0000
+++ b/reportlab/demos/odyssey/fodyssey.py	Thu Jun 01 15:23:06 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: fodyssey.py,v $
+#	Revision 1.12  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
 #	Revision 1.11  2000/06/01 09:41:12  rgbecker
 #	test filename case fix
-#
+#	
 #	Revision 1.10  2000/05/17 16:29:39  rgbecker
 #	Removal of SimpleFrame
 #	
@@ -64,16 +67,16 @@
 #	Revision 1.1  2000/04/06 08:58:09  rgbecker
 #	Paragraph formatting version of odyssey.py
 #	
-__version__=''' $Id: fodyssey.py,v 1.11 2000/06/01 09:41:12 rgbecker Exp $ '''
+__version__=''' $Id: fodyssey.py,v 1.12 2000/06/01 15:23:06 rgbecker Exp $ '''
 __doc__=''
 
 #REPORTLAB_TEST_SCRIPT
 import sys, copy, string, os
-from reportlab.platypus.paragraph import Paragraph
-from reportlab.platypus.doctemplate import *
+from reportlab.platypus import *
 from reportlab.lib.units import inch
 from reportlab.lib.styles import getSampleStyleSheet
 from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
+from reportlab.lib.pagesizes import DEFAULT_PAGE_SIZE
 
 styles = getSampleStyleSheet()
 
@@ -91,7 +94,7 @@
 	canvas.restoreState()
 	
 def go():
-	doc = SimpleDocTemplate('fodyssey.pdf',DEFAULT_PAGE_SIZE,showBoundary='showboundary' in sys.argv)
+	doc = SimpleDocTemplate('fodyssey.pdf',pageSize=DEFAULT_PAGE_SIZE,showBoundary='showboundary' in sys.argv)
 	doc.allowSplitting = not 'nosplitting' in sys.argv
 	doc.build(Elements,myFirstPage,myLaterPages)
 
--- a/reportlab/demos/pythonpoint/pythonpoint.py	Thu Jun 01 09:44:26 2000 +0000
+++ b/reportlab/demos/pythonpoint/pythonpoint.py	Thu Jun 01 15:23:06 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: pythonpoint.py,v $
+#	Revision 1.21  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
 #	Revision 1.20  2000/05/23 14:06:45  andy_robinson
 #	Preformatted objects now know how to split themselves.
-#
+#	
 #	Revision 1.19  2000/05/19 08:20:01  rgbecker
 #	Bring in line with canvas changes
 #	
@@ -96,7 +99,7 @@
 #	Revision 1.1.1.1  2000/02/15 15:08:55  rgbecker
 #	Initial setup of demos directory and contents.
 #	
-__version__=''' $Id: pythonpoint.py,v 1.20 2000/05/23 14:06:45 andy_robinson Exp $ '''
+__version__=''' $Id: pythonpoint.py,v 1.21 2000/06/01 15:23:06 rgbecker Exp $ '''
 # xml parser stuff for PythonPoint
 # PythonPoint Markup Language!
 __doc__="""
@@ -144,16 +147,12 @@
 import imp
 
 from reportlab.pdfgen import canvas
-from reportlab.platypus import layout
-from reportlab.platypus.paragraph import Paragraph
+from reportlab.platypus import Preformatted, Paragraph, Frame, Image
 from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
 from reportlab.lib import styles
 import stdparser 
-
-
+from reportlab.lib.pagesizes import DEFAULT_PAGE_SIZE
 
-
-        
 class PPPresentation:
     def __init__(self):
         self.filename = None
@@ -163,8 +162,8 @@
         self.showOutline = 1   #should it be displayed when opening?
         
         #assume landscape        
-        self.pageWidth = layout.DEFAULT_PAGE_SIZE[1]  
-        self.pageHeight = layout.DEFAULT_PAGE_SIZE[0]  
+        self.pageWidth = DEFAULT_PAGE_SIZE[1]  
+        self.pageHeight = DEFAULT_PAGE_SIZE[0]  
 
     def save(self):
         """This writes out the PDF document"""
@@ -247,8 +246,8 @@
         self.showBoundary = 0        
 
     def drawOn(self, canv):
-        #make a layout frame
-        frame = layout.Frame( self.x,
+        #make a frame
+        frame = Frame( self.x,
                               self.y,
                               self.width,
                               self.height
@@ -284,7 +283,7 @@
         self.style = None
 
     def getFlowable(self):
-        return layout.Preformatted(self.rawtext, getStyles()[self.style])
+        return Preformatted(self.rawtext, getStyles()[self.style])
 
 class PPImage:
     """Flowing image within the text"""
@@ -294,7 +293,7 @@
         self.height = None
 
     def getFlowable(self):
-        return layout.Image(self.filename, self.width, self.height)
+        return Image(self.filename, self.width, self.height)
 
 
 
--- a/reportlab/demos/pythonpoint/stdparser.py	Thu Jun 01 09:44:26 2000 +0000
+++ b/reportlab/demos/pythonpoint/stdparser.py	Thu Jun 01 15:23:06 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: stdparser.py,v $
+#	Revision 1.8  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
 #	Revision 1.7  2000/05/16 23:52:38  andy_robinson
 #	Bug in Image tag
-#
+#	
 #	Revision 1.6  2000/05/16 23:48:00  andy_robinson
 #	Allowed intra-paragraph text; fixed various bugs
 #	
@@ -70,7 +73,6 @@
 import string
 import imp
 import pythonpoint
-from reportlab.platypus import layout
 from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
 
 class PPMLParser(xmllib.XMLParser):
@@ -512,4 +514,4 @@
             self._curPara.rawtext = self._curPara.rawtext + '</%s>'% tag
         else:
             print 'Unknown end tag %s' % tag
-    
\ No newline at end of file
+    
--- a/reportlab/demos/pythonpoint/styles_horrible.py	Thu Jun 01 09:44:26 2000 +0000
+++ b/reportlab/demos/pythonpoint/styles_horrible.py	Thu Jun 01 15:23:06 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: styles_horrible.py,v $
+#	Revision 1.5  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
 #	Revision 1.4  2000/02/17 02:06:28  rgbecker
 #	Docstring & other fixes
-#
+#	
 #	Revision 1.3  2000/02/16 09:42:50  rgbecker
 #	Conversion to reportlab package
 #	
@@ -43,12 +46,12 @@
 #	Revision 1.1.1.1  2000/02/15 15:09:05  rgbecker
 #	Initial setup of demos directory and contents.
 #	
-__version__=''' $Id: styles_horrible.py,v 1.4 2000/02/17 02:06:28 rgbecker Exp $ '''
+__version__=''' $Id: styles_horrible.py,v 1.5 2000/06/01 15:23:06 rgbecker Exp $ '''
 # style_modern.py
 __doc__="""This is an example style sheet.  You can create your own, and
 have them loaded by the presentation.  A style sheet is just a
 dictionary, where they keys are style names and the values are
-layout.ParagraphStyle objects.
+ParagraphStyle objects.
 
 You must provide a function called "getParagraphStyles()" to
 return it.  In future, we can put things like LineStyles,
@@ -61,13 +64,12 @@
 A style sheet MUST define a style called 'Normal'.
 """
 
-from reportlab.platypus import layout
+from reportlab.lib import styles, enums
 def getParagraphStyles():
     """Returns a dictionary of styles based on Helvetica"""
     stylesheet = {}
-    ParagraphStyle = layout.ParagraphStyle
     
-    para = ParagraphStyle('Normal', None)   #the ancestor of all
+    para = styles.ParagraphStyle('Normal', None)   #the ancestor of all
     para.fontName = 'Courier'
     para.fontSize = 24
     para.leading = 28
@@ -79,7 +81,7 @@
     
     para = ParagraphStyle('BigCentered', stylesheet['Normal'])
     para.spaceBefore = 12
-    para.alignment = layout.TA_CENTER
+    para.alignment = enums.TA_CENTER
     stylesheet['BigCentered'] = para
 
     para = ParagraphStyle('Italic', stylesheet['BodyText'])
@@ -91,7 +93,7 @@
     para.fontSize = 48
     para.Leading = 58
     para.spaceAfter = 36
-    para.alignment = layout.TA_CENTER
+    para.alignment = enums.TA_CENTER
     stylesheet['Title'] = para
     
     para = ParagraphStyle('Heading1', stylesheet['Normal'])
@@ -99,7 +101,7 @@
     para.fontSize = 36
     para.leading = 44
     para.spaceAfter = 36
-    para.alignment = layout.TA_CENTER
+    para.alignment = enums.TA_CENTER
     stylesheet['Heading1'] = para
     
     para = ParagraphStyle('Heading2', stylesheet['Normal'])
--- a/reportlab/demos/pythonpoint/styles_modern.py	Thu Jun 01 09:44:26 2000 +0000
+++ b/reportlab/demos/pythonpoint/styles_modern.py	Thu Jun 01 15:23:06 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: styles_modern.py,v $
+#	Revision 1.6  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
 #	Revision 1.5  2000/05/16 23:48:01  andy_robinson
 #	Allowed intra-paragraph text; fixed various bugs
-#
+#	
 #	Revision 1.4  2000/02/17 02:06:28  rgbecker
 #	Docstring & other fixes
 #	
@@ -46,12 +49,12 @@
 #	Revision 1.1.1.1  2000/02/15 15:09:12  rgbecker
 #	Initial setup of demos directory and contents.
 #	
-__version__=''' $Id: styles_modern.py,v 1.5 2000/05/16 23:48:01 andy_robinson Exp $ '''
+__version__=''' $Id: styles_modern.py,v 1.6 2000/06/01 15:23:06 rgbecker Exp $ '''
 # style_modern.py
 __doc__="""This is an example style sheet.  You can create your own, and
 have them loaded by the presentation.  A style sheet is just a
 dictionary, where they keys are style names and the values are
-layout.ParagraphStyle objects.
+ParagraphStyle objects.
 
 You must provide a function called "getParagraphStyles()" to
 return it.  In future, we can put things like LineStyles,
@@ -64,7 +67,6 @@
 A style sheet MUST define a style called 'Normal'.
 """
 
-from reportlab.platypus import layout
 from reportlab.lib import styles
 from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT, TA_JUSTIFY
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reportlab/lib/sequencer.py	Thu Jun 01 15:23:06 2000 +0000
@@ -0,0 +1,67 @@
+###############################################################################
+#
+#	ReportLab Public License Version 1.0
+#
+#   Except for the change of names the spirit and intention of this
+#   license is the same as that of Python
+#
+#	(C) Copyright ReportLab Inc. 1998-2000.
+#
+#
+# All Rights Reserved
+#
+# Permission to use, copy, modify, and distribute this software and its
+# documentation for any purpose and without fee is hereby granted, provided
+# that the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of ReportLab not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission. 
+# 
+#
+# Disclaimer
+#
+# ReportLab Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+# IN NO EVENT SHALL ReportLab BE LIABLE FOR ANY SPECIAL, INDIRECT
+# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE. 
+#
+###############################################################################
+#	$Log: sequencer.py,v $
+#	Revision 1.1  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
+__version__=''' $Id: sequencer.py,v 1.1 2000/06/01 15:23:06 rgbecker Exp $ '''
+class Sequencer:
+	"""Something to make it easy to number paragraphs, sections,
+	images and anything else. Usage:
+		>>> seq = layout.Sequencer()
+		>>> seq.next('Bullets')
+		1
+		>>> seq.next('Bullets')
+		2
+		>>> seq.next('Bullets')
+		3
+		>>> seq.reset('Bullets')
+		>>> seq.next('Bullets')
+		1
+		>>> seq.next('Figures')
+		1
+		>>>
+	I plan to add multi-level linkages, so that Head2 could be reet
+	"""
+	def __init__(self):
+		self.dict = {}
+
+	def next(self, category):
+		if self.dict.has_key(category):
+			self.dict[category] = self.dict[category] + 1
+		else:
+			self.dict[category] = 1
+		return self.dict[category]
+
+	def reset(self, category):
+		self.dict[category] = 0
--- a/reportlab/pdfgen/canvas.py	Thu Jun 01 09:44:26 2000 +0000
+++ b/reportlab/pdfgen/canvas.py	Thu Jun 01 15:23:06 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: canvas.py,v $
+#	Revision 1.39  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
 #	Revision 1.38  2000/05/26 09:44:40  rgbecker
 #	generalised colors slightly
-#
+#	
 #	Revision 1.37  2000/05/23 14:06:45  andy_robinson
 #	Preformatted objects now know how to split themselves.
 #	
@@ -144,7 +147,7 @@
 #	Revision 1.2  2000/02/15 15:47:09  rgbecker
 #	Added license, __version__ and Logi comment
 #	
-__version__=''' $Id: canvas.py,v 1.38 2000/05/26 09:44:40 rgbecker Exp $ '''
+__version__=''' $Id: canvas.py,v 1.39 2000/06/01 15:23:06 rgbecker Exp $ '''
 __doc__=""" 
 PDFgen is a library to generate PDF files containing text and graphics.  It is the 
 foundation for a complete reporting solution in Python.  It is also the
@@ -934,7 +937,7 @@
             else:
                 raise 'Unknown color', str(aColor)
         elif type(aColor) is StringType:
-			self.setFillColor(colors.toColor(aColor))
+			self.setFillColor(toColor(aColor))
         else:
             raise 'Unknown color', str(aColor)
 
--- a/reportlab/platypus/__init__.py	Thu Jun 01 09:44:26 2000 +0000
+++ b/reportlab/platypus/__init__.py	Thu Jun 01 15:23:06 2000 +0000
@@ -31,14 +31,24 @@
 #
 ###############################################################################
 #	$Log: __init__.py,v $
+#	Revision 1.5  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
 #	Revision 1.4  2000/02/17 02:09:05  rgbecker
 #	Docstring & other fixes
-#
+#	
 #	Revision 1.3  2000/02/15 17:55:59  rgbecker
 #	License text fixes
 #	
 #	Revision 1.2  2000/02/15 15:47:09  rgbecker
 #	Added license, __version__ and Logi comment
 #	
-__version__=''' $Id: __init__.py,v 1.4 2000/02/17 02:09:05 rgbecker Exp $ '''
+__version__=''' $Id: __init__.py,v 1.5 2000/06/01 15:23:06 rgbecker Exp $ '''
 __doc__=''
+from flowables import Flowable, Image, Macro, PageBreak, Preformatted, Spacer, XBox
+from paragraph import Paragraph, cleanBlockQuotedText
+from paraparser import ParaFrag
+from tables import Table, TableStyle, CellStyle
+from frames import Frame
+from doctemplate import BaseDocTemplate, NextPageTemplate, PageTemplate, ActionFlowable, \
+						SimpleDocTemplate, FrameBreak
--- a/reportlab/platypus/doctemplate.py	Thu Jun 01 09:44:26 2000 +0000
+++ b/reportlab/platypus/doctemplate.py	Thu Jun 01 15:23:06 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: doctemplate.py,v $
+#	Revision 1.13  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
 #	Revision 1.12  2000/05/26 10:27:37  rgbecker
 #	Fixed infinite recursion bug
-#
+#	
 #	Revision 1.11  2000/05/17 22:17:38  rgbecker
 #	Renamed BasicFrame to Frame
 #	
@@ -67,15 +70,19 @@
 #	Revision 1.1  2000/05/12 12:53:33  rgbecker
 #	Initial try at a document template class
 #	
-__version__=''' $Id: doctemplate.py,v 1.12 2000/05/26 10:27:37 rgbecker Exp $ '''
+__version__=''' $Id: doctemplate.py,v 1.13 2000/06/01 15:23:06 rgbecker Exp $ '''
 __doc__="""
 More complicated Document model
 """
-from layout import *
-from layout import _doNothing
+from flowables import *
+from frames import Frame
 from types import *
 import sys
 
+def _doNothing(canvas, doc):
+	"Dummy callback for onPage"
+	pass
+
 class ActionFlowable(Flowable):
 	'''This Flowable is never drawn, it can be used for data driven controls'''
 	def __init__(self,action=[]):
@@ -149,23 +156,41 @@
 
 	4)	The document instances can override the base handler routines.
 	"""
-	def __init__(self, filename, pagesize=DEFAULT_PAGE_SIZE, pageTemplates=[], showBoundary=0,
-				leftMargin=inch, rightMargin=inch, topMargin=inch, bottomMargin=inch,
-				allowSplitting=1):
+	_initArgs = {	'pageSize':DEFAULT_PAGE_SIZE,
+					'pageTemplates':[],
+					'showBoundary':0,
+					'leftMargin':inch,
+					'rightMargin':inch,
+					'topMargin':inch,
+					'bottomMargin':inch,
+					'allowSplitting':1,
+					'title':None,
+					'author':None,
+					'_pageBreakQuick':1}
+	_invalidInitArgs = ()
 
-		self.pageTemplates = []
-		self.addPageTemplates(pageTemplates)
+	def __init__(self, filename, **kw):
 		self.filename = filename
-		self.showBoundary = showBoundary
-		self.leftMargin =  leftMargin
-		self.bottomMargin = bottomMargin
-		self.rightMargin = pagesize[0] - rightMargin
-		self.topMargin = pagesize[1] - topMargin
-		self.width = self.rightMargin - self.leftMargin
-		self.height = self.topMargin - self.bottomMargin
-		self.pagesize = pagesize
-		self.allowSplitting = allowSplitting
-		self._pageBreakQuick = 1
+
+		for k in self._initArgs.keys():
+			if not kw.has_key(k):
+				v = self._initArgs[k]
+			else:
+				if k in self._invalidInitArgs:
+					raise ValueError, "Invalid argument %s" % k
+				v = kw[k]
+			setattr(self,k,v)
+
+		p = self.pageTemplates
+		self.pageTemplates = []
+		self.addPageTemplates(p)
+		self._calc()
+
+	def _calc(self):
+		self._rightMargin = self.pageSize[0] - self.rightMargin
+		self._topMargin = self.pageSize[1] - self.topMargin
+		self.width = self._rightMargin - self.leftMargin
+		self.height = self._topMargin - self.bottomMargin
 
 	def clean_hanging(self):
 		'handle internal postponed actions'
@@ -322,6 +347,7 @@
 	_handle_nextFrame = handle_nextFrame
 
 	def _startBuild(self):
+		self._calc()
 		self.canv = canvas.Canvas(self.filename)
 		self.handle_documentBegin()
 
@@ -412,7 +438,7 @@
 	def run():
 		objects_to_draw = []
 		from reportlab.lib.styles import ParagraphStyle
-		from paragraph import Paragraph
+		#from paragraph import Paragraph
 		from doctemplate import SimpleDocTemplate
 
 		#need a style
@@ -427,7 +453,7 @@
 			para = Paragraph(randomText(), normal)
 			objects_to_draw.append(para)
 
-		SimpleDocTemplate('doctemplate.pdf',DEFAULT_PAGE_SIZE).build(objects_to_draw,
+		SimpleDocTemplate('doctemplate.pdf').build(objects_to_draw,
 			onFirstPage=myFirstPage,onLaterPages=myLaterPages)
 
 	run()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reportlab/platypus/flowables.py	Thu Jun 01 15:23:06 2000 +0000
@@ -0,0 +1,265 @@
+###############################################################################
+#
+#	ReportLab Public License Version 1.0
+#
+#	Except for the change of names the spirit and intention of this
+#	license is the same as that of Python
+#
+#	(C) Copyright ReportLab Inc. 1998-2000.
+#
+#
+# All Rights Reserved
+#
+# Permission to use, copy, modify, and distribute this software and its
+# documentation for any purpose and without fee is hereby granted, provided
+# that the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of ReportLab not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission.
+#
+#
+# Disclaimer
+#
+# ReportLab Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+# IN NO EVENT SHALL ReportLab BE LIABLE FOR ANY SPECIAL, INDIRECT
+# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+#
+###############################################################################
+#	$Log: flowables.py,v $
+#	Revision 1.1  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
+#	
+__version__=''' $Id: flowables.py,v 1.1 2000/06/01 15:23:06 rgbecker Exp $ '''
+__doc__="""
+"""
+
+# 200-10-13 gmcm
+#	packagizing
+#	rewrote grid stuff - now in tables.py
+import os
+import string
+from copy import deepcopy
+
+
+from reportlab.pdfgen import canvas
+from reportlab.lib.units import inch
+from reportlab.lib.colors import red
+from reportlab.pdfbase import pdfutils
+
+from reportlab.lib.pagesizes import DEFAULT_PAGE_SIZE
+PAGE_HEIGHT = DEFAULT_PAGE_SIZE[1]
+
+#############################################################
+#	Flowable Objects - a base class and a few examples.
+#	One is just a box to get some metrics.	We also have
+#	a paragraph, an image and a special 'page break'
+#	object which fills the space.
+#############################################################
+class Flowable:
+	"""Abstract base class for things to be drawn.	Key concepts:
+	1. It knows its size
+	2. It draws in its own coordinate system (this requires the
+		base API to provide a translate() function.
+	"""
+	def __init__(self):
+		self.width = 0
+		self.height = 0
+		self.wrapped = 0
+
+	def drawOn(self, canvas, x, y):
+		"Tell it to draw itself on the canvas.	Do not override"
+		self.canv = canvas
+		self.canv.saveState()
+		self.canv.translate(x, y)
+
+		self.draw()   #this is the bit you overload
+
+		self.canv.restoreState()
+		del self.canv
+
+
+	def wrap(self, availWidth, availHeight):
+		"""This will be called by the enclosing frame before objects
+		are asked their size, drawn or whatever.  It returns the
+		size actually used."""
+		return (self.width, self.height)
+
+	def split(self, availWidth, availheight):
+		"""This will be called by more sophisticated frames when
+		wrap fails. Stupid flowables should return []. Clever flowables
+		should split themselves and return a list of flowables"""
+		return []
+
+	def getSpaceAfter(self):
+		if hasattr(self,'spaceAfter'): return self.spaceAfter
+		elif hasattr(self,'style') and hasattr(self.style,'spaceAfter'): return self.style.spaceAfter
+		else: return 0
+
+	def getSpaceBefore(self):
+		if hasattr(self,'spaceBefore'): return self.spaceBefore
+		elif hasattr(self,'style') and hasattr(self.style,'spaceBefore'): return self.style.spaceBefore
+		else: return 0
+
+class XBox(Flowable):
+	"""Example flowable - a box with an x through it and a caption.
+	This has a known size, so does not need to respond to wrap()."""
+	def __init__(self, width, height, text = 'A Box'):
+		Flowable.__init__(self)
+		self.width = width
+		self.height = height
+		self.text = text
+
+	def draw(self):
+		self.canv.rect(0, 0, self.width, self.height)
+		self.canv.line(0, 0, self.width, self.height)
+		self.canv.line(0, self.height, self.width, 0)
+
+		#centre the text
+		self.canv.setFont('Times-Roman',12)
+		self.canv.drawCentredString(0.5*self.width, 0.5*self.height, self.text)
+
+class Preformatted(Flowable):
+	"""This is like the HTML <PRE> tag.  The line breaks are exactly where you put
+	them, and it will not be wrapped.  So it is much simpler to implement!"""
+	def __init__(self, text, style, bulletText = None, dedent=0):
+		self.style = style
+		self.bulletText = bulletText
+
+		#tidy up text - carefully, it is probably code.  If people want to
+		#indent code within a source script, you can supply an arg to dedent
+		#and it will chop off that many character, otherwise it leaves
+		#left edge intact.
+
+		templines = string.split(text, '\n')
+		self.lines = []
+		for line in templines:
+			line = string.rstrip(line[dedent:])
+			self.lines.append(line)
+		#don't want the first or last to be empty
+		while string.strip(self.lines[0]) == '':
+			self.lines = self.lines[1:]
+		while string.strip(self.lines[-1]) == '':
+			self.lines = self.lines[:-1]
+
+	def wrap(self, availWidth, availHeight):
+		self.width = availWidth
+		self.height = self.style.leading*len(self.lines)
+		return (self.width, self.height)
+
+	def split(self, availWidth, availHeight):
+		#returns two Preformatted objects
+
+		#not sure why they can be called with a negative height		
+		if availHeight < self.style.leading:
+			return []
+		
+		linesThatFit = int(availHeight * 1.0 / self.style.leading)
+		
+		text1 = string.join(self.lines[0:linesThatFit], '\n')
+		text2 = string.join(self.lines[linesThatFit:], '\n')
+		style = self.style
+		if style.firstLineIndent != 0:
+			style = deepcopy(style)
+			style.firstLineIndent = 0
+		return [Preformatted(text1, self.style), Preformatted(text2, style)]
+		
+
+	def draw(self):
+		#call another method for historical reasons.  Besides, I
+		#suspect I will be playing with alternate drawing routines
+		#so not doing it here makes it easier to switch.
+
+		cur_x = self.style.leftIndent
+		cur_y = self.height - self.style.fontSize
+		self.canv.addLiteral('%PreformattedPara')
+		if self.style.textColor:
+			self.canv.setFillColor(self.style.textColor)
+		tx = self.canv.beginText(cur_x, cur_y)
+		#set up the font etc.
+		tx.setFont(self.style.fontName,
+				   self.style.fontSize,
+				   self.style.leading)
+
+		for text in self.lines:
+			tx.textLine(text)
+		self.canv.drawText(tx)
+
+class Image(Flowable):
+	def __init__(self, filename, width=None, height=None):
+		"""If size to draw at not specified, get it from the image."""
+		import Image  #this will raise an error if they do not have PIL.
+		self.filename = filename
+		# if it is a JPEG, will be inlined within the file -
+		# but we still need to know its size now
+		if os.path.splitext(filename)[1] in ['.jpg', '.JPG', '.jpeg', '.JPEG']:
+			info = pdfutils.readJPEGInfo(open(filename, 'rb'))
+			self.imageWidth = info[0]
+			self.imageHeight = info[1]
+		else:
+			img = Image.open(filename)
+			(self.imageWidth, self.imageHeight) = img.size
+		if width:
+			self.drawWidth = width
+		else:
+			self.drawWidth = self.imageWidth
+		if height:
+			self.drawHeight = height
+		else:
+			self.drawHeight = self.imageHeight
+
+	def wrap(self, availWidth, availHeight):
+		#the caller may decide it does not fit.
+		self.availWidth = availWidth
+		return (self.drawWidth, self.drawHeight)
+
+	def draw(self):
+		#center it
+		startx = 0.5 * (self.availWidth - self.drawWidth)
+		self.canv.drawInlineImage(self.filename,
+								  startx,
+								  0,
+								  self.drawWidth,
+								  self.drawHeight
+								  )
+class Spacer(Flowable):
+	"""A spacer just takes up space and doesn't draw anything - it can
+	ensure a gap between objects."""
+	def __init__(self, width, height):
+		self.width = width
+		self.height = height
+
+	def wrap(self, availWidth, availHeight):
+		return (self.width, self.height)
+
+	def draw(self):
+		pass
+
+class PageBreak(Flowable):
+	"""This works by consuming all remaining space in the frame!"""
+
+	def wrap(self, availWidth, availHeight):
+		self.width = availWidth
+		self.height = availHeight
+		return (availWidth,availHeight)  #step back a point
+
+	def draw(self):
+		pass
+
+class Macro(Flowable):
+	"""This is not actually drawn (i.e. it has zero height)
+	but is executed when it would fit in the frame.  Allows direct
+	access to the canvas through the object 'canvas'"""
+	def __init__(self, command):
+		self.command = command
+	def wrap(self, availWidth, availHeight):
+		return (0,0)
+	def draw(self):
+		exec self.command in globals(), {'canvas':self.canv}
+
+from paragraph import Paragraph
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reportlab/platypus/frames.py	Thu Jun 01 15:23:06 2000 +0000
@@ -0,0 +1,155 @@
+###############################################################################
+#
+#	ReportLab Public License Version 1.0
+#
+#	Except for the change of names the spirit and intention of this
+#	license is the same as that of Python
+#
+#	(C) Copyright ReportLab Inc. 1998-2000.
+#
+#
+# All Rights Reserved
+#
+# Permission to use, copy, modify, and distribute this software and its
+# documentation for any purpose and without fee is hereby granted, provided
+# that the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of ReportLab not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission.
+#
+#
+# Disclaimer
+#
+# ReportLab Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+# IN NO EVENT SHALL ReportLab BE LIABLE FOR ANY SPECIAL, INDIRECT
+# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+#
+###############################################################################
+#	$Log: frames.py,v $
+#	Revision 1.1  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
+__version__=''' $Id: frames.py,v 1.1 2000/06/01 15:23:06 rgbecker Exp $ '''
+__doc__="""
+"""
+class Frame:
+	'''Abstraction for the definitional part of a Frame
+
+                width                    x2,y2
+    	+---------------------------------+
+    	| l  top padding                r | h
+    	| e +-------------------------+ i | e
+    	| f |                         | g | i
+    	| t |                         | h | g
+    	|   |                         | t | h
+    	| p |                         |   | t
+    	| a |                         | p |
+    	| d |                         | a |
+    	|   |                         | d |
+    	|   +-------------------------+   |
+    	|    bottom padding				  |
+    	+---------------------------------+
+    	(x1,y1)
+	'''
+	def __init__(self, x1, y1, width,height, leftPadding=6, bottomPadding=6,
+			rightPadding=6, topPadding=6, id=None, showBoundary=0):
+
+		self.id = id
+
+		#these say where it goes on the page
+		self.x1 = x1
+		self.y1 = y1
+		self.x2 = x1 + width
+		self.y2 = y1 + height
+
+		#these create some padding.
+		self.leftPadding = leftPadding
+		self.bottomPadding = bottomPadding
+		self.rightPadding = rightPadding
+		self.topPadding = topPadding
+
+		#efficiency
+		self.y1p = self.y1 + bottomPadding
+
+		# if we want a boundary to be shown
+		self.showBoundary = showBoundary
+
+		self._reset()
+
+	def	_reset(self):
+		#work out the available space
+		self.width = self.x2 - self.x1 - self.leftPadding - self.rightPadding
+		self.height = self.y2 - self.y1 - self.topPadding - self.bottomPadding
+		#drawing starts at top left
+		self.x = self.x1 + self.leftPadding
+		self.y = self.y2 - self.topPadding
+		self.atTop = 1
+
+	def _add(self, flowable, canv, trySplit=0):
+		""" Draws the flowable at the current position.
+		Returns 1 if successful, 0 if it would not fit.
+		Raises a LayoutError if the object is too wide,
+		or if it is too high for a totally empty frame,
+		to avoid infinite loops"""
+		y = self.y
+		p = self.y1p
+		s = self.atTop and 0 or flowable.getSpaceBefore()
+		h = y - p - s
+		if h>0:
+			w, h = flowable.wrap(self.width, h)
+		else:
+			return 0
+
+		h = h + s
+		y = y - h
+
+		if y < p:
+			if ((h > self.height and not trySplit) or w > self.width):
+				raise "LayoutError", "Flowable (%dx%d points) too large for frame (%dx%d points)." % (w,h, self.width,self.height)
+			return 0
+		else:
+			#now we can draw it, and update the current point.
+			flowable.drawOn(canv, self.x, y)
+			y = y - flowable.getSpaceAfter()
+			self.atTop = 0
+			self.y = y
+			return 1
+
+	add = _add
+
+	def split(self,flowable):
+		'''calls split on the flowable'''
+		y = self.y
+		p = self.y1p
+		s = self.atTop and 0 or flowable.getSpaceBefore()
+		return flowable.split(self.width, y-p-s)
+
+
+	def drawBoundary(self,canv):
+		canv.rect(
+				self.x1,
+				self.y1,
+				self.x2 - self.x1,
+				self.y2 - self.y1
+				)
+		
+	def addFromList(self, drawlist, canv):
+		"""Consumes objects from the front of the list until the
+		frame is full.	If it cannot fit one object, raises
+		an exception."""
+
+		if self.showBoundary:
+			self.drawBoundary(canv)
+
+		while len(drawlist) > 0:
+			head = drawlist[0]
+			if self.add(head,canv,trySplit=0):
+				del drawlist[0]
+			else:
+				#leave it in the list for later
+				break
--- a/reportlab/platypus/layout.py	Thu Jun 01 09:44:26 2000 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,502 +0,0 @@
-###############################################################################
-#
-#	ReportLab Public License Version 1.0
-#
-#	Except for the change of names the spirit and intention of this
-#	license is the same as that of Python
-#
-#	(C) Copyright ReportLab Inc. 1998-2000.
-#
-#
-# All Rights Reserved
-#
-# Permission to use, copy, modify, and distribute this software and its
-# documentation for any purpose and without fee is hereby granted, provided
-# that the above copyright notice appear in all copies and that both that
-# copyright notice and this permission notice appear in supporting
-# documentation, and that the name of ReportLab not be used
-# in advertising or publicity pertaining to distribution of the software
-# without specific, written prior permission.
-#
-#
-# Disclaimer
-#
-# ReportLab Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
-# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
-# IN NO EVENT SHALL ReportLab BE LIABLE FOR ANY SPECIAL, INDIRECT
-# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
-# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
-# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-# PERFORMANCE OF THIS SOFTWARE.
-#
-###############################################################################
-#	$Log: layout.py,v $
-#	Revision 1.30  2000/05/23 14:08:02  andy_robinson
-#	Preformatted objects now splitting
-#
-#	Revision 1.29  2000/05/18 09:05:08  andy_robinson
-#	Resynchronization
-#	
-#	Revision 1.28  2000/05/17 22:17:38  rgbecker
-#	Renamed BasicFrame to Frame
-#	
-#	Revision 1.27  2000/05/17 16:29:40  rgbecker
-#	Removal of SimpleFrame
-#	
-#	Revision 1.26  2000/05/16 16:15:16  rgbecker
-#	Changes related to removal of SimpleFlowDocument
-#	
-#	Revision 1.25  2000/05/15 13:36:11  rgbecker
-#	Splitting changes
-#	
-#	Revision 1.24  2000/05/12 12:52:00  rgbecker
-#	Fixes to BasicFrame split method
-#	
-#	Revision 1.23  2000/05/11 14:02:14  rgbecker
-#	Removed usage of spaceBefore/After in wrap methods
-#	
-#	Revision 1.22  2000/05/10 13:04:35  rgbecker
-#	Added softspace handling
-#	
-#	Revision 1.21  2000/05/10 09:54:40  rgbecker
-#	Flowable.split should return list
-#	
-#	Revision 1.20  2000/04/28 13:39:12  rgbecker
-#	Fix _doNothing argument name
-#	
-#	Revision 1.19  2000/04/26 11:07:15  andy_robinson
-#	Tables changed to use reportlab.lib.colors instead of
-#	the six hard-coded color strings there previously.
-#	
-#	Revision 1.18  2000/04/25 15:42:04  rgbecker
-#	Factored out BasicFrame from SimpleFrame
-#	
-#	Revision 1.17  2000/04/14 16:12:11  rgbecker
-#	Debugging xml changes
-#	
-#	Revision 1.16  2000/04/14 11:54:57  rgbecker
-#	Splitting layout.py
-#	
-#	Revision 1.15  2000/04/14 08:56:20  rgbecker
-#	Drawable ==> Flowable
-#	
-#	Revision 1.14  2000/04/13 17:06:40  rgbecker
-#	Fixed SimpleFrame.add
-#	
-#	Revision 1.13  2000/04/13 14:48:41  rgbecker
-#	<para> tag added in layout.py paraparser.py
-#	
-#	Revision 1.12  2000/04/12 16:26:51  rgbecker
-#	XML Tagged Paragraph parser changes
-#	
-#	Revision 1.11  2000/04/10 14:08:19  rgbecker
-#	fixes related to offset
-#	
-#	Revision 1.10  2000/04/10 12:25:10  rgbecker
-#	Typo fixes for justified paras
-#	
-#	Revision 1.9  2000/04/07 12:31:29  rgbecker
-#	Color fixes/changes
-#	
-#	Revision 1.8  2000/04/06 09:52:02  andy_robinson
-#	Removed some old comments; tweaks to experimental Outline methods.
-#	
-#	Revision 1.7  2000/03/08 13:06:39  andy_robinson
-#	Moved inch and cm definitions to reportlab.lib.units and amended all demos
-#	
-#	Revision 1.6  2000/02/23 10:53:33  rgbecker
-#	GMCM's memleak fixed
-#	
-#	Revision 1.5  2000/02/17 02:09:05  rgbecker
-#	Docstring & other fixes
-#	
-#	Revision 1.4  2000/02/16 09:42:50  rgbecker
-#	Conversion to reportlab package
-#	
-#	Revision 1.3  2000/02/15 17:55:59  rgbecker
-#	License text fixes
-#	
-#	Revision 1.2  2000/02/15 15:47:09  rgbecker
-#	Added license, __version__ and Logi comment
-#	
-__version__=''' $Id: layout.py,v 1.30 2000/05/23 14:08:02 andy_robinson Exp $ '''
-__doc__="""
-Page Layout And TYPography Using Scripts
-a page layout API on top of PDFgen
-currently working on paragraph wrapping stuff.
-"""
-
-# 200-10-13 gmcm
-#	packagizing
-#	rewrote grid stuff - now in tables.py
-import os
-import string
-from copy import deepcopy
-
-
-from reportlab.pdfgen import canvas
-from reportlab.lib.units import inch
-from reportlab.lib.colors import red
-from reportlab.pdfbase import pdfutils
-
-from reportlab.lib.pagesizes import DEFAULT_PAGE_SIZE
-PAGE_HEIGHT = DEFAULT_PAGE_SIZE[1]
-
-#############################################################
-#	Flowable Objects - a base class and a few examples.
-#	One is just a box to get some metrics.	We also have
-#	a paragraph, an image and a special 'page break'
-#	object which fills the space.
-#############################################################
-class Flowable:
-	"""Abstract base class for things to be drawn.	Key concepts:
-	1. It knows its size
-	2. It draws in its own coordinate system (this requires the
-		base API to provide a translate() function.
-	"""
-	def __init__(self):
-		self.width = 0
-		self.height = 0
-		self.wrapped = 0
-
-	def drawOn(self, canvas, x, y):
-		"Tell it to draw itself on the canvas.	Do not override"
-		self.canv = canvas
-		self.canv.saveState()
-		self.canv.translate(x, y)
-
-		self.draw()   #this is the bit you overload
-
-		self.canv.restoreState()
-		del self.canv
-
-
-	def wrap(self, availWidth, availHeight):
-		"""This will be called by the enclosing frame before objects
-		are asked their size, drawn or whatever.  It returns the
-		size actually used."""
-		return (self.width, self.height)
-
-	def split(self, availWidth, availheight):
-		"""This will be called by more sophisticated frames when
-		wrap fails. Stupid flowables should return []. Clever flowables
-		should split themselves and return a list of flowables"""
-		return []
-
-	def getSpaceAfter(self):
-		if hasattr(self,'spaceAfter'): return self.spaceAfter
-		elif hasattr(self,'style') and hasattr(self.style,'spaceAfter'): return self.style.spaceAfter
-		else: return 0
-
-	def getSpaceBefore(self):
-		if hasattr(self,'spaceBefore'): return self.spaceBefore
-		elif hasattr(self,'style') and hasattr(self.style,'spaceBefore'): return self.style.spaceBefore
-		else: return 0
-
-class XBox(Flowable):
-	"""Example flowable - a box with an x through it and a caption.
-	This has a known size, so does not need to respond to wrap()."""
-	def __init__(self, width, height, text = 'A Box'):
-		Flowable.__init__(self)
-		self.width = width
-		self.height = height
-		self.text = text
-
-	def draw(self):
-		self.canv.rect(0, 0, self.width, self.height)
-		self.canv.line(0, 0, self.width, self.height)
-		self.canv.line(0, self.height, self.width, 0)
-
-		#centre the text
-		self.canv.setFont('Times-Roman',12)
-		self.canv.drawCentredString(0.5*self.width, 0.5*self.height, self.text)
-
-class Preformatted(Flowable):
-	"""This is like the HTML <PRE> tag.  The line breaks are exactly where you put
-	them, and it will not be wrapped.  So it is much simpler to implement!"""
-	def __init__(self, text, style, bulletText = None, dedent=0):
-		self.style = style
-		self.bulletText = bulletText
-
-		#tidy up text - carefully, it is probably code.  If people want to
-		#indent code within a source script, you can supply an arg to dedent
-		#and it will chop off that many character, otherwise it leaves
-		#left edge intact.
-
-		templines = string.split(text, '\n')
-		self.lines = []
-		for line in templines:
-			line = string.rstrip(line[dedent:])
-			self.lines.append(line)
-		#don't want the first or last to be empty
-		while string.strip(self.lines[0]) == '':
-			self.lines = self.lines[1:]
-		while string.strip(self.lines[-1]) == '':
-			self.lines = self.lines[:-1]
-
-	def wrap(self, availWidth, availHeight):
-		self.width = availWidth
-		self.height = self.style.leading*len(self.lines)
-		return (self.width, self.height)
-
-	def split(self, availWidth, availHeight):
-		#returns two Preformatted objects
-
-		#not sure why they can be called with a negative height		
-		if availHeight < self.style.leading:
-			return []
-		
-		linesThatFit = int(availHeight * 1.0 / self.style.leading)
-		
-		text1 = string.join(self.lines[0:linesThatFit], '\n')
-		text2 = string.join(self.lines[linesThatFit:], '\n')
-		style = self.style
-		if style.firstLineIndent != 0:
-			style = deepcopy(style)
-			style.firstLineIndent = 0
-		return [Preformatted(text1, style), Preformatted(text2, style)]
-		
-
-	def draw(self):
-		#call another method for historical reasons.  Besides, I
-		#suspect I will be playing with alternate drawing routines
-		#so not doing it here makes it easier to switch.
-
-		cur_x = self.style.leftIndent
-		cur_y = self.height - self.style.fontSize
-		self.canv.addLiteral('%PreformattedPara')
-		if self.style.textColor:
-			self.canv.setFillColor(self.style.textColor)
-		tx = self.canv.beginText(cur_x, cur_y)
-		#set up the font etc.
-		tx.setFont(self.style.fontName,
-				   self.style.fontSize,
-				   self.style.leading)
-
-		for text in self.lines:
-			tx.textLine(text)
-		self.canv.drawText(tx)
-
-class Image(Flowable):
-	def __init__(self, filename, width=None, height=None):
-		"""If size to draw at not specified, get it from the image."""
-		import Image  #this will raise an error if they do not have PIL.
-		self.filename = filename
-		# if it is a JPEG, will be inlined within the file -
-		# but we still need to know its size now
-		if os.path.splitext(filename)[1] in ['.jpg', '.JPG', '.jpeg', '.JPEG']:
-			info = pdfutils.readJPEGInfo(open(filename, 'rb'))
-			self.imageWidth = info[0]
-			self.imageHeight = info[1]
-		else:
-			img = Image.open(filename)
-			(self.imageWidth, self.imageHeight) = img.size
-		if width:
-			self.drawWidth = width
-		else:
-			self.drawWidth = self.imageWidth
-		if height:
-			self.drawHeight = height
-		else:
-			self.drawHeight = self.imageHeight
-
-	def wrap(self, availWidth, availHeight):
-		#the caller may decide it does not fit.
-		self.availWidth = availWidth
-		return (self.drawWidth, self.drawHeight)
-
-	def draw(self):
-		#center it
-		startx = 0.5 * (self.availWidth - self.drawWidth)
-		self.canv.drawInlineImage(self.filename,
-								  startx,
-								  0,
-								  self.drawWidth,
-								  self.drawHeight
-								  )
-class Spacer(Flowable):
-	"""A spacer just takes up space and doesn't draw anything - it can
-	ensure a gap between objects."""
-	def __init__(self, width, height):
-		self.width = width
-		self.height = height
-
-	def wrap(self, availWidth, availHeight):
-		return (self.width, self.height)
-
-	def draw(self):
-		pass
-
-class PageBreak(Flowable):
-	"""This works by consuming all remaining space in the frame!"""
-
-	def wrap(self, availWidth, availHeight):
-		self.width = availWidth
-		self.height = availHeight
-		return (availWidth,availHeight)  #step back a point
-
-	def draw(self):
-		pass
-
-class Macro(Flowable):
-	"""This is not actually drawn (i.e. it has zero height)
-	but is executed when it would fit in the frame.  Allows direct
-	access to the canvas through the object 'canvas'"""
-	def __init__(self, command):
-		self.command = command
-	def wrap(self, availWidth, availHeight):
-		return (0,0)
-	def draw(self):
-		exec self.command in globals(), {'canvas':self.canv}
-
-class Frame:
-	'''Abstraction for the definitional part of a Frame
-
-                width                    x2,y2
-    	+---------------------------------+
-    	| l  top padding                r | h
-    	| e +-------------------------+ i | e
-    	| f |                         | g | i
-    	| t |                         | h | g
-    	|   |                         | t | h
-    	| p |                         |   | t
-    	| a |                         | p |
-    	| d |                         | a |
-    	|   |                         | d |
-    	|   +-------------------------+   |
-    	|    bottom padding				  |
-    	+---------------------------------+
-    	(x1,y1)
-	'''
-	def __init__(self, x1, y1, width,height, leftPadding=6, bottomPadding=6,
-			rightPadding=6, topPadding=6, id=None, showBoundary=0):
-
-		self.id = id
-
-		#these say where it goes on the page
-		self.x1 = x1
-		self.y1 = y1
-		self.x2 = x1 + width
-		self.y2 = y1 + height
-
-		#these create some padding.
-		self.leftPadding = leftPadding
-		self.bottomPadding = bottomPadding
-		self.rightPadding = rightPadding
-		self.topPadding = topPadding
-
-		#efficiency
-		self.y1p = self.y1 + bottomPadding
-
-		# if we want a boundary to be shown
-		self.showBoundary = showBoundary
-
-		self._reset()
-
-	def	_reset(self):
-		#work out the available space
-		self.width = self.x2 - self.x1 - self.leftPadding - self.rightPadding
-		self.height = self.y2 - self.y1 - self.topPadding - self.bottomPadding
-		#drawing starts at top left
-		self.x = self.x1 + self.leftPadding
-		self.y = self.y2 - self.topPadding
-		self.atTop = 1
-
-	def _add(self, flowable, canv, trySplit=0):
-		""" Draws the flowable at the current position.
-		Returns 1 if successful, 0 if it would not fit.
-		Raises a LayoutError if the object is too wide,
-		or if it is too high for a totally empty frame,
-		to avoid infinite loops"""
-		y = self.y
-		p = self.y1p
-		s = self.atTop and 0 or flowable.getSpaceBefore()
-		h = y - p - s
-		if h>0:
-			w, h = flowable.wrap(self.width, h)
-		else:
-			return 0
-
-		h = h + s
-		y = y - h
-
-		if y < p:
-			if ((h > self.height and not trySplit) or w > self.width):
-				raise "LayoutError", "Flowable (%dx%d points) too large for frame (%dx%d points)." % (w,h, self.width,self.height)
-			return 0
-		else:
-			#now we can draw it, and update the current point.
-			flowable.drawOn(canv, self.x, y)
-			y = y - flowable.getSpaceAfter()
-			self.atTop = 0
-			self.y = y
-			return 1
-
-	add = _add
-
-	def split(self,flowable):
-		'''calls split on the flowable'''
-		y = self.y
-		p = self.y1p
-		s = self.atTop and 0 or flowable.getSpaceBefore()
-		return flowable.split(self.width, y-p-s)
-
-
-	def drawBoundary(self,canv):
-		canv.rect(
-				self.x1,
-				self.y1,
-				self.x2 - self.x1,
-				self.y2 - self.y1
-				)
-		
-	def addFromList(self, drawlist, canv):
-		"""Consumes objects from the front of the list until the
-		frame is full.	If it cannot fit one object, raises
-		an exception."""
-
-		if self.showBoundary:
-			self.drawBoundary(canv)
-
-		while len(drawlist) > 0:
-			head = drawlist[0]
-			if self.add(head,canv,trySplit=0):
-				del drawlist[0]
-			else:
-				#leave it in the list for later
-				break
-
-class Sequencer:
-	"""Something to make it easy to number paragraphs, sections,
-	images and anything else. Usage:
-		>>> seq = layout.Sequencer()
-		>>> seq.next('Bullets')
-		1
-		>>> seq.next('Bullets')
-		2
-		>>> seq.next('Bullets')
-		3
-		>>> seq.reset('Bullets')
-		>>> seq.next('Bullets')
-		1
-		>>> seq.next('Figures')
-		1
-		>>>
-	I plan to add multi-level linkages, so that Head2 could be reet
-	"""
-	def __init__(self):
-		self.dict = {}
-
-	def next(self, category):
-		if self.dict.has_key(category):
-			self.dict[category] = self.dict[category] + 1
-		else:
-			self.dict[category] = 1
-		return self.dict[category]
-
-	def reset(self, category):
-		self.dict[category] = 0
-
-def _doNothing(canvas, doc):
-	"Dummy callback for onPage"
-	pass
--- a/reportlab/platypus/paragraph.py	Thu Jun 01 09:44:26 2000 +0000
+++ b/reportlab/platypus/paragraph.py	Thu Jun 01 15:23:06 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: paragraph.py,v $
+#	Revision 1.11  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
 #	Revision 1.10  2000/05/31 10:12:20  rgbecker
 #	<bullet> xml tag added
-#
+#	
 #	Revision 1.9  2000/05/16 16:15:16  rgbecker
 #	Changes related to removal of SimpleFlowDocument
 #	
@@ -61,12 +64,12 @@
 #	Revision 1.1  2000/04/14 13:21:52  rgbecker
 #	Removed from layout.py
 #	
-__version__=''' $Id: paragraph.py,v 1.10 2000/05/31 10:12:20 rgbecker Exp $ '''
+__version__=''' $Id: paragraph.py,v 1.11 2000/06/01 15:23:06 rgbecker Exp $ '''
 import string
 import types
 from reportlab.pdfbase.pdfmetrics import stringWidth
-from reportlab.platypus.paraparser import ParaParser, ParaFrag
-from layout import Flowable
+from paraparser import ParaParser, ParaFrag
+from 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
--- a/reportlab/platypus/paraparser.py	Thu Jun 01 09:44:26 2000 +0000
+++ b/reportlab/platypus/paraparser.py	Thu Jun 01 15:23:06 2000 +0000
@@ -1,4 +1,3 @@
-#!/bin/env python
 ###############################################################################
 #
 #	ReportLab Public License Version 1.0
@@ -32,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: paraparser.py,v $
+#	Revision 1.21  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
 #	Revision 1.20  2000/05/31 10:12:20  rgbecker
 #	<bullet> xml tag added
-#
+#	
 #	Revision 1.19  2000/05/26 09:49:23  rgbecker
 #	Color fixes; thanks to J Alet
 #	
@@ -56,7 +58,7 @@
 #	Revision 1.13  2000/04/25 13:07:57  rgbecker
 #	Added license
 #	
-__version__=''' $Id: paraparser.py,v 1.20 2000/05/31 10:12:20 rgbecker Exp $ '''
+__version__=''' $Id: paraparser.py,v 1.21 2000/06/01 15:23:06 rgbecker Exp $ '''
 import string
 import re
 from types import TupleType
@@ -490,7 +492,7 @@
 		return style, fragList, bFragList
 
 if __name__=='__main__':
-	from reportlab.platypus.paragraph import cleanBlockQuotedText
+	from reportlab.platypus import cleanBlockQuotedText
 	_parser=ParaParser()
 	def check_text(text,p=_parser):
 		print '##########'
--- a/reportlab/platypus/tables.py	Thu Jun 01 09:44:26 2000 +0000
+++ b/reportlab/platypus/tables.py	Thu Jun 01 15:23:06 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: tables.py,v $
+#	Revision 1.11  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
 #	Revision 1.10  2000/05/26 09:49:23  rgbecker
 #	Color fixes; thanks to J Alet
-#
+#	
 #	Revision 1.9  2000/05/16 16:15:16  rgbecker
 #	Changes related to removal of SimpleFlowDocument
 #	
@@ -59,16 +62,16 @@
 #	Revision 1.2  2000/02/15 15:47:09  rgbecker
 #	Added license, __version__ and Logi comment
 #	
-__version__=''' $Id: tables.py,v 1.10 2000/05/26 09:49:23 rgbecker Exp $ '''
+__version__=''' $Id: tables.py,v 1.11 2000/06/01 15:23:06 rgbecker Exp $ '''
 __doc__="""
 Tables are created by passing the constructor a tuple of column widths, a tuple of row heights and the data in
 row order. Drawing of the table can be controlled by using a TableStyle instance. This allows control of the
 color and weight of the lines (if any), and the font, alignment and padding of the text.
 """
-from reportlab.platypus.doctemplate import *
-from reportlab.platypus.paragraph import Paragraph
+from reportlab.platypus import *
 from reportlab.lib.styles import PropertySet, getSampleStyleSheet
 from reportlab.lib import colors
+from reportlab.lib.pagesizes import DEFAULT_PAGE_SIZE
 import operator
 
 _stringtype = type('')
@@ -492,7 +495,7 @@
      ('BACKGROUND', (0,0), (-1,0), colors.Color(0,0.7,0.7))]
     )
     """, styleSheet['Code']))
-    SimpleDocTemplate('testtables.pdf', DEFAULT_PAGE_SIZE, showBoundary=1).build(lst)
+    SimpleDocTemplate('testtables.pdf', showBoundary=1).build(lst)
 
 if __name__ == '__main__':
     test()
--- a/reportlab/platypus/test/testplatypus.py	Thu Jun 01 09:44:26 2000 +0000
+++ b/reportlab/platypus/test/testplatypus.py	Thu Jun 01 15:23:06 2000 +0000
@@ -31,26 +31,29 @@
 #
 ###############################################################################
 #	$Log: testplatypus.py,v $
-#	Revision 1.16  2000/05/17 22:17:38  rgbecker
+#	Revision 1.17  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
+#	Revision 1.16  2000/05/17 22:17:38	rgbecker
 #	Renamed BasicFrame to Frame
-#
-#	Revision 1.15  2000/05/16 14:28:55  rgbecker
+#	
+#	Revision 1.15  2000/05/16 14:28:55	rgbecker
 #	Fixes/Changes to get testplatypus to work with new framework
 #	
-#	Revision 1.14  2000/04/26 11:07:15  andy_robinson
+#	Revision 1.14  2000/04/26 11:07:15	andy_robinson
 #	Tables changed to use reportlab.lib.colors instead of
 #	the six hard-coded color strings there previously.
 #	
-#	Revision 1.13  2000/04/14 12:42:35  rgbecker
+#	Revision 1.13  2000/04/14 12:42:35	rgbecker
 #	Minor textual and spacing adjustments
 #	
-#	Revision 1.12  2000/04/14 11:54:57  rgbecker
+#	Revision 1.12  2000/04/14 11:54:57	rgbecker
 #	Splitting layout.py
 #	
-#	Revision 1.11  2000/04/14 08:56:20  rgbecker
+#	Revision 1.11  2000/04/14 08:56:20	rgbecker
 #	Drawable ==> Flowable
 #	
-#	Revision 1.10  2000/04/13 17:10:38  rgbecker
+#	Revision 1.10  2000/04/13 17:10:38	rgbecker
 #	minor adjustments
 #	
 #	Revision 1.9  2000/04/13 14:48:41  rgbecker
@@ -77,7 +80,7 @@
 #	Revision 1.2  2000/02/15 15:47:10  rgbecker
 #	Added license, __version__ and Logi comment
 #	
-__version__=''' $Id: testplatypus.py,v 1.16 2000/05/17 22:17:38 rgbecker Exp $ '''
+__version__=''' $Id: testplatypus.py,v 1.17 2000/06/01 15:23:06 rgbecker Exp $ '''
 
 #tests and documents Page Layout API
 __doc__="""This is not obvious so here's a brief explanation.  This module is both
@@ -90,12 +93,14 @@
 """
 import string, copy
 from reportlab.pdfgen import canvas
-from reportlab.platypus import layout, tables
-from reportlab.platypus.doctemplate import BaseDocTemplate, PageTemplate, Flowable, FrameBreak
-from reportlab.platypus.paragraph import Paragraph
+from reportlab import platypus
+from reportlab.platypus import BaseDocTemplate, PageTemplate, Flowable, FrameBreak
+from reportlab.platypus import Paragraph
 from reportlab.lib.units import inch, cm
 from reportlab.lib.styles import PropertySet, getSampleStyleSheet, ParagraphStyle
 from reportlab.lib import colors
+from reportlab.lib.pagesizes import DEFAULT_PAGE_SIZE
+PAGE_HEIGHT = DEFAULT_PAGE_SIZE[1]
 
 #################################################################
 #
@@ -111,17 +116,16 @@
 	canvas.saveState()
 	canvas.setStrokeColorRGB(1,0,0)
 	canvas.setLineWidth(5)
-	canvas.line(66,72,66,layout.PAGE_HEIGHT-72)
+	canvas.line(66,72,66,PAGE_HEIGHT-72)
 
 	canvas.setFont('Times-Italic',12)
-	canvas.drawRightString(523, layout.PAGE_HEIGHT - 56, "Platypus User Guide and Test Script")
+	canvas.drawRightString(523, PAGE_HEIGHT - 56, "Platypus User Guide and Test Script")
 	
 	canvas.setFont('Times-Roman',12)
 	canvas.drawString(4 * inch, 0.75 * inch,
 						"Page %d" % canvas.getPageNumber())
 	canvas.restoreState()
 	
-
 def getParagraphs(textBlock):
 	"""Within the script, it is useful to whack out a page in triple
 	quotes containing separate paragraphs. This breaks one into its
@@ -317,7 +321,7 @@
 	story.append(Paragraph("""
 		A FrameBreak causes the document to call its handle_frameEnd method.""",
 			styleSheet['Definition'],
-			bulletText='FrameBreak  '  #hack - spot the extra space after
+			bulletText='FrameBreak	'  #hack - spot the extra space after
 			))
 
 	story.append(Paragraph("""
@@ -372,7 +376,7 @@
 	p.debug = 1   #show me the borders
 	story.append(p)
 
-	story.append(layout.XBox(4*inch, 0.75*inch,
+	story.append(platypus.XBox(4*inch, 0.75*inch,
 			'This is a box with a fixed size'))
 
 	story.append(Paragraph("""
@@ -422,7 +426,7 @@
 		return (self.width, self.height)
 	'''
 	
-	story.append(layout.Preformatted(code, styleSheet['Code'], dedent=4))
+	story.append(platypus.Preformatted(code, styleSheet['Code'], dedent=4))
 	story.append(FrameBreak())
 	#######################################################################
 	#	  Examples Page 3
@@ -439,13 +443,13 @@
 				"Here is an Image.	For now, these are always centred in the frame.",
 				styleSheet['Italic']))
 
-	story.append(layout.Image('pythonpowered.gif'))
+	story.append(platypus.Image('pythonpowered.gif'))
 
 	story.append(Paragraph("""Here is a Table, which takes all kinds of formatting options...""",
 				styleSheet['Italic']))
-	story.append(layout.Spacer(0, 12))
+	story.append(platypus.Spacer(0, 12))
 	
-	g = tables.Table(
+	g = platypus.Table(
 			(72,36,36,36,36),
 			(24, 16,16,18),
 			(('','North','South','East','West'),
@@ -454,7 +458,7 @@
 			 ('Total',200,400,600,800))
 			)
 
-	style = tables.TableStyle([('ALIGN', (1,1), (-1,-1), 'RIGHT'),
+	style = platypus.TableStyle([('ALIGN', (1,1), (-1,-1), 'RIGHT'),
 							   ('ALIGN', (0,0), (-1,0), 'CENTRE'),
 							   ('GRID', (0,0), (-1,-1), 0.25, colors.black),
 							   ('LINEBELOW', (0,0), (-1,0), 2, colors.black),
@@ -469,16 +473,13 @@
 	return story
 
 class AndyTemplate(BaseDocTemplate):
-	def __init__(self, filename, pagesize=layout.DEFAULT_PAGE_SIZE, showBoundary=0,
-				leftMargin=inch, rightMargin=inch, topMargin=inch, bottomMargin=inch,
-				allowSplitting=0):
-		frame1 = layout.Frame(inch, 5.6*inch, 6*inch, 5.2*inch,id='F1')
-		frame2 = layout.Frame(inch, inch, 6*inch, 4.5*inch, showBoundary=1,id='F2')
-		BaseDocTemplate.__init__(self, filename, pagesize=pagesize,
-				pageTemplates=PageTemplate('normal',[frame1,frame2],framePage),
-				showBoundary=showBoundary, leftMargin=leftMargin, rightMargin=rightMargin,
-				topMargin=topMargin, bottomMargin=bottomMargin,
-				allowSplitting=allowSplitting)
+	_invalidInitArgs = ('pageTemplates',)
+	def __init__(self, filename, **kw):
+		frame1 = platypus.Frame(inch, 5.6*inch, 6*inch, 5.2*inch,id='F1')
+		frame2 = platypus.Frame(inch, inch, 6*inch, 4.5*inch, showBoundary=1,id='F2')
+		self.allowSplitting = 0
+		apply(BaseDocTemplate.__init__,(self,filename),kw)
+		self.addPageTemplates(PageTemplate('normal',[frame1,frame2],framePage))
 
 	def	fillFrame(self,flowables):
 		f = self.frame
--- a/reportlab/platypus/test/testtables.py	Thu Jun 01 09:44:26 2000 +0000
+++ b/reportlab/platypus/test/testtables.py	Thu Jun 01 15:23:06 2000 +0000
@@ -32,9 +32,12 @@
 #
 ###############################################################################
 #	$Log: testtables.py,v $
+#	Revision 1.9  2000/06/01 15:23:06  rgbecker
+#	Platypus re-organisation
+#
 #	Revision 1.8  2000/05/17 15:37:33  rgbecker
 #	Changes related to removal of SimpleFlowDocument
-#
+#	
 #	Revision 1.7  2000/04/26 11:07:15  andy_robinson
 #	Tables changed to use reportlab.lib.colors instead of
 #	the six hard-coded color strings there previously.
@@ -54,15 +57,14 @@
 #	Revision 1.2  2000/02/15 15:47:10  rgbecker
 #	Added license, __version__ and Logi comment
 #
-__version__=''' $Id: testtables.py,v 1.8 2000/05/17 15:37:33 rgbecker Exp $ '''
+__version__=''' $Id: testtables.py,v 1.9 2000/06/01 15:23:06 rgbecker Exp $ '''
 __doc__='Test script for reportlab.tables'
-from reportlab.platypus.doctemplate import Spacer, SimpleDocTemplate
-from reportlab.platypus import tables
+from reportlab.platypus import Spacer, SimpleDocTemplate, Table, TableStyle
 from reportlab.lib.units import inch
 from reportlab.lib import colors
 
 def getTable():
-    t = tables.Table(
+    t = Table(
             (72,36,36,36,36),
             (24, 16,16,18),
             (('','North','South','East','West'),
@@ -75,7 +77,7 @@
 def makeStyles():
     styles = []
     for i in range(5):
-        styles.append(tables.TableStyle([('ALIGN', (1,1), (-1,-1), 'RIGHT'),
+        styles.append(TableStyle([('ALIGN', (1,1), (-1,-1), 'RIGHT'),
                                          ('ALIGN', (0,0), (-1,0), 'CENTRE') ]))
     for style in styles[1:]:
         style.add('GRID', (0,0), (-1,-1), 0.25, colors.black)
@@ -87,7 +89,7 @@
     return styles
 
 def run():
-    doc = SimpleDocTemplate('testtables.pdf', (8.5*inch, 11*inch), showBoundary=1)
+    doc = SimpleDocTemplate('testtables.pdf', pageSize=(8.5*inch, 11*inch), showBoundary=1)
     styles = makeStyles()
     lst = []
     for style in styles: