
    Q?hIk                       S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SrSrSrSSKJrJrJrJr   " S	 S
5      rS rS rSSKJr  S rS rS r\4S jrS r " S S5      r " S S5      rSSSSSSSSSS S!S"S#S$.r " S% S&\5      r S' r!SmS) jr" " S* S+\5      r# " S, S-5      r$ " S. S/5      r% " S0 S1\%5      r& " S2 S3\%5      r' " S4 S5\'5      r( " S6 S7\'5      r) " S8 S9\%5      r* " S: S;5      r+S< r,SmS= jr-SnS> jr. " S? S@5      r/\/" 5       r0 " SA SB\/5      r1 " SC SD\15      r2 " SE SF\15      r3SG r4SHr5SIr6SJ r7\1" SK5      r8SLSMSNSOSP\4SQ\
4SRSS/\4" ST5      -   SU\84/-   \4" SV5      -   SW\84SXSP\4SYSQ\
4SRSS/-   \4" SZ5      -   SXSP\4S[S\SRSSSLS]/-   \4" S^5      -   SU\04/-   \4" S_5      -   SW\04S`SaSbScSdSbS`SeSbSfSMSgSXSP\4ShSiSRSS/-   \4" Sj5      -   SfSX/-   r9Sk r:\;Sl:X  a  \:" 5         g(g()oa!  new experimental paragraph implementation

Intended to allow support for paragraphs in paragraphs, hotlinks,
embedded flowables, and underlining.  The main entry point is the
function

def Paragraph(text, style, bulletText=None, frags=None)

Which is intended to be plug compatible with the "usual" platypus
paragraph except that it supports more functionality.

In this implementation you may embed paragraphs inside paragraphs
to create hierarchically organized documents.

This implementation adds the following paragraph-like tags (which
support the same attributes as paragraphs, for font specification, etc).

- Unnumberred lists (ala html)::

    <ul>
        <li>first one</li>
        <li>second one</li>
    </ul>


Also <ul type="disc"> (default) or <ul type="circle">, <ul type="square">.

- Numberred lists (ala html)::

    <ol>
        <li>first one</li>
        <li>second one</li>
    </ol>

Also <ul type="1"> (default) or <ul type="a">, <ul type="A">.

- Display lists (ala HTML):

For example

<dl bulletFontName="Helvetica-BoldOblique" spaceBefore="10" spaceAfter="10">
<dt>frogs</dt> <dd>Little green slimy things. Delicious with <b>garlic</b></dd>
<dt>kittens</dt> <dd>cute, furry, not edible</dd>
<dt>bunnies</dt> <dd>cute, furry,. Delicious with <b>garlic</b></dd>
</dl>

ALSO the following additional internal paragraph markup tags are supported

<u>underlined text</u>

<a href="http://www.reportlab.com">hyperlinked text</a>
<a href="http://www.reportlab.com" color="blue">hyperlinked text</a>

<link destination="end" >Go to the end (go to document internal destination)</link>
<link destination="start" color="cyan">Go to the beginning</link>

<setLink destination="start" color="magenta">This is the document start
  (define document destination inside paragraph, color is optional)</setLink>

    stringWidth)fp_str)Flowablecolors)_baseFontNamegh㈵>)TA_LEFT	TA_CENTERTA_RIGHT
TA_JUSTIFYc                   t    \ rS rSrSS jrSrS rS rSS jrS r	S	 r
S
 rS rS rS rS rS rS rS rSrg)paragraphEngineU   Nc                     SSK Jn  Uc  / n/ U l        Xl        S=U l        U l        SU l        SU l        SU l        SU l	        X l
        S=U l        =U l        U l        SSKJn  X0l        / U l        g )Nr   black        	Helvetica
      )r
   )reportlab.lib.colorsr   lineOpHandlersprogramindentrightIndent
baseindentfontNamefontSizeleading	fontColorxyrisereportlab.lib.enumsr
   	alignmenttextStateStack)selfr   r   r
   s       I/var/www/html/env/lib/python3.13/site-packages/reportlab/platypus/para.py__init__paragraphEngine.__init__W   sq    .?G ),,d&#&)))$)/      )	r   r   r   r   r    r!   r   r$   r&   c                     / nU R                    H  n[        X5      nUR                  U5        M!     U R                  U/-   U l        U$ N)TEXT_STATE_VARIABLESgetattrappendr'   r(   statevarvals       r)   pushTextStateparagraphEngine.pushTextStatem   sK    ,,C$$CLL - #115'9 r,   c                     U R                   S   nU R                   S S U l         US S  nU R                   H  nUS   nUS	 [        XU5        M     g )Nr   )r'   r/   setattrr2   s       r)   popTextStateparagraphEngine.popTextStatex   s\    ##B'"11#26a ,,C(CaDs# -r,   c                    U R                   R                  5       nUSS n/ nUnU(       a  X@l        Sn	Sn
