
    li8O                       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e"      Z0 G d de"      Z1 G d de"      Z2 G d de"      Z3 G d de"      Z4 G d de"      Z5 G d de"      Z6 G d de"      Z7 G d d e"      Z8 G d! d"e"      Z9 G d# d$e"      Z: G d% d&e"      Z; G d' d(e"      Z<y))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                      e Zd ZU dZded<    edd      Zded<    ed	      Zd
ed<   e	dd       Z
e
j                  dd       Z
edd       Zy)CT_RegularTextRunz`a:r` custom element class(Callable[[], CT_TextCharacterProperties]get_or_add_rPra:rPr)a:t
successors!CT_TextCharacterProperties | NonerPrr+   r   tc                :    | j                   j                  }|xs dS )z#All text of (required) `a:t` child. r0   text)selfr4   s     L/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/pptx/oxml/text.pyr4   zCT_RegularTextRun.text9   s     vv{{zr    c                D    | j                  |      | j                  _        y N)_escape_ctrl_charsr0   r4   r5   values     r6   r4   zCT_RegularTextRun.text@   s    --e4r7   c                2    t        j                  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                <    dt        | j                  d            z  S )Nz_x%04X_   )ordgroup)matchs    r6   <lambda>z6CT_RegularTextRun._escape_ctrl_chars.<locals>.<lambda>L   s    y3u{{[\~K^?^ r7   )resub)ss    r6   r:   z$CT_RegularTextRun._escape_ctrl_charsD   s     vv/1^`abbr7   Nreturnstr)r<   rI   )rF   rI   rH   rI   )__name__
__module____qualname____doc____annotations__r!   r/   r   r0   propertyr4   setterstaticmethodr:    r7   r6   r'   r'   /   ss    $<<-6H.C	*  'u-A-  
[[5 5 c cr7   r'   c                      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 Z	e
dd       Ze
dd       Zed        Zedd       Zed        Zed        Zd Zed        Zed        Zed        Zy)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                H    | j                   D ]  }| j                  |        y)zRemove all `a:p` children, but leave any others.

        cf. lxml `_Element.clear()` method which removes all children.
        N)rV   remove)r5   rZ   s     r6   clear_contentzCT_TextBody.clear_content]   s"    
  	AKKN	r7   c                d    | j                   d   }|j                         }|j                         }|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   )rV   get_or_add_pPrget_or_add_defRPr)r5   rZ   pPrdefRPrs       r6   rb   zCT_TextBody.defRPre   s2     JJqM &&(r7   c                z    | j                   }t        |      dkD  ry|st        d      |d   j                  dk7  ryy)z5True if only a single empty `a:p` element is present.r?   Fz#p:txBody must have at least one a:pr   r2   T)rV   lenr   r4   )r5   pss     r6   is_emptyzCT_TextBody.is_emptyq   s@     ZZr7Q;!"GHHa5::r7   c                <    | j                         }t        |      }|S )z%Return a new `p:txBody` element tree.)_txBody_tmplr   clsxmltxBodys      r6   newzCT_TextBody.new   s       3r7   c                X    | j                         }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   rT   r   ri   s      r6   new_a_txBodyzCT_TextBody.new_a_txBody   s'       "k9S>2r7   c                8    | j                         }t        |      S )zLReturn a new `p:txBody` element tree, suitable for use in an `p:sp` element.)_p_txBody_tmplr   )rj   rk   s     r6   new_p_txBodyzCT_TextBody.new_p_txBody   s       "~r7   c                :    dt        dd      z  }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   )rj   rk   txPrs      r6   new_txPrzCT_TextBody.new_txPr   s*     C
 ~r7   c                V    t        | j                        dkD  ry| j                          y)zEnsure 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)rd   rV   rU   r5   s    r6   unclear_contentzCT_TextBody.unclear_content   s      tzz?Q

r7   c                    dt        d      z  S )Nz1<a:txBody %s>
  <a:bodyPr/>
  <a:p/>
</a:txBody>
rv   r   rj   s    r6   ro   zCT_TextBody._a_txBody_tmpl   s    OSZ[^S_``r7   c                     dt        dd      z  S )Nz1<p:txBody %s>
  <a:bodyPr/>
  <a:p/>
