o
    `T3                     @   s   d Z ddlmZmZmZmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ dd	lmZ d
d ZG dd deZG dd deZG dd deZG dd deZG dd deZdS )z
Style object hierarchy.
    )absolute_importdivisionprint_functionunicode_literals   )	BabelFish   )WD_STYLE_TYPE)ElementProxy)Font)ParagraphFormatc                 C   s*   t jtt jtt jtt jti| j	 }|| S )zr
    Return a style object of the appropriate |BaseStyle| subclass, according
    to the type of *style_elm*.
    )
r	   	PARAGRAPH_ParagraphStyleZ	CHARACTER_CharacterStyleZTABLE_TableStyleZLIST_NumberingStyletype)Z	style_elmZ	style_cls r   AD:\Projects\ConvertPro\env\Lib\site-packages\docx\styles\style.pyStyleFactory   s   r   c                   @   s   e Zd ZdZdZe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edd Zedd Zej	dd ZdS )	BaseStylez
    Base class for the various types of style object, paragraph, character,
    table, and numbering. These properties and methods are inherited by all
    style objects.
    r   c                 C   s
   | j j S )a&  
        Read-only. |True| if this style is a built-in style. |False|
        indicates it is a custom (user-defined) style. Note this value is
        based on the presence of a `customStyle` attribute in the XML, not on
        specific knowledge of which styles are built into Word.
        )_elementZcustomStyleselfr   r   r   builtin*   s   
zBaseStyle.builtinc                 C   s   | j   d| _ dS )aQ  
        Remove this style definition from the document. Note that calling
        this method does not remove or change the style applied to any
        document content. Content items having the deleted style will be
        rendered using the default style, as is any content with a style not
        defined in the document.
        N)r   deleter   r   r   r   r   4   s   

zBaseStyle.deletec                 C      | j jS )a  
        |True| if display of this style in the style gallery and list of
        recommended styles is suppressed. |False| otherwise. In order to be
        shown in the style gallery, this value must be |False| and
        :attr:`.quick_style` must be |True|.
        r   ZsemiHidden_valr   r   r   r   hidden?      zBaseStyle.hiddenc                 C      || j _d S Nr   r   valuer   r   r   r   I      c                 C   r   )aH  
        Read/write Boolean. |True| if this style 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).
        r   Z
locked_valr   r   r   r   lockedM   s   	zBaseStyle.lockedc                 C   r    r!   r%   r"   r   r   r   r&   X   r$   c                 C   s   | j j}|du r
dS t|S )z,
        The UI name of this style.
        N)r   name_valr   Zinternal2ui)r   namer   r   r   r(   \   s   
zBaseStyle.namec                 C   r    r!   )r   r'   r"   r   r   r   r(   f   r$   c                 C   r   )a4  
        The integer sort key governing display sequence of this style in the
        Word UI. |None| indicates no setting is defined, causing Word to use
        the default value of 0. Style name is used as a secondary sort key to
        resolve ordering of styles having the same priority value.
        r   ZuiPriority_valr   r   r   r   priorityj   r   zBaseStyle.priorityc                 C   r    r!   r)   r"   r   r   r   r*   t   r$   c                 C   r   )z
        |True| if this style should be displayed in the style gallery when
        :attr:`.hidden` is |False|. Read/write Boolean.
        r   ZqFormat_valr   r   r   r   quick_stylex   s   zBaseStyle.quick_stylec                 C   r    r!   r+   r"   r   r   r   r,      r$   c                 C   r   )z
        The unique key name (string) for this style. This value is subject to
        rewriting by Word and should generally not be changed unless you are
        familiar with the internals involved.
        r   ZstyleIdr   r   r   r   style_id   s   zBaseStyle.style_idc                 C   r    r!   r-   r"   r   r   r   r.      r$   c                 C   s   | j j}|du rtjS |S )z
        Member of :ref:`WdStyleType` corresponding to the type of this style,
        e.g. ``WD_STYLE_TYPE.PARAGRAPH``.
        N)r   r   r	   r   )r   r   r   r   r   r      s   zBaseStyle.typec                 C   r   )a  
        |True| if an application should make this style visible the next time
        it is applied to content. False otherwise. Note that |docx| does not
        automatically unhide a style having |True| for this attribute when it
        is applied to content.
        r   ZunhideWhenUsed_valr   r   r   r   unhide_when_used   r   zBaseStyle.unhide_when_usedc                 C   r    r!   r/   r"   r   r   r   r0      r$   N)__name__
__module____qualname____doc__	__slots__propertyr   r   r   setterr&   r(   r*   r,   r.   r   r0   r   r   r   r   r   !   sH    
	
	



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

	r   c                   @   s:   e Zd ZdZdZedd Zejdd Zedd ZdS )	r   z
    A character style. A character style is applied to a |Run| object and
    primarily provides character-level formatting via the |Font| object in
    its :attr:`.font` property.
    r   c                 C   s   | j j}|du r
dS t|S )zv
        Style object this style inherits from or |None| if this style is
        not based on another style.
        N)r   
base_styler   )r   r8   r   r   r   r8      s   z_CharacterStyle.base_stylec                 C   s   |d ur|j nd }|| j_d S r!   )r.   r   ZbasedOn_val)r   styler.   r   r   r   r8      s   c                 C   
   t | jS )z
        The |Font| object providing access to the character formatting
        properties for this style, such as font name and size.
        )r   r   r   r   r   r   font      
z_CharacterStyle.fontN)	r1   r2   r3   r4   r5   r6   r8   r7   r;   r   r   r   r   r      s    


r   c                   @   sB   e Zd ZdZdZdd Zedd Zejdd Zedd	 Z	d
S )r   z
    A paragraph style. A paragraph style provides both character formatting
    and paragraph formatting such as indentation and line-spacing.
    r   c                 C      d| j t| f S )Nz_ParagraphStyle('%s') id: %sr(   idr   r   r   r   __repr__      z_ParagraphStyle.__repr__c                 C   s,   | j j}|du r
| S |jtjkr| S t|S )aY  
        |_ParagraphStyle| object representing the style to be applied
        automatically to a new paragraph inserted after a paragraph of this
        style. Returns self if no next paragraph style is defined. Assigning
        |None| or *self* removes the setting such that new paragraphs are
        created using this same style.
        N)r   Z
next_styler   r	   r   r   )r   Znext_style_elmr   r   r   next_paragraph_style   s   	z$_ParagraphStyle.next_paragraph_stylec                 C   s4   |d u s
|j | j kr| j  d S |j | j _d S r!   )r.   r   Z_remove_nextZget_or_add_nextval)r   r9   r   r   r   rB      s   c                 C   r:   )z
        The |ParagraphFormat| object providing access to the paragraph
        formatting properties for this style such as indentation.
        )r   r   r   r   r   r   paragraph_format   r<   z _ParagraphStyle.paragraph_formatN)
r1   r2   r3   r4   r5   r@   r6   rB   r7   rD   r   r   r   r   r      s    

r   c                   @   s   e Zd ZdZdZdd ZdS )r   z
    A table style. A table style provides character and paragraph formatting
    for its contents as well as special table formatting properties.
    r   c                 C   r=   )Nz_TableStyle('%s') id: %sr>   r   r   r   r   r@      rA   z_TableStyle.__repr__N)r1   r2   r3   r4   r5   r@   r   r   r   r   r      s    r   c                   @   s   e Zd ZdZdZdS )r   z1
    A numbering style. Not yet implemented.
    r   N)r1   r2   r3   r4   r5   r   r   r   r   r     s    r   N)r4   Z
__future__r   r   r   r    r   Z
enum.styler	   sharedr
   Z	text.fontr   Ztext.parfmtr   r   r   r   r   r   r   r   r   r   r   <module>   s    "+