o
    ýÞhc(  ã                   @   sP   d Z ddlmZ ddlmZmZmZmZmZm	Z	 ddl
mZ G dd„ deƒZdS )zParagraph-related proxy types.é    )ÚWD_LINE_SPACING)ÚElementProxyÚEmuÚLengthÚPtÚTwipsÚlazyproperty)ÚTabStopsc                   @   sl  e Zd ZdZedd„ ƒZejdd„ ƒZedd„ ƒZejdd„ ƒZedd	„ ƒZejd
d	„ ƒZedd„ ƒZ	e	jdd„ ƒZ	edd„ ƒZ
e
jdd„ ƒZ
edd„ ƒZejdd„ ƒZedd„ ƒZejdd„ ƒZedd„ ƒZejdd„ ƒZedd„ ƒZejdd„ ƒZedd„ ƒZejdd„ ƒZed d!„ ƒZejd"d!„ ƒZed#d$„ ƒZed%d&„ ƒZejd'd&„ ƒZed(d)„ ƒZed*d+„ ƒZd,S )-ÚParagraphFormatz�Provides access to paragraph formatting such as justification, indentation, line
    spacing, space before and after, and widow/orphan control.c                 C   ó   | j j}|du r
dS |jS )zéA member of the :ref:`WdParagraphAlignment` enumeration specifying the
        justification setting for this paragraph.

        A value of |None| indicates paragraph alignment is inherited from the style
        hierarchy.
        N)Ú_elementÚpPrÚjc_val©Úselfr   © r   úP/var/www/html/premium_crap/venv/lib/python3.10/site-packages/docx/text/parfmt.pyÚ	alignment   s   zParagraphFormat.alignmentc                 C   ó   | j  ¡ }||_d S ©N)r   Úget_or_add_pPrr   ©r   Úvaluer   r   r   r   r      ó   

c                 C   r   )aA  |Length| value specifying the relative difference in indentation for the
        first line of the paragraph.

        A positive value causes the first line to be indented. A negative value produces
        a hanging indent. |None| indicates first line indentation is inherited from the
        style hierarchy.
        N)r   r   Úfirst_line_indentr   r   r   r   r      ó   	z!ParagraphFormat.first_line_indentc                 C   r   r   )r   r   r   r   r   r   r   r   ,   r   c                 C   r   )zà|True| if the paragraph should be kept "in one piece" and not broken across a
        page boundary when the document is rendered.

        |None| indicates its effective value is inherited from the style hierarchy.
        N)r   r   ÚkeepLines_valr   r   r   r   Úkeep_together1   ó   zParagraphFormat.keep_togetherc                 C   ó   || j  ¡ _d S r   )r   r   r   ©r   r   r   r   r   r   =   ó   c                 C   r   )aT  |True| if the paragraph should be kept on the same page as the subsequent
        paragraph when the document is rendered.

        For example, this property could be used to keep a section heading on the same
        page as its first paragraph. |None| indicates its effective value is inherited
        from the style hierarchy.
        N)r   r   ÚkeepNext_valr   r   r   r   Úkeep_with_nextA   r   zParagraphFormat.keep_with_nextc                 C   r   r   )r   r   r"   r    r   r   r   r#   O   r!   c                 C   r   )a1  |Length| value specifying the space between the left margin and the left side
        of the paragraph.

        |None| indicates the left indent value is inherited from the style hierarchy.
        Use an |Inches| value object as a convenient way to apply indentation in units
        of inches.
        N)r   r   Úind_leftr   r   r   r   Úleft_indentS   r   zParagraphFormat.left_indentc                 C   r   r   )r   r   r$   r   r   r   r   r%   a   r   c                 C   ó$   | j j}|du r
dS |  |j|j¡S )aB  |float| or |Length| value specifying the space between baselines in
        successive lines of the paragraph.

        A value of |None| indicates line spacing is inherited from the style hierarchy.
        A float value, e.g. ``2.0`` or ``1.75``, indicates spacing is applied in
        multiples of line heights. A |Length| value such as ``Pt(12)`` indicates spacing
        is a fixed height. The |Pt| value class is a convenient way to apply line
        spacing in units of points. Assigning |None| resets line spacing to inherit from
        the style hierarchy.
        N)r   r   Ú_line_spacingÚspacing_lineÚspacing_lineRuler   r   r   r   Úline_spacingf   s   zParagraphFormat.line_spacingc                 C   sl   | j  ¡ }|d u rd |_d |_d S t|tƒr'||_|jtjkr%tj|_d S d S t	|t
dƒ ƒ|_tj|_d S )Néð   )r   r   r(   r)   Ú
isinstancer   r   ÚAT_LEASTÚEXACTLYr   r   ÚMULTIPLEr   r   r   r   r*   w   s   


