
    hi8O                    j   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<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                      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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                "    | j         j        }|pdS )z#All text of (required) `a:t` child. r0   text)selfr6   s     f/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/pptx/oxml/text.pyr6   zCT_RegularTextRun.text9   s     v{zr    valuec                D    |                      |          | j        _        d S N)_escape_ctrl_charsr0   r6   r7   r:   s     r8   r6   zCT_RegularTextRun.text@   s    --e44r9   sc                0    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                L    dt          |                     d                    z  S )Nz_x%04X_   )ordgroup)matchs    r8   <lambda>z6CT_RegularTextRun._escape_ctrl_chars.<locals>.<lambda>L   s    y3u{{[\~~K^K^?^ r9   )resub)r?   s    r8   r=   z$CT_RegularTextRun._escape_ctrl_charsD   s     v/1^1^`abbbr9   Nr1   r2   )r:   r2   )r?   r2   r1   r2   )__name__
__module____qualname____doc____annotations__r!   r/   r   r0   propertyr6   setterstaticmethodr=    r9   r8   r'   r'   /   s         $$<<<<-6YH. . .C     'u--A----   X 
[5 5 5 [5 c c c \c c cr9   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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                D    | j         D ]}|                     |           dS )zRemove all `a:p` children, but leave any others.

        cf. lxml `_Element.clear()` method which removes all children.
        N)rV   remove)r7   rZ   s     r8   clear_contentzCT_TextBody.clear_content]   s0    
  	 	AKKNNNN	 	r9   r1   CT_TextCharacterPropertiesc                p    | 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   )rV   get_or_add_pPrget_or_add_defRPr)r7   rZ   pPrdefRPrs       r8   rc   zCT_TextBody.defRPre   s6     JqM  &&((r9   boolc                    | 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.rB   Fz#p:txBody must have at least one a:pr   r4   T)rV   lenr   r6   )r7   pss     r8   is_emptyzCT_TextBody.is_emptyq   sR     Zr77Q;;5 	I!"GHHHa5:5tr9   c                L    |                                  }t          |          }|S )z%Return a new `p:txBody` element tree.)_txBody_tmplr   clsxmltxBodys      r8   newzCT_TextBody.new   s%       3r9   c                r    |                                  }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   rk   s      r8   new_a_txBodyzCT_TextBody.new_a_txBody   s/       ""k9S>>22r9   c                H    |                                  }t          |          S )zLReturn a new `p:txBody` element tree, suitable for use in an `p:sp` element.)_p_txBody_tmplr   )rl   rm   s     r8   new_p_txBodyzCT_TextBody.new_p_txBody   s!       ""~~r9   c                J    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   )rl   rm   txPrs      r8   new_txPrzCT_TextBody.new_txPr   s/     C
 ~~r9   c                b    t          | j                  dk    rdS |                                  dS )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)rf   rV   rU   r7   s    r8   unclear_contentzCT_TextBody.unclear_content   s-     tz??QF

r9   c                &    dt          d          z  S )Nz1<a:txBody %s>
  <a:bodyPr/>
  <a:p/>
