%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/reportlab/platypus/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/reportlab/platypus/__pycache__/para.cpython-312.pyc

�

��dIk���dZddlmZddlmZddlmZddlmZddl	m
Z
dZdZdZ
ddlmZmZmZmZGd	�d
�Zd�Zd�Zdd
lmZd�Zd�Zd�Zefd�Zd�ZGd�d�ZGd�d�Zdddddddddd d!d"d#d$�
ZGd%�d&e�Z d'�Z!dmd)�Z"Gd*�d+e�Z#Gd,�d-�Z$Gd.�d/�Z%Gd0�d1e%�Z&Gd2�d3e%�Z'Gd4�d5e'�Z(Gd6�d7e'�Z)Gd8�d9e%�Z*Gd:�d;�Z+d<�Z,dmd=�Z-dnd>�Z.Gd?�d@�Z/e/�Z0GdA�dBe/�Z1GdC�dDe1�Z2GdE�dFe1�Z3dG�Z4dHZ5dIZ6dJ�Z7e1dK�Z8dLdMdNdOdPefdQe
fdRdSge4dT�zdUe8fgze4dV�zdWe8fdXdPefdYdQe
fdRdSgze4dZ�zdXdPefd[d\dRdSdLd]gze4d^�zdUe0fgze4d_�zdWe0fd`dadbdcdddbd`dedbdfdMdgdXdPefdhdidRdSgze4dj�zdfdXgzZ9dk�Z:e;dlk(re:�y(y()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)�
_baseFontNameg�h㈵��>)�TA_LEFT�	TA_CENTER�TA_RIGHT�
TA_JUSTIFYc�h�eZdZdd�ZdZd�Zd�Zdd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zy)�paragraphEngineNc���ddlm}|�g}g|_||_dx|_|_d|_d|_d|_d|_	||_
dx|_x|_|_
ddlm}||_g|_y)Nr��black��	Helvetica�
�)r
)�reportlab.lib.colorsr�lineOpHandlers�program�indent�rightIndent�
baseindent�fontName�fontSize�leading�	fontColor�x�y�rise�reportlab.lib.enumsr
�	alignment�textStateStack)�selfrrr
s    �9/usr/lib/python3/dist-packages/reportlab/platypus/para.py�__init__zparagraphEngine.__init__Wsw��.��?��G� ������),�,���d�&����#��
���
�������&)�)���)���$�)�/� ��� ���)	rrrrrr rr#r%c��g}|jD]}t||�}|j|��!|j|gz|_|S�N)�TEXT_STATE_VARIABLES�getattr�appendr&�r'�state�var�vals    r(�
pushTextStatezparagraphEngine.pushTextStatemsR�����,�,�	�C��$��$�C��L�L���	�#�1�1�5�'�9����r*c��|jd}|jdd|_|dd}|jD]}|d}|d=t|||��y)N���r)r&r-�setattrr0s    r(�popTextStatezparagraphEngine.popTextStatexsc���#�#�B�'��"�1�1�#�2�6����a����,�,�	$�C���(�C��a���D�#�s�#�	$r*c�8�|jj�}|dd}g}|}|r||_d}	d}
|�r"|	�r|j}|j}||z
|z
}
|jj�}|
t
kr(t
d|j�d|j�d|����	|j||�\}}}}}}}|
|z}
|j}||kDr||z
}nd}	|jj|��n^|j}||d}|s|d=|tk(r!|r
t||�}n|j|�}n�|tk(r4|r
t||�}n|j|�}|j|||�}n�|tk(r4|r
t||�}n|j|�}|j!|||�}nz|t"k(rZ|r&|r$|rt%|||�}n]|j'|||�}nI|r
t||�}n|j|�}t(r#t+d�nt
d	t-|�z��|s|j/|�}|j1|�|r|	r��|jj�}|jj|�||z
}||||fS#�xYw)
zCreturn program with line operations added if at least one line fitsN�rzindents � z too wide for space r6z2no justify because line is not full or end of parazbad alignment )�__dict__�copyrrr�
TOOSMALLSPACE�
ValueError�fitLine�updater%r
�
stringLine�
shrinkWrapr�centerAlignr�
rightAlignr
�simpleJustifyAlign�justifyAlign�debug�print�repr�cleanProgram�extend)r'�maxwidth�	maxheightrr�
startstate�	remainder�lineprogram�heightremaining�room�cursorcountrr�	linewidth�beforelinestate�
lineIsFull�line�cursor�
currentLength�
usedIndent�	maxLength�justStringsr%�	laststate�
heightuseds                         r(�formatzparagraphEngine.format�s����]�]�'�'�)�
��A�J�	���$���7�D�L������D��[�[�F��*�*�K� �6�)�K�7�I�"�m�m�0�0�2�O���&� �$�+�+�W[�Wg�Wg�KS�"U�V�V�
�7;�|�|�I�x�7X�5��T�6�=��Y��&�f�,�K��l�l�G��w�&�"1�'�"9�����
�
�$�$�_�5�����I�"�&�'�*�I����H��'�!��%�d�M�:�D��?�?�4�0�D���I�%��%�d�M�:�D��?�?�4�0�D��'�'��m�Y�G���H�$��%�d�M�:�D��?�?�4�0�D����t�]�I�F���J�&���"�1�$�
�y�Q��#�0�0��}�i�P��"�)�$�
�>��#���t�4����R�S� �!1�$�y�/�!A�B�B���(�(��.�����t�$�s�D�t�M�M�&�&�(�	��
�
���Z�(���0�
��Y�	�:�>�>��c
��s�#J�Jc�6�|jj�Sr,)r<r=�r's r(�getStatezparagraphEngine.getState�s���}�}�!�!�#�#r*c�:�|jj|�yr,)r<rA)r'r1s  r(�
resetStatezparagraphEngine.resetState�s���
�
���U�#r*c���ddlm}|j}||z
|jz
}d}g}d}d}	d}
t	|�}d}d}
d}|j
}|j}|d||�}d}|�sd||k�r^||}t|t�st|d�r�|}d}t|d�rd}|j|�}d}n2|}|j�}|r||||�}nd}|r
|s|
r	|ddk(}nd}|}|r||z}|
|z}||kDr|
sd}d}	nL|r|j|�|r|j|�t|�tkDr|j|�|}
d}
�nkt|t�rFd}t|�}|tkD�rD|
|z}||kDr|
sd}n|tkDr|}
|j|�d}
�nt|t ��r�d}|d}|dk(r|j|�|dz
}dx}}�n�|d	k(rU|j"}|\}}t|t�rt%t&|�x}|_n	|x}|_|j|��n�|d
k(r+|\}} | x}|_|d||�}|j|��nR|dk(r�|\}}!tt|!��}"t|!t�rH|!dddk(r|j|"zx}|_n2|!ddd
k(r|j|"z
x}|_n|"x}|_n	|"x}|_|d||�}|j|��n�|dk(r|\}}#|#|_|j|��n�|dk(rN|\}}$|j|$zx}%|_|
rt+|%|�}||z
|jz
}|j|��n?|dk(r#|j-�|j|��n|dk(rF	|j/�|j
}|j}|d||�}|j|��n�|dk(r�|\}}&}%}'}"|%|j0z}%||&|%|'|"f}|
st3d��t||&|'|"��}(t|d|'|"��}|%|z|(z})t+|)|�}|
r||z
|jz
}|j|��n;|dk(r?|\}}$|j|$z|_|
r||z
|jz
}|j|�n�|dk(r-|\}}*|j4|*zx}+|_|j|�n�|dk(r|\}},|,|_|j|�n�|dk(r,|\}}-|j|�|j8|-gz|_nq|dk(r>|\}}-|j8dd}.|.j;|-�|.|_|j|�n.t3dt=|�z��t3dt=|�z��|s|dz
}|s||kr��^|s|jd�|	|||
|||fS#�xYw)z(fit words (and other things) onto a linerrr:Nr;�widthr6�nextLine�color�face�size�+�-rr�push�pop�bullet�bullet not at beginning of linerr#�align�
lineOperation�endLineOperationz*at format time don't understand indicator z-op must be string, float, instance, or tuple �rhr)�reportlab.pdfbase.pdfmetricsrrr�lenrr�
isinstance�str�hasattrrg�stripr/�absr>�float�tupler r.rr�maxr4r8rr?r#r%r�removerJ)/r'r�totalLengthrr[r\�donerXrYrWrZ�	maxcursor�	needspace�first�
terminatedrr�
spacewidthr]�opcode�
lastneedspacerg�
saveopcode�	fullwidth�	newlength�aopcode�
nextLength�	indicator�oldcolor�i�	colornameri�fontname�fontsizerkr�	incrementrrp�font�bulletwidth�	bulletminr#�newriser%�handler�hs/                                               r(r@zparagraphEngine.fitLine�sd��	=��[�[�
��*�,�t�/?�/?�?�	��������
��
���L�	��	����
��=�=���=�=�� ��h��9�
����6�)�+��V�_�F��&��%����)@� )�
��	��6�'�*�"#�K�"�L�L��.�E� !�I�!'�J�#�\�\�^�F�� +�F�H�h� G�� !��!�u�
�%/��^�S�%8�	�$%�	�!�	� � %�
� 2�I�)�)�3�	��Y�&�u�
�D�!"�J�%����Z�1�����V�-��5�z�-�/����e�V�-�(1�
����F�5�)����f�+���=�(�!.�w�!6�J�!�)�+�E� ��"�=�0�,6�M� �K�K��/��E��F�5�)���"�1�I�	��j�(��K�K��'��a�K�F�()�)�J����'�#�~�~�H�%+�N�Q�	�!�)�C�0�18���1K�K����1:�:�����K�K��'���&�$*�M�Q��/7�7�H�t�}�!,�S�(�H�!E�J��K�K��'���&�$*�M�Q���u�X��/�D�!�(�3�/�#�B�Q�<��,�7;�}�}�t�7K�K�H�t�}�%�b�q�\�3�.�7;�}�}�t�7K�K�H�t�}�7;�;�H�t�}�37�7��4�=�!,�S�(�H�!E�J��K�K��'��	�)�#)�L�Q��#*�D�L��K�K��'���(�%+�N�Q�	�+/�;�;��+B�B�F�T�[��%(���%<�
�$/�*�$<�t�?O�?O�$O�	��K�K��'���&��&�&�(��K�K��'���%���)�)�+� $�}�}�H�#�}�}�H�!,�S�(�H�!E�J��K�K��'���(�6<�3�Q����d�#�d�o�o�5�F�����t�<�F� �(�)J�K�K�"'��F�D�$�(G�"H�K�!&�{�3��d�'C�!D�J� &�z� 1�+� =�I�!$�Y�
�!;�J��$/�*�$<�t�?O�?O�$O�	��K�K��'��
�-�%+�N�Q�	�'+�'7�'7�	�'A�D�$��$/�*�$<�t�?O�?O�$O�	��K�K��'���&� &�I�Q��*.�)�)�D�.�8�G�d�i��K�K��'���'�%+�N�Q�	�&/�D�N��K�K��'���/�#)�L�Q���K�K��'�*.�*=�*=��	�*I�D�'�� 2�2�#)�L�Q���+�+�A�.�A��H�H�W�%�*+�D�'��K�K��'�%�%Q�RV�W`�Ra�%a�b�b� �!P�QU�V\�Q]�!]�^�^���!���i�6�)�+�v��K�K��*��D�&�-��Y�P[�\�\��K��s�*W'�'W*c�P�||z
}|dz}|tkDr|j||�S|S)N�@�r>�insertShift)r'rX�
lineLengthr\�diff�shifts      r(rDzparagraphEngine.centerAlign�s5����#���S�������#�#�D�%�0�0��r*c�F�||z
}|tkDr|j||�S|Sr,r�)r'rXr�r\r�s     r(rEzparagraphEngine.rightAlign�s,���*�$������#�#�D�%�0�0��r*c��g}d}|D]D}|r/t|t�st|d�r|j|�d}|j|��F|S)Nr:rgr)rxryrzr/)r'rXr��resultr��es      r(r�zparagraphEngine.insertShift�sT�������	�A��*�Q�s�+�w�q��/A��
�
�e�$����M�M�!��		�
�
r*c���||z
}d}d}d}|D]G}t|t�r|tkDr|r|dz
}�$|s�'t|t�s
t	|d�s�Dd}d}�I|dkr|S|t|�z}	|	tkr|Sd}d}g}
d}t|�}||krg||}|
j
|�|rt|t�st	|d�rd}n%t|t�r|tkDr|r
||	z}
|
|
d<|dz
}||kr�g|
S)Nrr:rgr6)rxr}r>ryrzrwr/)r'rXr�r\r��
spacecount�visibler�r�r�r�rY�nline�expandeds              r(rGzparagraphEngine.justifyAlign�s����#���
������	�A��!�E�"�q���7��a��
��J�q��-���7�1C�����	��a�<��K��U�:�&�&���-���K����������D�	���U�l��V��A��M�M�!���*�Q�s�+�w�q��/A����A�e�$��=��W��U�7��%��r�
��a�K�F��U�l��
r*c�t�g}d}t|�}||k�r"||}t|t�r�||dz
kr�|g}d}|dz
}||}||kr�t|ttf�r|t|t�r |dkr|dkDr|}|dkr|dkDr|}||z
}n!t|t�r|j	|�|dz
}||kr||}||krt|ttf�r�|dj|�}	|j	|	�|j	t|��|dz}n|j	|�|dz
}||kr��"|S)Nrr:rr;)rwrxryr}r/�join)
r'rXr��index�maxindexr��
thestrings�	thefloats�nexte�ss
          r(rCzparagraphEngine.shrinkWrap*sJ�������t�9���H�n��U��A��!�C� �U�8�A�:�%5��S�
��	���
���U����H�n��E�5��+�)F�!�%��.�$�Q�;�5��7�)2�
�I� ��7�y��{�%*�F�E�!�U�*�	�#�E�#�.�"�)�)�%�0��Q�J�E��X�~� $�U����H�n��E�5��+�)F��H�H�Z�(���
�
�a� ��
�
�e�I�.�/���
���
�
�a� ��Q�J�E�;�H�n�>�
r*c���g}d}|D]q}t|t�r)|dkr|dkDr|}|dkr|dkDr|}t|�|z}�<t|�tkDr|j	|�|j	|�d}�s|r|j	|�d}tt
t|�dz
��}|r�d}|D]�}|dz}||}	||}
d}t|	t�s(t|
t�st|	d�st|
d�rd}nUt|	t�rE|	d}t|
t�r|
d}
d}|
dk(r$|dk7r|dk7rd}nt|
t�r|dk(rd}|s��|
||<|	||<d}��|r��|S)zcollapse adjacent spacingsrr:rgrtrs)rxr}r|r>r/�list�rangerwryrzr~)r'rXr��lastr��change�rliner��	nextindex�this�next�doswap�
thisindicator�
nextindicators              r(rKzparagraphEngine.cleanProgramPs��������	�A��!�E�"���6�a��c� �5�D��Q�3�4��6���A��T�{�1�}���t�9�]�*��M�M�$�'��
�
�a� ���	���M�M�$�����U�3�v�;�q�=�)�*����F��
��!�!�G�	��e�}���i�(�����d�3�'��d�3�'��4��(�G�D��,A��F���U�+�$(��G�M�!�$�u�-�(,�Q��
�!"��)�+=�=�-�Qc�Bc� -�� >�%&�F�#�D��/�(�/�9�%&�F��$(�F�5�M�(,�F�9�%��F�5
��<�
r*c	��|j}|j}|jj�}d}d}|j	|j
�|j}	|j}
|j}d}|D�]Z}
t|
t�s
t|
d��r|st|
�tkDr3|jdt|
d�z�|xj|
z
c_|j D]+}|j#|j|j$|||��-d}||j&k7s||j(k7r*|j&}|j(}|j+||�t|
t�r|j-|
���|
j/|||���$t|
t0�rKt|
�}
|
tkDs��J|jdt|
d�z�|xj|
z
c_��t|
t2��r�|
d}|dk(r�|
\}}|j}|j$}|j$|j4z
x}|_|	x}|_|j}
|j}d}|j D]}|j7|||||��|j9||���4|dk(r\|j
}|
\}}t|t�rt;t<|�x}|_n	|x}|_||k7s���|j	|����|dk(r|
\}}||_���|d	k(r�|
\}}tt1|��}t|t�rD|ddd
k(r|xj(|z
c_n-|dddk(r|xj(|zc_n||_n||_|j(}|j+|j&|j(���U|dk(r|
\}}||_��h|d
k(r)|
\}}|j|zx}|_t?|
|�}
���|dk(r|jA����|dk(rb|j
}|j&}|j(} |jC�||j
k7s���|j	|j
���|dk(r|
\}}!|jE|!���1|dk(r�|
\}}"}}}t|j|	z
�tkDrtGd��t1tI|"||��}#t1tId||��}$||$z|#z}%|%|
kDr|%}
|jK|d�|j+||�|j-|"�|jK|d�|j+|j&|j(���|dk(r|
\}}|j|z|_��3|dk(r.|
\}}&|jL|&zx}'|_&|jO|'���f|dk(r|
\}}(|(|_(��y|dk(rE|
\}}|j#|j|j$|||�|j |gz|_���|dk(rg|
\}}|j7|j|j$|||�|j ddx})|_||)vr|j jS|���-��/tGdtU|�z��tGdtU|
�z��|jj�}*|jjW|�|*S)zrender the line(s)Nrrgz%s Tdr:rhrirjrkrlrmrrrnro�wordSpacingrprqr;rr#rrrsrtzdon't understand indicator z!op must be string float or tuple ),�_escape�_coder<r=�setFillColorr r!rrrxryrzr|r>r/rr�start_atr"rr�setFont�textOut�executer}r~r�end_at�
setTextOriginr.rrr4r8�setWordSpacer?r�
moveCursorr#�setRiser%r�rJrA)+r'r�canvas�
textobject�escape�coderOr�rk�xstart�thislineindent�thislinerightIndent�indentedr�r�r�r��endallmarksr!r"�newy�newxr�r�rir�r�rrr�r�oldfont�oldsize�wsrpr�r�r�r#r�r%�newhr^s+                                           r(�
runOpCodeszparagraphEngine.runOpCodes�sp�����������]�]�'�'�)�
�����	������/���������"�.�.�����X	S�F��&��%�'�&��*A���>�*�=�8����G�f�^�Q�.G�$G�H����.�0��#'�#6�#6�S���(�(��������v�z�R�S�������&�$��
�
�*=��=�=�D��=�=�D��&�&�t�T�2��f�S�)��&�&�v�.��N�N�4��V�<��F�5�)��V����-�'��K�K��&���*;� ;�<��F�F�f�$�F��F�5�)�"�1�I�	��j�(�'-�$�Q�����A����A�$(�F�F�4�<�<�$7�7�D�4�6�$*�*�D�4�6�%)�[�[�N�*.�*:�*:�'� �H�#'�#6�#6�G�����q�!�T�6�:�F�G��,�,�T�4�8���'�#�~�~�H�%+�N�Q�	�!�)�C�0�18���1K�K����1:�:�����h��"�/�/��6���&�$*�M�Q��$,�D�M���&�$*�M�Q���u�X��/�D�!�(�3�/�#�B�Q�<��,� �M�M�T�1�M�%�b�q�\�3�.� �M�M�T�1�M�,0�D�M�(,��
�#�}�}�H��&�&�t�}�}�d�m�m�D��	�)�#)�L�Q��#*�D�L���(�%+�N�Q�	�+/�;�;��+B�B�F�T�[�%(���%@�N���&��&�&�(���%�#�~�~�H�"�m�m�G�"�m�m�G��%�%�'� ����/�"�/�/����?��
�-�$�G�Q���+�+�B�/���(�6<�3�Q����d��4�6�6�&�=�)�-�7�(�)J�K�K�"'��F�D�$�(G�"H�K�!&�{�3��d�'C�!D�J� &�z� 1�+� =�I� �>�1�)2���)�)�&�!�4��&�&�t�T�2��&�&�v�.��)�)�6�'�1�5��&�&�t�}�}�d�m�m�D��
�-�%+�N�Q�	�'+�'7�'7�	�'A�D�$���&� &�I�Q��*.�)�)�D�.�8�G�d�i��&�&�w�/���'�%+�N�Q�	�%.�D�N���/�#)�L�Q���$�$�T�V�V�T�V�V�T�6�:�N�+/�*=�*=��	�*I�D�'�� 2�2�#)�L�Q���N�N�4�6�6�4�6�6�4���L�15�1D�1D�Q�1G�G�D�4�.��$���+�+�2�2�7�;��%�%B�4�	�?�%R�S�S� �!D�T�&�\�!Q�R�R�qX	S�r�M�M�&�&�(�	��
�
���Z�(��r*r,)r)�__name__�
__module__�__qualname__r)r-r4r8r`rcrer@rDrEr�rGrCrKr��r*r(rrUsY��!�")��
	�
$�l?�\$�$�R]�h��	�!�~$�L?�Bkr*rc���g}|D]$}t|t�s�|j|��&dj|�}|t	|�g}d}|r|d|k(r|j|�|S)zEsimple case: line with just strings and spacings which can be ignoredr;rur6)rxryr/r�r})rX�length�stringsr!�textr��nextlinemarks       r(rBrB>sp���G�
����a����N�N�1����8�8�G��D��E�&�M�
"�F�"�L���R��,�&��
�
�|�%��Mr*c�0�g}|ddD]$}t|t�s�|j|��&t|�dz
}||z
}dj	|�}|dkDr|dkDr|t|�z}d|f||dg}	n||dg}	d}
|r|d|
k(r|	j|
�|	S)	z&simple justification with only stringsNr6r:r;rr�)r�rru)rxryr/rwr�r})rXrZr\r�r!�nspaces�slackr��wordspacingr�r�s           r(rFrFLs����G�
�#�2�Y����a����N�N�1����'�l�1�n�G��m�#�E��8�8�G��D��q�y�U�1�W��E�'�N�*�� �+�.��i�AS�T���
��7��"�L���R��,�&��
�
�|�%��Mr*rc�j�|j�dvry|j�dvrytd|z��)N)�Y�YES�TRUE�1r:)�N�NO�FALSE�0rz+true/false attribute has illegal value '%s')�upperr?)r�s r(�readBoolr�bs7���z�z�|�0�0��	
����2�	2���F��M�N�Nr*c�z�|j�}|dk(rtS|dk(rtS|dvrtS|dk(rtSy)N�LEFT�RIGHT)�CENTER�CENTRE�JUSTIFY)r�r
rrr
)r��ups  r(�
readAlignmentr�jsF��	
����B�	�V�|���	�w����	�#�	#���	�y����
r*c�T�|j�}	t|�S#t$r�|j�}|dd|dd}}|j�}	t|�}n#t$rtd|z��wxYw	ddddd�|}n#t$rtd|z��wxYw||zcYSwxYw)	zIRead a dimension measurement: accept "3in", "5cm",
    "72 pt" and so on.N���zinvalid length attribute '%s'�Hg^|�b�X<@g��j�Z�@r:)�in�cm�mm�pt)r{r}r?�lower�KeyError)r��
numberText�units�number�
multipliers     r(�
readLengthrus����:�:�<�D�#��T�{����#��z�z�|�� ��"�I�d�2�3�i�E�
��%�%�'�
�	E��:�&�F���	E��<�t�C�D�D�	E��	E��"�"��	�
��J���	E��<�t�C�D�D�	E���
�"�"�%#�s?�
�3B'�A�B'�A5�5B'�9
B�B'�B�B'�&B'c���|j�}|dddk(r
|dddk(r|dd}|jd�}|D�cgc]}|j���}}|D�cgc]
}||���}}|Scc}wcc}w)z0from "(2, 1)" or "2,1" return [2,1], for exampleNr:�(r6�)�,)r{�split)r��	converter�sls   r(�lengthSequencer�s{��	���	�A���!�u�c�z�a���f�c�k�
�a��G��	
�����B��	 ��!�'�'�)�	 �B�	 � "�	#�1�)�A�,�	#�B�	#�
�I��
!��	#s�A+�A0c�t�|syddlm}ddlm}|d|vr|j|St|�}d}dt
|�cxkrdksJ|��J|��d}tt
|��D]}||d	kr�J|��t
|�dk(r
|j}nt
|�dk(r|j}|�S)
zCRead color names or tuples, RGB or CMYK, and return a Color object.Nrr)�lettersz:Color tuple must have 3 (or 4) elements for RGB (or CMYC).��z*Color tuple must have all elements <= 1.0.��?)
�
reportlab.libr�stringrr<rrwr��Color�	CMYKColor)r�rr�tup�msgr��colClasss       r(�	readColorr �s�����$���A�w�'�����t�$�$�
��
�C�
F�C���C���A��"�s�"��"�s�"��
6�C�
�3�s�8�_�"���1�v��}�!�c�!�}�"��3�x�1�}��<�<��	�S��Q���#�#���S�>�r*c�T�eZdZegZegZegZegZegZe	gZ
egZegZegZ
egZegZegZy)�StyleAttributeConvertersN)r�r�r�rrr�
leftIndentr�firstLineIndentr�r%�spaceBefore�
spaceAfter�bulletFontSize�bulletIndentr �	textColor�	backColorr�r*r(r"r"�sV���\�H�
�L�G��|�J���K��L�O��o�I���K��|�J��<�N���L��k�I��k�Ir*r"c�Z�eZdZdZdZeZdZdZdZ	dZ
dZeZ
dZdZeZdZdZeZdZd	d�Zd�Zy)
�SimpleStylez6simplified paragraph style without all the fancy stuff�basicrrrNc��|j}|r'|jj�D]
\}}|||<�|j�D]
\}}|||<�yr,)r<�items)r'�name�parent�kw�mydict�a�bs       r(r)zSimpleStyle.__init__�sY����������,�,�.�
���!���q�	�
��8�8�:�	�C�A�a��F�1�I�	r*c��|j�D]B}||}|��tt|�rtt|�d}||�}t	|||��Dy�Nr)�keysrzr"r.r7)r'�
dictionary�key�valuers     r(�
addAttributeszSimpleStyle.addAttributes�sZ���?�?�$�	*�C��s�O�E�� ��3�S�9� '�(@�#� F�q� I�I�%�e�,�E���c�5�)�
	*r*r,)r�r�r��__doc__r0r	rrrr#rr$r
r%r%r&�bulletFontNamer'r(rr)r*r)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)
zh1.defaultStylezh2.defaultStylezh3.defaultStylezh4.defaultStylezh5.defaultStylezh6.defaultStyleztitle.defaultStylezsubtitle.defaultStyle�para.defaultStylezpre.defaultStylezul.defaultStylezol.defaultStyle�li.defaultStylec�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�FastParazAparagraph with no special features (not even a single ampersand!)c�L�d|vrtd��||_||_d|_y)N�&zno ampersands please!)r?�style�
simpletext�lines)r'rRrSs   r(r)zFastPara.__init__�s-���*���4�5�5���
�$�����
r*c���|j}||_|j}|j}|j}|j}|j
}|j}	|j}
|j}|j�}g}
ddl
m}|d|	|
�}g}d}||z
|z
}||z
|z
}||kr
||z|z|fS||kr||fS|j��d}d}t|�}d}||kr�|s�|}|
s|}||}|||	|
�}|r||z}||z}|r||kr|dz
}|}|j|�n?|
jdj|�|t|�f�g}d}||z}||z|kDrd}||kr|s��|r3|s1|
jdj|�|t|�f�||z}|
|_||_dj||d�x}|_nd}|j }|j}
|r	|||zf}|S||f}|S)Nrrr;r:)rS�availableWidthrRrr#rrrr$rrvrrTrwr/r��heightrP)r'rV�availableHeightrSrRr�rr#rr�rk�firstindent�wordsrTrr��currentline�
currentlength�firstmaxlength�	maxlengthr_rY�nwordsr��
thismaxlength�thisword�thiswordsize�
nextlengthrPr�s                              r(�wrapz
FastPara.wrap�s[���_�_�
�,����
�
�������'�'���%�%�
��-�-���~�~���~�~���+�+��� � �"����<� ��d�D�1�
����
�'�+�5��C��"�[�0�:�=�	��Z���{�*�;�6��H�H��7�"�"�G�,�,��:�:���J��F���Z�F��D���-�� )�
��$2�M� ��=��*�8�T�4�@�� �#/�
�#:�L�*�\�9�
�$�
�9�(<��a�K�F�$.�M��&�&�x�0��L�L�3�8�8�K�#8�-��[�IY�"Z�\�"$�K�$%�M�!+�G�!3�J�!�'�)�/�9� ��-��-��.�T����s�x�x��4�m�S��EU�W�X�'��/�
��D�J�$�D�K�),���%���.�)A�A�I����I����J��J�J�E��$�o�g�&=�>�F��
�%�j�1�F��
r*c��|j}|j}||krgS|j}|�td��|j}|rt||�}||gS|gS)Nzmust wrap before split)rRrrTr?rPrO)r'rVrXrRrrTrPr�s        r(rzFastPara.splitFsd���
�
���-�-���7�"��I��
�
���=��5�6�6��N�N�	���E�9�-�D���;���6�Mr*c���|j}|j}|j}|j}|j}|j
}|j}|j}|j}	|j}
|
j}|j}|
jd||z
�|
j�}
|
j}|
j||�|j r|
j#|j �d}d}|j$|z
}d}t'|�}||kr�||\}}}|dz
}|}|r|	}|t(k(r|}nl|t*k(r||z
}||dzz}nU|t,k(r||z
}||z}nA|t.k(r8|}||kr |dkDr|
j1||z
|dz
z�n|
j1d�|
j3|�|
j5|�||z
}||kr��|
j7|
�y)Nrr:r�rr)rRrTrr#rrrr%r$�canvr�rW�	translate�	beginTextr�r�r)r�rVrwr
rrr
r�r�r��drawText)r'rRrTrr#rr�rkr%rY�cr�rWr�r�r�r"�
basicWidth�count�nlinesr�r�r_�
thisindentr!�extras                          r(�drawz
FastPara.drawUs����
�
���
�
���'�'���%�%�
��-�-���~�~���~�~���O�O�	��+�+���I�I����������	
���A�v�d�{�#��[�[�]�
��������4��&��?�?��#�#�E�O�O�4���
���(�(�;�6�
����U����F�l�%*�5�\�"�T�6�6��Q�J�E�#�J��(�
��'�!����I�%�"�V�+����s��*���H�$�"�V�+����&���J�&�����<�F�1�H��+�+�Z��->����,L�M��+�+�C�0��$�$�Q�q�)����t�$��'�	�A�/�F�l�0	
�
�
�:�r*c�.�|jjSr,)rRr%rbs r(�getSpaceBeforezFastPara.getSpaceBefore�s���z�z�%�%�%r*c�.�|jjSr,)rRr&rbs r(�
getSpaceAfterzFastPara.getSpaceAfter�s���z�z�$�$�$r*N)
r�r�r�r=r)rdrrqrsrur�r*r(rOrO�s&��G��F�P
�5�n&�
%r*rOc�l�i}ddlm}|�}tj�D]
\}}||||<�|S�Nr)�getSampleStyleSheet��reportlab.lib.stylesrx�DEFAULT_ALIASESr/)r�rx�styles�stylenamekey�stylenamevalues     r(�defaultContextr�sC��
�F�8�
 �
"�F�(7�(=�(=�(?�6�$��n�%�n�5��|��6��Mr*Nc�(�i}ddlm}|�Rtj�D]\}}||vs�||||<�tj�D]\}}||vs�||||<�|�}tj�D]\}}||vs�||vs�||||<�|Srwry)�
stylesheetr�rxr}r~r|s      r(�buildContextr��s���
�F�8���,;�,A�,A�,C�	@�(�L�.��z�)�'1�,�'?��|�$�	@�-<�,A�,A�,C�	B�(�L�.���+�'1�.�'A��|�$�	B�!�
"�F�(7�(=�(=�(?�:�$��n��v�%�.�F�*B�#)�.�#9�F�<� �:��Mr*c���eZdZdZdZd&d�Zd�Zd�Zd�Zd�Z	d�Z
d'd	�Zd(d
�Zd�Z
d)d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd*d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d+d%�Z'y),�PararNc�<�||_t|�|_||_||_||_g|_g|_d|_||_	|s"|j|_
|j|_d|_d|_
|j|_|j |_yr7)rr��context�
parsedText�
bulletText�style1r�formattedProgramrPr1r%r&�bold�italicrrjrrk)r'rRr�r�r1r�rs       r(r)z
Para.__init__�s���$���#�G�,���$���$��������� "��������
��$�0�0�D��#�.�.�D�O���	�����N�N��	��N�N��	r*c��|jSr,)r%rbs r(rszPara.getSpaceBefore�s�����r*c��|jSr,)r&rbs r(ruzPara.getSpaceAfter�s�����r*c��trCtdt|�||�td|j�td|j�||_t
�x|_}|j|_|j}|j}|j}|r|d}n|jj}|j}d|_
|r%|j|�d|_d|_|d}	n|jj}	||	krd|_
|dz|fS|�
|�t#d��|s|j%|�x|_}|js6|j'||||�\}}
}}||_||_||_|
|_n|j(}d}
|
rb|dz}
t/|jdd|j0��|_|
|j2_|j4|j2_d|_nd|_|}
|
|kDr|dz
}
||
f}tr=|\}}t7||z
�d	krtd
t9||�z�td||f|�|S)N�WRAPPINGz   rr:rzneed parsedText for formatting�r�r�r1r�g�������?g�������?zexact match???zwrap is)rHrI�idr�rrXr�myenginerr�r1r�r�cansplitrer!r"r?�compileProgramr`rWr^�remainderProgramr�r�rPr&r|rJ)r'rVrX�pr�r�r1rr�needatleastrPr^r_rWr��wr�s                 r(rdz	Para.wrap�sG����*�b��h���H��%��.�.�/��%����&�.���+�-�-��
��������_�_�
��0�0���
�
����I�&�G��k�k�)�)�G��,�,����
��
�L�L����A�C��A�C��	�*�K��+�+�-�-�K��K�'��D�M�$�A�%�~�6�6���'�/��=�>�>��%)�%8�%8��%D�D�D�L�7��$�$�&'�h�h�~��PW�Y`�&a�
$�
�y�
�
�$4�D�!�$�D�K�&�D�N�$-�D�!����J��I��
%�q�(�F�"�$�+�+�$�4�(1�4�<�<�I�D�N�%.�D�N�N�"�(,���D�N�N�%��D�O�!�D�N��F��o�%�(��,��!�&�)����F�Q���?�1�$�%�c�)��&��o�q�)A�A�B��)�n�o�>��G��
r*c��|dks|jsgS||_|j}|�td��|sgS|j}|r||g}|S|g}|S)Nrzmust call wrap before split)r�rXr�r?rP)r'rVrXr�rPr�s      r(rz
Para.splitsr���A��T�]�]��I�.����0�0���#��:�;�;�!��I��N�N�	���9�%�F��
��F�F��
r*c�<�|j}|j}|�td��|j}|j}|r|j|�d|_d|_|j}|j}|r|d}n|jj}|jd||jz
�|j�}tst r)t#dd�|D]
}	t#|	��t#d�|j%|||�}|j'|�y)Nzmust call wrap before drawrrz,============================================znow running programz,--------------------------------------------)r�r�r?r1r^rer!r"rgrWr�rrhrkri�DUMPPROGRAMrHrIr�rj)
r'r�r�r1r^rkrWr�tr!s
          r(rqz	Para.draw6s����M�M���0�0���#��9�:�:��
�
���N�N�	��
�L�L����A�C��A�C��I�I��������I�&�G��k�k�)�)�G�	
���A�v�d�i�i�'�(�
�K�K�M���%��&�/�0�%�
���a��
��&�M��L�L�!1�1�a�8�	�	�
�
�1�
r*c�8�|j}|�g}|j}|j}|d|f�ddlm}||�\|_|_|_|d|jf�|j|_	|d|jf�|d|jf�|jr|d|jf�|d|jf�|d|jf�|jr|d	|jf�|j r|j#|j |�|j%||�|jrKd}|D]%}|d
z
}t'|t(�s
t+|d�s�%n|j-|d|jf�|S)Nrjr)�ps2ttrkrrrrrrir:rg)r�r/r�reportlab.lib.fontsr�rjr�r�rrkr%r#r$rrr)r��	do_bullet�compileComponentrxryrz�insert)	r'r�rrRr4�fnr�rmr!s	         r(r�zPara.compileProgramWsp�������?��G��N�N��
�^�^��	�F�B�=��-�.3�B�i�+���D�I�t�{�	�F�E�N�N�$�&��N�N��	�	�G�U�_�_�&�(�	�H�e�&�&�(�*�� � �
��%�/�/�1�3�	�M�5�,�,�.�0�	�I�u�}�}�%�'��?�?�
�����)�+��?�?��N�N�4�?�?�G�4����j�'�2�� � ��E��
����
���a��$���'�(:��
�
�N�N�E�H�u�/D�/D�.D�#F�H�.�r*c�P�|�|j}|j}|�g}|jd�|jr+|jd|j|jzf�n|jd|jf�|jd�|j||��}|jd�|jd�|jr|jd|jf�n|jd�|jd�|jd�y)N�rnrru�r�ro)rr)r�r�r/r%rr�r&)r'rr�rRs    r(�	linearizezPara.linearize�s��������J������?��G����	�#�����N�N�Y��(9�(9�%�-�-�(G�H�J��N�N�Y��
�
�6�8�����)��%�%�j�'�%�B������"����	�#�����N�N�Y��(8�(8�9�;��N�N�N�,�����)�����"r*c��t|t�r5|r2|j�}|s|jd�yt	|||�yyt|t
�r|D]}|j
||��yt|t�r�|\}}}}|si}d|z}	t||	d�}
|
�|
||||�ytr�d|zg}|j}|si}|j�D]\}
}|d|
�d|����|r%|d�|t|��|d|z�n|d�dj|�}t	|||�ytd	t|�z��y)
Nr;�compile_�<�=�>z</%s>z/>�zdon't know how to handle tag )rxryr{r/�handleSpecialCharactersr�r�r~r.rHr/r�r?rJ)r'r�r�stextr��tagname�attdict�contentrp�compilername�compiler�Lr4�k�vr�s                r(r�zPara.compileComponent�sY���j��%��"�(�(�*����N�N�3�'�+�D�*�g�F���
�4�
(��
2���%�%�a��1�
2�
�
�5�
)�1;�.�W�g�w�����%�g�-�L��t�\�4�8�H��#���'�5�'�:����-�)�A����A�"�b�G� '�
�
��,���1��a��*�+�,���#���#�g�,���'�G�+�,��$������
�A�+�D�!�W�=�$�%D�t�G�}�%T�U�U�3*r*c��|j}|j}|j}|||f}|�|}|�|}|�|}||_||_||_ddlm}	|	|||�}
|	|||�}|
|k7r|jd|
f�|S)Nr��tt2psrj)rjr�r�r�r�r/)r'rrjr�r��oldface�oldbold�	olditalic�oldfontinfor�r�r�s            r(�	shiftfontzPara.shiftfont�s����)�)���)�)���K�K�	����3���<����<����>�I�6���	���	����-��T�$�v�&�����	�2����=��N�N�V�T�O�-��r*c�6�|D]}|j||��yr,)r��r'r�r�rprr�s      r(r�z
Para.compile_�s!���	.�A��!�!�!�W�-�	.r*c�6�|jt��yr,)r/�PageNumberObject�r'r�r�rprs     r(�compile_pageNumberzPara.compile_pageNumber�s�����'�)�*r*c��|j|d��\}}}|D]}|j||��|j||��y)Nr:)r��r�r��	r'r�r�rpr�fr5r�r�s	         r(�	compile_bzPara.compile_b�sI���.�.��q�.�1���1�Q��	.�A��!�!�!�W�-�	.����w�Q��'r*c��|j|d��\}}}|D]}|j||��|j||��y)Nr:)r�r�r�s	         r(�	compile_izPara.compile_i�sI���.�.���.�3���1�Q��	.�A��!�!�!�W�-�	.����w�q��)r*c��|jdtf�|D]}|j||��|jdtf�y)Nrsrt)r/�	UNDERLINEr�r�s      r(�	compile_uzPara.compile_u�sF��	����)�4�6��	.�A��!�!�!�W�-�	.����+�Y�7�9r*c��|j}|dzx|_}|dz}|jd|f�||_|jd|f�|D]}|j||��|jd|f�|jd|f�y�Ngffffff�?g�?rkr#�rkr/r��	r'r�r�rprrk�newsizer#r�s	         r(�compile_subzPara.compile_subs����y�y��"�S�j�(��	�G��C�x�������)�+���	�����$���)��	.�A��!�!�!�W�-�	.�������(�������(r*c��|j�}t|||j�}|D]�}t|t�r|j�s�$t
d��t|t�s�@|\}}	}
}|dk7rt
dt|�z��|j�}|	r|j|	�|j|�|j||
||���y)N�(don't expect CDATA between list elements�lizdon't expect %s inside list)r=�bulletMakerr�rxryr{r?r~rJrA�
makeBullet�compile_para)r'r�r�rprr��atts�bulletmakerr��attdict1�content1�newattss            r(�
compile_ulzPara.compile_uls����|�|�~��!�'�4����>���	E�A��!�C� ��7�7�9�$�%O�P�P��A�e�$�78�4��(�H�e��D�=�$�%B�T�'�]�%R�S�S��)�)�+����N�N�8�,��&�&�w�/��!�!�'�8�U�G�D�	Er*c�.�|j||||d��S)N�ol)r�)r�r�s     r(�
compile_olzPara.compile_ol#s�����w������N�Nr*c��|j�}|j�}td||j�}t|�}d}|r�|d}	|d=t	|	t
�r|	j
�rtd��|snŒ9t	|	t�r�|	\}
}}}|
dk7r|
dk7rtdt|
�z��|
dk(r0|rtdt|�z��|rf|j||||�nQ|
dk(rL|j�}
|r|
j|�|j|
|�	�|j|
|||�d}|r��|rtd
t|�z��y)N�dlr�rr��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�rxryr{r?r~rJr�rAr�)r'r�r�rprr�r��contentcopyrpr�r�r�r�r�s              r(�
compile_dlzPara.compile_dl&sg���|�|�~���|�|�~��!�$��d�l�l�;���7�m������A��A��A���!�C� ��7�7�9�$�%O�P�P�$����A�e�$�78�4��(�H�e��D�=�W�d�]�$�%\��w�-�&(�)�)��D�=��(�)]�^b�ci�^j�)j�k�k���)�)�(�H�e�W�M��d�]�"�i�i�k�G�����x�0��*�*�7�v�*�>��%�%�g�x���H��F�9�:��O�PT�U[�P\�\�]�]�r*c��|j}|dzx|_}|dz}|jd|f�|jd|f�|D]}|j||��|jd|f�||_|jd|f�yr�r�r�s	         r(�
compile_superzPara.compile_superQs����y�y��"�S�j�(��	�G��C�x�������)�+�������(��	.�A��!�!�!�W�-�	.�������(���	�����$���)r*c�~�|jd�d|vr=|d}ddlm}	|||j|j�}|jd|f�d|vr|d}|jd|f�d|vr|d}	|jd|	f�|D]}
|j|
|��|jd�y#|}Y�|xYw)Nr�rjrr�rirkr�)r/r�r�r�r�r�)r'r�r�rprrjr�r�r�rkr�s           r(�compile_fontzPara.compile_font^s������	�#��W���6�?�D�1�
��T�$�)�)�D�K�K�8��
�N�N�V�T�O�-��g����(�I��N�N�W�i�0�2��W���6�?�D��N�N�V�T�N�,��	.�A��!�!�!�W�-�	.�����"��
���s�B6�6B<c��|d}|jdd�}t|�}|jd�|jd|f�|jd|f�|jdtf�|D]}|j	||��|jdtf�|jd|f�|jd�y)N�hrefri�bluer�rsrtr�)�get�HotLinkr/r�r�)	r'r�r�rpr�urlr��Linkr�s	         r(�	compile_azPara.compile_ats����f�o���K�K���0�	��s�|�����	�#�����)�,�.�����$�/�1�����)�4�6��	.�A��!�!�!�W�-�	.����+�Y�7�9����+�T�2�4�����"r*c��|d}|jdd�}t|�}|jd�|r|jd|f�|jd|f�|jdtf�|D]}|j	||��|jdtf�|jd|f�|jd�y)N�destinationrir�rsrtr�)r��InternalLinkr/r�r��	r'r�r�rpr�destr�r�r�s	         r(�compile_linkzPara.compile_link�s����}�%���K�K���.�	��D�!�����	�#���N�N�W�i�0�2�����$�/�1�����)�4�6��	.�A��!�!�!�W�-�	.����+�Y�7�9����+�T�2�4�����"r*c��|d}|jdd�}t|�}|jd�|r|jd|f�|jd|f�|r|jdtf�|D]}|j	||��|r|jdtf�|jd|f�|jd�y)Nr�rir�r�rsrtr�)r��DefDestinationr/r�r�r�s	         r(�compile_setLinkzPara.compile_setLink�s����}�%���K�K���0�	��d�#�����	�#���N�N�W�i�0�2�����$�/�1���N�N�_�i�8�:��	.�A��!�!�!�W�-�	.���N�N�/��;�=����+�T�2�4�����"r*c��t|�dk7st|dt�std��|d}|j	||�y)Nr:rz*content for bullet must be a single string)rwrxryr?r�)r'r�r�rprr�s      r(�compile_bulletzPara.compile_bullet�s=���w�<��?�*�W�Q�Z��"<��I�J�J��q�z�����t�W�%r*c��|j}|j|jz}|j}|j}|jd||||f�y)Nrp)r�r(rr>r'r/)r'r�rrRrr�rks       r(r�zPara.do_bullet�sL�������#�#�d�o�o�5���#�#���#�#������4���t�<�>r*c��|j|d��\}}}|D]}|j||��|j||��y)N�Courier)rjr�r�s	         r(�
compile_ttzPara.compile_tt�sI���.�.��y�.�9���1�Q��	.�A��!�!�!�W�-�	.����w�Q��'r*c�0�|jddi|||�y)Nrj�symbol)r�r�s     r(�
compile_greekzPara.compile_greek�s�����6�8�,�g�u�g�Fr*c�R�|jt||||j��yr,)r/�EvalStringObjectr�r�s     r(�compile_evalStringzPara.compile_evalString�������(��'�5�$�,�,�O�Qr*c�R�|jt||||j��yr,)r/�
NameObjectr�r�s     r(�compile_namezPara.compile_name�s�����
�7�G�U�D�L�L�I�Kr*c�R�|jt||||j��yr,)r/�
GetNameObjectr�r�s     r(�compile_getNamezPara.compile_getName�s�����
�g�w��t�|�|�L�Nr*c�R�|jt||||j��yr,)r/�	SeqObjectr�r�s     r(�compile_seqzPara.compile_seq�s�����	�'�7�E�4�<�<�H�Jr*c�R�|jt||||j��yr,)r/�SeqResetObjectr�r�s     r(�compile_seqResetzPara.compile_seqReset�s������w������M�Or*c�R�|jt||||j��yr,)r/�SeqDefaultObjectr�r�s     r(�compile_seqDefaultzPara.compile_seqDefault�rr*c��|�i}|j}|jd|�}||}td|��}|j|�|jdd�}	|j}
t||||	��}|j}|
j|jzx|_|_|j|��|jd�||_y)NrRzrml2pdf internal embedded style�r0r1r��r�r�r�ru)
r�r�r,r<r�r�rr#r�r/)
r'r�r�rpr�	stylenamer�rR�newstyler��mystyle�thepara�mybaseindents
             r(r�zPara.compile_para�s����?��G��,�,���K�K���3�	��	�"���$E�e�T�����w�'��[�[��t�4�
��+�+���x��'�j�Q������/6�/A�/A�D�O�O�/S�S���'�,����'��*�����)�&��r*)NNNNrr,)NN�NNN)�ul)rL)(r�r�r�r%r&r)rsrurdrrqr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�rrrrrrrrr�r�r*r(r�r��s����K��J�#�. �
�F�P�0�B8�t#�2'V�R�$.�+�(�*�:�)�E�(O�)^�V*�#�,
#�#� #�,&�?�(�G�R�L�O�K�P�R�'r*r�c��eZdZd�Zdd�Zy)r�c��||_d}|jd|�x|_}dddd�|}|jd|�x|_}d|vr/||}dd	lm}|j}|d
d|�}	t|	�|d<d|_d|_	y)
NrMrR�discr�)r(r�r��typer#rr�XXXrr:)
r�r�rR�typrvrrryrm�_first)
r'r�r�r�rRr.�thestylerrkrs
          r(r)zbulletMaker.__init__�s������!��!�X�X�g�u�5�5��
