
    pjU                       d Z ddlm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 ddlmZmZ ddlmZmZ er4d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 m!Z! ddl"m#Z# ddl$m%Z%  G d de          Z& G d de	          Z'd	S )z'|Document| and closely related objects.    )annotations)IOTYPE_CHECKINGIteratorList)BlockItemContainer)
WD_SECTION)WD_BREAK)SectionSections)ElementProxyEmuN)CT_BodyCT_Document)DocumentPart)Settings)Length)ParagraphStyle_TableStyle)Table)	Paragraphc                  f    e Zd ZdZd6 fdZd7d8dZd Zd9d:dZ	 	 d;d<dZe	j
        fd=dZd>d?d!Zed"             Zed#             Zd@d%ZedAd'            ZedBd(            ZdCd*ZedDd,            ZedEd.            Zed/             ZedFd1            ZedGd3            ZedHd5            Z xZS )IDocumentzWordprocessingML (WML) document.

    Not intended to be constructed directly. Use :func:`docx.Document` to open or create
    a document.
    elementr   partr   c                    t          t          |                               |           || _        || _        d | _        d S N)superr   __init___element_part_Document__body)selfr   r   	__class__s      ]/lsinfo/ai/hellotax_ai/data_center/backend/venv/lib/python3.11/site-packages/docx/document.pyr   zDocument.__init__"   s:    h&&w///
        textstrlevelintc                    d|cxk    rdk    sn t          d|z            |dk    rdnd|z  }|                     ||          S )a  Return a heading paragraph newly added to the end of the document.

        The heading paragraph will contain `text` and have its paragraph style
        determined by `level`. If `level` is 0, the style is set to `Title`. If `level`
        is 1 (or omitted), `Heading 1` is used. Otherwise the style is set to `Heading
        {level}`. Raises |ValueError| if `level` is outside the range 0-9.
        r   	   z"level must be in range 0-9, got %dTitlez
Heading %d)
ValueErroradd_paragraph)r#   r)   r+   styles       r%   add_headingzDocument.add_heading(   s[     EQAEIJJJ A::<%+?!!$...r&   c                    |                                  }|                                                    t          j                   |S )z=Return newly |Paragraph| object containing only a page break.)r1   add_run	add_breakr
   PAGE)r#   	paragraphs     r%   add_page_breakzDocument.add_page_break5   s;    &&((	%%hm444r&   Nr2   str | ParagraphStyle | Nonereturnr   c                8    | j                             ||          S )a  Return paragraph newly added to the end of the document.

        The paragraph is populated with `text` and having paragraph style `style`.

        `text` can contain tab (``\t``) characters, which are converted to the
        appropriate XML form for a tab. `text` can also include newline (``\n``) or
        carriage return (``\r``) characters, each of which is converted to a line
        break.
        )_bodyr1   )r#   r)   r2   s      r%   r1   zDocument.add_paragraph;   s     z''e444r&   image_path_or_streamstr | IO[bytes]widthint | Length | Noneheightc                |    |                                                                  }|                    |||          S )a  Return new picture shape added in its own paragraph at end of the document.

        The picture contains the image at `image_path_or_stream`, scaled based on
        `width` and `height`. If neither width nor height is specified, the picture
        appears at its native size. If only one is specified, it is used to compute a
        scaling factor that is then applied to the unspecified dimension, preserving the
        aspect ratio of the image. The native size of the picture is calculated using
        the dots-per-inch (dpi) value specified in the image file, defaulting to 72 dpi
        if no value is specified, as is often the case.
        )r1   r5   add_picture)r#   r>   r@   rB   runs        r%   rD   zDocument.add_pictureG   s8        ""**,,3UFCCCr&   
start_typer	   c                v    | j         j                                        }||_        t	          || j                  S )zReturn a |Section| object newly added at the end of the document.

        The optional `start_type` argument must be a member of the :ref:`WdSectionStart`
        enumeration, and defaults to ``WD_SECTION.NEW_PAGE`` if not provided.
        )r    bodyadd_section_breakrF   r   r!   )r#   rF   
new_sectPrs      r%   add_sectionzDocument.add_sectionZ   s4     ]'99;;
 *
z4:...r&   rowscolsstr | _TableStyle | Nonec                V    | j                             ||| j                  }||_        |S )zAdd a table having row and column counts of `rows` and `cols` respectively.

        `style` may be a table style object or a table style name. If `style` is |None|,
        the table inherits the default table style of the document.
        )r=   	add_table_block_widthr2   )r#   rL   rM   r2   tables        r%   rP   zDocument.add_tabled   s,     
