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 )z¾Block 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 )zÞReturn 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&   