HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/docx/text/__pycache__/run.cpython-310.pyc
o

$we�%�@s�dZddlmZddlmZmZmZmZddlm	Z
ddlmZddl
mZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZerlddlmZddl m!Z!m"Z"ddlm#Z#Gdd�de�Z$Gdd�d�Z%dS)z=Run-related proxy objects for python-docx, Run in particular.�)�annotations)�IO�
TYPE_CHECKING�Iterator�cast)�types)�Drawing)�
WD_STYLE_TYPE)�WD_BREAK)�
CT_Drawing)�CT_LastRenderedPageBreak)�InlineShape)�
StoryChild)�CharacterStyle)�Font)�RenderedPageBreak)�WD_UNDERLINE)�CT_R�CT_Text)�LengthcseZdZdZd=�fdd�Zejfd>d
d�Z		d?d@dd�ZdAdd�Z	dBdd�Z
edCdd��Zej
dDd!d��Zd"d#�ZedEd%d&��ZedFd(d)��ZedCd*d+��Zej
dDd,d+��ZdGd.d/�ZedHd1d2��Zej
dId5d2��ZedJd6d7��Zej
dBd8d7��ZedKd:d;��Zej
dLd<d;��Z�ZS)M�RunaIProxy object wrapping `<w:r>` element.

    Several of the properties on Run take a tri-state value, |True|, |False|, or |None|.
    |True| and |False| correspond to on and off respectively. |None| indicates the
    property is not specified directly on the run and its effective value is taken from
    the style hierarchy.
    �rr�parent�t.ProvidesStoryPartcs"t��|�||_|_|_dS�N)�super�__init__�_r�_element�element)�selfrr��	__class__��F/home/arjun/projects/env/lib/python3.10/site-packages/docx/text/run.pyr"szRun.__init__�
break_typer
cCs^tjdtjdtjdtjdtjdtjdi|\}}|j��}|dur$||_	|dur-||_
dSdS)a	Add a break element of `break_type` to this run.

        `break_type` can take the values `WD_BREAK.LINE`, `WD_BREAK.PAGE`, and
        `WD_BREAK.COLUMN` where `WD_BREAK` is imported from `docx.enum.text`.
        `break_type` defaults to `WD_BREAK.LINE`.
        �NN)�pageN)�columnN)�textWrapping�left)r)�right)r)�allN)r
�LINE�PAGE�COLUMN�LINE_CLEAR_LEFT�LINE_CLEAR_RIGHT�LINE_CLEAR_ALLr�add_br�type�clear)r r%�type_r5�brr#r#r$�	add_break&s��

�z
Run.add_breakN�image_path_or_stream�str | IO[bytes]�width�
Length | None�height�returnr
cCs$|j�|||�}|j�|�t|�S)a�Return |InlineShape| containing image identified by `image_path_or_stream`.

        The picture is added to the end of this run.

        `image_path_or_stream` can be a path (a string) or a file-like object containing
        a binary image.

        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.
        )�part�new_pic_inliner�add_drawingr
)r r9r;r=�inliner#r#r$�add_picture;szRun.add_picture�NonecCs|j��dS)zcAdd a ``<w:tab/>`` element at the end of the run, which Word interprets as a
        tab character.N)r�add_tab�r r#r#r$rESszRun.add_tab�text�strcCs|j�|�}t|�S)z�Returns a newly appended |_Text| object (corresponding to a new ``<w:t>``
        child element) to the run, containing `text`.

        Compare with the possibly more friendly approach of assigning text to the
        :attr:`Run.text` property.
        )r�add_t�_Text)r rG�tr#r#r$�add_textXszRun.add_text�bool | NonecC�|jjS)aRead/write tri-state value.

        When |True|, causes the text of the run to appear in bold face. When |False|,
        the text unconditionally appears non-bold. When |None| the bold setting for this
        run is inherited from the style hierarchy.
        ��font�boldrFr#r#r$rQb�zRun.bold�valuecC�||j_dSrrO�r rSr#r#r$rQl�cCs|j��|S)zoReturn reference to this run after removing all its content.

        All run formatting is preserved.
        )r�
clear_contentrFr#r#r$r5ps
z	Run.clear�boolcCst|jj�S)a�`True` when one or more rendered page-breaks occur in this run.

        Note that "hard" page-breaks inserted by the author are not included. A hard
        page-break gives rise to a rendered page-break in the right position so if those
        were included that page-break would be "double-counted".

        It would be very rare for multiple rendered page-breaks to occur in a single
        run, but it is possible.
        )rXr�lastRenderedPageBreaksrFr#r#r$�contains_page_breakxszRun.contains_page_breakrcCs
