§
    £”j+  ã                  ó„  — d Z ddlmZ ddlmZ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 dd	lmZmZmZmZ dd
lmZ er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# G d„ de¦  «        Z$ G d„ de¦  «        Z% G d„ de¦  «        Z& G d„ de¦  «        Z' G d„ d¦  «        Z(dS )z3Custom element classes related to text runs (CT_R).é    )Úannotations)ÚTYPE_CHECKINGÚCallableÚIteratorÚListÚcast)Ú
CT_Drawing)Úqn)ÚOxmlElement)Ú
ST_BrClearÚ	ST_BrType)ÚCT_RPr)ÚBaseOxmlElementÚOptionalAttributeÚ
ZeroOrMoreÚ	ZeroOrOne)ÚTextAccumulator)Ú	CT_AnchorÚ	CT_Inline©ÚCT_LastRenderedPageBreak)Ú
CT_TabStopc                  ó°  — e Zd ZU dZded<   ded<   ded<   ded	<   d
ed<    ed¦  «        Zded<    ed¦  «        Z ed¦  «        Z	 ed¦  «        Z
 ed¦  «        Z ed¦  «        Zd1d„Zd2d„Zd3d„Zed4d „¦   «         Zd5d#„Zd5d$„Zed6d&„¦   «         Zed7d(„¦   «         Zej        d8d*„¦   «         Zed9d+„¦   «         Zej        d:d,„¦   «         Zd;d.„Zd<d/„Zd0S )=ÚCT_Rz>`<w:r>` element, containing the properties and text for a run.zCallable[[], CT_Br]Úadd_brzCallable[[], CT_TabStop]Úadd_tabzCallable[[], CT_RPr]Úget_or_add_rPrzCallable[[], CT_Drawing]Ú_add_drawingzCallable[..., CT_Text]Ú_add_tzw:rPrzCT_RPr | NoneÚrPrzw:brzw:crz	w:drawingzw:tzw:tabÚtextÚstrÚreturnÚCT_Textc                óÜ   — |                       |¬¦  «        }t          |                     ¦   «         ¦  «        t          |¦  «        k     r#|                     t	          d¦  «        d¦  «         |S )z7Return a newly added `<w:t>` element containing `text`.©r!   z	xml:spaceÚpreserve)r   ÚlenÚstripÚsetr
   )Úselfr!   Úts      úa/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/docx/oxml/text/run.pyÚadd_tz
