
    fh                     D    d dl mZ ddlmZ  G d dej                  ZdS )   )	xmlwriter    )warnc                       e Zd ZdZdM fd	Zd ZdNdZd ZdOd	ZdOd
Z	dPdZ
dOdZdPdZdOdZdOdZd ZdOdZdOdZd ZdQdZdOdZd ZdPdZdOdZdOdZdPdZd Zd ZdPdZd ZdPd Zd! ZdPd"Z dPd#Z!d$ Z"dPd%Z#d& Z$dPd'Z%d( Z&d) Z'dPd*Z(dOd+Z)dOd,Z*dOd-Z+d. Z,d/ Z-d0 Z.d1 Z/d2 Z0d3 Z1dRd5Z2d6 Z3d7 Z4d8 Z5d9 Z6d: Z7d; Z8d< Z9dOd=Z:d> Z;dOd?Z<d@ Z=dA Z>dB Z?dC Z@dD ZAdE ZBdF ZCdG ZDdH ZEdI ZFdJ ZGdK ZHdL ZI xZJS )SFormatz;
    A class for writing the Excel XLSX Format file.


    Nc                 X   |i }t          t          |                                            || _        || _        d| _        d| _        d| _        d| _        d| _	        d| _
        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d	| _        d| _         d| _!        d| _"        d| _#        d| _$        d| _%        d| _&        d| _'        d| _(        d| _)        d| _*        d| _+        d| _,        d| _-        d| _.        d| _/        d| _0        d| _1        d| _2        d| _3        d| _4        d| _5        d| _6        d| _7        d| _8        d| _9        d| _:        d| _;        d| _<        d| _=        d| _>        d| _?        d| _@        d| _A        d| _B        |C                                D ]!\  }} t          | d
|z             |           "d| _E        dS )z
        Constructor.

        NGeneralr   Calibri      minorFr   set_)Fsuperr   __init__xf_format_indicesdxf_format_indicesxf_index	dxf_index
num_formatnum_format_index
font_indexhas_fonthas_dxf_fontbold	underlineitalic	font_name	font_size
font_colorfont_strikeoutfont_outlinefont_shadowfont_scriptfont_familyfont_charsetfont_schemefont_condensefont_extendtheme	hyperlinkxf_idhiddenlockedtext_h_align	text_wraptext_v_aligntext_justlastrotationfg_colorbg_colorpatternhas_fillhas_dxf_fill
fill_index
fill_countborder_index
has_borderhas_dxf_borderborder_countbottombottom_colordiag_border
diag_color	diag_typeleft
left_colorrightright_colortop	top_colorindentshrinkmerge_rangereading_orderjust_distribcolor_indexed	font_onlyquote_prefixitemsgetattr_format_key)self
properties
xf_indicesdxf_indiceskeyvalue	__class__s         S/var/www/ffwdstore.be/apps/py-env/lib/python3.11/site-packages/xlsxwriter/format.pyr   zFormat.__init__   sX   
 Jfd$$&&&!+"-# !	""

	
