U
    cqe1l                     @  s  d Z ddlmZ ddlmZmZmZ ddlmZm	Z	 ddl
mZ ddlmZmZ ddlmZ ddlmZmZmZmZmZ dd	lmZmZmZmZmZmZmZ dd
lm Z m!Z! erddl"m#Z# ddlm$Z$ G dd deZ%G dd deZ&G dd deZ'G dd deZ(G dd deZ)G dd deZ*G dd deZ+G dd deZ,G dd deZ-G dd  d eZ.G d!d" d"eZ/G d#d$ d$eZ0G d%d& d&eZ1d'S )(z"Custom element classes for tables.    )annotations)TYPE_CHECKINGCallableList)WD_CELL_VERTICAL_ALIGNMENTWD_ROW_HEIGHT_RULE)InvalidSpanError)nsdeclsqn)	parse_xml)ST_MergeST_TblLayoutTypeST_TblWidthST_TwipsMeasureXsdInt)BaseOxmlElementOneAndOnlyOne	OneOrMoreOptionalAttributeRequiredAttribute
ZeroOrMore	ZeroOrOne)EmuTwips)CT_P)Lengthc                   @  s$   e Zd ZdZedeZedeZdS )	CT_HeightzFUsed for ``<w:trHeight>`` to specify a row height and row height rule.w:valzw:hRuleN)	__name__
__module____qualname____doc__r   r   valr   hRule r$   r$   3/tmp/pip-unpacked-wheel-gx5hpqp3/docx/oxml/table.pyr   "   s   
r   c                   @  s   e Zd ZdZedZedZedZdd Z	e
dd Ze
d	d
 Zejdd
 Ze
dd Zejdd Zdd Zdd Zdd ZdS )CT_Rowz``<w:tr>`` element.z	w:tblPrExzw:trPrzw:tcc                 C  sJ   d}| j D ]2}||kr|  S ||j7 }||kr
td| q
tddS )zThe ``<w:tc>`` element appearing at grid column `idx`.

        Raises |ValueError| if no ``w:tc`` element begins at that grid column.
        r   zno cell on grid column %dzindex out of boundsN)tc_lst	grid_span
ValueError)selfidxZgrid_coltcr$   r$   r%   tc_at_grid_col0   s    

zCT_Row.tc_at_grid_colc                 C  s   |   j| S )zSThe index of this ``<w:tr>`` element within its parent ``<w:tbl>``
        element.)	getparenttr_lstindexr*   r$   r$   r%   tr_idx>   s    zCT_Row.tr_idxc                 C  s   | j }|dkrdS |jS )zJReturn the value of `w:trPr/w:trHeight@w:hRule`, or |None| if not present.N)trPrtrHeight_hRuler*   r3   r$   r$   r%   r4   D   s    zCT_Row.trHeight_hRulec                 C  s   |   }||_d S N)get_or_add_trPrr4   r*   valuer3   r$   r$   r%   r4   L   s    c                 C  s   | j }|dkrdS |jS )zHReturn the value of `w:trPr/w:trHeight@w:val`, or |None| if not present.N)r3   trHeight_valr5   r$   r$   r%   r:   Q   s    zCT_Row.trHeight_valc                 C  s   |   }||_d S r6   )r7   r:   r8   r$   r$   r%   r:   Y   s    c                 C  s   |  d| d S Nr   insert)r*   tblPrExr$   r$   r%   _insert_tblPrEx^   s    zCT_Row._insert_tblPrExc                 C  s*   | j }|d k	r|| n| d| d S r;   )r>   Zaddnextr=   )r*   r3   r>   r$   r$   r%   _insert_trPra   s    zCT_Row._insert_trPrc                 C  s   t  S r6   )CT_Tcnewr1   r$   r$   r%   _new_tch   s    zCT_Row._new_tcN)r   r   r    r!   r   r>   r3   r   r,   r-   propertyr2   r4   setterr:   r?   r@   rC   r$   r$   r$   r%   r&   )   s$   




r&   c                   @  s   e Zd ZdZedZedZedZe	dd Z
e
jdd Z
e	dd	 Zd
d Zedddd dddZe	dd Zejdd ZedddddddZedd Zedd Zedd ZdS )CT_Tblz``<w:tbl>`` element.zw:tblPrz	w:tblGridzw:trc                 C  s   | j j}|dkrdS |jS )zValue of `w:tblPr/w:bidiVisual/@w:val` or |None| if not present.

        Controls whether table cells are displayed right-to-left or left-to-right.
        N)tblPr
