o
    7 ¾hÅ  ã                   @  sÌ   d 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
 ddlmZ ddlmZ ddlmZ erDdd	lmZ dd
lmZ d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dS )zAShapes based on the `p:pic` element, including Picture and Movie.é    )Úannotations)ÚTYPE_CHECKING©Ú
LineFormat)Ú	MSO_SHAPEÚMSO_SHAPE_TYPEÚPP_MEDIA_TYPE)Ú	BaseShape)ÚParentedElementProxy)Úlazyproperty)Ú
CT_Picture)ÚCT_LineProperties)ÚProvidesPartc                      s¾   e Zd ZdZd‡ fdd„Zed d
d„ƒZejd!dd„ƒZed dd„ƒZejd!dd„ƒZed dd„ƒZ	e	jd!dd„ƒZ	ed dd„ƒZ
e
jd!dd„ƒZ
dd„ Zed"dd„ƒZed#dd„ƒZ‡  ZS )$Ú_BasePicturez1Base class for shapes based on a `p:pic` element.Úpicr   Úparentr   c                   s   t t| ƒ ||¡ || _d S ©N)Úsuperr   Ú__init__Ú_pic)Úselfr   r   ©Ú	__class__© ú[/var/www/html/figdemos/bartoux_crm/venv/lib/python3.10/site-packages/pptx/shapes/picture.pyr      s   
z_BasePicture.__init__ÚreturnÚfloatc                 C  ó   | j jS )zÞ|float| representing relative portion cropped from shape bottom.

        Read/write. 1.0 represents 100%. For example, 25% is represented by 0.25. Negative values
        are valid as are values greater than 1.0.
        ©r   Ú	srcRect_b©r   r   r   r   Úcrop_bottom   ó   z_BasePicture.crop_bottomÚvaluec                 C  ó   || j _d S r   r   ©r   r#   r   r   r   r!   #   ó   c                 C  r   )z¹|float| representing relative portion cropped from left of shape.

        Read/write. 1.0 represents 100%. A negative value extends the side beyond the image
        boundary.
        ©r   Ú	srcRect_lr    r   r   r   Ú	crop_left'   r"   z_BasePicture.crop_leftc                 C  r$   r   r'   r%   r   r   r   r)   0   r&   c                 C  r   )zu|float| representing relative portion cropped from right of shape.

        Read/write. 1.0 represents 100%.
        ©r   Ú	srcRect_rr    r   r   r   Ú
crop_right4   ó   z_BasePicture.crop_rightc                 C  r$   r   r*   r%   r   r   r   r,   <   r&   c                 C  r   )zp|float| representing relative portion cropped from shape top.

        Read/write. 1.0 represents 100%.
        ©r   Ú	srcRect_tr    r   r   r   Úcrop_top@   r-   z_BasePicture.crop_topc                 C  r$   r   r.   r%   r   r   r   r0   H   r&   c                 C  s
   | j  ¡ S )z…Return the `a:ln` element for this `p:pic`-based image.

        The `a:ln` element contains the line format properties XML.
        )r   Úget_or_add_lnr    r   r   r   r1   L   s   
z_BasePicture.get_or_add_lnr   c                 C  s   t | ƒS )zRProvides access to properties of the picture outline, such as its color and width.r   r    r   r   r   ÚlineS   s   z_BasePicture.lineúCT_LineProperties | Nonec                 C  r   )z¨The `a:ln` element for this `p:pic`.

        Contains the line format properties such as line color and width. |None| if no `a:ln`
        element is present.
        )r   Úlnr    r   r   r   r4   X   r"   z_BasePicture.ln)r   r   r   r   )r   r   )r#   r   )r   r   )r   r3   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr!   Úsetterr)   r,   r0   r1   r   r2   r4   Ú__classcell__r   r   r   r   r      s0    r   c                   @  sF   e Zd ZdZeddd„ƒZeddd„ƒZed	d
