
    liT!                        d Z ddl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 ddlmZmZ erdd	lmZ dd
lmZ  G d de      Z G d de      Zy)z=lxml custom element classes for picture-related XML elements.    )annotations)TYPE_CHECKINGcast)escape)	parse_xmlnsdecls)BaseShapeElement)BaseOxmlElementOneAndOnlyOne)CT_ShapeProperties)Lengthc                     e Zd ZU dZ ed      Z ed      Z ed      Zded<   e	dd       Z
d Zd	 Ze	d
        Zed        Zed        Ze	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Ze	d        Zej&                  d        Ze	d        Zej&                  d        Ze	d        Zej&                  d        Ze	d        Zej&                  d        Zd Zed        Zed        Zed        Zd Zy)
CT_PicturezV`p:pic` element.

    Represents a picture shape (an image placement on a slide).
    z	p:nvPicPrz
p:blipFillzp:spPrr   spPrc                d    | j                   j                  }||j                  |j                  S y)zWValue of `p:blipFill/a:blip/@r:embed`.

        Returns |None| if not present.
        N)blipFillbliprEmbed)selfr   s     V/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/pptx/oxml/shapes/picture.pyblip_rIdzCT_Picture.blip_rId   s/     }}!! 7;;    c                Z    | j                   j                  | j                  ||             y)z
        Set cropping values in `p:blipFill/a:srcRect` such that an image of
        *image_size* will stretch to exactly fit *view_size* when its aspect
        ratio is preserved.
        N)r   crop_fill_cropping)r   
image_size	view_sizes      r   crop_to_fitzCT_Picture.crop_to_fit'   s#     	4..z9EFr   c                6    | j                   j                         S )zS
        Return the <a:ln> grandchild element, newly added if not present.
        )r   get_or_add_lnr   s    r   r!   zCT_Picture.get_or_add_ln/   s     yy&&((r   c                .    | j                   j                  S )zI
        ``<a:ln>`` grand-child element or |None| if not present
        )r   lnr"   s    r   r$   zCT_Picture.ln5   s    
 yy||r   c                B    t        | j                         ||||fz        S )zj
        Return a new `p:pic` placeholder element populated with the supplied
        parameters.
        )r   _pic_ph_tmpl)clsid_namedescrIds        r   
new_ph_piczCT_Picture.new_ph_pic<   s&     ))+sD$.DDEEr   c	                \    t        | j                         ||t        |      |||||fz        S )zFReturn new `<p:pic>` element tree configured with supplied parameters.)r   	_pic_tmplr   )	r'   shape_idr)   r*   r+   xycxcys	            r   new_piczCT_Picture.new_picD   s2     HdF4L#qRSUWY[+\\]]r   c
                h    t        t        t        | j                         |||||||||	f	z              S )z8Return a new `p:pic` populated with the specified video.)r   r   r   _pic_video_tmpl)
r'   r/   
shape_name	video_rId	media_rIdposter_frame_rIdr0   r1   r2   r3   s
             r   new_video_piczCT_Picture.new_video_picI   sM     ##%$

 	
r   c                $    | j                  d      S )z9Value of `p:blipFill/a:srcRect/@b` or 0.0 if not present.b
_srcRect_xr"   s    r   	srcRect_bzCT_Picture.srcRect_bi        s##r   c                B    || j                   j                         _        y N)r   get_or_add_srcRectr=   r   values     r   r@   zCT_Picture.srcRect_bn       /4((*,r   c                $    | j                  d      S )z9Value of `p:blipFill/a:srcRect/@l` or 0.0 if not present.lr>   r"   s    r   	srcRect_lzCT_Picture.srcRect_lr   rA   r   c                B    || j                   j                         _        y rC   )r   rD   rI   rE   s     r   rJ   zCT_Picture.srcRect_lw   rG   r   c                $    | j                  d      S )z9Value of `p:blipFill/a:srcRect/@r` or 0.0 if not present.rr>   r"   s    r   	srcRect_rzCT_Picture.srcRect_r{   rA   r   c                B    || j                   j                         _        y rC   )r   rD   rM   rE   s     r   rN   zCT_Picture.srcRect_r   rG   r   c                $    | j                  d      S )z9Value of `p:blipFill/a:srcRect/@t` or 0.0 if not present.tr>   r"   s    r   	srcRect_tzCT_Picture.srcRect_t   rA   r   c                B    || j                   j                         _        y rC   )r   rD   rQ   rE   s     r   rR   zCT_Picture.srcRect_t   rG   r   c                v    d } || } || }||k  rd||z  z
  dz  }|d|dfS ||kD  rd||z  z
  dz  }d|d|fS y)am  
        Return a (left, top, right, bottom) 4-tuple containing the cropping
        values required to display an image of *image_size* in *view_size*
        when stretched proportionately. Each value is a percentage expressed
        as a fraction of 1.0, e.g. 0.425 represents 42.5%. *image_size* and
        *view_size* are each (width, height) pairs.
        c                    | |z  S rC    )widthheights     r   aspect_ratioz/CT_Picture._fill_cropping.<locals>.aspect_ratio   s    6>!r   g      ?g       @        )rZ   rZ   rZ   rZ   rV   )r   r   r   rY   ar_viewar_imager   s          r   r   zCT_Picture._fill_cropping   sv    	" 	*,X7X-.#5D#tS))X8g-.#5DsD))#r   c                "    dt        ddd      z  S )Na=  <p:pic %s>
  <p:nvPicPr>
    <p:cNvPr id="%%d" name="%%s" descr="%%s"/>
    <p:cNvPicPr>
      <a:picLocks noGrp="1" noChangeAspect="1"/>
    </p:cNvPicPr>
    <p:nvPr/>
  </p:nvPicPr>
  <p:blipFill>
    <a:blip r:embed="%%s"/>
    <a:stretch>
      <a:fillRect/>
    </a:stretch>
  </p:blipFill>
  <p:spPr/>