t|j�S)z{The |Font| object providing access to the character formatting properties for
        this run, such as font name and size.)rrrFr#r#r$rP�s
zRun.fontcCrN)a	Read/write tri-state value.

        When |True|, causes the text of the run to appear in italics. When |False|, the
        text unconditionally appears non-italic. When |None| the italic setting for this
        run is inherited from the style hierarchy.
        �rP�italicrFr#r#r$r\�rRz
Run.italiccCrTrr[rUr#r#r$r\�rV�+Iterator[str | Drawing | RenderedPageBreak]ccsT�|jjD]"}t|t�r|Vqt|t�rt||�Vqt|t�r't||�VqdS)a'Generate the content-items in this run in the order they appear.

        NOTE: only content-types currently supported by `python-docx` are generated. In
        this version, that is text and rendered page-breaks. Drawing is included but
        currently only provides access to its XML element (CT_Drawing) on its
        `._drawing` attribute. `Drawing` attributes and methods may be expanded in
        future releases.

        There are a number of element-types that can appear inside a run, but most of
        those (w:br, w:cr, w:noBreakHyphen, w:t, w:tab) have a clear plain-text
        equivalent. Any contiguous range of such elements is generated as a single
        `str`. Rendered page-break and drawing elements are generated individually. Any
        other elements are ignored.
        N)r�inner_content_items�
isinstancerHrrrr)r �itemr#r#r$�iter_inner_content�s�

���zRun.iter_inner_contentrcCs|jj}tt|j�|tj��S)aaRead/write.

        A |CharacterStyle| object representing the character style applied to this run.
        The default character style for the document (often `Default Character Font`) is
        returned if the run has no directly-applied character style. Setting this
        property to |None| removes any directly-applied character style.
        )r�stylerrr?�	get_styler	�	CHARACTER)r �style_idr#r#r$rb�s	�z	Run.style�
style_or_name�str | CharacterStyle | NonecCs|j�|tj�}||j_dSr)r?�get_style_idr	rdrrb)r rfrer#r#r$rb�scCrN)a"String formed by concatenating the text equivalent of each run.

        Each `<w:t>` element adds the text characters it contains. A `<w:tab/>` element
        adds a `\t` character. A `<w:cr/>` or `<w:br>` element each add a `\n`
        character. Note that a `<w:br>` element can indicate a page break or column
        break as well as a line break. Only line-break `<w:br>` elements translate to
        a `\n` character. Others are ignored. All other content child elements, such as
        `<w:drawing>`, are ignored.

        Assigning text to this property has the reverse effect, translating each `\t`
        character to a `<w:tab/>` element and each `\n` or `\r` character to a
        `<w:cr/>` element. Any existing run content is replaced. Run formatting is
        preserved.
        �rrGrFr#r#r$rG�szRun.textcCrTrri)r rGr#r#r$rG�rV�bool | WD_UNDERLINE | NonecCrN)a�The underline style for this |Run|.

        Value is one of |None|, |True|, |False|, or a member of :ref:`WdUnderline`.

        A value of |None| indicates the run has no directly-applied underline value and
        so will inherit the underline value of its containing paragraph. Assigning
        |None| to this property removes any directly-applied underline value.

        A value of |False| indicates a directly-applied setting of no underline,
        overriding any inherited value.

        A value of |True| indicates single underline.

        The values from :ref:`WdUnderline` are used to specify other outline styles such
        as double, wavy, and dotted.
        �rP�	underlinerFr#r#r$rl�sz
Run.underlinecCrTrrkrUr#r#r$rl�rV)rrrr)r%r
r&)r9r:r;r<r=r<r>r
)r>rD)rGrH)r>rM)rSrM)r>rX)r>r)r>r])r>r)rfrg)r>rH)r>rj)rSrX)�__name__�
__module__�__qualname__�__doc__rr
r-r8rCrErL�propertyrQ�setterr5rZrPr\rarbrGrl�
__classcell__r#r#r!r$rsF�


		

rcs"eZdZdZd�fdd�Z�ZS)rJz&Proxy object wrapping `<w:t>` element.�t_elmrcstt|���||_dSr)rrJr�_t)r rtr!r#r$r�s
z_Text.__init__)rtr)rmrnrorprrsr#r#r!r$rJ�srJN)&rp�
__future__r�typingrrrr�docxrrK�docx.drawingr�docx.enum.styler	�docx.enum.textr
�docx.oxml.drawingr�docx.oxml.text.pagebreakr�
docx.shaper
�docx.sharedr�docx.styles.styler�docx.text.fontr�docx.text.pagebreakrr�docx.oxml.text.runrrrrrJr#r#r#r$�<module>s*\