bidiVisualr"   )r*   rH   r$   r$   r%   bidiVisual_vals   s    zCT_Tbl.bidiVisual_valc                 C  s&   | j }|d kr|  n
|| _d S r6   )rG   Z_remove_bidiVisualZget_or_add_bidiVisualr"   )r*   r9   rG   r$   r$   r%   rI   ~   s    
c                 C  s   t | jjS )z)The number of grid columns in this table.)lentblGridgridCol_lstr1   r$   r$   r%   	col_count   s    zCT_Tbl.col_countc                 c  s"   | j D ]}|jD ]
}|V  qqdS )zGenerate each of the `w:tc` elements in this table, left to right and top to
        bottom.

        Each cell in the first row is generated, followed by each cell in the second
        row, etc.
        N)r/   r'   )r*   trr,   r$   r$   r%   iter_tcs   s    

zCT_Tbl.iter_tcsintr   )rowscolswidthreturnc                 C  s   t | |||S )zReturn a new `w:tbl` element having `rows` rows and `cols` columns.

        `width` is distributed evenly between the columns.
        )r   _tbl_xml)clsrQ   rR   rS   r$   r$   r%   new_tbl   s    zCT_Tbl.new_tblc                 C  s   | j j}|dkrdS |jS )zYValue of `w:tblPr/w:tblStyle/@w:val` (a table style id) or |None| if not
        present.N)rG   tblStyler"   r*   rX   r$   r$   r%   tblStyle_val   s    zCT_Tbl.tblStyle_valc                 C  s(   | j }|  |dkrdS || _dS )zSet the value of `w:tblPr/w:tblStyle/@w:val` (a table style id) to `styleId`.

        If `styleId` is None, remove the `w:tblStyle` element.
        N)rG   _remove_tblStyle_add_tblStyler"   )r*   ZstyleIdrG   r$   r$   r%   rZ      s
    strc                 C  s@   |dkrt || nt d}dtd| ||| |||f S )Nr   z<w:tbl %s>
  <w:tblPr>
    <w:tblW w:type="auto" w:w="0"/>
    <w:tblLook w:firstColumn="1" w:firstRow="1"
               w:lastColumn="0" w:lastRow="0" w:noHBand="0"
               w:noVBand="1" w:val="04A0"/>
  </w:tblPr>
%s%s</w:tbl>
w)r   r	   _tblGrid_xml_trs_xml)rV   rQ   rR   rS   	col_widthr$   r$   r%   rU      s    
zCT_Tbl._tbl_xmlc                 C  s,   d}t |D ]}|d|j 7 }q|d7 }|S )Nz  <w:tblGrid>
z    <w:gridCol w:w="%d"/>
z  </w:tblGrid>
rangetwipsrV   rM   ra   xmlir$   r$   r%   r_      s
    zCT_Tbl._tblGrid_xmlc                 C  s*   d}t |D ]}|d| || 7 }q|S )N z  <w:tr>
%s  </w:tr>
)rc   _tcs_xml)rV   Z	row_countrM   ra   rf   rg   r$   r$   r%   r`      s     
zCT_Tbl._trs_xmlc                 C  s$   d}t |D ]}|d|j 7 }q|S )Nrh   zj    <w:tc>
      <w:tcPr>
        <w:tcW w:type="dxa" w:w="%d"/>
      </w:tcPr>
      <w:p/>
    </w:tc>
rb   re   r$   r$   r%   ri      s    zCT_Tbl._tcs_xmlN)r   r   r    r!   r   rG   rK   r   rN   rD   rI   rE   rM   rO   classmethodrW   rZ   rU   r_   r`   ri   r$   r$   r$   r%   rF   l   s2   







rF   c                   @  s   e Zd ZdZedddZdS )
CT_TblGridzw``<w:tblGrid>`` element, child of ``<w:tbl>``, holds ``<w:gridCol>`` elements
    that define column count, width, etc.z	w:gridCol)zw:tblGridChange
