o
    ýÞh8  ã                   @   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                    ó   t t| ƒ |d ¡ || _d S ©N)Úsuperr   Ú__init__Ú_pPr©ÚselfÚelement©Ú	__class__© úR/var/www/html/premium_crap/venv/lib/python3.10/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 )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   s0   � | j j}|dur|jD ]	}t|ƒV  qdS 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
   Ú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
   Ú_remove_tabs©r   r   r   r   Ú	clear_allC   s   zTabStops.clear_all)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   r   r   r   r   ÚLEFTr   Ú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                    r   r   )r   r   r	   Ú_tabr   r   r   r   r	   N   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.
        ©r0   Úvalr'   r   r   r   r#   R   ó   zTabStop.alignmentc                 C   ó   || j _d S r   r2   ©r   Úvaluer   r   r   r#   [   ó   c                 C   r1   )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.
        ©r0   r$   r'   r   r   r   r$   _   s   zTabStop.leaderc                 C   r5   r   r9   r6   r   r   r   r$   i   r8   c                 C   r1   )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.
        )r0   Úposr'   r   r   r   r"   m   r4   zTabStop.positionc                 C   s0   | j }| ¡ }| ||j|j¡| _ | |¡ d S r   )r0   Ú	getparentr!   r3   r$   r   )r   r7   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,   Údocx.enum.textr   r   Údocx.sharedr   r   r   r   r   r   r   Ú<module>   s
    A