Further tweaks of XPreformatted
authorrgbecker
Fri, 25 Aug 2000 11:35:37 +0000
changeset 450 37919675ea28
parent 449 1ba0d6fb0f9e
child 451 93ff18c6c3e4
Further tweaks of XPreformatted
docs/userguide/ch6_tables.py
reportlab/platypus/paragraph.py
reportlab/platypus/xpreformatted.py
--- a/docs/userguide/ch6_tables.py	Thu Aug 24 18:21:47 2000 +0000
+++ b/docs/userguide/ch6_tables.py	Fri Aug 25 11:35:37 2000 +0000
@@ -286,6 +286,7 @@
    As for <b>Preformatted</b>, if dedent is non zero <font color=red size=+1>dedent</font>
        common leading spaces will be removed from the
    front of each line.
+   You can have &amp;amp; style entities as well for &amp; &lt; &gt; and &quot;.
 
 '''
 t=XPreformatted(text,normalStyle,dedent=3)
--- a/reportlab/platypus/paragraph.py	Thu Aug 24 18:21:47 2000 +0000
+++ b/reportlab/platypus/paragraph.py	Fri Aug 25 11:35:37 2000 +0000
@@ -16,8 +16,8 @@
 # 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. 
-# 
+# without specific, written prior permission.
+#
 #
 # Disclaimer
 #
@@ -27,13 +27,16 @@
 # 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. 
+# PERFORMANCE OF THIS SOFTWARE.
 #
 ###############################################################################
 #	$Log: paragraph.py,v $
+#	Revision 1.21  2000/08/25 11:35:37  rgbecker
+#	Further tweaks of XPreformatted
+#
 #	Revision 1.20  2000/08/24 18:21:47  rgbecker
 #	XPreformatted fixed empty lines and leading space
-#
+#	
 #	Revision 1.19  2000/08/23 13:58:28  rgbecker
 #	Preparing for cleanup
 #	
@@ -92,7 +95,7 @@
 #	Revision 1.1  2000/04/14 13:21:52  rgbecker
 #	Removed from layout.py
 #	
-__version__=''' $Id: paragraph.py,v 1.20 2000/08/24 18:21:47 rgbecker Exp $ '''
+__version__=''' $Id: paragraph.py,v 1.21 2000/08/25 11:35:37 rgbecker Exp $ '''
 import string
 from types import StringType, ListType
 from reportlab.pdfbase.pdfmetrics import stringWidth
@@ -467,7 +470,7 @@
 						words[-1].text = nText
 					elif not _sameFrag(words[-1],f):
 						if nText!='' and nText[0]!=' ':
-							words[-1].text = words[-1].text + ' ' 
+							words[-1].text = words[-1].text + ' '
 						words.append(f.clone())
 						words[-1].text = nText
 					else:
--- a/reportlab/platypus/xpreformatted.py	Thu Aug 24 18:21:47 2000 +0000
+++ b/reportlab/platypus/xpreformatted.py	Fri Aug 25 11:35:37 2000 +0000
@@ -105,6 +105,7 @@
 				maxSize = 0
 				currentWidth = 0
 				words = []
+				first = 1
 				for w in _getFragWords(L):
 					spaceWidth = stringWidth(' ',w[-1][0].fontName, w[-1][0].fontSize)
 					if not n: currentWidth = -spaceWidth	# hack to get around extra space for word 1
@@ -118,11 +119,17 @@
 						words = [f.clone()]
 						words[-1].text = nText
 					elif not _sameFrag(words[-1],f):
-						words[-1].text = words[-1].text + ' ' 
+						ok = nText!='' and nText[0]!=' '
+						if first or ok:
+							words[-1].text = words[-1].text + ' '
+							if first and ok: first=0
 						words.append(f.clone())
 						words[-1].text = nText
 					else:
-						words[-1].text = words[-1].text + ' ' + nText
+						ok = nText!='' and nText[0]!=' '
+						if first or ok:
+							words[-1].text = words[-1].text + ' ' + nText
+							if first and ok: first=0
 
 					for i in w[2:]:
 						f = i[0].clone()
@@ -215,7 +222,7 @@
 
    This is a non rearranging form of the <b>Paragraph</b> class;
    <b><font color=red>XML</font></b> tags are allowed in <i>text</i> and have the same
-   
+
       meanings as for the <b>Paragraph</b> class.
    As for <b>Preformatted</b>, if dedent is non zero <font color=red size=+1>dedent</font>
        common leading spaces will be removed from the