Allowed intra-paragraph text; fixed various bugs
authorandy_robinson
Tue, 16 May 2000 23:48:01 +0000
changeset 222 f04b9db53afc
parent 221 3d71b66b14c6
child 223 0b0f63bec91c
Allowed intra-paragraph text; fixed various bugs
reportlab/demos/pythonpoint/pythonpoint.py
reportlab/demos/pythonpoint/pythonpoint.xml
reportlab/demos/pythonpoint/stdparser.py
reportlab/demos/pythonpoint/styles_modern.py
--- a/reportlab/demos/pythonpoint/pythonpoint.py	Tue May 16 16:15:16 2000 +0000
+++ b/reportlab/demos/pythonpoint/pythonpoint.py	Tue May 16 23:48:01 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: pythonpoint.py,v $
+#	Revision 1.16  2000/05/16 23:48:00  andy_robinson
+#	Allowed intra-paragraph text; fixed various bugs
+#
 #	Revision 1.15  2000/04/28 17:04:28  andy_robinson
 #	Changed to display multiple outline levels
-#
+#	
 #	Revision 1.14  2000/04/25 14:37:18  rgbecker
 #	Commented out call of _inPage0
 #	
@@ -81,7 +84,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.15 2000/04/28 17:04:28 andy_robinson Exp $ '''
+__version__=''' $Id: pythonpoint.py,v 1.16 2000/05/16 23:48:00 andy_robinson Exp $ '''
 # xml parser stuff for PythonPoint
 # PythonPoint Markup Language!
 __doc__="""
@@ -230,24 +233,17 @@
         self.width = width
         self.height = height
         self.content = []
-
-        #others which can be set
-        self.leftMargin = 0
-        self.rightMargin = 0
-        self.topMargin = 0
-        self.bottomMargin = 0
-
         self.showBoundary = 0        
 
     def drawOn(self, canv):
         #make a layout frame
-        frame = layout.SimpleFrame(canv, self.x, self.y, self.width, self.height)
+        frame = layout.SimpleFrame(canv,
+                                   self.x,
+                                   self.y,
+                                   self.width,
+                                   self.height)
+                    
         frame.showBoundary = self.showBoundary
-        # terminology difference, must fix
-        frame.leftPadding = self.leftMargin
-        frame.topPadding = self.topMargin
-        frame.rightPadding = self.topMargin
-        frame.bottomPadding = self.bottomMargin
         
         #build a story for the frame
         story = []
@@ -255,7 +251,6 @@
             #ask it for any flowables
             story.append(thingy.getFlowable())
         #draw it
-        
         frame.addFromList(story)
 
         
@@ -266,14 +261,15 @@
         self.style = None
 
     def getFlowable(self):
-        return Paragraph(
+        p = Paragraph(
                     self.rawtext,
                     getStyles()[self.style],
                     self.bulletText
                     )
+        return p
 
 class PPPreformattedText:
-    """Use this for source code, or stuff you wo not want to wrap"""
+    """Use this for source code, or stuff you do not want to wrap"""
     def __init__(self):
         self.rawtext = ''
         self.style = None
@@ -301,7 +297,7 @@
 
 class PPDrawingElement:
     """Base class for something which you draw directly on the page."""
-    def drawOn(selg, canv):
+    def drawOn(self, canv):
         raise "NotImplementedError", "Abstract base class!"
 
         
@@ -556,7 +552,7 @@
     para.firstLineIndent = 40
     para.leftIndent = 80
     para.spaceBefore = 6
-    #para.bulletFontName = 'Symbol'
+    para.bulletFontName = 'Symbol'
     para.bulletFontSize = 24
     para.bulletIndent = 20
     stylesheet['Bullet'] = para
--- a/reportlab/demos/pythonpoint/pythonpoint.xml	Tue May 16 16:15:16 2000 +0000
+++ b/reportlab/demos/pythonpoint/pythonpoint.xml	Tue May 16 23:48:01 2000 +0000
@@ -4,8 +4,6 @@
     <rectangle x="20" y="20" width="96" height="555" fill="(0,0,0.8)"/>
     <fixedimage  x="20" y="510" width="96" height="64" filename="leftlogo.gif"/>
 
-
-
 	<!--Now for the slides-->
      <slide id="Slide001" title="Introduction" effectname='Wipe'>
         <frame x="120" y="72" width="700" height="468" 
@@ -13,7 +11,7 @@
             <para style='Heading1'>Welcome to PythonPoint</para>
             <para style='BodyText'>...a library for creating presentation slides.</para>
             <para style='BodyText'>
-                PythonPoint lets you create attractive and consistent presentation slides
+                <i>PythonPoint</i> lets you create attractive and consistent presentation slides
                 on any platform.  It is a demo app built on top of the PDFgen PDF library
                 and the PLATYPUS Page Layout library.  Essentially, it converts slides
                 in an XML format to PDF.
@@ -69,10 +67,10 @@
                 The Page Layout model comes from PLATYPUS (Page Layout and Typography Using Scripts),
                 a key component of the toolkit.  This covers concepts such as:
             </para>
-            <para style='Bullet' bullettext = '¥'>Reusable 'Drawable Objects'</para>
-            <para style='Bullet' bullettext = '¥'>Frames into which objects flow (like this one, around which we have drawn a border)</para>
-            <para style='Bullet' bullettext = '¥'>Style Sheets for text, table cells, line styles etc.</para>
-            <para style='Bullet' bullettext = '¥'>Wrapping, page breaking an document management logic</para>
+            <para style='Bullet'>Reusable 'Drawable Objects'</para>
+            <para style='Bullet'>Frames into which objects flow (like this one, around which we have drawn a border)</para>
+            <para style='Bullet'>Style Sheets for text, table cells, line styles etc.</para>
+            <para style='Bullet'>Wrapping, page breaking an document management logic</para>
             <para style='BodyText'>Everything is open and extensible.  I hope a library of reusable objects
             such as charts and diagrams will grow up.</para>
         </frame>
@@ -131,12 +129,12 @@
                 Acrobat Reader supports tags to define page transition effects.  If you
 				are reading this on screen, you should have seen a selection of these:
             </para>
-	        <para style='Bullet' bullettext = '¥'>Split</para>
-	        <para style='Bullet' bullettext = '¥'>Blinds</para>
-	        <para style='Bullet' bullettext = '¥'>Box</para>
-	        <para style='Bullet' bullettext = '¥'>Wipe</para>
-	        <para style='Bullet' bullettext = '¥'>Dissolve</para>
-	        <para style='Bullet' bullettext = '¥'>Glitter</para>
+	        <para style='Bullet'>Split</para>
+	        <para style='Bullet'>Blinds</para>
+	        <para style='Bullet'>Box</para>
+	        <para style='Bullet'>Wipe</para>
+	        <para style='Bullet'>Dissolve</para>
+	        <para style='Bullet'>Glitter</para>
     		<para style='BodyText'>
 				Each has a range of options to fine-tune.
             </para>
@@ -192,13 +190,13 @@
             <para style='BodyText'>
                 This is the first version that runs.  A lot can now be added fairly easily:
             </para>
-            <para style='Bullet' bullettext = '¥'>Preprocessor to let you enter paragraphs 
+            <para style='Bullet'>Preprocessor to let you enter paragraphs 
 				and bullets as one block of text, with less tag typing!</para>
-            <para style='Bullet' bullettext = '¥'>PIDDLE drawings</para>
-            <para style='Bullet' bullettext = '¥'>PINGO drawings - 'Object Graphics' tags with grouping and coordinate transformations</para>
-            <para style='Bullet' bullettext = '¥'>Speaker notes and a mode to print them</para>
-            <para style='Bullet' bullettext = '¥'>Tools to archive slides in a database and build presentations to order</para>
-            <para style='Italic' bullettext = '¥'>...what else can YOU think of?</para>
+            <para style='Bullet'>PIDDLE drawings</para>
+            <para style='Bullet'>PINGO drawings - 'Object Graphics' tags with grouping and coordinate transformations</para>
+            <para style='Bullet'>Speaker notes and a mode to print them</para>
+            <para style='Bullet'>Tools to archive slides in a database and build presentations to order</para>
+            <para style='Italic'>...what else can YOU think of?</para>
         </frame>
     </slide>
 
@@ -607,22 +605,19 @@
         <frame x="120" y="72" width="700" height="468" 
 			leftmargin="36" rightmargin="36">
             <para style='Heading1'>Part 3 - To Do</para>
-            <para style='Bullet' bullettext = '¥'>Lots of testing</para>
-            <para style='Bullet' bullettext = '¥'>Text preprocessor to let you input text, styles and images
+            <para style='Bullet'>Lots of testing</para>
+            <para style='Bullet'>Text preprocessor to let you input text, styles and images
 			 in something easier to type</para>
-            <para style='Bullet' bullettext = '¥'>Support for Pingo (http://pingo.sourceforge.net/) drawings using
+            <para style='Bullet'>Support for Pingo (http://pingo.sourceforge.net/) drawings using
 			the Scalable Vector Graphics imaging model</para>
-            <para style='Bullet' bullettext = '¥'>Proper caching of flowing images</para>
-            <para style='Bullet' bullettext = '¥'>Basic Tables and Charts</para>
-            <para style='Bullet' bullettext = '¥'>Use new XML parsers as wel as xmllib</para>
-            <para style='Bullet' bullettext = '¥'>Slide indexing and database search tools</para>
-            <para style='Bullet' bullettext = '¥'>Speaker Notes mode</para>
+            <para style='Bullet'>Proper caching of flowing images</para>
+            <para style='Bullet'>Basic Tables and Charts</para>
+            <para style='Bullet'>Use new XML parsers as wel as xmllib</para>
+            <para style='Bullet'>Slide indexing and database search tools</para>
+            <para style='Bullet'>Speaker Notes mode</para>
 	    <para>Naturally, help is extremely welcome :-)</para>
         </frame>
     </slide>
-
-
-
   </section>
 </presentation>
 
--- a/reportlab/demos/pythonpoint/stdparser.py	Tue May 16 16:15:16 2000 +0000
+++ b/reportlab/demos/pythonpoint/stdparser.py	Tue May 16 23:48:01 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: stdparser.py,v $
+#	Revision 1.6  2000/05/16 23:48:00  andy_robinson
+#	Allowed intra-paragraph text; fixed various bugs
+#
 #	Revision 1.5  2000/05/11 13:53:51  rgbecker
 #	Change to allow different xmllib
-#
+#	
 #	Revision 1.4  2000/04/28 17:04:28  andy_robinson
 #	Changed to display multiple outline levels
 #	
@@ -84,11 +87,11 @@
             'y':'0',
             'width':'0',
             'height':'0',
-            'leftmargin':'0',
-            'rightmargin':'0',
-            'topmargin':'0',
-            'bottommargin':'0',
-            'border':'false'
+            'border':'false',
+            'leftmargin':'0',  #this is ignored
+            'topmargin':'0',  #this is ignored
+            'rightmargin':'0',  #this is ignored
+            'bottommargin':'0',  #this is ignored
             },
         'slide': {
             'id':'None',
@@ -299,10 +302,6 @@
             self.ceval('frame',args,'width'),
             self.ceval('frame',args,'height')
             )
-        self._curFrame.leftMargin = self.ceval('frame',args,'leftmargin')
-        self._curFrame.topMargin = self.ceval('frame',args,'topmargin')
-        self._curFrame.rightMargin = self.ceval('frame',args,'rightmargin')
-        self._curFrame.bottomMargin = self.ceval('frame',args,'bottommargin')
         if self._arg('frame',args,'border')=='true':
             self._curFrame.showBoundary = 1
 
@@ -313,9 +312,12 @@
     def start_para(self, args):
         self._curPara = pythonpoint.PPPara()
         self._curPara.style = self._arg('para',args,'style')
-        # hack - we want to allow octal escape sequences in the input -
-        # treat as raw string and evaluate
-        self._curPara.bulletText = self._arg('para',args,'bullettext')
+
+        # hack - bullet character if bullet style        
+        bt = self._arg('para',args,'bullettext')
+        if self._curPara.style == 'Bullet' and bt == '':
+            bt = '\267'  # Symbol Font bullet character, reasonable default
+        self._curPara.bulletText = bt
         
     def end_para(self):
         self._curFrame.content.append(self._curPara)
@@ -492,3 +494,21 @@
         elif self._curSection:
             self._curSection.graphics.append(self._curCustomShape)
         self._curCustomShape = None
+
+
+    ## intra-paragraph XML should be allowed through into PLATYPUS
+    def unknown_starttag(self, tag, attrs):
+        if  self._curPara:
+            echo = '<%s' % tag
+            for (key, value) in attrs.items():
+                echo = echo + ' %s="%s"' % (key, value)
+            echo = echo + '>'
+            self._curPara.rawtext = self._curPara.rawtext + echo
+        else:
+            print 'Unknown start tag %s' % tag
+    def unknown_endtag(self, tag):
+        if  self._curPara:
+            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_modern.py	Tue May 16 16:15:16 2000 +0000
+++ b/reportlab/demos/pythonpoint/styles_modern.py	Tue May 16 23:48:01 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: styles_modern.py,v $
+#	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
-#
+#	
 #	Revision 1.3  2000/02/16 09:42:50  rgbecker
 #	Conversion to reportlab package
 #	
@@ -43,7 +46,7 @@
 #	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.4 2000/02/17 02:06:28 rgbecker Exp $ '''
