
    liLB                    V   d Z ddlmZ ddl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 er*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 ddlmZ ddl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%y)z-Table-related objects such as Table and Cell.    )annotations)TYPE_CHECKINGIterator)
FillFormat)TcRange)Subshape)	TextFrame)Emulazyproperty)MSO_VERTICAL_ANCHOR)CT_TableCT_TableCellCT_TableColCT_TableRow)BaseSlidePart)GraphicFrame)ProvidesPart)Lengthc                      e Zd ZdZd f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edd	       Zej                  dd
       Z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edd       Zed        Zedd       Zej                  dd       Z xZS )TablezA DrawingML table object.

    Not intended to be constructed directly, use
    :meth:`.Slide.shapes.add_table` to add a table to a slide.
    c                F    t         t        |           || _        || _        y N)superr   __init___tbl_graphic_frame)selftblgraphic_frame	__class__s      H/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/pptx/table.pyr   zTable.__init__   s    eT#%	+    c                N    t        | j                  j                  ||      |       S )zReturn cell at `row_idx`, `col_idx`.

        Return value is an instance of |_Cell|. `row_idx` and `col_idx` are zero-based, e.g.
        cell(0, 0) is the top, left cell in the table.
        )_Cellr   tc)r   row_idxcol_idxs      r!   cellz
Table.cell"   s      TYY\\'73T::r"   c                .    t        | j                  |       S )z|_ColumnCollection| instance for this table.

        Provides access to |_Column| objects representing the table's columns. |_Column| objects
        are accessed using list notation, e.g. `col = tbl.columns[0]`.
        )_ColumnCollectionr   r   s    r!   columnszTable.columns*   s     !D11r"   c                .    | j                   j                  S )zWhen `True`, indicates first column should have distinct formatting.

        Read/write. Distinct formatting is used, for example, when the first column contains row
        headings (is a side-heading column).
        r   firstColr+   s    r!   	first_colzTable.first_col3        yy!!!r"   c                &    || j                   _        y r   r.   r   values     r!   r0   zTable.first_col<       "		r"   c                .    | j                   j                  S )zWhen `True`, indicates first row should have distinct formatting.

        Read/write. Distinct formatting is used, for example, when the first row contains column
        headings.
        r   firstRowr+   s    r!   	first_rowzTable.first_row@   r1   r"   c                &    || j                   _        y r   r7   r3   s     r!   r9   zTable.first_rowI   r5   r"   c                .    | j                   j                  S )zWhen `True`, indicates rows should have alternating shading.

        Read/write. Used to allow rows to be traversed more easily without losing track of which
        row is being read.
        r   bandRowr+   s    r!   horz_bandingzTable.horz_bandingM        yy   r"   c                &    || j                   _        y r   r<   r3   s     r!   r>   zTable.horz_bandingV       !		r"   c                J      fd j                   j                         D        S )zGenerate _Cell object for each cell in this table.

        Each grid cell is generated in left-to-right, top-to-bottom order.
        c              3  6   K   | ]  }t        |        y wr   r$   .0r%   r   s     r!   	<genexpr>z#Table.iter_cells.<locals>.<genexpr>_   s     ?Bb$?   )r   iter_tcsr+   s   `r!   
iter_cellszTable.iter_cellsZ   s    
 @$))*<*<*>??r"   c                .    | j                   j                  S )zWhen `True`, indicates the rightmost column should have distinct formatting.

        Read/write. Used, for example, when a row totals column appears at the far right of the
        table.
        r   lastColr+   s    r!   last_colzTable.last_cola   r?   r"   c                &    || j                   _        y r   rL   r3   s     r!   rN   zTable.last_colj   rA   r"   c                .    | j                   j                  S )zWhen `True`, indicates the bottom row should have distinct formatting.

        Read/write. Used, for example, when a totals row appears as the bottom row.
        r   lastRowr+   s    r!   last_rowzTable.last_rown   s     yy   r"   c                &    || j                   _        y r   rQ   r3   s     r!   rS   zTable.last_rowv   rA   r"   c                    t        t        | j                  D cg c]  }|j                   c}            }|| j                  _        yc c}w )zCalled by a row when its height changes.

        Triggers the graphic frame to recalculate its total height (as the sum of the row
        heights).
        N)r
   sumrowsheightr   )r   rownew_table_heights      r!   notify_height_changedzTable.notify_height_changedz   s;     s$))#D3CJJ#DEF%5" $E   A	c                    t        t        | j                  D cg c]  }|j                   c}            }|| j                  _        yc c}w )zCalled by a column when its width changes.

        Triggers the graphic frame to recalculate its total width (as the sum of the column
        widths).
        N)r
   rV   r,   widthr   )r   colnew_table_widths      r!   notify_width_changedzTable.notify_width_changed   s:     c"E399"EFG$3! #Fr\   c                .    | j                   j                  S )z'The package part containing this table.)r   partr+   s    r!   rc   z