successorsN)r   r   r    r!   r   ZgridColr$   r$   r$   r%   rk      s   rk   c                   @  s&   e Zd ZdZedeZedd ZdS )CT_TblGridColzJ``<w:gridCol>`` element, child of ``<w:tblGrid>``, defines a table column.w:wc                 C  s   |   j| S )z\The index of this ``<w:gridCol>`` element within its parent ``<w:tblGrid>``
        element.)r.   rL   r0   r1   r$   r$   r%   gridCol_idx   s    zCT_TblGridCol.gridCol_idxN)	r   r   r    r!   r   r   r^   rD   rp   r$   r$   r$   r%   rn      s   
rn   c                   @  s   e Zd ZdZedeZdS )CT_TblLayoutTypez|``<w:tblLayout>`` element, specifying whether column widths are fixed or can be
    automatically adjusted based on content.w:typeN)r   r   r    r!   r   r   typer$   r$   r$   r%   rq      s   rq   c                   @  s   e Zd ZdZdZededd dZededd dZed	ed
d dZededd dZ	[e
dd Zejdd Ze
ddddZejddddZe
dd Zejdd ZdS )CT_TblPrz}``<w:tblPr>`` element, child of ``<w:tbl>``, holds child elements that define
    table properties such as style and borders.)
w:tblStylezw:tblpPrzw:tblOverlapw:bidiVisualzw:tblStyleRowBandSizezw:tblStyleColBandSizezw:tblWw:jcw:tblCellSpacingzw:tblIndzw:tblBordersw:shdw:tblLayoutzw:tblCellMarz	w:tblLookzw:tblCaptionzw:tblDescriptionzw:tblPrChangeru      Nrl   rv      rw      rz      c                 C  s   | j }|dkrdS |jS )zMember of :ref:`WdRowAlignment` enumeration or |None|, based on the contents
        of the `w:val` attribute of `./w:jc`.

        |None| if no `w:jc` element is present.
        N)jcr"   )r*   r   r$   r$   r%   	alignment  s    zCT_TblPr.alignmentc                 C  s&   |    |d krd S |  }||_d S r6   )Z
_remove_jcZget_or_add_jcr"   )r*   r9   r   r$   r$   r%   r   +  s
    boolrT   c                 C  s   | j }|dkrdS |jdkS )zg|False| when there is a `w:tblLayout` child with `@w:type="fixed"`.

        Otherwise |True|.
        NTfixed)	tblLayoutrs   )r*   r   r$   r$   r%   autofit3  s    zCT_TblPr.autofit)r9   c                 C  s   |   }|rdnd|_d S )Nr   r   )Zget_or_add_tblLayoutrs   )r*   r9   r   r$   r$   r%   r   <  s    c                 C  s   | j }|dkrdS |jS )ziReturn the value of the ``val`` attribute of the ``<w:tblStyle>`` child or
        |None| if not present.N)rX   r"   rY   r$   r$   r%   styleA  s    zCT_TblPr.stylec                 C  s$   |    |d krd S | j|d d S )N)r"   )r[   r\   r*   r9   r$   r$   r%   r   J  s    )r   r   r    r!   _tag_seqr   rX   rH   r   r   rD   r   rE   r   r   r$   r$   r$   r%   rt     s&   


rt   c                   @  s>   e Zd ZdZedeZedeZe	dd Z
e
jdd Z
dS )CT_TblWidthzeUsed for ``<w:tblW>`` and ``<w:tcW>`` elements and many others, to specify a
    table-related width.ro   rr   c                 C  s   | j dkrdS t| jS )zbReturn the EMU length value represented by the combined ``w:w`` and
        ``w:type`` attributes.dxaN)rs   r   r^   r1   r$   r$   r%   rS   \  s    
zCT_TblWidth.widthc                 C  s   d| _ t|j| _d S )Nr   )rs   r   rd   r^   r   r$   r$   r%   rS   d  s    N)r   r   r    r!   r   r   r^   r   rs   rD   rS   rE   r$   r$   r$   r%   r   R  s   