</p:txBody>
rZ   rv   r   r~   s    r6   rr   zCT_TextBody._p_txBody_tmpl   s     MPWX[]`Pab	
r7   c                     dt        dd      z  S )NzA<p:txBody %s>
  <a:bodyPr/>
  <a:lstStyle/>
  <a:p/>
</p:txBody>
rv   rZ   r   r~   s    r6   rh   zCT_TextBody._txBody_tmpl   s      'sC0	2	
r7   N)rH   CT_TextCharacterProperties)rH   bool)rH   rT   )rJ   rK   rL   rM   rN   r   rX   r   rZ   r]   rO   rb   rf   classmethodrm   rp   rs   ry   r|   ro   rr   rh   rR   r7   r6   rT   rT   O   s    
 *)!!$1%F!  $E*A* 	 	        
  & a a 
 

 
 
r7   rT   c                     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      Z ede	 e
d            Zded<    ede	 e
d            Zded<    ede	 e
d            Zded<    ede	 e
d            Zded<    ede      Zded<    ede      Zded<   ed        Zej*                  d"d        Zy!)#rW   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                    | j                   t        j                  S | j                  t        j                  S | j
                  t        j                  S y)zTThe autofit setting for the text frame, a member of the `MSO_AUTO_SIZE` enumeration.N)r   r   NONEr   TEXT_TO_FIT_SHAPEr   SHAPE_TO_FIT_TEXTr{   s    r6   autofitzCT_TextBodyProperties.autofit   sK     >>% %%%' 222>>% 222r7   c                ,   ||t         vrt        d|       | j                          |t         j                  k(  r| j	                          y |t         j
                  k(  r| j                          y |t         j                  k(  r| j                          y y )Nzmonly None or a member of the MSO_AUTO_SIZE enumeration can be assigned to CT_TextBodyProperties.autofit, got )	r   
ValueErrorr   r   r   r   r   r   r   r;   s     r6   r   zCT_TextBodyProperties.autofit   s    m!;77<g?  	##%M&&&!m555!!#m555! 6r7   N)r<   zMSO_AUTO_SIZE | None)rJ   rK   rL   rM   rN   r"   r   eg_textAutoFitr   r   r#   r   r   r   r   r
   r   r   r   rO   r   rP   rR   r7   r6   rW   rW      s,   *118811..%%,,%%$		 79NOBN %UD&  %UD&  %UD&  %UD&  *;%*F&  )#D*    ^^" "r7   rW   c            
      x   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      Z edd      Z	ded<    e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" Zd%d#Zy$)&r   zCustom 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_latinr   _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                *    t        j                         S r9   )r   new_gradFillr{   s    r6   _new_gradFillz(CT_TextCharacterProperties._new_gradFillI  s    (5577r7   c                4    | j                         }||_        |S )zEAdd an `a:hlinkClick` child element with r:id attribute set to `rId`.)r   rId)r5   r   r   s      r6   add_hlinkClickz)CT_TextCharacterProperties.add_hlinkClickL  s    //1

r7   N)r   rI   rH   r%   )rJ   rK   rL   rM   rN   r"   r   eg_fillPropertiesr!   r   r   r   r   r   r   r   r   r   r   r	   r   r   r   rR   r7   r6   r   r     s   
 65//%%**':=!< < < ;	

6 !*
!E  '0#L'J#  $5$D
   'oB
  'sJ7A{7&sJ7A{7(9$)A% 8r7   r   c                  j    e Zd ZU dZded<    edd      Zded<    ed	d
      Zded<   edd       Z	y)CT_TextFieldz?`a:fld` field element, for either a slide number or date field.r(   r)   r*   )a:pPrr+   r,   r.   r/   r+   rR   r   r0   c                @    | j                   }|y|j                  xs dS )z$The text of the `a:t` child element.r2   r3   )r5   r0   s     r6   r4   zCT_TextField.text_  s#     FF9vv|r7   NrG   )
rJ   rK   rL   rM   rN   r!   r/   r0   rO   r4   rR   r7   r6   r   r   S  sP    I<<-6,.C	*  !*"!A   r7   r   c                  .    e Zd ZU dZ ede      Zded<   y)CT_TextFontzCustom element class for `a:latin`, `a:ea`, `a:cs`, and `a:sym`.

    These occur as child elements of CT_TextCharacterProperties, e.g. `a:rPr`.
    typefacerI   N)rJ   rK   rL   rM   r   r   r   rN   rR   r7   r6   r   r   h  s    
 &OHc r7   r   c                  @    e Zd ZU dZded<    edd      Zed        Zy)	CT_TextLineBreakz`a:br` line break elementr(   r)   r*   rR   r,   c                     y)zUnconditionally a single vertical-tab character.

        A line break element can contain no text other than the implicit line feed it
        represents.
        rR   r{   s    r6   r4   zCT_TextLineBreak.textz  s     r7   N)	rJ   rK   rL   rM   rN   r!   r/   rO   r4   rR   r7   r6   r   r   s  s)    #<<
G
+C r7   r   c                  &    e Zd ZdZ eded      Zy)CT_TextNormalAutofitzI`a:normAutofit` element specifying fit text to shape font reduction, etc.	fontScaleg      Y@r   N)rJ   rK   rL   rM   r   r   r   rR   r7   r6   r   r     s    S!;UIr7   r   c                      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      Zded<    edd      Z edd      Z	 edd      Z
ded<   ddZd d!dZd"dZed#d       Zed$d       Zd Zy)%rY   z`a:p` custom element classr(   get_or_add_endParaRPrz(Callable[[], CT_TextParagraphProperties]r_   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 | Nonera   r   )r   r   r   rR   r.   
endParaRPrc                "    | j                         S )z'Return a newly appended `a:br` element.)r   r{   s    r6   add_brzCT_TextParagraph.add_br  s    ||~r7   Nc                8    | j                         }|r||_        |S )z&Return a newly appended `a:r` element.)r   r4   )r5   r4   rs      r6   add_rzCT_TextParagraph.add_r  s    KKMAFr7   c                    t        t        j                  d|            D ].  \  }}|dkD  r| j                          |s| j	                  |       0 y)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)	enumeraterD   splitr   r   )r5   r4   idxr_strs       r6   append_textzCT_TextParagraph.append_text  sF     $BHHWd$;< 	"JCQw

5!	"r7   c                &    t        d | D              S )zSequence containing text-container child elements of this `a:p` element.

        These include `a:r`, `a:br`, and `a:fld`.
        c              3  X   K   | ]"  }t        |t        t        t        f      s| $ y wr9   )
isinstancer'   r   r   ).0es     r6   	<genexpr>z4CT_TextParagraph.content_children.<locals>.<genexpr>  s(      
z!.?AQS_-`aA
s    **)tupler{   s    r6   content_childrenz!CT_TextParagraph.content_children  s      

 
 	
r7   c                r    dj                  | j                  D cg c]  }|j                   c}      S c c}w )z%str text contained in this paragraph.r2   )joinr   r4   )r5   childs     r6   r4   zCT_TextParagraph.text  s+     ww0E0EFu

