U
    cqe                     @  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rd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                   @  s   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   3/tmp/pip-unpacked-wheel-gx5hpqp3/docx/oxml/shape.pyr      s   r   c                   @  s$   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                   @  s   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"   /   s   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                   @  sj   e Zd ZdZedZedZedZeddddd dd	d
Z	edddddd 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:graphicr   int
CT_Picture)cxcyshape_idr&   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str)r,   rIdfilenamer*   r+   r-   c           	      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   )r)   r7   r3   r#   r4   )	r5   r,   r9   r:   r*   r+   pic_idr&   r6   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>Zwpar&   rr   r5   r   r   r   r.   `   s    	zCT_Inline._inline_xmlN)r   r   r   r   r   r/   r0   r3   classmethodr7   r<   r.   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.
    r1   r2   N)	r   r   r   r   r   r   r1   r   r2   r   r   r   r   rA   p   s   
rA   c                   @  s   e Zd ZdZdS )CT_NonVisualPicturePropertieszK``<pic:cNvPicPr>`` element, specifies picture locking and resize behaviors.Nr   r   r   r   r   rB   z   s   rB   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 )
r)   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cNvPrr1   r2   blipFillr!   r   spPrr*   r+   )r5   r;   r:   r9   r*   r+   r&   r   r   r   r7      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&   r=   r>   r   r?   r   r   r   rC      s    
zCT_Picture._pic_xmlN)r   r   r   r   r   rD   rF   rG   r@   r7   rC   r   r   r   r   r)   ~   s   
r)   c                   @  s   e Zd ZdZedZdS )CT_PictureNonVisualz9``<pic:nvPicPr>`` element, non-visual picture properties.z	pic:cNvPrN)r   r   r   r   r   rE   r   r   r   r   rH      s   rH   c                   @  s$   e Zd ZdZedeZedeZdS )
CT_Point2DzaUsed for ``<a:off>`` element, and perhaps others.

    Specifies an x, y coordinate (point).
    xyN)r   r   r   r   r   r   rJ   rK   r   r   r   r   rI      s   
rI   c                   @  s$   e Zd ZdZedeZedeZdS )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   rL      s   
rL   c                   @  s   e Zd ZdZdS )CT_PresetGeometry2DzW``<a:prstGeom>`` element, specifies an preset autoshape geometry, such as
    ``rect``.Nr   r   r   r   r   rM      s   rM   c                   @  s   e Zd ZdZdS )CT_RelativeRectzX``<a:fillRect>`` element, specifying picture should fill containing rectangle
    shape.Nr   r   r   r   r   rN      s   rN   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  s   | j }|dkrdS |jS )z:Shape width as an instance of Emu, or None if not present.N)xfrmr*   selfrP   r   r   r   r*      s    zCT_ShapeProperties.cxc                 C  s   |   }||_d S N)get_or_add_xfrmr*   rR   valuerP   r   r   r   r*      s    c                 C  s   | j }|dkrdS |jS )z;Shape height as an instance of Emu, or None if not present.N)rP   r+   rQ   r   r   r   r+      s    zCT_ShapeProperties.cyc                 C  s   |   }||_d S rS   )rT   r+   rU   r   r   r   r+      s    N)
r   r   r   r   r   rP   propertyr*   setterr+   r   r   r   r   rO      s   


rO   c                   @  s   e Zd ZdZdS )CT_StretchInfoPropertieszT``<a:stretch>`` element, specifies how picture should fill its containing
    shape.Nr   r   r   r   r   rY      s   rY   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   r[   r   c                 C  s   | j }|d krd S |jS rS   )extr*   rR   r\   r   r   r   r*     s    zCT_Transform2D.cxc                 C  s   |   }||_d S rS   )get_or_add_extr*   rR   rV   r\   r   r   r   r*     s    c                 C  s   | j }|d krd S |jS rS   )r\   r+   r]   r   r   r   r+     s    zCT_Transform2D.cyc                 C  s   |   }||_d S rS   )r^   r+   r_   r   r   r   r+     s    N)r   r   r   r   r   offr\   rW   r*   rX   r+   r   r   r   r   rZ      s   


rZ   N))r   
__future__r   typingr   Zdocx.oxml.nsr   Zdocx.oxml.parserr   Zdocx.oxml.simpletypesr   r   r	   r
   r   r   Zdocx.oxml.xmlchemyr   r   r   r   r   Zdocx.sharedr   r   r   r   r"   r$   r'   rA   rB   r)   rH   rI   rL   rM   rN   rO   rY   rZ   r   r   r   r   <module>   s2    4
-

,