
    hi                        U 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 er0dd	l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 ddlmZ ddlmZ dZde d<    G d de          Z!d	S )zBlock item container, used by body, cell, header, etc.

Block level items are things like paragraph and table, although there are a few other
specialized ones like structured document tags.
    )annotations)TYPE_CHECKINGIterator)	TypeAlias)CT_Tbl)CT_P)
StoryChild	ParagraphN)
CT_Comment)CT_Body)	CT_HdrFtr)CT_Tc)Length)ParagraphStyleTablez(CT_Body | CT_Comment | CT_HdrFtr | CT_Tcr   BlockItemElementc                  p     e Zd ZdZd fdZdddZddZd dZed             Z	ed             Z
d Z xZS )!BlockItemContainera  Base class for proxy objects that can contain block items.

    These containers include _Body, _Cell, header, footer, footnote, endnote, comment,
    and text box objects. Provides the shared functionality to add a block item like a
    paragraph or table.
    elementr   parentt.ProvidesStoryPartc                f    t          t          |                               |           || _        d S )N)superr   __init___element)selfr   r   	__class__s      e/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/docx/blkcntnr.pyr   zBlockItemContainer.__init__)   s-     $''00888     Ntextstrstylestr | ParagraphStyle | Nonereturnr   c                n    |                                  }|r|                    |           |||_        |S )a>  Return paragraph newly added to the end of the content in this container.

        The paragraph has `text` in a single run if present, and is given paragraph
        style `style`.

        If `style` is |None|, no paragraph style is applied, which has the same effect
        as applying the 'Normal' style.
        )_add_paragraphadd_runr%   )r   r#   r%   	paragraphs       r    add_paragraphz BlockItemContainer.add_paragraph-   sD     ''))	 	$d####IOr!   rowsintcolswidthr   r   c                    ddl m} t          j        |||          }| j                            |            |||           S )zReturn table of `width` having `rows` rows and `cols` columns.

        The table is appended appended at the end of the content in this container.

        `width` is evenly distributed between the table columns.
        r   r   )
docx.tabler   r   new_tblr   _insert_tbl)r   r-   r/   r0   r   tbls         r    	add_tablezBlockItemContainer.add_table=   sQ     	%$$$$$nT4//!!#&&&uS$r!   Iterator[Paragraph | Table]c              #     K   ddl m} | j        j        D ]5}t	          |t
                    rt          ||           n |||           V  6dS )zIGenerate each `Paragraph` or `Table` in this container in document order.r   r   N)r2   r   r   inner_content_elements
isinstancer   r   )r   r   r   s      r    iter_inner_contentz%BlockItemContainer.iter_inner_contentJ   su      $$$$$$}; 	d 	dG/9'4/H/Hb9Wd+++eeT[]aNbNbcccc	d 	dr!   c                4      fd j         j        D             S )zcA list containing the paragraphs in this container, in document order.

        Read-only.
        c                0    g | ]}t          |          S  r
   ).0pr   s     r    
<listcomp>z1BlockItemContainer.paragraphs.<locals>.<listcomp>W   s#    @@@q	!T""@@@r!   )r   p_lstr   s   `r    
paragraphszBlockItemContainer.paragraphsQ   s%     A@@@DM,?@@@@r!   c                D     ddl m  fd j        j        D             S )z_A list containing the tables in this container, in document order.

        Read-only.
        r   r   c                (    g | ]} |          S r>   r>   )r?   r5   r   r   s     r    rA   z-BlockItemContainer.tables.<locals>.<listcomp>a   s%    BBBSc4  BBBr!   )r2   r   r   tbl_lst)r   r   s   `@r    tableszBlockItemContainer.tablesY   s:     	%$$$$$BBBBBDM,ABBBBr!   c                P    t          | j                                        |           S )zIReturn paragraph newly added to the end of the content in this container.)r   r   add_prC   s    r    r)   z!BlockItemContainer._add_paragraphc   s     ,,..555r!   )r   r   r   r   )r"   N)r#   r$   r%   r&   r'   r   )r-   r.   r/   r.   r0   r   r'   r   )r'   r7   )__name__
__module____qualname____doc__r   r,   r6   r;   propertyrD   rH   r)   __classcell__)r   s   @r    r   r   !   s                                d d d d A A XA C C XC6 6 6 6 6 6 6r!   r   )"rN   
__future__r   typingr   r   typing_extensionsr   docx.oxml.tabler   docx.oxml.text.paragraphr   docx.sharedr	   docx.text.paragraphr   
docx.typestypestdocx.oxml.commentsr   docx.oxml.documentr   docx.oxml.sectionr   r   r   docx.styles.styler   r2   r   r   __annotations__r   r>   r!   r    <module>r`      s     # " " " " " * * * * * * * * ' ' ' ' ' ' " " " " " " ) ) ) ) ) ) " " " " " " ) ) ) ) ) ) !------******++++++%%%%%%""""""000000      H  H H H HD6 D6 D6 D6 D6 D6 D6 D6 D6 D6r!   