
    kfIk                    Z   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 dZdZdZddlmZmZmZmZ  G d	 d
          Zd Zd ZddlmZ d Zd Zd ZefdZd Z G d d          Z G d d          Zdddddddddd d!d"d#d$Z G d% d&e          Z d' Z!dmd)Z" G d* d+e          Z# G d, d-          Z$ G d. d/          Z% G d0 d1e%          Z& G d2 d3e%          Z' G d4 d5e'          Z( G d6 d7e'          Z) G d8 d9e%          Z* G d: d;          Z+d< Z,dmd=Z-dnd>Z. G d? d@          Z/ e/            Z0 G dA dBe/          Z1 G dC dDe1          Z2 G dE dFe1          Z3dG Z4dHZ5dIZ6dJ Z7 e1dK          Z8dLdMdNdOdPefdQe
fdRdSg e4dT          z   dUe8fgz    e4dV          z   dWe8fdXdPefdYdQe
fdRdSgz    e4dZ          z   dXdPefd[d\dRdSdLd]gz    e4d^          z   dUe0fgz    e4d_          z   dWe0fd`dadbdcdddbd`dedbdfdMdgdXdPefdhdidRdSgz    e4dj          z   dfdXgz   Z9dk Z:e;dlk    r e:             d(S d(S )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                   j    e Zd ZddZdZd Zd ZddZd Zd	 Z	d
 Z
d Zd Zd Zd Zd Zd Zd ZdS )paragraphEngineNc                     ddl m} |g }g | _        || _        dx| _        | _        d| _        d| _        d| _        d| _	        || _
        dx| _        x| _        | _        ddlm} || _        g | _        d S )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       W/var/www/html/nettyfy-visnx/env/lib/python3.11/site-packages/reportlab/platypus/para.py__init__zparagraphEngine.__init__W   s    ......?G ),,d&#&)))$)//////      )	r   r   r   r   r   r    r   r#   r%   c                     g }| j         D ]'}t          | |          }|                    |           (| j        |gz   | _        |S N)TEXT_STATE_VARIABLESgetattrappendr&   r'   statevarvals       r(   pushTextStatezparagraphEngine.pushTextStatem   sV    , 	 	C$$$CLL"15'9 r*   c                     | j         d         }| j         d d         | _         |d d          }| j        D ]}|d         }|d= t          | ||           d S )Nr   )r&   r-   setattrr0   s       r(   popTextStatezparagraphEngine.popTextStatex   ss    #B'"1#2#6aaa , 	$ 	$C(CaD#s####	$ 	$r*   r   c                    | j                                         }|dd         }g }|}|r|| _        d}	d}
|rf|	rc| j        }| j        }||z
  |z
  }| j                                         }|t
          k     r"t          d| j        d| j        d|          	 |                     ||          \  }}}}}}}n#   xY w|
|z   }
| j        }||k    r||z
  }nd}	| j                             |           n| j	        }||d         }|s|d= |t          k    r*|rt          ||          }n|                     |          }n/|t          k    r@|rt          ||          }n|                     |          }|                     |||          }n|t          k    r@|rt          ||          }n|                     |          }|                     |||          }n|t"          k    ro|r.|r,|rt%          |||          }nv|                     |||          }n^|rt          ||          }n|                     |          }t(          rt+          d           nt          d	t-          |          z             |s|                     |          }|                    |           |r|	c| j                                         }| j                             |           ||z
  }||||fS )
zCreturn program with line operations added if at least one line fitsN   r   zindents  z too wide for space r6   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(   formatzparagraphEngine.format   s    ]''))
AAAJ	 $*7DL Y	%D Y	% [F*K 6)K7I"m0022O&& j$+++W[WgWgWgKS8"U V V V7;||Ix7X7X5T6=Y %f,KlGw&&"1'"9$$_555 I "&''*I H '!!  1%dM::DD??400DI%%  1%dM::DD??400D''mYGGH$$  1%dM::DD??400Dt]IFFJ&&  T T" Q1$yQQ#00}iPP" 5)$>>#t44 TRSSS !1$y//!ABBB /((..t$$$s  Y	%D Y	%t M&&((	Z(((0
Y	:>>s   B7 7B:c                 4    | j                                         S r,   )r<   r=   r'   s    r(   getStatezparagraphEngine.getState   s    }!!###r*   c                 :    | j                             |           d S r,   )r<   rA   )r'   r1   s     r(   
resetStatezparagraphEngine.resetState   s    U#####r*   c                 2   ddl m} | j        }||z
  | j        z
  }d}g }d}d}	d}
t	          |          }d}d}d}| j        }| j        } |d||          }d}|s||k     r||         }t          |t                    st          |d          r|}d}t          |d          rd}|
                    |           }d}n=|}|                                }|r ||||          }nd}|r|s|
r|d         dk    }nd}|}|r||z   }|
|z   }||k    r|sd}d}	n^|r|                    |           |r|                    |           t          |          t          k    r|                    |            |}
d}nt          |t                    rRd}t          |          }|t          k    r4|
|z   }||k    r|sd}n"|t          k    r|}
|                    |           d}nt          |t                     rWd}|d         }|dk    r |                    |           |dz  }dx}}nF|d	k    r^| j        }|\  }}t          |t                    rt%          t&          |          x}| _        n	|x}| _        |                    |           n|d
k    r2|\  }} | x}| _         |d||          }|                    |           n|dk    r|\  }}!t          t          |!                    }"t          |!t                    rJ|!dd         dk    r| j        |"z   x}| _        n3|!dd         dk    r| j        |"z
  x}| _        n|"x}| _        n	|"x}| _         |d||          }|                    |           n|dk    r#|\  }}#|#| _        |                    |           n|dk    rL|\  }}$| j        |$z   x}%| _        |rt+          |%|          }||z
  | j        z
  }|                    |           n||dk    r+|                                  |                    |           nK|dk    rN	 |                                  n#   xY w| j        }| j        } |d||          }|                    |           n|dk    r|\  }}&}%}'}"|%| j        z   }%||&|%|'|"f}|st3          d          t           ||&|'|"                    }(t           |d|'|"                    }|%|z   |(z   })t+          |)|          }|r||z
  | j        z
  }|                    |           nU|dk    r:|\  }}$| j        |$z   | _        |r||z
  | j        z
  }|                    |           n|dk    r,|\  }}*| j        |*z   x}+| _        |                    |           n|dk    r"|\  }},|,| _        |                    |           n|dk    r+|\  }}-|                    |           | j        |-gz   | _        n|dk    rF|\  }}-| j        dd         }.|.                    |-           |.| _        |                    |           n>t3          dt=          |          z             t3          dt=          |          z             |s|dz  }|s||k     |s|                    d           |	|||
|||fS )z(fit words (and other things) onto a liner   r   r:   Nr;   widthr6   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 rh   r   )reportlab.pdfbase.pdfmetricsr   r   r   lenr   r   
isinstancestrhasattrrg   stripr/   absr>   floattupler    r.   r   r   maxr4   r8   r   r?   r#   r%   r   removerJ   )/r'   r   totalLengthr   r[   r\   donerX   rY   rW   rZ   	maxcursor	needspacefirst
terminatedr   r   
spacewidthr]   opcodelastneedspacerg   
saveopcode	fullwidth	newlengthaopcode
nextLength	indicatoroldcolori	colornameri   fontnamefontsizerk   r   	incrementr   rp   fontbulletwidth	bulletminr#   newriser%   handlerhs/                                                  r(   r@   zparagraphEngine.fitLine   sA    	=<<<<<[
*,t/??	
LL		
== [h99
 t	6)++V_F&%% o_)@)@ o_ )	6'** &"#K"LL..E !II!'J#\\^^F " +FHh G G !! &u & &%/^S%8		$%	!	  3 %
 2I))3	Y&&u&
 D!"JJ % 2Z111 .V---5zz-//eV---(1 F5)) D_f++=((!.w!6J!)++E+ "=00,6M KK///EF5)) w_"1I	j(( KK'''aKF())J ''#~H%+NQ	!)C00 ;181K1KK1::KK''''&&$*MQ/77Ht}!,S(H!E!EJKK''''&&$*MQuX//D!(3// 8#BQB<,,7;}t7KKHt}}%bqb\3..7;}t7KKHt}}7;;Ht}}3774=!,S(H!E!EJKK''''	))#)LQ#*DLKK''''((%+NQ	+/;+BBFT[ P%(%<%<
