U
    '1eNC                     @   s  d Z dZdZddlmZ ddlmZmZmZm	Z	 ddl
mZ ddlmZmZmZmZmZmZmZmZmZmZ m!Z"m#Z$m%Z& eeddZ'eeddZ(eeddZ)G d	d
 d
Z*G dd de*Z+e,eeeee	dfddZ-G dd de*Z.G dd de*Z/e0 Z1G dd dZ2dd Z3dd Z4dS )z3.3.0a  Classes for ParagraphStyle and similar things.

A style is a collection of attributes, but with some extra features
to allow 'inheritance' from a parent, and to ensure nobody makes
changes after construction.

ParagraphStyle shows all the attributes available for formatting
paragraphs.

getSampleStyleSheet()  returns a stylesheet you can use for initial
development, with a few basic heading and text styles.
)PropertySetParagraphStyleZstr2alignmentLineStyle	ListStyleStyleSheet1getSampleStyleSheet    )black)TA_LEFT	TA_CENTERTA_RIGHT
TA_JUSTIFY)tt2ps)canvas_basefontnameunderlineWidthunderlineOffsetunderlineGapstrikeWidthstrikeOffset	strikeGapspaceShrinkageplatypus_link_underlinehyphenationLanghyphenationMinWordLengthuriWasteReduceembeddedHyphenation   c                   @   sF   e Zd Zi ZdddZdd Zdd Zdd	 ZdddZdddZ	dS )r   Nc                 K   s~   d| j kstdd| j ks$td|rL|j| jksLtd|jj| jjf || _|| _| j| j  |   | j	f | dS )zWhen initialized, it copies the class defaults;
        then takes a copy of the attributes of the parent
        if any.  All the work is done in init - styles
        should cost little to use at runtime.namez1Class Defaults may not contain a 'name' attributeparentz3Class Defaults may not contain a 'parent' attributez4Parent style %s must have same class as new style %sN)
defaultsAssertionError	__class____name__r   r   __dict__updaterefresh_setKwds)selfr   r   kw r'   8/tmp/pip-unpacked-wheel-109iniqw/reportlab/lib/styles.py__init__6   s    $zPropertySet.__init__c                 K   s    |  D ]\}}|| j|< qd S N)itemsr!   )r%   r&   keyvaluer'   r'   r(   r$   L   s    zPropertySet._setKwdsc                 C   s   d| j j| jf S )Nz	<%s '%s'>)r   r    r   r%   r'   r'   r(   __repr__Q   s    zPropertySet.__repr__c                 C   s2   | j r.| j j D ]\}}|dkr|| j|< qdS )zre-fetches attributes from the parent on demand;
        use if you have been hacking the styles.  This is
        used by __init__)r   r   N)r   r!   r+   )r%   r,   r-   r'   r'   r(   r#   T   s    zPropertySet.refresh c                 C   sz   t |d | j t |d | j t| j }|  |d |d |D ]&}| j|d }t |d||f   qNd S )Nzname =zparent =r   r   z%s = %s)	printr   r   listr!   keyssortremoveget)r%   indentZkeylistr,   r-   r'   r'   r(   	listAttrs]   s    

zPropertySet.listAttrsc                 K   s@   |  ||}| j |_||_|d kr*| p,||_|jf | |S r*   )r   r!   copyr   r   r$   )r%   r   r   kwdsrr'   r'   r(   cloneh   s    zPropertySet.clone)N)r0   )N)
r    
__module____qualname__r   r)   r$   r/   r#   r8   r<   r'   r'   r'   r(   r   3   s   
	
r   c                )   @   sb   e Zd Zedddddeddeddedddddddddddedddeee	e
eeeddeeed(ZdS )r   
      r   Nr   start)(fontNamefontSizeleading
leftIndentrightIndentfirstLineIndent	alignmentspaceBefore
spaceAfterbulletFontNamebulletFontSizebulletIndentZ	textColorZ	backColorZwordWrapZborderWidthZborderPaddingZborderColorZborderRadiusZallowWidowsZallowOrphansZtextTransformZendDotsZsplitLongWordsr   ZbulletAnchorZjustifyLastLineZjustifyBreaksr   r   r   r   r   r   ZlinkUnderlineZunderlineColorZstrikeColorr   r   r   )r    r=   r>   _baseFontNamer   r   _baseUnderlineWidth_spaceShrinkage_baseStrikeWidth_baseUnderlineOffset_baseUnderlineGap_baseStrikeOffset_baseStrikeGap_platypus_link_underline_hyphenationLang_embeddedHyphenation_uriWasteReducer   r'   r'   r'   r(   r   p   sR   r   )ZcentrecenterleftrightZjustifyc                 C   s.   | |  d }|d k	r|S t| dd S )Nz is illegal value for alignment)r6   lower
ValueError)vZ__map___r'   r'   r(   str2alignment   s    ra   c                   @   s   e Zd ZdedZdd ZdS )	LineStyler   )widthcolorc                 C   s   | d dS )zKYou can ask a LineStyle to set up the canvas for drawing
        the lines.r   N)ZsetLineWidth)r%   Zcanvasr'   r'   r(   prepareCanvas   s    zLineStyle.prepareCanvasN)r    r=   r>   r   r   re   r'   r'   r'   r(   rb      s   rb   c                   @   s,   e Zd Zeddddedddddd	d	d
