o
    	'fF                     @   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__ J/home/ubuntu/flask/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_allE   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   zAn 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	   P   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#   T      zTabStop.alignmentc                 C      || j _d S r   r2   r   valuer   r   r   r#   ]      c                 C   r1   )zA 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$   a   s   zTabStop.leaderc                 C   r5   r   r9   r6   r   r   r   r$   k   r8   c                 C   r1   )zA |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"   o   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"   x   s   )r)   r*   r+   r,   r	   propertyr#   setterr$   r"   r/   r   r   r   r   r   J   s    


	

r   N)r,   docx.enum.textr   r   docx.sharedr   r   r   r   r   r   r   <module>   s
    C