
    ,h-                     ~    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  G d d      Z G d dej                        Zy	)
    )DictListOptionalUnion   )	xmlwriter)_preserve_whitespace	_xl_colorxl_cell_to_rowcolxl_rowcol_to_cellc                       e Zd ZdZ	 d
dedededeeeeeee	f   f      fdZ
	 d
deeeeeee	f   f      fdZdedefd	Zy)CommentTypez@
    A class to represent a comment in an Excel worksheet.

    Nrowcoltextoptionsc                 n   || _         || _        || _        d| _        d| _        d| _        d| _        d| _        d| _        d| _	        d| _
        d| _        d| _        d| _        d| _        d| _        d	| _        g | _        | j%                  | j                   | j                         | j'                  |       y)
a  
        Initialize a Comment instance.

        Args:
            row (int): The row number of the comment.
            col (int): The column number of the comment.
            text (str): The text of the comment.
            options (dict): Additional options for the comment.
        Nz#ffffe1r      J   r      Tahoma   )r   r   r   authorcolor	start_row	start_col
is_visiblewidthheightx_scaley_scalex_offsety_offset	font_size	font_namefont_familyverticesset_offsets_set_user_options)selfr   r   r   r   s        U/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/xlsxwriter/comments.py__init__zCommentType.__init__    s      	%)#
*.
 !& !13 	488, 	w'    c                 X   |y|j                  d      }|rt        |t        t        f      r|| _        |j                  d      }|rt        |t        t        f      r|| _        |j                  d      }|rt        |t              r|| _        |j                  d      }|rt        |t              r|| _        |j                  d      }|rt        |t              r|| _        |j                  d      }|rt        |t              r|| _	        |j                  d      }|rt        |t        t        f      r|| _
        |j                  d	      }	|	rt        |	t              r|	| _        |j                  d
      }
|
rt        |
t              r|
| _        |j                  d      }|rt        |t              r|| _        |j                  d      }|t        |t              r|| _        |j                  d      }|rAt        |t              r1t#        |      j%                         }|j'                  ddd      | _        |j                  d      }|r,t        |t              rt+        |      \  }}|| _	        || _        |j                  d      }|r*t        |t        t        f      r| j                  |z  | _        |j                  d      }|r*t        |t        t        f      r| j
                  |z  | _        t        d| j                  z         | _        t        d| j
                  z         | _        y)zh
        This method handles the additional optional parameters to
        ``write_comment()``.
        Nr   r   r"   r#   r   r   r$   r%   r&   r   visibler   ff#r   
start_cellr    r!   g      ?)get
isinstanceintfloatr   r   r"   r#   r   r   r$   strr%   r&   r   boolr   r
   lowerreplacer   r   )r*   r   r   r   r"   r#   r   r   r$   r%   r&   r   r/   r   r2   r    r!   s                    r+   r)   zCommentType._set_user_optionsP   s    ? G$ZU|4DJX&j#u6 DK;;z*