U(       Gaj  U	(       Gab  U R                  nU R                  nX-
  U-
  nU R                   R                  5       nU[
        :  a+  [        SU R                  < SU R                  < SU< 35      e U R                  Xa5      u  nnnnnnnU
U-   n
U R                  nX:  a  X-
  nOSn	U R                   R                  U5        GOU R                  nUUS nU(       d  US	 U[        :X  a'  U(       a  [        UU5      nOU R                  U5      nGOU[        :X  a9  U(       a  [        UU5      nOU R                  U5      nU R                  UUU5      nOU[        :X  a9  U(       a  [        UU5      nOU R                  U5      nU R!                  UUU5      nOU["        :X  as  U(       a0  U(       a)  U(       a  [%        UUU5      nOgU R'                  UUU5      nOSU(       a  [        UU5      nOU R                  U5      n[(        (       a  [+        S5        O[        S	[-        U5      -   5      eU(       d  U R/                  U5      nUR1                  U5        U(       a
  U	(       a  GMb  U R                   R                  5       nU R                   R                  U5        X(-
  nXvUU4$ !   e = f)
zCreturn program with line operations added if at least one line fitsN   r   zindents  z too wide for space r9   z2no justify because line is not full or end of parazbad alignment )__dict__copyr    r   r   TOOSMALLSPACE
ValueErrorfitLineupdater&   r
   
stringLine
shrinkWrapr   centerAlignr   
rightAlignr   simpleJustifyAlignjustifyAligndebugprintreprcleanProgramextend)r(   maxwidth	maxheightr   r    
startstate	remainderlineprogramheightremainingroomcursorcountr   r   	linewidthbeforelinestate
lineIsFulllinecursorcurrentLength
usedIndent	maxLengthjustStringsr&   	laststate
heightuseds                            r)   formatparagraphEngine.format   s    ]]'')
AJ	 $7LD [[F**K )K7I"mm002O& $++W[WgWgKS"U V V7;||I7X5T6=Y &f,KllG&"1"9$$_5 I "&'*IH '! %dM:D??40DI% %dM:D??40D''mYGH$ %dM:D??40Dt]IFJ& "1$yQ#00}iP")$>#t4uRS !1$y/!ABB((.t$s DDt MM&&(	Z(0
	:>>c s   4K% %K(c                 6    U R                   R                  5       $ r.   )r@   rA   r(   s    r)   getStateparagraphEngine.getState   s    }}!!##r,   c                 :    U R                   R                  U5        g r.   )r@   rE   )r(   r3   s     r)   
resetStateparagraphEngine.resetState   s    U#r,   c                    SSK Jn  U R                  nX$-
  U R                  -
  nSn/ nSnSn	Sn
[	        U5      nSnSnSnU R
                  nU R                  nU" SUU5      nSnU(       Gd  X:  Ga  X   n[        U[        5      (       d  [        US5      (       a  UnSn[        US5      (       a  SnUR                  U 5      nSnOFUnUR                  5       nU(       a  U" UUU5      nOSnU(       a  U(       d  U
(       a	  US   S:H  nOSnUnU(       a  UU-   nU
U-   nUU:  a  U(       d  SnSn	OWU(       a  UR                  U5        U(       a  UR                  U5        [        U5      [        :  a  UR                  U* 5        Un
SnGO[        U[        5      (       aM  Sn[        U5      nU[        :  a4  U
U-   nUU:  a
  U(       d  SnOU[        :  a  Un
UR                  U5        SnGOC[        U[         5      (       Ga  SnUS   nUS:X  a  UR                  U5        US-  nS=pGOUS	:X  aZ  U R"                  nUu  nn[        U[        5      (       a  [%        [&        U5      =nU l        O	U=nU l        UR                  U5        GOUS
:X  a*  Uu  nn U =ol        U" SUU5      nUR                  U5        GOuUS:X  a  Uu  nn![        [        U!5      5      n"[        U![        5      (       aJ  U!SS S:X  a  U R                  U"-   =nU l        O3U!SS S:X  a  U R                  U"-
  =nU l        OU"=nU l        O	U"=nU l        U" SUU5      nUR                  U5        GOUS:X  a  Uu  nn#U#U l        UR                  U5        GOUS:X  aR  Uu  nn$U R                  U$-   =n%U l        U(       a  [+        U%U5      nX$-
  U R                  -
  nUR                  U5        GOTUS:X  a#  U R-                  5         UR                  U5        GO+US:X  aF   U R/                  5         U R
                  nU R                  nU" SUU5      nUR                  U5        GOUS:X  a  Uu  nn&n%n'n"U%U R0                  -   n%UU&U%U'U"4nU(       d  [3        S5      e[        U" U&U'U"5      5      n([        U" SU'U"5      5      nU%U-   U(-   n)[+        U)U5      nU(       a  X$-
  U R                  -
  nUR                  U5        GODUS:X  aC  Uu  nn$U R                  U$-   U l        U(       a  X$-
  U R                  -
  nUR                  U5        OUS:X  a-  Uu  nn*U R4                  U*-   =n+U l        UR                  U5        OUS:X  a  Uu  nn,U,U l        UR                  U5        OUS:X  a,  Uu  nn-UR                  U5        U R8                  U-/-   U l        OrUS:X  a>  Uu  nn-U R8                  SS n.U.R;                  U-5        U.U l        UR                  U5        O.[3        S[=        U5      -   5      e[3        S[=        U5      -   5      eU(       d  US-  nU(       d  X:  a  GM  U(       d  UR                  S5        XXXEU4$ !   e = f)z(fit words (and other things) onto a liner   r   r>   Nr?   widthr9   nextLinecolorfacesize+-r    r   pushpopbulletbullet not at beginning of liner   r$   alignlineOperationendLineOperationz*at format time don't understand indicator z-op must be string, float, instance, or tuple ro   r   )reportlab.pdfbase.pdfmetricsr   r   r   lenr   r   
isinstancestrhasattrrn   stripr1   absrB   floattupler!   r0   r   r    maxr6   r;   r   rC   r$   r&   r   removerN   )/r(   r   totalLengthr   r_   r`   doner\   r]   r[   r^   	maxcursor	needspacefirst
terminatedr   r   
spacewidthra   opcodelastneedspacern   
saveopcode	fullwidth	newlengthaopcode
nextLength	indicatoroldcolori	colornamerp   fontnamefontsizerr   r    	incrementr   rw   fontbulletwidth	bulletminr$   newriser&   handlerhs/                                                  r)   rD   paragraphEngine.fitLine   sd    	=[[
,t/?/??	
L		
==== h9
6+_F&%%)@)@ )	6'**"#K"LL.E !I!'J#\\^F +FHh G !!u%/^S%8	$%	!	  %
 2I))3	Y&u
 D!"J %Z1V-5z-/eV-(1 F5))f+=(!.w!6J!)+E "=0,6M KK/EF5))"1I	j( KK'aKF())J '#~~H%+NQ	!)C00181KK1::KK'&$*MQ/77H}!,S(H!EJKK'&$*MQuX/D!(3//#BQ<,7;}}t7KKHt}%bq\3.7;}}t7KKHt}7;;Ht}3774=!,S(H!EJKK'	)#)LQ#*DLKK'(%+NQ	+/;;+BBFT[%(%<
$/$<t?O?O$O	KK'&&&(KK'%))+  $}}H#}}H!,S(H!EJKK'(6<3Qd#doo5Ft<F ()JKK"'FD$(G"HK!&{3d'C!DJ &z 1+ =I!$Y
!;J$/$<t?O?O$O	KK'-%+NQ	'+'7'7	'AD$$/$<t?O?O$O	KK'& &IQ*.))D.8GdiKK''%+NQ	 &/DNKK'/#)LQKK'*.*=*=	*ID' 22#)LQ++A.AHHW%*+D'KK' %%QRVW`Ra%abb !PQUV\Q]!]^^!i 6+v KK*&P[\\K s   Y* *Y-c                 N    X2-
  nUS-  nU[         :  a  U R                  X5      $ U$ )N       @rB   insertShift)r(   r\   
lineLengthr`   diffshifts         r)   rH   paragraphEngine.centerAlign  s1    #S##D00r,   c                 D    X2-
  nU[         :  a  U R                  X5      $ U$ r.   r   )r(   r\   r   r`   r   s        r)   rI   paragraphEngine.rightAlign  s(    $##D00r,   c                     / nSnU HT  nU(       a9  [        U[        5      (       d  [        US5      (       a  UR                  U5        SnUR                  U5        MV     U$ )Nr>   rn   r   )r   r   r   r1   )r(   r\   r   resultr   es         r)   r   paragraphEngine.insertShift  sU    A*Qs++wq/A/Ae$MM!	 
 r,   c                 b   X2-
  nSnSnSnU He  n[        U[        5      (       a  U[        :  a  U(       a  US-  nM0  U(       d  M9  [        U[        5      (       d  [	        US5      (       d  Ma  SnSnMg     US:  a  U$ U[        U5      -  n	U	[        ::  a  U$ SnSn/ n
Sn[        U5      nX:  a  X   nU
R                  U5        U(       a)  [        U[        5      (       d  [	        US5      (       a  SnO.[        U[        5      (       a  U[        :  a  U(       a  X-   nXS'   US-  nX:  a  M  U
$ )Nr   r>   rn   r9   )r   r   rB   r   r   r~   r1   )r(   r\   r   r`   r   
spacecountvisibler   r   r   r   r]   nlineexpandeds                 r)   rK   paragraphEngine.justifyAlign  s!   #
A!E""q7a
Jq--71C1C  a<KU:&&-KD	lAMM!*Qs++wq/A/AAe$$=W7%r
aKF l r,   c                    / nSn[        U5      nX4:  Ga>  X   n[        U[        5      (       Ga  X4S-
  :  a  U/nSnUS-  nX   nX4:  a  [        U[        [        45      (       a  [        U[        5      (       a#  US:  a	  US:  a  U* nUS:  a	  US:  a  U* nXx-  nO&[        U[        5      (       a  UR	                  U5        US-  nX4:  a  X   nX4:  a  [        U[        [        45      (       a  M  SR                  U5      n	UR	                  U	5        UR	                  [        U5      5        US-  nOUR	                  U5        US-  nX4:  a  GM>  U$ )Nr   r>   r   r?   )r~   r   r   r   r1   join)
r(   r\   r   indexmaxindexr   
thestrings	thefloatsnextess
             r)   rG   paragraphEngine.shrinkWrap*  sE   t9nA!C  UA:%5S
	
nE5+)F)F!%..$Q;57)2
I 7y{%*FE!*	#E#.."))%0QJE~ $ nE5+)F)F HHZ(a eI./
a QJE; n> r,   c                 p   / nSnU H}  n[        U[        5      (       a.  US:  a	  US:  a  U* nUS:  a	  US:  a  U* n[        U5      U-   nMF  [        U5      [        :  a  UR	                  U5        UR	                  U5        SnM     U(       a  UR	                  U5        Sn[        [        [        U5      S-
  5      5      nU(       a  SnU H  nUS-   nX'   n	X(   n
Sn[        U	[        5      (       d7  [        U
[        5      (       d"  [        U	S5      (       d  [        U
S5      (       a  SnOh[        U	[        5      (       aS  U	S   n[        U
[        5      (       a  U
S   nSnUS:X  a  US:w  a  US:w  a  SnO[        U
[        5      (       a  US:X  a  SnU(       d  M  XU'   XU'   SnM     U(       a  M  U$ )zcollapse adjacent spacingsr   r>   rn   r{   rz   )r   r   r   rB   r1   listranger~   r   r   r   )r(   r\   r   lastr   changerliner   	nextindexthisnextdoswapthisindicatornextindicators                 r)   rO   paragraphEngine.cleanProgramP  s    A!E""6ac 5DQ346AT{1}t9]*MM$'a   MM$ U3v;q=)*F!!G	}(d3''d3''4((GD,A,AFU++$(GM!$u--(,Q!")+==-QcBc - >%&F#D//(/9%&F6$(5M(,9%F5  f< r,   c           	         UR                   nUR                  nU R                  R                  5       nSnSnUR	                  U R
                  5        U R                  n	U R                  n
U R                  nSnU GH  n[        U[        5      (       d  [        US5      (       Ga  U(       d  [        U
5      [        :  a3  UR                  S[        U
S5      -  5        U =R                  U
-  sl        U R                    H+  nUR#                  U R                  U R$                  XU5        M-     SnXpR&                  :w  d  XR(                  :w  a)  U R&                  nU R(                  nUR+                  Xx5        [        U[        5      (       a  UR-                  U5        GM%  UR/                  XU5        GM:  [        U[0        5      (       aN  [        U5      nU[        :  a6  UR                  S[        US5      -  5        U =R                  U-  sl        GM  GM  [        U[2        5      (       Ga  US   nUS:X  a  Uu  nnU R                  nU R$                  nU R$                  U R4                  -
  =nU l        U	=nU l        U R                  n
U R                  nSnU R                    H  nUR7                  UUXU5        M     UR9                  UU5        GMZ  US:X  ad  U R
                  nUu  nn[        U[        5      (       a  [;        [<        U5      =nU l        O	U=nU l        UU:w  a  UR	                  U5        GM  GM  US:X  a  Uu  nnUU l        GM  US	:X  a  Uu  nn[        [1        U5      5      n[        U[        5      (       aE  USS S
:X  a  U =R(                  U-  sl        O,USS S:X  a  U =R(                  U-  sl        OXl        OXl        U R(                  nUR+                  U R&                  U R(                  5        GM  US:X  a  Uu  nnUU l        GM  US:X  a*  Uu  nnU R                  U-   =nU l        [?        U
U5      n
GM  US:X  a  U RA                  5         GM  US:X  ae  U R
                  nU R&                  nU R(                  n U RC                  5         UU R
                  :w  a  UR	                  U R
                  5        GMS  GMV  US:X  a  Uu  nn!URE                  U!5        GMu  US:X  a  Uu  nn"npx[        U R                  U	-
  5      [        :  a  [G        S5      e[1        [I        U"Xx5      5      n#[1        [I        SXx5      5      n$UU$-   U#-   n%U%U
:  a  U%n
URK                  US5        UR+                  Xx5        UR-                  U"5        URK                  U* S5        UR+                  U R&                  U R(                  5        GMW  US:X  a  Uu  nnU R                  U-   U l        GMy  US:X  a/  Uu  nn&U RL                  U&-   =n'U l&        URO                  U'5        GM  US:X  a  Uu  nn(U(U l(        GM  US:X  aE  Uu  nnUR#                  U R                  U R$                  XU5        U R                   U/-   U l        GM  US:X  aj  Uu  nnUR7                  U R                  U R$                  XU5        U R                   SS =n)U l        UU);   a  U R                   RS                  U5        GM{  GM~  [G        S[U        U5      -   5      e[G        S[U        U5      -   5      e   U R                  R                  5       n*U R                  RW                  U5        U*$ )zrender the line(s)Nr   rn   z%s Tdr>   ro   rp   rq   rr   rs   rt   r    r   ru   rv   wordSpacingrw   rx   r?   r   r$   ry   rz   r{   zdon't understand indicator z!op must be string float or tuple ),_escape_coder@   rA   setFillColorr!   r"   r   r   r   r   r   r   rB   r1   r   r   start_atr#   r   r   setFonttextOutexecuter   r   r    end_atsetTextOriginr0   r   r   r6   r;   setWordSpacerC   r   
moveCursorr$   setRiser&   r   rN   rE   )+r(   r   canvas
textobjectescapecoderS   r   rr   xstartthislineindentthislinerightIndentindentedr   r   r   r   endallmarksr"   r#   newynewxr   r   rp   r   r   r   r    r   r   oldfontoldsizewsrw   r   r   r   r$   r   r&   newhrb   s+                                              r)   
runOpCodesparagraphEngine.runOpCodes  se    ]]'')
 	/"..F&%%'&*A*A>*=8 Gf^Q.G$GH.0#'#6#6((zR $7 &$*===D==D&&t2fS))&&v. NN4V<F5))V-'KK&*; ;<FFf$FF ( F5))"1I	j('-$QAA$(FF4<<$77D46$**D46%)[[N*.*:*:' H#'#6#6q!T:F $7 ,,T48'#~~H%+NQ	!)C00181KK1:: h"//6 '&$*MQ$,DM&$*MQuX/D!(3//#BQ<, MMT1M%bq\3. MMT1M,0M(,#}}H&&t}}dmmD	)#)LQ#*DL(%+NQ	+/;;+BBFT[%(%@N&&&(%#~~H"mmG"mmG%%'  /"//? 0-$GQ++B/(6<3Q466&=)-7()JKK"'FD(G"HK!&{3'C!DJ &z 1+ =I >1)2))&!4&&t2&&v.))6'15&&t}}dmmD-%+NQ	'+'7'7	'AD$& &IQ*.))D.8Gdi&&w/'%+NQ	%.DN/#)LQ$$TVVTVVT:N +/*=*=	*ID' 22#)LQNN4664664L151D1DQ1GGD4.$++227; %%B4	?%RSS !DT&\!QRRq r MM&&(	Z(r,   )r&   r   r!   r   r   r   r    r   r   r   r$   r'   r"   r#   r.   )r   )__name__
__module____qualname____firstlineno__r*   r/   r6   r;   rd   rh   rk   rD   rH   rI   r   rK   rG   rO   r   __static_attributes__ r,   r)   r   r   U   sY    !")
	
$l?\$$R]h	!~$L?Bkr,   r   c                     / nU  H+  n[        U[        5      (       d  M  UR                  U5        M-     SR                  U5      nU[	        U5      /nSnU (       a  U S   U:X  a  UR                  U5        U$ )zEsimple case: line with just strings and spacings which can be ignoredr?   r|   r9   )r   r   r1   r   r   )r\   lengthstringsr"   textr   nextlinemarks          r)   rF   rF   >  sn     GaNN1  88GDE&M"F"LR,&|%Mr,   c                 J   / nU SS  H+  n[        U[        5      (       d  M  UR                  U5        M-     [        U5      S-
  nX!-
  nSR	                  U5      nUS:  a  US:  a  U[        U5      -  nSU4XrS/n	OXqS/n	Sn
U (       a  U S   U
:X  a  U	R                  U
5        U	$ )	z&simple justification with only stringsNr9   r>   r?   r   r   )r   r   r|   )r   r   r1   r~   r   r   )r\   r^   r`   r   r"   nspacesslackr   wordspacingr   r   s              r)   rJ   rJ   L  s     G#2YaNN1  'l1nG#E88GDqyU1WE'N* +.AST7"LR,&|%Mr,   r   c                 r    U R                  5       S;   a  gU R                  5       S;   a  g[        SU -  5      e)N)YYESTRUE1r>   )NNOFALSE0r   z+true/false attribute has illegal value '%s')upperrC   )r   s    r)   readBoolr  b  s7    zz|00	2	2FMNNr,   c                     U R                  5       nUS:X  a  [        $ US:X  a  [        $ US;   a  [        $ US:X  a  [        $ g )NLEFTRIGHT)CENTERCENTREJUSTIFY)r  r
   r   r   r   )r   ups     r)   readAlignmentr  j  sF    	B	V|	w	#	#	y 
r,   c                 V   U R                  5       n  [        U 5      $ ! [         a    U R                  5       n U SS U SS p!UR                  5       n [        U5      nO! [         a    [        SU -  5      ef = f SSSSS.U   nO! [         a    [        SU -  5      ef = fX4-  s $ f = f)	zERead a dimension measurement: accept "3in", "5cm",
"72 pt" and so on.Nzinvalid length attribute '%s'H   g^|bX<@gjZ@r>   )incmmmpt)r   r   rC   lowerKeyError)r   
numberTextunitsnumber
multipliers        r)   
readLengthr  u  s     ::<D#T{ #zz| "Id23iE%%'
	E:&F 	E<tCDD	E	E""	
 J  	E<tCDD	E ""%#s?   
 3B(AB(A66B(:
BB(BB('B(c                     U R                  5       n U SS S:X  a  U SS S:X  a  U SS n U R                  S5      nU V s/ s H  o R                  5       PM     nn U V s/ s H
  o" U 5      PM     nn U$ s  sn f s  sn f )z0from "(2, 1)" or "2,1" return [2,1], for exampleNr>   (r9   ),)r   split)r   	convertersls      r)   lengthSequencer$    s{    		A!uczafckaG	
B	 R'')RB	  "	#1)A,B	#I 
!	#s   A1A6c                    U (       d  gSSK Jn  SSKJn  U S   U;   a  UR                  U    $ [        U 5      nSnS[        U5      s=::  a  S::  d   U5       e   U5       eSn[        [        U5      5       H  nX5   S	::  a  M   U5       e   [        U5      S:X  a  UR                  nO[        U5      S:X  a  UR                  nW" U6 $ )
zCRead color names or tuples, RGB or CMYK, and return a Color object.Nr   r   )lettersz:Color tuple must have 3 (or 4) elements for RGB (or CMYC).      z*Color tuple must have all elements <= 1.0.      ?)
reportlab.libr   stringr&  r@   r$  r~   r   Color	CMYKColor)r   r   r&  tupmsgr   colClasss          r)   	readColorr1    s    $Aw't$$

C
FCCA"s""s"
6C3s8_v}!c!}  3x1}<<	SQ##S>r,   c                   \    \ rS rSr\/r\/r\/r\/r\/r	\
/r\/r\/r\/r\/r\/r\/rSrg)StyleAttributeConvertersi  r   N)r   r   r   r   r  r   r    
leftIndentr   firstLineIndentr  r&   spaceBefore
spaceAfterbulletFontSizebulletIndentr1  	textColor	backColorr   r   r,   r)   r3  r3    sV    \HLG|JKLOoIK|J<NLkIkIr,   r3  c                   d    \ rS rSrSrSr\rSrSr	Sr
SrSr\rSrSr\rSrSr\rSrSS jrS	 rS
rg)SimpleStylei  z6simplified paragraph style without all the fancy stuffbasicr   r   r   Nc                     U R                   nU(       a'  UR                   R                  5        H	  u  pVXdU'   M     UR                  5        H	  u  pVXdU'   M     g r.   )r@   items)r(   nameparentkwmydictabs          r)   r*   SimpleStyle.__init__  sG    ,,.q	 /88:CA1I r,   c                     UR                  5        HH  nX   nUc  M  [        [        U5      (       a  [        [        U5      S   nU" U5      n[	        XU5        MJ     g Nr   )keysr   r3  r0   r:   )r(   
dictionarykeyvaluer"  s        r)   addAttributesSimpleStyle.addAttributes  sT    ??$COE 3S99 '(@# Fq II%e,E5) %r,   r   r.   )r   r   r   r   __doc__rA  r	   r   r   r    r4  r   r5  r
   r&   r6  r7  bulletFontNamer8  r9  r   r:  r;  r*   rN  r   r   r,   r)   r=  r=    sZ    <DHHGJKOIKJ NNLII*r,   r=  Heading1Heading2Heading3Heading4Heading5Heading6TitleSubTitleNormalCodeUnorderedListOrderedList
Definition)zh1.defaultStylezh2.defaultStylezh3.defaultStylezh4.defaultStylezh5.defaultStylezh6.defaultStyleztitle.defaultStylezsubtitle.defaultStylepara.defaultStylezpre.defaultStylezul.defaultStylezol.defaultStyleli.defaultStylec                   <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)FastParai  zAparagraph with no special features (not even a single ampersand!)c                 L    SU;   a  [        S5      eXl        X l        S U l        g )N&zno ampersands please!)rC   style
simpletextlines)r(   re  rf  s      r)   r*   FastPara.__init__  s)     *455
$
r,   c                 >   U R                   nXl        U R                  nU R                   nUR                  nUR                  nUR
                  nUR                  n	UR                  n
UR                  nUR                  5       n/ nSSK
Jn  U" SX5      n/ nSnX-
  U-
  nX-
  U-
  nUU:  a	  X-   U-   U4$ X(:  a  X4$ U R                  Gc%  SnSn[        U5      nSnUU:  a  U(       d  UnU(       d  UnUU   nU" UX5      nU(       a  UU-   nUU-   nU(       a  UU:  a  US-  nUnUR                  U5        O@UR                  SR                  U5      U[        U5      45        / nSnUU-   nUU-   U:  a  SnUU:  a	  U(       d  M  U(       a8  U(       d1  UR                  SR                  U5      U[        U5      45        UU-   nXl        UU l        SR                  UUS  5      =nU l        OS nU R                   nU R                  nU(       a  XU-   4nU$ UU4nU$ )Nr   r   r?   r>   )rf  availableWidthre  r   r4  r    r   r   r5  r!  r}   r   rg  r~   r1   r   heightrT   )r(   rj  availableHeightrf  re  r   r   r4  r    r   rr   firstindentwordsrg  r   r   currentlinecurrentlengthfirstmaxlength	maxlengthrc   r]   nwordsr   thismaxlengththiswordthiswordsize
nextlengthrT   r   s                                 r)   wrapFastPara.wrap  sI   __
,

''%%
--~~~~++  "< d1
'5C"0:=	Z*;6HH"",,::JFZFD- )$2M =*8T@ #/
#:L*\9
$
9(<aKF$.M&&x0 LL388K#8-[IY"Z\"$K$%M!+G!3J!')/9 - -. Tsxx4mSEUWX'/
J$DK),%.)AAI IJJJE$g&=>F  %j1Fr,   c                     U R                   nUR                  nX$:  a  / $ U R                  nUc  [        S5      eU R                  nU(       a  [        X65      nX/$ U /$ )Nzmust wrap before split)re  r    rg  rC   rT   rb  )r(   rj  rl  re  r    rg  rT   r   s           r)   r!  FastPara.splitF  s^    

--"I

=566NN	E-D;6Mr,   c                    U R                   nU R                  nUR                  nUR                  nUR                  nUR
                  nUR                  nUR                  nUR                  n	U R                  n
U
R                  nU R                  nU
R                  SX-
  5        U
R                  5       nUR                  nUR                  Xg5        UR                   (       a  UR#                  UR                   5        SnSnU R$                  U-
  nSn['        U5      nUU:  a  UU   u  nnnUS-  nUnU(       a  U	nU[(        :X  a  UnOqU[*        :X  a  UU-
  nUUS-  -   nOYU[,        :X  a  UU-
  nUU-   nODU[.        :X  a:  UnUU:  a!  US:  a  UR1                  UU-
  US-
  -  5        OUR1                  S5        UR3                  WU5        UR5                  U5        UU-
  nUU:  a  M  U
R7                  U5        g )Nr   r>   r   r)  r   )re  rg  r   r4  r    r   r   r&   r5  canvr   rk  	translate	beginTextr   r   r:  r   rj  r~   r
   r   r   r   r   r   r   drawText)r(   re  rg  r   r4  r    r   rr   r&   rm  cr   rk  r   r   r   r#   
basicWidthcountnlinesr   r   rs  
thisindentr"   extras                             r)   drawFastPara.drawU  s   



''%%
--~~~~OO	++II  	
Av{#[[]
4&??##EOO4((;6
UFl%*5\"T66QJE#J(
'!I%"V+s*H$"V+&J&<F1H++Z->,LM++C0$$Qq)t$'	A/ Fl0 	


:r,   c                 .    U R                   R                  $ r.   )re  r6  rg   s    r)   getSpaceBeforeFastPara.getSpaceBefore  s     zz%%%r,   c                 .    U R                   R                  $ r.   )re  r7  rg   s    r)   getSpaceAfterFastPara.getSpaceAfter  s    zz$$$r,   )rj  rk  rg  rT   rf  re  N)r   r   r   r   rP  r*   rx  r!  r  r  r  r   r   r,   r)   rb  rb    s&    GFP5n&
%r,   rb  c                  j    0 n SSK Jn  U" 5       n[        R                  5        H  u  p4X$   X'   M     U $ Nr   )getSampleStyleSheetreportlab.lib.stylesr  DEFAULT_ALIASESr@  )r   r  stylesstylenamekeystylenamevalues        r)   defaultContextr    s9    F8 "F(7(=(=(?$%5 )@Mr,   Nc                 4   0 nSSK Jn  U bT  [        R                  5        H  u  p4X0;   d  M  X   X'   M     [        R                  5        H  u  p4X@;   d  M  X   X'   M     U" 5       n[        R                  5        H  u  p4X1;  d  M  XE;   d  M  XT   X'   M     U$ r  r  )
stylesheetr   r  r  r  r  s         r)   buildContextr    s    F8,;,A,A,C(L)'1'?$ -D -<,A,A,C(L+'1'A$ -D !"F(7(=(=(?$%.*B#)#9F  )@ Mr,   c                      \ rS rSrSrSrS(S jrS rS rS r	S r
S	 rS)S
 jrS*S jrS rS+S jrS rS rS rS rS rS rS,S jrS rS rS rS rS rS rS rS rS rS r S r!S  r"S! r#S" r$S# r%S$ r&S% r'S-S& jr(S'r)g).Parai  r   Nc                 <   X`l         [        U5      U l        X l        X0l        Xl        / U l        / U l        S U l        X@l	        U(       d"  UR                  U l
        UR                  U l        SU l        SU l        UR                  U l        UR                   U l        g rI  )r   r  context
parsedText
bulletTextstyle1r   formattedProgramrT   r3   r6  r7  bolditalicr   rq   r   rr   )r(   re  r  r  r3   r  r   s          r)   r*   Para.__init__  s    $#G,$$ "
$00D#..DO 	NN	NN	r,   c                     U R                   $ r.   )r6  rg   s    r)   r  Para.getSpaceBefore  s     r,   c                     U R                   $ r.   )r7  rg   s    r)   r  Para.getSpaceAfter  s    r,   c                    [         (       aB  [        S[        U 5      X5        [        SU R                  5        [        SU R                  5        X l        [        5       =U l        nU R                  Ul        U R                  nU R                  nU R                  nU(       a  US   nOU R                  R                  nU R                  nSU l        U(       a%  UR                  U5        SUl        SUl        US   n	OU R                  R                  n	X)::  a  SU l        US-   U4$ Uc  Uc  [#        S5      eU(       d  U R%                  U5      =U l        nU R                  (       d.  UR'                  XX5      u  pZpXPl        Xl        Xl        Xl        OU R(                  nS n
U
(       a^  US-   n[/        U R                  S S WU R0                  S9U l        XR2                  l        U R4                  U R2                  l        SU l        OS U l        UnX:  a  US-
  nX4n[         (       a=  Uu  nn[7        UU-
  5      S	:  a  [        S
[9        UU5      -   5        [        SX4U5        U$ )NWRAPPINGz   r    r>   r   zneed parsedText for formattingr  r  r3   r  g?g?zexact match???zwrap is)rL   rM   idr  r   rl  r   myenginer   r  r3   r  r    cansplitrk   r"   r#   rC   compileProgramrd   rk  rb   remainderProgramr  r  rT   r7  r   rN   )r(   rj  rl  pr  r  r3   r    r   needatleastrT   rb   rc   rk  r   wr   s                    r)   rx  	Para.wrap  s,   5*bhH%../%&.+--__
00

I&Gkk))G,,LLACAC	*K++--K'DM $A%~66'/=>>%)%8%8%DDDL7$$&'hh~PW&a$$4!$K&N$-!JI
 %q(F "$++$4(14<<IDN%.NN"(,DNN%DO!DNF%(, !)5FQ?1$%c)&oq)AAB)n>Gr,   c                     US::  d  U R                   (       d  / $ X l        U R                  nUc  [        S5      eU(       d  / $ U R                  nU(       a  X/nU$ U /nU$ )Nr   zmust call wrap before split)r  rl  r  rC   rT   )r(   rj  rl  r  rT   r   s         r)   r!  
Para.split  sn     AT]] I.00#:;;!INN	%F  FFr,   c                 f   U R                   nU R                  nUc  [        S5      eU R                  nU R                  nU(       a  UR                  U5        SUl        SUl        U R                  nU R                  nU(       a  US   nOU R                  R                  nUR                  SX`R                  -
  5        UR                  5       n[        (       d  [         (       a+  [#        SS5        U H  n	[#        U	5        M     [#        S5        UR%                  X%U5      nUR'                  U5        g )Nzmust call wrap before drawr   r    z,============================================znow running programz,--------------------------------------------)r  r  rC   r3   rb   rk   r"   r#   r}  rk  r  r    r~  rr   r  DUMPPROGRAMrL   rM   r   r  )
r(   r  r  r3   rb   r  rk  r    tr"   s
             r)   r  	Para.draw6  s    MM00#9::

NN	LLACACII I&Gkk))G 	
Avii'(KKM;%%&/0%a &&MLL!1a8		

1r,   c                 x   U R                   nUc  / nUR                  nUR                  nU" SU45        SSKJn  U" U5      u  U l        U l        U l        U" SUR                  45        UR                  U l	        U" SUR                  45        U" SUR                  45        UR                  (       a  U" SUR                  45        U" SUR                  45        U" SUR                  45        UR                  (       a  U" S	UR                  45        U R                   (       a  U R#                  U R                   U5        U R%                  X5        UR                  (       aW  SnU H0  nUS
-  n['        U[(        5      (       d  [+        US5      (       d  M0    O   UR-                  USUR                  * 45        U$ )Nrq   r   )ps2ttrr   ry   r   r   r    rp   r>   rn   )r  r1   r   reportlab.lib.fontsr  rq   r  r  r   rr   r&   r4  r5  r   r    r:  r  	do_bulletcompileComponentr   r   r   insert)	r(   r  r   re  rE  fnr  r  r"   s	            r)   r  Para.compileProgramW  so    ?GNN^^	FB=-.3Bi+DIt{	FENN$&NN		GU__&(	He&&(*  %//13	M5,,.0	Iu}}%'??)+??NN4??G4j2  E
a$$'(:(:  NNEHu/D/D.D#FH. r,   c                 `   Uc  U R                   nU R                  nUc  / nUR                  S5        UR                  (       a+  UR                  SUR                  UR                  -   45        OUR                  SUR                  45        UR                  S5        U R                  X!S9nUR                  S5        UR                  S5        UR                  (       a  UR                  SUR                  45        OUR                  S5        UR                  S5        UR                  S5        g )Nru   r    r|   r   rv   )r    r   )r  r  r1   r6  r    r  r7  )r(   r   r  re  s       r)   	linearizePara.linearize  s     J?G	#NNY(9(9%--(GHJNNY68)%%j%B"	#NNY(8(89;NNN,)"r,   c                    [        U[        5      (       a>  U(       a6  UR                  5       nU(       d  UR                  S5        g [	        XU5        g g [        U[
        5      (       a  U H  nU R                  XB5        M     g [        U[        5      (       a  Uu  pVpxU(       d  0 nSU-   n	[        X	S 5      n
U
b
  U
" XgX5        g [        (       a  SU-   /nUR                  nU(       d  0 nUR                  5        H  u  pU" SU< SU< 35        M     U(       a%  U" S5        U" [        U5      5        U" SU-  5        OU" S5        SR                  U5      n[	        XU5        g [        S	[        U5      -   5      eg )
Nr?   compile_<=>z</%s>z/> zdon't know how to handle tag )r   r   r   r1   handleSpecialCharactersr   r  r   r0   rL   r@  r   rC   rN   )r(   r  r   stextr   tagnameattdictcontentr  compilernamecompilerLrE  kvr  s                   r)   r  Para.compileComponent  sH   j%% "((*NN3'+DgF  
4((%%a1  
5))1;.Ww%g-Lt48H#5: 5-)AA"bG 'a*+ !0##g,'G+,$
A+DW=$%DtG}%TUU3 *r,   c                     U R                   nU R                  nU R                  nXVU4nUc  UnUc  UnUc  UnX l         X0l        X@l        SSKJn	  U	" X#U5      n
U	" XVU5      nX:w  a  UR                  SU
45        U$ )Nr   tt2psrq   )rq   r  r  r  r  r1   )r(   r   rq   r  r  oldfaceoldbold	olditalicoldfontinfor  r   r   s               r)   	shiftfontPara.shiftfont  s    ))))KK	3<<>I6		-Tv&	2=NNVTO-r,   c                 8    U H  nU R                  XT5        M     g r.   )r  r(   r  r  r  r   r   s         r)   r  Para.compile_  s    A!!!- r,   c                 6    UR                  [        5       5        g r.   )r1   PageNumberObjectr(   r  r  r  r   s        r)   compile_pageNumberPara.compile_pageNumber  s    ')*r,   c                 |    U R                  USS9u  pVnU H  nU R                  X5        M     U R                  XFS9  g )Nr>   )r  r  r  	r(   r  r  r  r   frF  r   r   s	            r)   	compile_bPara.compile_b  s>    ..q.1QA!!!- w'r,   c                 |    U R                  USS9u  pVnU H  nU R                  X5        M     U R                  XGS9  g )Nr>   )r  r  r  s	            r)   	compile_iPara.compile_i  s>    ...3QA!!!- w)r,   c                     UR                  S[        45        U H  nU R                  XT5        M     UR                  S[        45        g )Nrz   r{   )r1   	UNDERLINEr  r  s         r)   	compile_uPara.compile_u  s?     	)46A!!!- +Y79r,   c                    U R                   nUS-  =U l         nUS-  nUR                  SU45        XPl         UR                  SU* 45        U H  nU R                  X5        M     UR                  SU45        UR                  SU45        g Ngffffff?g      ?rr   r$   rr   r1   r  	r(   r  r  r  r   rr   newsizer$   r   s	            r)   compile_subPara.compile_sub  s    yy"Sj(	GCx)+	$)A!!!- ((r,   c                    UR                  5       n[        XVU R                  5      nU H  n[        U[        5      (       a"  UR                  5       (       a  [        S5      eM:  [        U[        5      (       d  MQ  Uu  pYpUS:w  a  [        S[        U5      -  5      eUR                  5       nU	(       a  UR                  U	5        UR                  U5        U R                  XX45        M     g )N(don't expect CDATA between list elementslizdon't expect %s inside list)rA   bulletMakerr  r   r   r   rC   r   rN   rE   
makeBulletcompile_para)r(   r  r  r  r   r  attsbulletmakerr   attdict1content1newattss               r)   
compile_ulPara.compile_ul  s     ||~!'>A!C  7799$%OPP Ae$$784HD=$%BT']%RSS))+NN8,&&w/!!'UD r,   c                 $    U R                  XX4SS9$ )Nol)r  )r  r  s        r)   
compile_olPara.compile_ol#  s    wNNr,   c                    UR                  5       nUR                  5       n[        SXPR                  5      n[        U5      nSnU(       Ga  US   n	US	 [	        U	[
        5      (       a*  U	R                  5       (       a  [        S5      eU(       d  OMO  [	        U	[        5      (       a  U	u  ppU
S:w  a  U
S:w  a  [        S[        U
5      -  5      eU
S:X  a8  U(       a  [        S[        U5      -   5      eU(       a  U R                  XX45        OQU
S:X  aK  UR                  5       nU(       a  UR                  U5        UR                  XS	9  U R                  XX45        SnU(       a  GM  U(       a  [        S
[        U5      -   5      eg )Ndlr  r   r  dddtz5don't expect %s here inside list, expect 'dd' or 'dt'z2dt will not be displayed unless followed by a dd: )blz0dt will not be displayed unless followed by a dd)rA   r  r  r   r   r   r   rC   r   rN   r  rE   r  )r(   r  r  r  r   r  r  contentcopyrw   r   r  r	  r
  r  s                 r)   
compile_dlPara.compile_dl&  sb    ||~ ||~!$ll;7mAAA!C  7799$%OPP$Ae$$784HD=Wd]$%\w-&( ) )D=()]^bci^j)jkk))(eM d]"iikGx0**7*>%%gHF9 k: OPTU[P\\]] r,   c                    U R                   nUS-  =U l         nUS-  nUR                  SU45        UR                  SU45        U H  nU R                  X5        M     UR                  SU45        XPl         UR                  SU* 45        g r  r  r  s	            r)   compile_superPara.compile_superQ  s    yy"Sj(	GCx)+(A!!!- (	$)r,   c                    UR                  S5        SU;   a<  US   nSSKJn   U" XPR                  U R                  5      nUR                  SU45        SU;   a  US   nUR                  SU45        SU;   a  US   n	UR                  SU	45        U H  n
U R                  X5        M     UR                  S5        g !   Un N= f)Nr  rq   r   r  rp   rr   r  )r1   r  r  r  r  r  )r(   r  r  r  r   rq   r  r   r   rr   r   s              r)   compile_fontPara.compile_font^  s    	#W6?D1T))DKK8 NNVTO-g(INNWi02W6?DNNVTN,A!!!- "s   B< <Cc                    US   nUR                  SS5      n[        U5      nUR                  S5        UR                  SU45        UR                  SU45        UR                  S[        45        U H  nU R	                  X5        M     UR                  S[        45        UR                  SU45        UR                  S5        g )Nhrefrp   bluer  rz   r{   r  )getHotLinkr1   r  r  )	r(   r  r  r  r   urlr   Linkr   s	            r)   	compile_aPara.compile_at  s    foKK0	s|	#),.$/1)46A!!!- +Y79+T24"r,   c                    US   nUR                  SS 5      n[        U5      nUR                  S5        U(       a  UR                  SU45        UR                  SU45        UR                  S[        45        U H  nU R	                  X5        M     UR                  S[        45        UR                  SU45        UR                  S5        g )Ndestinationrp   r  rz   r{   r  )r#  InternalLinkr1   r  r  	r(   r  r  r  r   destr   r&  r   s	            r)   compile_linkPara.compile_link  s    }%KK.	D!	#NNWi02$/1)46A!!!- +Y79+T24"r,   c                    US   nUR                  SS5      n[        U5      nUR                  S5        U(       a  UR                  SU45        UR                  SU45        U(       a  UR                  S[        45        U H  nU R	                  X5        M     U(       a  UR                  S[        45        UR                  SU45        UR                  S5        g )Nr*  rp   r"  r  rz   r{   r  )r#  DefDestinationr1   r  r  r,  s	            r)   compile_setLinkPara.compile_setLink  s    }%KK0	d#	#NNWi02$/1NN_i8:A!!!- NN/;=+T24"r,   c                     [        U5      S:w  d  [        US   [        5      (       d  [        S5      eUS   nU R	                  XT5        g )Nr>   r   z*content for bullet must be a single string)r~   r   r   rC   r  )r(   r  r  r  r   r   s         r)   compile_bulletPara.compile_bullet  s>    w<?*WQZ"<"<IJJqzt%r,   c                     U R                   nUR                  U R                  -   nUR                  nUR                  nUR                  SXXV45        g )Nrw   )r  r9  r   rQ  r8  r1   )r(   r   r   re  r   r   rr   s          r)   r  Para.do_bullet  sH    ##doo5####4<>r,   c                 |    U R                  USS9u  pVnU H  nU R                  X5        M     U R                  XES9  g )NCourier)rq   r  r  s	            r)   
compile_ttPara.compile_tt  s>    ..y.9QA!!!- w'r,   c                 .    U R                  SS0X#U5        g )Nrq   symbol)r  r  s        r)   compile_greekPara.compile_greek  s    68,ggFr,   c                 N    UR                  [        XX0R                  5      5        g r.   )r1   EvalStringObjectr  r  s        r)   compile_evalStringPara.compile_evalString      (5,,OQr,   c                 N    UR                  [        XX0R                  5      5        g r.   )r1   
NameObjectr  r  s        r)   compile_namePara.compile_name  s    
7ULLIKr,   c                 N    UR                  [        XX0R                  5      5        g r.   )r1   GetNameObjectr  r  s        r)   compile_getNamePara.compile_getName  s    g||LNr,   c                 N    UR                  [        XX0R                  5      5        g r.   )r1   	SeqObjectr  r  s        r)   compile_seqPara.compile_seq  s    	'E<<HJr,   c                 N    UR                  [        XX0R                  5      5        g r.   )r1   SeqResetObjectr  r  s        r)   compile_seqResetPara.compile_seqReset  s    wMOr,   c                 N    UR                  [        XX0R                  5      5        g r.   )r1   SeqDefaultObjectr  r  s        r)   compile_seqDefaultPara.compile_seqDefault  rE  r,   c                    Uc  0 nU R                   nUR                  SU5      nXe   n[        SUS9nUR                  U5        UR                  SS 5      n	U R                  n
[        XXiS9nU R                  nU
R                  U R                  -   =U l        Ul        UR                  US9  UR                  S5        Xl        g )Nre  zrml2pdf internal embedded stylerA  rB  r  r  r  r  r|   )
r  r#  r=  rN  r  r  r   r4  r  r1   )r(   r  r  r  r   	stylenamer  re  newstyler  mystyletheparamybaseindents                r)   r  Para.compile_para  s    ?G,,KK3	"$EeTw'[[t4
++x'Q /6/A/ADOO/SS','*)&r,   )rl  r   r  r  r  r  rq   r  rk  r  rb   r  r  r   rT   r  rr   r7  r6  r3   r  )NNNNr   r.   )NNNNN)ul)r_  )*r   r   r   r   r6  r7  r*   r  r  rx  r!  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r'  r.  r2  r5  r  r;  r?  rC  rH  rL  rP  rT  rX  r  r   r   r,   r)   r  r    s    KJ#. 
FP0B8t#2'VR$.+(*:)E(O)^V*#,## #,&?(GRLOKPR'r,   r  c                   $    \ rS rSrS rSS jrSrg)r  i  c                    Xl         SnUR                  SU5      =U l        nSSS S.U   nUR                  SU5      =U l        nSU;  a.  X4   nSS	KJn  UR                  nU" S
SU5      n	[        U	5      US'   SU l        SU l	        g )Nr`  re  discr   )rd  r  r  typer4  r   r   XXXr:  r>   )
r  r#  re  typr}   r   r   r   r  _first)
r(   r  r  r  re  rj  thestyler   rr   r   s
             r)   r*   bulletMaker.__init__  s    !!XXgu55
U3d3G<--#t#~H@$$D 	48F!$VD
r,   Nc                 (   U R                   (       d  SUS'   OSU l         U R                  nU R                  nUGc8  US:X  aY  US:X  a  [        S5      nO;US:X  a  [        S5      nO)US	:X  a  [        S
5      nO[	        S[        U5      -  5      eSU;  a  SUS'   OUS:X  a  SU;   a  [        US   5      U l        OU =R                  S-  sl        US:X  a  [        U R                  5      nOUS:X  a'  [        S5      U R                  -   S-
  n[        U5      nO[US:X  a'  [        S5      U R                  -   S-
  n[        U5      nO.[	        S[        U5      -  5      e[	        S[        U5      -   5      eSU;  a  X!S'   SU;  a  U R                  US'   g g )Nr  r6  r   rd  rg  m   circlel   squaren   z&unordered list type %s not implementedrQ  ZapfDingbatsr  rM  r>   r   rE  Az&ordered bullet type %s not implementedzbad tagname r  re  )rk  rj  r  chrrC   rN   intr  r   ordre  )r(   r  r  rj  r  theords         r)   r  bulletMaker.makeBullet  ss   {{"%DDKhh,,:};SX(]SB(]SB$%MPTUXPY%YZZ#4/-;D)*$d?!$T']!3DJJJ!OJ8#djj/R#X Xdjj02FVB#X Xdjj02FVB$%MPTUXPY%YZZ W!=>>t#!#$ JJDM r,   )rk  r  re  r  rj  r.   )r   r   r   r   r*   r  r   r   r,   r)   r  r    s    &$'r,   r  c                   4    \ rS rSrSrSrS rS rS rS r	Sr
g	)
rB  i   z)this will only work if rml2pdf is present
evalStringc                 F    U(       d  0 nXl         X l        X@l        X0l        g r.   )r  r  r  r  )r(   r  r  r  r  s        r)   r*   EvalStringObject.__init__%  s    G
r,   c                 V    SSK Jn  UR                  XR                  0 5      =o@l        U$ )Nr   )
Controller)rlextra.rml2pdf.rml2pdfr  processTupler  op)r(   r   enginer  r  s        r)   getOpEvalStringObject.getOp-  s%    6!..ullBGGW	r,   c                     SSK Jn  U R                  nU(       d  / nU R                  U R                  X0R
                  4nU R                  XA5      =oPl        [        U5      nU" XaR                  UR                  5      $ Nr   r   )r}   r   r  r  r  r  r  r  r   r   r   )r(   r  r   r  r   r  r   s          r)   rn   EvalStringObject.width3  sa    <,,Gt||WjjAzz%00W G1oov??r,   c                 L    UR                  [        U R                  5      5        g r.   )r   r   r  r(   r  r   r   s       r)   r   EvalStringObject.execute@  s    3tww<(r,   )r  r  r  r  r  N)r   r   r   r   rP  r  r*   r  rn   r   r   r   r,   r)   rB  rB     s    /G@)r,   rB  c                       \ rS rSrS rSrg)rO  iC  c                     SSK Jn  U" 5       nU R                  nSU;   a  US   nXd-  =opl        U$ SU;   a  US   nOS nUR	                  U5      =opl        U$ )Nr   getSequencertemplater  )reportlab.lib.sequencerr  r  r  nextf)	r(   r   r  r  globalsequencerattrtemplr  r  s	            r)   r  SeqObject.getOpE  sj    8&.|| $E 22BIT\dBB&,,R00W	r,   r  Nr   r   r   r   r  r   r   r,   r)   rO  rO  C  s    r,   rO  c                       \ rS rSrSrS rSrg)rG  iV  rA  c                     g r.   r   r  s       r)   r   NameObject.executeX  s    r,   r   N)r   r   r   r   r  r   r   r   r,   r)   rG  rG  V  s    Gr,   rG  c                       \ rS rSrS rSrg)rW  i[  c                     SSK Jn  U" 5       nU R                  n US   nUR	                  U5        SU l        g! [         a    S n N'f = f)Nr   r  r  r  )r  r  r  r  setDefaultCounterr  )r(   r   r  r  r  r  defaults          r)   r  SeqDefaultObject.getOp]  sS    8&.||	4jG 	))'2	  	G	s   9 AAr  Nr  r   r,   r)   rW  rW  [  s    
r,   rW  c                       \ rS rSrS rSrg)rS  ii  c                     SSK Jn  U" 5       nU R                  n US   n [	        US   5      nUR                  Xg5        SU l        g! [         a    S n N6f = f!   Sn N1= f)Nr   r  r  baser  )r  r  r  r  rw  resetr  )r(   r   r  r  r  r  r  r  s           r)   r  SeqResetObject.getOpk  sq    8&.||	dB	tF|$D 	b'  	B		Ds   A A AAA r  Nr  r   r,   r)   rS  rS  i  s    r,   rS  c                       \ rS rSrSrSrg)rK  i{  getNamer   N)r   r   r   r   r  r   r   r,   r)   rK  rK  {  s    Gr,   rK  c                   *    \ rS rSrSS jrS rS rSrg)r  i~  c                     Xl         g r.   example)r(   r  s     r)   r*   PageNumberObject.__init__  s    r,   c                 ^    SSK Jn  U" U R                  UR                  UR                  5      $ r  )r}   r   r  r   r   )r(   r  r   s      r)   rn   PageNumberObject.width  s     <4<<&//JJr,   c                 X    UR                  5       nUR                  [        U5      5        g r.   )getPageNumberr   r   )r(   r  r   r   ns        r)   r   PageNumberObject.execute  s"      "3q6"r,   r  N)ri  )r   r   r   r   r*   rn   r   r   r   r,   r)   r  r  ~  s    K#r,   r  c                      SSK Jn Jn   " S SU 5      q[        5       q " S SU 5      q[        5       nX!S'   X!S'   X!S	'   [        US
'   [        US'   [        US'   [        US'   [        US'   g)z8make the para the default para implementation in rml2pdfr   )MapNoder  c                       \ rS rSrS rSrg)
paraMapperi  c                 @   Uu  pVpxUS-   n	UR                  SU	5      n	X9   n
[        SU
S9nUR                  U5        UR                  SS 5      nS nU(       d:  [        U5      S:X  a+  US   n[	        U[
        5      (       a  SU;  a  [        X5      nUc
  [        XX<S	9nU$ )
Nz.defaultStylere  zrml2pdf internal styler[  r  r>   r   rd  r\  )r#  r=  rN  r~   r   r   rb  r  )r(   	nodetuple
controllerr  	overridesr  r  r  r  r]  re  r_  r  r   r   s                  r)   r~  paraMapper.translate  s    1:.Ww/IGY7I&E!'?NG!!'* \48JF#g,/qzd3''CtO%g4F~gWMr,   r   Nr   r   r   r   r~  r   r   r,   r)   r  r    s    	r,   r  c                       \ rS rSrS rSrg)ulMapperi  c                 <    S0 U/S 4n[         R                  XRX45      $ )Npara)theParaMapperr~  )r(   r  r  r  r  r`  s         r)   r~  ulMapper.translate  s%    rI;5G **7SSr,   r   Nr  r   r,   r)   r  r    s    	Tr,   r  rd  r  r  r  h1h2h3titleN)r  r  r  r  r  r  )r  r  theListMappers      r)   EmbedInRml2pdfr    s{    ;W ( LMT7 T JM$t$t$t&Jv$Jt$Jt$Jt'Jwr,   c                    SSK Jn  SSKJn  SSSS.nUSS U;   a  UR	                  S	5         Uc  / nUR                  S5      n	Sn
U	S
   nU	 GH  nU
(       d  UR                  S5      nUS:  a  US U nUS   S:X  aI   US   S:X  a  [        USS  S5      nO[        USS  5      n US:  a  [        U5      XS-   S  -   nOSU-   nOX;   a5  X^   n[        U[        5      (       a  UR                  S5      nUXS-   S  -   nOEX;   a5  X>   n[        U[        5      (       a  UR                  S5      nUXS-   S  -   nOSU-   nOSU-   nUR                  5       nUS S
  H  nUR	                  US	-   5        M     U(       aS  U(       aL  US
   U;   a  UR	                  US
   S	-   5        O+US
   R                  5       nU(       a  UR	                  U5        Sn
GM     U$ ! [         a    S
n GNAf = f)Nr   )greeks)
whitespacer  r  rd  )ltgtampr>   r?   r9   ;#r"         utf8)reportlab.platypus.paraparserr  r+  r  r1   r!  r   rP   findrw  rC   rv  r   bytesdecode)r  r   r   r  r  standardr   r"   r   amptextr   lastfragfragmentsemirA  r  r   	sfragmentr  s                      r)   r  r    s   4!S,HAayJs 	 jjoGEr{H==%DAv7C<7c> #DHb 1A #DHA !t#&q6(67*;#;#&x<% A!(511HHV, q&'!22H^A!(511HHV, q&'!22H  #8|H x<NN$	3BANN1S5!   |z)	"c 13 }**,NND*a d NM & s   >GGG('G(c                 p    SU ;  a  SU ;  a	  [        XS9$ SSKJn  UR                  U SS9n[	        XUSUS9$ )	z]Paragraph(text, style, bulletText=None)
intended to be like a platypus Paragraph but better.
rd  r  )rf  r   	rparsexmlNentityReplacerr  )rb  r*  r  parsexmlSimpler  )r   re  r  fragsr  r  
parsedparas          r)   	Paragraphr    sH    
 $3d?// 	,--d$-G
EZt]deer,   c                   *    \ rS rSrSS jrS rS rSrg)UnderLineHandleri  Nc                     Xl         g r.   )rp   )r(   rp   s     r)   r*   UnderLineHandler.__init__  s    
r,   c                     Xl         X l        g r.   )xStartyStart)r(   r"   r#   r  r   r   s         r)   r   UnderLineHandler.start_at  s    r,   c                 (   UR                   S-  nUR                  5         U R                  nU R                  c  UR                  nUR	                  U5        UR                  U R                  U R                  U-
  XU-
  5        UR                  5         g )Ng       @)	r   	saveStaterp   r!   setStrokeColorr\   r  r  restoreState)r(   r"   r#   r  r   r   offsetrp   s           r)   r   UnderLineHandler.end_at  ss    s"

::NNEe$DKKV!3Qx@r,   )rp   r  r  r.   )r   r   r   r   r*   r   r   r   r   r,   r)   r  r    s    r,   r  c                   &    \ rS rSrS rS rS rSrg)r$  i#  c                     Xl         g r.   r%  )r(   r%  s     r)   r*   HotLink.__init__%  s    r,   c                     UR                   nU R                  U R                  XU-   /n[        (       a  [	        SU5        U R                  Xt5        g )NzLINKING RECTANGLE)r   r  r  rL   rM   link)r(   r"   r#   r  r   r   r   rects           r)   r   HotLink.end_at(  s?    ==T[[!hJ75%t,		$r,   c                 :    UR                  U R                  USS9  g )Nr>   )relative)linkURLr%  )r(   r  r   s      r)   r  HotLink.link0  s    txx2r,   r  N)r   r   r   r   r*   r   r  r   r   r,   r)   r$  r$  #  s     3r,   r$  c                       \ rS rSrS rSrg)r+  i3  c                 B    U R                   nSnUR                  XCUSS9  g )Nr  z[0 0 0])Border)r%  linkRect)r(   r  r   destinationnamecontentss        r)   r  InternalLink.link5  s"    ((4	Jr,   r   N)r   r   r   r   r  r   r   r,   r)   r+  r+  3  s    Kr,   r+  c                       \ rS rSrSrS rSrg)r1  i:  r   c                 |    U R                   nU R                  (       d  Uu  pEpgUR                  X4U5        SU l        g g )Nr>   )r%  definedbookmarkHorizontal)r(   r  r   r  r"   r#   x1y1s           r)   r  DefDestination.link>  s7    ((||!NQ2%%o"=DL r,   )r  N)r   r   r   r   r  r  r   r   r,   r)   r1  r1  :  s    Gr,   r1  c                 d    U R                  5       n/ nU H  nUR                  US-   5        M     U$ )Nr?   )r!  r1   )r   r  r   r   s       r)   
splitspacer  E  s1    JJLEFae Mr,   a  
This is Text.
<b>This is bold text.</b>
This is Text.
<i>This is italic text.</i>

<ul>
    <li> this is an element at 1
more text and even more text &amp; on and on and so forth
more text and even more text and on &amp; on and so forth
more text and even more text and on and on &amp; so forth
more text and even more text and on and on and so forth
more text and even more text and on and on and so forth --&gt;
more text <tt>monospaced</tt> and back to normal

    <ul>
        <li> this is an element at 2

more text and even more text and on and on and so forth
more text and even more text and on and on and so forth

        <ul>
            <li> this is an element at 3

more text and even more text and on and on and so forth


                <dl bulletFontName="Helvetica-BoldOblique" spaceBefore="10" spaceAfter="10">
                <dt>frogs</dt> <dd>Little green slimy things. Delicious with <b>garlic</b></dd>
                <dt>kittens</dt> <dd>cute, furry, not edible</dd>
                <dt>bunnies</dt> <dd>cute, furry,. Delicious with <b>garlic</b></dd>
                </dl>

more text and even more text and on and on and so forth

            <ul>
                <li> this is an element at  4
more text and even more text and on and on and so forth
                </li>
                <li> this is an element at4
more text and even more text and on and on and so forth
                </li>
            </ul>
more text and even more text and on and on and so forth
more text and even more text and on and on and so forth

            </li>
        </ul>
more text and even more text and on and on and so forth
more text and even more text and on and on and so forth
        </li>
    </ul>
<u><b>UNDERLINED</b> more text and even more text and on and on and so forth
more text and even more text and on and on and so forth</u>

<ol type="a">
    <li value="3">first element of the alpha list

     <ul type="square">
        <li>first element of the square unnumberred list</li>

        <li>second element of the unnumberred list</li>

        <li>third element of the unnumberred list
        third element of the unnumberred list
        third element of the unnumberred list
        third element of the unnumberred list
        third element of the unnumberred list
        third element of the unnumberred list
        third element of the unnumberred list
        </li>

        <li>fourth element of the unnumberred list</li>

      </ul>

    </li>

    <li>second element of the alpha list</li>

    <li>third element of the alpha list
    third element of the unnumberred list &amp;#33; --> &#33;
    third element of the unnumberred list &amp;#8704; --> &#8704;
    third element of the unnumberred list &amp;exist; --> &exist;
    third element of the unnumberred list
    third element of the unnumberred list
    third element of the unnumberred list
    </li>

    <li>fourth element of the alpha list</li>

  </ol>


    </li>
</ul>
u  
<a href="http://www.reportlab.com">goto www.reportlab.com</a>.


<para alignment="justify">
<font color="red" size="15">R</font>ed letter. thisisareallylongword andsoisthis andthisislonger
justified text paragraph example with a pound sign Â£
justified text paragraph example
justified text paragraph example
</para>

<para alignment="center">
<font color="green" size="15">G</font>reen letter.
centered text paragraph example
centered text paragraph example
centered text paragraph example
</para>
<para alignment="right">
<font color="blue" size="15">B</font>lue letter.
right justified text paragraph example
right justified text paragraph example
right justified text paragraph example
</para>
<para alignment="left">
<font color="yellow" size="15">Y</font>ellow letter.
left justified text paragraph example
left justified text paragraph example
left justified text paragraph example
</para>

c           	      :   SSK Jn  SSKJn  SSKJn  UR                  US S9nU" SS 5      n[        Xe5      nUR                  SU-  SU-  5      u  p[        S	X45        U R                  5         U R                  S
U-  S
U-  5        U R                  SSSU-  SU-  SS
S9  Xl        U R                  5         UR                  5         U R                  5         U R!                  S
SS5        U R                  SSXSS
S9  U R                  5         U R#                  5         g )Nr   inch)ParagraphStyler  r  rZ     r   z
wrapped asr>   )fillstroke)reportlab.lib.unitsr  r  r  r*  r  r  r  rx  rM   r  r~  r  r}  r  r  setStrokeColorRGBshowPage)
r}  testparar  r  r  r  SPr  r   s
             r)   test2r    s    (3'))($)GJx&AQAVVAdFBtG$FQ	,NNNN1T61T6"IIa!D&DqI3FNNFFH1a#IIa!AaI(MMOr,   zhttp://www.reportlab.comr  )r   d   )r      )rw   zvery long bullet2   r:     ry   rq   )rr   r   )r    r#  z1This is the first segment of the first paragraph.rz   zHOTLINK This is the first segment of the first paragraph. This is the first segment of the first paragraph. This is the first segment of the first paragraph. This is the first segment of the first paragraph. r{   r|   )rw   Bulletr   r:     zThis is the SECOND!!! segment of the first paragraph. This is the first segment of the first paragraph. This is the first segment of the first paragraph. This is the first segment of the first paragraph. This is the first segment of the first paragraph. )rw   z"Bullet not quite as long this timer"  r:  r%  )rq   zHelvetica-Oblique)rp   redz4This is the THIRD!!! segment of the first paragraph.zThis is the first segment of the first paragraph. This is the first segment of the first paragraph. This is the first segment of the first paragraph. This is the first segment of the first paragraph. )r$   r  zraised ztext )r$   izlowered znormal r  )r   r"  )rw   Or"  r:  r#  )rq   r   a  And this is the remainder of the paragraph indented further. a a a a a a a a And this is the remainder of the paragraph indented further. a a a a a a a a And this is the remainder of the paragraph indented further. a a a a a a a a And this is the remainder of the paragraph indented further. a a a a a a a a And this is the remainder of the paragraph indented further. a a a a a a a a And this is the remainder of the paragraph indented further. a a a a a a a a And this is the remainder of the paragraph indented further. a a a a a a a a c                     SSK J n   SSKJn  SSKJn  SnUR                  U5      n[        U[        5        [        U[        5         [        [        -   [        -   n0 nU(       a  [        S5        UR                  USU-  5        UR                  5       nUR                  SS5        [        5       nUR                  U5        SUl        SUl        SU-  n	S	n
UR%                  XU5      u  ppl[&        (       a  U " U5        UR)                  XU5      nUR+                  U5        UR-                  5         [        S
SUS   SUS   5        U(       a  M  UR/                  5         [        U5        g )Nr   )pprint)r   r  zparatest0.pdfzNEW PAGEr%     i  z==============================zx=r"   zy=r#   )r)  reportlab.pdfgenr   r  r  Canvasr  testparagraphtestparagraph1test_programrM   r~  r  r   r   rk   r"   r#   rd   rL   r   r  r  save)r)  r   r  r  r  rT   rb   r  r  rQ   rR   formattedprogramrk  s                r)   testr2  	  s*   '(	BbA	!M	!N </,>		*KKaf%AOOAa !ALL#ACACvHI?@xx]f?g<)u(*%5!<IJJqMJJL&$	#inE# i$ FFH	"Ir,   __main__r.   rc  )<rP  r}   r   reportlab.lib.rl_accelr   reportlab.platypus.flowablesr   r*  r   r  r	   rL   r  rB   r%   r
   r   r   r   r   rF   rJ   r   r   r  r  r  r$  r1  r3  r=  r  rb  r  r  r  r  rB  rO  rG  rW  rS  rK  r  r  r  r  r  r  r$  r+  r1  r  r-  r.  r  testlinkr/  r2  r   r   r,   r)   <module>r7     s^  ;x 5 ) 1   .
 	
 H Hg gR( 'O	#4 !+ , !* !*J "!!!!!!'!&$# a%x a%F(s'8 s'j8' 8't!) !)F  &! 
z Z $$ # #*(XJXf   	3 3 K7 K	W 	`D@. -. (Ei(]+ #	 ##VW	X %h/[ !  "t  uu (2#g&:]+ #x& #  $d  e'e( $j)V1 #$	h'8 ##Y '9'< %i0*;> #  $n  o?o@ (3w!w#'#h'6) #!r?0` #  $A	  B	a0B	b E	a2hB ZF r,   