o
    uTg                     @   s\  d 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 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 )'zG
Custom element classes for shape-related elements like ``<w:inline>``
   )	parse_xmlnsdecls)ST_CoordinateST_DrawingElementIdST_PositiveCoordinateST_RelationshipId	XsdStringXsdToken)BaseOxmlElementOneAndOnlyOneOptionalAttributeRequiredAttribute	ZeroOrOnec                   @   $   e Zd ZdZedeZedeZdS )CT_Blipzb
    ``<a:blip>`` element, specifies image source and adjustments such as
    alpha and tint.
    zr:embedzr:linkN)__name__
__module____qualname____doc__r   r   embedlink r   r   ?D:\Projects\ConvertPro\env\Lib\site-packages\docx\oxml\shape.pyr          
r   c                   @   s   e Zd ZdZedddZdS )CT_BlipFillPropertieszB
    ``<pic:blipFill>`` element, specifies picture properties
    za:blip)z	a:srcRectza:tilez	a:stretchZ
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_GraphicalObjectzC
    ``<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_GraphicalObjectDatazR
    ``<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"   ,   s    r"   c                   @   sL   e Zd ZdZedZedZedZedd Z	edd Z
ed	d
 ZdS )	CT_Inlinez@
    ``<w:inline>`` element, container for an inline shape.
    z	wp:extentzwp:docPrz	a:graphicc                 C   sL   t |  }||j_||j_||j_d| |j_d|jj	_
|jj	| |S )zn
        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extentcxcydocPridnamegraphicr    r#   _insert_pic)clsr(   r)   shape_idr$   inliner   r   r   new<   s   zCT_Inline.newc           	      C   s8   d}t |||||}| ||||}|jj| |S )z}
        Return a new `wp:inline` element containing the `pic:pic` element
        specified by the argument values.
            )
CT_Picturer2   r-   r    r.   )	r/   r0   rIdfilenamer(   r)   pic_idr$   r1   r   r   r   new_pic_inlineM   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   r/   r   r   r   r&   Y   s   	zCT_Inline._inline_xmlN)r   r   r   r   r   r'   r*   r-   classmethodr2   r8   r&   r   r   r   r   r%   4   s    

r%   c                   @   s$   e Zd ZdZedeZedeZdS )CT_NonVisualDrawingPropszt
    Used for ``<wp:docPr>`` element, and perhaps others. Specifies the id and
    name of a DrawingML drawing.
    r+   r,   N)	r   r   r   r   r   r   r+   r	   r,   r   r   r   r   r=   i   r   r=   c                   @      e Zd ZdZdS )CT_NonVisualPicturePropertieszY
    ``<pic:cNvPicPr>`` element, specifies picture locking and resize
    behaviors.
    Nr   r   r   r   r   r   r   r   r?   r       r?   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 )
r4   z4
    ``<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 )z
        Return 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cNvPrr+   r,   blipFillr   r   spPrr(   r)   )r/   r7   r6   r5   r(   r)   r$   r   r   r   r2      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$   r9   r:   r   r;   r   r   r   rB      s   
zCT_Picture._pic_xmlN)r   r   r   r   r   rC   rE   rF   r<   r2   rB   r   r   r   r   r4   y   s    
r4   c                   @   r   )CT_PictureNonVisualzB
    ``<pic:nvPicPr>`` element, non-visual picture properties
    z	pic:cNvPrN)r   r   r   r   r   rD   r   r   r   r   rG      r!   rG   c                   @   r   )
CT_Point2Dze
    Used for ``<a:off>`` element, and perhaps others. Specifies an x, y
    coordinate (point).
    xyN)r   r   r   r   r   r   rI   rJ   r   r   r   r   rH      r   rH   c                   @   r   )CT_PositiveSize2Dzt
    Used 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   rK      r   rK   c                   @   r>   )CT_PresetGeometry2Dza
    ``<a:prstGeom>`` element, specifies an preset autoshape geometry, such
    as ``rect``.
    Nr@   r   r   r   r   rL      rA   rL   c                   @   r>   )CT_RelativeRectzb
    ``<a:fillRect>`` element, specifying picture should fill containing
    rectangle shape.
    Nr@   r   r   r   r   rM      rA   rM   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_ShapePropertieszP
    ``<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 )zL
        Shape width as an instance of Emu, or None if not present.
        N)xfrmr(   selfrP   r   r   r   r(         zCT_ShapeProperties.cxc                 C      |   }||_d S N)get_or_add_xfrmr(   rR   valuerP   r   r   r   r(         
c                 C   rO   )zM
        Shape height as an instance of Emu, or None if not present.
        N)rP   r)   rQ   r   r   r   r)      rS   zCT_ShapeProperties.cyc                 C   rT   rU   )rV   r)   rW   r   r   r   r)      rY   N)
r   r   r   r   r   rP   propertyr(   setterr)   r   r   r   r   rN      s    
	

	rN   c                   @   r>   )CT_StretchInfoPropertiesz^
    ``<a:stretch>`` element, specifies how picture should fill its containing
    shape.
    Nr@   r   r   r   r   r\      rA   r\   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_Transform2DzN
    ``<a:xfrm>`` element, specifies size and shape of picture container.
    za:off)a:extr   r^   r   c                 C      | j }|d u r	d S |jS rU   )extr(   rR   r`   r   r   r   r(        zCT_Transform2D.cxc                 C   rT   rU   )get_or_add_extr(   rR   rX   r`   r   r   r   r(     rY   c                 C   r_   rU   )r`   r)   ra   r   r   r   r)     rb   zCT_Transform2D.cyc                 C   rT   rU   )rc   r)   rd   r   r   r   r)     rY   N)r   r   r   r   r   offr`   rZ   r(   r[   r)   r   r   r   r   r]      s    


r]   N)"r    r   nsr   Zsimpletypesr   r   r   r   r	   r
   Zxmlchemyr   r   r   r   r   r   r   r   r"   r%   r=   r?   r4   rG   rH   rK   rL   rM   rN   r\   r]   r   r   r   r   <module>   s*    		5	0		(