o
    W_Dl                     @   sx  d Z ddlmZmZ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 dd	lmZ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  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Z,G d$d% d%eZ-d&S )'z!Custom element classes for tables    )absolute_importdivisionprint_functionunicode_literals   )	parse_xml   )WD_CELL_VERTICAL_ALIGNMENTWD_ROW_HEIGHT_RULE)InvalidSpanError)nsdeclsqn)EmuTwips)ST_MergeST_TblLayoutTypeST_TblWidthST_TwipsMeasureXsdInt)BaseOxmlElementOneAndOnlyOne	OneOrMoreOptionalAttributeRequiredAttribute	ZeroOrOne
ZeroOrMorec                   @   s$   e Zd ZdZedeZedeZdS )	CT_HeightzP
    Used 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$   ?D:\Projects\ConvertPro\env\Lib\site-packages\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   sF   d}| j D ]}||kr|  S ||j7 }||krtd| qtd)z
        The ``<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 bounds)tc_lst	grid_span
ValueError)selfidxZgrid_coltcr$   r$   r%   tc_at_grid_col'   s   

zCT_Row.tc_at_grid_colc                 C      |   j| S )ze
        The index of this ``<w:tr>`` element within its parent ``<w:tbl>``
        element.
        )	getparenttr_lstindexr*   r$   r$   r%   tr_idx5      zCT_Row.tr_idxc                 C      | j }|du r	dS |jS )zd
        Return the value of `w:trPr/w:trHeight@w:hRule`, or |None| if not
        present.
        N)trPrtrHeight_hRuler*   r6   r$   r$   r%   r7   =      zCT_Row.trHeight_hRulec                 C      |   }||_d S N)get_or_add_trPrr7   r*   valuer6   r$   r$   r%   r7   H      