Table.part   s     ""'''r"   c                .    t        | j                  |       S )z|_RowCollection| instance for this table.

        Provides access to |_Row| objects representing the table's rows. |_Row| objects are
        accessed using list notation, e.g. `col = tbl.rows[0]`.
        )_RowCollectionr   r+   s    r!   rW   z
Table.rows   s     dii..r"   c                .    | j                   j                  S )zWhen `True`, indicates columns should have alternating shading.

        Read/write. Used to allow columns to be traversed more easily without losing track of
        which column is being read.
        r   bandColr+   s    r!   vert_bandingzTable.vert_banding   r?   r"   c                &    || j                   _        y r   rg   r3   s     r!   ri   zTable.vert_banding   rA   r"   )r   r   r   r   )r&   intr'   rk   returnr$   )rl   r*   rl   bool)r4   rn   rl   zIterator[_Cell]rl   None)rl   r   )__name__
__module____qualname____doc__r   r(   r   r,   propertyr0   setterr9   r>   rJ   rN   rS   r[   ra   rc   rW   ri   __classcell__r    s   @r!   r   r      sn   ,
; 2 2 " " # # " " # # ! ! " "@ ! ! __" " ! ! __" "64 ( ( / / ! ! " "r"   r   c                      e Zd ZdZd fdZ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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e	d$d       Zd%dZe	d&d       Zej                  d'd       Ze	d(d       Ze	d)d       Zej                  d*d       Zed+d       Z xZS ),r$   z
Table cellc                :    t         t        |   |       || _        y r   )r   r$   r   _tc)r   r%   parentr    s      r!   r   z_Cell.__init__   s    eT#F+r"   c                ^    t        |t        |             sy| j                  |j                  u S )z|True| if this object proxies the same element as `other`.

        Equality for proxy objects is defined as referring to the same XML element, whether or not
        they are the same proxy object instance.
        F
isinstancetyper|   r   others     r!   __eq__z_Cell.__eq__   s(     %d,xx599$$r"   c                ^    t        |t        |             sy| j                  |j                  uS )NTr   r   s     r!   __ne__z_Cell.__ne__   s&    %d,xxuyy((r"   c                `    | j                   j                         }t        j                  |      S )zs|FillFormat| instance for this cell.

        Provides access to fill properties such as foreground color.
        )r|   get_or_add_tcPrr   from_fill_parent)r   tcPrs     r!   fillz
_Cell.fill   s'     xx'')**400r"   c                .    | j                   j                  S )z=True if this cell is the top-left grid cell in a merged cell.)r|   is_merge_originr+   s    r!   r   z_Cell.is_merge_origin   s     xx'''r"   c                .    | j                   j                  S )ac  True if this cell is spanned by a merge-origin cell.

        A merge-origin cell "spans" the other grid cells in its merge range, consuming their area
        and "shadowing" the spanned grid cells.

        Note this value is |False| for a merge-origin cell. A merge-origin cell spans other grid
        cells, but is not itself a spanned cell.
        )r|   
