o
    	'f                     @  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r[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	Paragraph)types)CT_Body)	CT_HdrFtr)CT_Tc)Length)ParagraphStyleTablezCT_Body | CT_HdrFtr | CT_Tcr   BlockItemElementc                      sd   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__ E/home/ubuntu/flask/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_contentK   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>\       z1BlockItemContainer.paragraphs.<locals>.<listcomp>)r   p_lstr9   r   r9   r   
paragraphsV   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:   f   r;   z-BlockItemContainer.tables.<locals>.<listcomp>)r.   r   r   tbl_lstr9   r   r>   r   tables^   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&   h   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   N) rE   
__future__r   typingr   r   typing_extensionsr   docx.oxml.tabler   docx.oxml.text.paragraphr   docx.sharedr   docx.text.paragraphr
   docxr   tdocx.oxml.documentr   docx.oxml.sectionr   r   r   docx.styles.styler   r.   r   r   __annotations__r   r   r   r   r   <module>   s$   