c                 C   r5   )zb
        Return the value of `w:trPr/w:trHeight@w:val`, or |None| if not
        present.
        N)r6   trHeight_valr8   r$   r$   r%   r@   M   r9   zCT_Row.trHeight_valc                 C   r:   r;   )r<   r@   r=   r$   r$   r%   r@   X   r?   c                 C   s   |  d| d S Nr   insert)r*   tblPrExr$   r$   r%   _insert_tblPrEx]   s   zCT_Row._insert_tblPrExc                 C   s,   | j }|d ur|| d S | d| d S rA   )rD   ZaddnextrC   )r*   r6   rD   r$   r$   r%   _insert_trPr`   s   zCT_Row._insert_trPrc                 C      t  S r;   )CT_Tcnewr2   r$   r$   r%   _new_tcg      zCT_Row._new_tcN)r   r   r    r!   r   rD   r6   r   r,   r-   propertyr3   r7   setterr@   rE   rF   rJ   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 Ze	dd Zejdd Ze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      | j j}|du r
dS |jS )z
        Value 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*   rQ   r$   r$   r%   bidiVisual_vals   s   zCT_Tbl.bidiVisual_valc                 C   s(   | j }|d u r|  d S || _d S r;   )rP   Z_remove_bidiVisualZget_or_add_bidiVisualr"   )r*   r>   rP   r$   r$   r%   rR      s   c                 C   s   t | jjS )z;
        The number of grid columns in this table.
        )lentblGridgridCol_lstr2   r$   r$   r%   	col_count   s   zCT_Tbl.col_countc                 c   s$    | j D ]}|jD ]}|V  q	qdS )z
        Generate 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)r0   r'   )r*   trr,   r$   r$   r%   iter_tcs   s   

zCT_Tbl.iter_tcsc                 C   s   t | |||S )z
        Return a new `w:tbl` element having *rows* rows and *cols* columns
        with *width* distributed evenly between the columns.
        )r   _tbl_xml)clsrowscolswidthr$   r$   r%   new_tbl   s   zCT_Tbl.new_tblc                 C   rO   )zk
        Value of `w:tblPr/w:tblStyle/@w:val` (a table style id) or |None| if
        not present.
        N)rP   tblStyler"   r*   r_   r$   r$   r%   tblStyle_val   s   zCT_Tbl.tblStyle_valc                 C   s(   | j }|  |du rdS || _dS )z
        Set 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)rP   _remove_tblStyle_add_tblStyler"   )r*   ZstyleIdrP   r$   r$   r%   ra      s
   c                 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)rZ   r[   r\   r]   	col_widthr$   r$   r%   rY      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rZ   rV   rg   xmlir$   r$   r%   re      s
   zCT_Tbl._tblGrid_xmlc                 C   s*   d}t |D ]}|d| || 7 }q|S )N z  <w:tr>
%s  </w:tr>
)ri   _tcs_xml)rZ   Z	row_countrV   rg   rl   rm   r$   r$   r%   rf      s   
zCT_Tbl._trs_xmlc                 C   s$   d}t |D ]	}|d|j 7 }q|S )Nrn   zj    <w:tc>
      <w:tcPr>
        <w:tcW w:type="dxa" w:w="%d"/>
      </w:tcPr>
      <w:p/>
    </w:tc>
rh   rk   r$   r$   r%   ro      s   zCT_Tbl._tcs_xmlN)r   r   r    r!   r   rP   rT   r   rW   rL   rR   rM   rV   rX   classmethodr^   ra   rY   re   rf   ro   r$   r$   r$   r%   rN   k   s4    











rN   c                   @   s   e Zd ZdZedddZdS )
CT_TblGridz
    ``<w:tblGrid>`` element, child of ``<w:tbl>``, holds ``<w:gridCol>``
    elements that define column count, width, etc.
    z	w:gridCol)zw:tblGridChangeZ
successorsN)r   r   r    r!   r   ZgridColr$   r$   r$   r%   rq      s    rq   c                   @   s&   e Zd ZdZedeZedd ZdS )CT_TblGridColzX
    ``<w:gridCol>`` element, child of ``<w:tblGrid>``, defines a table
    column.
    w:wc                 C   r.   )zn
        The index of this ``<w:gridCol>`` element within its parent
        ``<w:tblGrid>`` element.
        )r/   rU   r1   r2   r$   r$   r%   gridCol_idx   r4   zCT_TblGridCol.gridCol_idxN)	r   r   r    r!   r   r   rd   rL   ru   r$   r$   r$   r%   rs      s
    
rs   c                   @      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%   rw     s    rw   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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:tblPrChanger{   r   Nrr   r|      r}      r      c                 C   r5   )z
        Member 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     zCT_TblPr.alignmentc                 C   s&   |    |d u r
d S |  }||_d S r;   )Z
_remove_jcZget_or_add_jcr"   )r*   r>   r   r$   r$   r%   r   +  s
   
c                 C   s$   | j }|du r	dS |jdkrdS dS )z
        Return |False| if there is a ``<w:tblLayout>`` child with ``w:type``
        attribute set to ``'fixed'``. Otherwise return |True|.
        NTfixedF)	tblLayoutry   )r*   r   r$   r$   r%   autofit3  s   zCT_TblPr.autofitc                 C   s    |   }|rd|_d S d|_d S )Nr   r   )Zget_or_add_tblLayoutry   )r*   r>   r   r$   r$   r%   r   >  s   c                 C   r5   )z{
        Return the value of the ``val`` attribute of the ``<w:tblStyle>``
        child or |None| if not present.
        N)r_   r"   r`   r$   r$   r%   styleC  r9   zCT_TblPr.stylec                 C   s$   |    |d u r
d S | j|d d S )N)r"   )rb   rc   r*   r>   r$   r$   r%   r   N  s   )r   r   r    r!   _tag_seqr   r_   rQ   r   r   rL   r   rM   r   r   r$   r$   r$   r%   rz     s(    






rz   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_TblWidthzo
    Used for ``<w:tblW>`` and ``<w:tcW>`` elements and many others, to
    specify a table-related width.
    rt   rx   c                 C   s   | j dkrdS t| jS )zt
        Return the EMU length value represented by the combined ``w:w`` and
        ``w:type`` attributes.
        dxaN)ry   r   rd   r2   r$   r$   r%   r]   a  s   

zCT_TblWidth.widthc                 C   s   d| _ t|j| _d S )Nr   )ry   r   rj   rd   r   r$   r$   r%   r]   k  s   N)r   r   r    r!   r   r   rd   r   ry   rL   r]   rM   r$   r$   r$   r%   r   V  s    


	r   c                   @   s  e Zd ZdZ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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dGd#d$Zd%d& Ze	d'd( Zd)d* Zd+d, Ze	d-d. Zd/d0 Zd1d2 Z d3d4 Z!d5d6 Z"d7d8 Z#e	d9d: Z$e	d;d< Z%e	d=d> Z&e	d?d@ Z'e	dAdB Z(e	dCdD Z)e	dEdF Z*d"S )HrH   z`w:tc` table cell elementzw:tcPrw:pw:tblc                 C   s4   | j dur| j}|dur|j tjkr|jS | jd S )z
        The 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   x  s
   