is_spannedr+   s    r!   r   z_Cell.is_spanned   s     xx"""r"   c                .    | j                   j                  S )zLeft margin of cells.

        Read/write. If assigned |None|, the default value is used, 0.1 inches for left and right
        margins and 0.05 inches for top and bottom.
        )r|   marLr+   s    r!   margin_leftz_Cell.margin_left   s     xx}}r"   c                H    | j                  |       || j                  _        y r   )_validate_margin_valuer|   r   )r   r   s     r!   r   z_Cell.margin_left   s    ##K0#r"   c                .    | j                   j                  S )zRight margin of cell.)r|   marRr+   s    r!   margin_rightz_Cell.margin_right        xx}}r"   c                H    | j                  |       || j                  _        y r   )r   r|   r   )r   r   s     r!   r   z_Cell.margin_right   s    ##L1$r"   c                .    | j                   j                  S )zTop margin of cell.)r|   marTr+   s    r!   
margin_topz_Cell.margin_top   r   r"   c                H    | j                  |       || j                  _        y r   )r   r|   r   )r   r   s     r!   r   z_Cell.margin_top   s    ##J/"r"   c                .    | j                   j                  S )zBottom margin of cell.)r|   marBr+   s    r!   margin_bottomz_Cell.margin_bottom   r   r"   c                H    | j                  |       || j                  _        y r   )r   r|   r   )r   r   s     r!   r   z_Cell.margin_bottom   s    ##M2%r"   c                   t        | j                  |j                        }|j                  st        d      |j                  rt        d      |j                          |j                  \  }}|j                         D ]	  }||_         |j                         D ]	  }||_
         |j                         D ]	  }d|_         |j                         D ]	  }d|_         y)a  Create merged cell from this cell to `other_cell`.

        This cell and `other_cell` specify opposite corners of the merged cell range. Either
        diagonal of the cell region may be specified in either order, e.g. self=bottom-right,
        other_cell=top-left, etc.

        Raises |ValueError| if the specified range already contains merged cells anywhere within
        its extents or if `other_cell` is not in the same table as `self`.
        zother_cell from different tablez'range contains one or more merged cellsTN)r   r|   in_same_table
ValueErrorcontains_merged_cellmove_content_to_origin
dimensionsiter_top_row_tcsrowSpaniter_left_col_tcsgridSpaniter_except_left_col_tcshMergeiter_except_top_row_tcsvMerge)r   
other_celltc_range	row_count	col_countr%   s         r!   mergez_Cell.merge  s     488Z^^4%%>??((FGG'')'22	9++- 	#B"BJ	#,,. 	$B#BK	$335 	BBI	224 	BBI	r"   c                .    | j                   j                  S )af  int count of rows spanned by this cell.

        The value of this property may be misleading (often 1) on cells where `.is_merge_origin`
        is not |True|, since only a merge-origin cell contains complete span information. This
        property is only intended for use on cells known to be a merge origin by testing
        `.is_merge_origin`.
        )r|   r   r+   s    r!   span_heightz_Cell.span_height"  s     xxr"   c                .    | j                   j                  S )ai  int count of columns spanned by this cell.

        The value of this property may be misleading (often 1) on cells where `.is_merge_origin`
        is not |True|, since only a merge-origin cell contains complete span information. This
        property is only intended for use on cells known to be a merge origin by testing
        `.is_merge_origin`.
        )r|   r   r+   s    r!   
span_widthz_Cell.span_width-  s     xx   r"   c                    | j                   st        d      t        j                  | j                        }|j                         D ]  }dx|_        |_        dx|_        |_	          y)aX  Remove merge from this (merge-origin) cell.

        The merged cell represented by this object will be "unmerged", yielding a separate
        unmerged cell for each grid cell previously spanned by this merge.

        Raises |ValueError| when this cell is not a merge-origin cell. Test with
        `.is_merge_origin` before calling.
        z>not a merge-origin cell; only a merge-origin cell can be split   FN)
r   r   r   from_merge_originr|   rI   r   r   r   r   )r   r   r%   s      r!   splitz_Cell.split8  sa     ##`aa,,TXX6##% 	*B'((BJ$))BI		*r"   c                .    | j                   j                  S )a  Textual content of cell as a single string.

        The returned string will contain a newline character (`"\n"`) separating each paragraph
        and a vertical-tab (`"\v"`) character for each line break (soft carriage return) in the
        cell's text.

        Assignment to `text` replaces all text currently contained in the cell. A newline
        character (`"\n"`) in the assigned text causes a new paragraph to be started. A
        vertical-tab (`"\v"`) character in the assigned text causes a line-break (soft
        carriage-return) to be inserted. (The vertical-tab character appears in clipboard text
        copied from PowerPoint as its encoding of line-breaks.)
        
text_frametextr+   s    r!   r   z
_Cell.textJ  s     ###r"   c                &    || j                   _        y r   r   )r   r   s     r!   r   z
_Cell.textZ  s    #r"   c                N    | j                   j                         }t        ||       S )z9|TextFrame| containing the text that appears in the cell.)r|   get_or_add_txBodyr	   )r   txBodys     r!   r   z_Cell.text_frame^  s#     ++-&&r"   c                .    | j                   j                  S )a  Vertical alignment of this cell.

        This value is a member of the :ref:`MsoVerticalAnchor` enumeration or |None|. A value of
        |None| indicates the cell has no explicitly applied vertical anchor setting and its
        effective value is inherited from its style-hierarchy ancestors.

        Assigning |None| to this property causes any explicitly applied vertical anchor setting to
        be cleared and inheritance of its effective value to be restored.
        r|   anchorr+   s    r!   vertical_anchorz_Cell.vertical_anchord  s     xxr"   c                &    || j                   _        y r   r   )r   mso_anchor_idxs     r!   r   z_Cell.vertical_anchorq  s    (r"   c                J    t        | t              s| d}t        || z        yy)zMRaise ValueError if `margin_value` is not a positive integer value or |None|.Nz.margin value must be integer or None, got '%s')r   rk   	TypeError)margin_valuetmpls     r!   r   z_Cell._validate_margin_valueu  s1     ,,1ICDD</00 2J,r"   )r%   r   r}   r   )r   objectrl   rn   )rl   r   rm   rl   r   )r   Length | None)r   r   )r   r   )r   r   )r   r$   rl   rq   rl   rk   rp   )rl   str)r   r   )rl   r	   )rl   MSO_VERTICAL_ANCHOR | None)r   r   )r   r   rl   rq   )rr   rs   rt   ru   r   r   r   r   r   rv   r   r   r   rw   r   r   r   r   r   r   r   r   r   r   staticmethodr   rx   ry   s   @r!   r$   r$      s   %)
 1 1 ( ( 	# 	#   $ $   % %   # #   & &<     ! !*$ $ $ 
[[$ $ ' '
 
 
 ) ) 1 1r"   r$   c                  \     e Zd ZdZd fdZedd       Zej                  dd       Z xZS )_ColumnzTable columnc                H    t         t        |   |       || _        || _        y r   )r   r   r   _parent_gridCol)r   gridColr}   r    s      r!   r   z_Column.__init__  s     gt%f-r"   c                .    | j                   j                  S )zWidth of column in EMU.)r   wr+   s    r!   r^   z_Column.width  s     }}r"   c                Z    || j                   _        | j                  j                          y r   )r   r   r   ra   )r   r^   s     r!   r^   z_Column.width  s    ))+r"   )r   r   r}   r*   r   )r^   r   )	rr   rs   rt   ru   r   rv   r^   rw   rx   ry   s   @r!   r   r   }  s7     
   \\, ,r"   r   c                  l     e Zd ZdZd fdZed        Zedd       Zej                  dd       Z xZ	S )	_Rowz	Table rowc                H    t         t        |   |       || _        || _        y r   )r   r   r   r   _trr   trr}   r    s      r!   r   z_Row.__init__  s     dD"6*r"   c                .    t        | j                  |       S )zRead-only reference to collection of cells in row.

        An individual cell is referenced using list notation, e.g. `cell = row.cells[0]`.
        )_CellCollectionr   r+   s    r!   cellsz
_Row.cells  s     txx..r"   c                .    | j                   j                  S )zHeight of row in EMU.)r   hr+   s    r!   rX   z_Row.height  s     xxzzr"   c                Z    || j                   _        | j                  j                          y r   )r   r   r   r[   )r   rX   s     r!   rX   z_Row.height  s    
**,r"   )r   r   r}   re   r   )rX   r   )
rr   rs   rt   ru   r   rv   r   rX   rw   rx   ry   s   @r!   r   r     sK    
 / /   ]]- -r"   r   c                  <     e Zd ZdZd fdZddZddZd	dZ xZS )
r   z Horizontal sequence of row cellsc                H    t         t        |   |       || _        || _        y r   )r   r   r   r   r   r   s      r!   r   z_CellCollection.__init__  s     ot-f5r"   c                    |dk  s"|t        | j                  j                        k\  rd|z  }t        |      t	        | j                  j                  |   |       S )z+Provides indexed access, (e.g. 'cells[0]').r   zcell index [%d] out of range)lenr   tc_lst
IndexErrorr$   r   idxmsgs      r!   __getitem__z_CellCollection.__getitem__  sK    7cS11036CS/!TXX__S)400r"   c                B      fd j                   j                  D        S )zProvides iterability.c              3  6   K   | ]  }t        |        y wr   rD   rE   s     r!   rG   z+_CellCollection.__iter__.<locals>.<genexpr>  s     :Bb$:rH   )r   r   r+   s   `r!   __iter__z_CellCollection.__iter__  s    :$((//::r"   c                @    t        | j                  j                        S )z1Supports len() function (e.g. 'len(cells) == 1').)r   r   r   r+   s    r!   __len__z_CellCollection.__len__  s    488??##r"   )r   r   r}   r   )r   rk   rl   r$   ro   r   )	rr   rs   rt   ru   r   r   r   r   rx   ry   s   @r!   r   r     s    *
1;$r"   r   c                  8     e Zd ZdZd fdZddZd Zd Z xZS )r*   zSequence of table columns.c                H    t         t        |   |       || _        || _        y r   )r   r*   r   r   r   r   r   r}   r    s      r!   r   z_ColumnCollection.__init__  s!    /7	r"   c                    |dk  s,|t        | j                  j                  j                        k\  rd|z  }t	        |      t        | j                  j                  j                  |   |       S )z-Provides indexed access, (e.g. 'columns[0]').r   zcolumn index [%d] out of range)r   r   tblGridgridCol_lstr   r   r   s      r!   r   z_ColumnCollection.__getitem__  s[    7cS!2!2!>!>??2S8CS/!tyy((44S94@@r"   c                T    t        | j                  j                  j                        S )z3Supports len() function (e.g. 'len(columns) == 1').)r   r   r   r   r+   s    r!   r   z_ColumnCollection.__len__  s    499$$0011r"   c                8    | j                   j                          y)z@Called by a column when its width changes. Pass along to parent.N)r   ra   r+   s    r!   ra   z&_ColumnCollection.notify_width_changed  s    ))+r"   r   r   r}   r   )r   rk   )	rr   rs   rt   ru   r   r   r   ra   rx   ry   s   @r!   r*   r*     s    $
A2,r"   r*   c                  8     e Zd ZdZd fdZddZd Zd Z xZS )re   zSequence of table rowsc                H    t         t        |   |       || _        || _        y r   )r   re   r   r   r   r   s      r!   r   z_RowCollection.__init__  s     nd,V4	r"   c                    |dk  s|t        |       k\  rd|z  }t        |      t        | j                  j                  |   |       S )z*Provides indexed access, (e.g. 'rows[0]').r   zrow index [%d] out of range)r   r   r   r   tr_lstr   s      r!   r   z_RowCollection.__getitem__  sD    7cSY&/#5CS/!DII$$S)400r"   c                @    t        | j                  j                        S )z0Supports len() function (e.g. 'len(rows) == 1').)r   r   r  r+   s    r!   r   z_RowCollection.__len__  s    499##$$r"   c                8    | j                   j                          y)z>Called by a row when its height changes. Pass along to parent.N)r   r[   r+   s    r!   r[   z$_RowCollection.notify_height_changed  s    **,r"   r  )r   rk   rl   r   )	rr   rs   rt   ru   r   r   r   r[   rx   ry   s   @r!   re   re     s     
1%-r"   re   N)&ru   
__future__r   typingr   r   pptx.dml.fillr   pptx.oxml.tabler   pptx.shapesr   pptx.text.textr	   	pptx.utilr
   r   pptx.enum.textr   r   r   r   r   pptx.parts.slider   pptx.shapes.graphfrmr   
pptx.typesr   r   r   r   r$   r   r   r   r*   re    r"   r!   <module>r     s    3 " * $ #   $ '2PP.1' O"F O"dR1H R1j,h ,&-8 -6$h $0, ,0-X -r"   