o
    7 h%,                     @  st  d Z ddlmZ ddlmZmZmZ ddlmZ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 erHdd	lm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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$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 )'zBSlide-related custom element classes, including those for masters.    )annotations)TYPE_CHECKINGCallablecast)parse_from_template	parse_xml)CT_GradientFillPropertiesnsdecls)	XsdString)BaseOxmlElementChoiceOneAndOnlyOneOptionalAttributeRequiredAttribute
ZeroOrMore	ZeroOrOneZeroOrOneChoice)CT_GroupShapec                   @  s(   e Zd ZU dZded< ed	ddZdS )
_BaseSlideElementz=Base class for the six slide types, providing common methods.CT_CommonSlideDatacSldreturnr   c                 C     | j jS )z-Return required `p:cSld/p:spTree` grandchild.)r   spTreeself r   W/var/www/html/figdemos/bartoux_crm/venv/lib/python3.10/site-packages/pptx/oxml/slide.pyr         z_BaseSlideElement.spTreeN)r   r   )__name__
__module____qualname____doc____annotations__propertyr   r   r   r   r   r      s
   
 r   c                   @  sH   e Zd ZU dZded< dZedddZded	< ed
ddZ[dd Z	dS )CT_Backgroundz`p:bg` element.z)Callable[[CT_BackgroundProperties], None]_insert_bgPr)p:bgPrp:bgRefr(   r   
successorszCT_BackgroundProperties | NonebgPrr)   c                 C  s*   dt dd }ttt|}| | |S )z5Return a new `p:bgPr` element with noFill properties.z4<p:bgPr %s>
  <a:noFill/>
  <a:effectLst/>
</p:bgPr>ap)r
   r   CT_BackgroundPropertiesr   r'   )r   xmlr,   r   r   r   add_noFill_bgPr3   s   
zCT_Background.add_noFill_bgPrN)
r    r!   r"   r#   r$   _tag_seqr   r,   ZbgRefr1   r   r   r   r   r&   %   s   
 r&   c                   @  sV   e Zd ZdZdZeededededededfed	d
 dZ[dd Zd
S )r/   z`p:bgPr` element.)	a:noFilla:solidFill
a:gradFill
a:blipFill
a:pattFill	a:grpFillza:effectLstza:effectDagza:extLstr3   r4   r5   r6   r7   r8      Nr*   c                 C  s   t  S )z1Override default to add default gradient subtree.)r   new_gradFillr   r   r   r   _new_gradFillV   s   z%CT_BackgroundProperties._new_gradFill)	r    r!   r"   r#   r2   r   r   eg_fillPropertiesr;   r   r   r   r   r/   ;   s    
r/   c                   @  s~   e Zd ZU dZded< ded< dZededd	 d
Zded< edZ	ded< [e
deddZded< dddZdddZd	S )r   z`p:cSld` element.zCallable[[], None]
_remove_bgzCallable[[], CT_Background]get_or_add_bg)p:bgp:spTreezp:custDataLstz
p:controlsp:extLstr?      Nr*   zCT_Background | Nonebgr@   r   r   name )defaultstrr   r/   c                 C  s,   | j }|du s|jdu r|  }tt|jS )zReturn `p:bg/p:bgPr` grandchild.

        If no such grandchild is present, any existing `p:bg` child is first removed and a new
        default `p:bg` with noFill settings is added.
        N)rC   r,   _change_to_noFill_bgr   r/   r   rC   r   r   r   get_or_add_bgPrk   s   z"CT_CommonSlideData.get_or_add_bgPrr&   c                 C  s   |    |  }|  |S )zmEstablish a `p:bg` child with no-fill settings.

        Any existing `p:bg` child is first removed.
        )r=   r>   r1   rI   r   r   r   rH   v   s   z'CT_CommonSlideData._change_to_noFill_bg)r   r/   )r   r&   )r    r!   r"   r#   r$   r2   r   rC   r   r   r   r   rD   rJ   rH   r   r   r   r   r   [   s   
 