+__version__=''' $Id: styles_modern.py,v 1.5 2000/05/16 23:48:01 andy_robinson 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
@@ -62,11 +65,13 @@
 """
 
 from reportlab.platypus import layout
+from reportlab.lib import styles
+from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT, TA_JUSTIFY
 
 def getParagraphStyles():
     """Returns a dictionary of styles based on Helvetica"""
     stylesheet = {}
-    ParagraphStyle = layout.ParagraphStyle
+    ParagraphStyle = styles.ParagraphStyle
  
     para = ParagraphStyle('Normal', None)   #the ancestor of all
     para.fontName = 'Helvetica'
@@ -80,7 +85,7 @@
     
     para = ParagraphStyle('BigCentered', stylesheet['Normal'])
     para.spaceBefore = 12
-    para.alignment = layout.TA_CENTER
+    para.alignment = TA_CENTER
     stylesheet['BigCentered'] = para
 
     para = ParagraphStyle('Italic', stylesheet['BodyText'])
@@ -92,7 +97,7 @@
     para.fontSize = 48
     para.Leading = 58
     para.spaceAfter = 36
-    para.alignment = layout.TA_CENTER
+    para.alignment = TA_CENTER
     stylesheet['Title'] = para
     
     para = ParagraphStyle('Heading1', stylesheet['Normal'])
@@ -100,7 +105,7 @@
     para.fontSize = 36
     para.leading = 44
     para.spaceAfter = 36
-    para.alignment = layout.TA_CENTER
+    para.alignment = TA_CENTER
     stylesheet['Heading1'] = para
     
     para = ParagraphStyle('Heading2', stylesheet['Normal'])