
    ,heG                     \   d Z ddlmZmZmZmZ ddlmZ ddlm	Z	 ddl
m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 dd
lmZm Z   G d de      Z! G d de      Z" G d de      Z# G d de      Z$ G d de      Z% G d de      Z& G d de      Z' G d de(      Z)y)z5Custom element classes for table-related XML elements    )absolute_importdivisionprint_functionunicode_literals)MSO_VERTICAL_ANCHOR)	parse_xml)CT_GradientFillPropertiesnsdecls)ST_CoordinateST_Coordinate32
XsdBooleanXsdInt)CT_TextBody)BaseOxmlElementChoiceOneAndOnlyOneOptionalAttributeRequiredAttribute
ZeroOrMore	ZeroOrOneZeroOrOneChoice)Emulazypropertyc                      e Zd ZdZdZ ededd       Z ed      Z e	ded	d       Z
[d
 Zed        Zej                  d        Zed        Zej                  d        Zed        Zej                  d        Zed        Zej                  d        Zd Zed        Zej                  d        Zed        Zej                  d        Zedd       Zd Zd Zd Zed        Zy)CT_Tablez`a:tbl` custom element class)a:tblPr	a:tblGrida:trr      N
successorsr   r      c                 &    | j                  |      S )z
        Return a reference to a newly created <a:tr> child element having its
        ``h`` attribute set to *height*.
        )h)_add_tr)selfheights     Q/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pptx/oxml/table.pyadd_trzCT_Table.add_tr#   s    
 ||f|%%    c                 $    | j                  d      S NbandCol_get_boolean_propertyr'   s    r)   r.   zCT_Table.bandCol*       )))44r+   c                 (    | j                  d|       y r-   _set_boolean_propertyr'   values     r)   r.   zCT_Table.bandCol.       ""9e4r+   c                 $    | j                  d      S NbandRowr/   r1   s    r)   r;   zCT_Table.bandRow2   r2   r+   c                 (    | j                  d|       y r:   r4   r6   s     r)   r;   zCT_Table.bandRow6   r8   r+   c                 $    | j                  d      S NfirstColr/   r1   s    r)   r?   zCT_Table.firstCol:       ))*55r+   c                 (    | j                  d|       y r>   r4   r6   s     r)   r?   zCT_Table.firstCol>       "":u5r+   c                 $    | j                  d      S NfirstRowr/   r1   s    r)   rE   zCT_Table.firstRowB   r@   r+   c                 (    | j                  d|       y rD   r4   r6   s     r)   rE   zCT_Table.firstRowF   rB   r+   c                 (    d | j                   D        S )zsGenerate each `a:tc` element in this tbl.

        tc elements are generated left-to-right, top-to-bottom.
        c              3   B   K   | ]  }|j                   D ]  }|   y wN)tc_lst).0trtcs      r)   	<genexpr>z$CT_Table.iter_tcs.<locals>.<genexpr>O   s      =r299=R==s   )tr_lstr1   s    r)   iter_tcszCT_Table.iter_tcsJ   s    
 >T[[==r+   c                 $    | j                  d      S NlastColr/   r1   s    r)   rS   zCT_Table.lastColQ   r2   r+   c                 (    | j                  d|       y rR   r4   r6   s     r)   rS   zCT_Table.lastColU   r8   r+   c                 $    | j                  d      S NlastRowr/   r1   s    r)   rW   zCT_Table.lastRowY   r2   r+   c                 (    | j                  d|       y rV   r4   r6   s     r)   rW   zCT_Table.lastRow]   r8   r+   c                    |d}| j                         |z  }t        |      }||z  }||z  }	t        |      D ]1  }
|
|dz
  k(  r||dz
  |	z  z
  }	|j                  j	                  |	       3 t        |      D ]G  }||dz
  k(  r||dz
  |z  z
  }|j                  |      }t        |      D ]  }
|j                           I |S )z&Return a new ``<p:tbl>`` element tree.z&{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}r    )width)r(   )	_tbl_tmplr   rangetblGridadd_gridColr*   add_tc)clsrowscolsrZ   r(   tableStyleIdxmltbl	rowheightcolwidthcolrowrL   s                r)   new_tblzCT_Table.new_tbla   s     CLmmo.n dN	D=; 	4CdQh TAX$9:KK##(#3		4 ; 	CdQh"tax9&<=	9-BT{ 			 
r+   c                 :    | j                   |   j                  |   S )z.Return `a:tc` element at *row_idx*, *col_idx*.)rO   rJ   )r'   row_idxcol_idxs      r)   rM   zCT_Table.tc   s    {{7#**733r+   c                 J    | j                   }|yt        ||      }dddd|   S )z
        Generalized getter for the boolean properties on the ``<a:tblPr>``
        child element. Defaults to False if *propname* attribute is missing
        or ``<a:tblPr>`` element itself is not present.
        FT)TFN)tblPrgetattr)r'   propnamero   propvals       r)   r0   zCT_Table._get_boolean_property   s3     

