a
    ]øj8  ã                   @   sD   d Z ddlmZmZ ddlmZ G dd„ deƒZG dd„ deƒZdS )	zTabstop-related proxy types.é    )ÚWD_TAB_ALIGNMENTÚWD_TAB_LEADER)ÚElementProxyc                       sZ   e 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 )ÚTabStopsa6  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.
    c                    s   t t| ƒ |d ¡ || _d S ©N)Úsuperr   Ú__init__Ú_pPr©ÚselfÚelement©Ú	__class__© úN/var/www/html/assistant/venv/lib/python3.9/site-packages/docx/text/tabstops.pyr      s    zTabStops.__init__c              	   C   sV   | j j}z| || ¡ W n ttfy8   tdƒ‚Y n0 t|ƒdkrR| j  |¡ dS )z0Remove 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 )z#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   s*   | j j}|dur&|jD ]}t|ƒV  qdS )zXGenerate 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__'   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_stop5   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_allC   s    zTabStops.clear_all)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   ZLEFTr   ZSPACESr"   r$   Ú__classcell__r   r   r   r   r      s   r   c                       sn   e 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.
    c                    s   t t| ƒ |d ¡ || _d S r   )r   r   r   Ú_tabr
   r   r   r   r   N   s    zTabStop.__init__c                 C   s   | j jS )z{A member of :ref:`WdTabAlignment` specifying the alignment setting for this
        tab stop.

        Read/write.
        ©r*   Úvalr#   r   r   r   r    R   s    zTabStop.alignmentc                 C   s   || j _d S r   r+   ©r   Úvaluer   r   r   r    [   s    c                 C   s   | j jS )zú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.
        ©r*   r!   r#   r   r   r   r!   _   s    zTabStop.leaderc                 C   s   || j _d S r   r/   r-   r   r   r   r!   i   s    c                 C   s   | j jS )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.
        )r*   Úposr#   r   r   r   r   m   s    zTabStop.positionc                 C   s0   | j }| ¡ }| ||j|j¡| _ | |¡ d S r   )r*   Z	getparentr   r,   r!   r   )r   r.   r   r   r   r   r   r   v   s    )r%   r&   r'   r(   r   Úpropertyr    Úsetterr!   r   r)   r   r   r   r   r   H   s   


	

r   N)r(   Zdocx.enum.textr   r   Zdocx.sharedr   r   r   r   r   r   r   Ú<module>   s   A