tests/test_platypus_paragraphs.py
author robin <robin@reportlab.com>
Fri, 23 Mar 2018 16:02:08 +0000
changeset 4389 61a7f0840d00
parent 4387 c9accf85d669
child 4396 7a77896c72f0
permissions -rw-r--r--
more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4330
617ffa6bbdc8 changes for release 3.4.0
robin <robin@reportlab.com>
parents: 4315
diff changeset
     1
#Copyright ReportLab Europe Ltd. 2000-2017
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
     2
#see license.txt for license details
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
     3
"""Tests for the reportlab.platypus.paragraphs module.
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
     4
"""
4252
fe660f227cac changes for release 3.3.0
robin
parents: 4249
diff changeset
     5
__version__='3.3.0'
2987
711910106e3a tests: more changes to testsFolder and friends
rgbecker
parents: 2984
diff changeset
     6
from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation
2984
c63f149d55aa tests.utils --> reportlab.lib.testutils
rgbecker
parents: 2966
diff changeset
     7
setOutDir(__name__)
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
     8
import sys, os, unittest
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
     9
from operator import truth
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    10
from reportlab.pdfbase.pdfmetrics import stringWidth, registerFont, registerFontFamily
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    11
from reportlab.pdfbase.ttfonts import TTFont
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    12
from reportlab.platypus.paraparser import ParaParser
3564
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
    13
from reportlab.platypus.flowables import Flowable, DocAssert
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    14
from reportlab.lib.colors import Color
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    15
from reportlab.lib.units import cm
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    16
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    17
from reportlab.lib.utils import _className
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    18
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    19
from reportlab.platypus.xpreformatted import XPreformatted
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    20
from reportlab.platypus.frames import Frame, ShowBoundaryValue
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    21
from reportlab.platypus.doctemplate import PageTemplate, BaseDocTemplate, PageBreak, NextPageTemplate
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    22
from reportlab.platypus import tableofcontents
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    23
from reportlab.platypus.tableofcontents import TableOfContents
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    24
from reportlab.platypus.tables import TableStyle, Table
4046
aed0e2af4546 paragraph: fix _splitWord for unicode/bytes bug reported by Anders Hammarquist & add a test
robin
parents: 4036
diff changeset
    25
from reportlab.platypus.paragraph import Paragraph, _getFragWords, _splitWord
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    26
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    27
def myMainPageFrame(canvas, doc):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    28
    "The page frame used for all PDF documents."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    29
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    30
    canvas.saveState()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    31
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    32
    canvas.rect(2.5*cm, 2.5*cm, 15*cm, 25*cm)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    33
    canvas.setFont('Times-Roman', 12)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    34
    pageNumber = canvas.getPageNumber()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    35
    canvas.drawString(10*cm, cm, str(pageNumber))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    36
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    37
    canvas.restoreState()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    38
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    39
class MyDocTemplate(BaseDocTemplate):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    40
    _invalidInitArgs = ('pageTemplates',)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    41
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    42
    def __init__(self, filename, **kw):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    43
        frame1 = Frame(2.5*cm, 2.5*cm, 15*cm, 25*cm, id='F1')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    44
        frame2 = Frame(2.5*cm, 2.5*cm, 310, 25*cm, id='F2')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    45
        self.allowSplitting = 0
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3320
diff changeset
    46
        BaseDocTemplate.__init__(self, filename, **kw)
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    47
        template = PageTemplate('normal', [frame1], myMainPageFrame)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    48
        template1 = PageTemplate('special', [frame2], myMainPageFrame)
