o
    7 hI                     @  s  d Z ddlmZ ddlmZmZ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 ddlmZmZmZ ddlmZ erdd	lmZmZ dd
lmZmZm Z m!Z!m"Z" ddl#m$Z$ ddl%m&Z&m'Z'm(Z( ddl)m*Z* ddl+m,Z,m-Z- ddlm.Z. ddl/m0Z0 G dd deZ1G dd de1Z2G dd de2Z3G dd de1Z4G dd de1Z5G dd deZ6G dd de1Z7G dd  d eZ8G d!d" d"e2Z9G d#d$ d$eZ:G d%d& d&eZ;d'S )(z=Slide-related objects, including masters, layouts, and notes.    )annotations)TYPE_CHECKINGIteratorcast)
FillFormat)PP_PLACEHOLDER)LayoutPlaceholdersLayoutShapesMasterPlaceholdersMasterShapesNotesSlidePlaceholdersNotesSlideShapesSlidePlaceholdersSlideShapes)ElementProxyParentedElementProxyPartElementProxy)lazyproperty)CT_SlideIdListCT_SlideMasterIdList)CT_CommonSlideDataCT_NotesSlideCT_SlideCT_SlideLayoutIdListCT_SlideMaster)PresentationPart)SlideLayoutPartSlideMasterPart	SlidePart)Presentation)LayoutPlaceholderMasterPlaceholder)NotesSlidePlaceholder)	TextFramec                   @  sF   e Zd ZU dZded< edddZedd	d
Zej	ddd
ZdS )
_BaseSlidezCBase class for slide objects, including masters, layouts and notes.r   _elementreturn_Backgroundc                 C  s   t | jjS )a8  |_Background| object providing slide background properties.

        This property returns a |_Background| object whether or not the
        slide, master, or layout has an explicitly defined background.

        The same |_Background| object is returned on every call for the same
        slide object.
        )r'   r%   cSldself r+   R/var/www/html/figdemos/bartoux_crm/venv/lib/python3.10/site-packages/pptx/slide.py
background,   s   
z_BaseSlide.backgroundstrc                 C  s
   | j jjS )zString representing the internal name of this slide.

        Returns an empty string (`''`) if no name is assigned. Assigning an empty string or |None|
        to this property causes any name to be removed.
        r%   r(   namer)   r+   r+   r,   r0   8   s   
z_BaseSlide.namevalue
str | Nonec                 C  s   |d u rdn|}|| j j_d S )N r/   )r*   r1   	new_valuer+   r+   r,   r0   A   s   N)r&   r'   )r&   r.   )r1   r2   )
__name__
__module____qualname____doc____annotations__r   r-   propertyr0   setterr+   r+   r+   r,   r$   '   s   
 r$   c                   @  s*   e Zd ZdZed	ddZedd ZdS )
_BaseMasterzBase class for master objects such as |SlideMaster| and |NotesMaster|.

    Provides access to placeholders and regular shapes.
    r&   r
   c                 C     t | jj| S )zw|MasterPlaceholders| collection of placeholder shapes in this master.

        Sequence sorted in `idx` order.
        )r
   r%   spTreer)   r+   r+   r,   placeholdersM      z_BaseMaster.placeholdersc                 C  r=   )zr
        Instance of |MasterShapes| containing sequence of shape objects
        appearing on this slide.
        )r   r%   r>   r)   r+   r+   r,   shapesU   r@   z_BaseMaster.shapesN)r&   r
   )r5   r6   r7   r8   r   r?   rA   r+   r+   r+   r,   r<   G   s    r<   c                   @  s   e Zd ZdZdS )NotesMasterzProxy for the notes master XML document.

    Provides access to shapes, the most commonly used of which are placeholders.
    N)r5   r6   r7   r8   r+   r+   r+   r,   rB   ^   s    rB   c                   @  s\   e Zd ZU dZded< ddd	ZedddZedddZe	dddZ
