
    ,h                         d 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
 ddlmZmZ  G d d	e
      Z G d
 de      Zy)z=lxml custom element classes for picture-related XML elements.    )division)escape)	parse_xmlnsdecls)BaseShapeElement)BaseOxmlElementOneAndOnlyOnec                      e Zd ZdZ ed      Z ed      Z ed      Zed        Z	d Z
d Zed        Zed	        Zed
        Ze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: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     Z/var/www/html/Resume-Scraper/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.
        )spPr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.ln2   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_pic9   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_picA   s4     MMOxvd|S!QBOO
 	
r   c
                 L    t        | j                         |||||||||	f	z        S )z8Return a new `p:pic` populated with the specified video.)r   _pic_video_tmpl)
r#   r+   
shape_name	video_rId	media_rIdposter_frame_rIdr,   r-   r.   r/   s
             r   new_video_piczCT_Picture.new_video_picH   sB    
 ! 

 	
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_b\        s##r   c                 B    || j                   j                         _        y N)r   get_or_add_srcRectr9   r   values     r   r<   zCT_Picture.srcRect_ba       /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_le   r=   r   c                 B    || j                   j                         _        y r?   )r   r@   rE   rA   s     r   rF   zCT_Picture.srcRect_lj   rC   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_rn   r=   r   c                 B    || j                   j                         _        y r?   )r   r@   rI   rA   s     r   rJ   zCT_Picture.srcRect_rs   rC   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_tw   r=   r   c                 B    || j                   j                         _        y r?   )r   r@   rM   rA   s     r   rN   zCT_Picture.srcRect_t|   rC   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 r?    )widthheights     r   aspect_ratioz/CT_Picture._fill_cropping.<locals>.aspect_ratio   s    6>!r   g      ?g       @        )rV   rV   rV   rV   rR   )r   r   r   rU   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arI   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[   rZ   rI   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[   rZ   rI   r   r\   s    r   r2   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.
        rV   )r   srcRectgetattr)r   	attr_namer`   s      r   r;   zCT_Picture._srcRect_x   s(     --''?w	**r   N)__name__
__module____qualname____doc__r
   nvPicPrr   r   propertyr   r   r   r    classmethodr(   r0   r7   r<   setterrF   rJ   rN   r   r"   r*   r2   r;   rR   r   r   r   r      s   
 K(G\*H"D 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)rc   rd   re   rf   r
   cNvPrnvPrrR   r   r   rl   rl      s    
 )$E"Dr   rl   N)rf   
__future__r   xml.sax.saxutilsr   	pptx.oxmlr   pptx.oxml.nsr   pptx.oxml.shapes.sharedr   pptx.oxml.xmlchemyr	   r
   r   rl   rR   r   r   <module>ru      s9    D  #    4 =h+! h+V#/ #r   