o
    	'f                     @  s  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
mZmZmZmZmZ ddlmZmZmZmZmZ er@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G dd de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 G dd de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%G d%d& d&eZ&G d'd( d(eZ'G d)d* d*eZ(d+S ),zDCustom element classes for shape-related elements like `<w:inline>`.    )annotations)TYPE_CHECKINGnsdecls)	parse_xml)ST_CoordinateST_DrawingElementIdST_PositiveCoordinateST_RelationshipId	XsdStringXsdToken)BaseOxmlElementOneAndOnlyOneOptionalAttributeRequiredAttribute	ZeroOrOne)Lengthc                   @     e Zd ZdZdS )	CT_Anchorz8`<wp:anchor>` element, container for a "floating" shape.N__name__
__module____qualname____doc__ r   r   G/home/ubuntu/flask/venv/lib/python3.10/site-packages/docx/oxml/shape.pyr          r   c                   @  $   e Zd ZdZedeZedeZdS )CT_BlipzX``<a:blip>`` element, specifies image source and adjustments such as alpha and
    tint.zr:embedzr:linkN)r   r   r   r   r   r
   embedlinkr   r   r   r   r   !   s    
r   c                   @  s   e Zd ZdZedddZdS )CT_BlipFillPropertiesz9``<pic:blipFill>`` element, specifies picture properties.za:blip)z	a:srcRectza:tilez	a:stretch
successorsN)r   r   r   r   r   blipr   r   r   r   r!   )   s    r!   c                   @     e Zd ZdZedZdS )CT_GraphicalObjectz:``<a:graphic>`` element, container for a DrawingML object.za:graphicDataN)r   r   r   r   r   graphicDatar   r   r   r   r&   /       r&   c                   @  s"   e Zd ZdZedZedeZdS )CT_GraphicalObjectDatazI``<a:graphicData>`` element, container for the XML of a DrawingML object.zpic:picuriN)	r   r   r   r   r   picr   r   r*   r   r   r   r   r)   5   s    r)   c                   @  sP   e Zd ZdZedZedZedZedddZ	edddZ
edd ZdS )	CT_Inlinez5`<wp:inline>` element, container for an inline shape.z	wp:extentzwp:docPrz	a:graphiccxr   cyshape_idintr+   
CT_Picturereturnc                 C  sL   t |  }||j_||j_||j_d| |j_d|jj	_
|jj	| |S )z\Return a new ``<wp:inline>`` element populated with the values passed as
        parameters.z
Picture %dz8http://schemas.openxmlformats.org/drawingml/2006/picture)r   _inline_xmlextentr-   r.   docPridnamegraphicr'   r*   _insert_pic)clsr-   r.   r/   r+   inliner   r   r   newC   s   zCT_Inline.newrIdstrfilenamec           	      C  s8   d}t |||||}| ||||}|jj| |S )zCreate `wp:inline` element containing a `pic:pic` element.

        The contents of the `pic:pic` element is taken from the argument values.
        r   )r1   r<   r8   r'   r9   )	r:   r/   r=   r?   r-   r.   pic_idr+   r;   r   r   r   new_pic_inlineR   s
   zCT_Inline.new_pic_inlinec                 C  s   dt dddd S )Na  <wp:inline %s>
  <wp:extent cx="914400" cy="914400"/>
  <wp:docPr id="666" name="unnamed"/>
  <wp:cNvGraphicFramePr>
    <a:graphicFrameLocks noChangeAspect="1"/>
  </wp:cNvGraphicFramePr>
  <a:graphic>
    <a:graphicData uri="URI not set"/>
  </a:graphic>
