o
    ãŽj8O  ã                   @  sÌ  d Z ddlmZ ddlZddlmZmZmZ ddlm	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mZmZmZmZmZmZmZm Z  ddl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z* ddl+m,Z,m-Z- er|ddl.m/Z/ G dd„ de"ƒZ0G dd„ de"ƒZ1G dd„ de"ƒZ2G dd„ de"ƒZ3G dd„ de"ƒZ4G dd„ de"ƒZ5G dd„ de"ƒZ6G dd„ de"ƒZ7G dd „ d e"ƒZ8G d!d"„ d"e"ƒZ9G d#d$„ d$e"ƒZ:G d%d&„ d&e"ƒZ;G d'd(„ d(e"ƒZ<dS ))z4Custom element classes for text-related XML elementsé    )ÚannotationsN)ÚTYPE_CHECKINGÚCallableÚcast)ÚMSO_LANGUAGE_ID)ÚMSO_AUTO_SIZEÚMSO_TEXT_UNDERLINE_TYPEÚMSO_VERTICAL_ANCHORÚPP_PARAGRAPH_ALIGNMENT)ÚInvalidXmlError)Ú	parse_xml)ÚCT_GradientFillProperties©Únsdecls)	ÚST_Coordinate32Ú&ST_TextFontScalePercentOrPercentStringÚST_TextFontSizeÚST_TextIndentLevelTypeÚ$ST_TextSpacingPercentOrPercentStringÚST_TextSpacingPointÚST_TextTypefaceÚST_TextWrappingTypeÚ
XsdBoolean)	ÚBaseOxmlElementÚChoiceÚOneAndOnlyOneÚ	OneOrMoreÚOptionalAttributeÚRequiredAttributeÚ
ZeroOrMoreÚ	ZeroOrOneÚZeroOrOneChoice)ÚEmuÚLength)ÚCT_Hyperlinkc                   @  sj   e Zd ZU dZded< edddZded< ed	ƒZd
ed< e	ddd„ƒZ
e
jddd„ƒZ
eddd„ƒZdS )ÚCT_RegularTextRunz`a:r` custom element classú(Callable[[], CT_TextCharacterProperties]Úget_or_add_rPrúa:rPr)úa:t©Ú
successorsú!CT_TextCharacterProperties | NoneÚrPrr)   r   ÚtÚreturnÚstrc                 C  s   | j j}|pdS )z#All text of (required) `a:t` child.Ú ©r.   Útext)Úselfr3   © r5   úN/home/air/Certificate/back/venv/lib/python3.10/site-packages/pptx/oxml/text.pyr3   9   s   zCT_RegularTextRun.textÚvaluec                 C  s   |   |¡| j_d S ©N)Ú_escape_ctrl_charsr.   r3   ©r4   r7   r5   r5   r6   r3   @   s   Úsc                 C  s   t  ddd„ | ¡S )a  Return str after replacing each control character with a plain-text escape.

        For example, a BEL character (x07) would appear as "_x0007_". Horizontal-tab
        (x09) and line-feed (x0A) are not escaped. All other characters in the range
        x00-x1F are escaped.
        z([\x00-\x08\x0B-\x1F])c                 S  s   dt |  d¡ƒ S )Nz_x%04X_é   )ÚordÚgroup)Úmatchr5   r5   r6   Ú<lambda>L   ó    z6CT_RegularTextRun._escape_ctrl_chars.<locals>.<lambda>)ÚreÚsub)r;   r5   r5   r6   r9   D   s   z$CT_RegularTextRun._escape_ctrl_charsN©r/   r0   )r7   r0   )r;   r0   r/   r0   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r    r-   r   r.   Úpropertyr3   ÚsetterÚstaticmethodr9   r5   r5   r5   r6   r%   /   s   
 ÿr%   c                   @  sÄ   e Zd ZU dZded< ded< edƒZded< ed	ƒZd
