o
    j6                     @  sd  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mZmZmZ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mZmZ dd	lm Z  erhdd
l!m"Z" ddl#m$Z$m%Z% 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/dS ) z"Common shape-related oxml objects.    )annotations)TYPE_CHECKINGCallable)CT_GradientFillProperties)PP_PLACEHOLDER)qn)
ST_AngleST_CoordinateST_DirectionST_DrawingElementIdST_LineWidthST_PlaceholderSizeST_PositiveCoordinate
XsdBoolean	XsdStringXsdUnsignedInt)BaseOxmlElementChoiceOptionalAttributeOxmlElementRequiredAttribute	ZeroOrOneZeroOrOneChoice)Emu)CT_Hyperlink)CT_CustomGeometry2DCT_PresetGeometry2D)Lengthc                   @  s  e Zd ZU dZded< ed?ddZejdd Zed?d	d
Zejdd
 Zedd Z	e	jdd Z	edd Z
e
jdd Z
dd Zedd Zed@ddZedAddZedBddZedBdd Zed!d" ZedCd$d%ZejdDd'd%Zed(d) Zed*d+ Zed,d- Zed?d.d/Zejd0d/ Zed1d2 Zed?d3d4Zejd5d4 Zed6d7 ZdEd:d;Zd<d= Zd>S )FBaseShapeElementzRProvides common behavior for shape element classes like CT_Shape, CT_Picture, etc.CT_ShapePropertiesspPrreturnr   c                 C  
   |  dS Ncx_get_xfrm_attrself r)   W/home/air/Certificate/back/venv/lib/python3.10/site-packages/pptx/oxml/shapes/shared.pyr$   ,      
zBaseShapeElement.cxc                 C     |  d| d S r#   _set_xfrm_attrr(   valuer)   r)   r*   r$   0      c                 C  r"   Ncyr%   r'   r)   r)   r*   r3   4   r+   zBaseShapeElement.cyc                 C  r,   r2   r-   r/   r)   r)   r*   r3   8   r1   c                 C     t | dS NflipHboolr&   r'   r)   r)   r*   r6   <      zBaseShapeElement.flipHc                 C  r,   r5   r-   r/   r)   r)   r*   r6   @   r1   c                 C  r4   NflipVr7   r'   r)   r)   r*   r;   D   r9   zBaseShapeElement.flipVc                 C  r,   r:   r-   r/   r)   r)   r*   r;   H   r1   c                 C  s
   | j  S )zReturn the `a:xfrm` grandchild element, newly-added if not present.

        This version works for `p:sp`, `p:cxnSp`, and `p:pic` elements, others will need to
        override.
        )r    get_or_add_xfrmr'   r)   r)   r*   r<   L      
z BaseShapeElement.get_or_add_xfrmc                 C  s
   | j duS )z
        True if this shape element has a `p:ph` descendant, indicating it
        is a placeholder shape. False otherwise.
        N)phr'   r)   r)   r*   
has_ph_elmT   r=   zBaseShapeElement.has_ph_elmCT_Placeholder | Nonec                 C  s"   |  d}t|dkrdS |d S )z>The `p:ph` descendant element if there is one, None otherwise.z./*[1]/p:nvPr/p:phr   N)xpathlen)r(   ph_elmsr)   r)   r*   r>   \   s   
zBaseShapeElement.phintc                 C     | j }|du rtd|jS )zpInteger value of placeholder idx attribute.

        Raises |ValueError| if shape is not a placeholder.
        Nnot a placeholder shape)r>   
