
    li                        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rdd
lmZ ddlmZmZmZmZ  G d de      Zy)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                      e Zd ZdZddZedd       ZddZedd       Z	edd       Z
ed        ZddZdd	Zdd
ZddZd Zed        Zy)PresentationPartziTop level class in object model.

    Represents the contents of the /ppt directory of a .pptx file.
    c                    | j                   }|j                  }t        j                  || j                  |      }| 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)selfslide_layoutpartnameslide_layout_part
slide_partrIds         U/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/pptx/parts/presentation.py	add_slidezPresentationPart.add_slide   sW    
 ,,(--]]8T\\;LM
nnZ2J$$$$    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   s    r$   r(   z PresentationPart.core_properties$   s     ||+++r&   c                    | j                   j                  D ]8  }|j                  |k(  s| j                  |j                        j
                  c S  y)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   slide_idsldIds      r$   	get_slidezPresentationPart.get_slide,   sI    
 ]]++ 	:Exx8#((3999	: r&   c                .    | j                   j                  S )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)   s    r$   r4   zPresentationPart.notes_master6   s     %%222r&   c                    	 | j                  t        j                        S # t        $ rD t	        j
                  | j                        }| j                  |t        j                         |cY S w xY 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
   create_defaultr   r   )r   r3   s     r$   r3   z"PresentationPart.notes_master_part@   sY    	%''88 	% / > >t|| LNN,boo>$$	%s   ! A
A.-A.c                .    t        | j                  |       S )zg
        A |Presentation| object providing access to the content of this
        presentation.
        )r   r+   r)   s    r$   presentationzPresentationPart.presentationN   s     DMM400r&   c                8    | j                  |      j                  S )z?Return |Slide| object for related |SlidePart| related by `rId`.)r.   r   r   r#   s     r$   related_slidezPresentationPart.related_slideV   s      %+++r&   c                8    | j                  |      j                  S )zCReturn |SlideMaster| object for |SlideMasterPart| related by `rId`.)r.   slide_masterr=   s     r$   related_slide_masterz%PresentationPart.related_slide_masterZ   s      %222r&   c                x    t        |      D ],  \  }}| j                  |      }t        d|dz   z        |_        . y)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   rIdsidxr#   r"   s        r$   rename_slide_partsz#PresentationPart.rename_slide_parts^   sD     "$ 	QHC**3/J")*CsQw*O"PJ	Qr&   c                :    | j                   j                  |       y)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   path_or_streams     r$   rJ   zPresentationPart.savej   s     	.)r&   c                    | j                   j                  D ]-  }| j                  |j                        |u s!|j                  c S  t        d      )z1Return the slide-id associated with `slide_part`.zmatching slide_part not found)r+   r,   r.   r#   r-   
ValueError)r   r"   r0   s      r$   r/   zPresentationPart.slide_idr   sI    ]]++ 	 E  +z9xx	  899r&   c                n    | j                   j                         }dt        |      dz   z  }t        |      S )zCReturn |PackURI| instance containing next available slide partname.rC   rD   )r+   get_or_add_sldIdLstlenr	   )r   r,   partname_strs      r$   r   z%PresentationPart._next_slide_partnamey   s4     ==4460CMA4EF|$$r&   N)r   r   )returnr   )r/   intrR   zSlide | None)rR   r   )rR   r
   )r#   strrR   r   )r#   rT   rR   r   )rF   zIterable[str])rK   zstr | IO[bytes])__name__
__module____qualname____doc__r%   propertyr(   r1   r   r4   r3   r;   r>   rA   rH   rJ   r/   r    r&   r$   r   r      s    
	% , , 3 3 % % 1 1,3
Q*: % %r&   r   N)rX   
__future__r   typingr   r   r   pptx.opc.constantsr   r   pptx.opc.packager   pptx.opc.packurir	   pptx.parts.slider
   r   pptx.presentationr   	pptx.utilr   pptx.parts.corepropsr   
pptx.slider   r   r   r   r   rZ   r&   r$   <module>re      s=    : " . . 6 $ $ 7 * "7GGk%w k%r&   