o
    h                     @  s   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rad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 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                      sb   e Zd ZdZd# fddZd$d%ddZd&ddZd'ddZedd Z	edd  Z
d!d" Z  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                   s   t t| | || _d S )N)superr   __init___element)selfr   r   	__class__ M/var/www/html/premium_crap/venv/lib/python3.10/site-packages/docx/blkcntnr.pyr   )   s   
zBlockItemContainer.__init__ Ntextstrstylestr | ParagraphStyle | Nonereturnr
   c                 C  s(   |   }|r|| |du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.
        N)_add_paragraphadd_runr#   )r   r!   r#   	paragraphr   r   r   add_paragraph-   s   	
z BlockItemContainer.add_paragraphrowsintcolswidthr   r   c                 C  s0   ddl m} t|||}| 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,   r-   r   tblr   r   r   	add_table=   s   
zBlockItemContainer.add_tableIterator[Paragraph | Table]c                 c  s@    ddl m} | jjD ]}t|trt|| n||| V  qdS )zIGenerate each `Paragraph` or `Table` in this container in document order.r   r   N)r.   r   r   inner_content_elements
isinstancer   r
   )r   r   r   r   r   r   iter_inner_contentJ   s
   "z%BlockItemContainer.iter_inner_contentc                   s    fdd j jD S )zcA list containing the paragraphs in this container, in document order.

        Read-only.
        c                   s   g | ]}t | qS r   r	   ).0pr   r   r   
<listcomp>W       z1BlockItemContainer.paragraphs.<locals>.<listcomp>)r   p_lstr9   r   r9   r   
paragraphsQ   s   zBlockItemContainer.paragraphsc                   s$   ddl m   fddjjD S )z_A list containing the tables in this container, in document order.

        Read-only.
        r   r   c                   s   g | ]} |qS r   r   )r7   r1   r   r   r   r   r:   a   r;   z-BlockItemContainer.tables.<locals>.<listcomp>)r.   r   r   tbl_lstr9   r   r>   r   tablesY   s   zBlockItemContainer.tablesc                 C  s   t | j | S )zIReturn paragraph newly added to the end of the content in this container.)r
   r   add_pr9   r   r   r   r&   c   s   z!BlockItemContainer._add_paragraph)r   r   r   r   )r    N)r!   r"   r#   r$   r%   r
   )r*   r+   r,   r+   r-   r   r%   r   )r%   r3   )__name__
__module____qualname____doc__r   r)   r2   r6   propertyr=   r@   r&   __classcell__r   r   r   r   r   !   s    



	r   )"rE   
__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   r.   r   r   __annotations__r   r   r   r   r   <module>   s&   