FGGFs   4c                4    dt        d      z  }t        |      S )Nz<a:r %s><a:t/></a:r>rv   rw   )r5   r_xmls     r6   _new_rzCT_TextParagraph._new_r  s    &5r7   )rH   r   r9   )r4   r   rH   r'   )r4   rI   )rH   z?tuple[CT_RegularTextRun | CT_TextLineBreak | CT_TextField, ...]rG   )rJ   rK   rL   rM   rN   r!   ra   r    r   brr   r   r   r   rO   r   r4   r   rR   r7   r6   rY   rY     s    $CC<<""++++-6D.C	*  	5%67A	F'8	9B4=25J1 "  
 
 H H
 r7   rY   c                     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       Zded<    ededd       Zded<    ededd       Z	ded<    ededd       Z
ded<    eded      Zd ed<    ed!e      Zd"ed!<   [ed)d#       Zej$                  d*d$       Zed+d%       Zej$                  d,d&       Zed'        Zej$                  d,d(       Zy)-CT_TextParagraphPropertiesz`a:pPr` custom element class.r(   r`   zCallable[[], CT_TextSpacing]
_add_lnSpc_add_spcAft_add_spcBefr   _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.   rb   lvlr   r   intalgnzPP_PARAGRAPH_ALIGNMENT | Nonec                    | j                   }|y|j                  |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)r5   r   s     r6   line_spacingz'CT_TextParagraphProperties.line_spacing   sG     