</p:pic>parM   r   r'   s    r   r&   zCT_Picture._pic_ph_tmpl   s     !c3/0	
r   c                "    dt        ddd      z  S )Na  <p:pic %s>
  <p:nvPicPr>
    <p:cNvPr id="%%d" name="%%s" descr="%%s"/>
    <p:cNvPicPr>
      <a:picLocks noChangeAspect="1"/>
    </p:cNvPicPr>
    <p:nvPr/>
  </p:nvPicPr>
  <p:blipFill>
    <a:blip r:embed="%%s"/>
    <a:stretch>
      <a:fillRect/>
    </a:stretch>
  </p:blipFill>
  <p:spPr>
    <a:xfrm>
      <a:off x="%%d" y="%%d"/>
      <a:ext cx="%%d" cy="%%d"/>
    </a:xfrm>
    <a:prstGeom prst="rect">
      <a:avLst/>
    </a:prstGeom>
  </p:spPr>
</p:pic>r_   r^   rM   r   r`   s    r   r.   zCT_Picture._pic_tmpl   s    . !c3//0	
r   c                "    dt        ddd      z  S )Na  <p:pic %s>
  <p:nvPicPr>
    <p:cNvPr id="%%d" name="%%s">
      <a:hlinkClick r:id="" action="ppaction://media"/>
    </p:cNvPr>
    <p:cNvPicPr>
      <a:picLocks noChangeAspect="1"/>
    </p:cNvPicPr>
    <p:nvPr>
      <a:videoFile r:link="%%s"/>
      <p:extLst>
        <p:ext uri="{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}">
          <p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="%%s"/>
        </p:ext>
      </p:extLst>
    </p:nvPr>
  </p:nvPicPr>
  <p:blipFill>
    <a:blip r:embed="%%s"/>
    <a:stretch>
      <a:fillRect/>
    </a:stretch>
  </p:blipFill>
  <p:spPr>
    <a:xfrm>
      <a:off x="%%d" y="%%d"/>
      <a:ext cx="%%d" cy="%%d"/>
    </a:xfrm>
    <a:prstGeom prst="rect">
      <a:avLst/>
    </a:prstGeom>
  </p:spPr>
</p:pic>r_   r^   rM   r   r`   s    r   r6   zCT_Picture._pic_video_tmpl   s!    !B !c3/C!0#	
r   c                L    | j                   j                  }|yt        ||      S )zU
        Value of `p:blipFill/a:srcRect/@{attr_name}` or 0.0 if not present.
        rZ   )r   srcRectgetattr)r   	attr_namerd   s      r   r?   zCT_Picture._srcRect_x   s(     --''?w	**r   N)returnz
str | None)r/   intr7   strr8   ri   r9   ri   r:   ri   r0   r   r1   r   r2   r   r3   r   rg   r   )__name__
__module____qualname____doc__r   nvPicPrr   r   __annotations__propertyr   r   r!   r$   classmethodr,   r4   r;   r@   setterrJ   rN   rR   r   r&   r.   r6   r?   rV   r   r   r   r      s   
 K(G\*H,X6D
6 G)   F F ^ ^ 

 
 	

 
 
 
 
 
 
 

 
> $ $ 5 5 $ $ 5 5 $ $ 5 5 $ $ 5 5$. 
 
( 
 
8 $
 $
L+r   r   c                  0    e Zd ZdZ ed      Z ed      Zy)CT_PictureNonVisualz\
    ``<p:nvPicPr>`` element, containing non-visual properties for a picture
    shape.
    zp:cNvPrzp:nvPrN)rj   rk   rl   rm   r   cNvPrnvPrrV   r   r   rt   rt     s    
 )$E"Dr   rt   N)rm   
__future__r   typingr   r   xml.sax.saxutilsr   	pptx.oxmlr   pptx.oxml.nsr	   pptx.oxml.shapes.sharedr
   pptx.oxml.xmlchemyr   r   r   	pptx.utilr   r   rt   rV   r   r   <module>r      sB    C " & #    4 =: r+! r+j#/ #r   