8S1$DM;;z*
8S1$DMKK,	Is3&DNKK,	Is3&DNKK,	IU|<&DNKK,	Is3&DNkk-0:k37*DX&j- DK++i(:gt#<%DOG$Zs+e$**,E tS!4DJ [[.
*Z5%6z%B"Y	&DN&DN ++i(z'C<8g-DJ++i(z'C<8++/DK tzz)*
#+,r-   c                 <   d}d}| j                   dk(  rd| _        d| _        n}| j                   |dz
  k(  rd| _        |dz
  | _        nY| j                   |dz
  k(  rd| _        |dz
  | _        n5| j                   |d	z
  k(  rd
| _        |dz
  | _        nd| _        |d	z
  | _        | j                  |dz
  k(  rd| _        |dz
  | _        y| j                  |dz
  k(  rd| _        |dz
  | _        y| j                  |d	z
  k(  rd| _        |dz
  | _        yd| _        |d	z   | _        y)z
        Set the default start cell and offsets for the comment. These are
        generally a fixed offset relative to the parent cell. However there are
        some edge cases for cells at the, well, edges.
        i   i @  r   r               r         
   1         N)r   r#   r   r   r"   r   )r*   r   r   row_maxcol_maxs        r+   r(   zCommentType.set_offsets   s    88q=DMDNXX1$DM$q[DNXX1$DM$q[DNXX1$DM$q[DNDM 1WDN88w{"DM$q[DNXX1$DM$q[DNXX1$DM$q[DNDM 1WDNr-   N)__name__
__module____qualname____doc__r5   r7   r   r   r   r6   r,   r)   r(    r-   r+   r   r      s     @D.(.( .( 	.(
 $sE#sE/$::;<.(b FJR-S%S%*@%@ ABR-h$%s $% $%r-   r   c                        e Zd ZdZ fdZddeee      fdZd Z	dee   fdZ
defd	Zdee   fd
ZdedefdZdefdZdefdZdefdZdefdZdefdZd ZdefdZdefdZ xZS )Commentsz=
    A class for writing the Excel XLSX Comments file.


    c                 0    t         |           i | _        y)z
        Constructor.

        N)superr,   
author_ids)r*   	__class__s    r+   r,   zComments.__init__   s     	r-   comments_datac                     |g }| j                          | j                          | j                  |       | j                  |       | j	                  d       | j                          y )Ncomments)_xml_declaration_write_comments_write_authors_write_comment_list_xml_end_tag
_xml_close)r*   rT   s     r+   _assemble_xml_filezComments._assemble_xml_file   se      M 	 	 	M* 	  /*% 	r-   c                 6    d}d|fg}| j                  d|       y )Nz9http://schemas.openxmlformats.org/spreadsheetml/2006/mainxmlnsrV   )_xml_start_tag)r*   r_   
attributess      r+   rX   zComments._write_comments	  s$    K&'
J
3r-   comment_datac                     d}| j                  d       |D ]E  }|j                  }||| j                  vs!|| j                  |<   |dz  }| j                  |       G | j	                  d       y )Nr   authorsr   )r`   r   rR   _write_authorr[   )r*   rb   author_countcommentr   s        r+   rY   zComments._write_authors  sv    I&# 		+G^^F!fDOO&C*6'! ""6*		+ 	)$r-   datac                 (    | j                  d|       y )Nr   )_xml_data_element)r*   rh   s     r+   re   zComments._write_author$  s    x.r-   c                     | j                  d       |D ];  }d}|j                  | j                  |j                     }| j                  ||       = | j	                  d       y )NcommentList)r`   r   rR   _write_commentr[   )r*   rb   rg   	author_ids       r+   rZ   zComments._write_comment_list(  sb    M*# 	4GI~~) OOGNN;	 3	4 	-(r-   rg   ro   c                     t        |j                  |j                        }d|fg}|dk7  r|j                  d| f       | j	                  d|       | j                  |       | j                  d       y )Nrefrm   authorIdrg   )r   r   r   appendr`   _write_textr[   )r*   rg   ro   rq   ra   s        r+   rn   zComments._write_comment7  sk    W[[9cl^
?zi[:;Iz2 	!)$r-   c                 j    | j                  d       | j                  |       | j                  d       y )Nr   )r`   _write_text_rr[   r*   rg   s     r+   rt   zComments._write_textG  s.    F# 	7#&!r-   c                     | j                  d       | j                  |       | j                  |j                         | j	                  d       y )Nr)r`   _write_r_pr_write_text_tr   r[   rw   s     r+   rv   zComments._write_text_rP  sB    C  	! 	7<<(#r-   r   c                 f    g }t        |      r|j                  d       | j                  d||       y )N)z	xml:spacepreservet)r	   rs   rj   )r*   r   ra   s      r+   r{   zComments._write_text_t\  s0    
%78sD*5r-   c                 
   | j                  d       | j                  |j                         | j                          | j	                  |j
                         | j                  |j                         | j                  d       y )NrPr)	r`   	_write_szr$   _write_color_write_r_fontr%   _write_familyr&   r[   rw   s     r+   rz   zComments._write_r_pre  sl    E" 	w(() 	 	7,,- 	7../% r-   r$   c                 2    d|fg}| j                  d|       y )Nvalsz_xml_empty_tag)r*   r$   ra   s      r+   r   zComments._write_szw  s    i()
D*-r-   c                 .    dg}| j                  d|       y )N)indexedQ   r   r   )r*   ra   s     r+   r   zComments._write_color}  s    %&
GZ0r-   r%   c                 2    d|fg}| j                  d|       y )Nr   rFontr   )r*   r%   ra   s      r+   r   zComments._write_r_font  s    i()
GZ0r-   r&   c                 2    d|fg}| j                  d|       y )Nr   familyr   )r*   r&   ra   s      r+   r   zComments._write_family  s    k*+
Hj1r-   rH   )rI   rJ   rK   rL   r,   r   r   r   r]   rX   rY   r7   re   rZ   r5   rn   rt   rv   r{   rz   r6   r   r   r   r   __classcell__)rS   s   @r+   rO   rO      s    k9J0K :4%4+< %&/# /)[0A )%k %c % "; "
[ 
6# 6!; !$.5 .11s 12 2r-   rO   N)typingr   r   r   r    r   utilityr	   r
   r   r   r   	XMLwriterrO   rM   r-   r+   <module>r      s;    / .  n% n%l}2y"" }2r-   