r   c                   @  s  e Zd ZU dZded< ded< ded< ded	< ed
ZedZedZ	e
dd Zdd Ze
dd Zejdd Ze
ddddZdd Ze
dd Zdd Zedd Ze
d d! Ze
d"d# Ze
d$d% Zejd&d% Ze
d'd( Zejd)d( Zd*d+ Ze
d,d- ZdSd/d0Zd1d2 Ze
d3d4 Zd5d6 Zd7d8 Ze
d9d: Z d;d< Z!d=d> Z"d?d@ Z#dAdB Z$dCdD Z%e
dEdF Z&e
dGdH Z'e
dIdJ Z(e
dKdL Z)e
dMdN Z*e
dOdP Z+e
dQdR Z,d.S )TrA   z`w:tc` table cell element.zCallable[[], CT_P]Zadd_pz
List[CT_P]Zp_lstzList[CT_Tbl]Ztbl_lstzCallable[[CT_Tbl], CT_Tbl]Z_insert_tblzw:tcPrw:pw:tblc                 C  s4   | j dk	r*| j}|dk	r*|j tjkr*|jS | jd S )zThe row index that marks the bottom extent of the vertical span of this cell.

        This is one greater than the index of the bottom-most row of the span, similar
        to how a slice of the cell's rows would be specified.
        Nr{   )vMerge	_tc_belowr   CONTINUEbottom_tr_idx)r*   Ztc_belowr$   r$   r%   r   w  s
    
zCT_Tc.bottomc                 C  s,   g }| j }|dk	r|| || dd< dS )aM  Remove all content child elements, preserving the ``<w:tcPr>`` element if
        present.

        Note that this leaves the ``<w:tc>`` element in an invalid state because it
        doesn't contain at least one block-level element. It's up to the caller to add a
        ``<w:p>``child element as the last content element.
        N)tcPrappend)r*   Znew_childrenr   r$   r$   r%   clear_content  s
    
zCT_Tc.clear_contentc                 C  s   | j }|dkrdS |jS )zzThe integer number of columns this cell spans.

        Determined by ./w:tcPr/w:gridSpan/@val, it defaults to 1.
        Nr{   )r   r(   r*   r   r$   r$   r%   r(     s    zCT_Tc.grid_spanc                 C  s   |   }||_d S r6   )get_or_add_tcPrr(   r*   r9   r   r$   r$   r%   r(     s    zList[CT_P | CT_Tbl]r   c                 C  s
   |  dS )zGenerate all `w:p` and `w:tbl` elements in this document-body.

        Elements appear in document order. Elements shaded by nesting in a `w:ins` or
        other "wrapper" element will not be included.
        z./w:p | ./w:tblZxpathr1   r$   r$   r%   inner_content_elements  s    zCT_Tc.inner_content_elementsc                 c  s4   t dt dt df}| D ]}|j|kr|V  qdS )zpGenerate a reference to each of the block-level content elements in this
        cell, in the order they appear.r   r   zw:sdtN)r
   tag)r*   Zblock_item_tagschildr$   r$   r%   iter_block_items  s    
zCT_Tc.iter_block_itemsc                 C  s   | j S )z?The grid column index at which this ``<w:tc>`` element appears.)	_grid_colr1   r$   r$   r%   left  s    z
CT_Tc.leftc                 C  s4   |  |\}}}}| jj| |}||| |S )zReturn the top-left ``<w:tc>`` element of a new span formed by merging the
        rectangular region defined by using this tc element and `other_tc` as diagonal
        corners.)_span_dimensions_tblr/   r-   _grow_to)r*   other_tctopr   heightrS   top_tcr$   r$   r%   merge  s    zCT_Tc.mergec                 C  s   t dtd S )zhReturn a new ``<w:tc>`` element, containing an empty paragraph as the
        required EG_BlockLevelElt.z<w:tc %s>
  <w:p/>
</w:tc>r^   )r   r	   )rV   r$   r$   r%   rB     s    z	CT_Tc.newc                 C  s   | j | j S )a  The grid column index that marks the right-side extent of the horizontal span
        of this cell.

        This is one greater than the index of the right-most column of the span, similar
        to how a slice of the cell's columns would be specified.
        )r   r(   r1   r$   r$   r%   right  s    zCT_Tc.rightc                 C  s$   | j dks| j tjkr| jS | jjS )z9The top-most row index in the vertical span of this cell.N)r   r   RESTARTr   	_tc_abover   r1   r$   r$   r%   r     s    z	CT_Tc.topc                 C  s   | j }|dkrdS |jS )zlThe value of the ./w:tcPr/w:vMerge/@val attribute, or |None| if the w:vMerge
        element is not present.N)r   