ValueErroridxr(   r>   r)   r)   r*   ph_idxd      zBaseShapeElement.ph_idxstrc                 C  rE   )zjPlaceholder orientation, e.g. 'vert'.

        Raises |ValueError| if shape is not a placeholder.
        NrF   )r>   rG   orientrI   r)   r)   r*   	ph_oriento   rK   zBaseShapeElement.ph_orientc                 C  rE   )ztPlaceholder size, e.g. ST_PlaceholderSize.HALF.

        Raises `ValueError` if shape is not a placeholder.
        NrF   )r>   rG   szrI   r)   r)   r*   ph_szz   rK   zBaseShapeElement.ph_szc                 C  rE   )zPlaceholder type, e.g. ST_PlaceholderType.TITLE ('title').

        Raises `ValueError` if shape is not a placeholder.
        NrF   )r>   rG   typerI   r)   r)   r*   ph_type   rK   zBaseShapeElement.ph_typefloatc                 C  s"   | j }|du s|jdu rdS |jS )z;Float representing degrees this shape is rotated clockwise.N        )xfrmrot)r(   rU   r)   r)   r*   rV      s   zBaseShapeElement.rotr0   c                 C  s   ||   _d S N)r<   rV   r/   r)   r)   r*   rV      r9   c                 C  
   | j jjS )z*
        Integer id of this shape
        )_nvXxPrcNvPridr'   r)   r)   r*   shape_id      
zBaseShapeElement.shape_idc                 C  rX   )z$
        Name of this shape
        )rY   rZ   namer'   r)   r)   r*   