e	dddZdS )
NotesSlidezxNotes slide object.

    Provides access to slide notes placeholder and other shapes on the notes handout
    page.
    r   elementnotes_masterrB   r&   Nonec                   s4   d fdd}| j }| D ]
}|td| qdS )a3  Selectively add placeholder shape elements from `notes_master`.

        Selected placeholder shape elements from `notes_master` are added to the shapes
        collection of this notes slide. Z-order of placeholders is preserved. Certain
        placeholders (header, date, footer) are not cloned.
        r&   Iterator[MasterPlaceholder]c                  3  s4    t jt jt jf}  jD ]}|jj| v r|V  qdS )zGenerate a reference to each cloneable placeholder in `notes_master`.

            These are the placeholders that should be cloned to a notes slide when the a new notes
            slide is created.
            N)r   SLIDE_IMAGEBODYSLIDE_NUMBERr?   rD   ph_type)Z	cloneableplaceholderrE   r+   r,   iter_cloneable_placeholdersv   s   
zINotesSlide.clone_master_placeholders.<locals>.iter_cloneable_placeholdersr    N)r&   rG   )rA   Zclone_placeholderr   )r*   rE   rN   rA   rL   r+   rM   r,   clone_master_placeholdersn   s
   
z$NotesSlide.clone_master_placeholdersNotesSlidePlaceholder | Nonec                 C  s&   | j D ]}|jjtjkr|  S qdS )aU  the notes placeholder on this notes slide, the shape that contains the actual notes text.

        Return |None| if no notes placeholder is present; while this is probably uncommon, it can
        happen if the notes master does not have a body placeholder, or if the notes placeholder
        has been deleted from the notes slide.
        N)r?   Zplaceholder_formattyper   rI   )r*   rL   r+   r+   r,   notes_placeholder   s
   
zNotesSlide.notes_placeholderTextFrame | Nonec                 C  s   | j }|du r	dS |jS )zThe text frame of the notes placeholder on this notes slide.

        |None| if there is no notes placeholder. This is a shortcut to accommodate the common case
        of simply adding "notes" text to the notes "page".
        N)rR   
text_frame)r*   rR   r+   r+   r,   notes_text_frame   s   zNotesSlide.notes_text_framer   c                 C  r=   )zInstance of |NotesSlidePlaceholders| for this notes-slide.

        Contains the sequence of placeholder shapes in this notes slide.
        )r   rD   r>   r)   r+   r+   r,   r?      r@   zNotesSlide.placeholdersr   c                 C  r=   )z8Sequence of shape objects appearing on this notes slide.)r   r%   r>   r)   r+   r+   r,   rA         zNotesSlide.shapesN)rE   rB   r&   rF   )r&   rP   )r&   rS   )r&   r   )r&   r   )r5   r6   r7   r8   r9   rO   r:   rR   rU   r   r?   rA   r+   r+   r+   r,   rC   e   s   
 
