B
    j6[)                 @   sh   d Z ddlmZmZmZm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.
    )absolute_importdivisionprint_functionunicode_literals   )WD_LINE_SPACING)ElementProxyEmulazypropertyLengthPtTwips   )TabStopsc               @   sp  e Zd 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.
    )Z
_tab_stopsc             C   s   | j j}|dk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   B/var/www/html/venv/lib/python3.7/site-packages/docx/text/parfmt.py	alignment   s    zParagraphFormat.alignmentc             C   s   | j  }||_d S )N)r   get_or_add_pPrr   )r   valuer   r   r   r   r   %   s    
c             C   s   | j j}|dkrdS |jS )aI  
        |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_indent)r   r   r   r   r   r   *   s    	z!ParagraphFormat.first_line_indentc             C   s   | j  }||_d S )N)r   r   r   )r   r   r   r   r   r   r   8   s    
c             C   s   | j j}|dkr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_val)r   r   r   r   r   keep_together=   s    zParagraphFormat.keep_togetherc             C   s   || j  _d S )N)r   r   r   )r   r   r   r   r   r   I   s    c             C   s   | j j}|dkrdS |jS )a\  
        |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_val)r   r   r   r   r   keep_with_nextM   s    	zParagraphFormat.keep_with_nextc             C   s   || j  _d S )N)r   r   r   )r   r   r   r   r   r   [   s    c             C   s   | j j}|dkr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_left)r   r   r   r   r   left_indent_   s    zParagraphFormat.left_indentc             C   s   | j  }||_d S )N)r   r   r   )r   r   r   r   r   r   r    l   s    
c             C   s$   | j j}|dkrdS | |j|jS )aJ  
        |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_lineRule)r   r   r   r   r   line_spacingq   s    zParagraphFormat.line_spacingc             C   sd   | j  }|d kr d |_d |_n@t|trF||_|jtjkr`tj|_nt	|t
d |_tj|_d S )N   )r   r   r"   r#   
isinstancer   r   ZAT_LEASTZEXACTLYr	   r   MULTIPLE)r   r   r   r   r   r   r$      s    


c             C   s$   | j j}|dkrdS | |j|jS )a|  
        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   r   line_spacing_rule   s
    	z!ParagraphFormat.line_spacing_rulec             C   sn   | j  }|tjkr(td|_tj|_nB|tjkrFtd|_tj|_n$|tj	krdtd|_tj|_n||_d S )Nr%   ih  i  )
r   r   r   SINGLEr   r"   r'   r#   ONE_POINT_FIVEDOUBLE)r   r   r   r   r   r   r)      s    









c             C   s   | j j}|dkr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_val)r   r   r   r   r   page_break_before   s    z!ParagraphFormat.page_break_beforec             C   s   || j  _d S )N)r   r   r-   )r   r   r   r   r   r.      s    c             C   s   | j j}|dkr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_right)r   r   r   r   r   right_indent   s    zParagraphFormat.right_indentc             C   s   | j  }||_d S )N)r   r   r/   )r   r   r   r   r   r   r0      s    
c             C   s   | j j}|dkrdS |jS )a  
        |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_after)r   r   r   r   r   space_after   s    
zParagraphFormat.space_afterc             C   s   || j  _d S )N)r   r   r1   )r   r   r   r   r   r2      s    c             C   s   | j j}|dkrdS |jS )av  
        |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_before)r   r   r   r   r   space_before   s    
zParagraphFormat.space_beforec             C   s   || j  _d S )N)r   r   r3   )r   r   r   r   r   r4      s    c             C   s   | j  }t|S )zp
        |TabStops| object providing access to the tab stops defined for this
        paragraph format.
        )r   r   r   )r   r   r   r   r   	tab_stops   s    
zParagraphFormat.tab_stopsc             C   s   | j j}|dkrdS |jS )a  
        |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_val)r   r   r   r   r   widow_control   s    zParagraphFormat.widow_controlc             C   s   || j  _d S )N)r   r   r6   )r   r   r   r   r   r7     s    c             C   s&   | dkrdS |t jkr"| td S | S )ac  
        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%   ih  i  )r   r'   r   r*   r+   r,   )lineZlineRuler   r   r   r(      s    
z"ParagraphFormat._line_spacing_ruleN)__name__
__module____qualname____doc__	__slots__propertyr   setterr   r   r   r    r$   r)   r.   r0   r2   r4   r
   r5   r7   staticmethodr!   r(   r   r   r   r   r      s:   	r   N)r=   
__future__r   r   r   r   Z	enum.textr   sharedr   r	   r
   r   r   r   Ztabstopsr   r   r   r   r   r   <module>   s
    