=%*56w??r+   c                 b    |dvrt        d|z        | j                         }t        |||       y)a  
        Generalized setter for boolean properties on the ``<a:tblPr>`` child
        element, setting *propname* attribute appropriately based on *value*.
        If *value* is True, the attribute is set to "1"; a tblPr child
        element is added if necessary. If *value* is False, the *propname*
        attribute is removed if present, allowing its default value of False
        to be its effective value.
        )TFz3assigned value must be either True or False, got %sN)
ValueErrorget_or_add_tblPrsetattr)r'   rq   r7   ro   s       r)   r5   zCT_Table._set_boolean_property   s=     %EM  %%'x'r+   c                 &    dt        d      dddS )Nz<a:tbl az;>
  <a:tblPr firstRow="1" bandRow="1">
    <a:tableStyleId>z%sz6</a:tableStyleId>
  </a:tblPr>
  <a:tblGrid/>
</a:tbl>r
   r`   s    r)   r[   zCT_Table._tbl_tmpl   s     "#,.	
r+   rI   )__name__
__module____qualname____doc___tag_seqr   ro   r   r]   r   rL   r*   propertyr.   setterr;   r?   rE   rP   rS   rW   classmethodrj   rM   r0   r5   r[    r+   r)   r   r      s   &/HiHQRL9EK(G	Fx|	4B& 5 5 ^^5 5 5 5 ^^5 5 6 6 __6 6 6 6 __6 6> 5 5 ^^5 5 5 5 ^^5 5  :4
@(  
 
r+   r   c                   >   e Zd ZdZdZ ededd       Z ededd       Z[ ed	e	d
      Z
 ede	d
      Z eded
      Z eded
      Zed        Zej"                  d        Zd Zed        Zed        Zed        Zed        Zej"                  d        Zed        Zej"                  d        Zed        Zej"                  d        Zed        Zej"                  d        Zed        Zed        Zed        Zed         Zd! Zd" Z d# Z!ed$        Z"y)%CT_TableCellz`a:tc` custom element class)a:txBodya:tcPra:extLstr   r    Nr!   r      gridSpandefaultrowSpanhMergeFvMergec                 H    | j                   y| j                   j                  S )zw
        String held in ``anchor`` attribute of ``<a:tcPr>`` child element of
        this ``<a:tc>`` element.
        N)tcPranchorr1   s    r)   r   zCT_TableCell.anchor   s!     99yyr+   c                 P    || j                   y| j                         }||_        y)zM
        Set value of anchor attribute on ``<a:tcPr>`` child element
        N)r   get_or_add_tcPrr   )r'   anchor_enum_idxr   s      r)   r   zCT_TableCell.anchor   s+    
 "tyy'8##%%r+   c                    |j                         }| j                         }|j                  ry|j                  r|j                          |j                  D ]  }|j	                  |        |j                          |j                          y)aS  Append `a:p` elements taken from *spanned_tc*.

        Any non-empty paragraph elements in *spanned_tc* are removed and
        appended to the text-frame of this cell. If *spanned_tc* is left with
        no content after this process, a single empty `a:p` element is added
        to ensure the cell is compliant with the spec.
        N)get_or_add_txBodyis_emptyclear_contentp_lstappendunclear_content)r'   
spanned_tcsource_txBodytarget_txBodyps        r)   append_ps_fromzCT_TableCell.append_ps_from   s     #446..0 !! !!'')$$ 	$A  #	$ 	%%'%%'r+   c                 @    | j                         j                  |       S )z*Offset of this cell's column in its table.)	getparentindexr1   s    r)   rm   zCT_TableCell.col_idx   s     ~~%%d++r+   c                 t    | j                   dkD  r| j                  sy| j                  dkD  r| j                  syy)z.True if cell is top-left in merged cell range.r    TF)r   r   r   r   r1   s    r)   is_merge_originzCT_TableCell.is_merge_origin   s1     ==1T[[<<!DKKr+   c                 6    | j                   xs | j                  S )z?True if cell is in merged cell range but not merge origin cell.)r   r   r1   s    r)   
is_spannedzCT_TableCell.is_spanned   s     {{)dkk)r+   c                 &    | j                  dd      S )a  
        Read/write integer top margin value represented in ``marT`` attribute
        of the ``<a:tcPr>`` child element of this ``<a:tc>`` element. If the
        attribute is not present, the default value ``45720`` (0.05 inches)
        is returned for top and bottom; ``91440`` (0.10 inches) is the
        default for left and right. Assigning |None| to any ``marX``
        property clears that attribute from the element, effectively setting
        it to the default value.
        marT防  	_get_marXr1   s    r)   r   zCT_TableCell.marT   s     ~~fe,,r+   c                 (    | j                  d|       y )Nr   	_set_marXr6   s     r)   r   zCT_TableCell.marT      vu%r+   c                 &    | j                  dd      S )zG
        Right margin value represented in ``marR`` attribute.
        marR0e r   r1   s    r)   r   zCT_TableCell.marR      
 ~~fe,,r+   c                 (    | j                  d|       y )Nr   r   r6   s     r)   r   zCT_TableCell.marR  r   r+   c                 &    | j                  dd      S )zH
        Bottom margin value represented in ``marB`` attribute.
        marBr   r   r1   s    r)   r   zCT_TableCell.marB  r   r+   c                 (    | j                  d|       y )Nr   r   r6   s     r)   r   zCT_TableCell.marB  r   r+   c                 &    | j                  dd      S )zF
        Left margin value represented in ``marL`` attribute.
        marLr   r   r1   s    r)   r   zCT_TableCell.marL!  r   r+   c                 (    | j                  d|       y )Nr   r   r6   s     r)   r   zCT_TableCell.marL(  r   r+   c                 <    | j                         }t        |      }|S )z$Return a new `a:tc` element subtree.)_tc_tmplr   )r`   rd   rM   s      r)   newzCT_TableCell.new,  s     llns^	r+   c                 6    | j                         j                  S )z'Offset of this cell's row in its table.)r   rl   r1   s    r)   rl   zCT_TableCell.row_idx3  s     ~~'''r+   c                 *    | j                  d      d   S )z#Table element this cell belongs to.zancestor::a:tblr   )xpathr1   s    r)   re   zCT_TableCell.tbl8  s     zz+,Q//r+   c                     | j                   }|ydj                  |j                  D cg c]  }|j                   c}      S c c}w )zstr text contained in cell 
)txBodyjoinr   text)r'   r   r   s      r)   r   zCT_TableCell.text=  s:     >yy&,,7Q!&&7887s   Ac                     | j                   t        |      S t        t        | j                   j                  ||                  S )z:
        Generalized method to get margin values.
        )r   r   intget)r'   	attr_namer   s      r)   r   zCT_TableCell._get_marXF  s7     99w<3tyy}}Y89::r+   c                 *    t        j                         S rI   )r   new_a_txBodyr1   s    r)   _new_txBodyzCT_TableCell._new_txBodyN  s    ''))r+   c                 \    || j                   y| j                         }t        |||       y)z
        Set value of marX attribute on ``<a:tcPr>`` child element. If *marX*
        is |None|, the marX attribute is removed. *marX* is a string, one of
        ``('marL', 'marR', 'marT', 'marB')``.
        N)r   r   rv   )r'   marXr7   r   s       r)   r   zCT_TableCell._set_marXQ  s/     =TYY.##%dE"r+   c                     dt        d      z  S )Nze<a:tc %s>
  <a:txBody>
    <a:bodyPr/>
    <a:lstStyle/>
    <a:p/>
  </a:txBody>
  <a:tcPr/>
</a:tc>rx   r
   ry   s    r)   r   zCT_TableCell._tc_tmpl\  s      %		
r+   )#rz   r{   r|   r}   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rm   r   r   r   r   r   r   r   r   rl   re   r   r   r   r   r   r   r+   r)   r   r      s   %1Hzhqrl;FX(12,7D VQ?H	61=GxUCFxUCF    ]]& &(4 , ,
   * * 
- 
- 
[[& & - - 
[[& & - - 
[[& & - - 
[[& &   ( ( 0 0 9 9;*	# 

 

r+   r   c            
           e Zd ZdZ e ed       ed       ed       ed       ed       ed      fd	      Z ed
e      Z	 ede
      Z ede
      Z ede
      Z ede
      Zd Zy)CT_TableCellPropertiesz`a:tcPr` custom element classza:noFillza:solidFillz
a:gradFillz
a:blipFillz
a:pattFillz	a:grpFill)z	a:headersr   r!   r   r   r   r   r   c                 *    t        j                         S rI   )r	   new_gradFillr1   s    r)   _new_gradFillz$CT_TableCellProperties._new_gradFill~  s    (5577r+   N)rz   r{   r|   r}   r   r   eg_fillPropertiesr   r   r   r   r   r   r   r   r   r   r+   r)   r   r   j  s    '':=!< < < ;	
 -
 x)<=FV_5DV_5DV_5DV_5D8r+   r   c                   "    e Zd ZdZ ede      Zy)CT_TableColz.
    ``<a:gridCol>`` custom element class
    wN)rz   r{   r|   r}   r   r   r   r   r+   r)   r   r     s     	#}-Ar+   r   c                   &    e Zd ZdZ ed      Zd Zy)CT_TableGridz.
    ``<a:tblGrid>`` custom element class
    z	a:gridColc                 &    | j                  |      S )z
        Return a reference to a newly created <a:gridCol> child element
        having its ``w`` attribute set to *width*.
        )r   )_add_gridCol)r'   rZ   s     r)   r^   zCT_TableGrid.add_gridCol  s    
   5 ))r+   N)rz   r{   r|   r}   r   gridColr^   r   r+   r)   r   r     s     %G*r+   r   c                       e Zd ZdZ eded      Z eded      Z eded      Z eded      Z	 eded      Z
 ed	ed      Zy
)CT_TablePropertiesz,
    ``<a:tblPr>`` custom element class
    r;   Fr   r.   rE   r?   rW   rS   N)rz   r{   r|   r}   r   r   r;   r.   rE   r?   rW   rS   r   r+   r)   r   r     s]      	:uEG	:uEG ZGH ZGH	:uEG	:uEGr+   r   c                   R    e Zd ZdZ edd      Z ede      Zd Z	e
d        Zd Zy	)
CT_TableRowz)
    ``<a:tr>`` custom element class
    za:tc)r   r!   r%   c                 "    | j                         S )ze
        Return a reference to a newly added minimal valid ``<a:tc>`` child
        element.
        )_add_tcr1   s    r)   r_   zCT_TableRow.add_tc  s    
 ||~r+   c                 T    | j                         j                  j                  |       S )z Offset of this row in its table.)r   rO   r   r1   s    r)   rl   zCT_TableRow.row_idx  s"     ~~&&,,T22r+   c                 *    t         j                         S rI   )r   r   r1   s    r)   _new_tczCT_TableRow._new_tc  s    !!r+   N)rz   r{   r|   r}   r   rM   r   r   r%   r_   r   rl   r   r   r+   r)   r   r     s?     
F}	5B#}-A 3 3"r+   r   c                       e Zd ZdZd Zed        Zed        Zed        Z	ed        Z
d Zd Zd	 Zd
 Zd Zd Zed        Zed        Zed        Zed        Zed        Zed        Zy)TcRangea  A 2D block of `a:tc` cell elements in a table.

    This object assumes the structure of the underlying table does not change
    during its lifetime. Structural changes in this context would be
    insertion or removal of rows or columns.

    The client is expected to create, use, and then abandon an instance in
    the context of a single user operation that is known to have no
    structural side-effects of this type.
    c                      || _         || _        y rI   )_tc	_other_tc)r'   rM   other_tcs      r)   __init__zTcRange.__init__  s    !r+   c                     |j                   j                  |j                  |j                  z   dz
  |j                  |j
                  z   dz
        } | ||      S )z5Return instance created from merge-origin tc element.r    )re   rM   rl   r   rm   r   )r`   rM   r   s      r)   from_merge_originzTcRange.from_merge_origin  sO     6699JJ#a'JJ$q(
 2x  r+   c                     | j                         D ]@  }|j                  dkD  r y|j                  dkD  r y|j                  r y|j                  s@ y y)z=True if one or more cells in range are part of a merged cell.r    TF)rP   r   r   r   r   )r'   rM   s     r)   contains_merged_cellzTcRange.contains_merged_cell  sN     --/ 	B{{QzzA~yyyy	 r+   c                 ,    | j                   \  }}}}||fS )z5(row_count, col_count) pair describing size of range._extents)r'   _rZ   r(   s       r)   
dimensionszTcRange.dimensions  s      #mm1eVu}r+   c                 ^    | j                   j                  | j                  j                  u ryy)z=True if both cells provided to constructor are in same table.TF)r   re   r   r1   s    r)   in_same_tablezTcRange.in_same_table  s$     88<<4>>---r+   c              #      K   | j                   j                  | j                  | j                   D ]1  }|j                  | j
                  dz   | j                   D ]  }|  3 yw)z=Generate each `a:tc` element not in leftmost column of range.r    N_tblrO   _top_bottomrJ   _left_rightr'   rL   rM   s      r)   iter_except_left_col_tcsz TcRange.iter_except_left_col_tcs  sY     ))""499t||< 	Bii

Q= 	   A#A%c              #      K   | j                   j                  | j                  dz   | j                   D ].  }|j                  | j
                  | j                   D ]  }|  0 yw)z8Generate each `a:tc` element in non-first rows of range.r    Nr   r  s      r)   iter_except_top_row_tcszTcRange.iter_except_top_row_tcs  sY     ))""499q=4<<@ 	Bii

T[[9 	r  c              #      K   | j                   }| j                  j                  | j                  | j                   D ]  }|j
                  |     yw)z9Generate each `a:tc` element in leftmost column of range.N)r   r   rO   r   r   rJ   )r'   rm   rL   s      r)   iter_left_col_tcszTcRange.iter_left_col_tcs  sF     **))""499t||< 	%B))G$$	%   AAc                 p      fd j                   j                   j                   j                   D        S )zwGenerate each `a:tc` element in this range.

        Cell elements are generated left-to-right, top-to-bottom.
        c              3   r   K   | ].  }|j                   j                  j                   D ]  }|  0 y wrI   )rJ   r   r  )rK   rL   rM   r'   s      r)   rN   z#TcRange.iter_tcs.<locals>.<genexpr>	  sA      
ii

T[[9
  

s   47)r   rO   r   r   r1   s   `r)   rP   zTcRange.iter_tcs  s.    

ii&&tyy4<<@
 	
r+   c              #      K   | j                   j                  | j                     }|j                  | j                  | j
                   D ]  }|  yw)z5Generate each `a:tc` element in topmost row of range.N)r   rO   r   rJ   r   r  r  s      r)   iter_top_row_tcszTcRange.iter_top_row_tcs  sE     YYdii())DJJ5 	BH	r	  c                 v    t        | j                               }|d   }|dd D ]  }|j                  |        y)z,Move all paragraphs in range to origin cell.r   r    N)listrP   r   )r'   tcs	origin_tcr   s       r)   move_content_to_originzTcRange.move_content_to_origin  s>    4==?#F	ab' 	1J$$Z0	1r+   c                 .    | j                   \  }}}}||z   S )z(Index of row following last row of ranger   )r'   r   topr(   s       r)   r   zTcRange._bottom  s      !MM36V|r+   c                     d }| j                   | j                  }} ||j                  |j                        \  }} ||j                  |j                        \  }}||||fS )a=  A (left, top, width, height) tuple describing range extents.

        Note this is normalized to accommodate the various orderings of the
        corner cells provided on construction, which may be in any of four
        configurations such as (top-left, bottom-right),
        (bottom-left, top-right), etc.
        c                 <    t        | |      t        | |z
        dz   fS )z:Return beginning and length of range based on two indexes.r    )minabs)idx	other_idxs     r)   start_and_sizez(TcRange._extents.<locals>.start_and_size,  s"    sI&C)O(<q(@@@r+   )r   r   rm   rl   )r'   r  rM   r   leftrZ   r  r(   s           r)   r   zTcRange._extents"  s^    	A xxH$RZZ1A1ABe$RZZ1A1ABVS%''r+   c                 (    | j                   \  }}}}|S )z!Index of leftmost column in ranger   )r'   r  r   s      r)   r   zTcRange._left7  s     aAr+   c                 .    | j                   \  }}}}||z   S )z2Index of column following the last column in ranger   )r'   r  r   rZ   s       r)   r  zTcRange._right=  s      !MMae|r+   c                 .    | j                   j                  S )z*`a:tbl` element containing this cell range)r   re   r1   s    r)   r   zTcRange._tblC  s     xx||r+   c                 (    | j                   \  }}}}|S )zIndex of topmost row in ranger   )r'   r   r  s      r)   r   zTcRange._topH  s     }}31
r+   N)rz   r{   r|   r}   r   r   r   r   r   r   r   r  r  r  rP   r  r  r   r   r   r  r   r   r   r+   r)   r   r     s    	" ! !    
  %	
1  
 ( ((  
  
    r+   r   N)*r}   
__future__r   r   r   r   pptx.enum.textr   	pptx.oxmlr   pptx.oxml.dml.fillr	   pptx.oxml.nsr   pptx.oxml.simpletypesr   r   r   r   pptx.oxml.textr   pptx.oxml.xmlchemyr   r   r   r   r   r   r   r   	pptx.utilr   r   r   r   r   r   r   r   r   objectr   r   r+   r)   <module>r+     s    < R R .  8   T T &	 	 	 (N
 N
b|
? |
~8_ 80./ .*? *
F 
F"/ "0Nf Nr+   