tests/test_platypus_paragraphs.py
author robin <robin@reportlab.com>
Tue, 07 Mar 2017 10:00:34 +0000
changeset 4330 617ffa6bbdc8
parent 4315 7c65c6e52b13
child 4341 19a971b1bfa4
permissions -rw-r--r--
changes for release 3.4.0
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)
9f7288085d44 reportlab: fix support for cjk splitting
rgbecker
parents: 3439
diff changeset
   123
        canv = Canvas('test_platypus_paragraph_cjk3.pdf')
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']
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   185
        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
   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
3931
ceee76b69e7c fix href bug reported by bitbucket.kmouts
robin
parents: 3807
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. <strike>This text should have a strike through it.</strike>
4291
1e64956b128b add mailto href test
robin
parents: 4255
diff changeset
   202
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>.
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   203
'''
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   204
        from reportlab.platypus.flowables import ImageAndFlowables, Image
2987
711910106e3a tests: more changes to testsFolder and friends
rgbecker
parents: 2984
diff changeset
   205
        from reportlab.lib.testutils import testsFolder
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
   206
        gif = os.path.join(testsFolder,'pythonpowered.gif')
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   207
        heading = Paragraph('This is a heading',h3)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   208
        story.append(ImageAndFlowables(Image(gif),[heading,Paragraph(text,bt)]))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   209
        phrase = 'This should be a paragraph spanning at least three pages. '
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   210
        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
   211
        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
   212
        story.append(NextPageTemplate('special'))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   213
        story.append(PageBreak())
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   214
        VERA = ('Vera','VeraBd','VeraIt','VeraBI')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   215
        for v in VERA:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   216
            registerFont(TTFont(v,v+'.ttf'))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   217
        registerFontFamily(*(VERA[:1]+VERA))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   218
        story.append(ImageAndFlowables(
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   219
                        Image(gif,width=280,height=120),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   220
                        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
   221
data applications began with the introduction of the IMACS. The
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   222
IMACS 200 carries on that tradition with an integrated solution
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   223
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
   224
economically address. An array of the most popular interfaces and
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   225
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
   226
providing the ultimate in ease of installation.</font>''',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   227
                        style=ParagraphStyle(
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   228
                                name="base",
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   229
                                fontName="Helvetica",
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   230
                                leading=12,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   231
                                leftIndent=0,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   232
                                firstLineIndent=0,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   233
                                spaceBefore = 9.5,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   234
                                fontSize=9.5,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   235
                                )
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   236
                            ),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   237
                    imageSide='left',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   238
                    )
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   239
                )
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   240
        story.append(ImageAndFlowables(
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   241
                        Image(gif,width=240,height=120),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   242
                        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
   243
data applications began with the introduction of the IMACS. The
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   244
IMACS 200 carries on that tradition with an integrated solution
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   245
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
   246
economically address. An array of the most popular interfaces and
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   247
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
   248
providing the ultimate in ease of installation.''',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   249
                        style=ParagraphStyle(
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   250
                                name="base",
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   251
                                fontName="Helvetica",
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   252
                                leading=12,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   253
                                leftIndent=0,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   254
                                firstLineIndent=0,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   255
                                spaceBefore = 9.5,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   256
                                fontSize=9.5,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   257
                                )
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   258
                            ),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   259
                    imageSide='left',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   260
                    )
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   261
                )
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   262
3320
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   263
        story.append(PageBreak())
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   264
        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
   265
        story.append(ImageAndFlowables(
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   266
                        Image(gif,width=6*110,height=6*44),
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   267
                        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
   268
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
   269
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
   270
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
   271
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
   272
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
   273
providing the ultimate in ease of installation.''',
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   274
                        style=ParagraphStyle(
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   275
                                name="base",
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   276
                                fontName="Helvetica",
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   277
                                leading=12,
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   278
                                leftIndent=0,
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   279
                                firstLineIndent=0,
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   280
                                spaceBefore = 9.5,
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   281
                                fontSize=9.5,
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   282
                                )
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   283
                            ),
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   284
                    imageSide='left',
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   285
                    )
d49ef1795c27 test_platypus_paragraphs.py: add overlarge test to ImageAndFlowables tests
rgbecker
parents: 3197
diff changeset
   286
                )
4036
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   287
        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
   288
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
   289
morphological analysis.  Another superficial similarity is the interest
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   290
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
   291
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
   292
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
   293
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
   294
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
   295
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
   296
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
   297
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
   298
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
   299