CT_R.add_t(   sU   € à�KŠK˜TˆKÑ"Ô"ˆÝˆt�zŠz‰|Œ|ÑÔ�s 4™yœyÒ(Ð(Ø�EŠE•"�[‘/”/ :Ñ.Ô.Ð.Øˆó    Úinline_or_anchorúCT_Inline | CT_Anchorr	   c                óX   — |                       ¦   «         }|                     |¦  «         |S )zŽReturn newly appended `CT_Drawing` (`w:drawing`) child element.

        The `w:drawing` element has `inline_or_anchor` as its child.
        )r   Úappend)r+   r0   Údrawings      r-   Úadd_drawingzCT_R.add_drawing/   s-   € ð
 ×#Ò#Ñ%Ô%ˆØ�ŠÐ'Ñ(Ô(Ð(Øˆr/   ÚNonec                ó`   — |                       d¦  «        D ]}|                      |¦  «         ŒdS )z>Remove all child elements except a `w:rPr` element if present.z./*[not(self::w:rPr)]N)ÚxpathÚremove)r+   Úes     r-   Úclear_contentzCT_R.clear_content8   s;   € ð —’Ð3Ñ4Ô4ð 	ð 	ˆAØ�KŠK˜‰NŒNˆNˆNð	ð 	r/   ú1List[str | CT_Drawing | CT_LastRenderedPageBreak]c                ón   ‡ ‡‡— ddl mŠ t          ¦   «         Šdˆˆˆ fd„}t           |¦   «         ¦  «        S )zGText of run, possibly punctuated by `w:lastRenderedPageBreak` elements.r   r   r#   ú5Iterator[str | CT_Drawing | CT_LastRenderedPageBreak]c               3  ó   •K  — ‰                      d¦  «        D ]Z} t          | t          ‰f¦  «        r‰                     ¦   «         E d {V —† | V — Œ8‰                     t          | ¦  «        ¦  «         Œ[‰                     ¦   «         E d {V —† d S )NzZw:br | w:cr | w:drawing | w:lastRenderedPageBreak | w:noBreakHyphen | w:ptab | w:t | w:tab)r8   Ú
isinstancer	   ÚpopÚpushr"   )r:   r   Úaccumr+   s    €€€r-   Ú
iter_itemsz,CT_R.inner_content_items.<locals>.iter_itemsE   s±   øè è € Ø—Z’Zðñ	ô 	ð 'ð '�õ ˜a¥*Ð.FÐ!GÑHÔHð 'Ø$Ÿyšy™{œ{Ð*Ð*Ð*Ð*Ð*Ð*Ð*Ø�G�G�G�Gà—J’J�s 1™vœvÑ&Ô&Ð&Ð&ð —y’y‘{”{Ð"Ð"Ð"Ð"Ð"Ð"Ð"Ð"Ð"r/   )r#   r>   )Údocx.oxml.text.pagebreakr   r   Úlist)r+   rD   r   rC   s   ` @@r-   Úinner_content_itemszCT_R.inner_content_items>   sc   øøø€ ð 	FÐEÐEÐEÐEÐEåÑ!Ô!ˆð	#ð 	#ð 	#ð 	#ð 	#ð 	#ð 	#ð 	#õ( �J�J‘L”LÑ!Ô!Ð!r/   Ú
comment_idÚintc           	     óÖ   — |                       |                      |¦  «        ¦  «         |                       t          dt          d¦  «        t	          |¦  «        i¬¦  «        ¦  «         dS )zöInsert a `w:commentRangeEnd` and `w:commentReference` element after this run.

        The `w:commentRangeEnd` element is the immediate sibling of this `w:r` and is followed by
        a `w:r` containing the `w:commentReference` element.
        zw:commentRangeEndúw:id©ÚattrsN)ÚaddnextÚ_new_comment_reference_runr   r
   r"   ©r+   rH   s     r-   Ú,insert_comment_range_end_and_reference_belowz1CT_R.insert_comment_range_end_and_reference_below[   s[   € ð 	�Š�T×4Ò4°ZÑ@Ô@ÑAÔAÐAØ�Š•[Ð!4½RÀ¹Z¼ZÍÈZÉÌÐ<YÐZÑZÔZÑ[Ô[Ð[Ð[Ð[r/   c           	     ó†   — |                       t          dt          d¦  «        t          |¦  «        i¬¦  «        ¦  «         dS )zIInsert a `w:commentRangeStart` element with `comment_id` before this run.zw:commentRangeStartrK   rL   N)Úaddpreviousr   r
   r"   rP   s     r-   Ú insert_comment_range_start_abovez%CT_R.insert_comment_range_start_aboved   s<   € à×Ò�Ð%:Å2ÀfÁ:Ä:ÍsÐS]ÉÌÐB_Ð`Ñ`Ô`ÑaÔaÐaÐaÐar/   úList[CT_LastRenderedPageBreak]c                ó,   — |                       d¦  «        S )z7All `w:lastRenderedPageBreaks` descendants of this run.z./w:lastRenderedPageBreak)r8   ©r+   s    r-   ÚlastRenderedPageBreakszCT_R.lastRenderedPageBreaksh   s   € ð �zŠzÐ5Ñ6Ô6Ð6r/   ú
str | Nonec                ó&   — | j         }|€dS |j        S )zxString contained in `w:val` attribute of `w:rStyle` grandchild.

        |None| if that element is not present.
        N)r    Ústyle©r+   r    s     r-   r[   z
CT_R.stylem   s   € ð ŒhˆØˆ;Ø�4ØŒyÐr/   r[   c                ó<   — |                       ¦   «         }||_        dS )zuSet character style of this `w:r` element to `style`.

        If `style` is None, remove the style element.
        N)r   r[   )r+   r[   r    s      r-   r[   z
CT_R.stylex   s    € ð ×!Ò!Ñ#Ô#ˆØˆŒ	ˆ	ˆ	r/   c                óf   — d                      d„ |                      d¦  «        D ¦   «         ¦  «        S )z�The textual content of this run.

        Inner-content child elements like `w:tab` are translated to their text
        equivalent.
        Ú c              3  ó4   K  — | ]}t          |¦  «        V — Œd S ©N)r"   )Ú.0r:   s     r-   ú	<genexpr>zCT_R.text.<locals>.<genexpr>ˆ   s9   è è € ð 
