o
    à’OjÅC  ã                   @   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 )zÎWhen 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   úZ/var/www/html/pharmsmart-cdr-gen/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 )zƒre-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