component delimits the traditional practice of grammarians.'''
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   300
        gif = os.path.join(testsFolder,'pythonpowered.gif')
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   301
        heading = Paragraph('This is a heading',h3)
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   302
        story.append(NextPageTemplate('template2'))
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   303
        story.append(PageBreak())
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   304
        story.append(heading)
f7d6d36cc44c test_platypus_paragraphs.py: add image and flowables test
robin
parents: 3931
diff changeset
   305
        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
   306
        doc = MyDocTemplate(outputfile('test_platypus_imageandflowables.pdf'),showBoundary=1)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   307
        doc.multiBuild(story)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   308
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   309
class TwoFrameDocTemplate(BaseDocTemplate):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   310
    "Define a simple document with two frames per page."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   311
    
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   312
    def __init__(self, filename, **kw):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   313
        m = 2*cm
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   314
        from reportlab.lib import pagesizes
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   315
        PAGESIZE = pagesizes.landscape(pagesizes.A4)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   316
        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
   317
        ch -= 14*cm
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   318
        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
   319
            leftPadding=0, topPadding=0, rightPadding=0, bottomPadding=0,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   320
            showBoundary=True
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
        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
   323
            leftPadding=0, topPadding=0, rightPadding=0, bottomPadding=0,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   324
            showBoundary=True
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   325
        )
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3320
diff changeset
   326
        BaseDocTemplate.__init__(self, filename, **kw)
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   327
        template = PageTemplate('template', [f1, f2])
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   328
        self.addPageTemplates(template)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   329
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   330
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   331
class SplitFrameParagraphTest(unittest.TestCase):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   332
    "Test paragraph split over two frames."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   333
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   334
    def test(self):    
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   335
        stylesheet = getSampleStyleSheet()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   336
        normal = stylesheet['BodyText']
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   337
        normal.fontName = "Helvetica"
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   338
        normal.fontSize = 12
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   339
        normal.leading = 16
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   340
        normal.alignment = TA_JUSTIFY
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   341
    
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   342
        text = "Bedauerlicherweise ist ein Donaudampfschiffkapit\xc3\xa4n auch <font color='red'>nur</font> <font color='green'>ein</font> Dampfschiffkapit\xc3\xa4n."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   343
        tagFormat = '%s'
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   344
        # strange behaviour when using next code line
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   345
        # (same for '<a href="http://www.reportlab.org">%s</a>'
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   346
        tagFormat = '<font color="red">%s</font>'
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   347
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   348
        #text = " ".join([tagFormat % w for w in text.split()])
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   349
        
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   350
        story = [Paragraph((text + " ") * 3, style=normal)]
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   351
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   352
        from reportlab.lib import pagesizes
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   353
        PAGESIZE = pagesizes.landscape(pagesizes.A4)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   354
        
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   355
        doc = TwoFrameDocTemplate(outputfile('test_paragraphs_splitframe.pdf'), pagesize=PAGESIZE)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   356
        doc.build(story)
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
class FragmentTestCase(unittest.TestCase):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   359
    "Test fragmentation of paragraphs."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   360
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   361
    def test0(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   362
        "Test empty paragraph."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   363
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   364
        styleSheet = getSampleStyleSheet()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   365
        B = styleSheet['BodyText']
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   366
        text = ''
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   367
        P = Paragraph(text, B)
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   368
        frags = [f.text for f in P.frags]
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   369
        assert frags == []
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 test1(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   372
        "Test simple 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 = "X<font name=Courier>Y</font>Z"
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 == ['X', 'Y', 'Z']
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   380
4046
aed0e2af4546 paragraph: fix _splitWord for unicode/bytes bug reported by Anders Hammarquist & add a test
robin
parents: 4036
diff changeset
   381
    def test2(self):
aed0e2af4546 paragraph: fix _splitWord for unicode/bytes bug reported by Anders Hammarquist & add a test
robin
parents: 4036
diff changeset
   382
        '''test _splitWord'''
aed0e2af4546 paragraph: fix _splitWord for unicode/bytes bug reported by Anders Hammarquist & add a test
robin
parents: 4036
diff changeset
   383
        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
   384
        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
   385
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   386
class ULTestCase(unittest.TestCase):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   387
    "Test underlining and overstriking of paragraphs."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   388
    def testUl(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   389
        from reportlab.platypus import BaseDocTemplate, PageTemplate, Frame, PageBegin
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   390
        from reportlab.lib.units import inch
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   391
        from reportlab.platypus.flowables import AnchorFlowable
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   392
        class MyDocTemplate(BaseDocTemplate):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   393
            _invalidInitArgs = ('pageTemplates',)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   394
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   395
            def __init__(self, filename, **kw):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   396
                self.allowSplitting = 0
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   397
                kw['showBoundary']=1
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   398
                BaseDocTemplate.__init__(self, filename, **kw)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   399
                self.addPageTemplates(
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   400
                        [
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   401
                        PageTemplate('normal',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   402
                                [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
   403
                                ),
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
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   406
        styleSheet = getSampleStyleSheet()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   407
        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
   408
        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
   409
        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
   410
        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
   411
        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
   412
        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
   413
        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
   414
        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
   415
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
   416
the constructions into these various categories.''',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   417
        '''We will bring evidence in favor of
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   418
The following thesis:  most of the methodological work in modern
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   419
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
   420
phonemic and morphological analysis.''']
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   421
        story =[]
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   422
        a = story.append
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   423
        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
   424
        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
   425
        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
   426
        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
   427
        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
   428
        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
   429
        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
   430
        for mode in (0,1):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   431
            text0 = texts[0]
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   432
            text1 = texts[1]
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   433
            if mode:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   434
                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
   435
                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
   436
            for t in ('u','strike'):
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   437
                for n in range(6):
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   438
                    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
   439
                        for autoLeading in ('','min','max'):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   440
                            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
   441
                                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
   442
                            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
   443
                                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
   444
                                a(Paragraph("<a name=\"theThird\"/>",style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   445
                            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
   446
                                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
   447
                                a(AnchorFlowable('theFourth'))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   448
                            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
   449
                            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
   450
                            autoLeading,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   451
                            (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
   452
                            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
   453
                            style=s))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   454
        a(Paragraph("The jump at the beginning should come here &lt;a name=\"theEnd\"/&gt;<a name=\"theEnd\"/>!",style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   455
        doc = MyDocTemplate(outputfile('test_platypus_paragraphs_ul.pdf'))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   456
        doc.build(story)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   457
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   458
class AutoLeadingTestCase(unittest.TestCase):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   459
    "Test underlining and overstriking of paragraphs."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   460
    def testAutoLeading(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   461
        from reportlab.platypus import BaseDocTemplate, PageTemplate, Frame, PageBegin
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   462
        from reportlab.lib.units import inch
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   463
        from reportlab.platypus.flowables import AnchorFlowable
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   464
        class MyDocTemplate(BaseDocTemplate):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   465
            _invalidInitArgs = ('pageTemplates',)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   466
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   467
            def __init__(self, filename, **kw):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   468
                self.allowSplitting = 0
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   469
                kw['showBoundary']=1
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   470
                BaseDocTemplate.__init__(self, filename, **kw)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   471
                self.addPageTemplates(
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   472
                        [
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   473
                        PageTemplate('normal',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   474
                                [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
   475
                                ),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   476
                        ])
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   477
2987
711910106e3a tests: more changes to testsFolder and friends
rgbecker
parents: 2984
diff changeset
   478
        from reportlab.lib.testutils import testsFolder
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   479
        styleSheet = getSampleStyleSheet()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   480
        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
   481
        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
   482
        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
   483
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
   484
<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
   485
        '''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
   486
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
   487
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
   488
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
   489
        story =[]
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   490
        a = story.append
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   491
        t = 'u'
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   492
        n = 1
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   493
        for s in (normal,normal_sp):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   494
            for autoLeading in ('','min','max'):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   495
                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
   496
                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
   497
                            autoLeading,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   498
                            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
   499
                            style=s))
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
   500
        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
   501
        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
   502
        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
   503
        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
   504
        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
   505
        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
   506
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   507
        #Volker Haas' valign tests
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   508
        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
   509
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
   510
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
   511
The following thesis:  most of the methodological work in Modern
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   512
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
   513
phonemic and <u>morphological</u> <strike>analysis</strike>.'''
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   514
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   515
        p_style= ParagraphStyle('Normal')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   516
        p_style.autoLeading = 'max'
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   517
        for valign in (
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   518
                'baseline',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   519
                'sub',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   520
                'super',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   521
                'top',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   522
                'text-top',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   523
                'middle',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   524
                'bottom',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   525
                'text-bottom',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   526
                '0%',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   527
                '2in',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   528
                ):
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
   529
            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
   530
            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
   531
4249
8fc7d11bdee0 add support for rml <sup>/<sub> rise and size attributes; version --> 3.2.17
robin
parents: 4220
diff changeset
   532
        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
   533
        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
   534
        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
   535
        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
   536
        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
   537
        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
   538
        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
   539
        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
   540
        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
   541
        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
   542
        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
   543
        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
   544
        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
   545
        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
   546
        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
   547
        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
   548
        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
   549
        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
   550
        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
   551
        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
   552
        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
   553
        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
   554
        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
   555
        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
   556
        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
   557
        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
   558
        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
   559
        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
   560
        a(PageBreak())
3439
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   561
dc7b50400f12 test_platypus_paragraphs.py: add more tests of percentaged width/height img tags
rgbecker
parents: 3435
diff changeset
   562
        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
   563
        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
   564
        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
   565
        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
   566
        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
   567
        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
   568
        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
   569
        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
   570
        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
   571
        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
   572
        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
   573
        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
   574
        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
   575
        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
   576
        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
   577
        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
   578
        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
   579
        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
   580
        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
   581
        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
   582
        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
   583
        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
   584
        doc = MyDocTemplate(outputfile('test_platypus_paragraphs_autoleading.pdf'))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   585
        doc.build(story)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   586
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   587
class JustifyTestCase(unittest.TestCase):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   588
    "Test justification of paragraphs."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   589
    def testUl(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   590
        from reportlab.platypus import BaseDocTemplate, PageTemplate, Frame, PageBegin
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   591
        from reportlab.lib.units import inch
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   592
        class MyDocTemplate(BaseDocTemplate):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   593
            _invalidInitArgs = ('pageTemplates',)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   594
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   595
            def __init__(self, filename, **kw):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   596
                self.allowSplitting = 0
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   597
                BaseDocTemplate.__init__(self, filename, **kw)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   598
                self.addPageTemplates(
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   599
                        [
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   600
                        PageTemplate('normal',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   601
                                [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
   602
                                ),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   603
                        ])
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   604
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   605
        styleSheet = getSampleStyleSheet()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   606
        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
   607
        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
   608
        text0 = '''Furthermore, a subset of English sentences interesting on quite
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   609
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
   610
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
   611
The following thesis:  most of the methodological work in modern
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   612
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
   613
phonemic and morphological analysis.'''
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   614
        story =[]
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   615
        a = story.append
4220
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   616
        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
   617
            text = text0
4220
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   618
            paraStyle = normal_just
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   619
            if mode==1:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   620
                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
   621
                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
   622
                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
   623
            elif mode==2:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   624
                text = '<b>%s</b>' % text
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   625
                a(Paragraph('Justified paragraph in bold font',style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   626
            elif mode==3:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   627
                text = '<i>%s</i>' % text
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   628
                a(Paragraph('Justified paragraph in italic font',style=normal))
3371
24dcc0cb4727 test_platypus_paragraphs: add hard spaces case
rgbecker
parents: 3326
diff changeset
   629
            elif mode==4:
24dcc0cb4727 test_platypus_paragraphs: add hard spaces case
rgbecker
parents: 3326
diff changeset
   630
                text = text.replace('English ','English&nbsp;').replace('quite ','quite&nbsp;')
24dcc0cb4727 test_platypus_paragraphs: add hard spaces case
rgbecker
parents: 3326
diff changeset
   631
                text = text.replace(' methodological','&nbsp;methodological').replace(' impose','&nbsp;impose')
3807
55af72526d90 fix tests
robin
parents: 3800
diff changeset
   632
                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
   633
            elif mode in (5,6,7):
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   634
                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
   635
                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
   636
                if mode in (6,7):
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   637
                    msg = []
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   638
                    msg.append('justifyBreaks=1')
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   639
                    paraStyle = paraStyle.clone('paraStyle6',paraStyle,justifyBreaks=1)
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   640
                    if mode==7:
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   641
                        msg.append('justifyLastLine=3')
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   642
                        paraStyle = paraStyle.clone('paraStyle7',paraStyle,justifyLastLine=3)
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   643
                    msg = '(%s) ' % (' '.join(msg))
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   644
                else:
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   645
                    a(PageBreak())
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   646
                    msg = ' '
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   647
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   648
                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
   649
            else:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   650
                a(Paragraph('Justified paragraph in normal font',style=normal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   651
4220
c0e82d246798 add justifyBreaks & justifyLastLine ParagraphStyle attributes; version-->3.2.7
robin
parents: 4148
diff changeset
   652
            a(Paragraph(text,style=paraStyle))
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   653
        doc = MyDocTemplate(outputfile('test_platypus_paragraphs_just.pdf'))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   654
        doc.build(story)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   655
3564
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   656
    def testAutoPageTemplate(self):
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   657
        from reportlab.platypus import BaseDocTemplate, PageTemplate, Frame, PageBegin
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   658
        from reportlab.lib.units import inch
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   659
        class onPage:
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   660
            def __init__(self,label):
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   661
                self.label = label
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   662
            def __call__(self,canv,doc):
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   663
                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
   664
        class MyDocTemplate(BaseDocTemplate):
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   665
            _invalidInitArgs = ('pageTemplates',)
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   666
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   667
            def __init__(self, filename, **kw):
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   668
                self.allowSplitting = 0
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   669
                BaseDocTemplate.__init__(self, filename, **kw)
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   670
                self.addPageTemplates(
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   671
                        [
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   672
                        PageTemplate('normal',
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   673
                                [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
   674
                                onPage = onPage('normal'),
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   675
                                ),
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   676
                        PageTemplate('auto',
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   677
                                [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
   678
                                onPage = onPage('auto'),
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   679
                                autoNextPageTemplate = 'autoFollow',
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   680
                                ),
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   681
                        PageTemplate('autoFollow',
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   682
                                [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
   683
                                onPage = onPage('autoFollow'),
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   684
                                ),
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   685
                        ])
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   686
        styleSheet = getSampleStyleSheet()
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   687
        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
   688
        story =[]
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   689
        a = story.append
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   690
        a(Paragraph('should be on page template normal', normal))
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   691
        a(NextPageTemplate('auto'))
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   692
        a(PageBreak())
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   693
        a(Paragraph('should be on page template auto', normal))
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   694
        a(PageBreak())
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   695
        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
   696
        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
   697
        a(PageBreak())
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   698
        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
   699
        doc = MyDocTemplate(outputfile('test_platypus_paragraphs_AutoNextPageTemplate.pdf'))
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   700
        doc.build(story)
fd1f9e74eac2 test_platypus_paragraphs.py simple test of PageTemplate.autoNextPageTemplate
rgbecker
parents: 3492
diff changeset
   701
4315
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   702
    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
   703
        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
   704
        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
   705
        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
   706
            _invalidInitArgs = ('pageTemplates',)
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   707
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   708
            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
   709
                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
   710
                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
   711
                self.addPageTemplates(
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   712
                        [
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   713
                        PageTemplate('normal',
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   714
                                [
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   715
                                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
   716
                                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
   717
                                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
   718
                                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
   719
                                ],
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   720
                                ),
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   721
                        ])
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   722
        styleSheet = getSampleStyleSheet()
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   723
        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
   724
        bold = ParagraphStyle(name='bold',fontName='Helvetica-Bold',fontSize=12,leading=14.4,parent=normal)
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   725
        brText="""
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   726
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
   727
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
   728
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
   729
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
   730
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
   731
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
   732
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
   733
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
   734
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
   735
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
   736
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
   737
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
   738
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
   739
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
   740
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
   741
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
   742
<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
   743
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
   744
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
   745
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
   746
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
   747
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
   748
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
   749
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
   750
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
   751
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
   752
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
   753
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
   754
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
   755
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
   756
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
   757
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
   758
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
   759
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
   760
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
   761
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
   762
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
   763
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
   764
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
   765
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
   766
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
   767
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
   768
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
   769
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
   770
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
   771
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
   772
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
   773
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
   774
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
   775
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
   776
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
   777
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
   778
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
   779
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
   780
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
   781
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
   782
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
   783
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
   784
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
   785
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
   786
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
   787
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
   788
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
   789
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
   790
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
   791
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
   792
<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
   793
"""
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   794
        story =[]
7c65c6e52b13 fix paragraph splitting bug (reporters Olivia Zhang & Echo Bell); version-->3.3.31
robin <robin@reportlab.com>
parents: 4291
diff changeset
   795
        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
   796
        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
   797
        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
   798
        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
   799
        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
   800
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   801
#noruntests
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   802
def makeSuite():
3371
24dcc0cb4727 test_platypus_paragraphs: add hard spaces case
rgbecker
parents: 3326
diff changeset
   803
    return makeSuiteForClasses(ParagraphCorners,SplitFrameParagraphTest,FragmentTestCase, ParagraphSplitTestCase, ULTestCase, JustifyTestCase,
24dcc0cb4727 test_platypus_paragraphs: add hard spaces case
rgbecker
parents: 3326
diff changeset
   804
            AutoLeadingTestCase)
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   805
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   806
#noruntests
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   807
if __name__ == "__main__":
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   808
    unittest.TextTestRunner().run(makeSuite())
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   809
    printLocation()