
    ,h                        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 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  G d de      Z y)zParagraph-related proxy types.    )annotations)TYPE_CHECKINGIteratorListcast)WD_STYLE_TYPE)CT_R)
StoryChild)ParagraphStyle)	Hyperlink)RenderedPageBreak)ParagraphFormat)RunN)WD_PARAGRAPH_ALIGNMENT)CT_P)CharacterStylec                  X    e Zd ZdZd fdZdddZedd       Zej                  dd       Zd Z	edd       Z
edd       Z	 d	 	 	 	 	 dd	Zdd
Zed        Zedd       Zedd       Zedd       Zej                  dd       Zed d       Zej                  d!d       Zd Z xZS )"	Paragraphz(Proxy object wrapping a `<w:p>` element.c                H    t         t        |   |       |x| _        | _        y N)superr   __init___p_element)selfpparent	__class__s      U/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/docx/text/paragraph.pyr   zParagraph.__init__   s     i'/"##$-    c                v    | j                   j                         }t        ||       }|r||_        |r||_        |S )a{  Append run containing `text` and having character-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. When `text` is `None`, the new run is empty.
        )r   add_rr   textstyle)r   r#   r$   rruns        r   add_runzParagraph.add_run   s7     GGMMO!TlCHCI
r    c                .    | j                   j                  S )a{  A member of the :ref:`WdParagraphAlignment` enumeration specifying the
        justification setting for this paragraph.

        A value of |None| indicates the paragraph has no directly-applied alignment
        value and will inherit its alignment value from its style hierarchy. Assigning
        |None| to this property removes any directly-applied alignment value.
        r   	alignmentr   s    r   r*   zParagraph.alignment.   s     ww   r    c                &    || j                   _        y r   r)   )r   values     r   r*   zParagraph.alignment9   s    !r    c                :    | j                   j                          | S )zReturn this same paragraph after removing all its content.

        Paragraph-level formatting, such as style, is preserved.
        )r   clear_contentr+   s    r   clearzParagraph.clear=   s    
 	r    c                @    t        | j                  j                        S )zE`True` when one or more rendered page-breaks occur in this paragraph.)boolr   lastRenderedPageBreaksr+   s    r   contains_page_breakzParagraph.contains_page_breakE   s     DGG2233r    c                h    | j                   j                  D cg c]  }t        ||        c}S c c}w )z<A |Hyperlink| instance for each hyperlink in this paragraph.)r   hyperlink_lstr   )r   	hyperlinks     r   
hyperlinkszParagraph.hyperlinksJ   s*     =AGG<Q<QRy	)T*RRR   /c                ^    | j                         }|r|j                  |       |||_        |S )zReturn a newly created paragraph, inserted directly before this paragraph.

        If `text` is supplied, the new paragraph contains that text in a single run. If
        `style` is provided, that style is assigned to the new paragraph.
        )_insert_paragraph_beforer'   r$   )r   r#   r$   	paragraphs       r   insert_paragraph_beforez!Paragraph.insert_paragraph_beforeO   s6     113	d##IOr    c              #     K   | j                   j                  D ],  }t        |t              rt	        ||       nt        ||        . yw)a  Generate the runs and hyperlinks in this paragraph, in the order they appear.

        The content in a paragraph consists of both runs and hyperlinks. This method
        allows accessing each of those separately, in document order, for when the
        precise position of the hyperlink within the paragraph text is important. Note
        that a hyperlink itself contains runs.
        N)r   inner_content_elements