r   c                   @  6   e Zd ZU dZdZedZded< [ed
ddZ	d	S )CT_NotesMasterz5`p:notesMaster` element, root of a notes master part.)p:cSldp:clrMapp:hfzp:notesStylerA   rM   r   r   r   c                 C     t ttdS )zLReturn a new `p:notesMaster` element based on the built-in default template.ZnotesMaster)r   rL   r   clsr   r   r   new_default   s   zCT_NotesMaster.new_defaultN)r   rL   )
r    r!   r"   r#   r2   r   r   r$   classmethodrS   r   r   r   r   rL         
 rL   c                   @  rK   )CT_NotesSlidez.`p:notes` element, root of a notes slide part.)rM   p:clrMapOvrrA   rM   r   r   r   c                 C  rP   )zReturn a new ``<p:notes>`` element based on the default template.

        Note that the template does not include placeholders, which must be subsequently cloned
        from the notes master.
        Znotes)r   rV   r   rQ   r   r   r   new   s   zCT_NotesSlide.newN)r   rV   )
r    r!   r"   r#   r2   r   r   r$   rT   rX   r   r   r   r   rV      rU   rV   c                   @  s   e Zd ZU dZdZedZded< ededd d	Z	ed
edd d	Z
[edddZedd Zdd Zdd Zedd Zedd Zedd ZdS )CT_Slidez=`p:sld` element, root element of a slide part (XML document).)rM   rW   p:transitionp:timingrA   rM   r   r   rW      Nr*   r[      r   c                 C  s   t tt|  S )z:Return new `p:sld` element configured as base slide shape.)r   rY   r   _sld_xmlrQ   r   r   r   rX      s   zCT_Slide.newc                 C  r   )z0Return `p:bg` grandchild or None if not present.)r   rC   r   r   r   r   rC      r   zCT_Slide.bgc                 C  s   | j }|du r|  }|S )a  Return parent element for a new `p:video` child element.

        The `p:video` element causes play controls to appear under a video
        shape (pic shape containing video). There can be more than one video
        shape on a slide, which causes the precondition to vary. It needs to
        handle the case when there is no `p:sld/p:timing` element and when
        that element already exists. If the case isn't simple, it just nukes
        what's there and adds a fresh one. This could theoretically remove
        desired existing timing information, but there isn't any evidence
        available to me one way or the other, so I've taken the simple
        approach.
        N)_childTnLst_add_childTnLst)r   Z
childTnLstr   r   r   get_or_add_childTnLst   s   zCT_Slide.get_or_add_childTnLstc                 C  s2   |  |   t|  }| | |dd S )zAdd `./p:timing/p:tnLst/p:par/p:cTn/p:childTnLst` descendant.

        Any existing `p:timing` child element is ruthlessly removed and
        replaced.
        z"./p:tnLst/p:par/p:cTn/p:childTnLstr   )removeZget_or_add_timingr   _childTnLst_timing_xmlZ_insert_timingxpath)r   timingr   r   r   r`      s   
zCT_Slide._add_childTnLstc                 C  s   |  d}|s	dS |d S )z~Return `./p:timing/p:tnLst/p:par/p:cTn/p:childTnLst` descendant.

        Return None if that element is not present.
        z+./p:timing/p:tnLst/p:par/p:cTn/p:childTnLstNr   )rd   )r   ZchildTnLstsr   r   r   r_      s   
zCT_Slide._childTnLstc                   C  s   dt d S )Nz<p:timing %s>
  <p:tnLst>
    <p:par>
      <p:cTn id="1" dur="indefinite" restart="never" nodeType="tmRoot">
        <p:childTnLst/>
      </p:cTn>
    </p:par>
  </p:tnLst>
</p:timing>r.   r	   r   r   r   r   rc      s   	zCT_Slide._childTnLst_timing_xmlc                   C  s   dt ddd S )Na  <p:sld %s>
  <p:cSld>
    <p:spTree>
      <p:nvGrpSpPr>
        <p:cNvPr id="1" name=""/>
        <p:cNvGrpSpPr/>
        <p:nvPr/>
      </p:nvGrpSpPr>
      <p:grpSpPr/>
    </p:spTree>
  </p:cSld>
  <p:clrMapOvr>
    <a:masterClrMapping/>
  </p:clrMapOvr>
</p:sld>r-   r.   rr	   r   r   r   r   r^      s   
zCT_Slide._sld_xml)r   rY   )r    r!   r"   r#   r2   r   r   r$   r   Z	clrMapOvrre   rT   rX   r%   rC   ra   r`   r_   staticmethodrc   r^   r   r   r   r   rY      s&   
 



