o
    P+ i                     @  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__ Y/home/app/PaddleOCR-VL-test/.venv_paddleocr/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_paragraphZadd_runr#   )r   r!   r#   Z	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   Znew_tblr   Z_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   Z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   Zp_lstr4   r   r4   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   )r2   r-   r   r   r   r   r5   a   r6   z-BlockItemContainer.tables.<locals>.<listcomp>)r,   r   r   Ztbl_lstr4   r   r8   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   Zadd_pr4   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%   r/   )__name__
__module____qualname____doc__r   r'   r.   r1   propertyr7   r9   r&   __classcell__r   r   r   r   r   !   s    



	r   )"r=   
__future__r   typingr   r   Ztyping_extensionsr   Zdocx.oxml.tabler   Zdocx.oxml.text.paragraphr   Zdocx.sharedr   Zdocx.text.paragraphr
   Z
docx.typestypestZdocx.oxml.commentsr   Zdocx.oxml.documentr   Zdocx.oxml.sectionr   r   r   Zdocx.styles.styler   r,   r   r   __annotations__r   r   r   r   r   <module>   s&   