o
    j6[W                     @   s\   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
 G dd deZG dd	 d	eZd
S )z
Tabstop-related proxy types.
    )absolute_importdivisionprint_functionunicode_literals   )ElementProxy)WD_TAB_ALIGNMENTWD_TAB_LEADERc                       s^   e Zd ZdZdZ fddZdd Zdd Zd	d
 Zdd Z	e
jejfddZdd Z  ZS )TabStopsa:  
    A sequence of |TabStop| objects providing access to the tab stops of
    a paragraph or paragraph style. Supports iteration, indexed access, del,
    and len(). It is accesed using the :attr:`~.ParagraphFormat.tab_stops`
    property of ParagraphFormat; it is not intended to be constructed
    directly.
    _pPrc                       t t| |d  || _d S N)superr
   __init__r   selfelement	__class__ BD:\Projects\ConvertPro\env\Lib\site-packages\docx\text\tabstops.pyr         
zTabStops.__init__c              	   C   sV   | j j}z	|||  W n ttfy   tdw t|dkr)| j | dS dS )zB
        Remove the tab at offset *idx* in this sequence.
        ztab index out of ranger   N)r   tabsremoveAttributeError
IndexErrorlen)r   idxr   r   r   r   __delitem__   s   zTabStops.__delitem__c                 C   s*   | j j}|du rtd|j| }t|S )z5
        Enables list-style access by index.
        NzTabStops object is empty)r   r   r   tab_lstTabStop)r   r   r   tabr   r   r   __getitem__+   s
   
zTabStops.__getitem__c                 c   s0    | j j}|dur|jD ]	}t|V  qdS dS )zj
        Generate a TabStop object for each of the w:tab elements, in XML
        document order.
        N)r   r   r   r    )r   r   r!   r   r   r   __iter__5   s   
zTabStops.__iter__c                 C   s   | j j}|d u r
dS t|jS )Nr   )r   r   r   r   )r   r   r   r   r   __len__?   s   
zTabStops.__len__c                 C   s    | j  }||||}t|S )a  
        Add a new tab stop at *position*, a |Length| object specifying the
        location of the tab stop relative to the paragraph edge. A negative
        *position* value is valid and appears in hanging indentation. Tab
        alignment defaults to left, but may be specified by passing a member
        of the :ref:`WdTabAlignment` enumeration as *alignment*. An optional
        leader character can be specified by passing a member of the
        :ref:`WdTabLeader` enumeration as *leader*.
        )r   Zget_or_add_tabsinsert_tab_in_orderr    )r   position	alignmentleaderr   r!   r   r   r   add_tab_stopE   s   
zTabStops.add_tab_stopc                 C   s   | j   dS )z.
        Remove all custom tab stops.
        N)r   Z_remove_tabsr   r   r   r   	clear_allT   s   zTabStops.clear_all)__name__
__module____qualname____doc__	__slots__r   r   r"   r#   r$   r   LEFTr	   ZSPACESr)   r+   __classcell__r   r   r   r   r
      s    


r
   c                       sr   e Zd ZdZdZ f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
  ZS )r    z
    An individual tab stop applying to a paragraph or style. Accessed using
    list semantics on its containing |TabStops| object.
    _tabc                    r   r   )r   r    r   r3   r   r   r   r   r   c   r   zTabStop.__init__c                 C      | j jS )z{
        A member of :ref:`WdTabAlignment` specifying the alignment setting
        for this tab stop. Read/write.
        r3   valr*   r   r   r   r'   g   s   zTabStop.alignmentc                 C      || j _d S r   r5   r   valuer   r   r   r'   o      c                 C   r4   )a  
        A member of :ref:`WdTabLeader` specifying a repeating character used
        as a "leader", filling in the space spanned by this tab. Assigning
        |None| produces the same result as assigning `WD_TAB_LEADER.SPACES`.
        Read/write.
        r3   r(   r*   r   r   r   r(   s   s   zTabStop.leaderc                 C   r7   r   r;   r8   r   r   r   r(   }   r:   c                 C   r4   )z
        A |Length| object representing the distance of this tab stop from the
        inside edge of the paragraph. May be positive or negative.
        Read/write.
        )r3   posr*   r   r   r   r&      s   zTabStop.positionc                 C   s0   | j }| }|||j|j| _ || d S r   )r3   Z	getparentr%   r6   r(   r   )r   r9   r!   r   r   r   r   r&      s   )r,   r-   r.   r/   r0   r   propertyr'   setterr(   r&   r2   r   r   r   r   r    [   s     


	

r    N)r/   Z
__future__r   r   r   r   sharedr   Zdocx.enum.textr   r	   r
   r    r   r   r   r   <module>   s   L