o
    7 ¾h8O  ã                   @  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   úV/var/www/html/figdemos/bartoux_crm/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   Z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ÚxmlZ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   )r`   ra   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   )r`   ra   Ú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>
rh   r   ©r`   r5   r5   r6   rc   ´   s   zCT_TextBody._a_txBody_tmplc                 C  ó   dt ddƒ S )Nz1<p:txBody %s>
  <a:bodyPr/>
  <a:p/>
</p:txBody>
rS   rh   r   rn   r5   r5   r6   re   ¸   s   ÿzCT_TextBody._p_txBody_tmplc                 C  ro   )NzA<p:txBody %s>
  <a:bodyPr/>
  <a:lstStyle/>
  <a:p/>
</p:txBody>
rh   rS   r   rn   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]   Úclassmethodrb   rd   rf   rk   rm   rc   re   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)rw   r   ÚNONErx   ÚTEXT_TO_FIT_SHAPEry   ÚSHAPE_TO_FIT_TEXTrl   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   Ú
ValueErrorru   r„   rq   r…   rr   r†   rs   r:   r5   r5   r6   r‡   ÷   s   ÿÿ


ÿN)r7   rˆ   )rE   rF   rG   rH   rI   r!   r   Z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]Zget_or_add_latinrt   Z_remove_latinZ_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:rtlrz   r*   r‹   )rŒ   r   rŽ   r   r   r‘   rz   zCT_TextFont | NoneÚlatinr   )r   r‘   rz   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   Znew_gradFillrl   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   Z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   rv   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   rl   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&   Zget_or_add_endParaRPrz(Callable[[], CT_TextParagraphProperties]rW   zlist[CT_RegularTextRun]Z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¥   rl   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>)Útuplerl   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¹   rl   r5   r5   r6   r3   Ã  s   zCT_TextParagraph.textc                 C  s   dt dƒ }t|ƒS )Nz<a:r %s><a:t/></a:r>rh   ri   )r4   Z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_spcBefrt   Ú_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:defRPrrz   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_spcPtsrt   Ú_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   Zpptx.enum.langr   Z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!