ð 
Ø�C�‰FŒFð
ð 
ð 
ð 
ð 
ð 
r/   z4w:br | w:cr | w:noBreakHyphen | w:ptab | w:t | w:tab)Újoinr8   rW   s    r-   r!   z	CT_R.text�   sC   € ð �wŠwð 
ð 
Ø ŸJšJÐ']Ñ^Ô^ð
ñ 
ô 
ñ 
ô 
ð 	
r/   c                ód   — |                       ¦   «          t                               | |¦  «         d S ra   )r;   Ú_RunContentAppenderÚappend_to_run_from_text©r+   r!   s     r-   r!   z	CT_R.textŒ   s0   € à×ÒÑÔÐÝ×3Ò3°D¸$Ñ?Ô?Ð?Ð?Ð?r/   r   c                ó2   — |                       d|¦  «         |S )Nr   )Úinsertr\   s     r-   Ú_insert_rPrzCT_R._insert_rPr‘   s   € Ø�Š�A�sÑÔÐØˆ
r/   c           	     ó   — t          t          t          d¦  «        ¦  «        }|                     ¦   «         }d|_        |                     t          dt          d¦  «        t          |¦  «        i¬¦  «        ¦  «         |S )a  Return a new `w:r` element with `w:commentReference` referencing `comment_id`.

        Should look like this:

            <w:r>
              <w:rPr><w:rStyle w:val="CommentReference"/></w:rPr>
              <w:commentReference w:id="0"/>
            </w:r>

        zw:rÚCommentReferencezw:commentReferencerK   rL   )r   r   r   r   r[   r3   r
   r"   )r+   rH   Úrr    s       r-   rO   zCT_R._new_comment_reference_run•   si   € õ ••{ 5Ñ)Ô)Ñ*Ô*ˆØ×ÒÑ Ô ˆØ&ˆŒ	Ø	�Š•Ð1½"¸V¹*¼*ÅcÈ*ÁoÄoÐ9VÐWÑWÔWÑXÔXÐXØˆr/   N)r!   r"   r#   r$   )r0   r1   r#   r	   )r#   r6   )r#   r<   )rH   rI   r#   r6   )r#   rU   )r#   rY   )r[   rY   ©r#   r"   ©r!   r"   )r    r   r#   r   )rH   rI   r#   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r    r   ÚbrÚcrr4   r,   Útabr.   r5   r;   ÚpropertyrG   rQ   rT   rX   r[   Úsetterr!   rk   rO   © r/   r-   r   r      s  € € € € € € ØHÐHàÐÐÑØ%Ð%Ð%Ñ%Ø(Ð(Ð(Ñ(Ø*Ð*Ð*Ñ*Ø"Ð"Ð"Ñ"à"˜ 7Ñ+Ô+€CÐ+Ð+Ð+Ñ+Ø	ˆ�FÑ	Ô	€BØ	ˆ�FÑ	Ô	€BØˆj˜Ñ%Ô%€GØˆ
�5ÑÔ€AØ
ˆ*�WÑ
Ô
€Cðð ð ð ðð ð ð ðð ð ð ð ð"ð "ð "ñ „Xð"ð8\ð \ð \ð \ðbð bð bð bð ð7ð 7ð 7ñ „Xð7ð ðð ð ñ „Xðð „\ðð ð ñ „\ðð ð
ð 
ð 
ñ „Xð
ð 
„[ð@ð @ð @ñ „[ð@ðð ð ð ðð ð ð ð ð r/   r   c                  ód   — e Zd ZU dZ eded¬¦  «        Zded<    ede¦  «        Z	ded<   dd„Z
dS )ÚCT_BrzD`<w:br>` element, indicating a line, page, or column break in a run.zw:typeÚtextWrapping)ÚdefaultrY   Útypezw:clearÚclearr#   r"   c                ó    — | j         dk    rdndS )a>  Text equivalent of this element. Actual value depends on break type.

        A line break is translated as "
". Column and page breaks produce the empty
        string ("").

        This allows the text of run inner-content to be accessed in a consistent way
        for all run inner-context text elements.
        r~   ú