isinstancer	   r   r   )r   
r_or_hlinks     r   iter_inner_contentzParagraph.iter_inner_content^   sH      ''88 	J j$/ J%z40	s   AA	c                ,    t        | j                        S )zThe |ParagraphFormat| object providing access to the formatting properties
        for this paragraph, such as line spacing and indentation.)r   r   r+   s    r   paragraph_formatzParagraph.paragraph_formatm   s     t}}--r    c                h    | j                   j                  D cg c]  }t        ||        c}S c c}w )zAll rendered page-breaks in this paragraph.

        Most often an empty list, sometimes contains one page-break, but can contain
        more than one is rare or contrived cases.
        )r   r3   r   )r   lrpbs     r   rendered_page_breakszParagraph.rendered_page_breakss   s*     ;?'':X:XY$!$-YYYr9   c                h    | j                   j                  D cg c]  }t        ||        c}S c c}w )zZSequence of |Run| instances corresponding to the <w:r> elements in this
        paragraph.)r   r_lstr   )r   r%   s     r   runszParagraph.runs|   s&     '+ggmm4At444r9   c                    | j                   j                  }| j                  j                  |t        j
                        }t        t        |      S )a  Read/Write.

        |_ParagraphStyle| object representing the style assigned to this paragraph. If
        no explicit style is assigned to this paragraph, its value is the default
        paragraph style for the document. A paragraph style name can be assigned in lieu
        of a paragraph style object. Assigning |None| removes any applied style, making
        its effective value the default paragraph style for the document.
        )r   r$   part	get_styler   	PARAGRAPHr   r   )r   style_idr$   s      r   r$   zParagraph.style   s:     77==		##Hm.E.EFNE**r    c                z    | j                   j                  |t        j                        }|| j                  _        y r   )rL   get_style_idr   rN   r   r$   )r   style_or_namerO   s      r   r$   zParagraph.style   s)    99))-9P9PQ r    c                .    | j                   j                  S )a  The textual content of this paragraph.

        The text includes the visible-text portion of any hyperlinks in the paragraph.
        Tabs and line breaks in the XML are mapped to ``\t`` and ``\n`` characters
        respectively.

        Assigning text to this property causes all existing paragraph content to be
        replaced with a single run containing the assigned text. A ``\t`` character in
        the text is mapped to a ``<w:tab/>`` element and each ``\n`` or ``\r``
        character is mapped to a line break. Paragraph-level formatting, such as style,
        is preserved. All run-level formatting, such as bold or italic, is removed.
        )r   r#   r+   s    r   r#   zParagraph.text   s     ww||r    c                F    | j                          | j                  |       y r   )r0   r'   )r   r#   s     r   r#   zParagraph.text   s    

Tr    c                b    | j                   j                         }t        || j                        S )zJReturn a newly created paragraph, inserted directly before this paragraph.)r   add_p_beforer   _parent)r   r   s     r   r;   z"Paragraph._insert_paragraph_before   s%    GG  "DLL))r    )r   r   r   zt.ProvidesStoryPart)NN)r#   
str | Noner$   zstr | CharacterStyle | Nonereturnr   )rY   zWD_PARAGRAPH_ALIGNMENT | None)r-   r   )rY   r2   )rY   zList[Hyperlink])r#   rX   r$   str | ParagraphStyle | NonerY   r   )rY   zIterator[Run | Hyperlink])rY   zList[RenderedPageBreak])rY   z	List[Run])rY   zParagraphStyle | None)rR   rZ   )rY   str)r#   rX   )__name__
__module____qualname____doc__r   r'   propertyr*   setterr0   r4   r8   r=   rB   rD   rG   rJ   r$   r#   r;   __classcell__)r   s   @r   r   r      s1   2$  ! ! " " 4 4 S S
 MQ.I	 . .
 Z Z 5 5
 + + \\! !   
[[ *r    r   )!r_   
__future__r   typingr   r   r   r   docx.enum.styler   docx.oxml.text.runr	   docx.sharedr
   docx.styles.styler   docx.text.hyperlinkr   docx.text.pagebreakr   docx.text.parfmtr   docx.text.runr   
docx.typestypestdocx.enum.textr   docx.oxml.text.paragraphr   r   r    r    r   <module>rs      sF    $ " 6 6 ) # " , ) 1 , 5-0V*
 V*r    