o
    &zhC                     @   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ParagraphStylestr2alignment	LineStyle	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 vs	J dd| j vsJ d|r&|j| jks&J d|jj| jjf || _|| _| j| j  |   | jdi | 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	__class____name__r   r   __dict__updaterefresh_setKwds)selfr   r   kwr   r   O/var/www/html/kangema/venv/lib/python3.10/site-packages/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   s6   | j r| j j D ]\}}|dvr|| j|< q	dS 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   q'd S )Nzname =zparent =r   r   z%s = %s)	printr   r   listr#   keyssortremoveget)r'   indentkeylistr-   r.   r   r   r)   	listAttrs]   s   

zPropertySet.listAttrsc                 K   sD   |  ||}| j |_||_|d u r| p||_|jdi | |S )Nr   )r!   r#   copyr   r   r&   )r'   r   r   kwdsrr   r   r)   cloneh   s   zPropertySet.cloner+   )r1   )
r"   
__module____qualname__r    r*   r&   r0   r%   r:   r>   r   r   r   r)   r   3   s    

	r   c                	   @   s   e Zd Zi deddddddddd	dd
edddddedddddeddddddddi ddddddddddddddddded d!d"dd#dd$ed%ed&e	d'e
d(eeeddeeed)ZdS )*r   fontNamefontSize
   leading   
leftIndentr   rightIndentfirstLineIndent	alignmentspaceBefore
spaceAfterbulletFontNamebulletFontSizebulletIndent	textColor	backColorNwordWrapshapingborderWidthborderPaddingborderColorborderRadiusallowWidowsr   allowOrphanstextTransformendDotssplitLongWordsr   bulletAnchorstartjustifyLastLinejustifyBreaksr   r   r   r   r   )r   linkUnderlineunderlineColor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   s    	
 !"#$%&'()r   )centrecenterleftrightjustifyc                 C   s*   | |  d }|d u rt| d|S )Nz is illegal value for alignment)r7   lower
ValueError)v__map___r   r   r)   r      s   r   c                   @   s   e Zd ZdedZdd ZdS )r   r   )widthcolorc                 C   s   | d dS )zKYou can ask a LineStyle to set up the canvas for drawing
        the lines.r   N)setLineWidth)r'   canvasr   r   r)   prepareCanvas   s   zLineStyle.prepareCanvasN)r"   r?   r@   r	   r    r}   r   r   r   r)   r      s
    r   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   rq   1	HelveticarE   autoltrN)rF   rG   bulletAlign
bulletTypebulletColorrL   rM   bulletOffsetYbulletDedent	bulletDirbulletFormatr]   )r"   r?   r@   dictr	   r    r   r   r   r)   r      s    
r   c                   @   sV   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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   sH   z| j | W S  ty#   z| j| W  Y S  ty"   td| w w )Nz"Style '%s' not found in stylesheet)r   KeyErrorr   r'   r-   r   r   r)   __getitem__   s   zStyleSheet1.__getitem__c                 C   s,   z| | W S  t y   |tkr| Y S  w r+   )r   _stylesheet1_undefined)r'   r-   defaultr   r   r)   r7      s   
zStyleSheet1.getc                 C   s   || j v p	|| jv S r+   )r   r   r   r   r   r)   __contains__   s   zStyleSheet1.__contains__c                 C   s   || v S r+   r   r   r   r   r)   has_key   s   zStyleSheet1.has_keyNc                 C   s   |j }|| jv rtd| || jv rtd| |r1|| jv r&td| || jv r1td| || j|< |r?|| j|< d S 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   r   r   r   )r'   stylealiasr-   r   r   r)   add   s   




zStyleSheet1.addc                 C   s(   || v r	|  |S t| jj d|)Nz instance has no attribute )r7   AttributeErrorr!   r"   )r'   ar   r   r)   __getattr__  s   zStyleSheet1.__getattr__c                 C   sr   t | j }|  i }t | j D ]\}}|||< q|D ]\}}||d }t|| |d t  qd S )Nz    )r3   r   r,   r5   r   r7   r2   r:   )r'   stylesaliir   r   r   r   r   r)   r3     s   


zStyleSheet1.listr+   )r"   r?   r@   __doc__r*   r   r   r7   r   r   r   r   r3   r   r   r   r)   r      s    	
r   c                  C   sJ   t dd } t| _d| _d| _|   t  t d| }d|_|  | |fS )NNormalrE   g,@LiteralCourier)r   rc   rA   rB   rD   r:   r2   )pNormal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   rC   rE   )r   rA   rB   rD   BodyText   )r   r   rJ   Italic)r   r   rA   Heading1r~      )r   r   rA   rB   rD   rK   h1)r   Title)r   r   rA   rB   rD   rI   rK   titleHeading2   )r   r   rA   rB   rD   rJ   rK   h2Heading3h3Heading4   h4Heading5	   g%@   h5Heading6   g @   h6Bulletr      )r   r   rH   rJ   bu
Definition$   )r   r   rH   rF   rN   rJ   rL   dfCoder   g!@r1   )r   r   rA   rB   rD   rH   rF   r   UnorderedListNrq   r   r   r   r   )r   r   rF   rG   r   r   r   rL   rM   r   r   r   r   r]   ulOrderedListol)
r   r   r   rc   _baseFontNameI_baseFontNameBr   _baseFontNameBIr   r	   )
stylesheetr   r   r)   r   (  s   								r   N)5__version__r   __all__reportlab.lib.colorsr	   reportlab.lib.enumsr
   r   r   r   reportlab.lib.fontsr   reportlab.rl_configr   rc   r   rd   r   rg   r   rh   r   rf   r   ri   r   rj   r   re   r   rk   r   rl   r   _hyphenationMinWordLengthr   rn   r   rm   r   r   r   r   r   r   r   r   r   objectr   r   r   r   r   r   r   r)   <module>   s0   	<=4	Q