</a:txBody>
rx   r   rl   s    r8   rq   zCT_TextBody._a_txBody_tmpl   s    OSZ[^S_S_``r9   c                (    dt          dd          z  S )Nz1<p:txBody %s>
  <a:bodyPr/>
  <a:p/>
</p:txBody>
rZ   rx   r   r   s    r8   rt   zCT_TextBody._p_txBody_tmpl   s     MPWX[]`PaPab	
r9   c                (    dt          dd          z  S )NzA<p:txBody %s>
  <a:bodyPr/>
  <a:lstStyle/>
  <a:p/>
</p:txBody>
rx   rZ   r   r   s    r8   rj   zCT_TextBody._txBody_tmpl   s       'sC00	2	
r9   N)r1   r^   )r1   rd   )r1   rT   )rJ   rK   rL   rM   rN   r   rX   r   rZ   r]   rO   rc   rh   classmethodro   rr   ru   r{   r~   rq   rt   rj   rR   r9   r8   rT   rT   O   s         
 *)))!!!!$1M% %F     $)E**A****   	 	 	 X	    X   [    [   [
   [&   a a [a 
 
 [

 
 
 [
 
 
r9   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d#S )%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                x    | j         t          j        S | j        t          j        S | j        t          j        S dS )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    r8   autofitzCT_TextBodyProperties.autofit   s=     >% %%' 22>% 22tr9   r:   MSO_AUTO_SIZE | Nonec                L   ||t           vrt          d|           |                                  |t           j        k    r|                                  d S |t           j        k    r|                                  d S |t           j        k    r|                                  d S d S )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     r8   r   zCT_TextBodyProperties.autofit   s    m!;!;?7<? ?   	##%%%M&&&!!!!!m555!!#####m555!!!!! 65r9   N)r:   r   )rJ   rK   rL   rM   rN   r"   r   eg_textAutoFitr   r   r#   r   r   r   r   r
   r   r   r   rO   r   rP   rR   r9   r8   rW   rW      s:        **111188881111....%%%%,,,,%%%%$_			 7 79N9NOB  N %$U  D     %$U  D     %$U  D     %$U  D     *;):%* *F     )(# D       X ^" " " ^" " "r9   rW   c            
         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d(S )*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 r<   )r   new_gradFillr}   s    r8   _new_gradFillz(CT_TextCharacterProperties._new_gradFillI  s    (5777r9   rIdr2   r1   r%   c                <    |                                  }||_        |S )zEAdd an `a:hlinkClick` child element with r:id attribute set to `rId`.)r   r   )r7   r   r   s      r8   add_hlinkClickz)CT_TextCharacterProperties.add_hlinkClickL  s     //11

r9   N)r   r2   r1   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   r9   r8   r^   r^     s         
 6555////%%%%****'F:F=!!F<  F<  F<  F;	

  6 !*	
! ! !E     '0i#L' ' 'J     $5#4$ $D     '&o B     '&sJ77A7777&&sJ77A7777(9(9$) )A    8 8 8     r9   r^   c                  ~    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	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+   rR   r   r0   r1   r2   c                *    | j         }|dS |j        pdS )z$The text of the `a:t` child element.Nr4   r5   )r7   r0   s     r8   r6   zCT_TextField.text_  s!     F92v|r9   NrI   )
rJ   rK   rL   rM   rN   r!   r/   r0   rO   r6   rR   r9   r8   r   r   S  s         II<<<<-6Y,. . .C     !*	"! ! !A        X  r9   r   c                  6    e Zd ZU dZ ede          Zded<   dS )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`.
    typefacer2   N)rJ   rK   rL   rM   r   r   r   rN   rR   r9   r8   r   r   h  sM          
 &%O H      r9   r   c                  N    e Zd ZU dZded<    edd          Zed             ZdS )	CT_TextLineBreakz`a:br` line break elementr(   r)   r*   rR   r,   c                    dS )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    r8   r6   zCT_TextLineBreak.textz  s	     tr9   N)	rJ   rK   rL   rM   rN   r!   r/   rO   r6   rR   r9   r8   r   r   s  sU         ##<<<<
)G
+
+
+C  X  r9   r   c                  .    e Zd ZdZ eded          ZdS )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   r9   r8   r   r     s3        SS!!;U  IIIr9   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dS ),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 | Nonerb   r   )r   r   r   rR   r.   
endParaRPrr1   r   c                *    |                                  S )z'Return a newly appended `a:br` element.)r   r}   s    r8   add_brzCT_TextParagraph.add_br  s    ||~~r9   Nr6   r   r'   c                @    |                                  }|r||_        |S )z&Return a newly appended `a:r` element.)r   r6   )r7   r6   rs      r8   add_rzCT_TextParagraph.add_r  s#    KKMM 	AFr9   r2   c                    t          t          j        d|                    D ]6\  }}|dk    r|                                  |r|                     |           7d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)	enumeraterG   splitr   r   )r7   r6   idxr_strs       r8   append_textzCT_TextParagraph.append_text  sf     $BHWd$;$;<< 	" 	"JCQww "

5!!!	" 	"r9   ?tuple[CT_RegularTextRun | CT_TextLineBreak | CT_TextField, ...]c                4    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  ^   K   | ](}t          |t          t          t          f          $|V  )d S r<   )
isinstancer'   r   r   ).0es     r8   	<genexpr>z4CT_TextParagraph.content_children.<locals>.<genexpr>  sO       
 