ed< dd„ Z	e
d&dd„ƒZe
d'dd„ƒZedd„ ƒZed(dd„ƒZedd„ ƒZedd„ ƒZdd„ Zedd „ ƒZed!d"„ ƒZed#d$„ ƒZd%S ))ÚCT_TextBodyzg`p:txBody` custom element class.

    Also used for `c:txPr` in charts and perhaps other elements.
    zCallable[[], CT_TextParagraph]Úadd_pzlist[CT_TextParagraph]Úp_lstza:bodyPrÚCT_TextBodyPropertiesÚbodyPrza:pÚCT_TextParagraphÚpc                 C  s   | j D ]}|  |¡ qdS )zRemove all `a:p` children, but leave any others.

        cf. lxml `_Element.clear()` method which removes all children.
        N)rO   Úremove)r4   rS   r5   r5   r6   Úclear_content]   s   
ÿzCT_TextBody.clear_contentr/   ÚCT_TextCharacterPropertiesc                 C  s   | j d }| ¡ }| ¡ }|S )zä`a:defRPr` element of required first `p` child, added with its ancestors if not present.

        Used when element is a ``c:txPr`` in a chart and the `p` element is used only to specify
        formatting, not content.
        r   )rO   Úget_or_add_pPrÚget_or_add_defRPr)r4   rS   ÚpPrÚdefRPrr5   r5   r6   rZ   e   s   