„ ƒZeddd„ƒZ	dS )ÚMoviezùA movie shape, one that places a video on a slide.

    Like |Picture|, a movie shape is based on the `p:pic` element. A movie is composed of a video
    and a *poster frame*, the placeholder image that represents the video before it is played.
    r   Ú_MediaFormatc                 C  s   t | j| ƒS )zThe |_MediaFormat| object for this movie.

        The |_MediaFormat| object provides access to formatting properties for the movie.
        )r=   r   r    r   r   r   Úmedia_formati   s   zMovie.media_formatr   c                 C  ó   t jS )zMember of :ref:`PpMediaType` describing this shape.

        The return value is unconditionally `PP_MEDIA_TYPE.MOVIE` in this case.
        )r   ÚMOVIEr    r   r   r   Ú
media_typeq   s   zMovie.media_typec                 C  s&   | j | jj}}|du rdS | |¡S )zŒReturn |Image| object containing poster frame for this movie.

        Returns |None| if this movie has no poster frame (uncommon).
        N)Úpartr   Úblip_rIdÚ	get_image©r   Ú
slide_partÚrIdr   r   r   Úposter_framey   s   
zMovie.poster_framer   c                 C  r?   )zžReturn member of :ref:`MsoShapeType` describing this shape.

        The return value is unconditionally `MSO_SHAPE_TYPE.MEDIA` in this
        case.
        )r   ÚMEDIAr    r   r   r   Ú
shape_type„   s   zMovie.shape_typeN)r   r=   )r   r   ©r   r   )
r5   r6   r7   r8   r   r>   r9   rA   rH   rJ   r   r   r   r   r<   b   s    

r<   c                   @  sH   e Zd ZdZeddd„ƒZejddd„ƒZed	d
„ ƒZeddd„ƒZdS )ÚPicturez]A picture shape, one that places an image on a slide.

    Based on the `p:pic` element.
    r   úMSO_SHAPE | Nonec                 C  s   | j jj}|du rdS |jS )a  Member of MSO_SHAPE indicating masking shape.

        A picture can be masked by any of the so-called "auto-shapes" available in PowerPoint,
        such as an ellipse or triangle. When a picture is masked by a shape, the shape assumes the
        same dimensions as the picture and the portion of the picture outside the shape boundaries
        does not appear. Note the default value for a newly-inserted picture is
        `MSO_AUTO_SHAPE_TYPE.RECTANGLE`, which performs no cropping because the extents of the
        rectangle exactly correspond to the extents of the picture.

        The available shapes correspond to the members of :ref:`MsoAutoShapeType`.

        The return value can also be |None|, indicating the picture either has no geometry (not
        expected) or has custom geometry, like a freeform shape. A picture with no geometry will
        have no visible representation on the slide, although it can be selected. This is because
        without geometry, there is no "inside-the-shape" for it to appear in.
        N)r   ÚspPrÚprstGeomÚprst)r   rO   r   r   r   Úauto_shape_type”   s   
zPicture.auto_shape_typeÚmemberr   c                 C  s:   t  |¡ | jj}|j}|d u r| ¡  | ¡ }||_d S r   )r   Úvalidater   rN   rO   Ú_remove_custGeomÚ_add_prstGeomrP   )r   rR   rN   rO   r   r   r   rQ   «   s   

c                 C  s*   | j | jj}}|du rtdƒ‚| |¡S )z†The |Image| object for this picture.

        Provides access to the properties and bytes of the image in this picture shape.
        Nzno embedded image)rB   r   rC   Ú
ValueErrorrD   rE   r   r   r   Úimageµ   s   
zPicture.imager   c                 C  r?   )z6Unconditionally `MSO_SHAPE_TYPE.PICTURE` in this case.)r   ÚPICTUREr    r   r   r   rJ   À   s   zPicture.shape_typeN)r   rM   )rR   r   rK   )	r5   r6   r7   r8   r9   rQ   r:   rW   rJ   r   r   r   r   rL   Ž   s    	

rL   c                   @  s   e Zd ZdZdS )r=   zProvides access to formatting properties for a Media object.

    Media format properties are things like start point, volume, and
    compression type.
    N)r5   r6   r7   r8   r   r   r   r   r=   Æ   s    r=   N)r8   Ú
__future__r   Útypingr   Úpptx.dml.liner   Úpptx.enum.shapesr   r   r   Úpptx.shapes.baser	   Úpptx.sharedr
   Ú	pptx.utilr   Úpptx.oxml.shapes.picturer   Úpptx.oxml.shapes.sharedr   Ú
pptx.typesr   r   r<   rL   r=   r   r   r   r   Ú<module>   s     O,8