�U��3�d�3�G�<�������-�-���#��t�#��u�~�H�@��$�$�D� ��	�4�8�F�!$�V��D�����
���r*Nc��|jsd|d<nd|_|j}|j}|��,|dk(rT|dk(rtd�}n9|dk(rtd�}n(|d	k(rtd
�}nt	dt|�z��d|vr�d
|d<n�|dk(r�d|vrt
|d�|_n|xjdz
c_|dk(rt|j�}n�|dk(r'td�|jzdz
}t|�}nZ|dk(r'td�|jzdz
}t|�}n.t	dt|�z��t	dt|�z��d|vr||d<d|vr|j|d<yy)Nr�r%rr(r+�m�circle�l�square�nz&unordered list type %s not implementedr>�ZapfDingbatsr�r;r:r�r4�Az&ordered bullet type %s not implementedzbad tagname r�rR)r/r.r��chrr?rJ�intrmry�ordrR)r'r�r�r.r��theords      r(r�zbulletMaker.makeBullet�st���{�{�"%�D����D�K��h�h���,�,��
�:���}���;�S��X���(�]��S��B��(�]��S��B�$�%M�PT�UX�PY�%Y�Z�Z�#�4�/�-;�D�)�*��$���d�?�!$�T�'�]�!3�D�J��J�J�!�O�J���8�#�d�j�j�/�R��#�X� ��X�d�j�j�0��2�F��V��B��#�X� ��X�d�j�j�0��2�F��V��B�$�%M�PT�UX�PY�%Y�Z�Z� ���W�
�!=�>�>��t�#�!#�D����$�� �J�J�D��M�r*r,)r�r�r�r)r�r�r*r(r�r��s���&$'r*r�c�,�eZdZdZdZd�Zd�Zd�Zd�Zy)r
z)this will only work if rml2pdf is present�
evalStringc�D�|si}||_||_||_||_yr,)r�r�r�rp)r'r�r�rpr�s     r(r)zEvalStringObject.__init__%s&����G������������
r*c�Z�ddlm}|j||ji�x}|_|S)Nr)�
Controller)�rlextra.rml2pdf.rml2pdfrA�processTupler��op)r'r~�enginerArDs     r(�getOpzEvalStringObject.getOp-s)��6�!�.�.�u�d�l�l�B�G�G��T�W��	r*c��ddlm}|j}|sg}|j|j||j
f}|j
||�x}|_t|�}|||j|j�S�Nrr)rvrr�r�r�rprFrDryrr)r'rErr�r~rDr�s       r(rgzEvalStringObject.width3si��<��,�,����G����t�|�|�W�d�j�j�A���z�z�%��0�0��T�W�
��G���1�f�o�o�v���?�?r*c�L�|jt|j��yr,)r�ryrD�r'rEr�r�s    r(r�zEvalStringObject.execute@s�����3�t�w�w�<�(r*N)	r�r�r�r=r�r)rFrgr�r�r*r(r
r
 s��/��G���@�)r*r