rC   c                   @  sz   e Zd ZU dZded< edd Zeddd	ZedddZe	dddZ
e	dddZedddZedddZdS ) SlidezCSlide object. Provides access to shapes and slide-level properties.r   partc                 C  s   | j jdu S )a  |True| if this slide inherits the slide master background.

        Assigning |False| causes background inheritance from the master to be
        interrupted; if there is no custom background for this slide,
        a default background is added. If a custom background already exists
        for this slide, assigning |False| has no effect.

        Assigning |True| causes any custom background for this slide to be
        deleted and inheritance from the master restored.
        N)r%   bgr)   r+   r+   r,   follow_master_background   s   zSlide.follow_master_backgroundr&   boolc                 C     | j jS )z`True` if this slide has a notes slide, `False` otherwise.

        A notes slide is created by :attr:`.notes_slide` when one doesn't exist; use this property
        to test for a notes slide without the possible side effect of creating one.
        )rX   has_notes_slider)   r+   r+   r,   r]         zSlide.has_notes_sliderC   c                 C  r\   )zThe |NotesSlide| instance for this slide.

        If the slide does not have a notes slide, one is created. The same single instance is
        returned on each call.
        )rX   notes_slider)   r+   r+   r,   r_      r^   zSlide.notes_slider   c                 C  r=   )z-Sequence of placeholder shapes in this slide.)r   r%   r>   r)   r+   r+   r,   r?      rV   zSlide.placeholdersr   c                 C  r=   )z2Sequence of shape objects appearing on this slide.)r   r%   r>   r)   r+   r+   r,   rA      rV   zSlide.shapesintc                 C  r\   )zInteger value that uniquely identifies this slide within this presentation.

        The slide id does not change if the position of this slide in the slide sequence is changed
        by adding, rearranging, or deleting slides.
        )rX   slide_idr)   r+   r+   r,   ra      r^   zSlide.slide_idSlideLayoutc                 C  r\   )z9|SlideLayout| object this slide inherits appearance from.)rX   slide_layoutr)   r+   r+   r,   rc         zSlide.slide_layoutN)r&   r[   )r&   rC   )r&   r   )r&   r   r&   r`   )r&   rb   )r5   r6   r7   r8   r9   r:   rZ   r]   r_   r   r?   rA   ra   rc   r+   r+   r+   r,   rW      s"   
 
rW   c                      sj   e Zd ZU dZded< d" fdd	Zd#ddZd$ddZd%ddZd&ddZ	d'd(ddZ
d)d d!Z  ZS )*SlideszSequence of slides belonging to an instance of |Presentation|.

    Has list semantics for access to individual slides. Supports indexed access, len(), and
    iteration.
    r   rX   sldIdLstr   prsr   c                      t t| || || _d S N)superrf   __init__	_sldIdLst)r*   rg   rh   	__class__r+   r,   rl         
zSlides.__init__idxr`   r&   rW   c                 C  6   z| j j| }W n ty   tdw | j|jS )z+Provide indexed access, (e.g. 'slides[0]').zslide index out of range)rm   	sldId_lst
IndexErrorrX   related_sliderId)r*   rq   sldIdr+   r+   r,   __getitem__      zSlides.__getitem__Iterator[Slide]c                 c  $    | j jD ]
}| j|jV  qdS )z/Support iteration, e.g. `for slide in slides:`.N)rm   rs   rX   ru   rv   )r*   rw   r+   r+   r,   __iter__     zSlides.__iter__c                 C  
   t | jS z9Support len() built-in function, e.g. `len(slides) == 4`.)lenrm   r)   r+   r+   r,   __len__     
zSlides.__len__rc   rb   c                 C  s,   | j |\}}|j| | j| |S )zDReturn a newly added slide that inherits layout from `slide_layout`.)rX   	add_sliderA   Zclone_layout_placeholdersrm   	add_sldId)r*   rc   rv   slider+   r+   r,   r     s   zSlides.add_slideNra   defaultSlide | Nonec                 C  s   | j |}|du r|S |S )zuReturn the slide identified by int `slide_id` in this presentation.

        Returns `default` if not found.
        N)rX   	get_slide)r*   ra   r   r   r+   r+   r,   get  s   z
Slides.getr   c                 C  s.   t | D ]\}}||kr|  S qtd| )z|Map `slide` to its zero-based position in this slide sequence.

        Raises |ValueError| on *slide* not present.
        z%s is not in slide collection	enumerate