Zd	S )r      r   r[   1	Helveticar@   autoltrN)rE   rF   bulletAlign
bulletTypebulletColorrK   rL   bulletOffsetYbulletDedent	bulletDirbulletFormatrA   )r    r=   r>   dictr   r   r'   r'   r'   r(   r      s   r   c                   @   sN   e Zd ZdZdd Zdd ZefddZdd	 Zd
d Z	dddZ
dd ZdS )r   aG  
    This may or may not be used.  The idea is to:
    
    1. slightly simplify construction of stylesheets;
    
    2. enforce rules to validate styles when added
       (e.g. we may choose to disallow having both
       'heading1' and 'Heading1' - actual rules are
       open to discussion);
       
    3. allow aliases and alternate style lookup
       mechanisms
       
    4. Have a place to hang style-manipulation
       methods (save, load, maybe support a GUI
       editor)
   
    Access is via getitem, so they can be
    compatible with plain old dictionaries.
    c                 C   s   i | _ i | _d S r*   )byNamebyAliasr.   r'   r'   r(   r)      s    zStyleSheet1.__init__c                 C   sX   z| j | W S  tk
rR   z| j| W  Y S  tk
rL   td| Y nX Y nX d S )Nz"Style '%s' not found in stylesheet)rt   KeyErrorrs   r%   r,   r'   r'   r(   __getitem__   s    zStyleSheet1.__getitem__c                 C   s6   z
| | W S  t k
r0   |tkr*| Y S  Y nX d S r*   )ru   _stylesheet1_undefined)r%   r,   defaultr'   r'   r(   r6      s    
 zStyleSheet1.getc                 C   s   || j kp|| jkS r*   )rt   rs   rv   r'   r'   r(   __contains__   s    zStyleSheet1.__contains__c                 C   s   || kS r*   r'   rv   r'   r'   r(   has_key   s    zStyleSheet1.has_keyNc                 C   s~   |j }|| jkrtd| || jkr2td| |rb|| jkrLtd| || jkrbtd| || j|< |rz|| j|< d S )Nz(Style '%s' already defined in stylesheetz1Style name '%s' is already an alias in stylesheetz1Alias name '%s' is already an alias in stylesheet)r   rs   ru   rt   )r%   stylealiasr,   r'   r'   r(   add   s    




zStyleSheet1.addc                 C   sr   t | j }|  i }t | j D ]\}}|||< q(|D ].\}}||d }t|| |d t  q>d S )Nz    )r2   rs   r+   r4   rt   r6   r1   r8   )r%   ZstylesZaliir}   r|   r   r'   r'   r(   r2     s    


zStyleSheet1.list)N)r    r=   r>   __doc__r)   rw   rx   r6   rz   r{   r~   r2   r'   r'   r'   r(   r      s   	
r   c                  C   sJ   t dd } t| _d| _d| _|   t  t d| }d|_|  | |fS )NNormalr@   g,@LiteralCourier)r   rN   rB   rC   rD   r8   r1   )ZpNormalZpPrer'   r'   r(   
testStyles  s    

r   c                  C   s
  t  } | tdtddd | td| d dd | td| d td	 | jtd
| d tdddddd | jtd| d tddtdddd | jtd| d tddddddd | jtd| d tddddddd | jtd| d tddddddd | jtd| d tdddddd d | jtd!| d td"d#dd$dd%d | jtd&| d d'd(d)d*d | jtd+| d d'd,d'dtd-d.d | td/| d d0dd1d'd,d2d3 | jtd4d5dd'd6d7t	d8dd'd9d:d5d5d;d<d | jtd=d5dd'd6d7t	d8dd'd9d:d5d5d;d>d | S )?zReturns a stylesheet objectr   r?   r@   )r   rB   rC   rD   ZBodyText   )r   r   rI   ZItalic)r   r   rB   ZHeading1rf      )r   r   rB   rC   rD   rJ   h1)r}   ZTitle)r   r   rB   rC   rD   rH   rJ   titleZHeading2   )r   r   rB   rC   rD   rI   rJ   h2ZHeading3h3ZHeading4   h4ZHeading5	   g%@   h5ZHeading6   g @   h6ZBulletr      )r   r   rG   rI   ZbuZ
Definition$   )r   r   rG   rE   rM   rI   rK   ZdfZCoder   g!@r0   )r   r   rB   rC   rD   rG   rE   r   ZUnorderedListNr[   rg   rh   ri   rj   )r   r   rE   rF   rk   rl   rm   rK   rL   rn   ro   rp   rq   rA   ulZOrderedListol)
r   r~   r   rN   _baseFontNameI_baseFontNameBr	   _baseFontNameBIr   r   )Z
stylesheetr'   r'   r(   r   %  s    								r   N)5__version__r   __all__Zreportlab.lib.colorsr   Zreportlab.lib.enumsr   r	   r
   r   Zreportlab.lib.fontsr   Zreportlab.rl_configr   rN   r   rO   r   rR   r   rS   r   rQ   r   rT   r   rU   r   rP   r   rV   r   rW   r   Z_hyphenationMinWordLengthr   rY   r   rX   r   r   r   r   r   rr   ra   rb   r   objectrx   r   r   r   r'   r'   r'   r(   <module>   s0   	<=3 M