$/*$<t?O$O	KK''''&&&&(((KK''''%%))++++ #}H#}H!,S(H!E!EJKK''''((6<3Qd#do5Ft<F  L()JKKK"'FD$(G(G"H"HK!&{{3d'C'C!D!DJ &z 1+ =I!$Y
!;!;J P$/*$<t?O$O	KK''''--%+NQ	'+'7	'AD$ P$/*$<t?O$O	KK''''&& &IQ*.)D.8GdiKK''''''%+NQ	 &/DNKK''''//#)LQKK'''*.*=	*ID'' 222#)LQ+AAA.AHHW%%%*+D'KK'''' %%QRVW`RaRa%abbb !PQUV\Q]Q]!]^^^ !i  t	6)++v  	+KK***D&-YP[\\s   %P: :P=c                 \    ||z
  }|dz  }|t           k    r|                     ||          S |S )N       @r>   insertShift)r'   rX   
lineLengthr\   diffshifts         r(   rD   zparagraphEngine.centerAlign  s;    #S##D%000r*   c                 R    ||z
  }|t           k    r|                     ||          S |S r,   r   )r'   rX   r   r\   r   s        r(   rE   zparagraphEngine.rightAlign  s2    *$##D%000r*   c                     g }d}|D ]U}|r<t          |t                    st          |d          r|                    |           d}|                    |           V|S )Nr:   rg   r   )rx   ry   rz   r/   )r'   rX   r   resultr   es         r(   r   zparagraphEngine.insertShift  sv     	 	A *Qs++ wq/A/A e$$$MM!r*   c                 P   ||z
  }d}d}d}|D ]U}t          |t                    r|t          k    r|r|dz  }*|r)t          |t                    st	          |d          rd}d}V|dk     r|S |t          |          z  }	|	t          k    r|S d}d}g }
d}t          |          }||k     r~||         }|
                    |           |r(t          |t                    st	          |d          rd}n,t          |t                    r|t          k    r|r
||	z   }||
d<   |dz  }||k     ~|
S )Nr   r:   rg   r6   )rx   r}   r>   ry   rz   rw   r/   )r'   rX   r   r\   r   
spacecountvisibler   r   r   r   rY   nlineexpandeds                 r(   rG   zparagraphEngine.justifyAlign  sw   #
 	 	A!E"" q7a

 Jq-- 71C1C a<<KU:&&&-KD		UllVAMM! &*Qs++ &wq/A/A &Ae$$ &=WU7%r
aKF Ull r*   c                    g }d}t          |          }||k     rg||         }t          |t                    r(||dz
  k     r|g}d}|dz  }||         }||k     rt          |t          t          f          rt          |t                    r$|dk     r	|dk    r| }|dk     r	|dk    r| }||z  }n*t          |t                    r|                    |           |dz  }||k     r||         }||k     rt          |t          t          f          d                    |          }	|                    |	           |                    t          |                     |dz  }n|                    |           |dz  }||k     g|S )Nr   r:   r   r;   )rw   rx   ry   r}   r/   join)
r'   rX   r   indexmaxindexr   
thestrings	thefloatsnextess
             r(   rC   zparagraphEngine.shrinkWrap*  s   t99HnnUA!C   !U8A:%5%5S
	
UHnnE5+)F)Fn!%.. 1$Q;;577)2
I 77y{{%*FE!U*		#E#.. 1"))%000QJEX~~ $U HnnE5+)F)Fn HHZ((a   eI..///
a   QJE; Hnn> r*   c                    g }d}|D ]}t          |t                    r1|dk     r	|dk    r| }|dk     r	|dk    r| }t          |          |z   }Ht          |          t          k    r|                    |           |                    |           d}|r|                    |           d}t          t          t          |          dz
                      }|rd}|D ]}|dz   }||         }	||         }
d}t          |	t                    s5t          |
t                    s t          |	d          st          |
d          rd}nnt          |	t                    rY|	d         }t          |
t                    r|
d         }d}|dk    r|dk    r|dk    rd}nt          |
t                    r|dk    rd}|r|
||<   |	||<   d}||S )zcollapse adjacent spacingsr   r:   rg   rt   rs   )rx   r}   r|   r>   r/   listrangerw   ry   rz   r~   )r'   rX   r   lastr   changerliner   	nextindexthisnextdoswapthisindicatornextindicators                 r(   rK   zparagraphEngine.cleanProgramP  s1     	 	A!E"" 66acc 5DQ33466AT{{1}t99]**MM$'''a    	 MM$ U3v;;q=))** 	F  !!G	e}i(d3'' 'd3'''4((',3D,A,A' FFU++ 
'$(GM!$u-- '(,Q!")+===-QcBcBc - > >%&F#D// '(/99%&F $(F5M(,F9%F;  	< r*   c           	      $   |j         }|j        }| j                                        }d}d}|                    | j                   | j        }	| j        }
| j        }d}|D ]|}t          |t                    st          |d          r|s{t          |
          t          k    r6|                    dt          |
d          z             | xj        |
z  c_        | j        D ]%}|                    | j        | j        | ||           &d}|| j        k    s|| j        k    r$| j        }| j        }|                    ||           t          |t                    r|                    |           |                    | ||           &t          |t0                    rRt          |          }|t          k    r6|                    dt          |d          z             | xj        |z  c_        t          |t2                    r|d         }|dk    r}|\  }}| j        }| j        }| j        | j        z
  x}| _        |	x}| _        | j        }
| j        }d}| j        D ]}|                    ||| ||           |                    ||           .|dk    rd| j        }|\  }}t          |t                    rt;          t<          |          x}| _        n	|x}| _        ||k    r|                    |           |dk    r|\  }}|| _        |d	k    r|\  }}t          t1          |                    }t          |t                    rF|dd         d
k    r| xj        |z  c_        n.|dd         dk    r| xj        |z  c_        n|| _        n|| _        | j        }|                    | j        | j                   ^|dk    r|\  }}|| _        r|dk    r(|\  }}| j        |z   x}| _        t?          |
|          }
|dk    r|                                   |dk    rP| j        }| j        }| j        } | !                                 || j        k    r|                    | j                   |dk    r|\  }}!|"                    |!           4|dk    r|\  }}"}}}t          | j        |	z
            t          k    rtG          d          t1          tI          |"||                    }#t1          tI          d||                    }$||$z   |#z   }%|%|
k    r|%}
|%                    |d           |                    ||           |                    |"           |%                    | d           |                    | j        | j                   7|dk    r|\  }}| j        |z   | _        S|dk    r-|\  }}&| j&        |&z   x}'| _&        |'                    |'           |dk    r|\  }}(|(| _(        |dk    r:|\  }}|                    | j        | j        | ||           | j        |gz   | _        |dk    r`|\  }}|                    | j        | j        | ||           | j        dd         x})| _        ||)v r| j        )                    |           >@tG          dtU          |          z             tG          dtU          |          z             | j                                        }*| j        +                    |           |*S )zrender the line(s)Nr   rg   z%s Tdr:   rh   ri   rj   rk   rl   rm   r   r   rn   ro   wordSpacingrp   rq   r;   r   r#   rr   rs   rt   zdon't understand indicator z!op must be string float or tuple ),_escape_coder<   r=   setFillColorr    r!   r   r   rx   ry   rz   r|   r>   r/   r   r   start_atr"   r   r   setFonttextOutexecuter}   r~   r   end_atsetTextOriginr.   r   r   r4   r8   setWordSpacer?   r   
moveCursorr#   setRiser%   r   rJ   rA   )+r'   r   canvas
textobjectescapecoderO   r   rk   xstartthislineindentthislinerightIndentindentedr   r   r   r   endallmarksr!   r"   newynewxr   r   ri   r   r   r   r   r   r   oldfontoldsizewsrp   r   r   r   r#   r   r%   newhr^   s+                                              r(   
runOpCodeszparagraphEngine.runOpCodes  s    ]''))
 	///". X	S X	SF&%% WS'&*A*A WS S>**=88 Gf^Q.G.G$GHHH.0#'#6 S S((vzRRRR&&$*=*==D=D&&tT222fS)) =&&v.... NN4V<<<<F5)) BSV-''KK&*;*; ;<<<FFf$FFF5)) {S"1I	j(('-$QAA$(F4<$77D46$**D46%)[N*.*:' H#'#6 G Gq!T6:FFFF,,T48888''#~H%+NQ	!)C00 ;181K1KK1:: h"//666&&$*MQ$,DMM&&$*MQuX//D!(3// -#BQB<,, MMT1MMM%bqb\3.. MMT1MMM,0DMM(,#}H&&t}dmDDDD	))#)LQ#*DLL((%+NQ	+/;+BBFT[%(%@%@NN&&&&((((%%#~H"mG"mG%%'''  //"//???--$GQ++B////((6<3Qd46&=))-77()JKKK"'FD$(G(G"H"HK!&{3d'C'C!D!DJ &z 1+ =I >11)2))&!444&&tT222&&v...))6'1555&&t}dmDDDD--%+NQ	'+'7	'AD$$&& &IQ*.)D.8Gdi&&w////''%+NQ	%.DNN//#)LQ$$TVTVT6:NNN +/*=	*ID'' 222#)LQNN46464LLL151DQQQ1GGD4.$+227;;;; %%B4	??%RSSS !DT&\\!QRRRM&&((	Z(((r*   r,   )r   )__name__
__module____qualname__r)   r-   r4   r8   r`   rc   re   r@   rD   rE   r   rG   rC   rK   r    r*   r(   r   r   U   s       ! ! ! !")
	 	 	
$ 
$ 
$l? l? l? l?\$ $ $$ $ $R] R] R]h    	 	 	! ! !~$ $ $L? ? ?Bk k k k kr*   r   c                     g }| D ],}t          |t                    r|                    |           -d                    |          }|t	          |          g}d}| r!| d         |k    r|                    |           |S )zEsimple case: line with just strings and spacings which can be ignoredr;   ru   r6   )rx   ry   r/   r   r}   )rX   lengthstringsr!   textr   nextlinemarks          r(   rB   rB   >  s     G  a 	NN188GDE&MM"F"L &R,&&|%%%Mr*   c                 r   g }| dd         D ],}t          |t                    r|                    |           -t          |          dz
  }||z
  }d                    |          }|dk    r!|dk    r|t          |          z  }d|f||dg}	n||dg}	d}
| r!| d         |
k    r|	                    |
           |	S )	z&simple justification with only stringsNr6   r:   r;   r   r   )r   r   ru   )rx   ry   r/   rw   r   r}   )rX   rZ   r\   r   r!   nspacesslackr   wordspacingr   r   s              r(   rF   rF   L  s     G#2#Y  a 	NN1'll1nGm#E88GDqyyU1WWE'NN* +.iAST7"L &R,&&|%%%Mr*   r   c                     |                                  dv rdS |                                  dv rdS t          d| z            )N)YYESTRUE1r:   )NNOFALSE0r   z+true/false attribute has illegal value '%s')upperr?   )r   s    r(   readBoolr   b  sH    zz||000q	2	2	2qFMNNNr*   c                     |                                  }|dk    rt          S |dk    rt          S |dv rt          S |dk    rt          S d S )NLEFTRIGHT)CENTERCENTREJUSTIFY)r   r
   r   r   r   )r   ups     r(   readAlignmentr   j  sS    	B	V||	w	#	#	#	y 
r*   c                    |                                  } 	 t          |           S # t          $ r |                                 } | dd         | dd         }}|                                 }	 t          |          }n # t          $ r t          d| z            w xY w	 ddddd|         }n # t          $ r t          d| z            w xY w||z  cY S w xY w)	zIRead 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}   r?   lowerKeyError)r   
numberTextunitsnumber
multipliers        r(   
readLengthr  u  s.    ::<<D#T{{ # # #zz|| "Id233iE
%%''
	E:&&FF 	E 	E 	E<tCDDD	E	E""	 
 JJ  	E 	E 	E<tCDDD	E 
""""%#s@   % AC,A<;C<BCB+*C+CCCc                     |                                  } | dd         dk    r| dd         dk    r
| dd         } |                     d          }d |D             }fd|D             }|S )	z0from "(2, 1)" or "2,1" return [2,1], for exampleNr:   (r6   ),c                 6    g | ]}|                                 S r   )r{   ).0r   s     r(   
<listcomp>z"lengthSequence.<locals>.<listcomp>  s     	 	 	 !''))	 	 	 r*   c                 &    g | ]} |          S r   r   )r  r   	converters     r(   r  z"lengthSequence.<locals>.<listcomp>  s!    	#	#	#1))A,,	#	#	#r*   )r{   split)r   r  sls    ` r(   lengthSequencer    s~    			A!uczzafckkadG	
B	 	 R	 	 	 B	#	#	#	#	#	#	#BIr*   c                    | sdS ddl m} ddlm} | d         |v r|j        |          S t          |           }d}dt          |          cxk    rdk    sn J |            d}t          t          |                    D ]}||         d	k    s
J |            t          |          dk    r|j        }nt          |          dk    r|j	        } || S )
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  rw   r   Color	CMYKColor)r   r   r  tupmsgr   colClasss          r(   	readColorr$    s    t$$$$$$Aw't$$


C
FCCAs
6C3s88__ " "1v}}}c}}}}
3xx1}}<	SQ#8S>r*   c                   V    e Zd ZegZegZegZegZegZe	gZ
egZegZegZegZegZegZdS )StyleAttributeConvertersN)r   r   r   r  r   r   
leftIndentr   firstLineIndentr   r%   spaceBefore
spaceAfterbulletFontSizebulletIndentr$  	textColor	backColorr   r*   r(   r&  r&    sb        \HLG|JKLOoIK|J<NLkIkIIIr*   r&  c                   \    e Zd ZdZdZeZdZdZdZ	dZ
dZeZdZdZeZdZdZeZdZd	dZd ZdS )
SimpleStylez6simplified paragraph style without all the fancy stuffbasicr   r   r   Nc                     | j         }|r$|j                                         D ]
\  }}|||<   |                                D ]
\  }}|||<   d S r,   )r<   items)r'   nameparentkwmydictabs          r(   r)   zSimpleStyle.__init__  sm     	,,..  !q		88:: 	 	CAaF1II	 	r*   c                     |                                 D ]X}||         }|Lt          t          |          r&t          t          |          d         } ||          }t	          | ||           Yd S Nr   )keysrz   r&  r.   r7   )r'   
dictionarykeyvaluer  s        r(   addAttributeszSimpleStyle.addAttributes  s~    ??$$ 	* 	*CsOE 3S99 - '(@# F Fq II%Ie,,Ec5)))	* 	*r*   r,   )r   r   r   __doc__r4  r	   r   r   r   r'  r   r(  r
   r%   r)  r*  bulletFontNamer+  r,  r   r-  r.  r)   r@  r   r*   r(   r0  r0    s        <<DHHGJKOIKJ NNLII   * * * * *r*   r0  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                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	FastParazAparagraph with no special features (not even a single ampersand!)c                 V    d|v rt          d          || _        || _        d | _        d S )N&zno ampersands please!)r?   style
simpletextlines)r'   rV  rW  s      r(   r)   zFastPara.__init__  s7     *4555
$


r*   c                    | j         }|| _        | j        }| j         }|j        }|j        }|j        }|j        }	|j        }
|j        }|	                                }g }ddl
m}  |d|	|
          }g }d}||z
  |z
  }||z
  |z
  }||k     r
||z   |z   |fS ||k     r||fS | j        1d}d}t          |          }d}||k     r|s|}|s|}||         } |||	|
          }|r||z   }||z   }|r||k     r|dz  }|}|                    |           nL|                    d                    |          |t          |          f           g }d}||z   }||z   |k    rd}||k     r||r?|s=|                    d                    |          |t          |          f           ||z   }|| _        || _        d                    ||d                    x}| _        nd }| j        }| j        }|r|||z   f}n||f}|S )Nr   r   r;   r:   )rW  availableWidthrV  r   r'  r   r   r   r(  r  rv   r   rX  rw   r/   r   heightrP   )r'   rZ  availableHeightrW  rV  r   r   r'  r   r   rk   firstindentwordsrX  r   r   currentlinecurrentlengthfirstmaxlength	maxlengthr_   rY   nwordsr   thismaxlengththiswordthiswordsize
nextlengthrP   r   s                                 r(   wrapzFastPara.wrap  s   _
,
'%
-~~+  ""<<<<<< [dD11
'+5C"[0:=	Z{*;6HH7"""G,,:JFZZFD--- ) 3$2M =*{8T4@@  ;#/
#:L*\9
$ !
9(<(<aKF$.M&&x0000 LL388K#8#8-[IYIY"Z\\\"$K$%M!+G!3J!')/99 - ---.  0T 0sxx44mSEUEUWXXX'/
DJ$DK),%.)A)AAI IJJE 	2$og&=>FF$j1Fr*   c                     | j         }|j        }||k     rg S | j        }|t          d          | j        }|rt          ||          }| |gS | gS )Nzmust wrap before split)rV  r   rX  r?   rP   rS  )r'   rZ  r\  rV  r   rX  rP   r   s           r(   r  zFastPara.splitF  sj    
-7""I
=5666N	 	E9--D;6Mr*   c                    | j         }| j        }|j        }|j        }|j        }|j        }|j        }|j        }|j        }	| j	        }
|
j
        }| j        }|
                    d||z
             |
                                }|j        }|                    ||           |j        r|                    |j                   d}d}| j        |z
  }d}t'          |          }||k     r||         \  }}}|dz  }|}|r|	}|t(          k    r|}n||t*          k    r||z
  }||dz  z   }nc|t,          k    r||z
  }||z   }nM|t.          k    rB|}||k     r%|dk    r|                    ||z
  |dz
  z             n|                    d           |                    ||           |                    |           ||z
  }||k     |
                    |           d S )Nr   r:   r   r  r   )rV  rX  r   r'  r   r   r   r%   r(  canvr   r[  	translate	beginTextr   r   r-  r   rZ  rw   r
   r   r   r   r   r   r   drawText)r'   rV  rX  r   r'  r   r   rk   r%   r]  cr   r[  r   r   r   r"   
basicWidthcountnlinesr   r   rc  
thisindentr!   extras                             r(   drawzFastPara.drawU  s%   

'%
-~~O	+I  	
Avd{###[[]]
4&&&? 	5##EO444(;6
UFll%*5\"T66QJE#J )(
'!!I%%"V+s*H$$"V+&J&&<<F1HH++Z->,LMMMM++C000$$Qq)))t$$$'	A/ Fll0 	


:r*   c                     | j         j        S r,   )rV  r)  rb   s    r(   getSpaceBeforezFastPara.getSpaceBefore  s     z%%r*   c                     | j         j        S r,   )rV  r*  rb   s    r(   getSpaceAfterzFastPara.getSpaceAfter  s    z$$r*   N)
r   r   r   rA  r)   rh  r  ru  rw  ry  r   r*   r(   rS  rS    sy        GG  F F FP  5 5 5n& & &
% % % % %r*   rS  c                  ~    i } ddl m}  |            }t                                          D ]\  }}||         | |<   | S Nr   )getSampleStyleSheetreportlab.lib.stylesr|  DEFAULT_ALIASESr3  )r   r|  stylesstylenamekeystylenamevalues        r(   defaultContextr    s^    F888888  ""F(7(=(=(?(? 6 6$n%n5|Mr*   Nc                 J   i }ddl m} | \t                                          D ]\  }}|| v r| |         ||<   t                                          D ]\  }}|| v r| |         ||<    |            }t                                          D ]\  }}||vr||v r||         ||<   |S r{  r}  )
stylesheetr   r|  r  r  r  s         r(   buildContextr    s    F888888,;,A,A,C,C 	@ 	@(L.z))'1,'?|$,;,A,A,C,C 	B 	B(L.++'1.'A|$  ""F(7(=(=(?(? : :$nv%%.F*B*B#).#9F< Mr*   c                       e Zd ZdZdZd(dZd Zd Zd Zd Z	d Z
d)d	Zd*d
Zd Zd+dZd Zd Zd Zd Zd Zd Zd,dZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d  Z!d! Z"d" Z#d# Z$d$ Z%d% Z&d-d'Z'dS ).Parar   Nc                    || _         t          |          | _        || _        || _        || _        g | _        g | _        d | _        || _	        |s|j
        | _
        |j        | _        d| _        d| _        |j        | _        |j        | _        d S r;  )r   r  context
parsedText
bulletTextstyle1r   formattedProgramrP   r1   r)  r*  bolditalicr   rj   r   rk   )r'   rV  r  r  r1   r  r   s          r(   r)   zPara.__init__  s    $#G,,$$ "
 	/$0D#.DO 	N	N			r*   c                     | j         S r,   )r)  rb   s    r(   rw  zPara.getSpaceBefore  s     r*   c                     | j         S r,   )r*  rb   s    r(   ry  zPara.getSpaceAfter  s
    r*   c                 t   t           rIt          dt          |           ||           t          d| j                   t          d| j                   || _        t                      x| _        }| j        |_        | j	        }| j        }| j
        }|r	|d         }n| j        j        }| j        }d| _        |r,|                    |           d|_        d|_        |d         }	n| j        j        }	||	k    rd| _        |dz   |fS ||t#          d          |s|                     |          x| _        }| j        s:|                    ||||          \  }}
}}|| _        || _        || _        |
| _        n	| j        }d }
|
rM|dz   }t/          | j        d d || j                  | _        |
| j        _        | j        | j        _        d| _        nd | _        |}||k    r|dz
  }||f}t           rN|\  }}t7          ||z
            d	k     r t          d
t9          ||          z              t          d||f|           |S )NWRAPPINGz   r   r:   r   zneed parsedText for formattingr  r  r1   r  g?g?zexact match???zwrap is)rH   rI   idr  r   r\  r   myenginer   r  r1   r  r   cansplitre   r!   r"   r?   compileProgramr`   r[  r^   remainderProgramr  r  rP   r*  r|   rJ   )r'   rZ  r\  pr  r  r1   r   r   needatleastrP   r^   r_   r[  r   wr   s                    r(   rh  z	Para.wrap  s    	'*bhhHHH%.///%&&&.+---_
0
 	*I&GGk)G, 	.LLACAC	*KK+-KK''DM $A%~66'/=>>> 	E%)%8%8%D%DDDL7$ 		&'hh~PWY`&a&a$y
$4D!$DK&DN$-D!!JI 	-
 %q(F "$+$4(14<I I IDN%.DN"(,DN%DOO!DNFo%%(, !&) 	HFQ?1$%%c))&oq)A)AABBB)no>GGGr*   c                     |dk    s| j         sg S || _        | j        }|t          d          |sg S | j        }|r| |g}n| g}|S )Nr   zmust call wrap before split)r  r\  r  r?   rP   )r'   rZ  r\  r  rP   r   s         r(   r  z
Para.split  sw     AT] I.0#:;;;! 	IN	 	9%FFFFr*   c                 2   | j         }| j        }|t          d          | j        }| j        }|r#|                    |           d|_        d|_        | j        }| j	        }|r	|d         }n| j
        j        }|                    d|| j        z
             |                                }t          st           r3t#          dd           |D ]}	t#          |	           t#          d           |                    |||          }|                    |           d S )Nzmust call wrap before drawr   r   z,============================================znow running programz,--------------------------------------------)r  r  r?   r1   r^   re   r!   r"   rk  r[  r  r   rl  rk   rm  DUMPPROGRAMrH   rI   r   rn  )
r'   r  r  r1   r^   ro  r[  r   tr!   s
             r(   ru  z	Para.draw6  s%   M0#9:::
N	 	LLACACI  	*I&GGk)G 	
Avdi'(((KKMM 	% 	&/000%  a&MMMLL!11a88		

1r*   c                    | j         }|g }|j        }|j        } |d|f           ddlm}  ||          \  | _        | _        | _         |d|j        f           |j        | _	         |d|j
        f            |d|j        f           |j        r |d|j        f            |d|j        f            |d|j        f           |j        r |d	|j        f           | j        r|                     | j        |           |                     ||           |j        rQd}|D ].}|d
z  }t'          |t(                    st+          |d          r n/|                    |d|j         f           |S )Nrj   r   )ps2ttrk   rr   r   r   r   ri   r:   rg   )r  r/   r   reportlab.lib.fontsr  rj   r  r  r   rk   r%   r'  r(  r   r   r-  r  	do_bulletcompileComponentrx   ry   rz   insert)	r'   r  r   rV  r8  fnr  rq  r!   s	            r(   r  zPara.compileProgramW  s    ?GN^	FB=------.3eBii+DIt{	FEN$&&&N		GU_&(((	He&(***  	4A%/1333	M5,.000	Iu}%'''? 	,A)+++? 	5NN4?G444j'222  	IE  
a$$ '(:(: ENNEHu/D.D#FHHH. r*   c                 Z   || j         }| j        }|g }|                    d           |j        r%|                    d|j        |j        z   f           n|                    d|j        f           |                    d           |                     ||          }|                    d           |                    d           |j        r|                    d|j        f           n|                    d           |                    d           |                    d           d S )Nrn   r   ru   r   ro   )r   r   )r  r  r/   r)  r   r  r*  )r'   r   r  rV  s       r(   	linearizezPara.linearize  s.    J?G	### 	9NNY(9%-(GHJJJJNNY6888)))%%j'%BB"""	### 	-NNY(89;;;;NNN,,,)))"""""r*   c                 >   t          |t                    rD|r@|                                }|s|                    d           d S t	          | ||           d S d S t          |t
                    r|D ]}|                     ||           d S t          |t                    r|\  }}}}|si }d|z   }	t          | |	d           }
|
 |
||||           d S t          rd|z   g}|j        }|si }|
                                D ]\  }} |d|d|           |r2 |d            |t          |                      |d|z             n |d           d                    |          }t	          | ||           d S t          d	t          |          z             d S )
Nr;   compile_<=>z</%s>z/> zdon't know how to handle tag )rx   ry   r{   r/   handleSpecialCharactersr   r  r~   r.   rH   r3  r   r?   rJ   )r'   r  r   stextr   tagnameattdictcontentrt  compilernamecompilerLr8  kvr  s                   r(   r  zPara.compileComponent  s%   j%% %	V  G"((** GNN3'''''+D*gFFFFFG G 
4(( 	V 2 2%%a11112 2
5)) 	V1;.Wgw %g-Lt\488H#'5':::::  V-)AA"0bG ' , ,1aaa*++++  ##g,,'G+,,,,$

A+D!W=====$%DtG}}%TUUU3	V 	Vr*   c                     | j         }| j        }| j        }|||f}||}||}||}|| _         || _        || _        ddlm}	  |	|||          }
 |	|||          }|
|k    r|                    d|
f           |S )Nr   tt2psrj   )rj   r  r  r  r  r/   )r'   r   rj   r  r  oldfaceoldbold	olditalicoldfontinfor  r   r   s               r(   	shiftfontzPara.shiftfont  s    ))K	3<<>I6		------uT$v&&%	22==NNVTO---r*   c                 <    |D ]}|                      ||           d S r,   )r  r'   r  r  rt  r   r   s         r(   r  zPara.compile_  s4     	. 	.A!!!W----	. 	.r*   c                 H    |                     t                                 d S r,   )r/   PageNumberObjectr'   r  r  rt  r   s        r(   compile_pageNumberzPara.compile_pageNumber  s!    '))*****r*   c                     |                      |d          \  }}}|D ]}|                     ||           |                      ||           d S )Nr:   )r  r  r  	r'   r  r  rt  r   fr9  r   r   s	            r(   	compile_bzPara.compile_b  sa    ..q.111Q 	. 	.A!!!W----wQ'''''r*   c                     |                      |d          \  }}}|D ]}|                     ||           |                      ||           d S )Nr:   )r  r  r  s	            r(   	compile_izPara.compile_i  sa    ...331Q 	. 	.A!!!W----wq)))))r*   c                     |                     dt          f           |D ]}|                     ||           |                     dt          f           d S )Nrs   rt   )r/   	UNDERLINEr  r  s         r(   	compile_uzPara.compile_u  sa     	)4666 	. 	.A!!!W----+Y799999r*   c                 4   | j         }|dz  x| _         }|dz  }|                    d|f           || _         |                    d| f           |D ]}|                     ||           |                    d|f           |                    d|f           d S Ngffffff?g      ?rk   r#   rk   r/   r  	r'   r  r  rt  r   rk   newsizer#   r   s	            r(   compile_subzPara.compile_sub  s    y"Sj(	GCx)+++	$))) 	. 	.A!!!W----((((((((r*   ulc                    |                                 }t          ||| j                  }|D ]}t          |t                    r$|                                rt          d          ;t          |t                    r|\  }}	}
}|dk    rt          dt          |          z            |                                 }|	r|	                    |	           |
                    |           |                     ||
||           d S )N(don't expect CDATA between list elementslizdon't expect %s inside list)r=   bulletMakerr  rx   ry   r{   r?   r~   rJ   rA   
makeBulletcompile_para)r'   r  r  rt  r   r  attsbulletmakerr   attdict1content1newattss               r(   
compile_ulzPara.compile_ul  s    ||~~!'4>> 	E 	EA!C   E7799 Q$%OPPPQAe$$ E784(HeD==$%BT']]%RSSS))++ -NN8,,,&&w///!!'8UGDDD	E 	Er*   c                 6    |                      ||||d          S )Nol)r  )r  r  s        r(   
compile_olzPara.compile_ol#  s    wNNNr*   c                 V   |                                 }|                                 }t          d|| j                  }t          |          }d}|r5|d         }	|d= t	          |	t
                    r'|	                                rt          d          |snJt	          |	t                    r|	\  }
}}}|
dk    r%|
dk    rt          dt          |
          z            |
dk    r<|rt          dt          |          z             |r| 
                    ||||           nb|
dk    r\|                                 }|r|                    |           |                    ||	           | 
                    ||||           d}|5|rt          d
t          |          z             d S )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)r=   r  r  r   rx   ry   r{   r?   r~   rJ   r  rA   r  )r'   r  r  rt  r   r  r  contentcopyrp   r   r  r  r  r  s                 r(   
compile_dlzPara.compile_dl&  s    ||~~ ||~~!$dl;;7mm 	 AAA!C    7799 $%OPPP$ Ae$$  784(HeD==Wd]]$%\w--&( ) ) )D== l()]^bci^j^j)jkkk N))(HeWMMM d]]"iikkG 1x000**7v*>>>%%gxHHHF9  	 :  	^OPTU[P\P\\]]]	^ 	^r*   c                 4   | j         }|dz  x| _         }|dz  }|                    d|f           |                    d|f           |D ]}|                     ||           |                    d|f           || _         |                    d| f           d S r  r  r  s	            r(   compile_superzPara.compile_superQ  s    y"Sj(	GCx)+++((( 	. 	.A!!!W----(((	$)))))r*   c                    |                     d           d|v rG|d         }ddlm} 	  ||| j        | j                  }n	#  |}Y nxY w|                     d|f           d|v r|d         }|                     d|f           d|v r|d         }	|                     d|	f           |D ]}
|                     |
|           |                     d           d S )Nr  rj   r   r  ri   rk   r  )r/   r  r  r  r  r  )r'   r  r  rt  r   rj   r  r   r   rk   r   s              r(   compile_fontzPara.compile_font^  s   	###W6?D111111uT$)DK88NNVTO---g(INNWi0222W6?DNNVTN,,, 	. 	.A!!!W----"""""s   A Ac                    |d         }|                     dd          }t          |          }|                    d           |                    d|f           |                    d|f           |                    dt          f           |D ]}|                     ||           |                    dt          f           |                    d|f           |                    d           d S )Nhrefri   bluer  rs   rt   r  )getHotLinkr/   r  r  )	r'   r  r  rt  r   urlr   Linkr   s	            r(   	compile_azPara.compile_at  s    foKK00	s||	###),...$/111)4666 	. 	.A!!!W----+Y7999+T2444"""""r*   c                    |d         }|                     dd           }t          |          }|                    d           |r|                    d|f           |                    d|f           |                    dt          f           |D ]}|                     ||           |                    dt          f           |                    d|f           |                    d           d S )Ndestinationri   r  rs   rt   r  )r  InternalLinkr/   r  r  	r'   r  r  rt  r   destr   r  r   s	            r(   compile_linkzPara.compile_link  s    }%KK..	D!!	### 	3NNWi0222$/111)4666 	. 	.A!!!W----+Y7999+T2444"""""r*   c                    |d         }|                     dd          }t          |          }|                    d           |r|                    d|f           |                    d|f           |r|                    dt          f           |D ]}|                     ||           |r|                    dt          f           |                    d|f           |                    d           d S )Nr   ri   r  r  rs   rt   r  )r  DefDestinationr/   r  r  r  s	            r(   compile_setLinkzPara.compile_setLink  s   }%KK00	d##	### 	3NNWi0222$/111 	;NN_i8::: 	. 	.A!!!W---- 	>NN/;===+T2444"""""r*   c                     t          |          dk    st          |d         t                    st          d          |d         }|                     ||           d S )Nr:   r   z*content for bullet must be a single string)rw   rx   ry   r?   r  )r'   r  r  rt  r   r   s         r(   compile_bulletzPara.compile_bullet  sU    w<<??*WQZ"<"<?IJJJqztW%%%%%r*   c                     | j         }|j        | j        z   }|j        }|j        }|                    d||||f           d S )Nrp   )r  r,  r   rB  r+  r/   )r'   r   r   rV  r   r   rk   s          r(   r  zPara.do_bullet  sK    #do5##4t<>>>>>r*   c                     |                      |d          \  }}}|D ]}|                     ||           |                      ||           d S )NCourier)rj   r  r  s	            r(   
compile_ttzPara.compile_tt  sa    ..y.991Q 	. 	.A!!!W----wQ'''''r*   c                 :    |                      ddi|||           d S )Nrj   symbol)r  r  s        r(   compile_greekzPara.compile_greek  s'    68,gugFFFFFr*   c                 Z    |                     t          |||| j                             d S r,   )r/   EvalStringObjectr  r  s        r(   compile_evalStringzPara.compile_evalString  +    ('5$,OOQQQQQr*   c                 Z    |                     t          |||| j                             d S r,   )r/   
NameObjectr  r  s        r(   compile_namezPara.compile_name  s*    
7GUDLIIKKKKKr*   c                 Z    |                     t          |||| j                             d S r,   )r/   GetNameObjectr  r  s        r(   compile_getNamezPara.compile_getName  s*    gwt|LLNNNNNr*   c                 Z    |                     t          |||| j                             d S r,   )r/   	SeqObjectr  r  s        r(   compile_seqzPara.compile_seq  s*    	'7E4<HHJJJJJr*   c                 Z    |                     t          |||| j                             d S r,   )r/   SeqResetObjectr  r  s        r(   compile_seqResetzPara.compile_seqReset  s*    wMMOOOOOr*   c                 Z    |                     t          |||| j                             d S r,   )r/   SeqDefaultObjectr  r  s        r(   compile_seqDefaultzPara.compile_seqDefault  r  r*   rP  c                    |i }| j         }|                    d|          }||         }t          d|          }|                    |           |                    dd           }	| j        }
t          ||||	          }| j        }|
j        | j        z   x| _        |_        |                    |           |	                    d           || _        d S )NrV  zrml2pdf internal embedded styler4  r5  r  r  r  r  ru   )
r  r  r0  r@  r  r  r   r'  r  r/   )r'   r  r  rt  r   	stylenamer  rV  newstyler  mystyletheparamybaseindents                r(   r  zPara.compile_para  s    ?G,KK33		"$EeTTTw'''[[t44
+x'jQQQ /6/ADO/SS','***)))&r*   )NNNNr   r,   )NNNNN)r  )rP  )(r   r   r   r)  r*  r)   rw  ry  rh  r  ru  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r  r  r  r   r#  r  r   r*   r(   r  r    ss       KJ# # # #.     
  F F FP  0  B8 8 8 8t# # # #2'V 'V 'VR   $. . .+ + +( ( (* * *: : :) ) )E E E E(O O O)^ )^ )^V* * *# # #,# # ## # # # # #,& & &? ? ?( ( (G G GR R RL L LO O OK K KP P PR R R' ' ' ' ' 'r*   r  c                       e Zd Zd ZddZdS )r  c                 0   || _         d}|                    d|          x| _        }ddd d|         }|                    d|          x| _        }d|vr4||         }dd	lm} |j        } |d
d|          }	t          |	          |d<   d| _        d| _	        d S )NrQ  rV  discr   )r  r  r  typer'  r   r   XXXr  r:   )
r  r  rV  typrv   r   r   ry   rq  _first)
r'   r  r  r  rV  r2  thestyler   rk   r   s
             r(   r)   zbulletMaker.__init__  s    !!XXgu555
U3d33G<---#t##u~H@@@@@@$D [	488F!$VD
r*   Nc                 @   | j         sd|d<   nd| _         | j        }| j        }|_|dk    rk|dk    rt          d          }nK|dk    rt          d          }n5|d	k    rt          d
          }nt	          dt          |          z            d|vrd|d<   n|dk    rd|v rt          |d                   | _        n| xj        dz  c_        |dk    rt          | j                  }n|dk    r*t          d          | j        z   dz
  }t          |          }nn|dk    r*t          d          | j        z   dz
  }t          |          }n>t	          dt          |          z            t	          dt          |          z             d|vr||d<   d|vr| j
        |d<   d S d S )Nr   r)  r   r  r/  m   circlel   squaren   z&unordered list type %s not implementedrB  ZapfDingbatsr  r?  r:   r   r8  Az&ordered bullet type %s not implementedzbad tagname r  rV  )r3  r2  r  chrr?   rJ   intrq  ry   ordrV  )r'   r  r  r2  r  theords         r(   r  zbulletMaker.makeBullet  s   { 	"%DDKh,:}};;SXX(]]SBB(]]SBB$%MPTUXPYPY%YZZZ#4//-;D)*$d??!$T']!3!3DJJJJ!OJJ88#dj//RR#XX XXdj02FVBB#XX XXdj02FVBB$%MPTUXPYPY%YZZZ W!=>>>t##!#D$ JDMMM r*   r,   )r   r   r   r)   r  r   r*   r(   r  r    s7          &$' $' $' $' $' $'r*   r  c                   .    e Zd ZdZdZd Zd Zd Zd ZdS )r  z)this will only work if rml2pdf is present
evalStringc                 F    |si }|| _         || _        || _        || _        d S r,   )r  r  r  rt  )r'   r  r  rt  r  s        r(   r)   zEvalStringObject.__init__%  s/     	G


r*   c                 X    ddl m} |                    || j        i           x}| _        |S )Nr   )
Controller)rlextra.rml2pdf.rml2pdfrE  processTupler  op)r'   r~   enginerE  rH  s        r(   getOpzEvalStringObject.getOp-  s9    666666!..udlBGGGTW	r*   c                     ddl m} | j        }|sg }| j        | j        || j        f}|                     ||          x}| _        t          |          } |||j	        |j
                  S Nr   r   )rv   r   r  r  r  rt  rJ  rH  ry   r   r   )r'   rI  r   r  r~   rH  r   s          r(   rg   zEvalStringObject.width3  s{    <<<<<<, 	Gt|WdjAzz%000TW GG{1fov???r*   c                 T    |                     t          | j                             d S r,   )r   ry   rH  r'   rI  r   r   s       r(   r   zEvalStringObject.execute@  s$    3tw<<(((((r*   N)	r   r   r   rA  r  r)   rJ  rg   r   r   r*   r(   r  r     s^        //G    @ @ @) ) ) ) )r*   r  c                       e Zd Zd ZdS )r  c                     ddl m}  |            }| j        }d|v r|d         }||z  x}| _        |S d|v r	|d         }nd }|                    |          x}| _        |S )Nr   getSequencertemplater  )reportlab.lib.sequencerrR  r  rH  nextf)	r'   r~   rI  rR  globalsequencerattrtemplrH  r  s	            r(   rJ  zSeqObject.getOpE  s    888888&,..| $E ?22BIT\\dBBB&,,R000TW	r*   Nr   r   r   rJ  r   r*   r(   r  r  C  s#            r*   r  c                       e Zd ZdZd ZdS )r  r4  c                     d S r,   r   rN  s       r(   r   zNameObject.executeX  s    r*   N)r   r   r   r  r   r   r*   r(   r  r  V  s(        G    r*   r  c                       e Zd Zd ZdS )r"  c                     ddl m}  |            }| j        }	 |d         }n# t          $ r d }Y nw xY w|                    |           d| _        dS )Nr   rQ  r  r  )rT  rR  r  r  setDefaultCounterrH  )r'   r~   rI  rR  rV  rW  defaults          r(   rJ  zSeqDefaultObject.getOp]  sz    888888&,..|	4jGG 	 	 	GGG	))'222rs   " 11NrY  r   r*   r(   r"  r"  [  s#        
 
 
 
 
r*   r"  c                       e Zd Zd ZdS )r  c                     ddl m}  |            }| j        }	 |d         }n# t          $ r d }Y nw xY w	 t	          |d                   }n	#  d}Y nxY w|                    ||           d| _        dS )Nr   rQ  r  baser  )rT  rR  r  r  r>  resetrH  )r'   r~   rI  rR  rV  rW  r  rb  s           r(   rJ  zSeqResetObject.getOpk  s    888888&,..|	dBB 	 	 	BBB		tF|$$DD	DDDb$'''rs   " 11A ANrY  r   r*   r(   r  r  i  s#            r*   r  c                       e Zd ZdZdS )r  getNameN)r   r   r   r  r   r*   r(   r  r  {  s        GGGr*   r  c                   "    e Zd ZddZd Zd ZdS )r  r1  c                     || _         d S r,   )example)r'   rh  s     r(   r)   zPageNumberObject.__init__  s    r*   c                 F    ddl m}  || j        |j        |j                  S rL  )rv   r   rh  r   r   )r'   rI  r   s      r(   rg   zPageNumberObject.width  s.    <<<<<<{4<&/JJJr*   c                 r    |                                 }|                    t          |                     d S r,   )getPageNumberr   ry   )r'   rI  r   r   ns        r(   r   zPageNumberObject.execute  s3      ""3q66"""""r*   N)r1  )r   r   r   r)   rg   r   r   r*   r(   r  r  ~  sI           K K K# # # # #r*   r  c                     ddl m} m}  G d d|           at                      a G d d|           at                      }||d<   ||d<   ||d	<   t          |d
<   t          |d<   t          |d<   t          |d<   t          |d<   dS )z8make the para the default para implementation in rml2pdfr   )MapNoderE  c                       e Zd Zd ZdS )
paraMapperc                    |\  }}}}|dz   }	|                     d|	          }	||	         }
t          d|
          }|                    |           |                     dd           }d }|sDt          |          dk    r1|d         }t	          |t
                    rd|vrt          ||          }|t          ||||	          }|S )
Nz.defaultStylerV  zrml2pdf internal styler%  r  r:   r   rU  r&  )r  r0  r@  rw   rx   ry   rS  r  )r'   	nodetuple
controllerr  	overridesr  r  r  rt  r'  rV  r)  r  r   r   s                  r(   rl  zparaMapper.translate  s    1:.Wgw/IGY77II&E!'?NNNG!!'*** \488JF 5#g,,//qzd3'' 5CtOO%gt44F~gwJWWWMr*   Nr   r   r   rl  r   r*   r(   rp  rp    s#        	 	 	 	 	r*   rp  c                       e Zd Zd ZdS )ulMapperc                 J    di |gd f}t                               ||||          S )Npara)theParaMapperrl  )r'   rr  rs  r  rt  r*  s         r(   rl  zulMapper.translate  s,    rI;5G **7JSSSr*   Nru  r   r*   r(   rw  rw    s(        	T 	T 	T 	T 	Tr*   rw  r  r  r  ry  h1h2h3titleN)rF  rn  rE  rp  rz  rw  )rn  rE  theListMappers      r(   EmbedInRml2pdfr    s    ;;;;;;;;    W   ( LLMT T T T T7 T T T JJM$Jt$Jt$Jt&Jv$Jt$Jt$Jt'Jwr*   c                    ddl m} ddlm} dddd}|dd         |v r|                    d	           	 |g }|                    d          }	d}
|	d
         }|	D ]}|
sE|                    d          }|dk    r$|d |         }|d         dk    rz	 |d         dk    rt          |dd          d          }nt          |dd                    }n# t          $ r d
}Y nw xY w|dk    rt          |          ||dz   d          z   }nd|z   }n||v rC||         }t          |t                    r|                    d          }|||dz   d          z   }nR||v rC||         }t          |t                    r|                    d          }|||dz   d          z   }nd|z   }nd|z   }|                                }|d d
         D ]}|                    |d	z              |r\|rZ|d
         |v r|                    |d
         d	z              n1|d
                                         }|r|                    |           d}
|S )Nr   )greeks)
whitespacer  r  rU  )ltgtampr:   r;   r6   ;#r!         utf8)reportlab.platypus.paraparserr  r  r  r/   r  r{   rL   findr>  r?   r=  rx   bytesdecode)rI  r   r   r  r  standardr   r!   r   amptextr   lastfragfragmentsemir4  rl  r   	sfragmentr  s                      r(   r  r    s   444444!!!!!!S,,HAaCyJs	 jjooGEr{H 0 0  	(==%%DAvv7C<<7c>> #DHb 1 1AA #DHA%   !tt#&q66(4677*;#;#&x<X%% A!(511 -HHV,, $q&''!22HHV^^tA!(511 -HHV,, $q&''!22HH  #8|HH x<NN$$	3B3 	" 	"ANN1S5!!!! 	+ 	+|z))	"c 13333 }**,, +NND***Ns   <CCCc                     d| vrd| vrt          ||           S ddlm} |                    | d          }t	          |||d|          S )	zf Paragraph(text, style, bulletText=None)
    intended to be like a platypus Paragraph but better.
    rU  r  )rW  r   	rparsexmlNentityReplacerr  )rS  r  r  parsexmlSimpler  )r   rV  r  fragsr  r  
parsedparas          r(   	Paragraphr    sn    
 $3d??$//// 	,+++++--d$-GG
EjZt]deeeer*   c                   "    e Zd ZddZd Zd ZdS )UnderLineHandlerNc                     || _         d S r,   )ri   )r'   ri   s     r(   r)   zUnderLineHandler.__init__  s    


r*   c                 "    || _         || _        d S r,   )xStartyStart)r'   r!   r"   ry  r   r   s         r(   r   zUnderLineHandler.start_at  s    r*   c                    |j         dz  }|                                 | j        }| j        |j        }|                    |           |                    | j        | j        |z
  |||z
             |                                 d S )Ng       @)	r   	saveStateri   r    setStrokeColorrX   r  r  restoreState)r'   r!   r"   ry  r   r   offsetri   s           r(   r   zUnderLineHandler.end_at  s    s"
:NEe$$$DKV!3Qqx@@@r*   r,   )r   r   r   r)   r   r   r   r*   r(   r  r    sF                 r*   r  c                        e Zd Zd Zd Zd ZdS )r  c                     || _         d S r,   )r  )r'   r  s     r(   r)   zHotLink.__init__%  s    r*   c                     |j         }| j        | j        |||z   g}t          rt	          d|           |                     ||           d S )NzLINKING RECTANGLE)r   r  r  rH   rI   link)r'   r!   r"   ry  r   r   r   rects           r(   r   zHotLink.end_at(  sR    =T[!AhJ7 	-%t,,,		$r*   c                 @    |                     | j        |d           d S )Nr:   )relative)linkURLr  )r'   r  r   s      r(   r  zHotLink.link0  s"    tx22222r*   N)r   r   r   r)   r   r  r   r*   r(   r  r  #  sA               3 3 3 3 3r*   r  c                       e Zd Zd ZdS )r  c                 J    | j         }d}|                    |||d           d S )Nr  z[0 0 0])Border)r  linkRect)r'   r  r   destinationnamecontentss        r(   r  zInternalLink.link5  s.    (/4	JJJJJr*   N)r   r   r   r  r   r*   r(   r  r  3  s(        K K K K Kr*   r  c                       e Zd ZdZd ZdS )r  r   c                 p    | j         }| j        s'|\  }}}}|                    |||           d| _        d S d S )Nr:   )r  definedbookmarkHorizontal)r'   r  r   r  r!   r"   x1y1s           r(   r  zDefDestination.link>  sM    (| 	!NQ2r%%oq"===DLLL	 	r*   N)r   r   r   r  r  r   r*   r(   r  r  :  s(        G    r*   r  c                 l    |                                  }g }|D ]}|                    |dz              |S )Nr;   )r  r/   )r   r  r   r   s       r(   
splitspacer  E  sA    JJLLE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                    ddl m} ddlm} ddlm} |                    |d           } |dd           }t          ||          }|                    d|z  d|z            \  }}	t          d	|	|f           | 
                                 |                     d
|z  d
|z             |                     ddd|z  d|z  dd
           | |_        | 
                                 |                                 |                                  |                     d
dd           |                     dd||	dd
           |                                  |                                  d S )Nr   inch)ParagraphStyler  r  rK     r   z
wrapped asr:   )fillstroke)reportlab.lib.unitsr  r~  r  r  r  r  r  rh  rI   r  rl  r  rk  ru  r  setStrokeColorRGBshowPage)
rk  testparar  r  r  r  SPr  r   s
             r(   test2r    s   ((((((333333''''''))($)GGJx&&AQ
AVVAdFBtG$$FQ	,1NNNN1T61T6"""IIa!D&DqI333AFNNFFHHH1a###IIa!AAaI(((MMOOOOOr*   zhttp://www.reportlab.comr  )r   d   )r      )rp   zvery long bullet2   r     rr   rj   )rk   r   )r   r  z1This is the first segment of the first paragraph.rs   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. rt   ru   )rp   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. )rp   z"Bullet not quite as long this timer  r  r  )rj   zHelvetica-Oblique)ri   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  )rp   Or  r  r  )rj   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                  `   ddl m }  ddlm} ddlm} d}|                    |          }t          |t                     t          |t                     	 t          t          z   t          z   }i }|rt          d           |                    |d|z             |                                }|                    dd           t                      }|                    |           d|_        d|_        d	|z  }	d
}
|                    |	|
|          \  }}}}t&          r | |           |                    |||          }|                    |           |                                 t          dd|d         d|d                    ||                                 t          |           d S )Nr   )pprint)r   r  zparatest0.pdfr:   zNEW PAGEr     i  z==============================zx=r!   zy=r"   )r  reportlab.pdfgenr   r  r  Canvasr  testparagraphtestparagraph1test_programrI   rl  rm  r   r   re   r!   r"   r`   rH   r   rn  r  save)r  r   r  r  ro  rP   r^   r  r  rM   rN   formattedprogramr[  s                r(   testr  	  s   ''''''((((((	BbA	!M	!NF </,>		 	F*KKaf%%%AOOAa   !!ALL###ACACvHI?@xxR[]f?g?g<y)V +(***%5q!<<IJJqMMMJJLLL&$	#inEEE#  	F$ FFHHH	"IIIIIr*   __main__r,   r,  )<rA  rv   r   reportlab.lib.rl_accelr   reportlab.platypus.flowablesr   r  r   r~  r	   rH   r  r>   r$   r
   r   r   r   r   rB   rF   r   r   r   r   r  r  r$  r&  r0  r  rS  r  r  r  r  r  r  r  r"  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  testlinkr  r  r   r   r*   r(   <module>r     s  ; ;x 5 4 4 4 4 4 ) ) ) ) ) ) 1 1 1 1 1 1             . . . . . .
 	
 H H H H H H H H H H H Hg g g g g g g gR    ( ' & & & & &O O O	 	 	# # #4 !+      ,       !* !* !* !* !* !* !* !*J "!!!!!!'!&$#  a% a% a% a% a%x a% a% a%F     (s' s' s' s' s'8 s' s' s'j8' 8' 8' 8' 8' 8' 8' 8't!) !) !) !) !) !) !) !)F        &    !   
    z       Z   $    $   # # # # # # # #*( *( *(XJ J J JXf f f f         	3 3 3 3 3 3 3 3 K K K K K7 K K K	 	 	 	 	W 	 	 	  `D@  . 7-.. (Ei(]+ #	 #
#VWW	X %h/[ !j  "t  u  uu (2#g&:]+ #x& #
  $d  e  e'e( $j)V1 #$	h'8 #
#Y ' '9'< %i0*;> #
  $n  o  o?o@ (3w!w#'#h'6) #!r?0` #
  $A	  B	  B	a0B	b E	a2h  B ZDFFFFF r*   