ValueError)r*   r   rq   Z
this_slider+   r+   r,   index  s
   zSlides.index)rg   r   rh   r   )rq   r`   r&   rW   )r&   rz   re   )rc   rb   r&   rW   rj   )ra   r`   r   r   r&   r   )r   rW   r&   r`   )r5   r6   r7   r8   r9   rl   rx   r|   r   r   r   r   __classcell__r+   r+   rn   r,   rf      s   
 




rf   c                   @  sZ   e Zd ZU dZded< dddZedd	d
ZedddZe	dddZ
e	dd ZdS )rb   zrSlide layout object.

    Provides access to placeholders, regular shapes, and slide layout-level properties.
    r   rX   r&   Iterator[LayoutPlaceholder]c                 c  s4    t jt jt jf}| jD ]}|jj|vr|V  qdS )zGenerate layout-placeholders on this slide-layout that should be cloned to a new slide.

        Used when creating a new slide from this slide-layout.
        N)r   DATEFOOTERrJ   r?   rD   rK   )r*   Zlatent_ph_typesphr+   r+   r,   rN   0  s   
z'SlideLayout.iter_cloneable_placeholdersr   c                 C  r=   )zjSequence of placeholder shapes in this slide layout.

        Placeholders appear in `idx` order.
        )r   r%   r>   r)   r+   r+   r,   r?   >  r@   zSlideLayout.placeholdersr	   c                 C  r=   )z2Sequence of shapes appearing on this slide layout.)r	   r%   r>   r)   r+   r+   r,   rA   F  rV   zSlideLayout.shapesSlideMasterc                 C  r\   )z>Slide master from which this slide-layout inherits properties.)rX   slide_masterr)   r+   r+   r,   r   K  rd   zSlideLayout.slide_masterc                   s$    j jjjj}t fdd|D S )z2Tuple of slide objects based on this slide layout.c                 3  s    | ]
}|j  kr|V  qd S rj   )rc   ).0sr)   r+   r,   	<genexpr>U  s    z-SlideLayout.used_by_slides.<locals>.<genexpr>)rX   packagepresentation_partpresentationslidestuple)r*   r   r+   r)   r,   used_by_slidesP  s   zSlideLayout.used_by_slidesN)r&   r   )r&   r   )r&   r	   )r&   r   )r5   r6   r7   r8   r9   rN   r   r?   rA   r:   r   r   r+   r+   r+   r,   rb   (  s   
 
rb   c                      sj   e Zd ZU dZded< d" fdd	Zd#ddZd$ddZd%ddZd&d'ddZ	d(ddZ
d)d d!Z  ZS )*SlideLayoutszSequence of slide layouts belonging to a slide-master.

    Supports indexed access, len(), iteration, index() and remove().
    r   rX   sldLayoutIdLstr   parentr   c                   ri   rj   )rk   r   rl   _sldLayoutIdLst)r*   r   r   rn   r+   r,   rl   `  rp   zSlideLayouts.__init__rq   r`   r&   rb   c                 C  rr   )z1Provides indexed access, e.g. `slide_layouts[2]`.zslide layout index out of range)r   sldLayoutId_lstrt   rX   related_slide_layoutrv   )r*   rq   sldLayoutIdr+   r+   r,   rx   d  ry   zSlideLayouts.__getitem__Iterator[SlideLayout]c                 c  r{   )z;Generate each |SlideLayout| in the collection, in sequence.N)r   r   rX   r   rv   )r*   r   r+   r+   r,   r|   l  r}   zSlideLayouts.__iter__c                 C  r~   r   )r   r   r)   r+   r+   r,   r   q  r   zSlideLayouts.__len__Nr0   r.   r   SlideLayout | Nonec                 C  s    | D ]}|j |kr|  S q|S )zCReturn SlideLayout object having `name`, or `default` if not found.)r0   )r*   r0   r   rc   r+   r+   r,   get_by_nameu  s
   
zSlideLayouts.get_by_namerc   c                 C  s*   t | D ]\}}||kr|  S qtd)zReturn zero-based index of `slide_layout` in this collection.

        Raises `ValueError` if `slide_layout` is not present in this collection.
        z*layout not in this SlideLayouts collectionr   )r*   rc   rq   Zthis_layoutr+   r+   r,   r   |  s
   zSlideLayouts.indexrF   c                 C  sD   |j rtd| |}| jj| }| j| |jj|j	 dS )zRemove `slide_layout` from the collection.

        Raises ValueError when `slide_layout` is in use; a slide layout which is the basis for one
        or more slides cannot be removed.
        z7cannot remove slide-layout in use by one or more slidesN)
r   r   r   r   r   remover   rX   drop_relrv   )r*   rc   Z
target_idxZtarget_sldLayoutIdr+   r+   r,   r     s   
zSlideLayouts.remove)r   r   r   r   )rq   r`   r&   rb   )r&   r   re   rj   )r0   r.   r   r   r&   r   )rc   rb   r&   r`   )rc   rb   r&   rF   )r5   r6   r7   r8   r9   rl   rx   r|   r   r   r   r   r   r+   r+   rn   r,   r   X  s   
 




r   c                   @  s(   e Zd ZU dZded< ed	ddZdS )
r   zSlide master object.

    Provides access to slide layouts. Access to placeholders, regular shapes, and slide master-level
    properties is inherited from |_BaseMaster|.
    r   r%   r&   r   c                 C  s   t | j | S )zF|SlideLayouts| object providing access to this slide-master's layouts.)r   r%   get_or_add_sldLayoutIdLstr)   r+   r+   r,   slide_layouts  s   zSlideMaster.slide_layoutsN)r&   r   )r5   r6   r7   r8   r9   r   r   r+   r+   r+   r,   r     s
   
 r   c                      sF   e Zd ZU dZded< d fdd	ZdddZdd Zdd Z  Z	S )SlideMasterszSequence of |SlideMaster| objects belonging to a presentation.

    Has list access semantics, supporting indexed access, len(), and iteration.
    r   rX   sldMasterIdLstr   r   r   c                   ri   rj   )rk   r   rl   _sldMasterIdLst)r*   r   r   rn   r+   r,   rl     rp   zSlideMasters.__init__rq   r`   r&   r   c                 C  rr   )z1Provides indexed access, e.g. `slide_masters[2]`.zslide master index out of range)r   sldMasterId_lstrt   rX   related_slide_masterrv   )r*   rq   sldMasterIdr+   r+   r,   rx     ry   zSlideMasters.__getitem__c                 c  r{   )zDGenerate each |SlideMaster| instance in the collection, in sequence.N)r   r   rX   r   rv   )r*   Zsmir+   r+   r,   r|     r}   zSlideMasters.__iter__c                 C  r~   )z@Support len() built-in function, e.g. `len(slide_masters) == 4`.)r   r   r)   r+   r+   r,   r     r   zSlideMasters.__len__)r   r   r   r   )rq   r`   r&   r   )
r5   r6   r7   r8   r9   rl   rx   r|   r   r   r+   r+   rn   r,   r     s   
 
r   c                      s.   e Zd ZdZd fddZedd Z  ZS )	r'   zProvides access to slide background properties.

    Note that the presence of this object does not by itself imply an
    explicitly-defined background; a slide with an inherited background still
    has a |_Background| object.
    r(   r   c                   s   t t| | || _d S rj   )rk   r'   rl   _cSld)r*   r(   rn   r+   r,   rl     s   
z_Background.__init__c                 C  s   | j  }t|S )a  |FillFormat| instance for this background.

        This |FillFormat| object is used to interrogate or specify the fill
        of the slide background.

        Note that accessing this property is potentially destructive. A slide
        background can also be specified by a background style reference and
        accessing this property will remove that reference, if present, and
        replace it with NoFill. This is frequently the case for a slide
        master background.

        This is also the case when there is no explicitly defined background
        (background is inherited); merely accessing this property will cause
        the background to be set to NoFill and the inheritance link will be
        interrupted. This is frequently the case for a slide background.

        Of course, if you are accessing this property in order to set the
        fill, then these changes are of no consequence, but the existing
        background cannot be reliably interrogated using this property unless
        you have already established it is an explicit fill.

        If the background is already a fill, then accessing this property
        makes no changes to the current background.
        )r   get_or_add_bgPrr   from_fill_parent)r*   bgPrr+   r+   r,   fill  s   

z_Background.fill)r(   r   )r5   r6   r7   r8   rl   r   r   r   r+   r+   rn   r,   r'     s
    r'   N)<r8   
__future__r   typingr   r   r   pptx.dml.fillr   pptx.enum.shapesr   Zpptx.shapes.shapetreer   r	   r
   r   r   r   r   r   pptx.sharedr   r   r   	pptx.utilr   pptx.oxml.presentationr   r   pptx.oxml.slider   r   r   r   r   pptx.parts.presentationr   pptx.parts.slider   r   r   pptx.presentationr   Zpptx.shapes.placeholderr    r!   r"   pptx.text.textr#   r$   r<   rB   rC   rW   rf   rb   r   r   r   r'   r+   r+   r+   r,   <module>   s8    (
 K>:0F