z!.?AQS_-`aa

 
 
 
 
 
r9   )tupler}   s    r8   content_childrenz!CT_TextParagraph.content_children  s2      
 

 
 
 
 
 	
r9   c                J    d                     d | j        D                       S )z%str text contained in this paragraph.r4   c                    g | ]	}|j         
S rR   )r6   )r   childs     r8   
<listcomp>z)CT_TextParagraph.text.<locals>.<listcomp>  s    FFFu
FFFr9   )joinr   r}   s    r8   r6   zCT_TextParagraph.text  s(     wwFF0EFFFGGGr9   c                D    dt          d          z  }t          |          S )Nz<a:r %s><a:t/></a:r>rx   ry   )r7   r_xmls     r8   _new_rzCT_TextParagraph._new_r  s     &5r9   )r1   r   r<   )r6   r   r1   r'   )r6   r2   )r1   r   rI   )rJ   rK   rL   rM   rN   r!   rb   r    r   brr   r   r   r   rO   r   r6   r   rR   r9   r8   rY   rY     sw        $$CCCC<<<<""""++++++++-6YD. . .C     	
5%6777A	F'8	9	9	9B4=I25 5 5J           " " " "  
 
 
 X
 H H H XH
         r9   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        d0d*            Zed+             Zej        d0d,            ZdS )1CT_TextParagraphPropertiesz`a:pPr` custom element class.r(   ra   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   rB   Nr,   zCT_TextSpacing | NonelnSpcr      spcBefr      spcAftr      r.   rc   lvlr   r   intalgnzPP_PARAGRAPH_ALIGNMENT | Noner1   float | Length | Nonec                |    | j         }|dS |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)r7   r   s     r8   line_spacingz'CT_TextParagraphProperties.line_spacing   s>     
=4<#<##)5<88<<r9   r:   c                    |                                   |d S t          |t                    r)|                                                     |           d S |                                                     |           d S r<   )r   r   r$   r   
set_spcPts
set_spcPctr>   s     r8   r
  z'CT_TextParagraphProperties.line_spacing  sx    =FeV$$ 	0OO((/////OO((/////r9   Length | Nonec                <    | j         }|dS |j        }|dS |j        S )zJThe EMU equivalent of the centipoints value in `./a:spcAft/a:spcPts/@val`.N)r   r  r  )r7   r   r  s      r8   space_afterz&CT_TextParagraphProperties.space_after  .     >4>4zr9   c                    |                                   |)|                                                     |           d S d S r<   )r   r   r  r>   s     r8   r  z&CT_TextParagraphProperties.space_after$  H    ))%00000 r9   c                <    | j         }|dS |j        }|dS |j        S )zJThe EMU equivalent of the centipoints value in `./a:spcBef/a:spcPts/@val`.N)r   r  r  )r7   r   r  s      r8   space_beforez'CT_TextParagraphProperties.space_before*  r  r9   c                    |                                   |)|                                                     |           d S d S r<   )r   r   r  r>   s     r8   r  z'CT_TextParagraphProperties.space_before5  r  r9   )r1   r  )r:   r  )r1   r  )r:   r  )rJ   rK   rL   rM   rN   _tag_seqr!   r   r   r   rc   r   r   r  r   r  rO   r
  rP   r  r  rR   r9   r8   r   r     s        ''????,,,,--------%%%%&&&&&&&&H& $-9hqrrl$ $ $E     %.Ix|% % %F     %.Ix|% % %F     1:	x}1 1 1F     ! %q  C     +<*;&+ +D     	= = = X= 0 0 0 0    X 1 1 1 1
   X 1 1 1 1 1 1r9   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	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_spcPtsr   _remove_spcPct_remove_spcPtsza:spcPctzCT_TextSpacingPercent | Noner	  za:spcPtszCT_TextSpacingPoint | Noner  r:   floatc                d    |                                   |                                 }||_        dS )zjSet spacing to `value` lines, e.g. 1.75 lines.

        A ./a:spcPts child is removed if present.
        N)r  r  r  )r7   r:   r	  s      r8   r  zCT_TextSpacing.set_spcPctM  s2    
 	''))


r9   r$   c                d    |                                   |                                 }||_        dS )zHSet spacing to `value` points. A ./a:spcPct child is removed if present.N)r  r  r  )r7   r:   r  s      r8   r  zCT_TextSpacing.set_spcPtsV  s0    ''))


r9   N)r:   r  )r:   r$   )
rJ   rK   rL   rM   rN   r!   r	  r  r  r  rR   r9   r8   r  r  <  s         BB::::8888&&&&&&&& ,59, ,F     *3* *F            r9   r  c                  6    e Zd ZU dZ ede          Zded<   dS )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   r9   r8   r  r  ]  sH         dd""3 C      r9   r  c                  6    e Zd ZU dZ ede          Zded<   dS )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   r9   r8   r#  r#  e  sH         WW##" C      r9   r#  )=rM   
__future__r   rG   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   r9   r8   <module>r0     s?   : : " " " " " " 				 0 0 0 0 0 0 0 0 0 0 * * * * * *            % $ $ $ $ $       8 8 8 8 8 8            
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 " ! ! ! ! ! ! ! .------c c c c c c c c@w
 w
 w
 w
 w
/ w
 w
 w
t;" ;" ;" ;" ;"O ;" ;" ;"|I I I I I I I IX    ?   *    /          "    ?   ?  ?  ?  ?  ?  ?  ?  ? Dk1 k1 k1 k1 k1 k1 k1 k1\    _   B    O       /     r9   