zCT_TextBody.defRPrÚboolc                 C  s8   | j }t|ƒdkrdS |stdƒ‚|d jdkrdS dS )z5True if only a single empty `a:p` element is present.r<   Fz#p:txBody must have at least one a:pr   r1   T)rO   Úlenr   r3   )r4   Úpsr5   r5   r6   Úis_emptyq   s   zCT_TextBody.is_emptyc                 C  s   |   ¡ }t|ƒ}|S )z%Return a new `p:txBody` element tree.)Ú_txBody_tmplr   ©ÚclsÚxmlÚtxBodyr5   r5   r6   Únew   s   zCT_TextBody.newc                 C  s   |   ¡ }ttt|ƒƒ}|S )zwReturn a new `a:txBody` element tree.

        Suitable for use in a table cell and possibly other situations.
        )Ú_a_txBody_tmplr   rM   r   r`   r5   r5   r6   Únew_a_txBody†   s   zCT_TextBody.new_a_txBodyc                 C  s   |   ¡ }t|ƒS )zLReturn a new `p:txBody` element tree, suitable for use in an `p:sp` element.)Ú_p_txBody_tmplr   )ra   rb   r5   r5   r6   Únew_p_txBody   s   zCT_TextBody.new_p_txBodyc                 C  s   dt ddƒ }t|ƒ}|S )zuReturn a `c:txPr` element tree.

        Suitable for use in a chart object like data labels or tick labels.
        zp<c:txPr %s>
  <a:bodyPr/>
  <a:lstStyle/>
  <a:p>
    <a:pPr>
      <a:defRPr/>
    </a:pPr>
  </a:p>
</c:txPr>
ÚcÚa©r   r   )ra   rb   ÚtxPrr5   r5   r6   Únew_txPr–   s
   	özCT_TextBody.new_txPrc                 C  s   t | jƒdkr	dS |  ¡  dS )z´Ensure p:txBody has at least one a:p child.

        Intuitively, reverse a ".clear_content()" operation to minimum conformance with spec
        (single empty paragraph).
        r   N)r\   rO   rN   ©r4   r5   r5   r6   Úunclear_contentª   s   zCT_TextBody.unclear_contentc                 C  s   dt dƒ S )Nz1<a:txBody %s>
  <a:bodyPr/>
  <a:p/>
</a:txBody>
rj   r   ©ra   r5   r5   r6   re   ´   s   zCT_TextBody._a_txBody_tmplc                 C  ó   dt ddƒ S )Nz1<p:txBody %s>
  <a:bodyPr/>
  <a:p/>
</p:txBody>
rS   rj   r   rp   r5   r5   r6   rg   ¸   s   ÿzCT_TextBody._p_txBody_tmplc                 C  rq   )NzA<p:txBody %s>
  <a:bodyPr/>
  <a:lstStyle/>
  <a:p/>
</p:txBody>
rj   rS   r   rp   r5   r5   r6   r_   ¾   s   üÿzCT_TextBody._txBody_tmplN)r/   rV   )r/   r[   )r/   rM   )rE   rF   rG   rH   rI   r   rQ   r   rS   rU   rJ   rZ   r^   Úclassmethodrd   rf   rh   rm   ro   re   rg   r_   r5   r5   r5   r6   rM   O   s8   
 ÿ
	




rM   c                   @  s  e Zd ZU dZded< ded< ded< ded< d	ed
< ded< d	ed< eedƒedƒedƒfddZede	e
dƒdZded< ede	e
dƒdZded< ede	e
dƒdZded< ede	e
dƒdZded< edeƒZded< edeƒZded< edd „ ƒZejd%d#d „ƒZd$S )&rP   z `a:bodyPr` custom element class.zCallable[[], BaseOxmlElement]Ú_add_noAutofitz"Callable[[], CT_TextNormalAutofit]Ú_add_normAutofitÚ_add_spAutoFitúCallable[[], None]Ú_remove_eg_textAutoFitúBaseOxmlElement | NoneÚ	noAutofitzCT_TextNormalAutofit | NoneÚnormAutofitÚ	spAutoFitza:noAutofitza:normAutofitza:spAutoFit)z	a:scene3dza:sp3dza:flatTxúa:extLstr*   ÚlInsi0e ©Údefaultr#   ÚtInsi˜²  ÚrInsÚbInsÚanchorzMSO_VERTICAL_ANCHOR | NoneÚwrapú
str | Nonec                 C  s4   | j durtjS | jdurtjS | jdurtjS dS )zTThe autofit setting for the text frame, a member of the `MSO_AUTO_SIZE` enumeration.N)ry   r   ÚNONErz   ÚTEXT_TO_FIT_SHAPEr{   ÚSHAPE_TO_FIT_TEXTrn   r5   r5   r6   Úautofitì   s   


zCT_TextBodyProperties.autofitr7   úMSO_AUTO_SIZE | Nonec                 C  sl   |d ur|t vrtd|› ƒ‚|  ¡  |t jkr|  ¡  d S |t jkr)|  ¡  d S |t jkr4|  ¡  d S d S )Nzmonly None or a member of the MSO_AUTO_SIZE enumeration can be assigned to CT_TextBodyProperties.autofit, got )	r   Ú
ValueErrorrw   r†   rs   r‡   rt   rˆ   ru   r:   r5   r5   r6   r‰   ÷   s   ÿÿ


ÿN)r7   rŠ   )rE   rF   rG   rH   rI   r!   r   Úeg_textAutoFitr   r   r"   r}   r€   r   r‚   r	   rƒ   r   r„   rJ   r‰   rK   r5   r5   r5   r6   rP   É   sF   
 þ
ÿ
ÿ
ÿ
ÿÿÿ

rP   c                   @  sö   e Zd ZU dZded< ded< ded< ded< eed	ƒed
ƒedƒedƒedƒedƒfddZedddZ	ded< edddZ
ded< edeƒZded< edeƒZded< edeƒZded< edeƒZded< ed eƒZd!ed < d"d#„ Zd+d(d)„Zd*S ),rV   zžCustom element class for `a:rPr`, `a:defRPr`, and `a:endParaRPr`.

    'rPr' is short for 'run properties', and it corresponds to the |Font| proxy class.
    zCallable[[], CT_Hyperlink]Úget_or_add_hlinkClickzCallable[[], CT_TextFont]Úget_or_add_latinrv   Ú_remove_latinÚ_remove_hlinkClickza:noFillza:solidFillz
a:gradFillz
a:blipFillz
a:pattFillz	a:grpFill)za:effectLstza:effectDagza:highlightza:uLnTxza:uLnz	a:uFillTxza:uFillúa:latinúa:eaúa:csúa:symúa:hlinkClickúa:hlinkMouseOverúa:rtlr|   r*   r‘   )r’   r“   r”   r•   r–   r—   r|   zCT_TextFont | NoneÚlatinr•   )r–   r—   r|   zCT_Hyperlink | NoneÚ
hlinkClickÚlangzMSO_LANGUAGE_ID | NoneÚszz
int | NoneÚbzbool | NoneÚiÚuzMSO_TEXT_UNDERLINE_TYPE | Nonec                 C  s   t  ¡ S r8   )r   Únew_gradFillrn   r5   r5   r6   Ú_new_gradFillI  s   z(CT_TextCharacterProperties._new_gradFillÚrIdr0   r/   r$   c                 C  s   |   ¡ }||_|S )zEAdd an `a:hlinkClick` child element with r:id attribute set to `rId`.)r   r¡   )r4   r¡   r™   r5   r5   r6   Úadd_hlinkClickL  s   z)CT_TextCharacterProperties.add_hlinkClickN)r¡   r0   r/   r$   )rE   rF   rG   rH   rI   r!   r   Úeg_fillPropertiesr    r˜   r™   r   r   rš   r   r›   r   rœ   r   r   rž   r    r¢   r5   r5   r5   r6   rV     sH   
 ú÷þÿÿÿÿrV   c                   @  sP   e Zd ZU dZded< edddZded< ed	d
dZded< eddd„ƒZ	dS )ÚCT_TextFieldz?`a:fld` field element, for either a slide number or date field.r&   r'   r(   )úa:pPrr)   r*   r,   r-   r)   r5   rx   r.   r/   r0   c                 C  s   | j }|du r	dS |jpdS )z$The text of the `a:t` child element.Nr1   r2   )r4   r.   r5   r5   r6   r3   _  s   
zCT_TextField.textNrD   )
rE   rF   rG   rH   rI   r    r-   r.   rJ   r3   r5   r5   r5   r6   r¤   S  s   
 ÿÿr¤   c                   @  ó$   e Zd ZU dZedeƒZded< dS )ÚCT_TextFontz•Custom element class for `a:latin`, `a:ea`, `a:cs`, and `a:sym`.

    These occur as child elements of CT_TextCharacterProperties, e.g. `a:rPr`.
    Útypefacer0   N)rE   rF   rG   rH   r   r   r¨   rI   r5   r5   r5   r6   r§   h  s
   
 ÿr§   c                   @  s2   e Zd ZU dZded< edddZedd„ ƒZd	S )
ÚCT_TextLineBreakz`a:br` line break elementr&   r'   r(   r5   r*   c                 C  s   dS )z¤Unconditionally a single vertical-tab character.

        A line break element can contain no text other than the implicit line feed it
        represents.
        úr5   rn   r5   r5   r6   r3   z  s   zCT_TextLineBreak.textN)	rE   rF   rG   rH   rI   r    r-   rJ   r3   r5   r5   r5   r6   r©   s  s   
 r©   c                   @  s   e Zd ZdZededdZdS )ÚCT_TextNormalAutofitzI`a:normAutofit` element specifying fit text to shape font reduction, etc.Ú	fontScaleg      Y@r~   N)rE   rF   rG   rH   r   r   r¬   r5   r5   r5   r6   r«   „  s
    
ÿr«   c                   @  s¾   e Zd ZU dZded< ded< ded< ded	< d
ed< edddZded< edddZedddZ	edddZ
ded< d,dd„Zd-d.d d!„Zd/d#d$„Zed0d&d'„ƒZed1d(d)„ƒZd*d+„ ZdS )2rR   z`a:p` custom element classr&   Úget_or_add_endParaRPrz(Callable[[], CT_TextParagraphProperties]rW   zlist[CT_RegularTextRun]Úr_lstzCallable[[], CT_TextLineBreak]Ú_add_brzCallable[[], CT_RegularTextRun]Ú_add_rr¥   )úa:rúa:brza:fldúa:endParaRPrr*   z!CT_TextParagraphProperties | NonerY   r±   )r³   r²   r³   r5   r,   Ú
endParaRPrr/   r©   c                 C  s   |   ¡ S )z'Return a newly appended `a:br` element.)r¯   rn   r5   r5   r6   Úadd_brž  s   zCT_TextParagraph.add_brNr3   r…   r%   c                 C  s   |   ¡ }|r	||_|S )z&Return a newly appended `a:r` element.)r°   r3   )r4   r3   Úrr5   r5   r6   Úadd_r¢  s   zCT_TextParagraph.add_rr0   c                 C  s<   t t d|¡ƒD ]\}}|dkr|  ¡  |r|  |¡ qdS )ao  Append `a:r` and `a:br` elements to `p` based on `text`.

        Any `