! %**,, 	/ 	/JC'GD&3,''....    c                     || _         dS )z
        Set the Format font_name property such as 'Time New Roman'. The
        default Excel font is 'Calibri'.

        Args:
            font_name: String with the font name. No default.

        Returns:
            Nothing.

        Nr   rT   r   s     r[   set_font_namezFormat.set_font_name{   s     #r\   r   c                     || _         dS )z
        Set the Format font_size property. The default Excel font size is 11.

        Args:
            font_size: Int with font size. No default.

        Returns:
            Nothing.

        Nr   rT   r   s     r[   set_font_sizezFormat.set_font_size        #r\   c                 :    |                      |          | _        dS )z
        Set the Format font_color property. The Excel default is black.

        Args:
            font_color: String with the font color. No default.

        Returns:
            Nothing.

        N
_get_colorr   rT   r   s     r[   set_font_colorzFormat.set_font_color        //*55r\   Tc                     || _         dS )z
        Set the Format bold property.

        Args:
            bold: Default is True, turns property on.

        Returns:
            Nothing.

        N)r   )rT   r   s     r[   set_boldzFormat.set_bold        			r\   c                     || _         dS )z
        Set the Format italic property.

        Args:
            italic: Default is True, turns property on.

        Returns:
            Nothing.

        N)r   )rT   r   s     r[   
set_italiczFormat.set_italic        r\   r   c                     || _         dS )z
        Set the Format underline property.

        Args:
            underline: Default is 1, single underline.

        Returns:
            Nothing.

        N)r   )rT   r   s     r[   set_underlinezFormat.set_underline   re   r\   c                     || _         dS )z
        Set the Format font_strikeout property.

        Args:
            font_strikeout: Default is True, turns property on.

        Returns:
            Nothing.

        N)r    )rT   r    s     r[   set_font_strikeoutzFormat.set_font_strikeout   s     -r\   c                     || _         dS )z
        Set the Format font_script property.

        Args:
            font_script: Default is 1, superscript.

        Returns:
            Nothing.

        N)r#   )rT   r#   s     r[   set_font_scriptzFormat.set_font_script        'r\   c                     || _         dS )z
        Set the Format font_outline property.

        Args:
            font_outline: Default is True, turns property on.

        Returns:
            Nothing.

        N)r!   )rT   r!   s     r[   set_font_outlinezFormat.set_font_outline        )r\   c                     || _         dS )z
        Set the Format font_shadow property.

        Args:
            font_shadow: Default is True, turns property on.

        Returns:
            Nothing.

        N)r"   )rT   r"   s     r[   set_font_shadowzFormat.set_font_shadow   rx   r\   c                     || _         dS )z
        Set the Format num_format property such as '#,##0'.

        Args:
            num_format: String representing the number format. No default.

        Returns:
            Nothing.

        N)r   )rT   r   s     r[   set_num_formatzFormat.set_num_format   s     %r\   c                     || _         dS )z
        Set the Format locked property.

        Args:
            locked: Default is True, turns property on.

        Returns:
            Nothing.

        N)r-   )rT   r-   s     r[   
set_lockedzFormat.set_locked  rq   r\   c                     || _         dS )z
        Set the Format hidden property.

        Args:
            hidden: Default is True, turns property on.

        Returns:
            Nothing.

        N)r,   )rT   r,   s     r[   
set_hiddenzFormat.set_hidden  rq   r\   c                    |                                 }|dk    r|                     d           |dk    r|                     d           |dk    r|                     d           |dk    r|                     d           |dk    r|                     d	           |d
k    r|                     d           |dk    r|                     d           |dk    r|                     d           |dk    r|                     d           |dk    r|                     d           |dk    rd| _        |dk    r|                     d           |dk    r|                     d           |dk    r|                     d           |dk    r|                     d           |dk    r|                     d	           |dk    r|                     d           dS dS )z
        Set the Format cell alignment.

        Args:
            alignment: String representing alignment. No default.

        Returns:
            Nothing.
        rC   r   centrer   centerrE      fill   justify   center_across   centre_acrossdistributed   justify_distributedrG   vcentrevcenterr>   vjustifyvdistributedN)lowerset_text_h_alignrM   set_text_v_align)rT   	alignments     r[   	set_alignzFormat.set_align%  s*    OO%%	 !!!$$$  !!!$$$  !!!$$$!!!$$$!!!$$$	!!!!!$$$''!!!$$$''!!!$$$%%!!!$$$---!!!$$$--- !D !!!$$$	!!!!!$$$	!!!!!$$$  !!!$$$
""!!!$$$&&!!!$$$$$ '&r\   c                 0    |                      d           dS )z`
        Set the Format center_across property.

        Returns:
            Nothing.

        r   N)r   )rT   