c��eZdZd�Zy)rc��ddlm}|�}|j}d|vr|d}||zx}|_|Sd|vr|d}nd}|j	|�x}|_|S)Nr��getSequencer�templater�)�reportlab.lib.sequencerrNr�rD�nextf)	r'r~rErN�globalsequencer�attr�templrDr�s	         r(rFzSeqObject.getOpEsp��8�&�.���|�|�������$�E� �?�2�2�B����I�
�T�\��d��B��B�&�,�,�R�0�0��T�W��	r*N�r�r�r�rFr�r*r(rrCs��r*rc��eZdZdZd�Zy)rr0c��yr,r�rJs    r(r�zNameObject.executeXs��r*N)r�r�r�r�r�r�r*r(rrVs���G�
r*rc��eZdZd�Zy)rc��ddlm}|�}|j}	|d}|j	|�d|_y#t$rd}Y�&wxYw)NrrMr�r�)rPrNr�r�setDefaultCounterrD)r'r~rErNrRrS�defaults       r(rFzSeqDefaultObject.getOp]sS��8�&�.���|�|��	��4�j�G�	�)�)�'�2������	�	��G�	�s�9�A�ANrUr�r*r(rr[s��
r*rc��eZdZd�Zy)rc���ddlm}|�}|j}	|d}	t	|d�}|j||�d|_y#t$rd}Y�6wxYw#d}Y�1xYw)NrrMr��baser�)rPrNr�rr:�resetrD)r'r~rErNrRrSr�r^s        r(rFzSeqResetObject.getOpkss��8�&�.���|�|��	��d��B�	��t�F�|�$�D�	���b�$�'�������	��B�	��	��D�s�A	�A�	A�A�A NrUr�r*r(rris��r*rc��eZdZdZy)r�getNameN)r�r�r�r�r�r*r(rr{s���Gr*rc� �eZdZdd�Zd�Zd�Zy)r�c��||_yr,)�example)r'rds  r(r)zPageNumberObject.__init__�s	����r*c�^�ddlm}||j|j|j�SrH)rvrrdrr)r'rErs   r(rgzPageNumberObject.width�s ��<��4�<�<����&�/�/�J�Jr*c�X�|j�}|jt|��yr,)�
getPageNumberr�ry)r'rEr�r��ns     r(r�zPageNumberObject.execute�s"��� � �"�����3�q�6�"r*N)r-)r�r�r�r)rgr�r�r*r(r�r�~s���K�#r*r�c���ddlm}m}Gd�d|�at�aGd�d|�at�}||d<||d<||d	<t|d
<t|d<t|d<t|d
<t|d<y)z8make the para the default para implementation in rml2pdfr)�MapNoderAc��eZdZd�Zy)�
paraMapperc�<�|\}}}}|dz}	|jd|	�}	||	}
td|
��}|j|�|jdd�}d}
|s3t|�dk(r%|d}t	|t
�rd|vrt
||�}
|
�t||||�	�}
|
S)
Nz
.defaultStylerRzrml2pdf internal styler r�r:rrQr!)r�r,r<rwrxryrOr�)r'�	nodetuple�
controllerr��	overridesr�r�r�rpr"rRr$r�r�r�s               r(rhzparaMapper.translate�s���1:�.�W�g�w����/�I����G�Y�7�I��I�&�E�!�'?��N�G��!�!�'�*� ���\�4�8�J��F��#�g�,��/��q�z���d�3�'�C�t�O�%�g�t�4�F��~��g�w��J�W���Mr*N�r�r�r�rhr�r*r(rlrl�s��	r*rlc��eZdZd�Zy)�ulMapperc�@�di|gdf}tj||||�S)N�para)�
theParaMapperrh)r'rnror�rpr%s      r(rhzulMapper.translate�s)���r�I�;��5�G� �*�*�7�J���S�Sr*Nrqr�r*r(rsrs�s��	Tr*rsr(r�r�ru�h1�h2�h3�titleN)rBrjrArlrvrs)rjrA�
theListMappers   r(�EmbedInRml2pdfr|�s���;��W��(�L�M�T�7�T��J�M�$�J�t��$�J�t��$�J�t��&�J�v��$�J�t��$�J�t��$�J�t��'�J�w�r*c��ddlm}ddlm}dddd�}|dd|vr|j	d	�	|�g}|jd�}	d}
|	d
}|	D�]_}|
s�|jd�}
|
dkDr�|d|
}|ddk(rG	|dd
k(rt|ddd�}nt|dd�}|dk\rt|�||
dzdz}n}d|z}nw||vr2||}t|t�r|jd�}|||
dzdz}nA||vr2||}t|t�r|jd�}|||
dzdz}nd|z}nd|z}|j�}|dd
D]}|j	|d	z��|rG|rE|d
|vr|j	|d
d	z�n&|d
j
�}|r|j	|�d}
��b|S#t$rd
}Y��#wxYw)Nr)�greeks)�
whitespacer�r�rQ)�lt�gt�ampr:r;r6�;�#r!���utf8)�reportlab.platypus.paraparserr~rrr/rr{rL�findr:r?r9rx�bytes�decode)rEr�rr~r�standardr�r!r��amptextr��lastfrag�fragment�semir0rhr��	sfragmentr�s                   r(r�r��s#��4�!��S��
,�H��A�a�y�J�����s��	������j�j��o�G�
�E��r�{�H��0����=�=��%�D��A�v��������7�C�<����7�c�>� #�D���H�b� 1�A� #�D���H�
�A��!�t�#&�q�6�(�4��6�7�*;�#;��#&�x�<���X�%� ���A�!�(�5�1��H�H�V�,�� ��$�q�&�'�!2�2�H��V�^��t��A�!�(�5�1��H�H�V�,�� ��$�q�&�'�!2�2�H� #�8�|�H��x�<���N�N�$�	��3�B��	"�A��N�N�1�S�5�!�	"�����|�z�)����	�"�
�c� 1�3� ��}�*�*�,����N�N�D�*���a0�d�N��M&�����s�4&F/�/F>�=F>c�~�d|vrd|vr
t||��Sddlm}|j|d��}t	|||d|��S)	zf Paragraph(text, style, bulletText=None)
    intended to be like a platypus Paragraph but better.
    rQr�)rSr��	rparsexmlN��entityReplacerr�)rOrr��parsexmlSimpler�)r�rRr��fragsr�r��
parsedparas       r(�	Paragraphr�sL��
�$��3�d�?���$�/�/�	,��-�-�d�$�-�G�
��E�j�Z�t�]d�e�er*c� �eZdZdd�Zd�Zd�Zy)�UnderLineHandlerNc��||_yr,)ri)r'ris  r(r)zUnderLineHandler.__init__s	����
r*c� �||_||_yr,)�xStart�yStart)r'r!r"rur�r�s      r(r�zUnderLineHandler.start_ats�������r*c�(�|jdz}|j�|j}|j�|j}|j	|�|j|j|j|z
|||z
�|j�y)Ng @)	r�	saveStaterir �setStrokeColorrXr�r��restoreState)r'r!r"rur�r��offsetris        r(r�zUnderLineHandler.end_atsu�����s�"�������
�
���:�:���N�N�E����e�$����D�K�K����V�!3�Q�q��x�@����r*r,)r�r�r�r)r�r�r�r*r(r�r�s����r*r�c��eZdZd�Zd�Zd�Zy)r�c��||_yr,)r�)r'r�s  r(r)zHotLink.__init__%s	����r*c��|j}|j|j|||zg}trt	d|�|j||�y)NzLINKING RECTANGLE)rr�r�rHrI�link)r'r!r"rur�r�r��rects        r(r�zHotLink.end_at(sA���=�=�����T�[�[�!�A�h�J�7����%�t�,��	�	�$��r*c�@�|j|j|d��y)Nr:)�relative)�linkURLr�)r'r�r�s   r(r�zHotLink.link0s�����t�x�x����2r*N)r�r�r�r)r�r�r�r*r(r�r�#s��� �3r*r�c��eZdZd�Zy)r�c�J�|j}d}|j|||d��y)Nr�z[0 0 0])�Border)r��linkRect)r'r�r��destinationname�contentss     r(r�zInternalLink.link5s$���(�(��������/�4�	��Jr*N)r�r�r�r�r�r*r(r�r�3s��Kr*r�c��eZdZdZd�Zy)rrc�x�|j}|js"|\}}}}|j|||�d|_yy)Nr:)r��defined�bookmarkHorizontal)r'r�r�r�r!r"�x1�y1s        r(r�zDefDestination.link>s=���(�(���|�|�!�N�Q��2�r��%�%�o�q�"�=��D�L�r*N)r�r�r�r�r�r�r*r(rr:s���G�r*rc�`�|j�}g}|D]}|j|dz��|S)Nr;)rr/)r�r�r�r�s    r(�
splitspacer�Es6���J�J�L�E�
�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�V�ddlm}ddlm}ddlm}|j
|d��}|dd�}t||�}|jd|zd|z�\}}	td	|	|f�|j�|jd
|zd
|z�|jddd|zd|zdd
��||_
|j�|j�|j�|j!d
dd�|jdd||	dd
��|j�|j#�y)Nr��inch)�ParagraphStyler�r�rG�rz
wrapped asr:)�fill�stroke)�reportlab.lib.unitsr�rzr�rr�r�r�rdrIr�rhr�rgrqr��setStrokeColorRGB�showPage)
rg�testparar�r�r�r��S�Pr�r�s
          r(�test2r��s��(�3�'��)�)�(�$�)�G�J��x��&�A��Q�
��A�
�V�V�A�d�F�B�t�G�
$�F�Q��	�,��1����N�N���N�N�1�T�6�1�T�6�"��I�I�a��!�D�&��D��q��I�3�
�A�F��N�N���F�F�H��������1�a��#��I�I�a��!�A�A�a�I�(������M�M�Or*zhttp://www.reportlab.comr�)r�d)r��)rpzvery long bullet�2r�rrrj)rkr)rr�z1This is the first segment of the first paragraph.rsz�HOTLINK 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. rtru)rp�Bulletrr�z�This 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. )rpz"Bullet not quite as long this timer�rr�)rjzHelvetica-Oblique)ri�redz4This is the THIRD!!! segment of the first paragraph.z�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�zraised ztext )r#i����zlowered znormal r�)rr�)rp�Or�rr�)rjraAnd 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��ddlm}ddlm}ddlm}d}|j|�}t
|t�t
|t�	ttztz}i}|r�td�|j|d|z�|j�}|jdd�t�}|j|�d|_d|_d|z}	d	}
|j%|	|
|�\}}}}t&r||�|j)|||�}|j+|�|j-�td
d|dd
|d�|r��|j/�t|�y)Nr)�pprint)r�r�z
paratest0.pdfzNEW PAGEr��i�z==============================zx=r!zy=r")r��reportlab.pdfgenr�r�r��Canvasr��
testparagraph�testparagraph1�test_programrIrhrir�rrer!r"r`rHr�rjr��save)
r�r�r�r�rkrPr^r�r�rMrN�formattedprogramrWs
             r(�testr�	s/���'�(�	�B��
�
�b��A�	�!�M��	�!�N��� �<�/�,�>�	��	���*��
�K�K��a��f�%����
�A�
�O�O�A�a� ��!�A�
�L�L��#��A�C��A�C���v�H��I�?@�x�x��R[�]f�?g�<�
�y�)�V���(�*����%5�q�!�<�I�
�J�J�q�M�
�J�J�L��&�$�	�#���i��n�E�#�$�F�F�H�	�"�Ir*�__main__r,r')<r=rvr�reportlab.lib.rl_accelr�reportlab.platypus.flowablesrrrrzr	rHr�r>r$r
rrr
rrBrFrrr�r�rrr r"r,r{rOrr�r�r�r
rrrrrr�r|r�r�r�r�r�r�rr�r�r�r��testlinkr�r�r�r�r*r(�<module>r�s^��;�x5�)�1� �.�
	
�����
�H�H�g�g�R��('�O�	�#�4!+���,��!*�!*�J"�!�!�!�!�!�!�'�!��&�$�#��� a%�x�a%�F��(s'�8�s'�j8'�8'�t!)�!)�F� ��&
�!�
�
�z���Z��$�$��#�#�*(�XJ�Xf��� 
��	�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	�a0B	�b
��E	�a2��h�B�Z���F�r*

Zerion Mini Shell 1.0