=<<#<<###)5<<8<<<r7   c                    | j                          |y t        |t              r | j                         j	                  |       y | j                         j                  |       y r9   )r   r   r$   r   
set_spcPts
set_spcPctr;   s     r6   r  z'CT_TextParagraphProperties.line_spacing  sJ    =eV$OO((/OO((/r7   c                V    | j                   }|y|j                  }|y|j                  S )zJThe EMU equivalent of the centipoints value in `./a:spcAft/a:spcPts/@val`.N)r   r  r  )r5   r   r  s      r6   space_afterz&CT_TextParagraphProperties.space_after  0     >>zzr7   c                h    | j                          | | j                         j                  |       y y r9   )r   r   r  r;   s     r6   r
  z&CT_TextParagraphProperties.space_after$  0    ))%0 r7   c                V    | j                   }|y|j                  }|y|j                  S )zJThe EMU equivalent of the centipoints value in `./a:spcBef/a:spcPts/@val`.N)r   r  r  )r5   r   r  s      r6   space_beforez'CT_TextParagraphProperties.space_before*  r  r7   c                h    | j                          | | j                         j                  |       y y r9   )r   r   r  r;   s     r6   r  z'CT_TextParagraphProperties.space_before5  r  r7   )rH   float | Length | None)r<   r  )rH   Length | None)r<   r  )rJ   rK   rL   rM   rN   _tag_seqr!   r   r   r   rb   r   r   r   r   r   rO   r  rP   r
  r  rR   r7   r6   r   r     st   '??,,----%%&&&&H& $-hqrl$E   %.x|%F!  %.x|%F!  1:x}1F-  !%qC  +<&+D
'  	= = 0 0   1 1
   1 1r7   r   c                  ~    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ZddZ	y)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_spcPtsr   _remove_spcPct_remove_spcPtsza:spcPctzCT_TextSpacingPercent | Noner  za:spcPtszCT_TextSpacingPoint | Noner  c                R    | j                          | j                         }||_        y)zjSet spacing to `value` lines, e.g. 1.75 lines.

        A ./a:spcPts child is removed if present.
        N)r  r  r  )r5   r<   r  s      r6   r  zCT_TextSpacing.set_spcPctM  s%    
 	'')
r7   c                R    | j                          | j                         }||_        y)zHSet spacing to `value` points. A ./a:spcPct child is removed if present.N)r  r  r  )r5   r<   r  s      r6   r  zCT_TextSpacing.set_spcPtsV  s#    '')
r7   N)r<   float)r<   r$   )
rJ   rK   rL   rM   rN   r!   r  r  r  r  rR   r7   r6   r  r  <  sU    B::88&&&& ,5,F(  *3*F& r7   r  c                  .    e Zd ZU dZ ede      Zded<   y)r  zZ`a:spcPct` element, specifying spacing in thousandths of a percent in its `val` attribute.r  r  N)rJ   rK   rL   rM   r   r   r  rN   rR   r7   r6   r  r  ]  s    d"3C r7   r  c                  .    e Zd ZU dZ ede      Zded<   y)CT_TextSpacingPointzM`a:spcPts` element, specifying spacing in centipoints in its `val` attribute.r  r$   N)rJ   rK   rL   rM   r   r   r  rN   rR   r7   r6   r  r  e  s    W#"C r7   r  )=rM   
__future__r   rD   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'   rT   rW   r   r   r   r   r   rY   r   r  r  r  rR   r7   r6   <module>r,     s   : " 	 0 0 *  %  8  
 
 

 
 
 "-c c@w
/ w
t;"O ;"|I IX? */  "? ?  ? Dk1 k1\_ BO / r7   