</wp:inline>wpar+   rr   r:   r   r   r   r3   `   s   	zCT_Inline._inline_xmlN)
r-   r   r.   r   r/   r0   r+   r1   r2   r,   )r/   r0   r=   r>   r?   r>   r-   r   r.   r   r2   r,   )r   r   r   r   r   r4   r5   r8   classmethodr<   rA   r3   r   r   r   r   r,   <   s    r,   c                   @  s$   e Zd ZdZedeZedeZdS )CT_NonVisualDrawingPropszpUsed for ``<wp:docPr>`` element, and perhaps others.

    Specifies the id and name of a DrawingML drawing.
    r6   r7   N)	r   r   r   r   r   r   r6   r   r7   r   r   r   r   rG   p       
rG   c                   @  r   )CT_NonVisualPicturePropertieszK``<pic:cNvPicPr>`` element, specifies picture locking and resize behaviors.Nr   r   r   r   r   rI   z   r   rI   c                   @  s@   e Zd ZdZedZedZedZedd Z	edd Z
d	S )
r1   z+``<pic:pic>`` element, a DrawingML picture.zpic:nvPicPrzpic:blipFillzpic:spPrc                 C  s>   t |  }||jj_||jj_||jj_||j	_
||j	_|S )zReturn a new ``<pic:pic>`` element populated with the minimal contents
        required to define a viable picture element, based on the values passed as
        parameters.)r   _pic_xmlnvPicPrcNvPrr6   r7   blipFillr$   r   spPrr-   r.   )r:   r@   r?   r=   r-   r.   r+   r   r   r   r<      s   


zCT_Picture.newc                 C  s   dt ddd S )Naq  <pic:pic %s>
  <pic:nvPicPr>
    <pic:cNvPr id="666" name="unnamed"/>
    <pic:cNvPicPr/>
  </pic:nvPicPr>
  <pic:blipFill>
    <a:blip/>
    <a:stretch>
      <a:fillRect/>
    </a:stretch>
  </pic:blipFill>
  <pic:spPr>
    <a:xfrm>
      <a:off x="0" y="0"/>
      <a:ext cx="914400" cy="914400"/>
    </a:xfrm>
    <a:prstGeom prst="rect"/>
  </pic:spPr>
</pic:pic>r+   rC   rD   r   rE   r   r   r   rJ      s   
zCT_Picture._pic_xmlN)r   r   r   r   r   rK   rM   rN   rF   r<   rJ   r   r   r   r   r1   ~   s    
r1   c                   @  r%   )CT_PictureNonVisualz9``<pic:nvPicPr>`` element, non-visual picture properties.z	pic:cNvPrN)r   r   r   r   r   rL   r   r   r   r   rO      r(   rO   c                   @  r   )
CT_Point2DzaUsed for ``<a:off>`` element, and perhaps others.

    Specifies an x, y coordinate (point).
    xyN)r   r   r   r   r   r   rQ   rR   r   r   r   r   rP      rH   rP   c                   @  r   )CT_PositiveSize2DzpUsed for ``<wp:extent>`` element, and perhaps others later.

    Specifies the size of a DrawingML drawing.
    r-   r.   N)r   r   r   r   r   r	   r-   r.   r   r   r   r   rS      rH   rS   c                   @  r   )CT_PresetGeometry2DzW``<a:prstGeom>`` element, specifies an preset autoshape geometry, such as
    ``rect``.Nr   r   r   r   r   rT      r   rT   c                   @  r   )CT_RelativeRectzX``<a:fillRect>`` element, specifying picture should fill containing rectangle
    shape.Nr   r   r   r   r   rU      r   rU   c                   @  sP   e Zd ZdZedddZedd Zejdd Zedd	 Z	e	jd
d	 Z	dS )CT_ShapePropertieszF``<pic:spPr>`` element, specifies size and shape of picture container.za:xfrm)z
a:custGeomz
a:prstGeomza:lnza:effectLstza:effectDagz	a:scene3dza:sp3dza:extLstr"   c                 C     | j }|du r	dS |jS )z:Shape width as an instance of Emu, or None if not present.N)xfrmr-   selfrX   r   r   r   r-         zCT_ShapeProperties.cxc                 C     |   }||_d S N)get_or_add_xfrmr-   rZ   valuerX   r   r   r   r-         
c                 C  rW   )z;Shape height as an instance of Emu, or None if not present.N)rX   r.   rY   r   r   r   r.      r[   zCT_ShapeProperties.cyc                 C  r\   r]   )r^   r.   r_   r   r   r   r.      ra   N)
r   r   r   r   r   rX   propertyr-   setterr.   r   r   r   r   rV      s    


rV   c                   @  r   )CT_StretchInfoPropertieszT``<a:stretch>`` element, specifies how picture should fill its containing
    shape.Nr   r   r   r   r   rd      r   rd   c                   @  s\   e Zd ZdZedddZedddZedd Zej	d	d Zed
d Z
e
j	dd Z
dS )CT_Transform2DzD``<a:xfrm>`` element, specifies size and shape of picture container.za:off)a:extr"   rf   r   c                 C     | j }|d u r	d S |jS r]   )extr-   rZ   rh   r   r   r   r-        zCT_Transform2D.cxc                 C  r\   r]   )get_or_add_extr-   rZ   r`   rh   r   r   r   r-     ra   c                 C  rg   r]   )rh   r.   ri   r   r   r   r.     rj   zCT_Transform2D.cyc                 C  r\   r]   )rk   r.   rl   r   r   r   r.     ra   N)r   r   r   r   r   offrh   rb   r-   rc   r.   r   r   r   r   re      s    


re   N))r   
__future__r   typingr   docx.oxml.nsr   docx.oxml.parserr   docx.oxml.simpletypesr   r   r	   r
   r   r   docx.oxml.xmlchemyr   r   r   r   r   docx.sharedr   r   r   r!   r&   r)   r,   rG   rI   r1   rO   rP   rS   rT   rU   rV   rd   re   r   r   r   r   <module>   s4     4
-

,