zCT_Tc.bottomc                 C   s,   g }| j }|dur|| || dd< dS )aU  
        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      | j }|du r	dS |jS )z
        The 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(     r9   zCT_Tc.grid_spanc                 C   r:   r;   )get_or_add_tcPrr(   r*   r>   r   r$   r$   r%   r(     r?   c                 c   s6    t dt dt df}| D ]
}|j|v r|V  qdS )z
        Generate 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 )zQ
        The grid column index at which this ``<w:tc>`` element appears.
        )	_grid_colr2   r$   r$   r%   left  s   z
CT_Tc.leftc                 C   s4   |  |\}}}}| jj| |}||| |S )z
        Return 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_tblr0   r-   _grow_to)r*   other_tctopr   heightr]   top_tcr$   r$   r%   merge  s   zCT_Tc.mergec                 C   s   t dtd S )zz
        Return a new ``<w:tc>`` element, containing an empty paragraph as the
        required EG_BlockLevelElt.
        z<w:tc %s>
  <w:p/>
</w:tc>rd   )r   r   )rZ   r$   r$   r%   rI     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(   r2   r$   r$   r%   right  s   zCT_Tc.rightc                 C   s$   | j du s| j tjkr| jS | jjS )zK
        The top-most row index in the vertical span of this cell.
        N)r   r   RESTARTr   	_tc_abover   r2   r$   r$   r%   r     s   z	CT_Tc.topc                 C   r5   )z~
        The 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     r9   zCT_Tc.vMergec                 C   r:   r;   )r   r   r   r$   r$   r%   r     r?   c                 C   r5   )z
        Return the EMU length value represented in the ``./w:tcPr/w:tcW``
        child element or |None| if not present.
        N)r   r]   r   r$   r$   r%   r]     r9   zCT_Tc.widthc                 C   r:   r;   )r   r]   r   r$   r$   r%   r]     r?   c                 C   s(   | j r|j r|  j |j 7  _ dS dS dS )z
        Add the width of *other_tc* to this cell. Does nothing if either this
        tc or *other_tc* does not have a specified width.
        N)r]   )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 r;   )r(   ).0r,   r$   r$   r%   	<genexpr>  s    z"CT_Tc._grid_col.<locals>.<genexpr>)_trr'   r1   sum)r*   rW   r+   Zpreceding_tcsr$   r$   r%   r     s   zCT_Tc._grid_colNc                    sT    fdd}|du rn|} ||||  dkr(j| d | dS dS )z
        Grow this cell to *width* grid columns and *height* rows by expanding
        horizontal spans and creating continuation cells to form vertical
        spans.
        c                    s    | u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*   r]   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   rB   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rdS dS )zS
        True if this cell contains only a single empty ``<w:p>`` element.
        r   Fr   T)listr   rS   r_lst)r*   block_itemspr$   r$   r%   	_is_empty,  s   zCT_Tc._is_emptyc                 C   sH   || u rdS | j rdS |  |  D ]}|| q| |   dS )z
        Append 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_to9  s   zCT_Tc._move_content_toc                 C   rG   r;   )rN   rI   r2   r$   r$   r%   _new_tblI  rK   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   NZxpath)r*   Zfollowing_tcsr$   r$   r%   _next_tcL  s   
zCT_Tc._next_tcc                 C   s   |   |  dS )z?
        Remove this `w:tc` element from the XML tree.
        N)r/   remover2   r$   r$   r%   _removeU  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 )zm
        Remove the last content element from this cell if it is an empty
        ``<w:p>`` element.
        r   Nr   )r   r   r   r   rS   r   r   )r*   r   Zlast_content_elmr   r$   r$   r%   r   [  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 )z
        Return 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   sH   | j |j kr| j|jkrtd| j|jkr | j|jkr"tdd S d S Nzrequested span not rectangularr   r   r   r   r   )abr$   r$   r%   raise_on_inverted_Lo  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 r*| |fn|| f\}}|j|jk r@|j|jkrBtdd S d S r   r   )r   r   Ztop_mostotherZ	left_mostr$   r$   r%   raise_on_tee_shapedu  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   i  s   
	
zCT_Tc._span_dimensionsc                 C   s4   |  | | j|k r| || | j|k s
|| _dS )ab  
        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     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 u 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      |  dd S )z=
        The tbl element this tc element appears in.
        z./ancestor::w:tbl[position()=1]r   r   r2   r$   r$   r%   r        z