r_   )r€   rW   s    r-   Ú__str__zCT_Br.__str__³   s   € ð ”y NÒ2Ð2ˆtˆt¸Ð:r/   Nro   )rq   rr   rs   rt   r   r   r€   ru   r   r�   r„   r{   r/   r-   r}   r}   «   s‚   € € € € € € ØNÐNà(Ð(Ø�) ^ðñ ô €Dð ð ð ñ ð *Ð)¨)°ZÑ@Ô@€EÐ@Ð@Ð@Ñ@ð	;ð 	;ð 	;ð 	;ð 	;ð 	;r/   r}   c                  ó   — e Zd ZdZdd„ZdS )ÚCT_Cra<  `<w:cr>` element, representing a carriage-return (0x0D) character within a run.

    In Word, this represents a "soft carriage-return" in the sense that it does not end
    the paragraph the way pressing Enter (aka. Return) on the keyboard does. Here the
    text equivalent is considered to be newline ("
") since in plain-text that's the
    closest Python equivalent.

    NOTE: this complex-type name does not exist in the schema, where `w:tab` maps to
    `CT_Empty`. This name was added to give it distinguished behavior. CT_Empty is used
    for many elements.
    r#   r"   c                ó   — dS )z8Text equivalent of this element, a single newline ("
").rƒ   r{   rW   s    r-   r„   zCT_Cr.__str__Ì   s   € àˆtr/   Nro   ©rq   rr   rs   rt   r„   r{   r/   r-   r†   r†   ¿   s2   € € € € € ð
ð 
ðð ð ð ð ð r/   r†   c                  ó   — e Zd ZdZdd„ZdS )ÚCT_NoBreakHyphenah  `<w:noBreakHyphen>` element, a hyphen ineligible for a line-wrap position.

    This maps to a plain-text dash ("-").

    NOTE: this complex-type name does not exist in the schema, where `w:noBreakHyphen`
    maps to `CT_Empty`. This name was added to give it behavior distinguished from the
    many other elements represented in the schema by CT_Empty.
    r#   r"   c                ó   — dS )z?Text equivalent of this element, a single dash character ("-").ú-r{   rW   s    r-   r„   zCT_NoBreakHyphen.__str__Û   s   € àˆsr/   Nro   rˆ   r{   r/   r-   rŠ   rŠ   Ñ   s2   € € € € € ðð ðð ð ð ð ð r/   rŠ   c                  ó   — e Zd ZdZdd„ZdS )ÚCT_PTaba  `<w:ptab>` element, representing an absolute-position tab character within a run.

    This character advances the rendering position to the specified position regardless
    of any tab-stops, perhaps for layout of a table-of-contents (TOC) or similar.
    r#   r"   c                ó   — dS )zÎText equivalent of this element, a single tab ("	") character.

        This allows the text of run inner-content to be accessed in a consistent way
        for all run inner-context text elements.
        ú	r{   rW   s    r-   r„   zCT_PTab.__str__ç   s	   € ð ˆtr/   Nro   rˆ   r{   r/   r-   rŽ   rŽ   à   s2   € € € € € ðð ðð ð ð ð ð r/   rŽ   c                  ó   — e Zd ZdZdd„ZdS )r$   zB`<w:t>` element, containing a sequence of characters within a run.r#   r"   c                ó   — | j         pdS )a@  Text contained in this element, the empty string if it has no content.

        This property allows this run inner-content element to be queried for its text
        the same way as other run-content elements are. In particular, this never
        returns None, as etree._Element does when there is no content.
        r_   r&   rW   s    r-   r„   zCT_Text.__str__ø   s   € ð Œyˆ˜BÐr/   Nro   rˆ   r{   r/   r-   r$   r$   õ   s.   € € € € € ØLÐLðð ð ð ð ð r/   r$   c                  óH   — e Zd ZdZdd„Zedd„¦   «         Zdd„Zdd
„Zd„ Z	dS )rf   af  Translates a Python string into run content elements appended in a `w:r` element.

    Contiguous sequences of regular characters are appended in a single `<w:t>` element.
    Each tab character ('	') causes a `<w:tab/>` element to be appended. Likewise a
    newline or carriage return character ('
', '') causes a `<w:cr>` element to be
    appended.
    rn   r   c                ó"   — || _         g | _        d S ra   )Ú_rÚ_bfr)r+   rn   s     r-   Ú__init__z_RunContentAppender.__init__  s   € ØˆŒØ!ˆŒ	ˆ	ˆ	r/   r!   r"   c                óF   —  | |¦  «        }|                      |¦  «         dS )z8Append inner-content elements for `text` to `r` element.N)Úadd_text)Úclsrn   r!   Úappenders       r-   rg   z+_RunContentAppender.append_to_run_from_text  s+   € ð �3�q‘6”6ˆØ×Ò˜$ÑÔÐÐÐr/   c                ób   — |D ]}|                       |¦  «         Œ|                      ¦   «          dS )z>Append inner-content elements for `text` to the `w:r` element.N)Úadd_charÚflush)r+   r!   Úchars      r-   r™   z_RunContentAppender.add_text  s7   € àð 	 ð 	 ˆDØ�MŠM˜$ÑÔÐÐØ�
