o
    T}                     @   sX   d Z ddlmZmZmZmZ ddlmZ ddlm	Z	 G dd de	Z
G d	d
 d
e	ZdS )z
Latent style-related objects.
    )absolute_importdivisionprint_functionunicode_literals   )	BabelFish   )ElementProxyc                   @   s   e Zd ZdZdZdd Zdd Zdd Z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dS )LatentStylesz
    Provides access to the default behaviors for latent styles in this
    document and to the collection of |_LatentStyle| objects that define
    overrides of those defaults for a particular named latent style.
     c                 C   s2   t |}| j|}|du rtd| t|S )zL
        Enables dictionary-style access to a latent style by name.
        Nzno latent style with name '%s')r   ui2internal_elementZget_by_nameKeyError_LatentStyle)selfkeyZ
style_namelsdExceptionr   r   BD:\Projects\ConvertPro\env\Lib\site-packages\docx\styles\latent.py__getitem__   s
   
zLatentStyles.__getitem__c                 C   s   dd | j jD S )Nc                 s   s    | ]}t |V  qd S N)r   ).0Zlsr   r   r   	<genexpr>#   s    z(LatentStyles.__iter__.<locals>.<genexpr>)r   lsdException_lstr   r   r   r   __iter__"   s   zLatentStyles.__iter__c                 C   s   t | jjS r   )lenr   r   r   r   r   r   __len__%   s   zLatentStyles.__len__c                 C   s   | j  }t||_t|S )z
        Return a newly added |_LatentStyle| object to override the inherited
        defaults defined in this latent styles object for the built-in style
        having *name*.
        )r   Zadd_lsdExceptionr   r   namer   )r   r   r   r   r   r   add_latent_style(   s   
zLatentStyles.add_latent_stylec                 C      | j jS )z
        Integer between 0 and 99 inclusive specifying the default sort order
        for latent styles in style lists and the style gallery. |None| if no
        value is assigned, which causes Word to use the default value 99.
        r   ZdefUIPriorityr   r   r   r   default_priority2   s   zLatentStyles.default_priorityc                 C      || j _d S r   r    r   valuer   r   r   r!   ;      c                 C      | j dS )z
        Boolean specifying whether the default behavior for latent styles is
        to be hidden. A hidden style does not appear in the recommended list
        or in the style gallery.
        defSemiHiddenr   Z	bool_propr   r   r   r   default_to_hidden?      zLatentStyles.default_to_hiddenc                 C      | j d| d S )Nr'   r   Zset_bool_propr#   r   r   r   r)   H      c                 C   r&   )ag  
        Boolean specifying whether the default behavior for latent styles is
        to be locked. A locked style does not appear in the styles panel or
        the style gallery and cannot be applied to document content. This
        behavior is only active when formatting protection is turned on for
        the document (via the Developer menu).
        defLockedStater(   r   r   r   r   default_to_lockedL      	zLatentStyles.default_to_lockedc                 C   r+   )Nr.   r,   r#   r   r   r   r/   W   r-   c                 C   r&   )z
        Boolean specifying whether the default behavior for latent styles is
        to appear in the style gallery when not hidden.
        
defQFormatr(   r   r   r   r   default_to_quick_style[      z#LatentStyles.default_to_quick_stylec                 C   r+   )Nr1   r,   r#   r   r   r   r2   c   r-   c                 C   r&   )z
        Boolean specifying whether the default behavior for latent styles is
        to be unhidden when first applied to content.
        defUnhideWhenUsedr(   r   r   r   r   default_to_unhide_when_usedg   r3   z(LatentStyles.default_to_unhide_when_usedc                 C   r+   )Nr4   r,   r#   r   r   r   r5   o   r-   c                 C   r   )aK  
        Integer specifying the number of built-in styles to initialize to the
        defaults specified in this |LatentStyles| object. |None| if there is
        no setting in the XML (very uncommon). The default Word 2011 template
        sets this value to 276, accounting for the built-in styles in Word
        2010.
        r   countr   r   r   r   
load_counts   s   	zLatentStyles.load_countc                 C   r"   r   r6   r#   r   r   r   r8   ~   r%   N)__name__
__module____qualname____doc__	__slots__r   r   r   r   propertyr!   setterr)   r/   r2   r5   r8   r   r   r   r   r
      s>    














r
   c                   @   s   e Zd ZdZdZ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jdd Zedd Zejdd ZdS )r   a   
    Proxy for an `w:lsdException` element, which specifies display behaviors
    for a built-in style when no definition for that style is stored yet in
    the `styles.xml` part. The values in this element override the defaults
    specified in the parent `w:latentStyles` element.
    r   c                 C   s   | j   d| _ dS )a6  
        Remove this latent style definition such that the defaults defined in
        the containing |LatentStyles| object provide the effective value for
        each of its attributes. Attempting to access any attributes on this
        object after calling this method will raise |AttributeError|.
        N)r   deleter   r   r   r   r@      s   

z_LatentStyle.deletec                 C   r&   )z
        Tri-state value specifying whether this latent style should appear in
        the recommended list. |None| indicates the effective value is
        inherited from the parent ``<w:latentStyles>`` element.
        
semiHiddenr   Zon_off_propr   r   r   r   hidden   r*   z_LatentStyle.hiddenc                 C   r+   )NrA   r   Zset_on_off_propr#   r   r   r   rC      r-   c                 C   r&   )aU  
        Tri-state value specifying whether this latent styles is locked.
        A locked style does not appear in the styles panel or the style
        gallery and cannot be applied to document content. This behavior is
        only active when formatting protection is turned on for the document
        (via the Developer menu).
        lockedrB   r   r   r   r   rE      r0   z_LatentStyle.lockedc                 C   r+   )NrE   rD   r#   r   r   r   rE      r-   c                 C   s   t | jjS )zK
        The name of the built-in style this exception applies to.
        )r   Zinternal2uir   r   r   r   r   r   r      s   z_LatentStyle.namec                 C   r   )zL
        The integer sort key for this latent style in the Word UI.
        r   Z
uiPriorityr   r   r   r   priority   s   z_LatentStyle.priorityc                 C   r"   r   rF   r#   r   r   r   rG      r%   c                 C   r&   )a  
        Tri-state value specifying whether this latent style should appear in
        the Word styles gallery when not hidden. |None| indicates the
        effective value should be inherited from the default values in its
        parent |LatentStyles| object.
        qFormatrB   r   r   r   r   quick_style   s   z_LatentStyle.quick_stylec                 C   r+   )NrH   rD   r#   r   r   r   rI      r-   c                 C   r&   )a<  
        Tri-state value specifying whether this style should have its
        :attr:`hidden` attribute set |False| the next time the style is
        applied to content. |None| indicates the effective value should be
        inherited from the default specified by its parent |LatentStyles|
        object.
        unhideWhenUsedrB   r   r   r   r   unhide_when_used   r0   z_LatentStyle.unhide_when_usedc                 C   r+   )NrJ   rD   r#   r   r   r   rK      r-   N)r9   r:   r;   r<   r=   r@   r>   rC   r?   rE   r   rG   rI   rK   r   r   r   r   r      s4    









	


r   N)r<   Z
__future__r   r   r   r    r   sharedr	   r
   r   r   r   r   r   <module>   s   t