vMerge_valr   r$   r$   r%   r     s    zCT_Tc.vMergec                 C  s   |   }||_d S r6   )r   r   r   r$   r$   r%   r     s    c                 C  s   | j }|dkrdS |jS )zqReturn the EMU length value represented in the ``./w:tcPr/w:tcW`` child
        element or |None| if not present.N)r   rS   r   r$   r$   r%   rS     s    zCT_Tc.widthc                 C  s   |   }||_d S r6   )r   rS   r   r$   r$   r%   rS     s    c                 C  s    | j r|j r|  j |j 7  _ dS )zAdd the width of `other_tc` to this cell.

        Does nothing if either this tc or `other_tc` does not have a specified width.
        N)rS   )r*   r   r$   r$   r%   _add_width_of  s    zCT_Tc._add_width_ofc                 C  s2   | j }|j| }|jd| }tdd |D S )z*The grid column at which this cell begins.Nc                 s  s   | ]}|j V  qd S r6   )r(   ).0r,   r$   r$   r%   	<genexpr>  s     z"CT_Tc._grid_col.<locals>.<genexpr>)_trr'   r0   sum)r*   rN   r+   Zpreceding_tcsr$   r$   r%   r     s    zCT_Tc._grid_colNc                   sP    fdd}|dkrn|} ||||  dkrLj| d | dS )zGrow this cell to `width` grid columns and `height` rows by expanding
        horizontal spans and creating continuation cells to form vertical spans.c                   s    | k	rt jS  dkrd S t jS Nr{   )r   r   r   )r   r   r*   r$   r%   r     s
    z"CT_Tc._grow_to.<locals>.vMerge_valNr{   )_span_to_widthr   r   )r*   rS   r   r   r   r$   r   r%   r     s
    zCT_Tc._grow_toc                 C  s   |  d| |S )z``tcPr`` has a bunch of successors, but it comes first if it appears, so just
        overriding and using insert(0, ...) rather than spelling out successors.r   r<   r   r$   r$   r%   _insert_tcPr  s    zCT_Tc._insert_tcPrc                 C  s:   t |  }t|dkrdS |d }t|jdkr6dS dS )zATrue if this cell contains only a single empty ``<w:p>`` element.r{   Fr   T)listr   rJ   r_lst)r*   block_itemspr$   r$   r%   	_is_empty  s    zCT_Tc._is_emptyc                 C  sH   || krdS | j rdS |  |  D ]}|| q&| |   dS )zoAppend the content of this cell to `other_tc`, leaving this cell with a
        single empty ``<w:p>`` element.N)r   _remove_trailing_empty_pr   r   Z_new_p)r*   r   Zblock_elementr$   r$   r%   _move_content_to%  s    zCT_Tc._move_content_toc                 C  s   t  S r6   )rF   rB   r1   r$   r$   r%   _new_tbl3  s    zCT_Tc._new_tblc                 C  s   |  d}|r|d S dS )zThe `w:tc` element immediately following this one in this row, or |None| if
        this is the last `w:tc` element in the row.z./following-sibling::w:tcr   Nr   )r*   Zfollowing_tcsr$   r$   r%   _next_tc6  s    
zCT_Tc._next_tcc                 C  s   |   |  dS )z-Remove this `w:tc` element from the XML tree.N)r.   remover1   r$   r$   r%   _remove=  s    zCT_Tc._removec                 C  sJ   t |  }|d }|jtdkr&dS |}t|jdkr<dS | | dS )z[Remove the last content element from this cell if it is an empty ``<w:p>``
        element.r   Nr   )r   r   r   r
   rJ   r   r   )r*   r   Zlast_content_elmr   r$   r$   r%   r   A  s    zCT_Tc._remove_trailing_empty_pc                 C  sp   dd }dd }|| | || | t | j|j}t | j|j}t| j|j}t| j|j}|||| || fS )zReturn a (top, left, height, width) 4-tuple specifying the extents of the
        merged cell formed by using this tc and `other_tc` as opposite corner
        extents.c                 S  sD   | j |j kr | j|jkr td| j|jkr@| j|jkr@tdd S Nzrequested span not rectangularr   r   r   r   r   )abr$   r$   r%   raise_on_inverted_LR  s    z3CT_Tc._span_dimensions.<locals>.raise_on_inverted_Lc                 S  s   | j |j k r| |fn|| f\}}|j |j k r@|j|jkr@td| j|jk rT| |fn|| f\}}|j|jk r|j|jkrtdd S r   r   )r   r   Ztop_mostotherZ	left_mostr$   r$   r%   raise_on_tee_shapedX  s      z3CT_Tc._span_dimensions.<locals>.raise_on_tee_shaped)minr   r   maxr   r   )r*   r   r   r   r   r   r   r   r$   r$   r%   r   M  s    	