$$T41BCCr&   c                    | j         j        S )zGA |CoreProperties| object providing Dublin Core properties of document.)r!   core_propertiesr#   s    r%   rT   zDocument.core_propertiesn   s     z))r&   c                    | j         j        S )zThe |InlineShapes| collection for this document.

        An inline shape is a graphical object, such as a picture, contained in a run of
        text and behaving like a character glyph, being flowed like other text in a
        paragraph.
        )r!   inline_shapesrU   s    r%   rW   zDocument.inline_shapess   s     z''r&   Iterator[Paragraph | Table]c                4    | j                                         S )zHGenerate each `Paragraph` or `Table` in this document in document order.)r=   iter_inner_contentrU   s    r%   rZ   zDocument.iter_inner_content}   s    z,,...r&   List[Paragraph]c                    | j         j        S )zThe |Paragraph| instances in the document, in document order.

        Note that paragraphs within revision marks such as ``<w:ins>`` or ``<w:del>`` do
        not appear in this list.
        )r=   
paragraphsrU   s    r%   r]   zDocument.paragraphs   s     z$$r&   c                    | j         S )z+The |DocumentPart| object of this document.)r!   rU   s    r%   r   zDocument.part   s     zr&   path_or_streamc                :    | j                             |           dS )zSave this document to `path_or_stream`.

        `path_or_stream` can be either a path to a filesystem location (a string) or a
        file-like object.
        N)r!   save)r#   r_   s     r%   ra   zDocument.save   s     	
'''''r&   r   c                6    t          | j        | j                  S )zD|Sections| object providing access to each section in this document.)r   r    r!   rU   s    r%   sectionszDocument.sections   s     tz222r&   r   c                    | j         j        S )zDA |Settings| object providing access to the document-level settings.)r!   settingsrU   s    r%   re   zDocument.settings   s     z""r&   c                    | j         j        S )zBA |Styles| object providing access to the styles in this document.)r!   stylesrU   s    r%   rg   zDocument.styles   s     z  r&   List[Table]c                    | j         j        S )aP  All |Table| instances in the document, in document order.

        Note that only tables appearing at the top level of the document appear in this
        list; a table nested inside a table cell does not appear. A table within
        revision marks such as ``<w:ins>`` or ``<w:del>`` will also not appear in the
        list.
        )r=   tablesrU   s    r%   rj   zDocument.tables   s     z  r&   r   c                d    | j         d         }t          |j        |j        z
  |j        z
            S )zGA |Length| object specifying the space between margins in last section.)rc   r   
page_widthleft_marginright_margin)r#   sections     r%   rQ   zDocument._block_width   s1     -#7%(;;g>RRSSSr&   _Bodyc                \    | j         t          | j        j        |           | _         | j         S )z>The |_Body| instance containing the content for this document.)r"   rq   r    rH   rU   s    r%   r=   zDocument._body   s*     ; 2D99DK{r&   )r   r   r   r   )r'   r(   )r)   r*   r+   r,   )r'   N)r)   r*   r2   r:   r;   r   )NN)r>   r?   r@   rA   rB   rA   )rF   r	   r   )rL   r,   rM   r,   r2   rN   )r;   rX   )r;   r[   )r;   r   )r_   r?   )r;   r   )r;   r   )r;   rh   )r;   r   )r;   rq   )__name__
__module____qualname____doc__r   r3   r9   r1   rD   r	   NEW_PAGErK   rP   propertyrT   rW   rZ   r]   r   ra   rc   re   rg   rj   rQ   r=   __classcell__r$   s   @r%   r   r      sE             / / / / /  
5 
5 
5 
5 
5 &*&*	D D D D D& 4>3F / / / / /     * * X* ( ( X(/ / / / % % % X%    X( ( ( ( 3 3 3 X3 # # # X# ! ! X! ! ! ! X! T T T XT
    X    r&   r   c                  *     e Zd ZdZd fdZd Z xZS )	rq   zoProxy for `<w:body>` element in this document.

    It's primary role is a container for document content.
    body_elmr   parentt.ProvidesStoryPartc                h    t          t          |                               ||           || _        d S r   )r   rq   r   r=   )r#   r|   r}   r$   s      r%   r   z_Body.__init__   s.    eT##Hf555


r&   c                8    | j                                          | S )zReturn this |_Body| instance after clearing it of all content.

        Section properties for the main document story, if present, are preserved.
        )r=   clear_contentrU   s    r%   r   z_Body.clear_content   s    
 	
  """r&   )r|   r   r}   r~   )rs   rt   ru   rv   r   r   ry   rz   s   @r%   rq   rq      sV         
           r&   rq   )(rv   
__future__r   typingr   r   r   r   docx.blkcntnrr   docx.enum.sectionr	   docx.enum.textr
   docx.sectionr   r   docx.sharedr   r   
docx.typestypestdocx.oxml.documentr   r   docx.parts.documentr   docx.settingsr   r   docx.styles.styler   r   
docx.tabler   docx.text.paragraphr   r   rq    r&   r%   <module>r      s   . - " " " " " " 4 4 4 4 4 4 4 4 4 4 4 4 , , , , , , ( ( ( ( ( ( # # # # # # * * * * * * * * ) ) ) ) ) ) ) ) .77777777000000&&&&&&""""""========      ------a a a a a| a a aH         r&   