
    h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dS )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d)S ),
CT_PicturezV`p:pic` element.

    Represents a picture shape (an image placement on a slide).
    z	p:nvPicPrz
p:blipFillzp:spPrr   spPrreturn
str | Nonec                >    | j         j        }||j        |j        S dS )zWValue of `p:blipFill/a:blip/@r:embed`.

        Returns |None| if not present.
        N)blipFillbliprEmbed)selfr   s     p/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/pptx/oxml/shapes/picture.pyblip_rIdzCT_Picture.blip_rId   s(     }! 7;t    c                b    | j                             |                     ||                     dS )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'   s0     	4..z9EEFFFFFr   c                4    | 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     y&&(((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    
 y|r   c                R    t          |                                 ||||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EEr   c	                t    t          |                                 ||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   s9     HdF4LL#qRSUWY[+\\]]]r   r1   int
shape_namestr	video_rId	media_rIdposter_frame_rIdr2   r   r3   r4   r5   c
                    t          t          t          |                                 |||||||||	f	z                      S )z8Return a new `p:pic` populated with the specified video.)r   r   r   _pic_video_tmpl)
r)   r1   r8   r:   r;   r<   r2   r3   r4   r5   s
             r   new_video_piczCT_Picture.new_video_picI   sZ     ##%%$
 
 
 	
r   c                ,    |                      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                                         _        d S N)r   get_or_add_srcRectrA   r   values     r   rD   zCT_Picture.srcRect_bn       /4((**,,,r   c                ,    |                      d          S )z9Value of `p:blipFill/a:srcRect/@l` or 0.0 if not present.lrB   r$   s    r   	srcRect_lzCT_Picture.srcRect_lr   rE   r   c                B    || j                                         _        d S rG   )r   rH   rM   rI   s     r   rN   zCT_Picture.srcRect_lw   rK   r   c                ,    |                      d          S )z9Value of `p:blipFill/a:srcRect/@r` or 0.0 if not present.rrB   r$   s    r   	srcRect_rzCT_Picture.srcRect_r{   rE   r   c                B    || j                                         _        d S rG   )r   rH   rQ   rI   s     r   rR   zCT_Picture.srcRect_r   rK   r   c                ,    |                      d          S )z9Value of `p:blipFill/a:srcRect/@t` or 0.0 if not present.trB   r$   s    r   	srcRect_tzCT_Picture.srcRect_t   rE   r   c                B    || j                                         _        d S rG   )r   rH   rU   rI   s     r   rV   zCT_Picture.srcRect_t   rK   r   c                |    d } || } || }||k     rd||z  z
  dz  }|d|dfS ||k    rd||z  z
  dz  }d|d|fS dS )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 rG    )widthheights     r   aspect_ratioz/CT_Picture._fill_cropping.<locals>.aspect_ratio   s    6>!r   g      ?g       @        )r^   r^   r^   r^   rZ   )r   r   r    r]   ar_viewar_imager   s          r   r   zCT_Picture._fill_cropping   s    	" 	" 	" ,	*<,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arQ   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>rc   rb   rQ   r   rd   s    r   r0   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>rc   rb   rQ   r   rd   s    r   r>   zCT_Picture._pic_video_tmpl   s$    !B !c3//C!0#	
r   c                B    | j         j        }|dS t          ||          S )zU
        Value of `p:blipFill/a:srcRect/@{attr_name}` or 0.0 if not present.
        Nr^   )r   srcRectgetattr)r   	attr_namerh   s      r   rC   zCT_Picture._srcRect_x   s(     -'?3w	***r   N)r   r   )r1   r7   r8   r9   r:   r9   r;   r9   r<   r9   r2   r   r3   r   r4   r   r5   r   r   r   )__name__
__module____qualname____doc__r   nvPicPrr   r   __annotations__propertyr   r!   r#   r&   classmethodr.   r6   r?   rD   setterrN   rR   rV   r   r(   r0   r>   rC   rZ   r   r   r   r      si         
 mK((G}\**H,}X66D6666   XG G G) ) )   X F F [F ^ ^ [^ 
 
 
 [
> $ $ X$ 5 5 5 $ $ X$ 5 5 5 $ $ X$ 5 5 5 $ $ X$ 5 5 5$ $ $. 
 
 [
( 
 
 [
8 $
 $
 [$
L+ + + + +r   r   c                  >    e Zd ZdZ ed          Z ed          ZdS )CT_PictureNonVisualz\
    ``<p:nvPicPr>`` element, containing non-visual properties for a picture
    shape.
    zp:cNvPrzp:nvPrN)rk   rl   rm   rn   r   cNvPrnvPrrZ   r   r   ru   ru     s8         
 M)$$E=""DDDr   ru   N)rn   
__future__r   typingr   r   xml.sax.saxutilsr   	pptx.oxmlr   pptx.oxml.nsr	   pptx.oxml.shapes.sharedr
   pptx.oxml.xmlchemyr   r   r   	pptx.utilr   r   ru   rZ   r   r   <module>r      s)   C C " " " " " " & & & & & & & & # # # # # #                   4 4 4 4 4 4 = = = = = = = = !::::::      r+ r+ r+ r+ r+! r+ r+ r+j# # # # #/ # # # # #r   