zCT_Tc._span_dimensionsc                 C  s,   |  | | j|k r"| || q
|| _dS )aZ  Incorporate and then remove `w:tc` elements to the right of this one until
        this cell spans `grid_width`.

        Raises |ValueError| if `grid_width` cannot be exactly achieved, such as when a
        merged cell would drive the span width greater than `grid_width` or if not
        enough grid columns are available to make this cell that wide. All content from
        incorporated cells is appended to `top_tc`. The val attribute of the vMerge
        element on the single remaining cell is set to `vMerge`. If `vMerge` is |None|,
        the vMerge element is removed if present.
        N)r   r(   _swallow_next_tcr   )r*   
grid_widthr   r   r$   r$   r%   r   k  s    

zCT_Tc._span_to_widthc                   sL    fdd}j }|| || |  j|j7  _|  dS )a  Extend the horizontal span of this `w:tc` element to incorporate the
        following `w:tc` element in the row and then delete that following `w:tc`
        element.

        Any content in the following `w:tc` element is appended to the content of
        `top_tc`. The width of the following `w:tc` element is added to this one, if
        present. Raises |InvalidSpanError| if the width of the resulting cell is greater
        than `grid_width` or if there is no next `<w:tc>` element in the row.
        c                   s,   | d krt dj| j  kr(t dd S )Nznot enough grid columnszspan is not rectangular)r   r(   )next_tcr   r*   r$   r%   raise_on_invalid_swallow  s    z8CT_Tc._swallow_next_tc.<locals>.raise_on_invalid_swallowN)r   r   r   r(   r   )r*   r   r   r   r   r$   r   r%   r   {  s    

zCT_Tc._swallow_next_tcc                 C  s   |  dd S )z+The tbl element this tc element appears in.z./ancestor::w:tbl[position()=1]r   r   r1   r$   r$   r%   r     s    z
CT_Tc._tblc                 C  s   | j | jS )zAThe `w:tc` element immediately above this one in its grid column.)	_tr_abover-   r   r1   r$   r$   r%   r     s    zCT_Tc._tc_abovec                 C  s   | j }|dkrdS || jS )z=The tc element immediately below this one in its grid column.N)	_tr_belowr-   r   )r*   Ztr_belowr$   r$   r%   r     s    zCT_Tc._tc_belowc                 C  s   |  dd S )z*The tr element this tc element appears in.z./ancestor::w:tr[position()=1]r   r   r1   r$   r$   r%   r     s    z	CT_Tc._trc                 C  s0   | j j}|| j}|dkr$td||d  S )zThe tr element prior in sequence to the tr this cell appears in.

        Raises |ValueError| if called on a cell in the top-most row.
        r   zno tr above topmost trr{   )r   r/   r0   r   r)   r*   r/   r2   r$   r$   r%   r     s
    zCT_Tc._tr_abovec                 C  s>   | j j}|| j}z||d  W S  tk
r8   Y dS X dS )zzThe tr element next in sequence after the tr this cell appears in, or |None|
        if this cell appears in the last row.r{   N)r   r/   r0   r   
IndexErrorr   r$   r$   r%   r     s    zCT_Tc._tr_belowc                 C  s   | j j| jS )z;The row index of the tr element this tc element appears in.)r   r/   r0   r   r1   r$   r$   r%   r     s    zCT_Tc._tr_idx)N)-r   r   r    r!   __annotations__r   r   r   r   ZtblrD   r   r   r(   rE   r   r   r   r   rj   rB   r   r   r   rS   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r$   r$   r$   r%   rA   j  s   





	

	
















rA   c                   @  s   e Zd ZdZdZededd dZededd dZed	ed
d dZededd dZ	[e
dd Zejdd Ze
dd Zejdd Ze
dd Zejdd Ze
dd Zejdd ZdS )CT_TcPrz5``<w:tcPr>`` element, defining table cell properties.)
w:cnfStylew:tcW
w:gridSpanzw:hMergew:vMergezw:tcBordersry   zw:noWrapzw:tcMarzw:textDirectionzw:tcFitTextw:vAlignz
w:hideMarkz	w:headersz	w:cellInsz	w:cellDelzw:cellMergezw:tcPrChanger      Nrl   r      r      r      c                 C  s   | j }|dkrdS |jS )zsThe integer number of columns this cell spans.

        Determined by ./w:gridSpan/@val, it defaults to 1.
        Nr{   )gridSpanr"   )r*   r   r$   r$   r%   r(     s    zCT_TcPr.grid_spanc                 C  s   |    |dkr||  _d S r   )Z_remove_gridSpanZget_or_add_gridSpanr"   r   r$   r$   r%   r(     s    c                 C  s   | j }|dkrdS |jS )zValue of `w:val` attribute on  `w:vAlign` child.

        Value is |None| if `w:vAlign` child is not present. The `w:val` attribute on
        `w:vAlign` is required.
        N)vAlignr"   )r*   r   r$   r$   r%   
