o
    7 h                     @  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 ddlmZmZ ddlmZ dd	lmZ erLdd
lmZ ddlmZmZmZmZ G dd deZdS )z4Presentation part, the main part in a .pptx package.    )annotations)IOTYPE_CHECKINGIterable)RELATIONSHIP_TYPE)XmlPart)PackURI)NotesMasterPart	SlidePart)Presentation)lazyproperty)CorePropertiesPart)NotesMasterSlideSlideLayoutSlideMasterc                   @  s   e Zd ZdZd,ddZed-dd	Zd.ddZed/ddZ	ed0ddZ
edd Zd1ddZd2ddZd3d!d"Zd4d%d&Zd'd( Zed)d* Zd+S )5PresentationPartziTop level class in object model.

    Represents the contents of the /ppt directory of a .pptx file.
    slide_layoutr   c                 C  s4   | j }|j}t|| j|}| |tj}||jfS )z}Return (rId, slide) pair of a newly created blank slide.

        New slide inherits appearance from `slide_layout`.
        )	_next_slide_partnamepartr
   newpackage	relate_toRTSLIDEslide)selfr   partnameZslide_layout_part
slide_partrId r    _/var/www/html/figdemos/bartoux_crm/venv/lib/python3.10/site-packages/pptx/parts/presentation.py	add_slide   s
   
zPresentationPart.add_slidereturnr   c                 C     | j jS )zA |CoreProperties| object for the presentation.

        Provides read/write access to the Dublin Core properties of this presentation.
        )r   core_propertiesr   r    r    r!   r%   $   s   z PresentationPart.core_propertiesslide_idintSlide | Nonec                 C  s.   | j jD ]}|j|kr| |jj  S qdS )zReturn optional related |Slide| object identified by `slide_id`.

        Returns |None| if no slide with `slide_id` is related to this presentation.
        N)_elementsldIdLstidrelated_partr   r   )r   r'   sldIdr    r    r!   	get_slide,   s
   
zPresentationPart.get_slider   c                 C  r$   )z
        Return the |NotesMaster| object for this presentation. If the
        presentation does not have a notes master, one is created from
        a default template. The same single instance is returned on each
        call.
        )notes_master_partnotes_masterr&   r    r    r!   r1   6   s   zPresentationPart.notes_masterr	   c                 C  s@   z|  tjW S  ty   t| j}| |tj | Y S w )zReturn the |NotesMasterPart| object for this presentation.

        If the presentation does not have a notes master, one is created from a default template.
        The same single instance is returned on each call.
        )part_related_byr   NOTES_MASTERKeyErrorr	   Zcreate_defaultr   r   )r   r0   r    r    r!   r0   @   s   z"PresentationPart.notes_master_partc                 C  s   t | j| S )zg
        A |Presentation| object providing access to the content of this
        presentation.
        )r   r*   r&   r    r    r!   presentationN   s   zPresentationPart.presentationr   strr   c                 C     |  |jS )z?Return |Slide| object for related |SlidePart| related by `rId`.)r-   r   r   r   r    r    r!   related_slideV      zPresentationPart.related_slider   c                 C  r7   )zCReturn |SlideMaster| object for |SlideMasterPart| related by `rId`.)r-   Zslide_masterr8   r    r    r!   related_slide_masterZ   r:   z%PresentationPart.related_slide_masterrIdsIterable[str]c                 C  s2   t |D ]\}}| |}td|d  |_qdS )a{  Assign incrementing partnames to the slide parts identified by `rIds`.

        Partnames are like `/ppt/slides/slide9.xml` and are assigned in the order their id appears
        in the `rIds` sequence. The name portion is always `slide`. The number part forms a
        continuous sequence starting at 1 (e.g. 1, 2, ... 10, ...). The extension is always
        `.xml`.
        /ppt/slides/slide%d.xml   N)	enumerater-   r   r   )r   r<   idxr   r   r    r    r!   rename_slide_parts^   s   
z#PresentationPart.rename_slide_partspath_or_streamstr | IO[bytes]c                 C  s   | j | dS )zSave this presentation package to `path_or_stream`.

        `path_or_stream` can be either a path to a filesystem location (a string) or a
        file-like object.
        N)r   save)r   rC   r    r    r!   rE   j   s   zPresentationPart.savec                 C  s0   | j jD ]}| |j|u r|j  S qtd)z1Return the slide-id associated with `slide_part`.zmatching slide_part not found)r*   r+   r-   r   r,   
ValueError)r   r   r.   r    r    r!   r'   r   s
   
zPresentationPart.slide_idc                 C  s"   | j  }dt|d  }t|S )zCReturn |PackURI| instance containing next available slide partname.r>   r?   )r*   get_or_add_sldIdLstlenr   )r   r+   Zpartname_strr    r    r!   r   y   s   
z%PresentationPart._next_slide_partnameN)r   r   )r#   r   )r'   r(   r#   r)   )r#   r   )r#   r	   )r   r6   r#   r   )r   r6   r#   r   )r<   r=   )rC   rD   )__name__
__module____qualname____doc__r"   propertyr%   r/   r   r1   r0   r5   r9   r;   rB   rE   r'   r   r    r    r    r!   r      s&    


	




r   N)rL   
__future__r   typingr   r   r   pptx.opc.constantsr   r   pptx.opc.packager   pptx.opc.packurir   pptx.parts.slider	   r
   Zpptx.presentationr   	pptx.utilr   pptx.parts.corepropsr   Z
pptx.slider   r   r   r   r   r    r    r    r!   <module>   s    