CT_Tc._tblc                 C   s   | j | jS )zS
        The `w:tc` element immediately above this one in its grid column.
        )	_tr_abover-   r   r2   r$   r$   r%   r     r   zCT_Tc._tc_abovec                 C   s   | j }|du r	dS || jS )zO
        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   r   )z<
        The tr element this tc element appears in.
        z./ancestor::w:tr[position()=1]r   r   r2   r$   r$   r%   r     r   z	CT_Tc._trc                 C   s0   | j j}|| j}|dkrtd||d  S )z
        The 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   r0   r1   r   r)   r*   r0   r3   r$   r$   r%   r     s
   zCT_Tc._tr_abovec                 C   s8   | j j}|| j}z||d  W S  ty   Y dS w )z
        The 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   r0   r1   r   
IndexErrorr   r$   r$   r%   r     s   zCT_Tc._tr_belowc                 C   s   | j j| jS )zM
        The row index of the tr element this tc element appears in.
        )r   r0   r1   r   r2   r$   r$   r%   r     s   zCT_Tc._tr_idxr;   )+r   r   r    r!   r   r   r   r   tblrL   r   r   r(   rM   r   r   r   rp   rI   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%   rH   q  sx    







	








		




	


rH   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_TcPrz>
    ``<w:tcPr>`` element, defining table cell properties
    )
w:cnfStylew:tcW
w:gridSpanzw:hMergew:vMergezw:tcBordersr   zw:noWrapzw:tcMarzw:textDirectionzw:tcFitTextw:vAlignz
w:hideMarkz	w:headersz	w:cellInsz	w:cellDelzw:cellMergezw:tcPrChanger   r   Nrr   r      r      r      c                 C   r   )z{
        The integer number of columns this cell spans. Determined by
        ./w:gridSpan/@val, it defaults to 1.
        Nr   )gridSpanr"   )r*   r   r$   r$   r%   r(     r9   zCT_TcPr.grid_spanc                 C   s"   |    |dkr||  _d S d S r   )Z_remove_gridSpanZget_or_add_gridSpanr"   r   r$   r$   r%   r(   
     c                 C   r5   )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  r   zCT_TcPr.vAlign_valc                 C   s"   |d u r
|    d S ||  _d S r;   )Z_remove_vAlignZget_or_add_vAlignr"   r   r$   r$   r%   r     s   c                 C   r5   )zw
        The 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   #  r9   zCT_TcPr.vMerge_valc                 C   s"   |    |d ur||  _d S d S r;   )Z_remove_vMergeZ_add_vMerger"   r   r$   r$   r%   r   .  r   c                 C   r5   )z
        Return the EMU length value represented in the ``<w:tcW>`` child
        element or |None| if not present or its type is not 'dxa'.
        N)tcWr]   )r*   r   r$   r$   r%   r]   4  r9   zCT_TcPr.widthc                 C   r:   r;   )Zget_or_add_tcWr]   )r*   r>   r   r$   r$   r%   r]   ?  r?   )r   r   r    r!   r   r   r   r   r   r   rL   r(   rM   r   r   r]   r$   r$   r$   r%   r     s0    









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_TrPrz=
    ``<w:trPr>`` element, defining table row properties
    )r   zw:divIdzw:gridBeforezw:gridAfterz	w:wBeforezw:wAfterzw:cantSplit
w:trHeightzw:tblHeaderr~   r}   zw:hiddenzw:inszw:delzw:trPrChanger   r   Nrr   c                 C   r5   )zU
        Return the value of `w:trHeight@w:hRule`, or |None| if not present.
        N)trHeightr#   r*   r   r$   r$   r%   r7   R     zCT_TrPr.trHeight_hRulec                 C   (   |d u r| j d u rd S |  }||_d S r;   )r   get_or_add_trHeightr#   r*   r>   r   r$   r$   r%   r7   \     
c                 C   r5   )zS
        Return the value of `w:trHeight@w:val`, or |None| if not present.
        N)r   r"   r   r$   r$   r%   r@   c  r   zCT_TrPr.trHeight_valc                 C   r   r;   )r   r   r"   r   r$   r$   r%   r@   m  r   )r   r   r    r!   r   r   r   rL   r7   rM   r@   r$   r$   r$   r%   r   E  s    
	

	r   c                   @   rv   )CT_VerticalJcz:`w:vAlign` element, specifying vertical alignment of cell.r   N)r   r   r    r!   r   r	   r"   r$   r$   r$   r%   r   u  s    r   c                   @   s    e Zd ZdZedeejdZdS )	CT_VMergezQ
    ``<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   z  s    r   N).r!   Z
__future__r   r   r   r   rn   r   Z
enum.tabler	   r
   
exceptionsr   nsr   r   sharedr   r   Zsimpletypesr   r   r   r   r   Zxmlchemyr   r   r   r   r   r   r   r   r&   rN   rq   rs   rw   rz   r   rH   r   r   r   r   r$   r$   r$   r%   <module>   s4   $L I   V0