vAlign_val  s    zCT_TcPr.vAlign_valc                 C  s"   |d kr|    d S ||  _d S r6   )Z_remove_vAlignZget_or_add_vAlignr"   r   r$   r$   r%   r     s    c                 C  s   | j }|dkrdS |jS )zeThe value of the ./w:vMerge/@val attribute, or |None| if the w:vMerge element
        is not present.N)r   r"   )r*   r   r$   r$   r%   r     s    zCT_TcPr.vMerge_valc                 C  s   |    |d k	r||  _d S r6   )Z_remove_vMergeZ_add_vMerger"   r   r$   r$   r%   r     s    c                 C  s   | j }|dkrdS |jS )zReturn the EMU length value represented in the ``<w:tcW>`` child element or
        |None| if not present or its type is not 'dxa'.N)tcWrS   )r*   r   r$   r$   r%   rS     s    zCT_TcPr.widthc                 C  s   |   }||_d S r6   )Zget_or_add_tcWrS   )r*   r9   r   r$   r$   r%   rS      s    )r   r   r    r!   r   r   r   r   r   r   rD   r(   rE   r   r   rS   r$   r$   r$   r%   r     s.   







r   c                   @  s^   e Zd ZdZdZededd dZ[edd Zej	d	d Zed
d Z
e
j	dd Z
dS )CT_TrPrz4``<w:trPr>`` element, defining table row properties.)r   zw:divIdzw:gridBeforezw:gridAfterz	w:wBeforezw:wAfterzw:cantSplit
w:trHeightzw:tblHeaderrx   rw   zw:hiddenzw:inszw:delzw:trPrChanger   r}   Nrl   c                 C  s   | j }|dkrdS |jS )zCReturn the value of `w:trHeight@w:hRule`, or |None| if not present.N)trHeightr#   r*   r   r$   r$   r%   r4   =  s    zCT_TrPr.trHeight_hRulec                 C  s(   |d kr| j d krd S |  }||_d S r6   )r   get_or_add_trHeightr#   r*   r9   r   r$   r$   r%   r4   E  s    c                 C  s   | j }|dkrdS |jS )zAReturn the value of `w:trHeight@w:val`, or |None| if not present.N)r   r"   r   r$   r$   r%   r:   L  s    zCT_TrPr.trHeight_valc                 C  s(   |d kr| j d krd S |  }||_d S r6   )r   r   r"   r   r$   r$   r%   r:   T  s    )r   r   r    r!   r   r   r   rD   r4   rE   r:   r$   r$   r$   r%   r   &  s   


r   c                   @  s   e Zd ZdZedeZdS )CT_VerticalJcz:`w:vAlign` element, specifying vertical alignment of cell.r   N)r   r   r    r!   r   r   r"   r$   r$   r$   r%   r   \  s   r   c                   @  s    e Zd ZdZedeejdZdS )	CT_VMergezG``<w:vMerge>`` element, specifying vertical merging behavior of a cell.r   )defaultN)r   r   r    r!   r   r   r   r"   r$   r$   r$   r%   r   b  s   r   N)2r!   
__future__r   typingr   r   r   Zdocx.enum.tabler   r   Zdocx.exceptionsr   Zdocx.oxml.nsr	   r
   Zdocx.oxml.parserr   Zdocx.oxml.simpletypesr   r   r   r   r   Zdocx.oxml.xmlchemyr   r   r   r   r   r   r   Zdocx.sharedr   r   Zdocx.oxml.text.paragraphr   r   r   r&   rF   rk   rn   rq   rt   r   rA   r   r   r   r   r$   r$   r$   r%   <module>   s6   $	C{Q  __6