rY   c                   @  s(   e Zd ZU dZdZedZded< [dS )CT_SlideLayoutz3`p:sldLayout` element, root of a slide layout part.)rM   rW   rZ   r[   rO   rA   rM   r   r   N)r    r!   r"   r#   r2   r   r   r$   r   r   r   r   rh      s
   
 rh   c                   @  s"   e Zd ZU dZded< edZdS )CT_SlideLayoutIdListz`p:sldLayoutIdLst` element, child of `p:sldMaster`.

    Contains references to the slide layouts that inherit from the slide master.
    zlist[CT_SlideLayoutIdListEntry]ZsldLayoutId_lstzp:sldLayoutIdN)r    r!   r"   r#   r$   r   ZsldLayoutIdr   r   r   r   ri     s   
 ri   c                   @  s$   e Zd ZU dZedeZded< dS )CT_SlideLayoutIdListEntryzg`p:sldLayoutId` element, child of `p:sldLayoutIdLst`.

    Contains a reference to a slide layout.
    zr:idrG   rIdN)r    r!   r"   r#   r   r   rk   r$   r   r   r   r   rj     s   
 rj   c                   @  sL   e Zd ZU dZded< dZedZded< eded	d
 dZ	ded< [d
S )CT_SlideMasterz3`p:sldMaster` element, root of a slide master part.z"Callable[[], CT_SlideLayoutIdList]Zget_or_add_sldLayoutIdLst)rM   rN   p:sldLayoutIdLstrZ   r[   rO   z
p:txStylesrA   rM   r   r   rm      Nr*   ri   sldLayoutIdLst)
r    r!   r"   r#   r$   r2   r   r   r   ro   r   r   r   r   rl     s   
 
rl   c                   @  s*   e Zd ZdZdZededd dZ[dS )CT_SlideTimingz>`p:timing` element, specifying animations and timed behaviors.)p:tnLstzp:bldLstrA   rq   rB   Nr*   )r    r!   r"   r#   r2   r   ZtnLstr   r   r   r   rp   0  s
    rp   c                   @  s$   e Zd ZdZdd Zedd ZdS )CT_TimeNodeListz%`p:tnLst` or `p:childTnList` element.c                 C  s*   dt d| j|f }t|}| | dS )z>Add a new `p:video` child element for movie having *shape_id*.a  <p:video %s>
  <p:cMediaNode vol="80000">
    <p:cTn id="%d" fill="hold" display="0">
      <p:stCondLst>
        <p:cond delay="indefinite"/>
      </p:stCondLst>
    </p:cTn>
    <p:tgtEl>
      <p:spTgt spid="%d"/>
    </p:tgtEl>
  </p:cMediaNode>
</p:video>
r.   N)r
   _next_cTn_idr   append)r   shape_idZ	video_xmlZvideor   r   r   	add_video;  s   zCT_TimeNodeList.add_videoc                 C  s$   |  d}dd |D }t|d S )z<Return the next available unique ID (int) for p:cTn element.z/p:sld/p:timing//p:cTn/@idc                 S  s   g | ]}t |qS r   )int).0id_strr   r   r   
<listcomp>R  s    z0CT_TimeNodeList._next_cTn_id.<locals>.<listcomp>rB   )rd   max)r   ZcTn_id_strsidsr   r   r   rs   N  s   
zCT_TimeNodeList._next_cTn_idN)r    r!   r"   r#   rv   r%   rs   r   r   r   r   rr   8  s
    rr   c                   @  s   e Zd ZdZdZedZ[dS )CT_TLMediaNodeVideoz2`p:video` element, specifying video media details.)p:cMediaNoder~   N)r    r!   r"   r#   r2   r   Z
cMediaNoder   r   r   r   r}   V  s
    r}   N))r#   
__future__r   typingr   r   r   	pptx.oxmlr   r   pptx.oxml.dml.fillr   pptx.oxml.nsr
   pptx.oxml.simpletypesr   pptx.oxml.xmlchemyr   r   r   r   r   r   r   r   pptx.oxml.shapes.groupshaper   r   r&   r/   r   rL   rV   rY   rh   ri   rj   rl   rp   rr   r}   r   r   r   r   <module>   s0    ( &_	