Š
‰Œˆˆˆr/   rŸ   c                ó
  — |dk    r/|                       ¦   «          | j                             ¦   «          dS |dv r/|                       ¦   «          | j                             ¦   «          dS | j                             |¦  «         dS )a0  Process next character of input through finite state maching (FSM).

        There are two possible states, buffer pending and not pending, but those are
        hidden behind the `.flush()` method which must be called at the end of text to
        ensure any pending `<w:t>` element is written.
        r�   z
N)rž   r•   r   r   r–   r3   )r+   rŸ   s     r-   r�   z_RunContentAppender.add_char  s|   € ð �4Š<ˆ<Ø�JŠJ‰LŒLˆLØŒG�OŠOÑÔÐÐÐØ�Vˆ^ˆ^Ø�JŠJ‰LŒLˆLØŒG�NŠNÑÔÐÐÐàŒI×Ò˜TÑ"Ô"Ð"Ð"Ð"r/   c                ó¤   — d                      | j        ¦  «        }|r| j                             |¦  «         | j                             ¦   «          d S )Nr_   )rd   r–   r•   r.   r�   rh   s     r-   rž   z_RunContentAppender.flush/  sI   € Ø�wŠw�t”yÑ!Ô!ˆØð 	 ØŒG�MŠM˜$ÑÔÐØŒ	�ŠÑÔÐÐÐr/   N)rn   r   )rn   r   r!   r"   rp   )rŸ   r"   )
rq   rr   rs   rt   r—   Úclassmethodrg   r™   r�   rž   r{   r/   r-   rf   rf     s‰   € € € € € ðð ð"ð "ð "ð "ð ð ð  ð  ñ „[ð ð
ð ð ð ð#ð #ð #ð #ð ð ð ð ð r/   rf   N))rt   Ú
__future__r   Útypingr   r   r   r   r   Údocx.oxml.drawingr	   Údocx.oxml.nsr
   Údocx.oxml.parserr   Údocx.oxml.simpletypesr   r   Údocx.oxml.text.fontr   Údocx.oxml.xmlchemyr   r   r   r   Údocx.sharedr   Údocx.oxml.shaper   r   rE   r   Údocx.oxml.text.parfmtr   r   r}   r†   rŠ   rŽ   r$   rf   r{   r/   r-   ú<module>r®      sX  ðØ 9Ð 9à "Ð "Ð "Ð "Ð "Ð "à @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @à (Ð (Ð (Ð (Ð (Ð (Ø Ð Ð Ð Ð Ð Ø (Ð (Ð (Ð (Ð (Ð (Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø &Ð &Ð &Ð &Ð &Ð &Ø XÐ XÐ XÐ XÐ XÐ XÐ XÐ XÐ XÐ XÐ XÐ XØ 'Ð 'Ð 'Ð 'Ð 'Ð 'àð 1Ø4Ð4Ð4Ð4Ð4Ð4Ð4Ð4ØAÐAÐAÐAÐAÐAØ0Ð0Ð0Ð0Ð0Ð0ðLð Lð Lð Lð Lˆ?ñ Lô Lð Lðf;ð ;ð ;ð ;ð ;ˆOñ ;ô ;ð ;ð(ð ð ð ð ˆOñ ô ð ð$ð ð ð ð �ñ ô ð ðð ð ð ð ˆoñ ô ð ð*
ð 
ð 
ð 
ð 
ˆoñ 
ô 
ð 
ð"-ð -ð -ð -ð -ñ -ô -ð -ð -ð -r/   