shape_name   r]   zBaseShapeElement.shape_namec                 C  s   |  tdS )z.Child `p:txBody` element, None if not present.zp:txBody)findr   r'   r)   r)   r*   txBody   s   zBaseShapeElement.txBodyc                 C  r"   Nxr%   r'   r)   r)   r*   rc      r+   zBaseShapeElement.xc                 C  r,   rb   r-   r/   r)   r)   r*   rc      r1   c                 C  s   | j jS )zThe `a:xfrm` grandchild element or |None| if not found.

        This version works for `p:sp`, `p:cxnSp`, and `p:pic` elements, others will need to
        override.
        )r    rU   r'   r)   r)   r*   rU      s   zBaseShapeElement.xfrmc                 C  r"   Nyr%   r'   r)   r)   r*   re      r+   zBaseShapeElement.yc                 C  r,   rd   r-   r/   r)   r)   r*   re      r1   c                 C  s   |  dd S )z
        Required non-visual shape properties element for this shape. Actual
        name depends on the shape type, e.g. `p:nvPicPr` for picture
        shape.
        z./*[1]r   )rA   r'   r)   r)   r*   rY      s   zBaseShapeElement._nvXxPrr^   Length | Nonec                 C  s   | j }|d u r	d S t||S rW   )rU   getattr)r(   r^   rU   r)   r)   r*   r&      s   
zBaseShapeElement._get_xfrm_attrc                 C  s   |   }t||| d S rW   )r<   setattr)r(   r^   r0   rU   r)   r)   r*   r.      s   zBaseShapeElement._set_xfrm_attrN)r!   r   )r!   r@   )r!   rD   )r!   rL   )r!   rS   )r0   rS   )r^   rL   r!   rf   )__name__
__module____qualname____doc____annotations__propertyr$   setterr3   r6   r;   r<   r?   r>   rJ   rN   rP   rR   rV   r\   r_   ra   rc   rU   re   rY   r&   r.   r)   r)   r)   r*   r   '   sp   
 



















r   c                   @  s&   e Zd ZU dZded< edddZdS )#CT_ApplicationNonVisualDrawingPropsz`p:nvPr` element.zCallable[[], CT_Placeholder]get_or_add_phzp:ph)z	a:audioCdza:wavAudioFileza:audioFileza:videoFileza:quickTimeFilezp:custDataLstzp:extLst
successorsN)ri   rj   rk   rl   rm   r   r>   r)   r)   r)   r*   rp      s   
 
rp   c                   @  s   e Zd ZdZdZeededededfedd d	Zed
edd d	Z	ededd d	Z
[edeeddZedd Zedd Zejdd ZdS )CT_LinePropertiesz'Custom element class for <a:ln> element)a:noFilla:solidFill
a:gradFill
a:pattFill
a:prstDash
a:custDashza:roundza:bevelza:miterz	a:headEndz	a:tailEnda:extLstru   rv   rw   rx      Nrr   ry      rz      wr   defaultc                 C  s   | j S )zE
        Required to fulfill the interface used by dml.fill.
        )eg_lineFillPropertiesr'   r)   r)   r*   eg_fillProperties  s   z#CT_LineProperties.eg_fillPropertiesc                 C  s   | j }|du r	dS |jS )zfReturn value of `val` attribute of `a:prstDash` child.

        Return |None| if not present.
        N)prstDashval)r(   r   r)   r)   r*   prstDash_val  s   zCT_LineProperties.prstDash_valc                 C  s   |    |  }||_d S rW   )_remove_custDashget_or_add_prstDashr   )r(   r   r   r)   r)   r*   r      s   
)ri   rj   rk   rl   _tag_seqr   r   r   r   r   custDashr   r   r   r   rn   r   r   ro   r)   r)   r)   r*   rt      s*    
	


rt   c                   @  st   e Zd ZU dZded< ded< dZededd d	Zd
ed< ededd d	Zd
ed< e	de
Ze	deZ[dS )CT_NonVisualDrawingPropsz`p:cNvPr` custom element class.zCallable[[], CT_Hyperlink]get_or_add_hlinkClickget_or_add_hlinkHover)a:hlinkClicka:hlinkHoverr{   r      Nrr   zCT_Hyperlink | None
hlinkClickr      
hlinkHoverr[   r^   )ri   rj   rk   rl   rm   r   r   r   r   r   r   r[   r   r^   r)   r)   r)   r*   r   '  s   
 

r   c                   @  sp   e Zd ZU dZedeejdZded< ede	e	j
dZded< edeejdZded< eded	dZd
ed< dS )CT_Placeholderz`p:ph` custom element class.rQ   r   r   rM   rL   rO   rH   r   rD   N)ri   rj   rk   rl   r   r   OBJECTrQ   rm   r
   HORZrM   r   FULLrO   r   rH   r)   r)   r)   r*   r   5  s   
 r   c                   @  s6   e Zd ZU dZedeZded< edeZded< dS )
CT_Point2Dz3
    Custom element class for <a:off> element.
    rc   r   re   N)	ri   rj   rk   rl   r   r	   rc   rm   re   r)   r)   r)   r*   r   F  s   
 r   c                   @  s$   e Zd ZdZedeZedeZdS )CT_PositiveSize2Dz3
    Custom element class for <a:ext> element.
    r$   r3   N)ri   rj   rk   rl   r   r   r$   r3   r)   r)   r)   r*   r   O  s    
r   c                   @  s.  e Zd ZU dZded< ded< ded< ded	< d
Zededd dZded< ededd dZded< ededd dZ	ded< e
ededededededfedd dZed ed!d dZd"ed#< ed$ed%d dZ[ed&d' Zed(d) Zed2d,d-Zed.d/ Zd0d1 ZdS )3r   zCustom element class for `p:spPr` element.

    Shared by `p:sp`, `p:cxnSp`,  and `p:pic` elements as well as a few more obscure ones.
    zCallable[[], CT_Transform2D]r<   zCallable[[], CT_LineProperties]get_or_add_lnz!Callable[[], CT_PresetGeometry2D]_add_prstGeomzCallable[[], None]_remove_custGeom)a:xfrm
a:custGeom
a:prstGeomru   rv   rw   
a:blipFillrx   	a:grpFilla:lna:effectLstza:effectDagz	a:scene3dza:sp3dr{   r   r   Nrr   zCT_Transform2D | NonerU   r   r   zCT_CustomGeometry2D | NonecustGeomr      zCT_PresetGeometry2D | NoneprstGeomru   rv   rw   r   rx   r   	   r   
   zCT_LineProperties | Nonelnr      c                 C     |  d}|s	dS t|d S )zL
        Shape width as an instance of Emu, or None if not present.
        z./a:xfrm/a:ext/@cxNr   rA   r   )r(   
cx_str_lstr)   r)   r*   r$        
zCT_ShapeProperties.cxc                 C  r   )zM
        Shape height as an instance of Emu, or None if not present.
        z./a:xfrm/a:ext/@cyNr   r   )r(   
cy_str_lstr)   r)   r*   r3     r   zCT_ShapeProperties.cyr!   rf   c                 C  r   )zkDistance between the left edge of the slide and left edge of the shape.

        0 if not present.
        z./a:xfrm/a:off/@xNr   r   )r(   	x_str_lstr)   r)   r*   rc        
zCT_ShapeProperties.xc                 C  r   )z
        The offset of the top of the shape from the top of the slide, as an
        instance of Emu. None if not present.
        z./a:xfrm/a:off/@yNr   r   )r(   	y_str_lstr)   r)   r*   re     r   zCT_ShapeProperties.yc                 C  s   t  S rW   )r   new_gradFillr'   r)   r)   r*   _new_gradFill  s   z CT_ShapeProperties._new_gradFill)r!   rf   )ri   rj   rk   rl   rm   r   r   rU   r   r   r   r   r   r   	effectLstrn   r$   r3   rc   re   r   r)   r)   r)   r*   r   X  sP   
 

	
	


r   c                   @  s  e Zd ZU dZdZededd dZded< ed	ed
d dZededd dZ	ededd dZ
[ededdZded< ededdZededdZedd Zejdd Zedd Zejdd Zedd Zejdd Zedd  Zejd!d  Zd"d# Zd$d% ZdS )&CT_Transform2Dz`a:xfrm` custom element class.

    NOTE: this is a composite including CT_GroupTransform2D, which appears
    with the `a:xfrm` tag in a group shape (including a slide `p:spTree`).
    )a:offa:exta:chOffa:chExtr   r   Nrr   zCT_Point2D | Noneoffr   r   r   r   r   r|   rV   rT   r   zfloat | Noner6   Fr;   c                 C     | j }|d u r	d S |jS rW   )r   rc   r(   r   r)   r)   r*   rc        zCT_Transform2D.xc                 C     |   }||_d S rW   )get_or_add_offrc   r(   r0   r   r)   r)   r*   rc        
c                 C  r   rW   )r   re   r   r)   r)   r*   re     r   zCT_Transform2D.yc                 C  r   rW   )r   re   r   r)   r)   r*   re     r   c                 C  r   rW   )extr$   r(   r   r)   r)   r*   r$     r   zCT_Transform2D.cxc                 C  r   rW   )get_or_add_extr$   r(   r0   r   r)   r)   r*   r$     r   c                 C  r   rW   )r   r3   r   r)   r)   r*   r3     r   zCT_Transform2D.cyc                 C  r   rW   )r   r3   r   r)   r)   r*   r3     r   c                 C     t d}d|_d|_|S )Nr   r   )r   r$   r3   r   r)   r)   r*   _new_ext     zCT_Transform2D._new_extc                 C  r   )Nr   r   )r   rc   re   r   r)   r)   r*   _new_off  r   zCT_Transform2D._new_off)ri   rj   rk   rl   r   r   r   rm   r   chOffchExtr   r   rV   r   r6   r;   rn   rc   ro   re   r$   r3   r   r   r)   r)   r)   r*   r     sB   
 







r   N)0rl   
__future__r   typingr   r   pptx.dml.fillr   pptx.enum.shapesr   pptx.oxml.nsr   pptx.oxml.simpletypesr   r	   r
   r   r   r   r   r   r   r   pptx.oxml.xmlchemyr   r   r   r   r   r   r   	pptx.utilr   pptx.oxml.actionr   pptx.oxml.shapes.autoshaper   r   r   r   rp   rt   r   r   r   r   r   r   r)   r)   r)   r*   <module>   s.    0$	 68		d