4036
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
    49
        template2 = PageTemplate('template2', [Frame(395, 108, 165, 645, id='second2')])
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
    50
        self.addPageTemplates([template,template1,template2])
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    51
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    52
class ParagraphCorners(unittest.TestCase):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    53
    "some corner cases which should parse"
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    54
    def check(self,text,bt = getSampleStyleSheet()['BodyText']):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    55
        try:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    56
            P = Paragraph(text,style=bt)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    57
        except:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    58
            raise AssertionError("'%s' should parse"%text)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    59
            
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    60
    def test0(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    61
        self.check('<para />')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    62
        self.check('<para/>')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    63
        self.check('\t\t\t\n\n\n<para />')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    64
        self.check('\t\t\t\n\n\n<para/>')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    65
        self.check('<para\t\t\t\t/>')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    66
        self.check('<para></para>')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    67
        self.check('<para>      </para>')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    68
        self.check('\t\t\n\t\t\t   <para>      </para>')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    69
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    70
    def test1(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    71
        "This makes several special paragraphs."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    72
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    73
        # Build story.
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    74
        story = []
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    75
        styleSheet = getSampleStyleSheet()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    76
        bt = styleSheet['BodyText']
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    77
        btN = ParagraphStyle('BodyTextTTNone',parent=bt,textTransform='none')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    78
        btL = ParagraphStyle('BodyTextTTLower',parent=bt,textTransform='lowercase')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    79
        btU = ParagraphStyle('BodyTextTTUpper',parent=bt,textTransform='uppercase')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    80
        btC = ParagraphStyle('BodyTextTTCapitalize',parent=bt,textTransform='capitalize')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    81
        story.append(Paragraph('''This should be ORDINARY text.''',style=bt))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    82
        story.append(Paragraph('''This should be ORDINARY text.''',style=btN))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    83
        story.append(Paragraph('''This should be LOWER text.''',style=btL))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    84
        story.append(Paragraph('''This should be upper text.''',style=btU))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    85
        story.append(Paragraph('''This should be cAPITALIZED text.''',style=btC))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    86
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    87
        story.append(Paragraph('''T<i>hi</i>s shoul<font color="red">d b</font>e <b>ORDINARY</b> text.''',style=bt))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    88
        story.append(Paragraph('''T<i>hi</i>s shoul<font color="red">d b</font>e <b>ORDINARY</b> text.''',style=btN))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    89
        story.append(Paragraph('''T<i>hi</i>s shoul<font color="red">d b</font>e <b>LOWER</b> text.''',style=btL))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    90
        story.append(Paragraph('''T<i>hi</i>s shoul<font color="red">d b</font>e <b>upper</b> text.''',style=btU))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    91
        story.append(Paragraph('''T<i>hi</i>s shoul<font color="red">d b</font>e <b>cAPITALIZED</b> text.''',style=btC))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    92
        doc = MyDocTemplate(outputfile('test_platypus_specialparagraphs.pdf'))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    93
        doc.multiBuild(story)
3191
07560dd4d3d0 test_platypus_paragraphs.py: add in Volker's crashing CJK split as a test
rgbecker
parents: 2987
diff changeset
    94
07560dd4d3d0 test_platypus_paragraphs.py: add in Volker's crashing CJK split as a test
rgbecker
parents: 2987
diff changeset
    95
    def test2(self):
07560dd4d3d0 test_platypus_paragraphs.py: add in Volker's crashing CJK split as a test
rgbecker
parents: 2987
diff changeset
    96
        '''CJK splitting in multi-frag case'''
07560dd4d3d0 test_platypus_paragraphs.py: add in Volker's crashing CJK split as a test
rgbecker
parents: 2987
diff changeset
    97
        style = ParagraphStyle('test', wordWrap = 'CJK')
07560dd4d3d0 test_platypus_paragraphs.py: add in Volker's crashing CJK split as a test
rgbecker
parents: 2987
diff changeset
    98
        p = Paragraph('bla <i>blub</i> '*130 , style)
07560dd4d3d0 test_platypus_paragraphs.py: add in Volker's crashing CJK split as a test
rgbecker
parents: 2987
diff changeset
    99
        aW,aH=439.275590551,121.88976378
07560dd4d3d0 test_platypus_paragraphs.py: add in Volker's crashing CJK split as a test
rgbecker
parents: 2987
diff changeset
   100
        w,h=p.wrap(aW,aH)
07560dd4d3d0 test_platypus_paragraphs.py: add in Volker's crashing CJK split as a test
rgbecker
parents: 2987
diff changeset
   101
        S=p.split(aW,aH)
3197
f4cef2b94b59 test_platypus_paragraphs.py: fix CJK splitting test
rgbecker
parents: 3191
diff changeset
   102
        assert len(S)==2, 'Multi frag CJK splitting failed'
3191
07560dd4d3d0 test_platypus_paragraphs.py: add in Volker's crashing CJK split as a test
rgbecker
parents: 2987
diff changeset
   103
        w0,h0=S[0].wrap(aW,aH)
07560dd4d3d0 test_platypus_paragraphs.py: add in Volker's crashing CJK split as a test
rgbecker
parents: 2987
diff changeset
   104
        assert h0<=aH,'Multi-frag CJK split[0] has wrong height %s >= available %s' % (H0,aH)
07560dd4d3d0 test_platypus_paragraphs.py: add in Volker's crashing CJK split as a test
rgbecker
parents: 2987
diff changeset
   105
        w1,h1=S[1].wrap(aW,aH)
07560dd4d3d0 test_platypus_paragraphs.py: add in Volker's crashing CJK split as a test
rgbecker
parents: 2987
diff changeset
   106
        assert h0+h1==h, 'Multi-frag-CJK split[0].height(%s)+split[1].height(%s) don\'t add to original %s' % (h0,h1,h)
3492
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   107
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   108
    def test3(self):
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   109
        '''compare CJK splitting in some edge cases'''
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   110
        from reportlab.pdfgen.canvas import Canvas
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   111
        from reportlab.platypus.paragraph import Paragraph
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   112
        from reportlab.lib.styles import ParagraphStyle
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   113
        from reportlab.pdfbase import pdfmetrics
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   114
        from reportlab.lib.enums import TA_LEFT
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   115
        sty = ParagraphStyle('A')
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   116
        sty.fontSize = 15
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   117
        sty.leading = sty.fontSize*1.2
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   118
        sty.fontName = 'Courier'
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   119
        sty.alignment = TA_LEFT
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   120
        sty.wordWrap = 'CJK'
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   121
        p0=Paragraph('ABCDEFGHIJKL]N',sty)
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   122
        p1=Paragraph('AB<font color="red">C</font>DEFGHIJKL]N',sty)
4389
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   123
        canv = Canvas(outputfile('test_platypus_paragraph_cjk3.pdf'))
3492
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   124
        ix = len(canv._code)
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   125
        aW = pdfmetrics.stringWidth('ABCD','Courier',15)
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   126
        w,h=p0.wrap(aW,1000000)
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   127
        y = canv._pagesize[1]-72-h
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   128
        p0.drawOn(canv,72,y)
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   129
        w,h=p1.wrap(aW,1000000)
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   130
        y -= h+10
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   131
        p1.drawOn(canv,72,y)
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   132
        w,h=p0.wrap(aW*0.25-2,1000000)
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   133
        y -= h+10
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   134
        p0.drawOn(canv,72,y)
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   135
        w,h=p1.wrap(aW/4.-2,1000000)
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   136
        y -= h+10
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   137
        p1.drawOn(canv,72,y)
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   138
        assert canv._code[ix:]==['q', '1 0 0 1 72 697.8898 cm', 'q', '0 0 0 rg', 'BT 1 0 0 1 0 57 Tm /F2 15 Tf 18 TL (ABCD) Tj T* (EFGH) Tj T* (IJKL]) Tj T* (N) Tj T* ET', 'Q', 'Q', 'q', '1 0 0 1 72 615.8898 cm', 'q', 'BT 1 0 0 1 0 57 Tm 18 TL /F2 15 Tf 0 0 0 rg (AB) Tj 1 0 0 rg (C) Tj 0 0 0 rg (D) Tj T* (EFGH) Tj T* (IJKL]) Tj T* (N) Tj T* ET', 'Q', 'Q', 'q', '1 0 0 1 72 353.8898 cm', 'q', '0 0 0 rg', 'BT 1 0 0 1 0 237 Tm /F2 15 Tf 18 TL (A) Tj T* (B) Tj T* (C) Tj T* (D) Tj T* (E) Tj T* (F) Tj T* (G) Tj T* (H) Tj T* (I) Tj T* (J) Tj T* (K) Tj T* (L) Tj T* (]) Tj T* (N) Tj T* ET', 'Q', 'Q', 'q', '1 0 0 1 72 91.88976 cm', 'q', 'BT 1 0 0 1 0 237 Tm 18 TL /F2 15 Tf 0 0 0 rg (A) Tj T* (B) Tj T* 1 0 0 rg (C) Tj T* 0 0 0 rg (D) Tj T* (E) Tj T* (F) Tj T* (G) Tj T* (H) Tj T* (I) Tj T* (J) Tj T* (K) Tj T* (L) Tj T* (]) Tj T* (N) Tj T* ET', 'Q', 'Q']
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   139
        canv.showPage()
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   140
        canv.save()
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   141
        
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   142
class ParagraphSplitTestCase(unittest.TestCase):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   143
    "Test multi-page splitting of paragraphs (eyeball-test)."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   144
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   145
    def test0(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   146
        "This makes one long multi-page paragraph."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   147
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   148
        # Build story.
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   149
        story = []
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   150
        styleSheet = getSampleStyleSheet()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   151
        bt = styleSheet['BodyText']
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   152
        text = '''If you imagine that the box of X's tothe left is
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   153
an image, what I want to be able to do is flow a
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   154
series of paragraphs around the image
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   155
so that once the bottom of the image is reached, then text will flow back to the
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   156
left margin. I know that it would be possible to something like this
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   157
using tables, but I can't see how to have a generic solution.
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   158
There are two examples of this in the demonstration section of the reportlab
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   159
site.
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   160
If you look at the "minimal" euro python conference brochure, at the end of the
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   161
timetable section (page 8), there are adverts for "AdSu" and "O'Reilly". I can
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   162
see how the AdSu one might be done generically, but the O'Reilly, unsure...
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   163
I guess I'm hoping that I've missed something, and that
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   164
it's actually easy to do using platypus.
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   165
'''
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   166
        from reportlab.platypus.flowables import ParagraphAndImage, Image
2987
711910106e3a tests: more changes to testsFolder and friends
rgbecker
parents: 2984
diff changeset
   167
        from reportlab.lib.testutils import testsFolder
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
   168
        gif = os.path.join(testsFolder,'pythonpowered.gif')
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   169
        story.append(ParagraphAndImage(Paragraph(text,bt),Image(gif)))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   170
        phrase = 'This should be a paragraph spanning at least three pages. '
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   171
        description = ''.join([('%d: '%i)+phrase for i in range(250)])
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   172
        story.append(ParagraphAndImage(Paragraph(description, bt),Image(gif),side='left'))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   173
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   174
        doc = MyDocTemplate(outputfile('test_platypus_paragraphandimage.pdf'))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   175
        doc.multiBuild(story)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   176
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   177
    def test1(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   178
        "This makes one long multi-page paragraph."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   179
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   180
        # Build story.
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   181
        story = []
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   182
        styleSheet = getSampleStyleSheet()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   183
        h3 = styleSheet['Heading3']
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   184
        bt = styleSheet['BodyText']
4341
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   185
        text = b'''If you imagine that the box of X's to the left is
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   186
an image, what I want to be able to do is flow a
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   187
series of paragraphs around the image
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   188
so that once the bottom of the image is reached, then text will flow back to the
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   189
left margin. I know that it would be possible to something like this
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   190
using tables, but I can't see how to have a generic solution.
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   191
There are two examples of this in the demonstration section of the reportlab
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   192
site.
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   193
If you look at the "minimal" euro python conference brochure, at the end of the
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   194
timetable section (page 8), there are adverts for "AdSu" and "O'Reilly". I can
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   195
see how the AdSu one might be done generically, but the O'Reilly, unsure...
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   196
I guess I'm hoping that I've missed something, and that
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   197
it's actually easy to do using platypus.We can do greek letters <greek>mDngG</greek>. This should be a
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   198
u with a dieresis on top &lt;unichar code=0xfc/&gt;="<unichar code="0xfc"/>" and this &amp;#xfc;="&#xfc;" and this \\xc3\\xbc="\xc3\xbc". On the other hand this
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   199
should be a pound sign &amp;pound;="&pound;" and this an alpha &amp;alpha;="&alpha;". You can have links in the page <link href="http://www.reportlab.com" color="blue">ReportLab</link> &amp; <a href="http://www.reportlab.org" color="green">ReportLab.org</a>.
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   200
Use scheme "pdf:" to indicate an external PDF link, "http:", "https:" to indicate an external link eg something to open in
4387
c9accf85d669 fix issue 136 reported by lostbard @ bitbucket.org; version --> 3.4.28
robin <robin@reportlab.com>
parents: 4345
diff changeset
   201
your browser. If an internal link begins with something that looks like a scheme, precede with "document:". Empty hrefs should be allowed ie <a href="">&lt;a href=""&gt;test&lt;/a&gt;</a> should be allowed.
4389
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   202
<u>This text should be underlined.</u><br/>
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   203
<strike>This text should have a strike through it.</strike><br/>
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   204
<span backcolor="yellow"><strike>This text should have a strike through it and be highlighted.</strike></span><br/>
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   205
<span backcolor="yellow"><strike><u>This text should have a strike through it and be highlighted and underlined.</u></strike></span><br/>
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   206
This should be a mailto link <a href="mailto:reportlab-users@lists2.reportlab.com"><font color="blue">reportlab-users at lists2.reportlab.com</font></a>.<br/>
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   207
This should be an underlined mailto link <a underline="1" href="mailto:reportlab-users@lists2.reportlab.com"><font color="blue">reportlab-users at lists2.reportlab.com</font></a>.<br/>
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   208
This should be a highlighted mailto link <span backcolor="yellow"><a href="mailto:reportlab-users@lists2.reportlab.com"><font color="blue">reportlab-users at lists2.reportlab.com</font></a></span>.<br/>
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   209
This should be a highlighted &amp; underlined mailto link <span backcolor="yellow"><a underline="1" ucolor="red" uwidth="0.01*F" href="mailto:reportlab-users@lists2.reportlab.com"><font color="blue">reportlab-users at lists2.reportlab.com</font></a></span>.<br/>
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   210
<u offset="-.125*F">Underlined <font size="-1">Underlined</font></u><br/>
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   211
This is A<sup><u>underlined</u></sup> as is A<u><sup>this</sup></u>
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   212
<u color="red">This is A<sup><u>underlined</u></sup> as is A<u><sup>this</sup></u></u>
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   213
'''
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   214
        from reportlab.platypus.flowables import ImageAndFlowables, Image
2987
711910106e3a tests: more changes to testsFolder and friends
rgbecker
parents: 2984
diff changeset
   215
        from reportlab.lib.testutils import testsFolder
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
   216
        gif = os.path.join(testsFolder,'pythonpowered.gif')
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   217
        heading = Paragraph('This is a heading',h3)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   218
        story.append(ImageAndFlowables(Image(gif),[heading,Paragraph(text,bt)]))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   219
        phrase = 'This should be a paragraph spanning at least three pages. '
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   220
        description = ''.join([('%d: '%i)+phrase for i in range(250)])
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   221
        story.append(ImageAndFlowables(Image(gif),[heading,Paragraph(description, bt)],imageSide='left'))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   222
        story.append(NextPageTemplate('special'))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   223
        story.append(PageBreak())
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   224
        VERA = ('Vera','VeraBd','VeraIt','VeraBI')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   225
        for v in VERA:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   226
            registerFont(TTFont(v,v+'.ttf'))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   227
        registerFontFamily(*(VERA[:1]+VERA))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   228
        story.append(ImageAndFlowables(
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   229
                        Image(gif,width=280,height=120),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   230
                        Paragraph('''<font name="Vera">The <b>concept</b> of an <i>integrated</i> one <b><i>box</i></b> solution for <i><b>advanced</b></i> voice and
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   231
data applications began with the introduction of the IMACS. The
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   232
IMACS 200 carries on that tradition with an integrated solution
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   233
optimized for smaller port size applications that the IMACS could not
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   234
economically address. An array of the most popular interfaces and
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   235
features from the IMACS has been bundled into a small 2U chassis
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   236
providing the ultimate in ease of installation.</font>''',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   237
                        style=ParagraphStyle(
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   238
                                name="base",
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   239
                                fontName="Helvetica",
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   240
                                leading=12,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   241
                                leftIndent=0,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   242
                                firstLineIndent=0,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   243
                                spaceBefore = 9.5,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   244
                                fontSize=9.5,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   245
                                )
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   246
                            ),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   247
                    imageSide='left',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   248
                    )
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   249
                )
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   250
        story.append(ImageAndFlowables(
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   251
                        Image(gif,width=240,height=120),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   252
                        Paragraph('''The concept of an integrated one box solution for advanced voice and
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   253
data applications began with the introduction of the IMACS. The
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   254
IMACS 200 carries on that tradition with an integrated solution
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   255
optimized for smaller port size applications that the IMACS could not
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   256
economically address. An array of the most popular interfaces and
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   257
features from the IMACS has been bundled into a small 2U chassis
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   258
providing the ultimate in ease of installation.''',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   259
                        style=ParagraphStyle(
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   260
                                name="base",
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   261
                                fontName="Helvetica",
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   262
                                leading=12,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   263
                                leftIndent=0,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   264
                                firstLineIndent=0,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   265
                                spaceBefore = 9.5,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   266
                                fontSize=9.5,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   267
                                )
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   268
                            ),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   269
                    imageSide='left',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   270
                    )
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   271
                )
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   272
3320
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   273
        story.append(PageBreak())
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   274
        story.append(Paragraph('Image larger than the frame',h3))
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   275
        story.append(ImageAndFlowables(
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   276
                        Image(gif,width=6*110,height=6*44),
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   277
                        Paragraph('''The concept of an integrated one box solution for advanced voice and
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   278
data applications began with the introduction of the IMACS. The
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   279
IMACS 200 carries on that tradition with an integrated solution
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   280
optimized for smaller port size applications that the IMACS could not
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   281
economically address. An array of the most popular interfaces and
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   282
features from the IMACS has been bundled into a small 2U chassis
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   283
providing the ultimate in ease of installation.''',
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   284
                        style=ParagraphStyle(
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   285
                                name="base",
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   286
                                fontName="Helvetica",
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   287
                                leading=12,
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   288
                                leftIndent=0,
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   289
                                firstLineIndent=0,
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   290
                                spaceBefore = 9.5,
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   291
                                fontSize=9.5,
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   292
                                )
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   293
                            ),
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   294
                    imageSide='left',
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   295
                    )
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   296
                )
4036
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   297
        text = '''With this clarification, an important property of these three types of
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   298
EC can be defined in such a way as to impose problems of phonemic and
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   299
morphological analysis.  Another superficial similarity is the interest
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   300
in simulation of behavior, this analysis of a formative as a pair of
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   301
sets of features does not readily tolerate a stipulation to place the
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   302
constructions into these various categories.  We will bring evidence in
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   303
favor of the following thesis:  the earlier discussion of deviance is
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   304
not to be considered in determining the extended c-command discussed in
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   305
connection with (34).  Another superficial similarity is the interest in
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   306
simulation of behavior, relational information may remedy and, at the
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   307
same time, eliminate a descriptive fact.  There is also a different
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   308
approach to the [unification] problem, the descriptive power of the base
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   309
component delimits the traditional practice of grammarians.'''
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   310
        gif = os.path.join(testsFolder,'pythonpowered.gif')
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   311
        heading = Paragraph('This is a heading',h3)
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   312
        story.append(NextPageTemplate('template2'))
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   313
        story.append(PageBreak())
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   314
        story.append(heading)
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   315
        story.append(ImageAndFlowables(Image(gif,width=66,height=81),[Paragraph(text,bt)],imageSide='left',imageRightPadding=10))
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   316
        doc = MyDocTemplate(outputfile('test_platypus_imageandflowables.pdf'),showBoundary=1)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   317
        doc.multiBuild(story)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   318
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   319
class TwoFrameDocTemplate(BaseDocTemplate):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   320
    "Define a simple document with two frames per page."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   321
    
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   322
    def __init__(self, filename, **kw):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   323
        m = 2*cm
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   324
        from reportlab.lib import pagesizes
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   325
        PAGESIZE = pagesizes.landscape(pagesizes.A4)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   326
        cw, ch = (PAGESIZE[0]-2*m)/2., (PAGESIZE[1]-2*m)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   327
        ch -= 14*cm
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   328
        f1 = Frame(m, m+0.5*cm, cw-0.75*cm, ch-1*cm, id='F1', 
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   329
            leftPadding=0, topPadding=0, rightPadding=0, bottomPadding=0,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   330
            showBoundary=True
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   331
        )
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   332
        f2 = Frame(cw+2.7*cm, m+0.5*cm, cw-0.75*cm, ch-1*cm, id='F2', 
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   333
            leftPadding=0, topPadding=0, rightPadding=0, bottomPadding=0,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   334
            showBoundary=True
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   335
        )
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3320
diff changeset
   336
        BaseDocTemplate.__init__(self, filename, **kw)
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   337
        template = PageTemplate('template', [f1, f2])
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   338
        self.addPageTemplates(template)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   339
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   340
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   341
class SplitFrameParagraphTest(unittest.TestCase):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   342
    "Test paragraph split over two frames."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   343
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   344
    def test(self):    
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   345
        stylesheet = getSampleStyleSheet()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   346
        normal = stylesheet['BodyText']
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   347
        normal.fontName = "Helvetica"
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   348
        normal.fontSize = 12
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   349
        normal.leading = 16
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   350
        normal.alignment = TA_JUSTIFY
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   351
    
4341
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   352
        text = b"Bedauerlicherweise ist ein Donaudampfschiffkapit\xc3\xa4n auch <font color='red'>nur</font> <font color='green'>ein</font> Dampfschiffkapit\xc3\xa4n."
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   353
        tagFormat = '%s'
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   354
        # strange behaviour when using next code line
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   355
        # (same for '<a href="http://www.reportlab.org">%s</a>'
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   356
        tagFormat = '<font color="red">%s</font>'
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   357
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   358
        #text = " ".join([tagFormat % w for w in text.split()])
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   359
        
4341
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   360
        story = [Paragraph((text.decode('utf8') + u" ") * 3, style=normal)]
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   361
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   362
        from reportlab.lib import pagesizes
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   363
        PAGESIZE = pagesizes.landscape(pagesizes.A4)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   364
        
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   365
        doc = TwoFrameDocTemplate(outputfile('test_paragraphs_splitframe.pdf'), pagesize=PAGESIZE)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   366
        doc.build(story)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   367
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   368
class FragmentTestCase(unittest.TestCase):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   369
    "Test fragmentation of paragraphs."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   370
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   371
    def test0(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   372
        "Test empty paragraph."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   373
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   374
        styleSheet = getSampleStyleSheet()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   375
        B = styleSheet['BodyText']
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   376
        text = ''
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   377
        P = Paragraph(text, B)
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   378
        frags = [f.text for f in P.frags]
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   379
        assert frags == []
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   380
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   381
    def test1(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   382
        "Test simple paragraph."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   383
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   384
        styleSheet = getSampleStyleSheet()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   385
        B = styleSheet['BodyText']
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   386
        text = "X<font name=Courier>Y</font>Z"
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   387
        P = Paragraph(text, B)
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   388
        frags = [f.text for f in P.frags]
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   389
        assert frags == ['X', 'Y', 'Z']
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   390
4046
aed0e2af4546 paragraph: fix _splitWord for unicode/bytes bug reported by Anders Hammarquist & add a test
robin
parents: 4036
diff changeset
   391
    def test2(self):
aed0e2af4546 paragraph: fix _splitWord for unicode/bytes bug reported by Anders Hammarquist & add a test
robin
parents: 4036
diff changeset
   392
        '''test _splitWord'''
aed0e2af4546 paragraph: fix _splitWord for unicode/bytes bug reported by Anders Hammarquist & add a test
robin
parents: 4036
diff changeset
   393
        self.assertEqual(_splitWord(u'd\'op\u00e9ration',30,[30],0,'Helvetica',12),[u"d'op\xe9", u'ratio', u'n'])
aed0e2af4546 paragraph: fix _splitWord for unicode/bytes bug reported by Anders Hammarquist & add a test
robin
parents: 4036
diff changeset
   394
        self.assertEqual(_splitWord(b'd\'op\xc3\xa9ration',30,[30],0,'Helvetica',12),[u"d'op\xe9", u'ratio', u'n'])
aed0e2af4546 paragraph: fix _splitWord for unicode/bytes bug reported by Anders Hammarquist & add a test
robin
parents: 4036
diff changeset
   395
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   396
class ULTestCase(unittest.TestCase):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   397
    "Test underlining and overstriking of paragraphs."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   398
    def testUl(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   399
        from reportlab.platypus import BaseDocTemplate, PageTemplate, Frame, PageBegin
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   400
        from reportlab.lib.units import inch
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   401
        from reportlab.platypus.flowables import AnchorFlowable
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   402
        class MyDocTemplate(BaseDocTemplate):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   403
            _invalidInitArgs = ('pageTemplates',)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   404
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   405
            def __init__(self, filename, **kw):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   406
                self.allowSplitting = 0
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   407
                kw['showBoundary']=1
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   408
                BaseDocTemplate.__init__(self, filename, **kw)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   409
                self.addPageTemplates(
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   410
                        [
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   411
                        PageTemplate('normal',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   412
                                [Frame(inch, inch, 6.27*inch, 9.69*inch, id='first',topPadding=0,rightPadding=0,leftPadding=0,bottomPadding=0,showBoundary=ShowBoundaryValue(color="red"))],
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   413
                                ),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   414
                        ])
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   415
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   416
        styleSheet = getSampleStyleSheet()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   417
        normal = ParagraphStyle(name='normal',fontName='Times-Roman',fontSize=12,leading=1.2*12,parent=styleSheet['Normal'])
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   418
        normal_sp = ParagraphStyle(name='normal_sp',parent=normal,alignment=TA_JUSTIFY,spaceBefore=12)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   419
        normal_just = ParagraphStyle(name='normal_just',parent=normal,alignment=TA_JUSTIFY)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   420
        normal_right = ParagraphStyle(name='normal_right',parent=normal,alignment=TA_RIGHT)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   421
        normal_center = ParagraphStyle(name='normal_center',parent=normal,alignment=TA_CENTER)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   422
        normal_indent = ParagraphStyle(name='normal_indent',firstLineIndent=0.5*inch,parent=normal)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   423
        normal_indent_lv_2 = ParagraphStyle(name='normal_indent_lv_2',firstLineIndent=1.0*inch,parent=normal)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   424
        texts = ['''Furthermore, a subset of <font size="14">English sentences</font> interesting on quite
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   425
independent grounds is not quite equivalent to a stipulation to place
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   426
the constructions into these various categories.''',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   427
        '''We will bring evidence in favor of
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   428
The following thesis:  most of the methodological work in modern
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   429
linguistics can be defined in such a way as to impose problems of
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   430
phonemic and morphological analysis.''']
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   431
        story =[]
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   432
        a = story.append
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   433
        a(Paragraph("This should &lt;a href=\"#theEnd\" color=\"blue\"&gt;<a href=\"#theEnd\" color=\"blue\">jump</a>&lt;/a&gt; jump to the end!",style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   434
        a(XPreformatted("This should &lt;a href=\"#theEnd\" color=\"blue\"&gt;<a href=\"#theEnd\" color=\"blue\">jump</a>&lt;/a&gt; jump to the end!",style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   435
        a(Paragraph("<a href=\"#theEnd\"><u><font color=\"blue\">ditto</font></u></a>",style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   436
        a(XPreformatted("<a href=\"#theEnd\"><u><font color=\"blue\">ditto</font></u></a>",style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   437
        a(Paragraph("This <font color='CMYKColor(0,0.6,0.94,0)'>should</font> &lt;a href=\"#thePenultimate\" color=\"blue\"&gt;<a href=\"#thePenultimate\" color=\"blue\">jump</a>&lt;/a&gt; jump to the penultimate page!",style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   438
        a(Paragraph("This should &lt;a href=\"#theThird\" color=\"blue\"&gt;<a href=\"#theThird\" color=\"blue\">jump</a>&lt;/a&gt; jump to a justified para!",style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   439
        a(Paragraph("This should &lt;a href=\"#theFourth\" color=\"blue\"&gt;<a href=\"#theFourth\" color=\"blue\">jump</a>&lt;/a&gt; jump to an indented para!",style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   440
        for mode in (0,1):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   441
            text0 = texts[0]
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   442
            text1 = texts[1]
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   443
            if mode:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   444
                text0 = text0.replace('English sentences','<b>English sentences</b>').replace('quite equivalent','<i>quite equivalent</i>')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   445
                text1 = text1.replace('the methodological work','<b>the methodological work</b>').replace('to impose problems','<i>to impose problems</i>')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   446
            for t in ('u','strike'):
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   447
                for n in range(6):
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   448
                    for s in (normal,normal_center,normal_right,normal_just,normal_indent, normal_indent_lv_2):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   449
                        for autoLeading in ('','min','max'):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   450
                            if n==4 and s==normal_center and t=='strike' and mode==1:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   451
                                a(Paragraph("<font color=green>The second jump at the beginning should come here &lt;a name=\"thePenultimate\"/&gt;<a name=\"thePenultimate\"/>!</font>",style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   452
                            elif n==4 and s==normal_just and t=='strike' and mode==1:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   453
                                a(Paragraph("<font color=green>The third jump at the beginning should come just below here to a paragraph with just an a tag in it!</font>",style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   454
                                a(Paragraph("<a name=\"theThird\"/>",style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   455
                            elif n==4 and s==normal_indent and t=='strike' and mode==1:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   456
                                a(Paragraph("<font color=green>The fourth jump at the beginning should come just below here!</font>",style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   457
                                a(AnchorFlowable('theFourth'))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   458
                            a(Paragraph('n=%d style=%s(autoLeading=%s) tag=%s'%(n,s.name,autoLeading,t),style=normal_sp))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   459
                            a(Paragraph('<para autoleading="%s">%s<%s>%s</%s>. %s <%s>%s</%s>. %s</para>' % (
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   460
                            autoLeading,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   461
                            (s==normal_indent_lv_2 and '<seq id="document" inc="no"/>.<seq id="document_lv_2"/>' or ''),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   462
                            t,' '.join((n+1)*['A']),t,text0,t,' '.join((n+1)*['A']),t,text1),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   463
                            style=s))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   464
        a(Paragraph("The jump at the beginning should come here &lt;a name=\"theEnd\"/&gt;<a name=\"theEnd\"/>!",style=normal))
4389
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   465
        a(Paragraph('Underlining <span fontSize="11"><u color="red">A<u color="green">B</u><u color="blue">C</u>D<sup><strike width="0.5" color="magenta">2</strike><sup><u color="darkgreen" width="0.2">3</u></sup></sup></u></span>',normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   466
        a(Paragraph('<para autoLeading="max" spaceAfter="10">this is in 12 <font size=30>this is in 30</font> <u offset="-0.5" width="0.5" color="red"><u offset="-1.5" width="0.5" color="blue">and</u></u> <link underline="1" ucolor="blue" href="http://google.com/">the link box<sup><a color="red" ucolor="green" underline="1" href="https://www.reportlab.com">2</a></sup> is right (twice).</link></para>''',normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   467
        a(Paragraph('<para autoLeading="max" spaceAfter="10">this is in 12 <font size=30>this is in 30</font> and <link underline="1" ucolor="blue" href="http://google.com/">the link box is right.</link></para>''',normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   468
        a(Paragraph('Underlining <u><span color="red">underlined in red? <span color="blue"><u>or blue</u></span> or red again?</span></u>',normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   469
        a(Paragraph('Link <a href="#theEnd" color="blue">jump</a> to end.<br/>Underlined link <a href="#theEnd" underline="1" ucolor="red" color="blue">jump</a> to end!',style=normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   470
        a(Paragraph('<para autoleading=""><u>A</u>. Furthermore, a subset of <font size="14">English sentences</font> interesting on quite\nindependent grounds is not quite equivalent to a stipulation to place\nthe constructions into these various categories. <u>A</u>. We will bring evidence in favor of\nThe following thesis: most of the methodological work in modern\nlinguistics can be defined in such a way as to impose problems of\nphonemic and morphological analysis.</para>',normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   471
        a(Paragraph('<para autoleading=""><u>A</u>. Furthermore, a subset of <font size="14">English sentences</font> interesting on quite<br/><u>A</u>.</para>',normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   472
        a(Paragraph(u"<para>This is a <sup rise=5><span color='red'>sup</span></sup>rise=5.</para>",normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   473
        a(Paragraph('<span fontSize="11"><u color="green"><strike color="blue">AAAAAA</strike></u></span>',normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   474
        a(Paragraph("Underlining &amp; width proportional to first use font size ('f' suffix) <u offset='-0.125*f' width='0.05*f'>underlined <span size=14>underlined</span></u>!",style=normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   475
        a(Paragraph("Underlining &amp; width proportional to first use font size ('F' suffix) <u offset='-0.125*F' width='0.05*F'>underlined <span size=14>underlined</span></u>!",style=normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   476
        a(Paragraph('''<para spaceBefore="10">This is underlined &lt;sup&gt;: a<sup><u><span color="red">sup</span></u></sup></para>''',style=normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   477
        a(Paragraph('''<para spaceBefore="10">This is <u>underlined</u></para>''',style=normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   478
        a(Paragraph('''<para spaceBefore="10">This is <u kind="double">underlined double</u></para>''',style=normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   479
        a(Paragraph('''<para spaceBefore="10">This is <strike>striken</strike></para>''',style=normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   480
        a(Paragraph('''<para spaceBefore="10">This is <strike><u>both</u></strike></para>''',style=normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   481
        a(Paragraph('''<para spaceBefore="10">This is <u width="0.5" offset="-1" kind="double">underlined kind="double"</u></para>''',style=normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   482
        a(Paragraph('''<para spaceBefore="10">This is <u width="0.25" offset="-1" kind="double">double underlined with thinner lines</u></para>''',style=normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   483
        a(Paragraph('''<para spaceBefore="10">This is <u width="0.5" offset="-0.5" color="red">underlined in red</u></para>''',style=normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   484
        a(Paragraph('''<para spaceBefore="10">This is <strike width="0.5" color="red">overstruck in red</strike></para>''',style=normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   485
        a(Paragraph('''<para spaceBefore="10">This is <strike width="0.5" color="red" kind="double">doubly overstruck in red</strike></para>''',style=normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   486
        a(Paragraph('''<para spaceBefore="10">This is <strike width="0.5" offset="0.125*F" color="red" kind="triple" gap="0.5">triply overstruck in red</strike></para>''',style=normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   487
        a(Paragraph('''<para autoLeading="max" spaceAfter="10" spaceBefore="30">this is in 12 <font size="30">this is in 30</font> <u offset="-0.5" width="0.5" color="red"><u offset="-1.5" width="0.5" color="blue">and</u></u> <link underline="1" ucolor="blue" href="http://google.com/">the link box<sup><a color="red" ucolor="green" underline="1" href="https://www.reportlab.com">2</a></sup> is right (twice).</link></para>''',style=normal))
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4387
diff changeset
   488
        a(Paragraph("",style=normal))
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   489
        doc = MyDocTemplate(outputfile('test_platypus_paragraphs_ul.pdf'))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   490
        doc.build(story)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   491
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   492
class AutoLeadingTestCase(unittest.TestCase):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   493
    "Test underlining and overstriking of paragraphs."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   494
    def testAutoLeading(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   495
        from reportlab.platypus import BaseDocTemplate, PageTemplate, Frame, PageBegin
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   496
        from reportlab.lib.units import inch
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   497
        from reportlab.platypus.flowables import AnchorFlowable
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   498
        class MyDocTemplate(BaseDocTemplate):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   499
            _invalidInitArgs = ('pageTemplates',)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   500
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   501
            def __init__(self, filename, **kw):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   502
                self.allowSplitting = 0
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   503
                kw['showBoundary']=1
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   504
                BaseDocTemplate.__init__(self, filename, **kw)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   505
                self.addPageTemplates(
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   506
                        [
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   507
                        PageTemplate('normal',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   508
                                [Frame(inch, inch, 6.27*inch, 9.69*inch, id='first',topPadding=0,rightPadding=0,leftPadding=0,bottomPadding=0,showBoundary=ShowBoundaryValue(color="red"))],
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   509
                                ),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   510
                        ])
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   511
2987
711910106e3a tests: more changes to testsFolder and friends
rgbecker
parents: 2984
diff changeset
   512
        from reportlab.lib.testutils import testsFolder
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   513
        styleSheet = getSampleStyleSheet()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   514
        normal = ParagraphStyle(name='normal',fontName='Times-Roman',fontSize=12,leading=1.2*12,parent=styleSheet['Normal'])
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   515
        normal_sp = ParagraphStyle(name='normal_sp',parent=normal,alignment=TA_JUSTIFY,spaceBefore=12)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   516
        texts = ['''Furthermore, a subset of <font size="14">English sentences</font> interesting on quite
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   517
independent grounds is not quite equivalent to a stipulation to place
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
   518
<font color="blue">the constructions <img src="%(testsFolder)s/../docs/images/testimg.gif"/> into these various categories.</font>'''%dict(testsFolder=testsFolder),
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   519
        '''We will bring <font size="18">Ugly Things</font> in favor of
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   520
The following thesis:  most of the methodological work in Modern
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
   521
Linguistics can be <img src="%(testsFolder)s/../docs/images/testimg.gif" valign="baseline" /> defined in such <img src="%(testsFolder)s/../docs/images/testimg.gif" valign="10" /> a way as to impose problems of
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
   522
phonemic and <u>morphological <img src="%(testsFolder)s/../docs/images/testimg.gif" valign="top"/> </u> analysis.'''%dict(testsFolder=testsFolder)]
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   523
        story =[]
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   524
        a = story.append
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   525
        t = 'u'
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   526
        n = 1
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   527
        for s in (normal,normal_sp):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   528
            for autoLeading in ('','min','max'):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   529
                a(Paragraph('style=%s(autoLeading=%s)'%(s.name,autoLeading),style=normal_sp))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   530
                a(Paragraph('<para autoleading="%s"><%s>%s</%s>. %s <%s>%s</%s>. %s</para>' % (
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   531
                            autoLeading,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   532
                            t,' '.join((n+1)*['A']),t,texts[0],t,' '.join((n+1)*['A']),t,texts[1]),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   533
                            style=s))
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
   534
        a(Paragraph('''<img src="%(testsFolder)s/../docs/images/testimg.gif" valign="top"/> image is very first thing in the line.'''%dict(testsFolder=testsFolder), style=normal))
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   535
        a(Paragraph('some text.... some more.... some text.... some more....', normal))
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
   536
        a(Paragraph('<img src="%(testsFolder)s/../docs/images/testimg.gif" width="0.57in" height="0.19in" /> some text <br /> '%dict(testsFolder=testsFolder), normal))
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   537
        a(Paragraph('some text.... some more.... some text.... some more....', normal))
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
   538
        a(Paragraph('<img src="%(testsFolder)s/../docs/images/testimg.gif" width="0.57in" height="0.19in" /> <br /> '%dict(testsFolder=testsFolder), normal))
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   539
        a(Paragraph('some text.... some more.... some text.... some more....', normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   540
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   541
        #Volker Haas' valign tests
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   542
        fmt = '''<font color="red">%(valign)s</font>: Furthermore, a <u>subset</u> <strike>of</strike> <font size="14">English sentences</font> interesting on quite
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
   543
independent grounds is not quite equivalent to a stipulation to place <img src="%(testsFolder)s/../docs/images/redsquare.png" width="0.5in" height="0.5in" valign="%(valign)s"/>
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   544
the constructions into these <u>various</u> categories. We will bring <font size="18">Ugly Things</font> in favor of
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   545
The following thesis:  most of the methodological work in Modern
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   546
Linguistics can be defined in such a way as to impose problems of
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   547
phonemic and <u>morphological</u> <strike>analysis</strike>.'''
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   548
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   549
        p_style= ParagraphStyle('Normal')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   550
        p_style.autoLeading = 'max'
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   551
        for valign in (
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   552
                'baseline',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   553
                'sub',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   554
                'super',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   555
                'top',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   556
                'text-top',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   557
                'middle',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   558
                'bottom',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   559
                'text-bottom',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   560
                '0%',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   561
                '2in',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   562
                ):
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
   563
            a(Paragraph(fmt % dict(valign=valign,testsFolder=testsFolder),p_style))
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
   564
            a(XPreformatted(fmt % dict(valign=valign,testsFolder=testsFolder),p_style))
3439
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   565
4249
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   566
        a(Paragraph('<br/><b>Some Paragraph tests of &lt;sup rise="pts" size="pts"</b>...', normal))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   567
        a(Paragraph("<br/>This is a <sup><span color='red'>sup</span></sup>.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   568
        a(XPreformatted("This is a <sup><span color='red'>sup</span></sup>.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   569
        a(Paragraph("This is a <sup rise=5><span color='red'>sup</span></sup>rise=5.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   570
        a(XPreformatted("This is a <sup rise=5><span color='red'>sup</span></sup>rise=5.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   571
        a(Paragraph("This is a <sup rise=6><span color='red'>sup</span></sup>rise=6.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   572
        a(XPreformatted("This is a <sup rise=6><span color='red'>sup</span></sup>rise=6.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   573
        a(Paragraph("This is a <sup rise=7><span color='red'>sup</span></sup>rise=7.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   574
        a(XPreformatted("This is a <sup rise=7><span color='red'>sup</span></sup>rise=7.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   575
        a(Paragraph("This is a <sup rise=8><span color='red'>sup</span></sup>rise=8.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   576
        a(XPreformatted("This is a <sup rise=8><span color='red'>sup</span></sup>rise=8.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   577
        a(Paragraph("This is a <sup rise=9><span color='red'>sup</span></sup>rise=9.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   578
        a(XPreformatted("This is a <sup rise=9><span color='red'>sup</span></sup>rise=9.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   579
        a(Paragraph("This is a <sup size=7><span color='red'>sup</span></sup>size=7.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   580
        a(XPreformatted("This is a <sup size=7><span color='red'>sup</span></sup>size=7.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   581
        a(Paragraph("This is a <sup rise=5 size=7><span color='red'>sup</span></sup>rise=5 size=7.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   582
        a(XPreformatted("This is a <sup rise=5 size=7><span color='red'>sup</span></sup>rise=5 size=7.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   583
        a(Paragraph("This is a <sup rise=6 size=7><span color='red'>sup</span></sup>rise=6 size=7.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   584
        a(XPreformatted("This is a <sup rise=6 size=7><span color='red'>sup</span></sup>rise=6 size=7.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   585
        a(Paragraph("This is a <sup rise=7 size=7><span color='red'>sup</span></sup>rise=7 size=7.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   586
        a(XPreformatted("This is a <sup rise=7 size=7><span color='red'>sup</span></sup>rise=7 size=7.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   587
        a(Paragraph("This is a <sup rise=8 size=7><span color='red'>sup</span></sup>rise=8 size=7.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   588
        a(XPreformatted("This is a <sup rise=8 size=7><span color='red'>sup</span></sup>rise=8 size=7.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   589
        a(Paragraph("This is a <sup rise=9 size=7><span color='red'>sup</span></sup>rise=9 size=7.",p_style))
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   590
        a(XPreformatted("This is a <sup rise=9 size=7><span color='red'>sup</span></sup>rise=9 size=7.",p_style))
4255
89ea1d46b4a0 make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents: 4252
diff changeset
   591
        a(Paragraph("This is a <sup rise=90% size=70%><span color='red'>sup</span></sup>rise=90% size=70%.",p_style))
89ea1d46b4a0 make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents: 4252
diff changeset
   592
        a(Paragraph("This is a <sup rise=-2 size=-2><span color='red'>sup</span></sup>rise=-2 size=-2.",p_style))
89ea1d46b4a0 make paraparser syntax errors real and fix <sup/sub> tags to have relative values; version-->3.3.1
robin
parents: 4252
diff changeset
   593
        a(Paragraph("This is a <sup rise=-4 size=-3><span color='red'>sup</span></sup>rise=-4 size=-3.",p_style))
4249
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   594
        a(PageBreak())
3439
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   595
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   596
        a(Paragraph('<br/><b>Some Paragraph tests of &lt;img width="x%" height="x%"</b>...', normal))
3435
31d0d9bb877a platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3371
diff changeset
   597
        a(Paragraph('H=10%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="0.57in" height="10%%" />'%dict(testsFolder=testsFolder), normal))
31d0d9bb877a platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3371
diff changeset
   598
        a(Paragraph('H=50%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="0.57in" height="50%%" />'%dict(testsFolder=testsFolder), normal))
31d0d9bb877a platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3371
diff changeset
   599
        a(Paragraph('H=100%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="0.57in" height="100%%" />'%dict(testsFolder=testsFolder), normal))
31d0d9bb877a platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3371
diff changeset
   600
        a(Paragraph('H=100%% W=10%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="10%%" height="100%%" />'%dict(testsFolder=testsFolder), normal))
31d0d9bb877a platypus: preliminary working version of % height/width for <img> tag
rgbecker
parents: 3371
diff changeset
   601
        a(Paragraph('H=100%% W=50%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="50%%" height="100%%" />'%dict(testsFolder=testsFolder), normal))
3439
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   602
        a(Paragraph('H=50%% W=50%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="50%%" height="50%%" />'%dict(testsFolder=testsFolder), normal))
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   603
        a(Paragraph('<br/><b>Some XPreformatted tests of &lt;img width="x%" height="x%"</b>...', normal))
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   604
        a(XPreformatted('H=10%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="0.57in" height="10%%" />'%dict(testsFolder=testsFolder), normal))
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   605
        a(XPreformatted('H=50%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="0.57in" height="50%%" />'%dict(testsFolder=testsFolder), normal))
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   606
        a(XPreformatted('H=100%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="0.57in" height="100%%" />'%dict(testsFolder=testsFolder), normal))
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   607
        a(XPreformatted('H=100%% W=10%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="10%%" height="100%%" />'%dict(testsFolder=testsFolder), normal))
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   608
        a(XPreformatted('H=100%% W=50%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="50%%" height="100%%" />'%dict(testsFolder=testsFolder), normal))
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   609
        a(XPreformatted('H=50%% W=50%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="50%%" height="50%%" />'%dict(testsFolder=testsFolder), normal))
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   610
        a(Paragraph('<br/><b>Some CJK Paragraph tests of &lt;img width="x%" height="x%"</b>...', normal))
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   611
        normalCJK = ParagraphStyle('normalCJK', parent=normal, wordWrap = 'CJK')
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   612
        a(Paragraph('H=10%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="0.57in" height="10%%" />'%dict(testsFolder=testsFolder), normalCJK))
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   613
        a(Paragraph('H=50%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="0.57in" height="50%%" />'%dict(testsFolder=testsFolder), normalCJK))
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   614
        a(Paragraph('H=100%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="0.57in" height="100%%" />'%dict(testsFolder=testsFolder), normalCJK))
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   615
        a(Paragraph('H=100%% W=10%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="10%%" height="100%%" />'%dict(testsFolder=testsFolder), normalCJK))
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   616
        a(Paragraph('H=100%% W=50%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="50%%" height="100%%" />'%dict(testsFolder=testsFolder), normalCJK))
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   617
        a(Paragraph('H=50%% W=50%% <img src="%(testsFolder)s/../docs/images/testimg.gif" width="50%%" height="50%%" />'%dict(testsFolder=testsFolder), normalCJK))
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   618
        doc = MyDocTemplate(outputfile('test_platypus_paragraphs_autoleading.pdf'))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   619
        doc.build(story)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   620
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   621
class JustifyTestCase(unittest.TestCase):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   622
    "Test justification of paragraphs."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   623
    def testUl(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   624
        from reportlab.platypus import BaseDocTemplate, PageTemplate, Frame, PageBegin
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   625
        from reportlab.lib.units import inch
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   626
        class MyDocTemplate(BaseDocTemplate):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   627
            _invalidInitArgs = ('pageTemplates',)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   628
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   629
            def __init__(self, filename, **kw):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   630
                self.allowSplitting = 0
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   631
                BaseDocTemplate.__init__(self, filename, **kw)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   632
                self.addPageTemplates(
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   633
                        [
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   634
                        PageTemplate('normal',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   635
                                [Frame(inch, inch, 6.27*inch, 9.69*inch, id='first',topPadding=0,rightPadding=0,leftPadding=0,bottomPadding=0,showBoundary=ShowBoundaryValue(color="red"))],
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   636
                                ),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   637
                        ])
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   638
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   639
        styleSheet = getSampleStyleSheet()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   640
        normal = ParagraphStyle(name='normal',fontName='Times-Roman',fontSize=12,leading=1.2*12,parent=styleSheet['Normal'])
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   641
        normal_just = ParagraphStyle(name='normal_just',parent=normal,alignment=TA_JUSTIFY,spaceAfter=12)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   642
        text0 = '''Furthermore, a subset of English sentences interesting on quite
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   643
independent grounds is not quite equivalent to a stipulation to place
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   644
the constructions into these various categories. We will bring evidence in favor of
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   645
The following thesis:  most of the methodological work in modern
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   646
linguistics can be defined in such a way as to impose problems of
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   647
phonemic and morphological analysis.'''
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   648
        story =[]
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   649
        a = story.append
4220
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   650
        for mode in (0,1,2,3,4,5,6,7):
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   651
            text = text0
4220
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   652
            paraStyle = normal_just
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   653
            if mode==1:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   654
                text = text.replace('English sentences','<b>English sentences</b>').replace('quite equivalent','<i>quite equivalent</i>')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   655
                text = text.replace('the methodological work','<b>the methodological work</b>').replace('to impose problems','<i>to impose problems</i>')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   656
                a(Paragraph('Justified paragraph in normal/bold/italic font',style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   657
            elif mode==2:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   658
                text = '<b>%s</b>' % text
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   659
                a(Paragraph('Justified paragraph in bold font',style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   660
            elif mode==3:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   661
                text = '<i>%s</i>' % text
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   662
                a(Paragraph('Justified paragraph in italic font',style=normal))
3371
24dcc0cb4727 test_platypus_paragraphs: add hard spaces case
rgbecker
parents: 3326
diff changeset
   663
            elif mode==4:
24dcc0cb4727 test_platypus_paragraphs: add hard spaces case
rgbecker
parents: 3326
diff changeset
   664
                text = text.replace('English ','English&nbsp;').replace('quite ','quite&nbsp;')
24dcc0cb4727 test_platypus_paragraphs: add hard spaces case
rgbecker
parents: 3326
diff changeset
   665
                text = text.replace(' methodological','&nbsp;methodological').replace(' impose','&nbsp;impose')
3807
55af72526d90 fix tests
robin
parents: 3800
diff changeset
   666
                a(Paragraph('Justified paragraph in normal font &amp; some hard spaces',style=normal))
4220
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   667
            elif mode in (5,6,7):
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   668
                text = text.replace('as to impose','<br/>as to impose').replace(' most of the','<br/>most of the')
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   669
                text = text.replace(' grounds','<br/>grounds').replace(' various','<br/>various')
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   670
                if mode in (6,7):
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   671
                    msg = []
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   672
                    msg.append('justifyBreaks=1')
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   673
                    paraStyle = paraStyle.clone('paraStyle6',paraStyle,justifyBreaks=1)
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   674
                    if mode==7:
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   675
                        msg.append('justifyLastLine=3')
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   676
                        paraStyle = paraStyle.clone('paraStyle7',paraStyle,justifyLastLine=3)
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   677
                    msg = '(%s) ' % (' '.join(msg))
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   678
                else:
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   679
                    a(PageBreak())
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   680
                    msg = ' '
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   681
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   682
                a(Paragraph('Justified%swith some &lt;br/&gt; tags' % msg,style=normal))
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   683
            else:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   684
                a(Paragraph('Justified paragraph in normal font',style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   685
4220
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   686
            a(Paragraph(text,style=paraStyle))
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   687
        doc = MyDocTemplate(outputfile('test_platypus_paragraphs_just.pdf'))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   688
        doc.build(story)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   689
3564
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   690
    def testAutoPageTemplate(self):
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   691
        from reportlab.platypus import BaseDocTemplate, PageTemplate, Frame, PageBegin
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   692
        from reportlab.lib.units import inch
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   693
        class onPage:
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   694
            def __init__(self,label):
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   695
                self.label = label
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   696
            def __call__(self,canv,doc):
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   697
                canv.drawString(72,72,'This is pageTemplate(%s)' % (self.label,))
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   698
        class MyDocTemplate(BaseDocTemplate):
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   699
            _invalidInitArgs = ('pageTemplates',)
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   700
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   701
            def __init__(self, filename, **kw):
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   702
                self.allowSplitting = 0
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   703
                BaseDocTemplate.__init__(self, filename, **kw)
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   704
                self.addPageTemplates(
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   705
                        [
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   706
                        PageTemplate('normal',
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   707
                                [Frame(inch, inch, 6.27*inch, 9.69*inch, id='first',topPadding=0,rightPadding=0,leftPadding=0,bottomPadding=0,showBoundary=ShowBoundaryValue(color="red"))],
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   708
                                onPage = onPage('normal'),
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   709
                                ),
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   710
                        PageTemplate('auto',
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   711
                                [Frame(inch, inch, 6.27*inch, 9.69*inch, id='first',topPadding=0,rightPadding=0,leftPadding=0,bottomPadding=0,showBoundary=ShowBoundaryValue(color="red"))],
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   712
                                onPage = onPage('auto'),
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   713
                                autoNextPageTemplate = 'autoFollow',
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   714
                                ),
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   715
                        PageTemplate('autoFollow',
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   716
                                [Frame(inch, inch, 6.27*inch, 9.69*inch, id='first',topPadding=0,rightPadding=0,leftPadding=0,bottomPadding=0,showBoundary=ShowBoundaryValue(color="red"))],
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   717
                                onPage = onPage('autoFollow'),
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   718
                                ),
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   719
                        ])
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   720
        styleSheet = getSampleStyleSheet()
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   721
        normal = ParagraphStyle(name='normal',fontName='Times-Roman',fontSize=12,leading=1.2*12,parent=styleSheet['Normal'])
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   722
        story =[]
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   723
        a = story.append
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   724
        a(Paragraph('should be on page template normal', normal))
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   725
        a(NextPageTemplate('auto'))
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   726
        a(PageBreak())
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   727
        a(Paragraph('should be on page template auto', normal))
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   728
        a(PageBreak())
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   729
        a(DocAssert('doc.pageTemplate.id=="autoFollow"','expected doc.pageTemplate.id=="autoFollow"'))
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   730
        a(Paragraph('should be on page template autoFollow 1', normal))
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   731
        a(PageBreak())
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   732
        a(Paragraph('should be on page template autoFollow 2', normal))
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   733
        doc = MyDocTemplate(outputfile('test_platypus_paragraphs_AutoNextPageTemplate.pdf'))
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   734
        doc.build(story)
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   735
4315
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   736
    def testParaBrFlowing(self):
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   737
        from reportlab.platypus import BaseDocTemplate, PageTemplate, Frame, PageBegin
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   738
        from reportlab.lib.units import inch
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   739
        class MyDocTemplate(BaseDocTemplate):
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   740
            _invalidInitArgs = ('pageTemplates',)
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   741
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   742
            def __init__(self, filename, **kw):
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   743
                self.allowSplitting = 0
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   744
                BaseDocTemplate.__init__(self, filename, **kw)
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   745
                self.addPageTemplates(
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   746
                        [
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   747
                        PageTemplate('normal',
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   748
                                [
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   749
                                Frame(inch, 4.845*inch, 3*inch, 3.645*inch, id='first',topPadding=0,rightPadding=0,leftPadding=0,bottomPadding=0,showBoundary=ShowBoundaryValue(color="red")),
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   750
                                Frame(4.27*inch, 4.845*inch, 3*inch, 3.645*inch, id='second',topPadding=0,rightPadding=0,leftPadding=0,bottomPadding=0,showBoundary=ShowBoundaryValue(color="red")),
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   751
                                Frame(inch, inch, 3*inch, 3.645*inch, id='third',topPadding=0,rightPadding=0,leftPadding=0,bottomPadding=0,showBoundary=ShowBoundaryValue(color="red")),
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   752
                                Frame(4.27*inch, inch, 3*inch, 3.645*inch, id='fourth',topPadding=0,rightPadding=0,leftPadding=0,bottomPadding=0,showBoundary=ShowBoundaryValue(color="red"))
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   753
                                ],
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   754
                                ),
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   755
                        ])
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   756
        styleSheet = getSampleStyleSheet()
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   757
        normal = ParagraphStyle(name='normal',fontName='Helvetica',fontSize=10,leading=12,parent=styleSheet['Normal'])
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   758
        bold = ParagraphStyle(name='bold',fontName='Helvetica-Bold',fontSize=12,leading=14.4,parent=normal)
4345
6d1e728dc253 reproducibility changes
robin <robin@reportlab.com>
parents: 4341
diff changeset
   759
        brText=u"""
4315
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   760
Clearly, the natural general principle that will subsume this case is
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   761
not subject to a parasitic gap construction.  Presumably, most of the
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   762
methodological work in modern linguistics can be defined in such a way
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   763
as to impose the system of base rules exclusive of the lexicon.  In the
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   764
discussion of resumptive pronouns following (81), the fundamental error
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   765
of regarding functional notions as categorial is to be regarded as a
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   766
descriptive <span color="red">fact</span>.<br/>So far, the earlier discussion of deviance is not
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   767
quite equivalent to a parasitic gap construction.  To characterize a
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   768
linguistic level L, a case of semigrammaticalness of a different sort
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   769
may remedy and, at the same time, eliminate irrelevant intervening
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   770
contexts in selectional <span color="red">rules</span>.<br/>
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   771
Summarizing, then, we assume that the descriptive power of the base
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   772
component can be defined in such a way as to impose nondistinctness in
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   773
the sense of distinctive feature theory.  A lot of sophistication has
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   774
been developed about the utilization of machines for complex purposes,
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   775
the notion of level of grammaticalness delimits an abstract underlying
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   776
<span color="red">order</span>.<br/>To provide a constituent structure for T(Z,K), a subset of
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   777
English sentences interesting on quite independent grounds appears to
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   778
correlate rather closely with problems of phonemic and morphological
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   779
analysis.  For one thing, this analysis of a formative as a pair of sets
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   780
of features is rather different from a general convention regarding the
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   781
forms of the grammar.  A lot of sophistication has been developed about
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   782
the utilization of machines for complex purposes, a case of
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   783
semigrammaticalness of a different sort is not to be considered in
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   784
determining an important distinction in language <span color="red">use</span>.<br/>
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   785
We will bring evidence in favor of the following thesis:  a subset of
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   786
English sentences interesting on quite independent grounds delimits a
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   787
descriptive <span color="red">fact</span>.<br/>To characterize a linguistic level L, the notion of
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   788
level of grammaticalness is not to be considered in determining a
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   789
parasitic gap construction.  It must be emphasized, once again, that the
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   790
speaker-hearer's linguistic intuition can be defined in such a way as to
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   791
impose a stipulation to place the constructions into these various
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   792
categories.  On our assumptions, the appearance of parasitic gaps in
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   793
domains relatively inaccessible to ordinary extraction raises serious
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   794
doubts about problems of phonemic and morphological analysis.  For one
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   795
thing, the fundamental error of regarding functional notions as
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   796
categorial is not quite equivalent to a stipulation to place the
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   797
constructions into these various <span color="red">categories</span>.<br/>
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   798
Thus the descriptive power of the base component is unspecified with
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   799
respect to the strong generative capacity of the theory.  Presumably,
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   800
the theory of syntactic features developed earlier appears to correlate
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   801
rather closely with a corpus of utterance tokens upon which conformity
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   802
has been defined by the paired utterance test.  To provide a constituent
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   803
structure for T(Z,K), a case of semigrammaticalness of a different sort
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   804
is not to be considered in determining the ultimate standard that
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   805
determines the accuracy of any proposed grammar.  For any transformation
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   806
which is sufficiently diversified in application to be of any interest,
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   807
a subset of English sentences interesting on quite independent grounds
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   808
raises serious doubts about the requirement that branching is not
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   809
tolerated within the dominance scope of a complex symbol.  We will bring
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   810
evidence in favor of the following thesis:  an important property of
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   811
these three types of EC is not to be considered in determining the
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   812
system of base rules exclusive of the <span color="red">lexicon</span>.<br/>
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   813
With this clarification, the descriptive power of the base component is
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   814
not subject to the requirement that branching is not tolerated within
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   815
the dominance scope of a complex <span color="red">symbol</span>.<br/>In the discussion of
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   816
resumptive pronouns following (81), this selectionally introduced
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   817
contextual feature does not readily tolerate a parasitic gap
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   818
construction.  Another superficial similarity is the interest in
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   819
simulation of behavior, a descriptively adequate grammar does not affect
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   820
the structure of a corpus of utterance tokens upon which conformity has
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   821
been defined by the paired utterance <span color="red">test</span>.<br/>From C1, it follows that the
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   822
speaker-hearer's linguistic intuition is not to be considered in
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   823
determining the traditional practice of grammarians.  Let us continue to
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   824
suppose that the notion of level of grammaticalness is necessary to
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   825
impose an interpretation on the system of base rules exclusive of the
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   826
<span color="red">lexicon</span>.<br/>
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   827
"""
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   828
        story =[]
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   829
        a = story.append
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   830
        a(Paragraph('Paragraph Flowing', bold))
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   831
        a(Paragraph(brText, normal))
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   832
        doc = MyDocTemplate(outputfile('test_platypus_paragraphs_para_br_flowing.pdf'))
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   833
        doc.build(story)
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   834
4341
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   835
    def testParaNBSP(self):
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   836
        from reportlab.platypus import BaseDocTemplate, PageTemplate, Frame, PageBegin
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   837
        from reportlab.lib.units import inch
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   838
        class MyDocTemplate(BaseDocTemplate):
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   839
            _invalidInitArgs = ('pageTemplates',)
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   840
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   841
            def __init__(self, filename, **kw):
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   842
                self.allowSplitting = 0
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   843
                BaseDocTemplate.__init__(self, filename, **kw)
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   844
                self.addPageTemplates(
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   845
                        [
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   846
                        PageTemplate('normal',
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   847
                                [
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   848
                                Frame(inch, 4.845*inch, 3*inch, 3.645*inch, id='first',topPadding=0,rightPadding=0,leftPadding=0,bottomPadding=0,showBoundary=ShowBoundaryValue(color="red")),
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   849
                                Frame(4.27*inch, 4.845*inch, 3*inch, 3.645*inch, id='second',topPadding=0,rightPadding=0,leftPadding=0,bottomPadding=0,showBoundary=ShowBoundaryValue(color="red")),
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   850
                                Frame(inch, inch, 3*inch, 3.645*inch, id='third',topPadding=0,rightPadding=0,leftPadding=0,bottomPadding=0,showBoundary=ShowBoundaryValue(color="red")),
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   851
                                Frame(4.27*inch, inch, 3*inch, 3.645*inch, id='fourth',topPadding=0,rightPadding=0,leftPadding=0,bottomPadding=0,showBoundary=ShowBoundaryValue(color="red"))
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   852
                                ],
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   853
                                ),
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   854
                        ])
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   855
        styleSheet = getSampleStyleSheet()
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   856
        normal = ParagraphStyle(name='normal',fontName='Helvetica',fontSize=10,leading=12,parent=styleSheet['Normal'])
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   857
        bold = ParagraphStyle(name='bold',fontName='Helvetica-Bold',fontSize=12,leading=14.4,parent=normal)
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   858
        story =[]
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   859
        a = story.append
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   860
        a(Paragraph('Paragraph Hard Space Handling', bold))
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   861
        a(Paragraph(''' <span backcolor="pink">ABCDEFGHI</span> ''', normal))
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   862
        a(Paragraph(''' <span backcolor="palegreen">&nbsp;ABCDEFGHI&nbsp;</span> ''', normal))
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   863
        doc = MyDocTemplate(outputfile('test_platypus_paragraphs_nbsp.pdf'))
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   864
        doc.build(story)
19a971b1bfa4 more reprodicibility fixes
robin <robin@reportlab.com>
parents: 4330
diff changeset
   865
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   866
#noruntests
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   867
def makeSuite():
3371
24dcc0cb4727 test_platypus_paragraphs: add hard spaces case
rgbecker
parents: 3326
diff changeset
   868
    return makeSuiteForClasses(ParagraphCorners,SplitFrameParagraphTest,FragmentTestCase, ParagraphSplitTestCase, ULTestCase, JustifyTestCase,
24dcc0cb4727 test_platypus_paragraphs: add hard spaces case
rgbecker
parents: 3326
diff changeset
   869
            AutoLeadingTestCase)
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   870
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   871
#noruntests
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   872
if __name__ == "__main__":
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   873
    unittest.TextTestRunner().run(makeSuite())
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   874
    printLocation()