` or `` (vertical-tab) characters in `text` delimit `a:r` (run) elements and
        themselves are translated to `a:br` (line-break) elements. The vertical-tab character
        appears in clipboard text from PowerPoint at "soft" line-breaks (new-line, but not new
        paragraph).
        z
|r   N)Ú	enumeraterB   Úsplitrµ   r·   )r4   r3   ÚidxÚr_strr5   r5   r6   Úappend_text©  s   
€úzCT_TextParagraph.append_textú?tuple[CT_RegularTextRun | CT_TextLineBreak | CT_TextField, ...]c                 C  s   t dd„ | D ƒƒS )z„Sequence containing text-container child elements of this `a:p` element.

        These include `a:r`, `a:br`, and `a:fld`.
        c                 s  s$    | ]}t |tttfƒr|V  qd S r8   )Ú
isinstancer%   r©   r¤   )Ú.0Úer5   r5   r6   Ú	<genexpr>¿  s   € ÿ
ÿz4CT_TextParagraph.content_children.<locals>.<genexpr>)Útuplern   r5   r5   r6   Úcontent_children¹  s   ÿz!CT_TextParagraph.content_childrenc                 C  s   d  dd„ | jD ƒ¡S )z%str text contained in this paragraph.r1   c                 S  s   g | ]}|j ‘qS r5   )r3   )r¿   Úchildr5   r5   r6   Ú
<listcomp>Ç  rA   z)CT_TextParagraph.text.<locals>.<listcomp>)ÚjoinrÃ   rn   r5   r5   r6   r3   Ã  s   zCT_TextParagraph.textc                 C  s   dt dƒ }t|ƒS )Nz<a:r %s><a:t/></a:r>rj   rk   )r4   Úr_xmlr5   r5   r6   Ú_new_rÉ  s   zCT_TextParagraph._new_r)r/   r©   r8   )r3   r…   r/   r%   )r3   r0   )r/   r½   rD   )rE   rF   rG   rH   rI   r    rY   r   r¶   Úbrr´   rµ   r·   r¼   rJ   rÃ   r3   rÈ   r5   r5   r5   r6   rR   Œ  s.   
 ÿÿ

	rR   c                   @  s@  e Zd ZU dZded< ded< ded< ded< ded	< ded
< ded< dZededd… dZded< ededd… dZded< ededd… dZ	ded< ededd… dZ
ded< ededdZd ed< ed!eƒZd"ed!< [ed0d%d&„ƒZejd1d(d&„ƒZed2d*d+„ƒZejd3d,d+„ƒZed-d.„ ƒZejd3d/d.„ƒZdS )4ÚCT_TextParagraphPropertiesz`a:pPr` custom element class.r&   rX   zCallable[[], CT_TextSpacing]Ú
_add_lnSpcÚ_add_spcAftÚ_add_spcBefrv   Ú_remove_lnSpcÚ_remove_spcAftÚ_remove_spcBef)úa:lnSpcúa:spcBefúa:spcAftz	a:buClrTxza:buClrza:buSzTxz	a:buSzPctz	a:buSzPtsz
a:buFontTxza:buFontza:buNoneza:buAutoNumza:buCharza:buBlipza:tabLstúa:defRPrr|   rÑ   r<   Nr*   zCT_TextSpacing | NoneÚlnSpcrÒ   é   ÚspcBefrÓ   é   ÚspcAftrÔ   é   r,   rZ   Úlvlr   r~   ÚintÚalgnzPP_PARAGRAPH_ALIGNMENT | Noner/   úfloat | Length | Nonec                 C  s2   | j }|du r	dS |jdur|jjS tt|jƒjS )a5  The spacing between baselines of successive lines in this paragraph.

        A float value indicates a number of lines. A |Length| value indicates a fixed spacing.
        Value is contained in `./a:lnSpc/a:spcPts/@val` or `./a:lnSpc/a:spcPct/@val`. Value is
        |None| if no element is present.
        N)rÕ   ÚspcPtsÚvalr   ÚCT_TextSpacingPercentÚspcPct)r4   rÕ   r5   r5   r6   Úline_spacing   s   
z'CT_TextParagraphProperties.line_spacingr7   c                 C  sB   |   ¡  |d u r
d S t|tƒr|  ¡  |¡ d S |  ¡  |¡ d S r8   )rÎ   r¾   r#   rË   Ú
set_spcPtsÚ
set_spcPctr:   r5   r5   r6   rã     s   
úLength | Nonec                 C  ó*   | j }|du r	dS |j}|du rdS |jS )zJThe EMU equivalent of the centipoints value in `./a:spcAft/a:spcPts/@val`.N)rÙ   rß   rà   )r4   rÙ   rß   r5   r5   r6   Úspace_after  ó   z&CT_TextParagraphProperties.space_afterc                 C  ó&   |   ¡  |d ur|  ¡  |¡ d S d S r8   )rÏ   rÌ   rä   r:   r5   r5   r6   rè   $  ó   ÿc                 C  rç   )zJThe EMU equivalent of the centipoints value in `./a:spcBef/a:spcPts/@val`.N)r×   rß   rà   )r4   r×   rß   r5   r5   r6   Úspace_before*  ré   z'CT_TextParagraphProperties.space_beforec                 C  rê   r8   )rÐ   rÍ   rä   r:   r5   r5   r6   rì   5  rë   )r/   rÞ   )r7   rÞ   )r/   ræ   )r7   ræ   )rE   rF   rG   rH   rI   Ú_tag_seqr    rÕ   r×   rÙ   rZ   r   r   rÛ   r
   rÝ   rJ   rã   rK   rè   rì   r5   r5   r5   r6   rÊ   Î  sR   
 ÿÿÿÿÿÿ	


rÊ   c                   @  sf   e Zd ZU dZded< ded< ded< ded< ed	ƒZd
ed< edƒZded< ddd„Zddd„Z	dS )ÚCT_TextSpacingz8Used for `a:lnSpc`, `a:spcBef`, and `a:spcAft` elements.z#Callable[[], CT_TextSpacingPercent]Úget_or_add_spcPctz!Callable[[], CT_TextSpacingPoint]Úget_or_add_spcPtsrv   Ú_remove_spcPctÚ_remove_spcPtsza:spcPctzCT_TextSpacingPercent | Nonerâ   za:spcPtszCT_TextSpacingPoint | Nonerß   r7   Úfloatc                 C  ó   |   ¡  |  ¡ }||_dS )zjSet spacing to `value` lines, e.g. 1.75 lines.

        A ./a:spcPts child is removed if present.
        N)rò   rï   rà   )r4   r7   râ   r5   r5   r6   rå   M  s   
zCT_TextSpacing.set_spcPctr#   c                 C  rô   )zHSet spacing to `value` points. A ./a:spcPct child is removed if present.N)rñ   rð   rà   )r4   r7   rß   r5   r5   r6   rä   V  s   
zCT_TextSpacing.set_spcPtsN)r7   ró   )r7   r#   )
rE   rF   rG   rH   rI   r    râ   rß   rå   rä   r5   r5   r5   r6   rî   <  s   
 ÿÿ
	rî   c                   @  r¦   )rá   zZ`a:spcPct` element, specifying spacing in thousandths of a percent in its `val` attribute.rà   ró   N)rE   rF   rG   rH   r   r   rà   rI   r5   r5   r5   r6   rá   ]  ó
   
 ÿrá   c                   @  r¦   )ÚCT_TextSpacingPointzM`a:spcPts` element, specifying spacing in centipoints in its `val` attribute.rà   r#   N)rE   rF   rG   rH   r   r   rà   rI   r5   r5   r5   r6   rö   e  rõ   rö   )=rH   Ú
__future__r   rB   Útypingr   r   r   Úpptx.enum.langr   Úpptx.enum.textr   r   r	   r
   Úpptx.excr   Ú	pptx.oxmlr   Úpptx.oxml.dml.fillr   Úpptx.oxml.nsr   Úpptx.oxml.simpletypesr   r   r   r   r   r   r   r   r   Úpptx.oxml.xmlchemyr   r   r   r   r   r   r   r    r!   Ú	pptx.utilr"   r#   Úpptx.oxml.actionr$   r%   rM   rP   rV   r¤   r§   r©   r«   rR   rÊ   rî   rá   rö   r5   r5   r5   r6   Ú<module>   s8    ,, z>LBn!