o
    W²ç_Ï	  ã                   @   sT   d Z ddlmZmZmZmZ ddlmZ ddlm	Z	 ddl
mZ 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.
é    )Úabsolute_importÚdivisionÚprint_functionÚunicode_literals)ÚCT_Tbl)ÚParented©Ú	Paragraphc                       sR   e Zd ZdZ‡ fdd„Zddd„Z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.
    c                    s   t t| ƒ |¡ || _d S )N)Úsuperr
   Ú__init__Ú_element)ÚselfÚelementÚparent©Ú	__class__© ú=D:\Projects\ConvertPro\env\Lib\site-packages\docx\blkcntnr.pyr      s   
zBlockItemContainer.__init__Ú Nc                 C   s(   |   ¡ }|r| |¡ |dur||_|S )a2  
        Return a paragraph newly added to the end of the content in this
        container, having *text* in a single run if present, and having
        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_runÚstyle)r   Útextr   Z	paragraphr   r   r   Úadd_paragraph   s   
z BlockItemContainer.add_paragraphc                 C   s0   ddl m} t |||¡}| j |¡ ||| ƒS )zÌ
        Return a table of *width* having *rows* rows and *cols* columns,
        newly appended to the content in this container. *width* is evenly
        distributed between the table columns.
        é   ©ÚTable)Útabler   r   Znew_tblr   Z_insert_tbl)r   ZrowsÚcolsÚwidthr   Útblr   r   r   Ú	add_table*   s   
zBlockItemContainer.add_tablec                    s   ‡ fdd„ˆ j jD ƒS )zk
        A 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   Zp_lstr$   r   r$   r   Ú
paragraphs5   s   zBlockItemContainer.paragraphsc                    s$   ddl m‰  ‡ ‡fdd„ˆjjD ƒS )zg
        A list containing the tables in this container, in document order.
        Read-only.
        r   r   c                    s   g | ]}ˆ |ˆƒ‘qS r   r   )r"   r    ©r   r   r   r   r%   D   r&   z-BlockItemContainer.tables.<locals>.<listcomp>)r   r   r   Ztbl_lstr$   r   r(   r   Útables=   s   zBlockItemContainer.tablesc                 C   s   t | j ¡ | ƒS )ze
        Return a paragraph newly added to the end of the content in this
        container.
        )r	   r   Zadd_pr$   r   r   r   r   F   s   z!BlockItemContainer._add_paragraph)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r!   Úpropertyr'   r)   r   Ú__classcell__r   r   r   r   r
      s    


r
   N)r-   Z
__future__r   r   r   r   Zdocx.oxml.tabler   Zdocx.sharedr   Zdocx.text.paragraphr	   r
   r   r   r   r   Ú<module>   s   