align_types     r[   set_center_acrosszFormat.set_center_acrossX  s     	a     r\   c                     || _         dS )z
        Set the Format text_wrap property.

        Args:
            text_wrap: Default is True, turns property on.

        Returns:
            Nothing.

        N)r/   )rT   r/   s     r[   set_text_wrapzFormat.set_text_wrapb  re   r\   c                     t          |          }|dk    rd}n.d|cxk    rdk    rn n|dk     r| dz   }nt          d           dS || _        dS )z
        Set the Format rotation property.

        Args:
            rotation: Rotation angle. No default.

        Returns:
            Nothing.

        i     iZ   r   z3Rotation rotation outside range: -90 <= angle <= 90N)intr   r2   )rT   r2   s     r[   set_rotationzFormat.set_rotationo  sw     x== s??HHH"""""""""!||$9r>FGGGF r\   c                     || _         dS )z
        Set the Format indent property.

        Args:
            indent: Default is 1, first indentation level.

        Returns:
            Nothing.

        N)rI   )rT   rI   s     r[   
set_indentzFormat.set_indent  rq   r\   c                     || _         dS )z
        Set the Format shrink property.

        Args:
            shrink: Default is True, turns property on.

        Returns:
            Nothing.

        N)rJ   )rT   rJ   s     r[   
set_shrinkzFormat.set_shrink  rq   r\   c                     || _         dS )z
        Set the Format text_justlast property.

        Args:
            text_justlast: Default is True, turns property on.

        Returns:
            Nothing.

        N)r1   )rT   r1   s     r[   set_text_justlastzFormat.set_text_justlast  s     +r\   c                     || _         dS )z
        Set the Format pattern property.

        Args:
            pattern: Default is 1, solid fill.

        Returns:
            Nothing.

        N)r5   )rT   r5   s     r[   set_patternzFormat.set_pattern  s     r\   c                 :    |                      |          | _        dS )z
        Set the Format bg_color property.

        Args:
            bg_color: Background color. No default.

        Returns:
            Nothing.

        N)rh   r4   )rT   r4   s     r[   set_bg_colorzFormat.set_bg_color       11r\   c                 :    |                      |          | _        dS )z
        Set the Format fg_color property.

        Args:
            fg_color: Foreground color. No default.

        Returns:
            Nothing.

        N)rh   r3   )rT   r3   s     r[   set_fg_colorzFormat.set_fg_color  r   r\   c                     |                      |           |                     |           |                     |           |                     |           dS z
        Set the Format bottom property.

        Args:
            bottom: Default is 1, border type 1.

        Returns:
            Nothing.

        N)
set_bottomset_topset_left	set_right)rT   styles     r[   
set_borderzFormat.set_border  sR     	Ueur\   c                     |                      |           |                     |           |                     |           |                     |           dS )z
        Set the Format bottom property.

        Args:
            color: Color string. No default.

        Returns:
            Nothing.

        N)set_bottom_colorset_top_colorset_left_colorset_right_color)rT   colors     r[   set_border_colorzFormat.set_border_color  sZ     	e$$$5!!!E"""U#####r\   c                     || _         dS r   )r>   )rT   r>   s     r[   r   zFormat.set_bottom  rq   r\   c                 :    |                      |          | _        dS )z
        Set the Format bottom_color property.

        Args:
            bottom_color: Color string. No default.

        Returns:
            Nothing.

        N)rh   r?   )rT   r?   s     r[   r   zFormat.set_bottom_color  s     !OOL99r\   c                     || _         dS )z
        Set the Format diag_type property.

        Args:
            diag_type: Default is 1, border type 1.

        Returns:
            Nothing.

        N)rB   )rT   rB   s     r[   set_diag_typezFormat.set_diag_type  re   r\   c                     || _         dS )z
        Set the Format left property.

        Args:
            left: Default is 1, border type 1.

        Returns:
            Nothing.

        N)rC   )rT   rC   s     r[   r   zFormat.set_left  rn   r\   c                 :    |                      |          | _        dS )z
        Set the Format left_color property.

        Args:
            left_color: Color string. No default.

        Returns:
            Nothing.

        N)rh   rD   )rT   rD   s     r[   r   zFormat.set_left_color,  rk   r\   c                     || _         dS )z
        Set the Format right property.

        Args:
            right: Default is 1, border type 1.

        Returns:
            Nothing.

        N)rE   )rT   rE   s     r[   r   zFormat.set_right9  s     


r\   c                 :    |                      |          | _        dS )z
        Set the Format right_color property.

        Args:
            right_color: Color string. No default.

        Returns:
            Nothing.

        N)rh   rF   )rT   rF   s     r[   r   zFormat.set_right_colorF  s      ??;77r\   c                     || _         dS )z
        Set the Format top property.

        Args:
            top: Default is 1, border type 1.

        Returns:
            Nothing.

        N)rG   )rT   rG   s     r[   r   zFormat.set_topS  s     r\   c                 :    |                      |          | _        dS )z
        Set the Format top_color property.

        Args:
            top_color: Color string. No default.

        Returns:
            Nothing.

        N)rh   rH   )rT   rH   s     r[   r   zFormat.set_top_color`  s     33r\   c                 :    |                      |          | _        dS )z
        Set the Format diag_color property.

        Args:
            diag_color: Color string. No default.

        Returns:
            Nothing.

        N)rh   rA   )rT   rA   s     r[   set_diag_colorzFormat.set_diag_colorm  rk   r\   c                     || _         dS )z
        Set the Format diag_border property.

        Args:
            diag_border: Default is 1, border type 1.

        Returns:
            Nothing.

        N)r@   )rT   r@   s     r[   set_diag_borderzFormat.set_diag_borderz  rx   r\   c                     || _         dS )z
        Set the Format quote prefix property.

        Args:
            quote_prefix: Default is True, turns property on.

        Returns:
            Nothing.

        N)rP   )rT   rP   s     r[   set_quote_prefixzFormat.set_quote_prefix  r{   r\   c                     || _         d S N)r   )rT   r   s     r[   set_has_fontzFormat.set_has_font       r\   c                     || _         d S r   )r6   )rT   r6   s     r[   set_has_fillzFormat.set_has_fill  r   r\   c                     || _         d S r   )r   )rT   r   s     r[   set_font_indexzFormat.set_font_index  s    $r\   c                     || _         d S r   )r   )rT   r   s     r[   set_xf_indexzFormat.set_xf_index  r   r\   c                     || _         d S r   )r   )rT   r   s     r[   set_dxf_indexzFormat.set_dxf_index      "r\   c                     || _         d S r   )r   )rT   r   s     r[   set_num_format_indexzFormat.set_num_format_index  s     0r\   c                     || _         d S r   )r.   )rT   r.   s     r[   r   zFormat.set_text_h_align      (r\   c                     || _         d S r   )r0   )rT   r0   s     r[   r   zFormat.set_text_v_align  r   r\   r   c                     || _         d S r   )rL   )rT   	directions     r[   set_reading_orderzFormat.set_reading_order  s    &r\   c                 0    |                      |           d S r   )r   )rT   aligns     r[   
set_valignzFormat.set_valign  s     	ur\   c                     || _         d S r   )r$   )rT   r$   s     r[   set_font_familyzFormat.set_font_family      &r\   c                     || _         d S r   )r%   )rT   r%   s     r[   set_font_charsetzFormat.set_font_charset  r   r\   c                     || _         d S r   )r&   )rT   r&   s     r[   set_font_schemezFormat.set_font_scheme  r   r\   c                     || _         d S r   )r'   )rT   r'   s     r[   set_font_condensezFormat.set_font_condense  s    *r\   c                     || _         d S r   )r(   )rT   r(   s     r[   set_font_extendzFormat.set_font_extend  r   r\   c                     || _         d S r   )r)   )rT   r)   s     r[   	set_themezFormat.set_theme  s    


r\   c                 v    d| _         |                     d           |                     d           || _        d S )Nr   
   )r+   rs   r   r*   )rT   r*   s     r[   set_hyperlinkzFormat.set_hyperlink  s<     
1r"r\   c                     || _         d S r   )rN   )rT   color_indexs     r[   set_color_indexedzFormat.set_color_indexed  s    (r\   c                     || _         d S r   )rO   )rT   rO   s     r[   set_font_onlyzFormat.set_font_only  r   r\   c                     || _         d S r   r^   r_   s     r[   set_fontzFormat.set_font  r   r\   c                     || _         d S r   rb   rc   s     r[   set_sizezFormat.set_size  r   r\   c                 :    |                      |          | _        d S r   rg   ri   s     r[   	set_colorzFormat.set_color  s    //*55r\   c                 f   d}g }| j         s*| j        s#| j        s| j        s| j        s| j        s| j        rd}n||fS | j        rI| j         dk    r>| j         dk    r3| j         dk    r(| j        dk    r| j        dk    r| j        dk    rd| _         | j        rd| _        | j         dk    rd| _        | j         dk    rd| _        | j         dk    rd| _        | j         dk    rd| _        | j        rd| _        d}| j         dk    r|                    d           | j         d	k    r|                    d
           | j         dk    r|                    d           | j         dk    r|                    d           | j         dk    r|                    d           | j         dk    r|                    d|f           | j         dk    r|                    d           | j        r|                    d           | j        dk    r|                    d           | j        d	k    r|                    d           | j        dk    r|                    d           | j        dk    r|                    d           | j        r|                    d| j        f           | j        r|                    d| j        f           | j        r|                    d           | j        r|                    d           | j        dk    r|                    d           | j        d	k    r|                    d           ||fS )Nr   r   r   r   r   r   centerContinuous)
horizontalrC   r   )r  r   )r  rE   )r  r   )r  r   r   r  )r  r   )justifyLastLiner   )verticalrG   )r  r   )r  r   )r  r   textRotationrI   )wrapTextr   )shrinkToFitr   )readingOrderr   )r  r   )	r.   r0   rI   r2   r/   rJ   rL   rM   append)rT   changedr   
continuouss       r[   _get_align_propertieszFormat._get_align_properties   s    	" 	" {	" }		"
 ~	" {	" !	" GGE>! K		"!Q&&!Q&&!Q&&!Q&&!Q&&!Q&& !D > 	DK!!DK!!DK!!DK!! !D; 	" !D'
!!LL/000!!LL1222!!LL0111!!LL/000!!LL2333!!LL,
3444!!LL6777 	1LL/000 !!LL,---!!LL/000!!LL0111!!LL4555= 	:LL.$-8999; 	2LL(DK0111> 	*LL))); 	-LL+,,,""LL,---""LL,---~r\   c                 z    g }| j         s|                    d           | j        r|                    d           |S )N)r-   r   )r,   r   )r-   r  r,   )rT   attribss     r[   _get_protection_propertiesz!Format._get_protection_properties_  sD    { 	*NN=))); 	*NN=)))r\   c                 .   | j         d                    d |                                 |                                 |                                 |                                 | j        | j        | j        | j	        fD                       | _         | j         S )N:c              3   4   K   | ]}t          |          V  d S r   str.0xs     r[   	<genexpr>z)Format._get_format_key.<locals>.<genexpr>m  s<       ( ( A( ( ( ( ( (r\   )
rS   join_get_font_key_get_border_key_get_fill_key_get_alignment_keyr   r-   rP   r,   )rT   s    r[   _get_format_keyzFormat._get_format_keyj  s    #"xx ( ( &&((((**&&((++--OK%K	( ( (    D r\   c                     d                     d | j        | j        | j        | j        | j        | j        | j        | j        | j	        | j
        | j        | j        | j        fD                       }|S )Nr  c              3   4   K   | ]}t          |          V  d S r   r  r  s     r[   r  z'Format._get_font_key.<locals>.<genexpr>  s<       
 
 FF
 
 
 
 
 
r\   )r  r   r   r%   r$   r!   r#   r"   r    r   r   r   r   r)   rT   rX   s     r[   r  zFormat._get_font_key}  s    hh 
 
 	! !  #

 
 
 
 
& 
r\   c                     d                     d | j        | j        | j        | j        | j        | j        | j        | j        | j	        | j
        | j        fD                       }|S )Nr  c              3   4   K   | ]}t          |          V  d S r   r  r  s     r[   r  z)Format._get_border_key.<locals>.<genexpr>  s<       
 
 FF
 
 
 
 
 
r\   )r  r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   r%  s     r[   r  zFormat._get_border_key  sv    hh 
 
 ! 	
 
 
 
 
 
" 
r\   c                 h    d                     d | j        | j        | j        fD                       }|S )Nr  c              3   4   K   | ]}t          |          V  d S r   r  r  s     r[   r  z'Format._get_fill_key.<locals>.<genexpr>  s(      TT!s1vvTTTTTTr\   )r  r5   r4   r3   r%  s     r[   r   zFormat._get_fill_key  s4    hhTTdmT]'STTTTT
r\   c           
          d                     d | j        | j        | j        | j        | j        | j        | j        fD                       }|S )Nr  c              3   4   K   | ]}t          |          V  d S r   r  r  s     r[   r  z,Format._get_alignment_key.<locals>.<genexpr>  s<       
 
 FF
 
 
 
 
 
r\   )r  r.   r0   rI   r2   r/   rJ   rL   r%  s     r[   r!  zFormat._get_alignment_key  sd     hh 
 
 !!"
 
 
 
 
 
r\   c                     | j         | j         S |                                 }|| j        v r| j        |         S dt          | j                  z   }|| j        |<   || _         |S )Nr   )r   r"  r   lenrT   rX   indexs      r[   _get_xf_indexzFormat._get_xf_index  sq    =$=  &&((Cd,,,-c22 C 6777.3&s+ %r\   c                     | j         | j         S |                                 }|| j        v r| j        |         S t          | j                  }|| j        |<   || _         |S r   )r   r"  r   r-  r.  s      r[   _get_dxf_indexzFormat._get_dxf_index  sl    >%>! &&((Cd---.s33 D344/4',!&r\   c                     i ddddddddd	d
ddddddddddddddddddddddd d!}||v r||         }|S )"Nblackz#000000bluez#0000FFbrownz#800000cyanz#00FFFFgrayz#808080greenz#008000limez#00FF00magentaz#FF00FFnavyz#000080orangez#FF6600pinkpurplez#800080redz#FF0000silverz#C0C0C0whitez#FFFFFFyellowz#FFFF00	automatic	Automatic )rT   r   named_colorss      r[   rh   zFormat._get_color  s    
Y
I
 Y
 I	

 I
 Y
 I
 y
 I
 i
 I
 i
 9
 i
 Y
  i!
" #
( L   'Er\   )NNN)r   )T)r   r   )r   )K__name__
__module____qualname____doc__r   r`   rd   rj   rm   rp   rs   ru   rw   rz   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   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r"  r  r  r   r!  r0  r2  rh   __classcell__)rZ   s   @r[   r   r      s        X  X  X  X  X  X @# # ## # # #6 6 6      # # # #- - - -' ' ' ') ) ) )' ' ' '% % %      1% 1% 1%f! ! ! !# # # #! ! !2      + + + +   2 2 22 2 2   "$ $ $    : : :# # # #   6 6 6   8 8 8   4 4 46 6 6' ' ' ') ) ) )(! ! ! !! ! ! !% % %! ! !# # #1 1 1) ) )) ) )' ' ' '  ' ' ') ) )' ' '+ + +' ' '  # # # #) ) )# # # #
# # ## # #6 6 6] ] ]~	 	 	     &  .  *    $  (  &      r\   r   N) r   warningsr   	XMLwriterr   rF  r\   r[   <module>rP     sl               u u u u uY  u u u u ur\   