ÿc                 C   r&   )at  A member of the :ref:`WdLineSpacing` enumeration indicating how the value of
        :attr:`line_spacing` should be interpreted.

        Assigning any of the :ref:`WdLineSpacing` members :attr:`SINGLE`,
        :attr:`DOUBLE`, or :attr:`ONE_POINT_FIVE` will cause the value of
        :attr:`line_spacing` to be updated to produce the corresponding line spacing.
        N)r   r   Ú_line_spacing_ruler(   r)   r   r   r   r   Úline_spacing_rule…   s   	z!ParagraphFormat.line_spacing_rulec                 C   st   | j  ¡ }|tjkrtdƒ|_tj|_d S |tjkr%tdƒ|_tj|_d S |tj	kr5tdƒ|_tj|_d S ||_d S )Nr+   éh  éà  )
r   r   r   ÚSINGLEr   r(   r/   r)   ÚONE_POINT_FIVEÚDOUBLEr   r   r   r   r1   “   s   







c                 C   r   )zÁ|True| if the paragraph should appear at the top of the page following the
        prior paragraph.

        |None| indicates its effective value is inherited from the style hierarchy.
        N)r   r   ÚpageBreakBefore_valr   r   r   r   Úpage_break_before¢   r   z!ParagraphFormat.page_break_beforec                 C   r   r   )r   r   r7   r    r   r   r   r8   ®   r!   c                 C   r   )a4  |Length| value specifying the space between the right margin and the right
        side of the paragraph.

        |None| indicates the right indent value is inherited from the style hierarchy.
        Use a |Cm| value object as a convenient way to apply indentation in units of
        centimeters.
        N)r   r   Ú	ind_rightr   r   r   r   Úright_indent²   r   zParagraphFormat.right_indentc                 C   r   r   )r   r   r9   r   r   r   r   r:   À   r   c                 C   r   )ao  |Length| value specifying the spacing to appear between this paragraph and
        the subsequent paragraph.

        |None| indicates this value is inherited from the style hierarchy. |Length|
        objects provide convenience properties, such as :attr:`~.Length.pt` and
        :attr:`~.Length.inches`, that allow easy conversion to various length units.
        N)r   r   Úspacing_afterr   r   r   r   Úspace_afterÅ   r   zParagraphFormat.space_afterc                 C   r   r   )r   r   r;   r    r   r   r   r<   Ó   r!   c                 C   r   )af  |Length| value specifying the spacing to appear between this paragraph and
        the prior paragraph.

        |None| indicates this value is inherited from the style hierarchy. |Length|
        objects provide convenience properties, such as :attr:`~.Length.pt` and
        :attr:`~.Length.cm`, that allow easy conversion to various length units.
        N)r   r   Úspacing_beforer   r   r   r   Úspace_before×   r   zParagraphFormat.space_beforec                 C   r   r   )r   r   r=   r    r   r   r   r>   å   r!   c                 C   s   | j  ¡ }t|ƒS )z^|TabStops| object providing access to the tab stops defined for this
        paragraph format.)r   r   r	   r   r   r   r   Ú	tab_stopsé   s   
zParagraphFormat.tab_stopsc                 C   r   )zò|True| if the first and last lines in the paragraph remain on the same page
        as the rest of the paragraph when Word repaginates the document.

        |None| indicates its effective value is inherited from the style hierarchy.
        N)r   r   ÚwidowControl_valr   r   r   r   Úwidow_controlð   r   zParagraphFormat.widow_controlc                 C   r   r   )r   r   r@   r    r   r   r   rA   ü   r!   c                 C   s&   | du rdS |t jkr| tdƒ S | S )a[  Return the line spacing value calculated from the combination of
        `spacing_line` and `spacing_lineRule`.

        Returns a |float| number of lines when `spacing_lineRule` is
        ``WD_LINE_SPACING.MULTIPLE``, otherwise a |Length| object of absolute line
        height is returned. Returns |None| when `spacing_line` is |None|.
        Né   )r   r/   r   )r(   r)   r   r   r   r'      s
   	
zParagraphFormat._line_spacingc                 C   sD   |t jkr | tdƒkrt jS | tdƒkrt jS | tdƒkr t jS |S )zñReturn the line spacing rule value calculated from the combination of `line`
        and `lineRule`.

        Returns special members of the :ref:`WdLineSpacing` enumeration when line
        spacing is single, double, or 1.5 lines.
        r+   r2   r3   )r   r/   r   r4   r5   r6   )ÚlineÚlineRuler   r   r   r0     s   
z"ParagraphFormat._line_spacing_ruleN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr   Úsetterr   r   r#   r%   r*   r1   r8   r:   r<   r>   r   r?   rA   Ústaticmethodr'   r0   r   r   r   r   r
      sp    

























r
   N)rH   Údocx.enum.textr   Údocx.sharedr   r   r   r   r   r   Údocx.text.tabstopsr	   r
   r   r   r   r   Ú<module>   s
     