
    hic(                     ^    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e          ZdS )zParagraph-related proxy types.    )WD_LINE_SPACING)ElementProxyEmuLengthPtTwipslazyproperty)TabStopsc                      e Zd ZdZed             Zej        d             Zed             Zej        d             Zed             Zej        d             Zed             Z	e	j        d	             Z	ed
             Z
e
j        d             Z
ed             Zej        d             Zed             Zej        d             Zed             Zej        d             Zed             Zej        d             Zed             Zej        d             Zed             Zej        d             Zed             Zed             Zej        d             Zed             Zed             ZdS )ParagraphFormatzProvides access to paragraph formatting such as justification, indentation, line
    spacing, space before and after, and widow/orphan control.c                 0    | j         j        }|dS |j        S )zA 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   s     h/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/docx/text/parfmt.py	alignmentzParagraphFormat.alignment   s      m;4z    c                 F    | j                                         }||_        d S N)r   get_or_add_pPrr   r   valuer   s      r   r   zParagraphFormat.alignment   s     m**,,


r   c                 0    | j         j        }|dS |j        S )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   s     r   r   z!ParagraphFormat.first_line_indent   s!     m;4$$r   c                 F    | j                                         }||_        d S r   )r   r   r   r   s      r   r   z!ParagraphFormat.first_line_indent,   s#    m**,, %r   c                 0    | j         j        }|dS |j        S )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   s     r   keep_togetherzParagraphFormat.keep_together1   s!     m;4  r   c                 B    || j                                         _        d S r   )r   r   r   r   r   s     r   r    zParagraphFormat.keep_together=       7<$$&&444r   c                 0    | j         j        }|dS |j        S )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   s     r   keep_with_nextzParagraphFormat.keep_with_nextA   s!     m;4r   c                 B    || j                                         _        d S r   )r   r   r%   r"   s     r   r&   zParagraphFormat.keep_with_nextO   s    6;$$&&333r   c                 0    | j         j        }|dS |j        S )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   s     r   left_indentzParagraphFormat.left_indentS   s      m;4|r   c                 F    | j                                         }||_        d S r   )r   r   r)   r   s      r   r*   zParagraphFormat.left_indenta   s     m**,,r   c                 b    | j         j        }|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   s     r   line_spacingzParagraphFormat.line_spacingf   s4     m;4!!#"2C4HIIIr   c                 R   | j                                         }|d |_        d |_        d S t	          |t
                    r1||_        |j        t          j        k    rt          j        |_        d S d S t          |t          d          z            |_        t          j        |_        d S )N   )r   r   r.   r/   
isinstancer   r   AT_LEASTEXACTLYr   r   MULTIPLEr   s      r   r0   zParagraphFormat.line_spacingw   s    m**,,=#C#'C   v&& 	<$C#'???'6'>$$$ @?  #55::#566C#2#;C   r   c                 b    | j         j        }|dS |                     |j        |j                  S )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   s     r   line_spacing_rulez!ParagraphFormat.line_spacing_rule   s4     m;4&&s'79MNNNr   c                    | j                                         }|t          j        k    r't	          d          |_        t          j        |_        d S |t          j        k    r't	          d          |_        t          j        |_        d S |t          j	        k    r't	          d          |_        t          j        |_        d S ||_        d S )Nr2   h    )
r   r   r   SINGLEr   r.   r6   r/   ONE_POINT_FIVEDOUBLEr   s      r   r9   z!ParagraphFormat.line_spacing_rule   s    m**,,O***$SzzC#2#;C   o444$SzzC#2#;C   o,,,$SzzC#2#;C   #(C   r   c                 0    | j         j        }|dS |j        S )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   s     r   page_break_beforez!ParagraphFormat.page_break_before   s!     m;4&&r   c                 B    || j                                         _        d S r   )r   r   rA   r"   s     r   rB   z!ParagraphFormat.page_break_before   s    =B$$&&:::r   c                 0    | j         j        }|dS |j        S )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   s     r   right_indentzParagraphFormat.right_indent   s      m;4}r   c                 F    | j                                         }||_        d S r   )r   r   rE   r   s      r   rF   zParagraphFormat.right_indent   s     m**,,r   c                 0    | j         j        }|dS |j        S )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   s     r   space_afterzParagraphFormat.space_after   s!     m;4  r   c                 B    || j                                         _        d S r   )r   r   rI   r"   s     r   rJ   zParagraphFormat.space_after   r#   r   c                 0    | j         j        }|dS |j        S )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   s     r   space_beforezParagraphFormat.space_before   s!     m;4!!r   c                 B    || j                                         _        d S r   )r   r   rM   r"   s     r   rN   zParagraphFormat.space_before   s    8=$$&&555r   c                 R    | j                                         }t          |          S )z^|TabStops| object providing access to the tab stops defined for this
        paragraph format.)r   r   r
   r   s     r   	tab_stopszParagraphFormat.tab_stops   s#     m**,,}}r   c                 0    | j         j        }|dS |j        S )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   s     r   widow_controlzParagraphFormat.widow_control   s!     m;4##r   c                 B    || j                                         _        d S r   )r   r   rS   r"   s     r   rT   zParagraphFormat.widow_control   s    :?$$&&777r   c                 R    | dS |t           j        k    r| t          d          z  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   r6   r   )r.   r/   s     r   r-   zParagraphFormat._line_spacing   s4     4777"R&&((r   c                     |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 )zReturn 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.
        r2   r;   r<   )r   r6   r   r=   r>   r?   )linelineRules     r   r8   z"ParagraphFormat._line_spacing_rule  se     ///uSzz!!&--uSzz!!&55uSzz!!&--r   N)__name__
__module____qualname____doc__propertyr   setterr   r    r&   r*   r0   r9   rB   rF   rJ   rN   r	   rQ   rT   staticmethodr-   r8    r   r   r   r      s5       B B 
 
 X
    % % X% & & & 	! 	! X	! = = =     X  < < <   X    J J XJ  < < < O O XO ) ) ) 	' 	' X	' C C C   X    ! ! X! = = = " " X" > > >   \ 	$ 	$ X	$ @ @ @   \   \  r   r   N)r^   docx.enum.textr   docx.sharedr   r   r   r   r   r	   docx.text.tabstopsr
   r   rb   r   r   <module>rf      s    $ $ * * * * * * J J J J J J J J J J J J J J J J ' ' ' ' ' 'V V V V Vl V V V V Vr   